CGEM BOSS 6.6.5.f
BESIII Offline Software System
Loading...
Searching...
No Matches
EmcRec Class Reference

#include <EmcRec.h>

+ Inheritance diagram for EmcRec:

Public Member Functions

 EmcRec (const std::string &name, ISvcLocator *pSvcLocator)
 
StatusCode initialize ()
 
StatusCode execute ()
 
StatusCode finalize ()
 
 EmcRec (const std::string &name, ISvcLocator *pSvcLocator)
 
StatusCode initialize ()
 
StatusCode execute ()
 
StatusCode finalize ()
 

Detailed Description

Definition at line 22 of file InstallArea/include/EmcRec/EmcRec/EmcRec.h.

Constructor & Destructor Documentation

◆ EmcRec() [1/2]

EmcRec::EmcRec ( const std::string &  name,
ISvcLocator *  pSvcLocator 
)

Definition at line 38 of file EmcRec.cxx.

38 :
39 Algorithm(name, pSvcLocator),fCluster2Shower(0)
40{
41 m_event=0;
42 fPositionMode.push_back("log");
43 fPositionMode.push_back("5x5");
44 // Declare the properties
45 m_propMgr.declareProperty("Output",fOutput=0);
46 m_propMgr.declareProperty("EventNb",fEventNb=0);
47 m_propMgr.declareProperty("DigiCalib",fDigiCalib=false);
48 m_propMgr.declareProperty("TofEnergy",fTofEnergy=false);
49 m_propMgr.declareProperty("OnlineMode",fOnlineMode=false);
50 m_propMgr.declareProperty("TimeMin",fTimeMin=0);
51 m_propMgr.declareProperty("TimeMax",fTimeMax=60);
52 m_propMgr.declareProperty("PositionMode",fPositionMode);
53
54 IJobOptionsSvc* jobSvc;
55 pSvcLocator->service("JobOptionsSvc", jobSvc);
56 jobSvc->setMyProperties("EmcRecAlg", &m_propMgr);
57
58 // Get EmcRecParameter
61 Para.SetDigiCalib(fDigiCalib);
62 Para.SetTimeMin(fTimeMin);
63 Para.SetTimeMax(fTimeMax);
64 Para.SetPositionMode(fPositionMode);
65
67}
void SetPositionMode(std::vector< std::string > &mode)
static EmcRecParameter & GetInstance()

◆ EmcRec() [2/2]

EmcRec::EmcRec ( const std::string &  name,
ISvcLocator *  pSvcLocator 
)

Member Function Documentation

◆ execute() [1/2]

StatusCode EmcRec::execute ( )

Reconstruction begins. State 1: Initialize digit map

Retrieve EMC digi

State 2: DigitMap --> HitMap

State 3: HitMap --> ClusterMap

State 4: ClusterMap --> ShowerMap

State 6: Register to TDS

Definition at line 147 of file EmcRec.cxx.

