9 #include "StEEmcAssociationMaker.h"
14 #include "StEmcUtil/geometry/StEmcGeom.h"
15 #include "StEEmcUtil/EEmcGeom/EEmcGeomDefs.h"
16 #include "StMcEventTypes.hh"
17 #include "StMcEvent.hh"
18 #include "StEventTypes.h"
19 #include <StMessMgr.h>
21 const TString eemcDetname[] = {
"etow",
"eprs",
"esmdu",
"esmdv"};
30 StEEmcAssociation::~StEEmcAssociation()
34 { mCluster=c; mFTrack = ft; mFEmc = fe;}
35 StEEmcClusterAssociation::~StEEmcClusterAssociation()
39 { mPoint=p; mAssocType = at; }
40 StEEmcPointAssociation::~StEEmcPointAssociation()
43 StEEmcAssociationMaker::StEEmcAssociationMaker(
const char* name):
StMaker(name)
45 for(Int_t i=0;i<NDETECTORS;i++)
47 mTrackCluster[i] = NULL;
48 mClusterTrack[i] = NULL;
56 StEEmcAssociationMaker::~StEEmcAssociationMaker()
59 void StEEmcAssociationMaker::Clear(
const char* a)
61 if(mPrint) cout <<
"Cleaning old stuff from EEMC association\n";
62 for(Int_t i=0;i<NDETECTORS;i++)
64 if(mPrint) cout <<
"Cleaning for detector "<<i<<endl;
67 for(multiEEmcTrackClusterIter j=mTrackCluster[i]->begin(); j!=mTrackCluster[i]->end(); j++)
69 SafeDelete((*j).second);
71 mTrackCluster[i]->clear();
72 SafeDelete(mTrackCluster[i]);
73 mTrackCluster[i]=NULL;
77 mClusterTrack[i]->clear();
78 SafeDelete(mClusterTrack[i]);
79 mClusterTrack[i]=NULL;
82 if (mPrint) cout <<
"Cleaning points Association\n";
85 for(multiEEmcTrackPointIter j=mTrackPoint->begin(); j!=mTrackPoint->end(); j++)
87 SafeDelete((*j).second);
90 SafeDelete(mTrackPoint);
96 SafeDelete(mPointTrack);
102 Int_t StEEmcAssociationMaker::Init()
104 return StMaker::Init();
109 if(mPrint) gMessMgr->Info() <<
"StEEmcAssociationMaker::Make()" << endm;
114 StSPtrVecMcTrack& tracks=mcEvent->tracks();
115 if(tracks.size()==0)
return kStWarn;
121 if(Debug()==2)
if(mPrint)
printHits(event);
124 if(!emcCollection)
return kStWarn;
127 for (Int_t detnum=0; detnum<NDETECTORS; detnum++)
129 if(mPrint) cout <<
"Doing association for detector "<<detnum<<endl;
130 StDetectorId detId=
static_cast<StDetectorId
>(detnum+kEndcapEmcTowerId);
133 if (detector) clusterColl=detector->cluster();
136 StSPtrVecEmcCluster& clusters=clusterColl->clusters();
139 if(mPrint) cout<<
"Track size = "<<tracks.size()<<
" cluster size = "<<clusters.size()<<endl;
140 if(!mTrackCluster[detnum]) mTrackCluster[detnum]=
new multiEEmcTrackCluster;
141 if(!mClusterTrack[detnum]) mClusterTrack[detnum]=
new multiEEmcClusterTrack;
143 for (UInt_t i=0; i<tracks.size(); i++)
145 StPtrVecMcCalorimeterHit hits;
148 case 0: { hits=tracks[i]->eemcHits();
break; }
149 case 1: { hits=tracks[i]->eprsHits();
break; }
150 case 2: { hits=tracks[i]->esmduHits();
break; }
151 case 3: { hits=tracks[i]->esmdvHits();
break; }
152 default: { gMessMgr->Warning()<<
"Detector does not exist"<<endm;
break; }
159 for (UInt_t i2=0; i2<hits.size(); i2++)
161 Float_t hitEnergy=hits[i2]->dE();
165 for (UInt_t j=0; j<clusters.size(); j++)
167 StPtrVecEmcRawHit& clHits=clusters[j]->hit();
168 Float_t trackEnergyFraction=0;
169 Float_t clusterEnergyFraction=0;
171 for (UInt_t k=0; k<hits.size(); k++)
173 UInt_t module=hits[k]->module();
174 UInt_t eta=hits[k]->eta();
175 Int_t sub=hits[k]->sub();
177 for (UInt_t l=0; l<clHits.size(); l++)
179 UInt_t clModule=clHits[l]->module();
180 UInt_t clEta=clHits[l]->eta();
181 Int_t clSub=abs(clHits[l]->sub());
184 if (module==clModule && eta==clEta
185 && ((detnum > 1)? 1 : sub==clSub))
188 if(Debug())
if(mPrint) {
189 cout << eemcDetname[detnum]
190 <<
" cluster = " << j
191 <<
", m = " <<module <<
" " << clModule
192 <<
", e = " << eta <<
" " << clEta
193 <<
", s = " << sub <<
" " << clSub << endl;
195 Float_t hitEnergy=hits[k]->dE();
196 trackEnergyFraction+=hitEnergy/energy;
197 Float_t clEnergy=clusters[j]->energy();
198 clusterEnergyFraction+=hitEnergy/clEnergy;
204 mTrackCluster[detnum]->insert(multiEEmcTrackClusterValue(tracks[i],c));
206 mClusterTrack[detnum]->insert(multiEEmcClusterTrackValue(clusters[j],c));
216 if(mPrint) cout <<
"Doing point association\n";
217 StSPtrVecEmcPoint& endcapPoints=emcCollection->endcapPoints();
218 cout <<
"points.size() = " << endcapPoints.size() << endl;
219 for (UInt_t j=0; j<endcapPoints.size(); j++) {
221 for(Int_t detnum=0;detnum<NDETECTORS;detnum++){
222 StDetectorId detId=
static_cast<StDetectorId
>(detnum+kEndcapEmcTowerId);
223 StPtrVecEmcCluster& cluster=endcapPoints[j]->cluster(detId);
224 nCl[detnum] = cluster.size();
226 if(nCl[0]!=0 && nCl[1]!=0 && nCl[2]!=1 && nCl[3]!=1 &&
227 endcapPoints[j]->nTracks()!=0) endcapPoints[j]->print();
229 if(endcapPoints.size()!=0)
232 if(!mTrackPoint) mTrackPoint =
new multiEEmcTrackPoint;
233 if(!mPointTrack) mPointTrack =
new multiEEmcPointTrack;
235 for (UInt_t i=0; i<tracks.size(); i++)
237 StPtrVecMcCalorimeterHit hits;
239 for (UInt_t j=0; j<endcapPoints.size(); j++)
242 for(Int_t detnum=0;detnum<NDETECTORS;detnum++)
246 case 0: { hits=tracks[i]->eemcHits();
break; }
247 case 1: { hits=tracks[i]->eprsHits();
break; }
248 case 2: { hits=tracks[i]->esmduHits();
break; }
249 case 3: { hits=tracks[i]->esmdvHits();
break; }
250 default: { gMessMgr->Warning()<<
"Detector does not exist"<<endm;
break; }
252 StDetectorId detId=
static_cast<StDetectorId
>(detnum+kEndcapEmcTowerId);
253 StPtrVecEmcCluster& cluster=endcapPoints[j]->cluster(detId);
254 for (UInt_t k=0; k<hits.size(); k++)
if(hits[k])
256 UInt_t module=hits[k]->module();
257 UInt_t eta=hits[k]->eta();
258 Int_t sub=hits[k]->sub();
260 for (UInt_t j2=0; j2<cluster.size(); j2++)
if(cluster[j2])
262 StPtrVecEmcRawHit& clHit=cluster[j2]->hit();
263 for (UInt_t l=0; l<clHit.size(); l++)
if(clHit[l])
265 UInt_t clModule=clHit[l]->module();
266 UInt_t clEta=clHit[l]->eta();
267 Int_t clSub=abs(clHit[l]->sub());
270 if (module==clModule && eta==clEta
271 && ((detnum > 1)? 1 : sub==clSub))
273 assoc+=(1<<(detnum));
274 if(Debug())
if(mPrint) {
275 cout <<
"assoc = " << assoc <<
" "
276 << eemcDetname[detnum]
277 <<
", m = " <<module <<
" " << clModule
278 <<
", e = " << eta <<
" " << clEta
279 <<
", s = " << sub <<
" " << clSub << endl;
286 nextDetector:
continue;
290 mTrackPoint->insert(multiEEmcTrackPointValue(tracks[i],p));
291 mPointTrack->insert(multiEEmcPointTrackValue(endcapPoints[j],p));
296 if(Debug())
if(mPrint) printMaps();
304 gMessMgr->Info() <<
"StEEmcAssociationMaker::Finish()" << endm;
311 if(det>0)
return mTrackCluster[det-1];
318 if(det>0)
return mClusterTrack[det-1];
325 for (Int_t i=0; i<NDETECTORS; i++)
326 if (!strcmp(detname,eemcDetname[i])) detnum = i+1;
330 void StEEmcAssociationMaker::printMaps()
332 for(
int i=0;i<NDETECTORS;i++)
334 cout <<
"-----------------------------------------------------------\n";
335 cout <<
"ASSOCIATION FOR DETECTOR "<<eemcDetname[i].Data()<<endl;
339 cout <<
"Track->Cluster Association Map\n";
340 for(multiEEmcTrackClusterIter j=map->begin(); j!=map->end(); j++)
350 cout <<
" McTrack = "<<track<<
" GeantId = "<<track->geantId()<<
" pt = "<<track->pt()<<
" TReta = "<<track->pseudoRapidity()
351 <<
" Cl = "<<c<<
" E = "<<c->energy()<<
" eta = "<<c->eta()<<
" phi = "<<c->phi()
352 <<
" FrTr = "<<value->getFractionTrack()<<
" FrCl = "<<value->getFractionCluster()<<endl;
361 cout <<
"Cluster->Track Association Map\n";
362 for(multiEEmcClusterTrackIter j=map1->begin(); j!=map1->end(); j++)
371 cout <<
" Cl = "<<c<<
" E = "<<c->energy()<<
" eta = "<<c->eta()<<
" phi = "<<c->phi()
372 <<
" McTrack = "<<track<<
" GeantId = "<<track->geantId()<<
" pt = "<<track->pt()<<
" TReta = "<<track->pseudoRapidity()
373 <<
" FrTr = "<<value->getFractionTrack()<<
" FrCl = "<<value->getFractionCluster()<<endl;
382 cout <<
"Track->Point Association Map\n";
383 for(multiEEmcTrackPointIter j = mapPoint->begin(); j!=mapPoint->end(); j++)
392 cout <<
" McTrack = "<<track<<
" GeantId = "<<track->geantId()<<
" pt = "<<track->pt()<<
" TReta = "<<track->pseudoRapidity()
393 <<
" Point = "<<point<<
" E = "<<point->energy()
394 <<
" Assoc. = "<<value->getAssociation();
395 for(
int i=1;i<=4;i++) cout <<
" det "<<i<<
" A = "<< value->getAssociation(i);
404 cout <<
"Point->Track Association Map\n";
405 for(multiEEmcPointTrackIter j = mapPoint1->begin(); j!=mapPoint1->end(); j++)
414 cout <<
" McTrack = "<<track<<
" GeantId = "<<track->geantId()<<
" pt = "<<track->pt()<<
" TReta = "<<track->pseudoRapidity()
415 <<
" Point = "<<point<<
" E = "<<point->energy()
416 <<
" Assoc. = "<<value->getAssociation();
417 for(
int i=1;i<=4;i++) cout <<
" det "<<i<<
" A = "<< value->getAssociation(i);
429 gMessMgr->Info()<<
"****** EEMC Association printHits() *******" <<endm;
430 for(Int_t i=0; i<NDETECTORS; i++)
432 StDetectorId
id =
static_cast<StDetectorId
>(i+kEndcapEmcTowerId);
434 gMessMgr->Info()<<
"****************** hits in detector "
435 << eemcDetname[i].Data()<<endm;
436 if(detector)
for(
int j=1;j<=kEEmcNumSectors;j++)
439 StSPtrVecEmcRawHit& rawHit=sector->hits();
441 gMessMgr->Info()<<
"Number of hits for module "
442 <<j<<
" = "<<rawHit.size()<<endm;
443 for(UInt_t k=0;k<rawHit.size();k++)
445 gMessMgr->Info()<<
"Hit number = "<<k
446 <<
" sector = " << rawHit[k]->module()
447 <<
" eta = "<<rawHit[k]->eta()
448 <<
" sub = "<< rawHit[k]->sub()
449 <<
" adc = "<< rawHit[k]->adc()
450 <<
" energy = "<<rawHit[k]->energy()<<endm;
452 gMessMgr->Info()<<
"Hit number = "<<k
453 <<
" sector = " << rawHit[k]->module()
454 <<
" strip = "<<rawHit[k]->eta()
455 <<
" adc = "<< rawHit[k]->adc()
456 <<
" energy = "<<rawHit[k]->energy()<<endm;
multiEEmcClusterTrack * getClusterTrackMap(Int_t i)
returns multimap for association betwwen clusters and MC tracks
multiEEmcTrackCluster * getTrackClusterMap(Int_t i)
returns multimap for association betwwen MC tracks and clusters
void printHits(StEvent *)
Set print log.
Monte Carlo Track class All information on a simulated track is stored in this class: kinematics...
Int_t getDetNum(const char *)
returns detector number for each EMC sub detector
multiEEmcPointTrack * getPointTrackMap()
returns multimap for association betwwen points and MC tracks
multiEEmcTrackPoint * 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...