72 MsgStream log(
msgSvc(), name());
73 log << MSG::INFO <<
"in initialize()" << endreq;
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;
92 if ( nt ) m_tuple = nt;
94 m_tuple=
ntupleSvc()->book(
"FILE301/n1",CLID_ColumnWiseTuple,
"EmcRec");
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);
130 log << MSG::ERROR <<
"Cannot book N-tuple:" << long(m_tuple) << endmsg;
131 return StatusCode::FAILURE;
143 return StatusCode::SUCCESS;
149 MsgStream log(
msgSvc(), name());
150 log << MSG::DEBUG <<
"in execute()" << endreq;
156 SmartDataPtr<Event::EventHeader> eventHeader(eventSvc(),
"/Event/EventHeader");
158 log << MSG::FATAL <<name() <<
" Could not find Event Header" << endreq;
159 return( StatusCode::FAILURE);
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;
168 log << MSG::DEBUG <<
"===================================="<<endreq;
169 log << MSG::DEBUG <<
"run= "<<run<<
"; event= "<<
event<<endreq;
175 if(fOutput>=1&&run<0) {
177 SmartDataPtr<McParticleCol> mcParticleCol(eventSvc(),
"/Event/MC/McParticleCol");
178 if (!mcParticleCol) {
179 log << MSG::WARNING <<
"Could not find McParticle" << endreq;
182 McParticleCol::iterator iter_mc = mcParticleCol->begin();
183 for (;iter_mc != mcParticleCol->end(); iter_mc++) {
185 <<
" particleId = " << (*iter_mc)->particleProperty()
187 pG = (*iter_mc)->initialFourMomentum();
188 posG = (*iter_mc)->initialPosition().v();
198 SmartDataPtr<EmcMcHitCol> emcMcHitCol(eventSvc(),
"/Event/MC/EmcMcHitCol");
200 log << MSG::WARNING <<
"Could not find EMC truth" << endreq;
204 unsigned int mcTrackIndex;
205 double mcPosX=0,mcPosY=0,mcPosZ=0;
206 double mcPx=0,mcPy=0,mcPz=0;
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();
242 StatusCode sc = service(
"EmcCalibConstSvc", emcCalibConstSvc);
243 if(sc != StatusCode::SUCCESS) {
248 SmartDataPtr<EmcDigiCol> emcDigiCol(eventSvc(),
"/Event/Digi/EmcDigiCol");
250 log << MSG::FATAL <<
"Could not find EMC digi" << endreq;
251 return( StatusCode::FAILURE);
254 EmcDigiCol::iterator iter3;
255 for (iter3=emcDigiCol->begin();iter3!= emcDigiCol->end();iter3++) {
258 (*iter3)->getChargeChannel());
266 int index = emcCalibConstSvc->
getIndex(nnpart,nnthe,nnphi);
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);
277 if (ixtalNumber==-9) {
282 if (ixtalNumber==-99) {
287 aDigit.
Assign(
id,adc,tdc);
288 fDigitMap[id]=aDigit;
292 RecEmcDigitMap::iterator iDigitMap;
293 for(iDigitMap=fDigitMap.begin();
294 iDigitMap!=fDigitMap.end();
303 fDigit2Hit.
Convert(fDigitMap,fHitMap);
305 RecEmcHitMap::iterator iHitMap;
306 for(iHitMap=fHitMap.begin();
307 iHitMap!=fHitMap.end();
311 fDigit2Hit.
Output(fHitMap);
316 fHit2Cluster.
Convert(fHitMap,fClusterMap);
319 RecEmcClusterMap::iterator iClusterMap;
320 for(iClusterMap=fClusterMap.begin();
321 iClusterMap!=fClusterMap.end();
328 fCluster2Shower->
Convert(fClusterMap,fShowerMap);
331 RecEmcShowerMap::iterator iShowerMap;
332 for(iShowerMap=fShowerMap.begin();
333 iShowerMap!=fShowerMap.end();
354 ndigi=fDigitMap.size();
356 ncluster=fClusterMap.size();
358 RecEmcShowerMap::iterator iShowerMap;
359 for(iShowerMap=fShowerMap.begin();
360 iShowerMap!=fShowerMap.end();
362 fShowerVec.push_back(iShowerMap->second);
364 sort(fShowerVec.begin(), fShowerVec.end(), greater<RecEmcShower>());
365 nneu=fShowerMap.size();
369 RecEmcShowerVec::iterator iShowerVec;
370 iShowerVec=fShowerVec.begin();
374 if(iShowerVec!=fShowerVec.end()) {
384 theta1=(aShower.
position()-posG).theta();
385 phi1=(aShower.
position()-posG).phi();
394 eseed=aShower.
eSeed();
407 enseed=fHitMap[nseed].getEnergy();
413 if(dphi1<-
pi) dphi1=dphi1+twopi;
414 if(dphi1>
pi) dphi1=dphi1-twopi;
417 if(iShowerVec!=fShowerVec.end()) {
419 if(iShowerVec!=fShowerVec.end()) {
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)));
443 return StatusCode::SUCCESS;