Skip to content
Snippets Groups Projects
Commit 8a26c04d authored by Stephen A. Wood's avatar Stephen A. Wood Committed by Stephen Wood
Browse files

Implement a correction for FADC trigger time slippage

  Correction is done in the hitlist by comparing the trigger time
  from the TI to the trigger time in the FADC.  These generally have
  a fixed offset.  A FUDGE offset is included to make the difference
  between the FADC and TI times zero or close to zero.

  The FADC delivers times in units of 0.0625 ns.  The trigger time is in
  units of 4ns.  So the FADCs will be shifted by 64 units for each unit
  of trigger time slippage.
parent 8b5c505a
No related branches found
No related tags found
No related merge requests found
...@@ -21,12 +21,13 @@ ...@@ -21,12 +21,13 @@
using namespace std; using namespace std;
#define SUPPRESSMISSINGADCREFTIMEMESSAGES 1 #define SUPPRESSMISSINGADCREFTIMEMESSAGES 1
THcHitList::THcHitList() THcHitList::THcHitList() : fMap(0), fTISlot(0)
{ {
/// Normal constructor. /// Normal constructor.
fRawHitList = NULL; fRawHitList = NULL;
fPSE125 = NULL; fPSE125 = NULL;
fFADCSlotMap.clear();
} }
...@@ -45,6 +46,16 @@ initialize a hit array of hits of class hitclass ...@@ -45,6 +46,16 @@ initialize a hit array of hits of class hitclass
*/ */
/* InitHitList should make a list of ROCs that have FADCs in them. (Probably
just one.) It then needs to figure out where the TI is and make sure
the decoder is setup for pulling out the event time.
Do we need to somehow configure this in the Hall C style map file. Is there
a method to ask the OO decoder what kind of module is in a given slot?
*/
void THcHitList::InitHitList(THaDetMap* detmap, void THcHitList::InitHitList(THaDetMap* detmap,
const char *hitclass, Int_t maxhits, const char *hitclass, Int_t maxhits,
Int_t tdcref_cut, Int_t adcref_cut) { Int_t tdcref_cut, Int_t adcref_cut) {
...@@ -171,6 +182,48 @@ The hit list is sorted (by plane, counter) after filling. ...@@ -171,6 +182,48 @@ The hit list is sorted (by plane, counter) after filling.
*/ */
Int_t THcHitList::DecodeToHitList( const THaEvData& evdata, Bool_t suppresswarnings ) { Int_t THcHitList::DecodeToHitList( const THaEvData& evdata, Bool_t suppresswarnings ) {
if(!fMap) { // Find the TI slot for ADCs
// Assumes that all FADCs are in the same crate
cout << "Got the Crate map" << endl;
fMap = evdata.GetCrateMap();
for (Int_t i=0; i < fdMap->GetSize(); i++) { // Look for a FADC250
THaDetMap::Module* d = fdMap->GetModule(i);
Decoder::Fadc250Module* isfadc = dynamic_cast<Decoder::Fadc250Module*>(evdata.GetModule(d->crate, d->slot));
if(isfadc) {
// Scan this crate to find the TI.
for(Int_t slot=0;slot<Decoder::MAXSLOT;slot++) {
if(fMap->getModel(d->crate, slot) == 4) {
fTISlot = slot;
fTICrate = d->crate;
cout << "TI Slot = " << fTISlot << endl;
break;
}
}
// Now make a map of all the FADCs in this crate
if(fTISlot>0) {
for(Int_t slot=0;slot<Decoder::MAXSLOT;slot++) {
Decoder::Fadc250Module* fadc = dynamic_cast<Decoder::Fadc250Module*>
(evdata.GetModule(d->crate, slot));
if(fadc) {
fFADCSlotMap[slot] = fadc;
}
}
}
break;
}
}
}
Int_t titime = 0;
if(fTISlot!=0) {
#define FUDGE 7
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();
//cout << "TI Crate: " << fTICrate << " " << (UInt_t) titime << endl;
}
// cout << " Clearing TClonesArray " << endl; // cout << " Clearing TClonesArray " << endl;
fRawHitList->Clear( ); fRawHitList->Clear( );
fNRawHits = 0; fNRawHits = 0;
...@@ -180,6 +233,7 @@ Int_t THcHitList::DecodeToHitList( const THaEvData& evdata, Bool_t suppresswarni ...@@ -180,6 +233,7 @@ Int_t THcHitList::DecodeToHitList( const THaEvData& evdata, Bool_t suppresswarni
// Get the indexed reference times for this event // Get the indexed reference times for this event
for(Int_t i=0;i<fNRefIndex;i++) { for(Int_t i=0;i<fNRefIndex;i++) {
if(fRefIndexMaps[i].defined) { if(fRefIndexMaps[i].defined) {
if(evdata.IsMultifunction(fRefIndexMaps[i].crate, if(evdata.IsMultifunction(fRefIndexMaps[i].crate,
fRefIndexMaps[i].slot)) { // Multifunction module (e.g. FADC) fRefIndexMaps[i].slot)) { // Multifunction module (e.g. FADC)
// Make sure at least one pulse // Make sure at least one pulse
...@@ -187,12 +241,24 @@ Int_t THcHitList::DecodeToHitList( const THaEvData& evdata, Bool_t suppresswarni ...@@ -187,12 +241,24 @@ Int_t THcHitList::DecodeToHitList( const THaEvData& evdata, Bool_t suppresswarni
fRefIndexMaps[i].crate, fRefIndexMaps[i].crate,
fRefIndexMaps[i].slot, fRefIndexMaps[i].slot,
fRefIndexMaps[i].channel); fRefIndexMaps[i].channel);
Int_t timeshift=0;
if(fTISlot>0) { // Get the trigger time for this module
if(fTrigTimeShiftMap.find(fRefIndexMaps[i].slot)
== fTrigTimeShiftMap.end()) { //
if(fFADCSlotMap.find(fRefIndexMaps[i].slot) != fFADCSlotMap.end()) {
fTrigTimeShiftMap[fRefIndexMaps[i].slot]
= fFADCSlotMap[fRefIndexMaps[i].slot]->GetTriggerTime() - titime;
}
timeshift = fTrigTimeShiftMap[fRefIndexMaps[i].slot];
}
}
fRefIndexMaps[i].hashit = kFALSE; fRefIndexMaps[i].hashit = kFALSE;
Bool_t goodreftime=kFALSE; Bool_t goodreftime=kFALSE;
Int_t reftime = 0; Int_t reftime = 0;
for(Int_t ihit=0; ihit<nrefhits; ihit++) { for(Int_t ihit=0; ihit<nrefhits; ihit++) {
reftime = evdata.GetData(Decoder::kPulseTime,fRefIndexMaps[i].crate, reftime = evdata.GetData(Decoder::kPulseTime,fRefIndexMaps[i].crate,
fRefIndexMaps[i].slot, fRefIndexMaps[i].channel,ihit); fRefIndexMaps[i].slot, fRefIndexMaps[i].channel,ihit);
reftime += 64*timeshift;
if(reftime >= fADC_RefTimeCut) { if(reftime >= fADC_RefTimeCut) {
goodreftime = kTRUE; goodreftime = kTRUE;
break; break;
...@@ -343,10 +409,21 @@ Int_t THcHitList::DecodeToHitList( const THaEvData& evdata, Bool_t suppresswarni ...@@ -343,10 +409,21 @@ Int_t THcHitList::DecodeToHitList( const THaEvData& evdata, Bool_t suppresswarni
// Pulse area will go into regular SetData, others will use special hit methods // Pulse area will go into regular SetData, others will use special hit methods
Int_t npulses=evdata.GetNumEvents(Decoder::kPulseIntegral, d->crate, d->slot, chan); Int_t npulses=evdata.GetNumEvents(Decoder::kPulseIntegral, d->crate, d->slot, chan);
// Assume that the # of pulses for kPulseTime, kPulsePeak and kPulsePedestal are same; // Assume that the # of pulses for kPulseTime, kPulsePeak and kPulsePedestal are same;
Int_t timeshift=0;
if(fTISlot>0) { // Get the trigger time for this module
if(fTrigTimeShiftMap.find(d->slot)
== fTrigTimeShiftMap.end()) { //
if(fFADCSlotMap.find(d->slot) != fFADCSlotMap.end()) {
fTrigTimeShiftMap[d->slot]
= fFADCSlotMap[d->slot]->GetTriggerTime() - titime;
}
}
timeshift = fTrigTimeShiftMap[d->slot];
}
for (Int_t ipulse=0;ipulse<npulses;ipulse++) { for (Int_t ipulse=0;ipulse<npulses;ipulse++) {
rawhit->SetDataTimePedestalPeak(signal, rawhit->SetDataTimePedestalPeak(signal,
evdata.GetData(Decoder::kPulseIntegral, d->crate, d->slot, chan, ipulse), evdata.GetData(Decoder::kPulseIntegral, d->crate, d->slot, chan, ipulse),
evdata.GetData(Decoder::kPulseTime, d->crate, d->slot, chan, ipulse), evdata.GetData(Decoder::kPulseTime, d->crate, d->slot, chan, ipulse)+64*timeshift,
evdata.GetData(Decoder::kPulsePedestal, d->crate, d->slot, chan, ipulse), evdata.GetData(Decoder::kPulsePedestal, d->crate, d->slot, chan, ipulse),
evdata.GetData(Decoder::kPulsePeak, d->crate, d->slot, chan, ipulse)); evdata.GetData(Decoder::kPulsePeak, d->crate, d->slot, chan, ipulse));
} }
...@@ -356,8 +433,20 @@ Int_t THcHitList::DecodeToHitList( const THaEvData& evdata, Bool_t suppresswarni ...@@ -356,8 +433,20 @@ Int_t THcHitList::DecodeToHitList( const THaEvData& evdata, Bool_t suppresswarni
d->crate, d->slot, d->refchan); d->crate, d->slot, d->refchan);
Bool_t goodreftime=kFALSE; Bool_t goodreftime=kFALSE;
Int_t reftime = 0; Int_t reftime = 0;
timeshift=0;
if(fTISlot>0) { // Get the trigger time for this module
if(fTrigTimeShiftMap.find(d->slot)
== fTrigTimeShiftMap.end()) { //
if(fFADCSlotMap.find(d->slot) != fFADCSlotMap.end()) {
fTrigTimeShiftMap[d->slot]
= fFADCSlotMap[d->slot]->GetTriggerTime() - titime;
}
}
timeshift = fTrigTimeShiftMap[d->slot];
}
for(Int_t ihit=0; ihit<nrefhits; ihit++) { for(Int_t ihit=0; ihit<nrefhits; ihit++) {
reftime = evdata.GetData(Decoder::kPulseTime, d->crate, d->slot, d->refchan, ihit); reftime = evdata.GetData(Decoder::kPulseTime, d->crate, d->slot, d->refchan, ihit);
reftime += 64*timeshift;
if(reftime >= fADC_RefTimeCut) { if(reftime >= fADC_RefTimeCut) {
goodreftime=kTRUE; goodreftime=kTRUE;
break; break;
...@@ -397,6 +486,18 @@ Int_t THcHitList::DecodeToHitList( const THaEvData& evdata, Bool_t suppresswarni ...@@ -397,6 +486,18 @@ Int_t THcHitList::DecodeToHitList( const THaEvData& evdata, Bool_t suppresswarni
} }
} }
} }
#if 1
if(fTISlot) {
// cout << "TI ROC: " << fTICrate << " TI Time: " << titime << endl;
map<Int_t, Int_t>::iterator it;
for(it=fTrigTimeShiftMap.begin(); it!=fTrigTimeShiftMap.end(); it++) {
if(it->second < -3 || it->second > 3) {
cout << "Big ADC Trigger Time Shift, ROC " << fTICrate << endl;
cout << it->first << " " << it->second << endl;
}
}
}
#endif
fRawHitList->Sort(fNRawHits); fRawHitList->Sort(fNRawHits);
fNTDCRef_miss += (tdcref_miss ? 1 : 0); fNTDCRef_miss += (tdcref_miss ? 1 : 0);
......
...@@ -7,8 +7,11 @@ ...@@ -7,8 +7,11 @@
#include "TClonesArray.h" #include "TClonesArray.h"
#include "TObject.h" #include "TObject.h"
#include "Decoder.h" #include "Decoder.h"
#include "THaCrateMap.h"
#include "Fadc250Module.h"
#include <iomanip> #include <iomanip>
#include <map>
using namespace std; using namespace std;
...@@ -29,7 +32,7 @@ public: ...@@ -29,7 +32,7 @@ public:
THcHitList(); THcHitList();
virtual Int_t DecodeToHitList( const THaEvData&, Bool_t suppress=kFALSE ); virtual Int_t DecodeToHitList( const THaEvData& evdata, Bool_t suppress=kFALSE );
void InitHitList(THaDetMap* detmap, void InitHitList(THaDetMap* detmap,
const char *hitclass, Int_t maxhits, const char *hitclass, Int_t maxhits,
Int_t tdcref_cut=0, Int_t adcref_cut=0); Int_t tdcref_cut=0, Int_t adcref_cut=0);
...@@ -76,6 +79,12 @@ protected: ...@@ -76,6 +79,12 @@ protected:
Int_t fNTDCRef_miss; Int_t fNTDCRef_miss;
Int_t fNADCRef_miss; Int_t fNADCRef_miss;
Decoder::THaCrateMap* fMap; /* The Crate map */
Int_t fTISlot;
Int_t fTICrate;
std::map<Int_t, Int_t> fTrigTimeShiftMap;
std::map<Int_t, Decoder::Fadc250Module*> fFADCSlotMap;
ClassDef(THcHitList,0); // List of raw hits sorted by plane, counter ClassDef(THcHitList,0); // List of raw hits sorted by plane, counter
}; };
#endif #endif
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment