16 #include "StBTofMaker.h"
18 #include "StEventTypes.h"
19 #include "StEvent/StBTofCollection.h"
20 #include "StEvent/StBTofHeader.h"
21 #include "StEvent/StBTofRawHit.h"
22 #include "StBTofUtil/StBTofRawHitCollection.h"
23 #include "StBTofUtil/StBTofHitCollection.h"
24 #include "StBTofUtil/StBTofDaqMap.h"
25 #include "StBTofUtil/StBTofINLCorr.h"
26 #include "StEvent/StEvent.h"
34 mDoTriggerCut = kTRUE;
40 LOG_INFO <<
"StBTofMaker::ctor" << endm;
44 StBTofMaker::~StBTofMaker()
50 for(
int i=0;i<4;i++) mTriggerTimeStamp[i] = 0;
54 Int_t StBTofMaker::Init()
61 Int_t StBTofMaker::InitRun(Int_t runnumber)
66 LOG_INFO <<
" Initialize Daq map ... " << endm;
68 mBTofDaqMap->
Init(
this);
72 LOG_INFO <<
" Initialize StBTofSortRawHit() ... " << endm;
74 mBTofSortRawHit->Init(
this, mBTofDaqMap);
77 LOG_INFO <<
" Initialize INL table ... " << endm;
87 Int_t StBTofMaker::FinishRun(Int_t runnumber)
89 if(mBTofDaqMap)
delete mBTofDaqMap;
93 if(mBTofINLCorr)
delete mBTofINLCorr;
97 if(mBTofSortRawHit)
delete mBTofSortRawHit;
120 mStEvent =
dynamic_cast<StEvent *
> (GetInputDS(
"StEvent"));
125 btofCollection = mStEvent->btofCollection();
128 if ( !btofCollection ) {
131 mStEvent->setBTofCollection(btofCollection);
134 return btofCollection;
142 if (mBTofCollection) {
143 fillBTofHitCollection();
151 void StBTofMaker::fillBTofHitCollection()
157 for(
size_t i=0;i<validtray.size();i++) {
158 int trayId = validtray[i];
161 LOG_INFO <<
" Number of fired hits on tray " << trayId <<
" = " << validchannel.size() << endm;
164 for(
size_t iv=0;iv<validchannel.size();iv++) {
165 UIntVec leTdc = mBTofSortRawHit->
GetLeadingTdc(trayId, validchannel[iv], mDoTriggerCut);
166 UIntVec teTdc = mBTofSortRawHit->
GetTrailingTdc(trayId, validchannel[iv], mDoTriggerCut);
169 LOG_INFO <<
" Number of fired hits on channel " << validchannel[iv] <<
" = " << leTdc.size() <<
" / " << teTdc.size() << endm;
172 if(!leTdc.size() || !teTdc.size())
continue;
174 int chan = validchannel[iv];
176 int moduleId = map[0];
182 unsigned int tmptdc = leTdc[0];
183 int bin = tmptdc&0x3ff;
184 double corr = mDoINLCorr ? mBTofINLCorr->
getTrayINLCorr(trayId, chan, bin) : 0.0;
185 double tmptdc_f = tmptdc + corr;
186 double letime = tmptdc_f*VHRBIN2PS / 1000.;
190 corr = mDoINLCorr ? mBTofINLCorr->
getTrayINLCorr(trayId, chan, bin) : 0.0;
191 tmptdc_f = tmptdc + corr;
192 double tetime = tmptdc_f*VHRBIN2PS / 1000.;
195 aHit->setTray((UChar_t)trayId);
196 aHit->setModule((UChar_t)moduleId);
197 aHit->setCell((UChar_t)cellId);
198 aHit->setLeadingEdgeTime(letime);
199 aHit->setTrailingEdgeTime(tetime);
200 mBTofCollection->addHit(aHit);
206 for(
int ivpd=0;ivpd<2;ivpd++) {
207 StBeamDirection eastwest = (ivpd==0) ? west : east;
208 int trayId = (ivpd==0) ? mWestVpdTrayId : mEastVpdTrayId;
211 LOG_INFO <<
" Number of fired hits on tray(vpd) " << trayId <<
" = " << validtube.size() << endm;
214 if(!validtube.size())
continue;
215 for(
int i=0;i<mNVPD;i++) {
219 UIntVec leTdc = mBTofSortRawHit->
GetLeadingTdc(trayId, lechan, mDoTriggerCut);
220 UIntVec teTdc = mBTofSortRawHit->
GetTrailingTdc(trayId, lechan, mDoTriggerCut);
223 LOG_INFO <<
" Number of fired hits on tube " << tubeId <<
" = " << leTdc.size() <<
" / " << teTdc.size() << endm;
226 if(leTdc.size() && teTdc.size()) {
229 unsigned int tmptdc = leTdc[0];
230 int bin = tmptdc&0x3ff;
231 double corr = mDoINLCorr ? mBTofINLCorr->
getVpdINLCorr(eastwest, lechan, bin) : 0.0;
232 double tmptdc_f = tmptdc + corr;
233 double letime = tmptdc_f*VHRBIN2PS / 1000.;
237 corr = mDoINLCorr ? mBTofINLCorr->
getVpdINLCorr(eastwest, techan, bin) : 0.0;
238 tmptdc_f = tmptdc + corr;
239 double tetime = tmptdc_f*VHRBIN2PS / 1000.;
242 aHit->setTray((UChar_t)trayId);
244 aHit->setCell((UChar_t)tubeId);
245 aHit->setLeadingEdgeTime(letime);
246 aHit->setTrailingEdgeTime(tetime);
247 mBTofCollection->addHit(aHit);
void Init(StMaker *maker)
Initial function, need a maker to access the data base.
Int_t numberOfValidTrays()
Returns the number of valid trays.
Int_t WestPMT2TDIGTeChan(const Int_t iTube)
To convert west VPD PMT number to TDIG trailing channel number.
Int_t WestPMT2TDIGLeChan(const Int_t iTube)
To convert west VPD PMT number to TDIG leading channel number.
IntVec ValidTrays()
Returns the list of valid tray Ids.
void setBTofCollection(StBTofCollection *tofColl)
set to use the VPD delays
Int_t EastPMT2TDIGTeChan(const Int_t iTube)
To convert east VPD PMT number to TDIG trailing channel number.
IntVec GetValidChannel(int tray)
Returns the valid channel Ids for a tray.
UIntVec GetLeadingTdc(int tray, int channel, bool triggerevent=true)
Returns the leading Tdcs for one channel. triggerevent used as a switch for physical hits selection...
float getTrayINLCorr(int trayId, int globalTdcChan, int bin)
To get the INL correction tables for trays.
UIntVec GetTrailingTdc(int tray, int channel, bool triggerevent=true)
Returns the trailing Tdcs for one channel. triggerevent used as a switch for physical hits selection...
StBTofCollection * GetBTofCollection()
Switch to turn on trigger cut.
void initFromDbase(StMaker *maker)
Initial function to access the data base and retrieve INL tables.
IntVec TDIGChan2Cell(const Int_t iTdc)
To convert TDIG channel number to module/cell number.
Int_t EastPMT2TDIGLeChan(const Int_t iTube)
void Clear(Option_t *option="")
User defined functions.
StBTofMaker(const char *name="tof_raw")
Default constructor.
float getVpdINLCorr(StBeamDirection eastwest, int globalTdcChan, int bin)
To get the INL correction tables for vpds.