BOSS 6.6.4.p03
BESIII Offline Software System
Loading...
Searching...
No Matches
EventAssemblyAlg.cxx
Go to the documentation of this file.
2
3#include "GaudiKernel/MsgStream.h"
4#include "GaudiKernel/AlgFactory.h"
5#include "GaudiKernel/ISvcLocator.h"
6#include "GaudiKernel/SmartDataPtr.h"
7#include "GaudiKernel/IDataProviderSvc.h"
8#include "GaudiKernel/IDataManagerSvc.h"
9#include "GaudiKernel/PropertyMgr.h"
10//#include "GaudiKernel/INTupleSvc.h"
11//#include "GaudiKernel/IHistogramSvc.h"
12
19#include "Identifier/TofID.h"
20
21
22/////////////////////////////////////////////////////////////////////////////
23EventAssemblyAlg::EventAssemblyAlg(const std::string& name, ISvcLocator* pSvcLocator):Algorithm(name, pSvcLocator)
24{
25 //Declare the properties
26 declareProperty("MsgFlag",myMsgFlag=false);
27 declareProperty("ActiveCutFlag",myActiveCutFlag=true);
28 declareProperty("EmcThetaMatchCut",myEmcThetaCut=-1);
29 declareProperty("EmcPhiMatchCut",myEmcPhiCut=-1);
30 declareProperty("EmcThetaNSigmaCut",myEmcThetaNSigmaCut=5);
31 declareProperty("EmcPhiNSigmaCut",myEmcPhiNSigmaCut=5);
32 declareProperty("ParticleId",myParticleId);
33 declareProperty("Output", m_Output = 0);
34}
35
36//////////////////////////////////////////
38{
39 MsgStream log(msgSvc(), name());
40 log << MSG::INFO << "in initialize()" << endreq;
41
42 if(myEmcThetaCut<0) myEmcThetaCut = 0.1745;
43 if(myEmcPhiCut<0) myEmcPhiCut = 0.2618;
44
45 log << MSG::INFO <<"EmcThetaCut,EmcPhiCut: "<<myEmcThetaCut<<", "<<myEmcPhiCut<<endreq;
46 log << MSG::INFO <<"emcThetaNSigmaCut, emcPhiNSigmaCut: "<<myEmcThetaNSigmaCut<<", "<<myEmcPhiNSigmaCut<<endreq;
47
48 if(m_Output == 1){
49 NTuplePtr nt1(ntupleSvc(), "FILE998/match");
50 if ( nt1 ) myNTuple1 = nt1;
51 else {
52 myNTuple1 = ntupleSvc()->book("FILE998/match", CLID_ColumnWiseTuple, "match");
53 if ( myNTuple1 ) {
54 myNTuple1->addItem("exted",myExted);
55 myNTuple1->addItem("matched",myMatched);
56 myNTuple1->addItem("Ematched",myEnergyMatched);
57 }
58 else {
59 log << MSG::ERROR << " Cannot book N-tuple:" << long(myNTuple1) << endmsg;
60 //return StatusCode::FAILURE;
61 }
62 }
63 }
64 return StatusCode::SUCCESS;
65}
66
67///////////////////////////////////////
69{
70 MsgStream log(msgSvc(), name());
71 log << MSG::INFO << "in execute()" << endreq;
72
73 int numOfChargedTrks = 0;
74 int numOfKalTrks = 0;
75 int numOfDedx = 0;
76 int numOfExt = 0;
77 int numOfTof = 0;
78 int numOfShower = 0;
79 int numOfMatchedShower = 0;
80 int numOfMucTrks = 0;
81
82 // Part 1: Get the event header, print out event and run number
83 SmartDataPtr<Event::EventHeader> eventHeader(eventSvc(),"/Event/EventHeader");
84 if (!eventHeader)
85 {
86 log << MSG::FATAL << "Could not find Event Header" << endreq;
87 return( StatusCode::FAILURE);
88 }
89 log << MSG::INFO << ": retrieved event: " << eventHeader->eventNumber() << " run: " << eventHeader->runNumber() << endreq;
90
91 //Part 2: Retrieve Rec data
92 SmartDataPtr<RecMdcTrackCol> recMdcTrackCol(eventSvc(),EventModel::Recon::RecMdcTrackCol);
93 RecMdcTrackCol::iterator beginOfMdcTrkCol = RecMdcTrackCol::iterator(NULL);
94 if(!recMdcTrackCol)
95 {
96 log<<MSG::INFO<<"Could not find RecMdcTrackCol!"<<endreq;
97 }
98 else
99 {
100 beginOfMdcTrkCol = recMdcTrackCol->begin();
101 numOfChargedTrks = recMdcTrackCol->size();
102 }
103
104 SmartDataPtr<RecMdcKalTrackCol> mdcKalTrackCol(eventSvc(), EventModel::Recon::RecMdcKalTrackCol);
105 RecMdcKalTrackCol::iterator beginOfMdcKalTrackCol = RecMdcKalTrackCol::iterator(NULL);
106 if(!mdcKalTrackCol)
107 {
108 log<<MSG::INFO<<"Could not find MdcKalTrackCol!"<<endreq;
109 }
110 else
111 {
112 numOfKalTrks = mdcKalTrackCol->size();
113 beginOfMdcKalTrackCol = mdcKalTrackCol->begin();
114 }
115
116
117 SmartDataPtr<RecMdcDedxCol> mdcDedxCol(eventSvc(), EventModel::Recon::RecMdcDedxCol);
118 RecMdcDedxCol::iterator beginOfDedxCol = RecMdcDedxCol::iterator(NULL);
119 if(!mdcDedxCol)
120 {
121 log<<MSG::INFO<<"Could not find MdcDedxCol!"<<endreq;
122 }
123 else {
124 numOfDedx = mdcDedxCol->size();
125 beginOfDedxCol = mdcDedxCol->begin();
126 }
127
128
129 SmartDataPtr<RecExtTrackCol> extTrackCol(eventSvc(), EventModel::Recon::RecExtTrackCol);
130 RecExtTrackCol::iterator beginOfExtTrackCol = RecExtTrackCol::iterator(NULL);
131 if(!extTrackCol)
132 {
133 log<<MSG::INFO<<"Could not find RecExtTrackCol!"<<endreq;
134 }
135 else
136 {
137 beginOfExtTrackCol = extTrackCol->begin();
138 numOfExt = extTrackCol->size();
139 }
140
141 SmartDataPtr<RecTofTrackCol> TofTrackCol(eventSvc(), EventModel::Recon::RecTofTrackCol);
142 RecTofTrackCol::iterator beginOfTofTrackCol = RecTofTrackCol::iterator(NULL);
143 if(!TofTrackCol)
144 {
145 log<<MSG::INFO<<"Could not find RecTofTrackCol!"<<endreq;
146 }
147 else
148 {
149 beginOfTofTrackCol = TofTrackCol->begin();
150 numOfTof = TofTrackCol->size();
151 }
152
153 SmartDataPtr<RecEmcShowerCol> emcRecShowerCol(eventSvc(), EventModel::Recon::RecEmcShowerCol);
154 RecEmcShowerCol::iterator beginOfEmcTrackCol = RecEmcShowerCol::iterator(NULL);
155 if(!emcRecShowerCol)
156 {
157 log<<MSG::INFO<<"Could not find RecEmcShowerCol!"<<endreq;
158 }
159 else
160 {
161 beginOfEmcTrackCol = emcRecShowerCol->begin();
162 numOfShower = emcRecShowerCol->size();
163 }
164
165 SmartDataPtr<RecMucTrackCol> mucTrackCol(eventSvc(), EventModel::Recon::RecMucTrackCol);
166 RecMucTrackCol::iterator beginOfMucTrackCol = RecMucTrackCol::iterator(NULL);
167 if(!mucTrackCol)
168 {
169 log<<MSG::INFO<<"Could not find RecMucTrackCol!"<<endreq;
170 }
171 else
172 {
173 beginOfMucTrackCol = mucTrackCol->begin();
174 numOfMucTrks = mucTrackCol->size();
175 }
176
177 //Some match flag
178
179 int MaxHit = numOfChargedTrks+numOfShower+numOfTof;
180
181 vector<bool> dEdxMatched;
182 vector<bool> kalTrkMatched;
183 vector<bool> extMatched;
184 vector<bool> TofMatched;
185 vector<bool> emcMatched;
186 vector<bool> mucMatched;
187
188 for(int i=0;i<MaxHit;i++)
189 {
190 dEdxMatched.push_back(false);
191 kalTrkMatched.push_back(false);
192 extMatched.push_back(false);
193 TofMatched.push_back(false);
194 emcMatched.push_back(false);
195 mucMatched.push_back(false);
196 }
197
198
199 //Part 3: Match tracks
200 // RecTrackListCol* aNewRecTrkListCol = new RecTrackListCol;
201 EvtRecTrackCol* aNewEvtRecTrackCol = new EvtRecTrackCol;
202 if(numOfChargedTrks+numOfShower)//if mdc trackCol and emc trackCol neither exists,there is no match job.
203 {
204 for(int i=0;i<numOfChargedTrks;i++)//match charged tracks
205 {
206 EvtRecTrack* aNewEvtRecTrack = new EvtRecTrack;
207 int mdcTrkID = (*(beginOfMdcTrkCol+i))->trackId();
208 aNewEvtRecTrack->setTrackId(mdcTrkID);
209 aNewEvtRecTrack->setMdcTrack(*(beginOfMdcTrkCol+i));
210 // aNewEvtRecTrack->setMdcTrkIdx(i);
211 for(int j=0;j<numOfKalTrks;j++)//match MdcKalTrack
212 if( !kalTrkMatched[j] && mdcTrkID==(*(beginOfMdcKalTrackCol+j))->trackId() )
213 {
214 aNewEvtRecTrack->setMdcKalTrack(*(beginOfMdcKalTrackCol+j));
215 // aNewRecTrkList->setMdcKalTrkIdx(j);
216 kalTrkMatched[j]=true;
217 }
218
219 for(int j=0;j<numOfDedx;j++)//match dEdx
220 if( !dEdxMatched[j] && mdcTrkID==(*(beginOfDedxCol+j))->trackId() )
221 {
222 aNewEvtRecTrack->setMdcDedx(*(beginOfDedxCol+j));
223 // aNewRecTrkList->setDedxTrkIdx(j);
224 dEdxMatched[j]=true;
225 }
226
227 for(int j=0;j<numOfExt;j++)//match ExtTrack
228 if( !extMatched[j] && mdcTrkID==(*(beginOfExtTrackCol+j))->trackId() )
229 {
230 aNewEvtRecTrack->setExtTrack(*(beginOfExtTrackCol+j));
231 // aNewRecTrkList->setExtTrkIdx(j);
232 extMatched[j]=true;
233 }
234 for(int j=0;j<numOfTof;j++)//match Tof
235 if( !TofMatched[j] && mdcTrkID==(*(beginOfTofTrackCol+j))->trackID() )
236 {
237 aNewEvtRecTrack->addTofTrack(*(beginOfTofTrackCol+j));
238 // aNewRecTrkList->setTofTrkIdx(j);
239 TofMatched[j]=true;
240 }
241 for(int j=0;j<numOfMucTrks;j++)//match MucTrack
242 if( !mucMatched[j] && mdcTrkID==(*(beginOfMucTrackCol+j))->trackId() )
243 {
244 aNewEvtRecTrack->setMucTrack(*(beginOfMucTrackCol+j));
245 // aNewRecTrkList->setMucTrkIdx(j);
246 mucMatched[j]=true;
247 }
248
249 if(m_Output==1){
250 myExted = -1.;
251 myMatched = -1.;
252 myEnergyMatched = -1.;
253 }
254 if(aNewEvtRecTrack->isExtTrackValid()&&(aNewEvtRecTrack->extTrack())->emcVolumeNumber()!=-1)//start to match Emc showers
255 {
256 if(m_Output==1)myExted = 1.;
257 //resieve ext information @ Emc
258 Hep3Vector extPos = (aNewEvtRecTrack->extTrack())->emcPosition();
259 double extTheta = extPos.theta();
260 double extPhi = extPos.phi();
261
262 double dAngleMin = 9999.;
263 int indexOfEmcNearest = -1;
264
265 for(int j=0;j<numOfShower;j++)//start to find nearest emc shower
266 {
267 if(!emcMatched[j])
268 {
269 HepPoint3D emcPot = (*(beginOfEmcTrackCol+j))->position();
270 Hep3Vector emcPos(emcPot.x(),emcPot.y(),emcPot.z());
271 double dAngle = extPos.angle(emcPos);
272 if(dAngle<dAngleMin)
273 {
274 dAngleMin = dAngle;
275 indexOfEmcNearest = j;
276 }
277 }
278 }
279 if(indexOfEmcNearest>=0)//if nearest Emc shower is found
280 {
281 HepPoint3D emcPot = (*(beginOfEmcTrackCol+indexOfEmcNearest))->position();
282 double theta = emcPot.theta();
283 double phi = emcPot.phi();
284 double deltaTheta = (extTheta-theta);
285 double deltaPhi = fmod(extPhi-phi+5*M_PI,2*M_PI)-M_PI;
286 if(myActiveCutFlag)
287 {
288 double tanLamda = (*(beginOfMdcTrkCol+i))->helix(4);
289 double kappa = (*(beginOfMdcTrkCol+i))->helix(2);
290 double p = sqrt(1+tanLamda*tanLamda)/fabs(kappa);
291 double aThetaCut = thetaCut(p,myEmcThetaNSigmaCut,myParticleId);
292 double aPhiCUt = phiCut(p,myEmcPhiNSigmaCut,myParticleId);
293 if(fabs(deltaTheta)<aThetaCut && fabs(deltaPhi)<aPhiCUt)
294 {
295 aNewEvtRecTrack->setEmcShower(*(beginOfEmcTrackCol+indexOfEmcNearest));
296 // aNewRecTrkList->setEmcTrkIdx(indexOfEmcNearest);
297 emcMatched[indexOfEmcNearest]=true;
298 numOfMatchedShower++;
299 if(m_Output==1)myMatched = 1.;
300 }
301 }
302 else if(fabs(deltaTheta)<myEmcThetaCut && fabs(deltaPhi)<myEmcPhiCut)//if the nearest shower is in the fixed match window,it will be matched.
303 {
304 aNewEvtRecTrack->setEmcShower(*(beginOfEmcTrackCol+indexOfEmcNearest));
305 // aNewRecTrkList->setEmcTrkIdx(indexOfEmcNearest);
306 emcMatched[indexOfEmcNearest]=true;
307 numOfMatchedShower++;
308 if(m_Output==1)myMatched = 1.;
309 }
310 }
311 }
312 aNewEvtRecTrackCol->push_back(aNewEvtRecTrack);
313 if(m_Output==1){
314 myEnergyMatched = 0.;
315 myNTuple1->write();
316 }
317 }//end charged track match
318
319 int id=0;
320 for(int i=0;i<numOfShower;i++)//If Emc shower isn't macthed, it will be added to the end of RecTrackListCol
321 {
322 if(!emcMatched[i])
323 {
324 EvtRecTrack* aNewEvtRecTrack = new EvtRecTrack;
325 aNewEvtRecTrack->setTrackId(id+numOfChargedTrks);
326 aNewEvtRecTrack->setEmcShower(*(beginOfEmcTrackCol+i));
327 // aNewRecTrkList->setEmcTrkIdx(i);
328
329 //EMC and TOF match
330 HepPoint3D emcPos((*(beginOfEmcTrackCol+i))->position());
331 double emcPhi = emcPos.phi();
332 emcPhi = emcPhi < 0 ? emcPhi+CLHEP::twopi : emcPhi;
333
334 int module=9999, nphi1=9999, nphi2=9999, nphi1_mrpc=9999;
335 module = (*(beginOfEmcTrackCol+i))->module();
336 if(module==1) { //barrel
337 nphi1 = (int)(emcPhi*88./CLHEP::twopi); //tof layer1 number
338 nphi2 = (int)(emcPhi*88./CLHEP::twopi+0.5); //tof layer2 number
339 nphi2 += 88;
340 } else { //endcap
341 nphi1 = (int)(emcPhi*48./CLHEP::twopi+0.5);
342
343
344 //new mrpc detector
345 double fi_endtof_mrpc = atan2(emcPos.y(),emcPos.x())-3.141592654/2.;
346 if(fi_endtof_mrpc<0) fi_endtof_mrpc += 2*3.141592654;
347 nphi1_mrpc=((int)(fi_endtof_mrpc/(3.141593/18)))+1; //We have 36 modules in each endcap (divided again into two layers)! The numbering starts with 1.
348
349 if(nphi1_mrpc%2==0){nphi1_mrpc=nphi1_mrpc/2;} //Calculate the correct number as in each endcap we have two layers of modules furnished with numbers 1 to 18.
350 else {nphi1_mrpc=(nphi1_mrpc+1)/2;}
351
352 if(emcPos.z()>0) {(nphi1_mrpc -= 19); nphi1_mrpc=nphi1_mrpc*(-1);} //Consider that for the east endcap the module at x=0;y=max has the number 18 (the numbering is != to west endcap)
353 // nphi1_mrpc is now the number of the nearest ToF module!
354
355 }
356
357 int dPhiMin = 9999;
358 int partid_dPhiMin = 7;
359 bool mrpcmatch = false;
360
361 int indexOfTofNearest = -1;
362 for(int j=0;j<numOfTof;j++) { //start to find nearest Tof shower
363 if( !TofMatched[j] ) {
364
365 Identifier id((*(beginOfTofTrackCol+j))->tofID());
366 bool is_mrpc = TofID::is_mymrpc(id);
367
368 if(!is_mrpc)
369 {
370 int barrel_ec = TofID::barrel_ec(id);
371 int layer = TofID::layer(id);
372 int im = TofID::phi_module(id);
373 im += layer * 88;
374
375 if(module!=barrel_ec) continue;
376
377 int dPhi;
378 if(layer == 0) {
379 dPhi = abs(im - nphi1);
380 } else {
381 dPhi = abs(im - nphi2);
382 }
383 if(module==1) {
384 dPhi = dPhi>=44 ? 88-dPhi : dPhi;
385 } else {
386 dPhi = dPhi>=24 ? 48-dPhi : dPhi;
387 }
388
389 if(dPhi < dPhiMin) {
390 dPhiMin = dPhi;
391 indexOfTofNearest = j;
392 }
393 }//close if(!is_mrpc)
394 else//is_mrpc
395 {
396 int barrel_ec = TofID::barrel_ec(id);
397 int im = TofID::phi_module(id);
398 int module_mrpc = (int)im/25;
399
400 if(module==1) continue; //Skip the barrel part
401 if(module==0 && (barrel_ec==5 || barrel_ec==6)) continue; // opposite sides of Tof and MRPC
402 if(module==2 && (barrel_ec==3 || barrel_ec==4)) continue;// opposite sides of Tof and MRPC
403
404 int dphi;
405 dphi = abs(module_mrpc-nphi1_mrpc);
406
407 if(dphi < dPhiMin)
408 {
409 dPhiMin=dphi;
410 partid_dPhiMin=barrel_ec;
411 indexOfTofNearest = j;
412 mrpcmatch = true;
413 }
414 }//close else is_mrpc
415
416 }//close if( !TofMatched[j] )
417 }//close for(int j=0;j<numOfTof;j++)
418
419 /*
420 if(0)
421 {
422 cout << "Event Assembly Algorithm" <<endl;
423 cout << "EMC Shower number = " << i << endl;
424 cout << "mrpcmatch ? " << mrpcmatch << endl;
425 cout << "indexOfTofNearest " << indexOfTofNearest <<endl;
426 cout << "dphiMin " << dPhiMin << endl;
427 cout << "partid_mrpc " << partid_dPhiMin <<endl;
428 cout << "partid_emc " << module <<endl <<endl;
429 }
430 */
431
432 //match in z-direction
433 if(indexOfTofNearest>=0) {
434 HepPoint3D tofPos(0,0.867,(*(beginOfTofTrackCol+indexOfTofNearest))->zrhit());
435 double matWindow = 0;
436 double eShower = (*(beginOfEmcTrackCol+i))->e5x5();//energy of a 5x5 cluster
437 if(eShower>0) {
438 matWindow = 0.01277+0.004268/sqrt(eShower);
439 }
440 }
441
442
443 if(indexOfTofNearest>=0 && dPhiMin<=1) { //if nearest Tof shower is found
444 // calculate matching window for barrel
445 double eShower = (*(beginOfEmcTrackCol+i))->e5x5();
446 double matWindow = 0;
447 if(eShower>0) {
448 matWindow = 0.01277+0.004268/sqrt(eShower);
449 }
450 matWindow = 0.2; //temp code
451
452 HepPoint3D tofPos(0,0.867,(*(beginOfTofTrackCol+indexOfTofNearest))->zrhit());
453 if(fabs(tofPos.theta()-emcPos.theta())<matWindow || module!=1) {
454 aNewEvtRecTrack->addTofTrack(*(beginOfTofTrackCol+indexOfTofNearest));
455 TofMatched[indexOfTofNearest]=true;
456 //cout << "EventAssembly : New neutral Toftrack added " << endl;
457
458 }
459 }//close if(indexOfTofNearest>=0 && dPhiMin<=1)
460
461 aNewEvtRecTrackCol->push_back(aNewEvtRecTrack);
462 id++;
463 }//close if(!)
464 }//close for(int i=0;i<numOfShower;i++) <---This are the EMC showers
465 }//end match
466
467 //match statistics
468 if(myMsgFlag) cout<<"Charged tracks: "<<numOfChargedTrks<<" Ext track: "<<numOfExt <<" Shower:"<<numOfShower<<" Matched shower:"<<numOfMatchedShower<<endl;
469
470 //Part 4: register RecTrackListCol and EventList in TDS
471 DataObject *aDataObject1;
472 eventSvc()->findObject(EventModel::EvtRec::Event, aDataObject1);
473 if ( aDataObject1 == NULL ) {
474 EvtRecObject* aRecObject = new EvtRecObject;
475 StatusCode sc = eventSvc()->registerObject(EventModel::EvtRec::Event, aRecObject);
476 if ( sc.isFailure() ) {
477 log << MSG::FATAL << "Could not register EvtRecObject in TDS!" << endreq;
478 return StatusCode::FAILURE;
479 }
480 }
481
482 DataObject* aDataObject2;
483 eventSvc()->findObject(EventModel::EvtRec::EvtRecEvent, aDataObject2);
484 if ( aDataObject2 == NULL ) {
485 EvtRecEvent* aRecEvent = new EvtRecEvent;
486 aRecEvent->setTotalTracks(numOfChargedTrks+numOfShower-numOfMatchedShower);
487 aRecEvent->setTotalCharged(numOfChargedTrks);
488 aRecEvent->setTotalNeutral(numOfShower-numOfMatchedShower);
489 StatusCode sc = eventSvc()->registerObject(EventModel::EvtRec::EvtRecEvent, aRecEvent);
490 if ( sc.isFailure() ) {
491 log << MSG::FATAL << "Could not register EvtRecEvent in TDS!" << endreq;
492 return( StatusCode::FAILURE);
493 }
494 }
495 else {
496 EvtRecEvent* aRecEvent = dynamic_cast<EvtRecEvent*>(aDataObject2);
497 aRecEvent->setTotalTracks(numOfChargedTrks+numOfShower-numOfMatchedShower);
498 aRecEvent->setTotalCharged(numOfChargedTrks);
499 aRecEvent->setTotalNeutral(numOfShower-numOfMatchedShower);
500 }
501
502 DataObject* aDataObject3;
503 eventSvc()->findObject(EventModel::EvtRec::EvtRecTrackCol, aDataObject3);
504 if ( aDataObject3 != NULL ) {
505 //IDataManagerSvc* dataMgrSvc = dynamic_cast<IDataManagerSvc*> (eventSvc());
506 SmartIF<IDataManagerSvc> dataMgrSvc(eventSvc());
507 dataMgrSvc->clearSubTree(EventModel::EvtRec::EvtRecTrackCol);
508 eventSvc()->unregisterObject(EventModel::EvtRec::EvtRecTrackCol);
509 }
510
511 StatusCode sc = eventSvc()->registerObject(EventModel::EvtRec::EvtRecTrackCol, aNewEvtRecTrackCol);
512 if ( sc.isFailure() ) {
513 log << MSG::FATAL << "Could not register EvtRecTrackCol in TDS!" << endreq;
514 return( StatusCode::FAILURE);
515 }
516
517 //Part 5: check RecTrackListCol in TDS
518 SmartDataPtr<EvtRecTrackCol> evtRecTrackCol(eventSvc(), EventModel::EvtRec::EvtRecTrackCol);
519 if(!evtRecTrackCol)
520 {
521 log<<MSG::FATAL<<"Could not find RecTrackListCol in TDS!"<<endreq;
522 }
523
524 EvtRecTrackCol::iterator itOfRecTrkListCol = evtRecTrackCol->begin();
525 if(myMsgFlag)
526 for(int i=0;itOfRecTrkListCol!=evtRecTrackCol->end();itOfRecTrkListCol++,i++)
527 {
528 cout<<"******************** Track "<<i<<": *********************"<<endl;
529 cout<<"Track ID: "<<(*itOfRecTrkListCol)->trackId()<<endl;
530 if((*itOfRecTrkListCol)->isMdcTrackValid())
531 {
532 RecMdcTrack* mdcTrk = (*itOfRecTrkListCol)->mdcTrack();
533 double kappa = mdcTrk->helix(2);
534 double tanl = mdcTrk->helix(4);
535 cout<<"Mdc kappa, tanl: "<<kappa<<", "<<tanl<<endl;
536 }
537 if((*itOfRecTrkListCol)->isExtTrackValid())
538 {
539 RecExtTrack* extTrack = (*itOfRecTrkListCol)->extTrack();
540 Hep3Vector emcPos = extTrack->emcPosition();
541 cout<<"Ext Emc pos:"<<emcPos.x()<<","<<emcPos.y()<<","<<emcPos.z()<<endl;
542 }
543 if((*itOfRecTrkListCol)->isEmcShowerValid())
544 {
545 RecEmcShower* emcTrack = (*itOfRecTrkListCol)->emcShower();
546 HepPoint3D emcPos = emcTrack->position();
547 double x = emcPos.x();
548 double y = emcPos.y();
549 double z = emcPos.z();
550 cout<<"Emc rec pos:"<<x<<","<<y<<","<<z<<endl;
551 }
552 }
553
554 return StatusCode::SUCCESS;
555}
556
557// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
559{
560 MsgStream log(msgSvc(), name());
561 log << MSG::INFO << "in finalize()" << endreq;
562
563 return StatusCode::SUCCESS;
564}
565
566
567
568//////////////////////////////
569double EventAssemblyAlg::thetaCut(double p,double nSigma,int parId)
570{
571 if(p<0.3) p=0.3;
572 if(parId<1||parId>3) parId=3;
573 if(nSigma<=0) nSigma = 5.;
574 double cut = myEmcThetaCut;
575 switch(parId)
576 {
577 case 1:cut = fabs(-0.00159)+(exp(-3.566*p-4.14)+0.006804)*nSigma; break;
578 case 2:cut = fabs(-0.00145)+(exp(-4.268*p-3.305)+0.01129)*nSigma; break;
579 case 3:cut = fabs(-0.00161)+(exp(-5.955*p-3.052)+0.01751)*nSigma; break;
580 }
581
582 return cut;
583}
584
585///////////////////////////////
586double EventAssemblyAlg::phiCut(double p,double nSigma,int parId)
587{
588 if(p<0.3) p=0.3;
589 if(parId<1||parId>3) parId=3;
590 if(nSigma<=0) nSigma = 5.;
591 double cut = myEmcPhiCut;
592 switch(parId)
593 {
594 case 1:cut = fabs(exp(-2.187*p-2.945)+0.03236)+(exp(-2.977*p-3.558)+0.005566)*nSigma; break;
595 case 2:cut = fabs(exp(-2.216*p-2.13)+0.03314)+(exp(-2.436*p-3.392)+0.005049)*nSigma; break;
596 case 3:cut = fabs(exp(-1.63*p-2.931)+0.03223)+(exp(-3.192*p-2.756)+0.01533)*nSigma; break;
597 }
598
599 return cut;
600}
601
Double_t x[10]
EvtComplex exp(const EvtComplex &c)
Definition: EvtComplex.hh:252
double abs(const EvtComplex &c)
Definition: EvtComplex.hh:212
ObjectVector< EvtRecTrack > EvtRecTrackCol
Definition: EvtRecTrack.h:109
*********Class see also m_nmax DOUBLE PRECISION m_MasPhot DOUBLE PRECISION m_phsu DOUBLE PRECISION m_Xenph DOUBLE PRECISION m_r2 DOUBLE PRECISION m_WtMass INTEGER m_nmax INTEGER m_Nevgen INTEGER m_IsFSR INTEGER m_MarTot *COMMON c_KarFin $ !Output file $ !Event serial number $ !alpha QED at Thomson limit $ !minimum energy at CMS for remooval $ !infrared cut
Definition: KarFin.h:27
INTupleSvc * ntupleSvc()
IMessageSvc * msgSvc()
#define M_PI
Definition: TConstant.h:4
HepPoint3D position() const
Definition: DstEmcShower.h:34
const Hep3Vector emcPosition() const
Definition: DstExtTrack.h:126
const HepVector helix() const
......
EventAssemblyAlg(const std::string &name, ISvcLocator *pSvcLocator)
StatusCode execute()
StatusCode initialize()
void setTotalTracks(const int tottks)
Definition: EvtRecEvent.h:22
void setTotalNeutral(const int nneu)
Definition: EvtRecEvent.h:28
void setTotalCharged(const int nchrg)
Definition: EvtRecEvent.h:25
void setMucTrack(const RecMucTrack *trk)
Definition: EvtRecTrack.h:83
void setMdcTrack(const RecMdcTrack *trk)
Definition: EvtRecTrack.h:76
int trackId() const
Definition: EvtRecTrack.h:32
void setTrackId(const int trkId)
Definition: EvtRecTrack.h:64
bool isExtTrackValid()
Definition: EvtRecTrack.h:49
void setMdcKalTrack(const RecMdcKalTrack *trk)
Definition: EvtRecTrack.h:77
void setMdcDedx(const RecMdcDedx *trk)
Definition: EvtRecTrack.h:78
RecExtTrack * extTrack()
Definition: EvtRecTrack.h:56
void setEmcShower(const RecEmcShower *shower)
Definition: EvtRecTrack.h:82
void addTofTrack(const SmartRef< RecTofTrack > trk)
Definition: EvtRecTrack.h:81
void setExtTrack(const RecExtTrack *trk)
Definition: EvtRecTrack.h:79
static int phi_module(const Identifier &id)
Definition: TofID.cxx:117
static int barrel_ec(const Identifier &id)
Values of different levels (failure returns 0)
Definition: TofID.cxx:95
static bool is_mymrpc(const Identifier &id)
Definition: TofID.cxx:58
static int layer(const Identifier &id)
Definition: TofID.cxx:109
_EXTERN_ std::string Event
Definition: EventModel.h:110
_EXTERN_ std::string EvtRecEvent
Definition: EventModel.h:111
_EXTERN_ std::string EvtRecTrackCol
Definition: EventModel.h:112
_EXTERN_ std::string RecExtTrackCol
Definition: EventModel.h:89
_EXTERN_ std::string RecMdcDedxCol
Definition: EventModel.h:84
_EXTERN_ std::string RecTofTrackCol
Definition: EventModel.h:93
_EXTERN_ std::string RecMdcTrackCol
Definition: EventModel.h:82
_EXTERN_ std::string RecMdcKalTrackCol
Definition: EventModel.h:86
_EXTERN_ std::string RecMucTrackCol
Definition: EventModel.h:102
_EXTERN_ std::string RecEmcShowerCol
Definition: EventModel.h:99