16 #include "StMtdHitMaker.h"
17 #include "StEventTypes.h"
18 #include "StEvent/StMtdCollection.h"
19 #include "StEvent/StMtdHeader.h"
20 #include "StEvent/StMtdRawHit.h"
21 #include "StEvent/StEvent.h"
22 #include "StDAQMaker/StDAQReader.h"
23 #include "StRtsTable.h"
24 #include "DAQ_MTD/daq_mtd.h"
25 #include "StBTofUtil/StBTofINLCorr.h"
26 #include "StMuDSTMaker/COMMON/StMuDstMaker.h"
27 #include "StMuDSTMaker/COMMON/StMuEvent.h"
28 #include "StMuDSTMaker/COMMON/StMuDst.h"
29 #include "StMuDSTMaker/COMMON/StMuTrack.h"
30 #include "StMuDSTMaker/COMMON/StMuMtdCollection.h"
31 #include "StMuDSTMaker/COMMON/StMuMtdRawHit.h"
32 #include "StMuDSTMaker/COMMON/StMuMtdHeader.h"
33 #include "tables/St_mtdTrayToTdigMap_Table.h"
34 #include "tables/St_mtdTrayIdMap_Table.h"
35 #include "tables/St_mtdTdigIdMap_Table.h"
36 #include "tables/St_mtdTriggerTimeCut_Table.h"
42 mStEvent(0),fMtd(0), mUseMuDst(0),
43 mCosmicFlag(kFALSE), mCosmicTrigTimeWinFile(
""),
44 mTriggerWndSelection(kTRUE), mSwapBacklegInRun13(0),
45 mReverseStripInRun14(kFALSE),
51 LOG_DEBUG <<
"StMtdHitMaker::ctor" << endm;
53 Int_t mStripMap[24]={21,12,32,20,14,35,25,13,30,24,11,31,34,22,10,37,27,17,33,23,16,36,26,15};
54 for(
int i=0;i<24;i++) mtdStrip[i] = mStripMap[i];
55 hxhyhz =
new TH3D(
"hxhyhz",
"hxhyhz",10,19.5,29.5,10,-0.5,9.5,30,-0.5,29.5);
60 StMtdHitMaker::~StMtdHitMaker()
68 MtdLeadingHits.clear();
69 MtdTrailingHits.clear();
70 memset(mTriggerTimeStamp,0,2);
75 Int_t StMtdHitMaker::Init()
79 memset(mTray2TdigMap,-1,
sizeof(mTray2TdigMap));
80 memset(mTrayId,0,
sizeof(mTrayId));
81 memset(mTdigId,0,
sizeof(mTdigId));
83 for(Int_t i=0;i<gMtdNModulesAll;i++)
85 mTriggerTimeWindow[i][0] = 0;
86 mTriggerTimeWindow[i][1] = 9999;
96 mYear= (Int_t)(runnumber/1000000 -1);
98 LOG_INFO <<
"Process data from year " << mYear << endm;
101 LOG_INFO <<
"Retrieving mtdTrayToTdigMap table from database ..." << endm;
102 TDataSet *dataset = GetDataBase(
"Geometry/mtd/mtdTrayToTdigMap");
103 St_mtdTrayToTdigMap *mtdTrayToTdigMap =
static_cast<St_mtdTrayToTdigMap*
>(dataset->
Find(
"mtdTrayToTdigMap"));
104 if(!mtdTrayToTdigMap)
106 LOG_ERROR <<
"No mtdTrayToTdigMap table found in database" << endm;
109 mtdTrayToTdigMap_st *mTrayToTdigTable =
static_cast<mtdTrayToTdigMap_st*
>(mtdTrayToTdigMap->GetTable());
110 for(Int_t i=0; i<gMtdNBacklegs; i++)
112 for(Int_t j=0; j<gMtdNModules; j++)
113 mTray2TdigMap[i][j] = (Int_t)(mTrayToTdigTable->tdigId[i*5+j]);
116 LOG_INFO <<
"Retrieving mtdTrayIdMap table from database ..." << endm;
117 dataset = GetDataBase(
"Geometry/mtd/mtdTrayIdMap");
118 St_mtdTrayIdMap *mtdTrayIdMap =
static_cast<St_mtdTrayIdMap*
>(dataset->
Find(
"mtdTrayIdMap"));
121 LOG_ERROR <<
"No mtdTrayIdMap table found in database" << endm;
124 mtdTrayIdMap_st *mtdTrayIdTable =
static_cast<mtdTrayIdMap_st*
>(mtdTrayIdMap->GetTable());
125 for(Int_t i=0; i<gMtdNBacklegs; i++)
127 for(Int_t j=0; j<gMtdNModules; j++)
128 mTrayId[i][j] = (Int_t)(mtdTrayIdTable->trayId[i*5+j]);
131 LOG_INFO <<
"Retrieving mtdTdigIdMap table from database ..." << endm;
132 dataset = GetDataBase(
"Geometry/mtd/mtdTdigIdMap");
133 St_mtdTdigIdMap *mtdTdigIdMap =
static_cast<St_mtdTdigIdMap*
>(dataset->
Find(
"mtdTdigIdMap"));
136 LOG_ERROR <<
"No mtdTdigIdMap table found in database" << endm;
139 mtdTdigIdMap_st *mtdTdigIdTable =
static_cast<mtdTdigIdMap_st*
>(mtdTdigIdMap->GetTable());
140 for(Int_t i=0; i<gMtdNModulesAll; i++)
142 mTdigId[i] = (Int_t)(mtdTdigIdTable->tdigBoardId[i]);
145 LOG_INFO <<
"Retrieving mtdTriggerTimeCut table from database ..." << endm;
146 dataset = GetDataBase(
"Calibrations/mtd/mtdTriggerTimeCut");
147 St_mtdTriggerTimeCut *mtdTriggerTimeCut =
static_cast<St_mtdTriggerTimeCut*
>(dataset->
Find(
"mtdTriggerTimeCut"));
148 if(!mtdTriggerTimeCut)
150 LOG_ERROR <<
"No mtdTriggerTimeCut table found in database" << endm;
153 mtdTriggerTimeCut_st *mtdTriggerTimeTable =
static_cast<mtdTriggerTimeCut_st*
>(mtdTriggerTimeCut->GetTable());
154 for(Int_t i=0; i<gMtdNModulesAll; i++)
156 mTriggerTimeWindow[i][0] = mtdTriggerTimeTable->minTriggerTime[i];
157 mTriggerTimeWindow[i][1] = mtdTriggerTimeTable->maxTriggerTime[i];
158 LOG_DEBUG <<
"(" << i/5 <<
"," << i%5 <<
"): " << mTriggerTimeWindow[i][0] <<
" - " << mTriggerTimeWindow[i][1] << endm;
162 if(mTriggerWndSelection && mCosmicFlag && mCosmicTrigTimeWinFile.Length()>0)
164 LOG_WARN <<
"Local trigger time window cuts are picked up for cosmic ray data." << endm;
166 inData.open(mCosmicTrigTimeWinFile.Data());
167 Int_t backleg, module;
169 for(Int_t i=0; i<gMtdNModulesAll; i++)
171 inData >> backleg >> module >> mTriggerTimeWindow[i][0] >> mTriggerTimeWindow[i][1];
177 LOG_DEBUG <<
"Initializing INL table:" << endm;
189 memset(mTray2TdigMap,-1,
sizeof(mTray2TdigMap));
190 memset(mTrayId,0,
sizeof(mTrayId));
191 memset(mTdigId,0,
sizeof(mTdigId));
193 if(mINLCorr)
delete mINLCorr;
217 LOG_DEBUG <<
" getting the mtd collection " << mMtdCollection << endm;
218 mStEvent =
dynamic_cast<StEvent *
> (GetInputDS(
"StEvent"));
222 mMtdCollection = mStEvent->mtdCollection();
226 mStEvent->setMtdCollection(mMtdCollection);
234 LOG_WARN<<
"MTD_READER::Unpack MTD Data ERROR!"<<endm;
245 LOG_INFO <<
"No MuDstMaker ..bye-bye..."<<endm;
251 LOG_INFO <<
"No Mudst ... bye-bye" <<endm;
259 Int_t nMtdRawHits = 0;
263 muMtdHeader = muMtdCollection->mtdHeader();
264 nMtdRawHits = muMtdCollection->rawHitsPresent();
268 muMtdHeader = mMuDst->mtdHeader();
269 nMtdRawHits = mMuDst->numberOfBMTDRawHit();
272 for(
int i=0;i<nTHUB;i++)
274 mTriggerTimeStamp[i] = muMtdHeader->triggerTime(i+1);
278 for(Int_t i=0; i<nMtdRawHits; i++)
280 if(muMtdCollection) ahit = muMtdCollection->RawMtdHit(i);
281 else ahit = mMuDst->mtdRawHit(i);
282 Int_t backleg = (Int_t)ahit->backleg();
283 Int_t channel = (Int_t)ahit->channel();
285 if(mYear==13 && mSwapBacklegInRun13 !=0 )
290 if(mSwapBacklegInRun13==1)
292 if(backleg==25) backleg = 26;
293 else if (backleg==26) backleg = 25;
295 else if (mSwapBacklegInRun13==2)
299 if(backleg==25) backleg = 26;
300 else if (backleg==26) backleg = 25;
305 LOG_FATAL <<
"Please check your setup for mSwapBacklegInRun13" << endm;
310 if(mYear>=14 && mReverseStripInRun14)
315 Int_t module = (channel-1)/24 + 1;
318 Int_t cell = (channel-1)%24;
319 if(cell>=0 && cell<=5) cell = 5 - cell;
320 else if (cell>=6 && cell<=11) cell = 17 - cell;
321 else if (cell>=12 && cell<=17) cell = 29 - cell;
322 else if (cell>=18 && cell<=23) cell = 41 - cell;
323 channel = cell + 1 + (module-1)*24;
327 mMtdCollection->addRawHit(
new StMtdRawHit(ahit->flag(),(UChar_t)backleg,(UChar_t)channel,ahit->tdc()));
330 return mMtdCollection;
337 assert(0 &&
"RTS doesn't provide sector by sector legacy mtd banks yet");
351 LOG_DEBUG <<
"GetNextRaw()" << endm;
391 MtdLeadingHits.clear();
392 MtdTrailingHits.clear();
395 for(
int ifib=0;ifib<nTHUB;ifib++)
397 int nword=fMtd->ddl_words[ifib];
398 if(nword <= 0)
continue;
399 int halfbacklegid = -99;
401 mTriggerTimeStamp[ifib] = 0;
403 LOG_DEBUG <<
"RDO " << ifib+1 <<
": words " << fMtd->ddl_words[ifib] << endm;
406 for (
int iword=0;iword<nword;iword++)
408 unsigned int dataword=fMtd->ddl[ifib][iword];
409 LOG_DEBUG <<
"DATAWORD: 0x" << hex << dataword << dec << endm;
412 if( (dataword&0xF0000000)>>28 == 0x2)
415 if(mTriggerTimeStamp[ifib]==0) mTriggerTimeStamp[ifib] = dataword;
419 if( (dataword&0xF0000000)>>28 == 0xD)
continue;
420 if( (dataword&0xF0000000)>>28 == 0xE)
continue;
421 if( (dataword&0xF0000000)>>28 == 0xA)
continue;
424 if( (dataword&0xF0000000)>>28 == 0xC)
426 halfbacklegid = dataword&0x01;
427 backlegid = (dataword&0x0FE)>>1;
432 if(backlegid==25) backlegid = 26;
433 else if (backlegid==26) backlegid = 25;
439 if(halfbacklegid<0)
continue;
440 if(backlegid<1 || backlegid>gMtdNBacklegs)
442 LOG_ERROR<<
"StMtdHitMaker::DATA ERROR!! unexpected backlegid "<< backlegid <<
" !" << endm;
446 if( (dataword&0xF0000000)>>28 == 0x6)
continue;
449 int edgeid =int( (dataword & 0xF0000000)>>28 );
450 if((edgeid !=4) && (edgeid!=5))
continue;
455 int tdcid=(dataword & 0x0F000000)>>24;
458 int tdigid=((tdcid & 0xC)>>2) + halfbacklegid*4;
464 int tdcchan=(dataword&0x00E00000)>>21;
467 unsigned int timeinbin = ((dataword&0x7ffff)<<2)+((dataword>>19)&0x03);
472 for (
int i=1;i<=5;i++)
474 if (mTray2TdigMap[backlegid-1][i-1] == tdigid)
479 if(itray<1||itray>5) LOG_FATAL<<
" Wrong tray ID or mTray2TdigMap missing! backleg = "<<backlegid<<
" trayid = "<<itray<<
" tdigid ="<<tdigid<<endm;
483 memset(&temphit,0,
sizeof(temphit));
484 temphit.
fiberid = (UChar_t)ifib;
486 temphit.tdc = timeinbin;
493 if(mYear>=14 && backlegid==7)
496 Int_t module = (channel-1)/24 + 1;
499 Int_t cell = (channel-1)%24;
500 if(cell>=0 && cell<=5) cell = 5 - cell;
501 else if (cell>=6 && cell<=11) cell = 17 - cell;
502 else if (cell>=12 && cell<=17) cell = 29 - cell;
503 else if (cell>=18 && cell<=23) cell = 41 - cell;
504 channel = cell + 1 + (module-1)*24;
514 MtdLeadingHits.push_back(temphit);
518 MtdTrailingHits.push_back(temphit);
522 LOG_WARN<<
"StMtdHitMaker::Unknown TDC data type ! "<<endm;
544 LOG_WARN <<
"calling Run12++ tdc mapping for Run" << mYear <<
". Not good." << endm;
547 Int_t globalStripId=-1;
549 int globalTdcChan=Hnum*10+tdcChan;
550 for(
int i=0;i<24;i++)
552 if(mtdStrip[i]==globalTdcChan) {globalStripId=i+1;
break;}
555 globalStripId = (globalStripId>12)? globalStripId-12:globalStripId+12;
558 globalStripId += (itray-1)*24;
560 return globalStripId;
574 LOG_WARN <<
"calling pre-Run12 tdc mapping for Run" << mYear <<
". Not good." << endm;
578 Int_t globalStripId=-1;
581 if (tdcId>3) tdcId=tdcId-4;
582 int globalTdcChan=(tdcId+1)*10+tdcChan;
583 for(
int i=0;i<24;i++)
585 if(mtdStrip[i]==globalTdcChan) {globalStripId=i+1;
break;}
591 int globalTdcChan=(tdcId+1)*10+tdcChan;
592 int mtdStripRun11[18]= {34,22,10,37,27,17, 32,20,30,24,11,31, 33,23,16,36,26,15};
593 for(
int i=0;i<18;i++)
595 if(mtdStripRun11[i]==globalTdcChan) {globalStripId=i+1;
break;}
599 return globalStripId;
612 for (
unsigned int i=0;i<MtdLeadingHits.size();i++)
614 char flag = (+1)*(MtdLeadingHits[i].fiberid+1);
615 unsigned char backlegid = MtdLeadingHits[i].backlegid;
616 unsigned char chn = MtdLeadingHits[i].globaltdcchan;
617 unsigned int tdc = MtdLeadingHits[i].tdc;
618 LOG_DEBUG <<
" mtd raw hit LE flag:" << (short)flag <<
" backlegid:"<< (
short)backlegid <<
" chn:" << (short)chn <<
" tdc:"<< tdc << endm;
619 mMtdCollection->addRawHit(
new StMtdRawHit(flag,backlegid,chn,tdc));
622 for (
unsigned int i=0;i<MtdTrailingHits.size();i++)
624 char flag = (-1)*(MtdTrailingHits[i].fiberid+1);
625 unsigned char backlegid = MtdTrailingHits[i].backlegid;
626 unsigned char chn = MtdTrailingHits[i].globaltdcchan;
627 unsigned int tdc = MtdTrailingHits[i].tdc;
628 LOG_DEBUG <<
" mtd raw hit TE flag:" << (short)flag <<
" backlegid:"<< (
short)backlegid <<
" chn:" << (short)chn <<
" tdc:"<< tdc << endm;
629 mMtdCollection->addRawHit(
new StMtdRawHit(flag,backlegid,chn,tdc));
634 MtdLeadingHits.clear();
635 MtdTrailingHits.clear();
636 StSPtrVecMtdRawHit& mtdRawHitVec = mMtdCollection->mtdRawHits();
637 for(
unsigned int i=0;i<mtdRawHitVec.size();i++)
641 rawHit.tdc=aRawHit->tdc();
643 rawHit.
fiberid=aRawHit->fiberId();
645 if(aRawHit->flag()>0)
647 MtdLeadingHits.push_back(rawHit);
651 MtdTrailingHits.push_back(rawHit);
666 for(
int i=0;i<gMtdNModulesAll;i++) mSingleHitVec[i].clear();
667 for(UInt_t i=0;i<MtdLeadingHits.size();i++)
669 unsigned char ifiber = MtdLeadingHits[i].fiberid;
670 int ibackleg = MtdLeadingHits[i].backlegid;
671 unsigned char chn = MtdLeadingHits[i].globaltdcchan;
672 unsigned int tdc = MtdLeadingHits[i].tdc;
673 int itray = (chn-1)/24+1;
674 int ichan = (chn-1)%24;
675 if (ibackleg>gMtdNBacklegs || itray<=0 || itray>gMtdNModules || ichan<0 || ichan>=gMtdNChannels || ifiber>mNFIBER )
677 LOG_FATAL <<
" StMtdHitMaker::fillMtdSingleHits() "
678 <<
": ibackleg=" << ibackleg
679 <<
": itray=" << itray
680 <<
": ichan=" << ichan
681 <<
": ifiber=" << ifiber*1
685 bool iexist = kFALSE;
686 int igtray = (ibackleg-1)*gMtdNModules+itray;
687 for(
size_t ii=0; ii<mSingleHitVec[igtray-1].size(); ii++)
689 if(ibackleg==mSingleHitVec[igtray-1][ii].backleg&&itray==mSingleHitVec[igtray-1][ii].tray && ichan==mSingleHitVec[igtray-1][ii].channel) {
696 aSingleHit.fiberId = ifiber;
697 aSingleHit.backleg = ibackleg;
698 aSingleHit.tray = itray;
699 aSingleHit.channel = ichan;
700 aSingleHit.leadingEdgeTime.push_back(tdc);
701 for(
size_t j=i+1;j<MtdLeadingHits.size();j++)
703 unsigned char jchn = MtdLeadingHits[j].globaltdcchan;
704 int jbackleg = MtdLeadingHits[j].backlegid;
705 int jtray = (jchn-1)/24+1;
706 int jchan = (jchn-1)%24;
707 int jtdc = MtdLeadingHits[j].tdc;
708 if(jbackleg == ibackleg
713 aSingleHit.leadingEdgeTime.push_back(jtdc);
716 for(
size_t j=0;j<MtdTrailingHits.size();j++)
718 unsigned char jchn = MtdTrailingHits[j].globaltdcchan;
719 int jbackleg = MtdTrailingHits[j].backlegid;
720 int jtray = (jchn-1)/24+1;
721 int jchan = (jchn-1)%24;
722 int jtdc = MtdTrailingHits[j].tdc;
723 if(jbackleg == ibackleg
728 aSingleHit.trailingEdgeTime.push_back(jtdc);
731 if(aSingleHit.trailingEdgeTime.size()) mSingleHitVec[igtray-1].push_back(aSingleHit);
737 for(
int i=0;i<gMtdNModulesAll;i++)
739 for(
size_t m=0;m<mSingleHitVec[i].size();m++)
741 LOG_INFO<<
" idx backleg = "<<i/5+1<<
" tray = "<< i%5+1 <<
" channel = "<<mSingleHitVec[i][m].channel<<endm;
742 LOG_INFO<<
" vec backleg = "<<mSingleHitVec[i][m].backleg<<
" tray = "<< mSingleHitVec[i][m].tray <<
" channel = "<<mSingleHitVec[i][m].channel<<endm;
743 LOG_INFO<<
" leading tdcs = " <<endm;
744 for(
size_t j=0;j<mSingleHitVec[i][m].leadingEdgeTime.size();j++)
746 LOG_INFO <<
" " << mSingleHitVec[i][m].leadingEdgeTime[j] << endm;
748 LOG_INFO<<
" trailing tdcs = " <<endm;
749 for(
size_t j=0;j<mSingleHitVec[i][m].trailingEdgeTime.size();j++)
751 LOG_INFO <<
" " << mSingleHitVec[i][m].trailingEdgeTime[j] <<endm;
763 for(
int i=0;i<gMtdNModulesAll;i++)
765 if(mSingleHitVec[i].size()>0)
767 gTrayVec.push_back(i+1);
775 IntVec StMtdHitMaker::GetValidChannel(
int backleg,
int tray,
int &fiber)
778 int igtray = (backleg-1)*gMtdNModules+tray;
779 if(igtray>gMtdNModulesAll)
return chanVec;
781 for(
size_t i=0 ; i<mSingleHitVec[igtray-1].size() ; i++)
783 if( mSingleHitVec[igtray-1][i].tray == tray
784 && mSingleHitVec[igtray-1][i].backleg == backleg )
786 chanVec.push_back(mSingleHitVec[igtray-1][i].channel);
787 fiber = mSingleHitVec[igtray-1][i].fiberId;
795 UIntVec StMtdHitMaker::GetLeadingTdc(
int backleg,
int tray,
int channel)
798 int igtray = (backleg-1)*gMtdNModules+tray;
799 for(
size_t i=0 ; i<mSingleHitVec[igtray-1].size() ; i++)
801 if(mSingleHitVec[igtray-1][i].backleg!=backleg)
continue;
802 if(mSingleHitVec[igtray-1][i].tray!=tray)
continue;
803 if(mSingleHitVec[igtray-1][i].channel!=channel)
continue;
804 for(
size_t j=0; j<mSingleHitVec[igtray-1][i].leadingEdgeTime.size(); j++)
806 leTdc.push_back(mSingleHitVec[igtray-1][i].leadingEdgeTime[j]);
814 UIntVec StMtdHitMaker::GetTrailingTdc(
int backleg,
int tray,
int channel)
817 int igtray = (backleg-1)*gMtdNModules+tray;
818 for(
size_t i=0 ; i<mSingleHitVec[igtray-1].size() ; i++)
820 if(mSingleHitVec[igtray-1][i].backleg!=backleg)
continue;
821 if(mSingleHitVec[igtray-1][i].tray!=tray)
continue;
822 if(mSingleHitVec[igtray-1][i].channel!=channel)
continue;
823 for(
size_t j=0; j<mSingleHitVec[igtray-1][i].trailingEdgeTime.size(); j++)
825 teTdc.push_back(mSingleHitVec[igtray-1][i].trailingEdgeTime[j]);
839 int shouldHaveRejectEvent = -1;
840 unsigned int tpcSectorMask = 0;
848 muMtdHeader = muMtdCollection->mtdHeader();
850 muMtdHeader = mMuDst->mtdHeader();
852 shouldHaveRejectEvent = muMtdHeader->shouldHaveRejectEvent();
853 tpcSectorMask = muMtdHeader->tpcSectorMask();
857 TDataSet* ds = FindDataSet(
"MtdShouldHaveRejectEvent");
858 shouldHaveRejectEvent = (ds ? atoi(ds->GetTitle()) : -1);
859 ds = FindDataSet(
"TpcSectorsByMtd");
860 tpcSectorMask = (ds ? (
unsigned int) atoi(ds->GetTitle()) : 0U);
864 for(
int i=0;i<nTHUB;i++)
866 mtdHeader->setTriggerTime(mTriggerTimeStamp[i], i);
867 LOG_DEBUG <<
"Trigger Time Stamp "<< i+1 <<
": " << (
unsigned int)mTriggerTimeStamp[i] << endm;
869 mtdHeader->setShouldHaveRejectEvent(shouldHaveRejectEvent);
870 mtdHeader->setTpcSectorMask(tpcSectorMask);
872 mMtdCollection->setHeader(mtdHeader);
882 vector<MTDOneSideHit> mOneSideHits;
884 LOG_DEBUG <<
" Number of fired trays " << validtray.size() <<endm;
885 for(
size_t i=0;i<validtray.size();i++)
887 int igtray = validtray[i];
888 int backleg = (igtray-1)/gMtdNModules+1;
889 int tray = (igtray-1)%gMtdNModules+1;
891 IntVec validchan = GetValidChannel(backleg,tray,fiber);
892 LOG_DEBUG <<
"fired backleg " << backleg <<
" tray " << tray << endm;
893 LOG_DEBUG <<
" total channels "<<validchan.size() <<endm;
894 for(
size_t iv=0;iv<validchan.size();iv++)
896 UIntVec leTdc = GetLeadingTdc(backleg, tray, validchan[iv]);
897 UIntVec teTdc = GetTrailingTdc(backleg, tray, validchan[iv]);
899 LOG_DEBUG <<
" leTdc.size():"<<leTdc.size()<<
" teTdc.size():"<<teTdc.size()<<endl;
900 if(!leTdc.size() || !teTdc.size())
continue;
901 int chan = validchan[iv];
903 int tdigboardid = getTdigBoardId(backleg,tray,chan);
904 int ilocalchan = getLocalTdcChan(backleg,tray,chan);
905 unsigned int tmptdc = leTdc[0];
906 int bin = tmptdc&0x3ff;
907 double tmptdc_f = tmptdc+mINLCorr->
getTdigINLCorr(tdigboardid,ilocalchan,bin);
908 double letime = tmptdc_f*VHRBIN2PS / 1000.;
912 tmptdc_f = tmptdc+mINLCorr->
getTdigINLCorr(tdigboardid,ilocalchan,bin);
913 double tetime = tmptdc_f*VHRBIN2PS / 1000.;
916 tmpHit.fiberId = fiber;
917 tmpHit.backleg = backleg;
919 tmpHit.channel = channel;
920 tmpHit.leadingEdgeTime = letime;
921 tmpHit.trailingEdgeTime = tetime;
922 mOneSideHits.push_back(tmpHit);
927 int nHits = mOneSideHits.size();
928 LOG_DEBUG <<
" one side hits # = "<<nHits<<endm;
929 for(
int i=0;i<nHits;i++)
931 int iBackLeg = mOneSideHits[i].backleg;
932 int iTray = mOneSideHits[i].tray;
933 int iCell = mOneSideHits[i].channel;
934 int iFiber = mOneSideHits[i].fiberId;
935 float iLeadingEdgeTime = mOneSideHits[i].leadingEdgeTime;
936 float iTrailingEdgeTime = mOneSideHits[i].trailingEdgeTime;
937 for(
int j=i+1;j<nHits;j++)
939 int jBackLeg = mOneSideHits[j].backleg;
940 int jTray = mOneSideHits[j].tray;
941 int jCell = mOneSideHits[j].channel;
942 int jFiber = mOneSideHits[j].fiberId;
943 float jLeadingEdgeTime = mOneSideHits[j].leadingEdgeTime;
944 float jTrailingEdgeTime = mOneSideHits[j].trailingEdgeTime;
945 if(abs(iCell-jCell)!=12)
continue;
946 if(iBackLeg != jBackLeg)
continue;
947 if(iTray != jTray)
continue;
948 if(iFiber != jFiber)
continue;
949 UChar_t mBackLeg = iBackLeg;
950 UChar_t mModule = iTray;
952 pair<Double_t,Double_t> mLeadingEdgeTime;
953 pair<Double_t,Double_t> mTrailingEdgeTime;
958 mLeadingEdgeTime.first = iLeadingEdgeTime;
959 mLeadingEdgeTime.second = jLeadingEdgeTime;
960 mTrailingEdgeTime.first = iTrailingEdgeTime;
961 mTrailingEdgeTime.second = jTrailingEdgeTime;
966 mLeadingEdgeTime.first = jLeadingEdgeTime;
967 mLeadingEdgeTime.second = iLeadingEdgeTime;
968 mTrailingEdgeTime.first = jTrailingEdgeTime;
969 mTrailingEdgeTime.second = iTrailingEdgeTime;
972 if(mTriggerWndSelection)
975 float timeDiff = (mLeadingEdgeTime.first+mLeadingEdgeTime.second)/2 - 25.*(mTriggerTimeStamp[iFiber] & 0xfff);
976 while(timeDiff<0) timeDiff += 51200;
977 int igtray = (iBackLeg-1)*gMtdNModules+iTray;
978 if(timeDiff<mTriggerTimeWindow[igtray-1][0] || timeDiff>mTriggerTimeWindow[igtray-1][1])
continue;
982 aHit->setBackleg(mBackLeg);
983 aHit->setModule(mModule);
984 aHit->setCell(mCell);
985 aHit->setLeadingEdgeTime(mLeadingEdgeTime);
986 aHit->setTrailingEdgeTime(mTrailingEdgeTime);
987 mMtdCollection->addHit(aHit);
989 LOG_DEBUG <<
" backleg " << mBackLeg*1
990 <<
" module "<< mModule*1
991 <<
" cell " <<mCell*1
992 <<
" leading.first "<<mLeadingEdgeTime.first
993 <<
" leading.second "<<mLeadingEdgeTime.second
994 <<
" trailing.first "<<mTrailingEdgeTime.first
995 <<
" trailing.second "<<mTrailingEdgeTime.second<<endm;
999 LOG_DEBUG <<
" matched hits " << nMtdHits <<endm;
1008 LOG_DEBUG <<
"fillStEvent() Starting..." << endm;
1013 LOG_WARN <<
"No MtdCollection ... creating an empty one in StEvent" << endm;
1016 mStEvent->setMtdCollection(mMtdCollection);
1030 if(mtdCollection->rawHitsPresent())
1032 StSPtrVecMtdRawHit& rawMtdVec = mtdCollection->mtdRawHits();
1034 if(!mUseMuDst || Debug())
1036 LOG_INFO << rawMtdVec.size() <<
" MTD raw hits in event ..." << endm;
1041 for(
size_t i=0;i<rawMtdVec.size();i++)
1043 LOG_DEBUG << (*rawMtdVec[i]) << endm;
1049 LOG_DEBUG <<
"No MtdRawHitCollection" << endm;
1052 if(mtdCollection->hitsPresent())
1054 StSPtrVecMtdHit& mtdVec = mtdCollection->mtdHits();
1056 if(!mUseMuDst || Debug())
1058 LOG_INFO << mtdVec.size() <<
" MTD hits in event ..." << endm;
1063 for(
size_t i=0;i<mtdVec.size();i++)
1065 LOG_DEBUG << (*mtdVec[i]) << endm;
1070 LOG_DEBUG <<
"No MtdHitCollection" << endm;
1075 LOG_WARN <<
"No MtdCollection" << endm;
1076 LOG_WARN <<
"No MtdRawHitCollection" << endm;
1077 LOG_WARN <<
"No MtdHitCollection" << endm;
1083 Int_t StMtdHitMaker::getTdigBoardId(Int_t backlegid, Int_t tray, Int_t chn)
1085 Int_t tdigboardid = mTdigId[mTrayId[backlegid-1][tray-1]-200];
1091 Int_t StMtdHitMaker::getLocalTdcChan(Int_t backlegid, Int_t tray, Int_t chn)
1094 int itdigid = mTray2TdigMap[backlegid-1][tray-1];
1095 if(itdigid>3) channel = (channel>11)?channel-12:channel+12;
1097 int iglobalChan = mtdStrip[channel];
1098 int ilocalChan = (iglobalChan/10-1)*8+iglobalChan%10;
Class StRTSBaseMaker - is an abstract StMaker to define the interface to access the DAQ data from the...
UChar_t globaltdcchan
1,2,...,117
void Clear(Option_t *option="")
User defined functions.
void fillMtdHitCollection()
StRtsTable * GetNextRaw()
This is an overloaded member function, provided for convenience.
UChar_t fiberid
data word before unpack
UInt_t dataword
tdc time (in bin) per hit.
IntVec GetValidTrays()
ship collection to StEvent and check
float getTdigINLCorr(int tdigId, int tdcChannel, int bin)
direct access to INL correction table for any TDIG-Id
StMtdCollection * GetMtdCollection()
void initFromDbase(StMaker *maker)
Initial function to access the data base and retrieve INL tables.
StRtsTable * DaqDta()
Return the current DAQ data block. This member function is provided for convenience.
Int_t tdcChan2globalStrip11(Int_t, Int_t, Int_t, Int_t)
Int_t tdcChan2globalStrip(Int_t, Int_t, Int_t, Int_t)
StMtdHitMaker(const char *name="mtd_raw")
Default constructor.
virtual StRtsTable * GetNextLegacy()
This is an overloaded member function, provided for convenience.
void setMtdArray(StMtdCollection *mtd_coll)
void fillMtdRawHitCollection()
virtual TDataSet * Find(const char *path) const