Hall C ROOT/C++ Analyzer (hcana)
Loading...
Searching...
No Matches
THcHitList.cxx
Go to the documentation of this file.
1// Remove this line to restore missing ADC reference time messages
11#include "THcHitList.h"
12#include "TError.h"
13#include "TClass.h"
14
15#include "THcConfigEvtHandler.h"
16#include "THcRawAdcHit.h"
17#include "THaGlobals.h"
18#include "THcGlobals.h"
19#include "THcParmList.h"
20#include "TList.h"
21
22#include <cassert>
23
24using namespace std;
25
26#define SUPPRESSMISSINGADCREFTIMEMESSAGES 1
28 : fNRawHits(0)
29 , fNMaxRawHits(0)
30 , fTDC_RefTimeCut(0)
31 , fADC_RefTimeCut(0)
32 , fTDC_RefTimeBest(false)
33 , fADC_RefTimeBest(false)
34 , fRawHitList(nullptr)
35 , fRawHitClass(nullptr)
36 , fdMap(nullptr)
37 , fNRefIndex(0)
38 , fNSignals(0)
39 , fSignalTypes(nullptr)
40 , fPSE125(nullptr)
41 , fHaveFADCInfo(false)
42 , fNSA(-1)
43 , fNSB(-1)
44 , fNPED(-1)
45 , fNTDCRef_miss(0)
46 , fNADCRef_miss(0)
47 , fMap(nullptr)
48 , fTISlot(0)
49 , fTICrate(0)
50 , fDisableSlipCorrection(false)
51{
53}
54
57 delete fRawHitList;
58 delete [] fSignalTypes;
59}
60
73/* InitHitList should make a list of ROCs that have FADCs in them. (Probably
74just one.) It then needs to figure out where the TI is and make sure
75the decoder is setup for pulling out the event time.
76
77Do we need to somehow configure this in the Hall C style map file. Is there
78a method to ask the OO decoder what kind of module is in a given slot?
79
80*/
81
83 const char *hitclass, Int_t maxhits,
84 Int_t tdcref_cut, Int_t adcref_cut) {
85 cout << "InitHitList: " << hitclass << " RefTimeCuts: " << tdcref_cut << " " << adcref_cut << endl;
86 fRawHitList = new TClonesArray(hitclass, maxhits);
88 fNMaxRawHits = maxhits;
89 fNRawHits = 0;
90
91 if(tdcref_cut >= 0) {
93 fTDC_RefTimeCut = tdcref_cut;
94 } else {
96 fTDC_RefTimeCut = -tdcref_cut;
97 }
98 if(adcref_cut >= 0) {
100 fADC_RefTimeCut = adcref_cut;
101 } else {
103 fADC_RefTimeCut = -adcref_cut;
104 }
105
106 for(Int_t i=0;i<maxhits;i++) {
108 }
109 // Query a raw hit object to see what kind of data to deliver
110 auto* rawhit = (THcRawHit*) (*fRawHitList)[0];
111 fNSignals = rawhit->GetNSignals();
113 for(UInt_t isig=0;isig<fNSignals;isig++) {
114 fSignalTypes[isig] = rawhit->GetSignalType(isig);
115 }
116
117 fdMap = detmap;
118
119 /* Pull out all the reference channels */
120 fNRefIndex = 0;
121 fRefIndexMaps.clear();
122 fRefIdxDefined.clear();
123 /* Find the biggest refindex */
124 for (UInt_t i=0; i < fdMap->GetSize(); i++) {
126 if(d->plane >= 1000) {
127 auto refindex = static_cast<Int_t>(d->signal);
128 if( refindex >= fNRefIndex) {
129 fNRefIndex = refindex + 1;
130 }
131 }
132 }
133 // Create the vector
135 fRefIdxDefined.reserve(fNRefIndex/10);
136 // Put the refindex mapping information in the vector
137 for( UInt_t i = 0; i < fdMap->GetSize(); i++ ) {
139 if( d->plane >= 1000 ) { // This is a reference time definition
140 auto refindex = static_cast<Int_t>(d->signal); // Really an Int_t
141 if( refindex >= 0 ) {
142 auto& theMap = fRefIndexMaps[refindex];
143 theMap.crate = d->crate;
144 theMap.slot = d->slot;
145 theMap.channel = d->lo;
146 theMap.defined = kTRUE;
147 fRefIdxDefined.push_back(refindex);
148 } else {
149 cout << "Hitlist: Invalid refindex mapping" << endl;
150 }
151 }
152 }
153 // Loop to check that requested refindex's are defined
154 // and that signal #'s are in range
155 for( UInt_t i = 0; i < fdMap->GetSize(); i++ ) {
157 Int_t refindex = d->refindex;
158 if( d->plane < 1000 ) {
159 if( d->signal >= fNSignals ) {
160 cout << "Invalid signal " << d->signal << " for " <<
161 " (" << d->crate << ", " << d->slot <<
162 ", " << d->lo << ")" << endl;
163 }
164 if( refindex >= 0 ) {
165 if( !fRefIndexMaps[refindex].defined ) {
166 cout << "Refindex " << refindex << " not defined for " <<
167 " (" << d->crate << ", " << d->slot <<
168 ", " << d->lo << ")" << endl;
169 }
170 }
171 }
172 }
173
174 // Find the Event 125 handler
176 while (lnk) {
177 if(strcmp(lnk->GetObject()->ClassName(),"THcConfigEvtHandler")==0) {
178 break;
179 }
180 lnk = lnk->Next();
181 }
182 fPSE125 = lnk ? dynamic_cast<THcConfigEvtHandler*>(lnk->GetObject()) : nullptr;
183 if( !fPSE125 ) {
184 cout << "THcHitList::InitHitList : Prestart event 125 not found." << endl;
185 }
187
188 fNTDCRef_miss = 0;
189 fNADCRef_miss = 0;
190
191 // DisableSlipCorrection();
192}
193
205Int_t THcHitList::DecodeToHitList( const THaEvData& evdata, Bool_t suppresswarnings )
206{
208 fTISlot = -1;
209
210 else if( !fMap ) { // Find the TI slot for ADCs
211 // Assumes that all FADCs are in the same crate
212 //cout << "Got the Crate map" << endl;
213 fMap = evdata.GetCrateMap();
214 for( UInt_t i = 0; i < fdMap->GetSize(); i++ ) { // Look for a FADC250
216 auto* isfadc = dynamic_cast<Decoder::Fadc250Module*>(evdata.GetModule(d->crate, d->slot));
217 if( isfadc ) {
218 // Scan this crate to find the TI.
219 for( UInt_t slot = 0; slot < Decoder::MAXSLOT; slot++ ) {
220 if( fMap->getModel(d->crate, slot) == 4 ) {
221 fTISlot = slot;
222 fTICrate = d->crate;
223 //cout << "TI Slot = " << fTISlot << endl;
224 break;
225 }
226 }
227 // Now make a map of all the FADCs in this crate
228 if( fTISlot > 0 ) {
229 for( UInt_t slot = 0; slot < Decoder::MAXSLOT; slot++ ) {
230 auto* fadc = dynamic_cast<Decoder::Fadc250Module*>(evdata.GetModule(d->crate, slot));
231 if( fadc ) {
232 fFADCSlotMap[slot] = fadc;
233 }
234 }
235 }
236 break;
237 }
238 }
239 }
240
241 UInt_t titime = 0;
242 Bool_t TI_TRIGGER_TIME_FOUND = kFALSE;
243 if( fTISlot > 0 ) {
244 const UInt_t FUDGE = 7;
245 if( evdata.GetNumHits(fTICrate, fTISlot, 2) > 0 ) {
246 TI_TRIGGER_TIME_FOUND = kTRUE;
247 titime = evdata.GetData(fTICrate, fTISlot, 2, 0);
248 if( titime >= FUDGE )
249 titime -= FUDGE;
250 else {
251 Warning(Here("DecodeToHitList"),
252 "Invalid TI time %u - %u < 0 for crate/slot = %d/%d",
253 titime, FUDGE, fTICrate, fTISlot);
254 titime = 0;
255 }
256 // Need to get the FADC time for all modules in this crate
257 // that have hits. Make a map with these times.
258 fTrigTimeShiftMap.clear();
259 }
260 }
261
262 // cout << " Clearing TClonesArray " << endl;
263 fRawHitList->Clear( );
264 fNRawHits = 0;
265 Bool_t tdcref_miss = kFALSE;
266 Bool_t adcref_miss = kFALSE;
267
268 // Get the indexed reference times for this event
269 for( auto i: fRefIdxDefined ) {
270 assert(fRefIndexMaps[i].defined); // else bug in InitHitList
271 auto& theMap = fRefIndexMaps[i];
272
273 if( evdata.IsMultifunction(theMap.crate, theMap.slot) ) {
274 // Multifunction module (e.g. FADC)
275 Int_t timeshift = 0;
276 if( fTISlot > 0 && TI_TRIGGER_TIME_FOUND ) { // Get the trigger time for this module
277 auto ishift = fTrigTimeShiftMap.find(theMap.slot);
278 if( ishift == fTrigTimeShiftMap.end() ) {
279 auto ifadc = fFADCSlotMap.find(theMap.slot);
280 if( ifadc != fFADCSlotMap.end() ) {
281 timeshift = fTrigTimeShiftMap[theMap.slot] =
282 static_cast<Int_t>(ifadc->second->GetTriggerTime() - titime);
283 }
284 } else {
285 timeshift = ishift->second;
286 }
287 }
288 theMap.hashit = kFALSE;
289 Bool_t goodreftime = kFALSE;
290 Int_t reftime = 0;
291 Int_t prevtime = 0;
292 Int_t difftime = 0;
293 // Make sure there is at least one pulse
294 UInt_t nrefhits = evdata.GetNumEvents(Decoder::kPulseTime,
295 theMap.crate, theMap.slot, theMap.channel);
296 for( UInt_t ihit = 0; ihit < nrefhits; ihit++ ) {
297 reftime = evdata.GetData(Decoder::kPulseTime, theMap.crate,
298 theMap.slot, theMap.channel, ihit);
299 reftime += 64 * timeshift;
300 if( ihit != 0 )
301 difftime = reftime - prevtime;
302 prevtime = reftime;
303 if( reftime >= fADC_RefTimeCut ) {
304 goodreftime = kTRUE;
305 break;
306 }
307 }
308
309 UInt_t nrefsamples = evdata.GetNumEvents(Decoder::kSampleADC,
310 theMap.crate, theMap.slot, theMap.channel);
311 if( nrefhits == 0 && nrefsamples > 0 ) {
312 Int_t ref_fNSA = 0;
313 Int_t ref_fNSB = 0;
314 Int_t ref_fNPED = 0;
315 if( fPSE125 ) {
316 ref_fNSA = fPSE125->GetNSA(theMap.crate);
317 ref_fNSB = fPSE125->GetNSB(theMap.crate);
318 ref_fNPED = fPSE125->GetNPED(theMap.crate);
319 if( ref_fNSA == -1 ) ref_fNSA = 26;
320 if( ref_fNSB == -1 ) ref_fNSB = 3;
321 if( ref_fNPED == -1 ) ref_fNPED = 4;
322 } else {
323 ref_fNSA = 26;
324 ref_fNSB = 3;
325 ref_fNPED = 4;
326 }
327 // Set F250 parameters.
328 auto* refrawhit = new THcRawAdcHit(); // large object, better on the heap
329 refrawhit->SetF250Params(ref_fNSA, ref_fNSB, ref_fNPED);
330 for( UInt_t isamp = 0; isamp < nrefsamples; isamp++ ) {
331 refrawhit->SetSample(
333 theMap.crate, theMap.slot, theMap.channel, isamp));
334 }
335 refrawhit->SetSampThreshold(20.);
336 refrawhit->SetSampIntTimePedestalPeak();
337 UInt_t NRefSampPulses = refrawhit->GetNSampPulses();
338 for( UInt_t ihit = 0; ihit < NRefSampPulses; ihit++ ) {
339 reftime = refrawhit->GetSampPulseTimeRaw(ihit);
340 reftime += 64 * timeshift;
341 if( ihit != 0 )
342 difftime = reftime - prevtime;
343 prevtime = reftime;
344 if( reftime >= fADC_RefTimeCut ) {
345 goodreftime = kTRUE;
346 break;
347 }
348 }
349 delete refrawhit;
350 }
351
352 if( goodreftime || (nrefhits > 0 && fADC_RefTimeBest) || (nrefsamples > 0 && fADC_RefTimeBest) ) {
353 theMap.reftime = reftime;
354 theMap.refdifftime = difftime;
355 theMap.hashit = kTRUE;
356 }
357 }
358
359 else {
360 // Assume this is a TDC
361 UInt_t nrefhits = evdata.GetNumHits(theMap.crate, theMap.slot, theMap.channel);
362 theMap.hashit = kFALSE;
363 // Only take first hit in this reference channel that is bigger
364 // then fTDC_RefTimeCut
365 Bool_t goodreftime = kFALSE;
366 Int_t reftime = 0;
367 Int_t prevtime = 0;
368 Int_t difftime = 0;
369 for( UInt_t ihit = 0; ihit < nrefhits; ihit++ ) {
370 reftime = evdata.GetData(theMap.crate, theMap.slot, theMap.channel, ihit);
371 if( ihit != 0 )
372 difftime = reftime - prevtime;
373 prevtime = reftime;
374 if( reftime >= fTDC_RefTimeCut ) {
375 goodreftime = kTRUE;
376 break;
377 }
378 }
379 if( goodreftime || (nrefhits > 0 && fTDC_RefTimeBest) ) {
380 theMap.reftime = reftime;
381 theMap.refdifftime = difftime;
382 theMap.hashit = kTRUE;
383 }
384 }
385 }
386
387 map<ULong64_t, THcRawHit*> hitlookup;
388 auto lookupkey = []( UInt_t plane, UInt_t counter) -> ULong64_t {
389 return (static_cast<ULong64_t>(plane) << 32) + counter;
390 };
391
392 THcRawHit* prev_rawhit = nullptr;
393 bool sorted = true;
394 for ( UInt_t i=0; i < fdMap->GetSize(); i++ ) {
396
397 // Loop over all channels that have a hit.
398 // cout << "Crate/Slot: " << d->crate << "/" << d->slot << endl;
399 auto plane = static_cast<Int_t>(d->plane);
400 if( plane >= 1000 )
401 continue; // Skip reference times
402 auto signal = static_cast<Int_t>(d->signal);
403 UInt_t signaltype = fSignalTypes[signal];
404 Bool_t multifunction = evdata.IsMultifunction(d->crate, d->slot);
405
406 for( UInt_t j = 0; j < evdata.GetNumChan(d->crate, d->slot); j++ ) {
407 UInt_t chan = evdata.GetNextChan(d->crate, d->slot, j);
408 if( chan < d->lo || chan > d->hi )
409 continue; // Not one of my channels
410
411 // Need to convert crate, slot, chan into plane, counter, signal
412 // Search hitlist for this plane,counter,signal
413 Int_t counter = d->reverse
414 ? static_cast<Int_t>(d->first + d->hi - chan)
415 : static_cast<Int_t>(d->first + chan - d->lo);
416 //cout << d->crate << " " << d->slot << " " << chan << " " << plane << " "
417 // << counter << " " << signal << endl;
418 THcRawHit* rawhit = nullptr;
419 // See if we already have a hit for this plane and counter.
420 auto found = hitlookup.find(lookupkey(plane, counter));
421 if( found != hitlookup.end() )
422 rawhit = found->second;
423 else {
424 rawhit = static_cast<THcRawHit*>(fRawHitList->ConstructedAt(fNRawHits,""));
425 rawhit->fPlane = plane;
426 rawhit->fCounter = counter;
427 // cout << "Found as " << fNRawHits << " pl = " << plane << " c = " << counter << endl;
428 hitlookup.emplace(lookupkey(plane, counter), rawhit);
429 fNRawHits++;
430 assert(fNRawHits == hitlookup.size());
431 if( sorted ) {
432 if( prev_rawhit && prev_rawhit->Compare(rawhit) >= 0 )
433 sorted = false;
434 else
435 prev_rawhit = rawhit;
436 }
437 }
438
439 // Get the data from this channel
440 // Allow for multiple hits
441 if( signaltype == THcRawHit::kTDC || !multifunction ) {
442 UInt_t nMHits = evdata.GetNumHits(d->crate, d->slot, chan);
443 for( UInt_t mhit = 0; mhit < nMHits; mhit++ ) {
444 Int_t data = evdata.GetData(d->crate, d->slot, chan, mhit);
445 // cout << "Signal " << signal << "=" << data << endl;
446 rawhit->SetData(signal, data);
447 }
448 // Get the reference time.
449 if( d->refchan >= 0 ) {
450 UInt_t nrefhits = evdata.GetNumHits(d->crate, d->slot, d->refchan);
451 Bool_t goodreftime = kFALSE;
452 Int_t reftime = 0;
453 Int_t prevtime = 0;
454 Int_t difftime = 0;
455 for( UInt_t ihit = 0; ihit < nrefhits; ihit++ ) {
456 reftime = evdata.GetData(d->crate, d->slot, d->refchan, ihit);
457 if( ihit != 0 ) difftime = reftime - prevtime;
458 prevtime = reftime;
459 if( reftime >= fTDC_RefTimeCut ) {
460 goodreftime = kTRUE;
461 break;
462 }
463 }
464 // If RefTimeBest flag set, take the last hit if none of the
465 // hits make the RefTimeCut
466 if( goodreftime || (nrefhits > 0 && fTDC_RefTimeBest) ) {
467 rawhit->SetReference(signal, reftime);
468 rawhit->SetReferenceDiff(signal, difftime);
469 } else if( !suppresswarnings ) {
470 cout << "HitList(event=" << evdata.GetEvNum() << "): refchan " << d->refchan <<
471 " missing for (" << d->crate << ", " << d->slot <<
472 ", " << chan << ")" << endl;
473 tdcref_miss = kTRUE;
474 }
475 } else {
476 if( d->refindex >= 0 && d->refindex < static_cast<Int_t>(fNRefIndex) ) {
477 const auto& theMap = fRefIndexMaps[d->refindex];
478 if( theMap.hashit ) {
479 rawhit->SetReference(signal, theMap.reftime);
480 rawhit->SetReferenceDiff(signal, theMap.refdifftime);
481 } else {
482 if( !suppresswarnings ) {
483 cout << "HitList(event=" << evdata.GetEvNum() << "): refindex " << d->refindex <<
484 " (" << theMap.crate <<
485 ", " << theMap.slot <<
486 ", " << theMap.channel << ")" <<
487 " missing for (" << d->crate << ", " << d->slot <<
488 ", " << chan << ")" << endl;
489 tdcref_miss = kTRUE;
490 }
491 }
492 }
493 }
494 } else { // This is a Flash ADC
495
496 if( fPSE125 ) {
497 if( !fHaveFADCInfo ) {
498 fNSA = fPSE125->GetNSA(d->crate);
499 fNSB = fPSE125->GetNSB(d->crate);
500 fNPED = fPSE125->GetNPED(d->crate);
501 if( fNSA == -1 ) fNSA = 26;
502 if( fNSB == -1 ) fNSB = 3;
503 if( fNPED == -1 ) fNPED = 4;
505 }
506 } else if( !fHaveFADCInfo ) {
507 fNSA = 26;
508 fNSB = 3;
509 fNPED = 4;
511 }
512 rawhit->SetF250Params(fNSA, fNSB, fNPED);
513
514 // Copy the samples
515 UInt_t nsamples = evdata.GetNumEvents(Decoder::kSampleADC, d->crate, d->slot, chan);
516
517 // If nsamples comes back zero, may want to suppress further attempts to
518 // get sample data for this or all modules
519 for( UInt_t isamp = 0; isamp < nsamples; isamp++ ) {
520 rawhit->SetSample(signal, evdata.GetData(Decoder::kSampleADC, d->crate, d->slot, chan, isamp));
521 }
522 // Now get the pulse mode data
523 // Pulse area will go into regular SetData, others will use special hit methods
524 UInt_t npulses = evdata.GetNumEvents(Decoder::kPulseIntegral, d->crate, d->slot, chan);
525 // Assume that the # of pulses for kPulseTime, kPulsePeak and kPulsePedestal are same;
526 Int_t timeshift = 0;
527 if( fTISlot > 0 && TI_TRIGGER_TIME_FOUND ) { // Get the trigger time for this module
528 auto ishift = fTrigTimeShiftMap.find(d->slot);
529 if( ishift == fTrigTimeShiftMap.end() ) {
530 auto ifadc = fFADCSlotMap.find(d->slot);
531 if( ifadc != fFADCSlotMap.end() ) {
532 timeshift = fTrigTimeShiftMap[d->slot] =
533 static_cast<Int_t>(ifadc->second->GetTriggerTime() - titime);
534 }
535 } else {
536 timeshift = ishift->second;
537 }
538 }
539 for( UInt_t ipulse = 0; ipulse < npulses; ipulse++ ) {
540 rawhit->SetDataTimePedestalPeak(signal,
541 evdata.GetData(Decoder::kPulseIntegral, d->crate, d->slot, chan, ipulse),
542 evdata.GetData(Decoder::kPulseTime, d->crate, d->slot, chan, ipulse) + 64 * timeshift,
543 evdata.GetData(Decoder::kPulsePedestal, d->crate, d->slot, chan, ipulse),
544 evdata.GetData(Decoder::kPulsePeak, d->crate, d->slot, chan, ipulse));
545 }
546 if( nsamples > 0 ) {
547 rawhit->SetSampIntTimePedestalPeak(signal);
548 }
549 // Get the reference time for the FADC pulse time
550 if( d->refchan >= 0 ) { // Reference time for the slot
552 d->crate, d->slot, d->refchan);
553 Int_t reftime = 0;
554 Int_t prevtime = 0;
555 Int_t difftime = 0;
556 timeshift = 0;
557 if( fTISlot > 0 && TI_TRIGGER_TIME_FOUND ) { // Get the trigger time for this module
558 auto ishift = fTrigTimeShiftMap.find(d->slot);
559 if( ishift == fTrigTimeShiftMap.end() ) {
560 auto ifadc = fFADCSlotMap.find(d->slot);
561 if( ifadc != fFADCSlotMap.end() ) {
562 timeshift = fTrigTimeShiftMap[d->slot] =
563 static_cast<Int_t>(ifadc->second->GetTriggerTime() - titime);
564 }
565 } else {
566 timeshift = ishift->second;
567 }
568 }
569 Bool_t goodreftime = kFALSE;
570 for( UInt_t ihit = 0; ihit < nrefhits; ihit++ ) {
571 reftime = evdata.GetData(Decoder::kPulseTime, d->crate, d->slot, d->refchan, ihit);
572 reftime += 64 * timeshift;
573 if( ihit != 0 ) difftime = reftime - prevtime;
574 prevtime = reftime;
575 if( reftime >= fADC_RefTimeCut ) {
576 goodreftime = kTRUE;
577 break;
578 }
579 }
580
581 UInt_t nrefsamples = evdata.GetNumEvents(Decoder::kSampleADC, d->crate, d->slot, d->refchan);
582 if( nrefhits == 0 && nrefsamples > 0 ) {
583 auto* refrawhit = new THcRawAdcHit();
584 for( UInt_t isamp = 0; isamp < nrefsamples; isamp++ ) {
585 refrawhit->SetSample(evdata.GetData(Decoder::kSampleADC, d->crate, d->slot, d->refchan, isamp));
586 }
587 refrawhit->SetSampThreshold(20.);
588 refrawhit->SetSampIntTimePedestalPeak();
589 UInt_t NRefSampPulses = refrawhit->GetNSampPulses();
590 for( UInt_t ihit = 0; ihit < NRefSampPulses; ihit++ ) {
591 reftime = refrawhit->GetSampPulseTimeRaw(ihit);
592 reftime += 64 * timeshift;
593 if( ihit != 0 )
594 difftime = reftime - prevtime;
595 prevtime = reftime;
596 if( reftime >= fADC_RefTimeCut ) {
597 goodreftime = kTRUE;
598 break;
599 }
600 }
601 delete refrawhit;
602 }
603
604 // If RefTimeBest flag set, take the last hit if none of the
605 // hits make the RefTimeCut
606 if( goodreftime || (nrefhits > 0 && fADC_RefTimeBest) || (nrefsamples > 0 && fADC_RefTimeBest) ) {
607 rawhit->SetReference(signal, reftime);
608 rawhit->SetReferenceDiff(signal, difftime);
609 } else if( !suppresswarnings ) {
610#ifndef SUPPRESSMISSINGADCREFTIMEMESSAGES
611 cout << "HitList(event=" << evdata.GetEvNum() << "): refchan " << d->refchan <<
612 " missing for (" << d->crate << ", " << d->slot <<
613 ", " << chan << ")" << endl;
614#endif
615 adcref_miss = kTRUE;
616 }
617 } else {
618 if( d->refindex >= 0 && d->refindex < fNRefIndex ) {
619 const auto& theMap = fRefIndexMaps[d->refindex];
620 if( theMap.hashit ) {
621 rawhit->SetReference(signal, theMap.reftime);
622 rawhit->SetReferenceDiff(signal, theMap.refdifftime);
623 } else {
624 if( !suppresswarnings ) {
625#ifndef SUPPRESSMISSINGADCREFTIMEMESSAGES
626 cout << "HitList(event=" << evdata.GetEvNum() << "): refindex " << d->refindex <<
627 " (" << theMap.crate <<
628 ", " << theMap.slot <<
629 ", " << theMap.channel << ")" <<
630 " missing for (" << d->crate << ", " << d->slot <<
631 ", " << chan << ")" << endl;
632#endif
633 adcref_miss = kTRUE;
634 }
635 }
636 }
637 }
638 }
639 }
640 }
641#if 1
642 if( fTISlot > 0 && TI_TRIGGER_TIME_FOUND ) {
643 // cout << "TI ROC: " << fTICrate << " TI Time: " << titime << endl;
644 for( const auto& it: fTrigTimeShiftMap ) {
645 if( it.second < -3 || it.second > 3 ) {
646 cout << "Big ADC Trigger Time Shift, ROC " << fTICrate << endl;
647 cout << it.first << " " << it.second << endl;
648 }
649 }
650 } else if( fTISlot > 0 && !TI_TRIGGER_TIME_FOUND ) {
651 // cout << "TI Trigger Time Not found for event type = " << evdata.GetEvType() << " event num = " << evdata.GetEvNum() << " TI Crate = " << fTICrate << " TI Slot = " << fTISlot<< endl;
652 }
653
654#endif
655 if( !sorted )
657
658 fNTDCRef_miss += (tdcref_miss ? 1 : 0);
659 fNADCRef_miss += (adcref_miss ? 1 : 0);
660 return fNRawHits; // Does anything care what is returned
661}
662void THcHitList::CreateMissReportParms(const char *prefix) const
663{
671 cout << "Defining " << Form("%s_tdcref_miss", prefix) << " and " << Form("%s_adcref_miss", prefix) << endl;
672 gHcParms->Define(Form("%s_tdcref_miss", prefix), "Missing TDC reference times", fNTDCRef_miss);
673 gHcParms->Define(Form("%s_adcref_miss", prefix), "Missing ADC reference times", fNADCRef_miss);
674}
675void THcHitList::MissReport(const char *name) const
676{
677 cout << "Missing Ref times:" << setw(20) << name << setw(10) << fNTDCRef_miss << setw(10) << fNADCRef_miss << endl;
678}
679
int Int_t
unsigned int UInt_t
uint32_t chan
#define d(i)
bool Bool_t
const Bool_t kFALSE
const Bool_t kTRUE
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void data
R__EXTERN class TList * gHaEvtHandlers
ClassImp(VDC::AnalyticTTDConv) using namespace std
R__EXTERN class THcParmList * gHcParms
Definition THcGlobals.h:11
char * Form(const char *fmt,...)
Int_t getModel(UInt_t crate, UInt_t slot) const
TClass * GetClass() const
void Clear(Option_t *option="") override
void Sort(Int_t upto=kMaxInt) override
TObject * ConstructedAt(Int_t idx)
UInt_t GetSize() const
Module * GetModule(UInt_t i) const
UInt_t GetNumHits(UInt_t crate, UInt_t slot, UInt_t chan) const
Decoder::THaCrateMap * GetCrateMap() const
UInt_t GetData(Decoder::EModuleType type, UInt_t crate, UInt_t slot, UInt_t chan, UInt_t hit) const
UInt_t GetNextChan(UInt_t crate, UInt_t slot, UInt_t index) const
UInt_t GetNumEvents(Decoder::EModuleType type, UInt_t crate, UInt_t slot, UInt_t chan) const
UInt_t GetEvNum() const
UInt_t GetNumChan(UInt_t crate, UInt_t slot) const
virtual Decoder::Module * GetModule(UInt_t roc, UInt_t slot) const
Bool_t IsMultifunction(UInt_t crate, UInt_t slot) const
THaVar * Define(const char *name, const Byte_t &var, const Int_t *count=nullptr)
Analyze Hall C Configuration events. (Event type 125).
UInt_t GetNSA(UInt_t crate)
UInt_t GetNSB(UInt_t crate)
UInt_t GetNPED(UInt_t crate)
Builds a Hall C ENGx1INE style list of raw hits from raw data.
Definition THcHitList.h:27
virtual Int_t DecodeToHitList(const THaEvData &evdata, Bool_t suppress=kFALSE)
Populate the hitlist from the raw event data.
TClonesArray * fRawHitList
Definition THcHitList.h:51
Int_t fNSB
Definition THcHitList.h:78
virtual ~THcHitList()
UInt_t fNSignals
Definition THcHitList.h:72
Int_t fTICrate
Definition THcHitList.h:86
Int_t fTISlot
Definition THcHitList.h:85
void CreateMissReportParms(const char *prefix) const
THaDetMap * fdMap
Definition THcHitList.h:54
Bool_t fDisableSlipCorrection
Definition THcHitList.h:87
std::vector< RefIndexMap > fRefIndexMaps
Definition THcHitList.h:68
std::vector< UInt_t > fRefIdxDefined
Definition THcHitList.h:69
Int_t fTDC_RefTimeCut
Definition THcHitList.h:47
Int_t fNSA
Definition THcHitList.h:77
Bool_t fADC_RefTimeBest
Definition THcHitList.h:50
Int_t fNPED
Definition THcHitList.h:79
std::map< UInt_t, Int_t > fTrigTimeShiftMap
Definition THcHitList.h:88
std::map< UInt_t, Decoder::Fadc250Module * > fFADCSlotMap
Definition THcHitList.h:89
Int_t fNADCRef_miss
Definition THcHitList.h:82
void InitHitList(THaDetMap *detmap, const char *hitclass, Int_t maxhits, Int_t tdcref_cut=0, Int_t adcref_cut=0)
Save the electronics module to detector mapping and initialize a hit array of hits of class hitclass.
THcConfigEvtHandler * fPSE125
Definition THcHitList.h:75
UInt_t fNRawHits
Definition THcHitList.h:45
Bool_t fTDC_RefTimeBest
Definition THcHitList.h:49
Int_t fNTDCRef_miss
Definition THcHitList.h:81
Decoder::THaCrateMap * fMap
Definition THcHitList.h:84
Bool_t fHaveFADCInfo
Definition THcHitList.h:76
Int_t fNRefIndex
Definition THcHitList.h:71
TClass * fRawHitClass
Definition THcHitList.h:52
Int_t fNMaxRawHits
Definition THcHitList.h:46
void MissReport(const char *name) const
Int_t fADC_RefTimeCut
Definition THcHitList.h:48
THcRawHit::ESignalType * fSignalTypes
Definition THcHitList.h:73
Class representing a single raw ADC hit.
Definition THcRawAdcHit.h:7
Base class detector specific raw hit that go into hit lists.
Definition THcRawHit.h:11
virtual void SetF250Params(Int_t NSA, Int_t NSB, Int_t NPED)
Definition THcRawHit.h:44
Int_t fPlane
Definition THcRawHit.h:52
virtual void SetData(Int_t signal, Int_t data)
Definition THcRawHit.h:28
virtual void SetDataTimePedestalPeak(Int_t signal, Int_t data, Int_t time, Int_t pedestal, Int_t peak)
Definition THcRawHit.h:32
virtual void SetSampIntTimePedestalPeak(Int_t signal)
Definition THcRawHit.h:31
virtual Int_t Compare(const TObject *obj) const
Definition THcRawHit.cxx:13
virtual void SetReferenceDiff(Int_t signal, Int_t reference)
Definition THcRawHit.h:40
virtual void SetReference(Int_t signal, Int_t reference)
Definition THcRawHit.h:39
Int_t fCounter
Definition THcRawHit.h:53
virtual void SetSample(Int_t signal, Int_t data)
Definition THcRawHit.h:29
virtual TObjLink * FirstLink() const
virtual const char * ClassName() const
unsigned long long ULong64_t
static const UInt_t MAXSLOT
void Warning(const char *location, const char *fmt,...)
STL namespace.