147 {
148
149 MsgStream log(msgSvc(), name());
150 log << MSG::DEBUG << "in execute()" << endreq;
151
152 /// Reconstruction begins.
153 /// State 1: Initialize digit map
154 int event, run;
155
156 SmartDataPtr<Event::EventHeader> eventHeader(eventSvc(),"/Event/EventHeader");
157 if (!eventHeader) {
158 log << MSG::FATAL <<name() << " Could not find Event Header" << endreq;
159 return( StatusCode::FAILURE);
160 }
161 run=eventHeader->runNumber();
162 event=eventHeader->eventNumber();
163 if(fEventNb!=0&&m_event%fEventNb==0) {
164 log << MSG::FATAL <<m_event<<"-------: "<<run<<","<<event<<endreq;
165 }
166 m_event++;
167 if(fOutput>=2) {
168 log << MSG::DEBUG <<"===================================="<<endreq;
169 log << MSG::DEBUG <<"run= "<<run<<"; event= "<<event<<endreq;
170 }
171
172 Hep3Vector posG; //initial photon position
173#ifndef OnlineMode
174 if(!(m_rawDataProviderSvc->isOnlineMode())) {
175 if(fOutput>=1&&run<0) { //run<0 means MC
176 // Retrieve mc truth
177 SmartDataPtr<McParticleCol> mcParticleCol(eventSvc(),"/Event/MC/McParticleCol");
178 if (!mcParticleCol) {
179 log << MSG::WARNING << "Could not find McParticle" << endreq;
180 } else {
181 HepLorentzVector pG;
182 McParticleCol::iterator iter_mc = mcParticleCol->begin();
183 for (;iter_mc != mcParticleCol->end(); iter_mc++) {
184 log << MSG::INFO
185 << " particleId = " << (*iter_mc)->particleProperty()
186 << endreq;
187 pG = (*iter_mc)->initialFourMomentum();
188 posG = (*iter_mc)->initialPosition().v();
189 }
190 ttheta = pG.theta();
191 tphi = pG.phi();
192 if(tphi<0) {
193 tphi=twopi+tphi;
194 }
195 tp = pG.rho();
196
197 // Retrieve EMC truth
198 SmartDataPtr<EmcMcHitCol> emcMcHitCol(eventSvc(),"/Event/MC/EmcMcHitCol");
199 if (!emcMcHitCol) {
200 log << MSG::WARNING << "Could not find EMC truth" << endreq;
201 }
202
203 RecEmcID mcId;
204 unsigned int mcTrackIndex;
205 double mcPosX=0,mcPosY=0,mcPosZ=0;
206 double mcPx=0,mcPy=0,mcPz=0;
207 double mcEnergy=0;
208
209 EmcMcHitCol::iterator iterMc;
210 for(iterMc=emcMcHitCol->begin();iterMc!=emcMcHitCol->end();iterMc++){
211 mcId=(*iterMc)->identify();
212 mcTrackIndex=(*iterMc)->getTrackIndex();
213 mcPosX=(*iterMc)->getPositionX();
214 mcPosY=(*iterMc)->getPositionY();
215 mcPosZ=(*iterMc)->getPositionZ();
216 mcPx=(*iterMc)->getPx();
217 mcPy=(*iterMc)->getPy();
218 mcPz=(*iterMc)->getPz();
219 mcEnergy=(*iterMc)->getDepositEnergy();
220
221 if(fOutput>=2){
222 //cout<<"mcId="<<mcId<<"\t"<<"mcTrackIndex="<<mcTrackIndex<<endl;
223 //cout<<"mcPosition:\t"<<mcPosX<<"\t"<<mcPosY<<"\t"<<mcPosZ<<endl;
224 //cout<<"mcP:\t"<<mcPx<<"\t"<<mcPy<<"\t"<<mcPz<<endl;
225 //cout<<"mcDepositEnergy=\t"<<mcEnergy<<endl;
226 }
227 }
228 }
229 } //fOutput>=1
230 } //isOnlineMode
231
232#endif
233
234 /// Retrieve EMC digi
235 fDigitMap.clear();
236 fHitMap.clear();
237 fClusterMap.clear();
238 fShowerMap.clear();
239
240 // Get EmcCalibConstSvc.
241 IEmcCalibConstSvc *emcCalibConstSvc = 0;
242 StatusCode sc = service("EmcCalibConstSvc", emcCalibConstSvc);
243 if(sc != StatusCode::SUCCESS) {
244 ;
245 //cout << "EmcRec Error: Can't get EmcCalibConstSvc." << endl;
246 }
247
248 SmartDataPtr<EmcDigiCol> emcDigiCol(eventSvc(),"/Event/Digi/EmcDigiCol");
249 if (!emcDigiCol) {
250 log << MSG::FATAL << "Could not find EMC digi" << endreq;
251 return( StatusCode::FAILURE);
252 }
253
254 EmcDigiCol::iterator iter3;
255 for (iter3=emcDigiCol->begin();iter3!= emcDigiCol->end();iter3++) {
256 RecEmcID id((*iter3)->identify());
257 double adc=RawDataUtil::EmcCharge((*iter3)->getMeasure(),
258 (*iter3)->getChargeChannel());
259 double tdc=RawDataUtil::EmcTime((*iter3)->getTimeChannel());
260
261 //for cable connection correction
262 unsigned int nnpart=EmcID::barrel_ec(id);
263 unsigned int nnthe=EmcID::theta_module(id);
264 unsigned int nnphi=EmcID::phi_module(id);
265
266 int index = emcCalibConstSvc->getIndex(nnpart,nnthe,nnphi);
267 int ixtalNumber=emcCalibConstSvc->getIxtalNumber(index);
268
269 if(run>0&&ixtalNumber>0) {
270 unsigned int npartNew=emcCalibConstSvc->getPartID(ixtalNumber);
271 unsigned int ntheNew=emcCalibConstSvc->getThetaIndex(ixtalNumber);
272 unsigned int nphiNew=emcCalibConstSvc->getPhiIndex(ixtalNumber);
273 id=EmcID::crystal_id(npartNew,ntheNew,nphiNew);
274 }//-------
275
276 //ixtalNumber=-9 tag dead channel
277 if (ixtalNumber==-9) {
278 adc=0.0;
279 }
280
281 //ixtalNumber=-99 tag hot channel
282 if (ixtalNumber==-99) {
283 adc=0.0;
284 }
285
286 RecEmcDigit aDigit;
287 aDigit.Assign(id,adc,tdc);
288 fDigitMap[id]=aDigit;
289 }
290
291 if(fOutput>=2) {
292 RecEmcDigitMap::iterator iDigitMap;
293 for(iDigitMap=fDigitMap.begin();
294 iDigitMap!=fDigitMap.end();
295 iDigitMap++){
296 //cout<<iDigitMap->second;
297 }
298 }
299 // DigitMap ok
300
301 // oooooooooooooooooooooooooooooooooooooooooooooooooooooooooo
302 /// State 2: DigitMap --> HitMap
303 fDigit2Hit.Convert(fDigitMap,fHitMap);
304 if(fOutput>=2) {
305 RecEmcHitMap::iterator iHitMap;
306 for(iHitMap=fHitMap.begin();
307 iHitMap!=fHitMap.end();
308 iHitMap++){
309 //cout<<iHitMap->second;
310 }
311 fDigit2Hit.Output(fHitMap);
312 }
313
314
315 /// State 3: HitMap --> ClusterMap
316 fHit2Cluster.Convert(fHitMap,fClusterMap);
317 //
318 if(fOutput>=2) {
319 RecEmcClusterMap::iterator iClusterMap;
320 for(iClusterMap=fClusterMap.begin();
321 iClusterMap!=fClusterMap.end();
322 iClusterMap++){
323 //cout<<iClusterMap->second;
324 }
325 }
326
327 /// State 4: ClusterMap --> ShowerMap
328 fCluster2Shower->Convert(fClusterMap,fShowerMap);
329 //
330 if(fOutput>=2) {
331 RecEmcShowerMap::iterator iShowerMap;
332 for(iShowerMap=fShowerMap.begin();
333 iShowerMap!=fShowerMap.end();
334 iShowerMap++) {
335 //cout<<iShowerMap->second;
336 }
337 }
338
339 /// State 6: Register to TDS
340 EmcRecTDS tds;
341 tds.RegisterToTDS(fHitMap,fClusterMap,fShowerMap);
342 if(fOutput>=2) {
343 tds.CheckRegister();
344 }
345
346 // oooooooooooooooooooooooooooooooooooooooooooooooooooooooooo
347#ifndef OnlineMode
348 if(!(m_rawDataProviderSvc->isOnlineMode())) {
349 if(fOutput>=1) {
350 nrun=run;
351 nrec=event;
352
353 //cout<<"cm="<<cm<<"\tmm="<<mm<<"\tGeV="<<GeV<<"\tMeV="<<MeV<<endl;
354 ndigi=fDigitMap.size();
355 nhit=fHitMap.size();
356 ncluster=fClusterMap.size();
357 RecEmcShowerVec fShowerVec;
358 RecEmcShowerMap::iterator iShowerMap;
359 for(iShowerMap=fShowerMap.begin();
360 iShowerMap!=fShowerMap.end();
361 iShowerMap++) {
362 fShowerVec.push_back(iShowerMap->second);
363 }
364 sort(fShowerVec.begin(), fShowerVec.end(), greater<RecEmcShower>());
365 nneu=fShowerMap.size();
366
367 RecEmcShower aShower;
368 //aShower.e5x5(-99.);
369 RecEmcShowerVec::iterator iShowerVec;
370 iShowerVec=fShowerVec.begin();
371 npart=-99;
372 ntheta=-99;
373 nphi=-99;
374 if(iShowerVec!=fShowerVec.end()) {
375 aShower=*iShowerVec;
376 RecEmcID id=aShower.getShowerId();
377 npart=EmcID::barrel_ec(id);
378 ntheta=EmcID::theta_module(id);
379 nphi=EmcID::phi_module(id);
380 pp1[0]=aShower.energy()*aShower.x()/aShower.position().mag();
381 pp1[1]=aShower.energy()*aShower.y()/aShower.position().mag();
382 pp1[2]=aShower.energy()*aShower.z()/aShower.position().mag();
383 pp1[3]=aShower.energy();
384 theta1=(aShower.position()-posG).theta();
385 phi1=(aShower.position()-posG).phi();
386 if(phi1<0) {
387 phi1=twopi+phi1;
388 }
389 thtgap1=aShower.ThetaGap();
390 phigap1=aShower.PhiGap();
391 RecEmcID seed,nseed;
392 seed=aShower.getShowerId();
393 nseed=aShower.NearestSeed();
394 eseed=aShower.eSeed();
395 e3x3=aShower.e3x3();
396 e5x5=aShower.e5x5();
397 etof2x1=aShower.getETof2x1();
398 etof2x3=aShower.getETof2x3();
399 if(aShower.getCluster()) {
400 cluster2ndMoment=aShower.getCluster()->getSecondMoment();
401 }
402 secondMoment=aShower.secondMoment();
403 latMoment=aShower.latMoment();
404 a20Moment=aShower.a20Moment();
405 a42Moment=aShower.a42Moment();
406 if(nseed.is_valid()) {
407 enseed=fHitMap[nseed].getEnergy();
408 } else {
409 enseed=0;
410 }
411
412 dphi1=phi1-tphi;
413 if(dphi1<-pi) dphi1=dphi1+twopi;
414 if(dphi1>pi) dphi1=dphi1-twopi;
415 }
416
417 if(iShowerVec!=fShowerVec.end()) {
418 iShowerVec++;
419 if(iShowerVec!=fShowerVec.end()) {
420 aShower=*iShowerVec;
421 pp2[0]=aShower.energy()*aShower.x()/aShower.position().mag();
422 pp2[1]=aShower.energy()*aShower.y()/aShower.position().mag();
423 pp2[2]=aShower.energy()*aShower.z()/aShower.position().mag();
424 pp2[3]=aShower.energy();
425 }
426 }
427
428 //for pi0
429 if(fShowerVec.size()>=2) {
430 RecEmcShowerVec::iterator iShowerVec1,iShowerVec2;
431 iShowerVec1=fShowerVec.begin();
432 iShowerVec2=fShowerVec.begin()+1;
433 double e1=(*iShowerVec1).energy();
434 double e2=(*iShowerVec2).energy();
435 double angle=(*iShowerVec1).position().angle((*iShowerVec2).position());
436 mpi0=sqrt(2*e1*e2*(1-cos(angle)));
437 }
438 m_tuple->write();
439 }
440 }
441#endif
442
443 return StatusCode::SUCCESS;
444}
Double_t e1
Double_t e2
double cos(const BesAngle a)
static Identifier crystal_id(const unsigned int barrel_ec, const unsigned int theta_module, const unsigned int phi_module)
For a single crystal.
static unsigned int barrel_ec(const Identifier &id)
Values of different levels (failure returns 0)
static unsigned int theta_module(const Identifier &id)
static unsigned int phi_module(const Identifier &id)
virtual void Convert(RecEmcClusterMap &aClusterMap, RecEmcShowerMap &aShowerMap)=0
void Convert(const RecEmcDigitMap &aDigitMap, RecEmcHitMap &aHitMap)
void Output(const RecEmcHitMap &aHitMap) const
void Convert(const RecEmcHitMap &aHitMap, RecEmcClusterMap &aClusterMap)
StatusCode RegisterToTDS(RecEmcHitMap &aHitMap, RecEmcClusterMap &aClusterMap, RecEmcShowerMap &aShowerMap)
Definition: EmcRecTDS.cxx:15
StatusCode CheckRegister()
Definition: EmcRecTDS.cxx:208
virtual unsigned int getPartID(int Index) const =0
virtual int getIxtalNumber(int No) const =0
virtual unsigned int getPhiIndex(int Index) const =0
virtual unsigned int getThetaIndex(int Index) const =0
virtual int getIndex(unsigned int PartId, unsigned int ThetaIndex, unsigned int PhiIndex) const =0
virtual bool isOnlineMode()=0
virtual bool is_valid() const
Check if id is in a valid state.
static double EmcCharge(int measure, int chargeChannel)
double getSecondMoment() const
void Assign(const RecEmcID &CellId, const RecEmcADC &ADC, const RecEmcTDC &TDC)
Definition: RecEmcDigit.cxx:88
int ThetaGap() const
RecEmcID NearestSeed() const
int PhiGap() const

