Skip to content

Commit

Permalink
THcHitList: Prevent underflow and print warning if TI time is invalid
Browse files Browse the repository at this point in the history
  • Loading branch information
hansenjo committed Sep 6, 2022
1 parent 1caed56 commit 4118d87
Showing 1 changed file with 25 additions and 17 deletions.
42 changes: 25 additions & 17 deletions src/THcHitList.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -211,24 +211,32 @@ Int_t THcHitList::DecodeToHitList( const THaEvData& evdata, Bool_t suppresswarni
if(fadc) {
fFADCSlotMap[slot] = fadc;
}
}
}
}
break;
}
}
}
if(fDisableSlipCorrection) fTISlot = -1;

UInt_t titime = 0;
Bool_t TI_TRIGGER_TIME_FOUND = kFALSE;
if(fTISlot>0) {
UInt_t FUDGE=7;
const UInt_t FUDGE = 7;
if (evdata.GetNumHits(fTICrate, fTISlot, 2) > 0) {
TI_TRIGGER_TIME_FOUND = kTRUE;
titime = evdata.GetData(fTICrate, fTISlot, 2, 0)-FUDGE;
// Need to get the FADC time for all modules in this crate
// that have hits. Make a map with these times.
fTrigTimeShiftMap.clear();
TI_TRIGGER_TIME_FOUND = kTRUE;
titime = evdata.GetData(fTICrate, fTISlot, 2, 0);
if( titime >= FUDGE )
titime -= FUDGE;
else {
Warning(Here("DecodeToHitList"), "Invalid TI time %u - %u < 0 "
" for crate/slot = %d/%d",
titime, FUDGE, fTICrate, fTISlot);
titime = 0;
}
// Need to get the FADC time for all modules in this crate
// that have hits. Make a map with these times.
fTrigTimeShiftMap.clear();
}
}

Expand All @@ -240,7 +248,7 @@ Int_t THcHitList::DecodeToHitList( const THaEvData& evdata, Bool_t suppresswarni

// Get the indexed reference times for this event
for(Int_t i=0;i<fNRefIndex;i++) {
if(fRefIndexMaps[i].defined) {
if(fRefIndexMaps[i].defined) {
if(evdata.IsMultifunction(fRefIndexMaps[i].crate,fRefIndexMaps[i].slot)) { // Multifunction module (e.g. FADC)
// Make sure at least one pulse
UInt_t nrefhits = evdata.GetNumEvents(Decoder::kPulseTime,
Expand All @@ -250,7 +258,7 @@ Int_t THcHitList::DecodeToHitList( const THaEvData& evdata, Bool_t suppresswarni
Int_t timeshift=0;
if(fTISlot>0 && TI_TRIGGER_TIME_FOUND) { // Get the trigger time for this module
if(fTrigTimeShiftMap.find(fRefIndexMaps[i].slot)
== fTrigTimeShiftMap.end()) { //
== fTrigTimeShiftMap.end()) { //
if(fFADCSlotMap.find(fRefIndexMaps[i].slot) != fFADCSlotMap.end()) {
fTrigTimeShiftMap[fRefIndexMaps[i].slot]
= fFADCSlotMap[fRefIndexMaps[i].slot]->GetTriggerTime() - titime;
Expand Down Expand Up @@ -342,7 +350,7 @@ Int_t THcHitList::DecodeToHitList( const THaEvData& evdata, Bool_t suppresswarni
}
for ( UInt_t i=0; i < fdMap->GetSize(); i++ ) {
THaDetMap::Module* d = fdMap->GetModule(i);

// Loop over all channels that have a hit.
// cout << "Crate/Slot: " << d->crate << "/" << d->slot << endl;
Int_t plane = d->plane;
Expand Down Expand Up @@ -451,7 +459,7 @@ Int_t THcHitList::DecodeToHitList( const THaEvData& evdata, Bool_t suppresswarni
// Set F250 parameters.
rawhit->SetF250Params(fNSA, fNSB, fNPED);
}

// Copy the samples
UInt_t nsamples=evdata.GetNumEvents(Decoder::kSampleADC, d->crate, d->slot, chan);

Expand All @@ -467,7 +475,7 @@ Int_t THcHitList::DecodeToHitList( const THaEvData& evdata, Bool_t suppresswarni
Int_t timeshift=0;
if(fTISlot>0 && TI_TRIGGER_TIME_FOUND) { // Get the trigger time for this module
if(fTrigTimeShiftMap.find(d->slot)
== fTrigTimeShiftMap.end()) { //
== fTrigTimeShiftMap.end()) { //
if(fFADCSlotMap.find(d->slot) != fFADCSlotMap.end()) {
fTrigTimeShiftMap[d->slot]
= fFADCSlotMap[d->slot]->GetTriggerTime() - titime;
Expand Down Expand Up @@ -496,7 +504,7 @@ Int_t THcHitList::DecodeToHitList( const THaEvData& evdata, Bool_t suppresswarni
timeshift=0;
if(fTISlot>0 && TI_TRIGGER_TIME_FOUND) { // Get the trigger time for this module
if(fTrigTimeShiftMap.find(d->slot)
== fTrigTimeShiftMap.end()) { //
== fTrigTimeShiftMap.end()) { //
if(fFADCSlotMap.find(d->slot) != fFADCSlotMap.end()) {
fTrigTimeShiftMap[d->slot]
= fFADCSlotMap[d->slot]->GetTriggerTime() - titime;
Expand Down Expand Up @@ -584,9 +592,9 @@ Int_t THcHitList::DecodeToHitList( const THaEvData& evdata, Bool_t suppresswarni
}
} else if ( fTISlot>0 && !TI_TRIGGER_TIME_FOUND) {
cout << "TI Trigger Time Not found for event type = " << evdata.GetEvType() << " event num = " << evdata.GetEvNum() << " TI Crate = " << fTICrate << " TI Slot = " << fTISlot<< endl;
}
#endif
}

#endif
fRawHitList->Sort(fNRawHits);

fNTDCRef_miss += (tdcref_miss ? 1 : 0);
Expand Down

0 comments on commit 4118d87

Please sign in to comment.