Reconstruction begins. State 1: Initialize digit map
147 {
148
149 MsgStream log(
msgSvc(), name());
150 log << MSG::DEBUG << "in execute()" << endreq;
151
152
153
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;
173#ifndef OnlineMode
175 if(fOutput>=1&&run<0) {
176
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
198 SmartDataPtr<EmcMcHitCol> emcMcHitCol(eventSvc(),"/Event/MC/EmcMcHitCol");
199 if (!emcMcHitCol) {
200 log << MSG::WARNING << "Could not find EMC truth" << endreq;
201 }
202
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
223
224
225
226 }
227 }
228 }
229 }
230 }
231
232#endif
233
234
235 fDigitMap.clear();
236 fHitMap.clear();
237 fClusterMap.clear();
238 fShowerMap.clear();
239
240
242 StatusCode sc = service("EmcCalibConstSvc", emcCalibConstSvc);
243 if(sc != StatusCode::SUCCESS) {
244 ;
245
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++) {
258 (*iter3)->getChargeChannel());
260
261
265
266 int index = emcCalibConstSvc->
getIndex(nnpart,nnthe,nnphi);
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);
274 }
275
276
277 if (ixtalNumber==-9) {
278 adc=0.0;
279 }
280
281
282 if (ixtalNumber==-99) {
283 adc=0.0;
284 }
285
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
297 }
298 }
299
300
301
302
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
310 }
311 fDigit2Hit.
Output(fHitMap);
312 }
313
314
315
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
324 }
325 }
326
327
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
336 }
337 }
338
339
342 if(fOutput>=2) {
344 }
345
346
347#ifndef OnlineMode
349 if(fOutput>=1) {
350 nrun=run;
351 nrec=event;
352
353
354 ndigi=fDigitMap.size();
355 nhit=fHitMap.size();
356 ncluster=fClusterMap.size();
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
368
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;
384 theta1=(aShower.
position()-posG).theta();
385 phi1=(aShower.
position()-posG).phi();
386 if(phi1<0) {
387 phi1=twopi+phi1;
388 }
394 eseed=aShower.
eSeed();
401 }
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;
425 }
426 }
427
428
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}
vector< RecEmcShower > RecEmcShowerVec
double cos(const BesAngle a)
HepPoint3D position() const
double secondMoment() const
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)
StatusCode CheckRegister()
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 EmcTime(int timeChannel)
static double EmcCharge(int measure, int chargeChannel)
double getSecondMoment() const
void Assign(const RecEmcID &CellId, const RecEmcADC &ADC, const RecEmcTDC &TDC)
RecEmcID getShowerId() const
RecEmcCluster * getCluster() const
RecEmcEnergy getETof2x1() const
RecEmcID NearestSeed() const
RecEmcEnergy getETof2x3() const