◆ execute() [2/2]

StatusCode EmcRec::execute ( )

◆ finalize() [1/2]

StatusCode EmcRec::finalize ( )

Definition at line 447 of file EmcRec.cxx.

447 {
449 if(fCluster2Shower) delete fCluster2Shower;
450
451 MsgStream log(msgSvc(), name());
452 log << MSG::INFO << "in finalize()" << endreq;
453 return StatusCode::SUCCESS;
454}
static void Kill()

◆ finalize() [2/2]

StatusCode EmcRec::finalize ( )

◆ initialize() [1/2]

StatusCode EmcRec::initialize ( )

Definition at line 70 of file EmcRec.cxx.

70 {
71
72 MsgStream log(msgSvc(), name());
73 log << MSG::INFO << "in initialize()" << endreq;
74
75 //Get RawDataProviderSvc
76 // tianhl for mt
77 std::string rawDataProviderSvc_name("RawDataProviderSvc");
78 StatusCode sc = service(rawDataProviderSvc_name.c_str(), m_rawDataProviderSvc);
79 if(sc != StatusCode::SUCCESS) {
80 log << MSG::ERROR << "EmcRec Error: Can't get RawDataProviderSvc." << endmsg;
81 }
82
83 fDigit2Hit.SetAlgName(name());
84
85#ifndef OnlineMode
86 if(!(m_rawDataProviderSvc->isOnlineMode())) {
87 m_tuple=0;
88 StatusCode status;
89
90 if(fOutput>=1) {
91 NTuplePtr nt(ntupleSvc(),"FILE301/n1");
92 if ( nt ) m_tuple = nt;
93 else {
94 m_tuple=ntupleSvc()->book("FILE301/n1",CLID_ColumnWiseTuple,"EmcRec");
95 if( m_tuple ) {
96 status = m_tuple->addItem ("pid",pid);
97 status = m_tuple->addItem ("tp",tp);
98 status = m_tuple->addItem ("ttheta",ttheta);
99 status = m_tuple->addItem ("tphi",tphi);
100 status = m_tuple->addItem ("nrun",nrun);
101 status = m_tuple->addItem ("nrec",nrec);
102 status = m_tuple->addItem ("nneu",nneu);
103 status = m_tuple->addItem ("ncluster",ncluster);
104 status = m_tuple->addItem ("npart",npart);
105 status = m_tuple->addItem ("ntheta",ntheta);
106 status = m_tuple->addItem ("nphi",nphi);
107 status = m_tuple->addItem ("ndigi",ndigi);
108 status = m_tuple->addItem ("nhit",nhit);
109 status = m_tuple->addItem ("pp1",4,pp1);
110 status = m_tuple->addItem ("theta1",theta1);
111 status = m_tuple->addItem ("phi1",phi1);
112 status = m_tuple->addItem ("dphi1",dphi1);
113 status = m_tuple->addItem ("eseed",eseed);
114 status = m_tuple->addItem ("e3x3",e3x3);
115 status = m_tuple->addItem ("e5x5",e5x5);
116 status = m_tuple->addItem ("enseed",enseed);
117 status = m_tuple->addItem ("etof2x1",etof2x1);
118 status = m_tuple->addItem ("etof2x3",etof2x3);
119 status = m_tuple->addItem ("cluster2ndMoment",cluster2ndMoment);
120 status = m_tuple->addItem ("secondMoment",secondMoment);
121 status = m_tuple->addItem ("latMoment",latMoment);
122 status = m_tuple->addItem ("a20Moment",a20Moment);
123 status = m_tuple->addItem ("a42Moment",a42Moment);
124 status = m_tuple->addItem ("mpi0",mpi0);
125 status = m_tuple->addItem ("thtgap1",thtgap1);
126 status = m_tuple->addItem ("phigap1",phigap1);
127 status = m_tuple->addItem ("pp2",4,pp2);
128 }
129 else { // did not manage to book the N tuple....
130 log << MSG::ERROR <<"Cannot book N-tuple:" << long(m_tuple) << endmsg;
131 return StatusCode::FAILURE;
132 }
133 }
134 }
135 fCluster2Shower = new EmcRecCluster2Shower;
136 } else {
137 fCluster2Shower = new EmcRecFastCluster2Shower;
138 }
139#else
140 fCluster2Shower = new EmcRecFastCluster2Shower;
141#endif
142
143 return StatusCode::SUCCESS;
144}

◆ initialize() [2/2]

StatusCode EmcRec::initialize ( )

The documentation for this class was generated from the following files: