12 #include <StMessMgr.h>
13 #include "St_db_Maker/St_db_Maker.h"
14 #include "StTrack2FastDetectorMatcher.h"
16 #include "StEEmcUtil/database/StEEmcDb.h"
17 #include "StEEmcUtil/database/EEmcDbItem.h"
18 #include "StEEmcUtil/database/cstructs/eemcConstDB.hh"
19 #include "StEEmcUtil/EEmcGeom/EEmcGeomSimple.h"
20 #include "StEmcCollection.h"
21 #include "StBTofCollection.h"
22 #include "StBTofUtil/StBTofGeometry.h"
23 #include "TGeoManager.h"
27 StTrack2FastDetectorMatcher::StTrack2FastDetectorMatcher() : mTotEve(0), mMinZBtof(-3.0), mMaxZBtof(3.0), mMinAdcBemc(5), mMinAdcEemc(5),
31 bemcList(0), eemcList(0), btofGeom(0),
34 LOG_INFO <<
"StTrack2FastDetectorMatcher::StTrack2FastDetectorMatcher is in use" << endm;
38 StTrack2FastDetectorMatcher::Clear(
const Char_t *opt){
39 LOG_DEBUG <<
"StTrack2FastDetectorMatcher::Clear nEve="<<mTotEve<< endm;
40 if (btofList) btofList->clear();
41 if (ctbList) ctbList->clear();
42 if (bemcList) bemcList->clear();
43 if (eemcList) eemcList->clear();
47 StTrack2FastDetectorMatcher::~StTrack2FastDetectorMatcher() {
58 void StTrack2FastDetectorMatcher::fillArrays(
StEvent* event) {
59 static Bool_t InitRun = kTRUE;
61 isMC = (!
event->triggerData() );
63 Int_t dateY=mydb->GetDateTime().GetYear();
65 eeDb = (
StEEmcDb*)StMaker::GetChain()->GetDataSet(
"StEEmcDb");
69 UInt_t killStatEEmc=EEMCSTAT_ONLPED | EEMCSTAT_STKBT| EEMCSTAT_HOTHT | EEMCSTAT_HOTJP | EEMCSTAT_JUMPED ;
70 eemcList =
new StEemcHitList(eeDb, killStatEEmc,geomE); eemcList->initRun();
78 TVolume *starHall = gGeoManager ?
nullptr : (
TVolume *)mydb->GetDataSet(
"HALL");
79 LOG_INFO <<
" BTofGeometry initialization ... " << endm;
81 if (isMC) btofGeom->SetMCOn();
82 else btofGeom->SetMCOff();
83 btofGeom->Init(mydb, starHall, gGeoManager);
84 mydb->AddConst(
new TObjectSet(
"btofGeometry",btofGeom));
94 LOG_INFO <<
"StTrack2FastDetectorMatcher M-C, Db_date="<<mydb->GetDateTime().AsString()<<endm;
98 if(dateY>=2008) mMinAdcBemc =8;
100 if(dateY<2006) mMinAdcBemc = 15;
101 else mMinAdcBemc = 8;
104 <<
"\n Min/Max Z position for BTOF hit = "<<mMinZBtof<<
" "<<mMaxZBtof
105 <<
"\n MinAdcBemc for MIP ="<<mMinAdcBemc
106 <<
"\n MinAdcEemc for MIP ="<<mMinAdcEemc
107 <<
"\n bool isMC ="<<isMC
108 <<
"\n bool useCtb ="<< (ctbList != 0)
109 <<
"\n bool useBemc ="<< (bemcList != 0)
110 <<
"\n bool useEemc ="<< (eemcList != 0)
111 <<
"\n bool useBtof ="<< (btofList != 0)
115 StEvent *mEvent = (
StEvent *) StMaker::GetChain()->GetInputDS(
"StEvent");
120 LOG_INFO <<
"StTrack2FastDetectorMatcher::fillArrays START nEve="<<mTotEve<<
" eveID="<<eveID<< endm;
124 if (btofColl) btofList->build(btofColl);
130 ctbList->buildFromData(trgD);
132 if(StMaker::GetChain()->GetDataSet(
"geant/g2t_ctb_hit")) {
133 St_DataSet *gds=StMaker::GetChain()->GetDataSet(
"geant");
134 ctbList->buildFromMC(gds);
142 if(btow) bemcList->build(btow, mMinAdcBemc);
146 if (etow) eemcList->build(etow, mMinAdcEemc);
159 for(
size_t i=0;i<idVec.size();i++) {
160 Int_t tray, module, cell;
161 btofGeom->DecodeCellId(idVec[i], cell, module, tray);
163 Double_t local[3], global[3];
164 for(Int_t j=0;j<3;j++) local[j] = 0;
165 global[0] = crossVec[i].x();
166 global[1] = crossVec[i].y();
167 global[2] = crossVec[i].z();
170 LOG_WARN <<
"no sensitive module in this projection??? - weird" << endm;
173 sensor->Master2Local(&global[0],&local[0]);
174 if(local[2]<mMinZBtof||local[2]>mMaxZBtof)
continue;
175 Int_t iBin = btofList->addBtofTrack(tray, module, cell);
176 if (iBin < 0)
continue;
177 iBinVec.push_back(iBin);
178 btofList->addBtofTrack(tray, module, cell);
181 if (! iBinVec.size())
return;
182 Bool_t btofMatch=btofList->isMatched(iBinVec);
183 Bool_t btofVeto =btofList->isVetoed(iBinVec);
184 Float_t btofW =btofList->getWeight(iBinVec);
185 LOG_DEBUG <<
" ** BTOF ** match/veto/weight = " << btofMatch <<
" " << btofVeto <<
" " << btofW << endm;
186 t->updateAnyMatch(btofMatch,btofVeto,t->mBtof);
188 t->btofBin= iBinVec.size();
193 const Double_t Rctb=213.6;
200 if(d2.first>=0 || d2.second<=0) {
201 LOG_DEBUG <<Form(
"WARN MatchTrk , unexpected solution for track crossing CTB\n")<<
202 Form(
" d2.firts=%f, second=%f, try first", d2.first, d2.second)<<endm;
205 posCTB = hlx->at(path);
209 Float_t phi=TMath::ATan2(posCTB.y(),posCTB.x());
210 if(phi < ctbList->MinPhi()) phi+=2*TMath::Pi();
211 Float_t eta=posCTB.pseudoRapidity();
214 Int_t iBin=ctbList->addTrack(eta,phi);
215 if (iBin < 0)
return;
216 Bool_t ctbMatch=ctbList->isMatched(iBin);
217 Bool_t ctbVeto =ctbList->isVetoed(iBin);
218 Float_t ctbW =ctbList->getWeight(iBin);
220 t->updateAnyMatch(ctbMatch,ctbVeto,t->mCtb);
232 if(d2.first>=0 || d2.second<=0) {
234 printf(
"WARN MatchTrk , unexpected solution for track crossing Cyl\n");
235 printf(
" d2.firts=%f, second=%f, try first\n",
236 d2.first, d2.second);
240 posCyl = hlx->at(path);
244 Float_t phi=TMath::ATan2(posCyl.y(),posCyl.x());
245 if(phi < bemcList->MinPhi()) phi+=2*TMath::Pi();
246 Float_t eta=posCyl.pseudoRapidity();
250 Int_t iBin=bemcList->addTrack(eta,phi);
251 if (iBin < 0)
return;
252 Bool_t bemcMatch=bemcList->isMatched(iBin);
253 Bool_t bemcVeto =bemcList->isVetoed(iBin);
254 Float_t bemcW =bemcList->getWeight(iBin);
256 t->updateAnyMatch(bemcMatch,bemcVeto,t->mBemc);
265 const Float_t maxPath=200 ;
275 if(path>maxPath)
return;
278 Float_t periodL=hlx-> period();
281 printf(
" Warn, long path fac=%.1f ",path/periodL);
282 printf(
" punchEEMC1 x,y,z=%.1f, %.1f, %.1f path=%.1f period=%.1f\n",r.x(),r.y(),r.z(),path,periodL);
285 Float_t phi=TMath::ATan2(r.y(),r.x());
286 if(phi < eemcList->MinPhi()) phi+=2*TMath::Pi();
287 Float_t eta=r.pseudoRapidity();
289 Int_t iBin=eemcList->addTrack(eta,phi);
290 if (iBin < 0)
return;
291 Bool_t eemcMatch=eemcList->isMatched(iBin);
292 Bool_t eemcVeto =eemcList->isVetoed(iBin);
293 Float_t eemcW =eemcList->getWeight(iBin);
295 t->updateAnyMatch(eemcMatch,eemcVeto,t->mEemc);
302 if (btofList && btofList->NoHits()) matchTrack2BTOF(hlx,t);
303 if (ctbList && ctbList->NoHits() ) matchTrack2CTB(hlx,t);
304 if (bemcList && bemcList->NoHits()) matchTrack2BEMC(hlx,t,242);
305 if (eemcList && eemcList->NoHits()) matchTrack2EEMC(hlx,t,288);
Bool_t HelixCrossCellIds(const StHelixD &helix, IntVec &idVec, DoubleVec &pathVec, PointVec &crossVec) const
pair< double, double > pathLength(double r) const
path length at given r (cylindrical r)
virtual TObject * GetObject() const
The depricated method (left here for the sake of the backward compatibility)