9 #include "StEmcAssociationMaker.h"
14 #include "StEmcUtil/geometry/StEmcGeom.h"
15 #include "StMcEvent/StMcCalorimeterHit.hh"
16 #include "StMcEventTypes.hh"
17 #include "StMcEvent.hh"
18 #include "StEventTypes.h"
19 #include <StMessMgr.h>
28 StEmcAssociation::~StEmcAssociation()
32 { mCluster=c; mFTrack = ft; mFEmc = fe;}
33 StEmcClusterAssociation::~StEmcClusterAssociation()
37 { mPoint=p; mAssocType = at; }
38 StEmcPointAssociation::~StEmcPointAssociation()
41 StEmcAssociationMaker::StEmcAssociationMaker(
const char* name):
StMaker(name)
43 for(Int_t i=0;i<NDETECTORS;i++)
45 mTrackCluster[i] = NULL;
46 mClusterTrack[i] = NULL;
54 StEmcAssociationMaker::~StEmcAssociationMaker()
57 void StEmcAssociationMaker::Clear(
const char* a)
59 if(mPrint) cout <<
"Cleaning old stuff from EMC association\n";
60 for(Int_t i=0;i<NDETECTORS;i++)
62 if(mPrint) cout <<
"Cleaning for detector "<<i<<endl;
65 for(multiEmcTrackClusterIter j=mTrackCluster[i]->begin(); j!=mTrackCluster[i]->end(); j++)
67 SafeDelete((*j).second);
69 mTrackCluster[i]->clear();
70 SafeDelete(mTrackCluster[i]);
71 mTrackCluster[i]=NULL;
75 mClusterTrack[i]->clear();
76 SafeDelete(mClusterTrack[i]);
77 mClusterTrack[i]=NULL;
80 if (mPrint) cout <<
"Cleaning points Association\n";
83 for(multiEmcTrackPointIter j=mTrackPoint->begin(); j!=mTrackPoint->end(); j++)
85 SafeDelete((*j).second);
88 SafeDelete(mTrackPoint);
94 SafeDelete(mPointTrack);
100 Int_t StEmcAssociationMaker::Init()
102 return StMaker::Init();
107 if(mPrint) gMessMgr->Info() <<
"StEmcAssociationMaker::Make()" << endm;
112 StSPtrVecMcTrack& tracks=mcEvent->tracks();
113 if(tracks.size()==0)
return kStWarn;
120 if(!emcCollection)
return kStWarn;
123 for (Int_t detnum=0; detnum<NDETECTORS; detnum++)
125 if(mPrint) cout <<
"Doing association for detector "<<detnum<<endl;
126 StDetectorId detId=
static_cast<StDetectorId
>(detnum+kBarrelEmcTowerId);
129 if (detector) clusterColl=detector->cluster();
132 StSPtrVecEmcCluster& clusters=clusterColl->clusters();
135 if(mPrint) cout<<
"Track size = "<<tracks.size()<<
" cluster size = "<<clusters.size()<<endl;
136 if(!mTrackCluster[detnum]) mTrackCluster[detnum]=
new multiEmcTrackCluster;
137 if(!mClusterTrack[detnum]) mClusterTrack[detnum]=
new multiEmcClusterTrack;
139 for (UInt_t i=0; i<tracks.size(); i++)
141 StPtrVecMcCalorimeterHit hits;
144 case 0: { hits=tracks[i]->bemcHits();
break; }
145 case 1: { hits=tracks[i]->bprsHits();
break; }
146 case 2: { hits=tracks[i]->bsmdeHits();
break; }
147 case 3: { hits=tracks[i]->bsmdpHits();
break; }
148 default: { gMessMgr->Warning()<<
"Detector does not exist"<<endm;
break; }
154 for (UInt_t i2=0; i2<hits.size(); i2++)
156 Float_t hitEnergy=dEToEnergy(hits[i2],detnum);
160 for (UInt_t j=0; j<clusters.size(); j++){
161 StPtrVecEmcRawHit& clHits=clusters[j]->hit();
162 Float_t trackEnergyFraction=0;
163 Float_t clusterEnergyFraction=0;
165 for (UInt_t k=0; k<hits.size(); k++){
166 UInt_t module=hits[k]->module();
167 UInt_t eta=hits[k]->eta();
168 Int_t sub=hits[k]->sub();
170 for (UInt_t l=0; l<clHits.size(); l++){
171 UInt_t clModule=clHits[l]->module();
172 UInt_t clEta=clHits[l]->eta();
173 Int_t clSub=abs(clHits[l]->sub());
175 if (module==clModule && eta==clEta && sub==clSub){
177 Float_t hitEnergy=dEToEnergy(hits[k],detnum);
178 trackEnergyFraction+=hitEnergy/energy;
179 Float_t clEnergy=clusters[j]->energy();
180 clusterEnergyFraction+=hitEnergy/clEnergy;
186 mTrackCluster[detnum]->insert(multiEmcTrackClusterValue(tracks[i],c));
188 mClusterTrack[detnum]->insert(multiEmcClusterTrackValue(clusters[j],c));
198 if(mPrint) cout <<
"Doing point association\n";
199 StSPtrVecEmcPoint& barrelPoints=emcCollection->barrelPoints();
200 if(barrelPoints.size()!=0)
203 if(!mTrackPoint) mTrackPoint =
new multiEmcTrackPoint;
204 if(!mPointTrack) mPointTrack =
new multiEmcPointTrack;
206 for (UInt_t i=0; i<tracks.size(); i++)
208 StPtrVecMcCalorimeterHit hits;
210 for (UInt_t j=0; j<barrelPoints.size(); j++)
213 for(Int_t detnum=0;detnum<NDETECTORS;detnum++)
217 case 0: { hits=tracks[i]->bemcHits();
break; }
218 case 1: { hits=tracks[i]->bprsHits();
break; }
219 case 2: { hits=tracks[i]->bsmdeHits();
break; }
220 case 3: { hits=tracks[i]->bsmdpHits();
break; }
221 default: { gMessMgr->Warning()<<
"Detector does not exist"<<endm;
break; }
223 StDetectorId detId=
static_cast<StDetectorId
>(detnum+kBarrelEmcTowerId);
224 StPtrVecEmcCluster& cluster=barrelPoints[j]->cluster(detId);
225 for (UInt_t k=0; k<hits.size(); k++)
if(hits[k])
227 UInt_t module=hits[k]->module();
228 UInt_t eta=hits[k]->eta();
229 Int_t sub=hits[k]->sub();
231 for (UInt_t j2=0; j2<cluster.size(); j2++)
if(cluster[j2])
233 StPtrVecEmcRawHit& clHit=cluster[j2]->hit();
234 for (UInt_t l=0; l<clHit.size(); l++)
if(clHit[l])
236 UInt_t clModule=clHit[l]->module();
237 UInt_t clEta=clHit[l]->eta();
238 Int_t clSub=abs(clHit[l]->sub());
241 if (module==clModule && eta==clEta && sub==clSub) { assoc+=(1<<(detnum));
goto nextDetector;}
245 nextDetector:
continue;
249 mTrackPoint->insert(multiEmcTrackPointValue(tracks[i],p));
250 mPointTrack->insert(multiEmcPointTrackValue(barrelPoints[j],p));
262 gMessMgr->Info() <<
"StEmcAssociationMaker::Finish()" << endm;
270 Float_t P0[]={14.69,559.7,0.1185e6,0.1260e6};
271 Float_t P1[]={-0.1022,-109.9,-0.3292e5,-0.1395e5};
272 Float_t P2[]={0.7484,-97.81,0.3113e5,0.1971e5};
274 UInt_t m=hit->module();
276 Float_t dE=hit->dE();
277 Float_t hitEnergy = 0;
279 StEmcGeom* emcGeom=StEmcGeom::instance(detnum+1);
281 emcGeom->getEta(m,e,Eta);
283 Float_t sf=P0[detnum]+P1[detnum]*x+P2[detnum]*x*x;
285 if (hitEnergy<=0) hitEnergy=0;
292 if(det>0)
return mTrackCluster[det-1];
299 if(det>0)
return mClusterTrack[det-1];
305 const TString det[] = {
"bemc",
"bprs",
"bsmde",
"bsmdp"};
307 for (Int_t i=0; i<NDETECTORS; i++)
308 if (!strcmp(detname,det[i])) detnum = i+1;
312 void StEmcAssociationMaker::printMaps()
314 const TString det[] = {
"bemc",
"bprs",
"bsmde",
"bsmdp"};
315 for(
int i=0;i<NDETECTORS;i++)
317 cout <<
"-----------------------------------------------------------\n";
318 cout <<
"ASSOCIATION FOR DETECTOR "<<det[i].Data()<<endl;
322 cout <<
"Track->Cluster Association Map\n";
323 for(multiEmcTrackClusterIter j=map->begin(); j!=map->end(); j++)
333 cout <<
" McTrack = "<<track<<
" GeantId = "<<track->geantId()<<
" pt = "<<track->pt()<<
" TReta = "<<track->pseudoRapidity()
334 <<
" Cl = "<<c<<
" E = "<<c->energy()<<
" eta = "<<c->eta()<<
" phi = "<<c->phi()
335 <<
" FrTr = "<<value->getFractionTrack()<<
" FrCl = "<<value->getFractionCluster()<<endl;
344 cout <<
"Cluster->Track Association Map\n";
345 for(multiEmcClusterTrackIter j=map1->begin(); j!=map1->end(); j++)
354 cout <<
" Cl = "<<c<<
" E = "<<c->energy()<<
" eta = "<<c->eta()<<
" phi = "<<c->phi()
355 <<
" McTrack = "<<track<<
" GeantId = "<<track->geantId()<<
" pt = "<<track->pt()<<
" TReta = "<<track->pseudoRapidity()
356 <<
" FrTr = "<<value->getFractionTrack()<<
" FrCl = "<<value->getFractionCluster()<<endl;
365 cout <<
"Track->Point Association Map\n";
366 for(multiEmcTrackPointIter j = mapPoint->begin(); j!=mapPoint->end(); j++)
375 cout <<
" McTrack = "<<track<<
" GeantId = "<<track->geantId()<<
" pt = "<<track->pt()<<
" TReta = "<<track->pseudoRapidity()
376 <<
" Point = "<<point<<
" E = "<<point->energy()
377 <<
" Assoc. = "<<value->getAssociation();
378 for(
int i=1;i<=4;i++) cout <<
" det "<<i<<
" A = "<< value->getAssociation(i);
387 cout <<
"Point->Track Association Map\n";
388 for(multiEmcPointTrackIter j = mapPoint1->begin(); j!=mapPoint1->end(); j++)
397 cout <<
" McTrack = "<<track<<
" GeantId = "<<track->geantId()<<
" pt = "<<track->pt()<<
" TReta = "<<track->pseudoRapidity()
398 <<
" Point = "<<point<<
" E = "<<point->energy()
399 <<
" Assoc. = "<<value->getAssociation();
400 for(
int i=1;i<=4;i++) cout <<
" det "<<i<<
" A = "<< value->getAssociation(i);
407 void StEmcAssociationMaker::printTracks()
410 if (!mcEvent)
return;
411 StSPtrVecMcTrack& tracks=mcEvent->tracks();
412 if(tracks.size()==0)
return;
417 cout<<
"Primary Vertex (x,y,z) = "<<v->position().x()<<
" "<<v->position().y()<<
" "<<v->position().z()<<
" "<<endl;
419 for(UInt_t i = 0; i<tracks.size();i++)
421 cout <<
"Track " <<tracks[i]<<
" Geant Id = "<<tracks[i]->geantId()<<
" pT = "<< tracks[i]->pt()
422 <<
" eta = "<<tracks[i]->pseudoRapidity()
423 <<
" phi = "<<tracks[i]->momentum().phi()<<endl;
424 cout <<
" Parent = "<<tracks[i]->parent()<<endl;
425 v = tracks[i]->startVertex();
426 if(v) cout <<
" Start vertex (x,y,z) = "<<v->position().x()<<
" "<<v->position().y()<<
" "<<v->position().z()<<
" "<<endl;
427 v = tracks[i]->stopVertex();
428 if(v) cout <<
" Stop vertex (x,y,z) = "<<v->position().x()<<
" "<<v->position().y()<<
" "<<v->position().z()<<
" "<<endl;
multiEmcTrackCluster * getTrackClusterMap(Int_t i)
returns multimap for association betwwen MC tracks and clusters
Int_t getDetNum(const char *)
returns detector number for each EMC sub detector
Monte Carlo Track class All information on a simulated track is stored in this class: kinematics...
multiEmcPointTrack * getPointTrackMap()
returns multimap for association betwwen points and MC tracks
multiEmcClusterTrack * getClusterTrackMap(Int_t i)
returns multimap for association betwwen clusters and MC tracks
multiEmcTrackPoint * getTrackPointMap()
returns multimap for association betwwen MC tracks and points
Event data structure to hold all information from a Monte Carlo simulation. This class is the interfa...