BOSS 7.1.2
BESIII Offline Software System
Loading...
Searching...
No Matches
LambdaCReconstruction.cxx
Go to the documentation of this file.
1//
2// All D+ decay modes Reconstruction
3//
4#include <fstream>
5#include "GaudiKernel/MsgStream.h"
6#include "GaudiKernel/AlgFactory.h"
7#include "GaudiKernel/ISvcLocator.h"
8#include "GaudiKernel/SmartDataPtr.h"
9#include "GaudiKernel/IDataProviderSvc.h"
10
12#include "EventModel/Event.h"
14
21
26#include "BesDChain/CDPi0List.h"
27#include "BesDChain/CDEtaList.h"
28#include "BesDChain/CDKsList.h"
31
32#include "McTruth/McParticle.h"
34#include "VertexFit/VertexFit.h"
37
53
54#include "DTagAlg/utility.h"
56
57
58
59using namespace Event;
60DECLARE_COMPONENT(LambdaCReconstruction)
61//*******************************************************************************************
62LambdaCReconstruction::LambdaCReconstruction(const std::string& name, ISvcLocator* pSvcLocator):
63 Algorithm(name, pSvcLocator) {
64 //Declare the properties
65 declareProperty( "debug", m_debug = false );
66 declareProperty( "ReadBeamEFromDB", m_ReadBeamEFromDB = false );
67 declareProperty( "UseCalibBeamE", m_usecalibBeamE = false );
68 declareProperty( "UseVertexfit", m_usevertexfit = false );
69 declareProperty( "BeamE", m_beamE = 2.3);
70 declareProperty( "LcList", m_decaylist = "test.txt" );
71 declareProperty("UseVFRefine", m_useVFrefine = true);
72 declareProperty( "UseBFieldCorr", m_useBFC = true);
73 }
74
75//******************************************************************************************
77 MsgStream log(msgSvc(), name());
78 log << MSG::INFO << "in initialize()" <<endreq;
79
80 m_irun=-100;
81 m_beta.setX(0.011);
82 m_beta.setY(0);
83 m_beta.setZ(0);
84 chanlist=getlist(m_decaylist);
85
86 return StatusCode::SUCCESS;
87}
88
89//********************************************************************************************
91 MsgStream log(msgSvc(), name());
92 log << MSG::INFO << "in finalize()" << endreq;
93
94 chanlist.clear();
95
96 return StatusCode::SUCCESS;
97}
98
99StatusCode LambdaCReconstruction::registerEvtRecDTagCol(
100 EvtRecDTagCol* aNewEvtRecDTagCol, MsgStream& log) {
101 StatusCode sc = eventSvc()->registerObject("/Event/EvtRec/EvtRecDTagCol",
102 aNewEvtRecDTagCol);
103 if (sc != StatusCode::SUCCESS) {
104 log << MSG::FATAL << "Could not register EvtRecDTagCol in TDS!" << endreq;
105 }
106 return sc;
107}
108
109//*********************************************************************************************
111 MsgStream log(msgSvc(), name());
112 log << MSG::INFO << "in execute()" << endreq;
113
114 StatusCode sc;
115
116 //////////////////
117 // Read REC data
118 /////////////////
119 SmartDataPtr<Event::EventHeader> eventHeader(eventSvc(),"/Event/EventHeader");
120 int event= eventHeader->eventNumber();
121 // if ( m_debug || ( (event & 0x3FF) == 0 ) )
122 //std::cout << "event: " << event << std::endl;
123
124 SmartDataPtr<EvtRecEvent> recEvent(eventSvc(), EventModel::EvtRec::EvtRecEvent);
125 SmartDataPtr<EvtRecTrackCol> recTrackCol(eventSvc(), EventModel::EvtRec::EvtRecTrackCol);
126 log << MSG::DEBUG << "run and event = " << eventHeader->runNumber()
127 << " " << eventHeader->eventNumber() << endreq;
128 log << MSG::DEBUG <<"ncharg, nneu, tottks = "
129 << recEvent->totalCharged() << " , "
130 << recEvent->totalNeutral() << " , "
131 << recEvent->totalTracks() <<endreq;
132
133 EvtRecTrackIterator charged_begin = recTrackCol->begin();
134 EvtRecTrackIterator charged_end = charged_begin + recEvent->totalCharged();
135
136 EvtRecTrackIterator neutral_begin = recTrackCol->begin()+recEvent->totalCharged();
137 EvtRecTrackIterator neutral_end = recTrackCol->begin()+recEvent->totalTracks();
138
139
140 SmartDataPtr<EvtRecPi0Col> recPi0Col(eventSvc(), "/Event/EvtRec/EvtRecPi0Col");
141 if ( ! recPi0Col ) {
142 log << MSG::FATAL << "Could not find EvtRecPi0Col" << endreq;
143 return StatusCode::FAILURE;
144 }
145
146
147 SmartDataPtr<EvtRecEtaToGGCol> recEtaToGGCol(eventSvc(), "/Event/EvtRec/EvtRecEtaToGGCol");
148 if ( ! recEtaToGGCol ) {
149 log << MSG::FATAL << "Could not find EvtRecEtaToGGCol" << endreq;
150 return StatusCode::FAILURE;
151 }
152
153
154 SmartDataPtr<EvtRecVeeVertexCol> recVeeVertexCol(eventSvc(), "/Event/EvtRec/EvtRecVeeVertexCol");
155 if ( ! recVeeVertexCol ) {
156 log << MSG::FATAL << "Could not find EvtRecVeeVertexCol" << endreq;
157 return StatusCode::FAILURE;
158 }
159
160
161 SmartDataPtr<EvtRecDTagCol> recDTagCol(eventSvc(), EventModel::EvtRec::EvtRecDTagCol);
162 if (!recDTagCol) {
163 log << MSG::FATAL << "EvtRecDTagCol is not registered yet" << endreq;
164 return StatusCode::FAILURE;
165 }
166
167
168
169 //get primary vertex from db
170 Hep3Vector xorigin(0,0,0);
171
172 IVertexDbSvc* vtxsvc;
173 Gaudi::svcLocator()->service("VertexDbSvc", vtxsvc);
174 if (vtxsvc->isVertexValid()) {
175
176 //vertex[0] = vx; vertex[1]= vy; vertex[2] = vz;
177 double* vertex = vtxsvc->PrimaryVertex();
178 xorigin.setX(vertex[0]);
179 xorigin.setY(vertex[1]);
180 xorigin.setZ(vertex[2]);
181 }
182
183 utility util;
184
185 /////////////////////////////
186 //reconstruct particle lists
187 /////////////////////////////
191
192 CDChargedPionList pionList(charged_begin, charged_end, pionSelector);
193 CDChargedKaonList kaonList(charged_begin, charged_end, kaonSelector);
194 CDProtonList protonList(charged_begin, charged_end, protonSelector);
195
196 CDPhotonList photonList(neutral_begin, neutral_end, photonSelector);
197
198 CDKsList ksList(ksSelector);
199 dc_fill(ksList, recVeeVertexCol->begin(), recVeeVertexCol->end());
200
201 // do a secondary vertex fit and cut on the results
202 map<EvtRecVeeVertex*, vector< double > > fitinfo_Ks;
203 for( CDKsList::iterator ksit = ksList.particle_begin(); ksit != ksList.particle_end(); ++ksit ){
204 EvtRecVeeVertex* ks = const_cast<EvtRecVeeVertex*>( (*ksit).particle().navKshort() );
205 if(m_useVFrefine){
206 fitinfo_Ks[ks] = util.SecondaryVFitref(ks, vtxsvc);
207 }else{
208 fitinfo_Ks[ks] = util.SecondaryVFit(ks, vtxsvc);
209 }
210
211 }
212
213 //CDLambdaList lambdaList(lambdaSelector);
214 //dc_fill(lambdaList, recVeeVertexCol->begin(), recVeeVertexCol->end());
215 CDLambdaList lambdaList( recVeeVertexCol->begin(), recVeeVertexCol->end(), lambdaSelector);
216 map<EvtRecVeeVertex*, vector< double > > fitinfo_Lambda;
217 for( CDLambdaList::iterator lambdait = lambdaList.particle_begin(); lambdait != lambdaList.particle_end(); ++lambdait ){
218 EvtRecVeeVertex* lambda = const_cast<EvtRecVeeVertex*>( (*lambdait).particle().navLambda() );
219 if(m_useVFrefine){
220 fitinfo_Lambda[lambda] = util.SecondaryVFit_Lambdaref(lambda, vtxsvc);
221 }else{
222 fitinfo_Lambda[lambda] = util.SecondaryVFit_Lambda(lambda, vtxsvc);
223 }
224
225 }
226
227 CDPi0List pi0List(pi0Selector);
228 dc_fill(pi0List, recPi0Col->begin(), recPi0Col->end());
229
230 CDEtaList etaList(etatoGGSelector);
231 dc_fill(etaList, recEtaToGGCol->begin(), recEtaToGGCol->end());
232
233 //pion/kaon list with PID
237 CDChargedPionList pionList_tight(charged_begin, charged_end, pionSelector);
238 CDChargedKaonList kaonList_tight(charged_begin, charged_end, kaonSelector);
239 CDProtonList protonList_tight(charged_begin, charged_end, protonSelector);
240 int run = eventHeader->runNumber();
241 m_ievt = eventHeader->eventNumber();
242 m_nChrg = recEvent->totalCharged();
243 m_nNeu = recEvent->totalNeutral();
244 m_nPion = pionList.size();
245 m_nKaon = kaonList.size();
246 m_nProton = protonList.size();
247 m_nPi0 = pi0List.size();
248 m_nKs = ksList.size();
249 m_nLambda = lambdaList.size();
250
251
252 ///////////////////////
253 // get beam energy and beta
254 ///////////////////////
255
256
257 if(m_ReadBeamEFromDB && m_irun!=run){
258 m_irun=run;
259 if(m_usecalibBeamE)
260 m_readDb.setcalib(true);
261 m_beamE=m_readDb.getbeamE(m_irun,m_beamE);
262 if(run>0)
263 m_beta=m_readDb.getbeta();
264 // cout<<"use beam E from data base:"<<m_beamE<<endl;
265 }
266 double ebeam=m_beamE;
267
268
269 //////////////////////////////
270 //reconstruct decay lists
271 /////////////////////////////
272
273
274 for(int list=0;list<chanlist.size();list++){
275
276 string channel=chanlist[list];
277 vector<int> numchan;
279 lambdaCSelector.setbeta(m_beta);
280 CDDecayList decaylist(lambdaCSelector);
281
282 //K+/-: 1, Pi+/-:2, Pi0:3, Eta: 4, Ks:5, epTopipieta:6, epTorhogam:7, proton:8, Lambda:9, Sigma0:10, SigmaP:11, Omega:12
283 //the fist element of the vector stands for decay mode,
284 //the rest will be particles, and size of the vector minus 1 will be number of daughers.
285
286 if(channel=="LambdacPtoKsP") {
287 numchan.push_back( EvtRecDTag::kLambdacPtoKsP);
288 numchan.push_back(8);
289 numchan.push_back(5);
290 decaylist=protonList.plus()* ksList;
291 }
292 else if(channel=="LambdacPtoKPiP") {
293 numchan.push_back( EvtRecDTag::kLambdacPtoKPiP );
294 numchan.push_back(8);
295 numchan.push_back(1);
296 numchan.push_back(2);
297 decaylist=protonList.plus()* kaonList.minus()* pionList.plus();
298 }
299 else if(channel=="LambdacPtoKsPi0P") {
300 numchan.push_back( EvtRecDTag::kLambdacPtoKsPi0P);
301 numchan.push_back(8);
302 numchan.push_back(5);
303 numchan.push_back(3);
304 decaylist=protonList.plus()* ksList* pi0List;
305 }
306 else if(channel=="LambdacPtoKsPiPiP") {
307 numchan.push_back( EvtRecDTag::kLambdacPtoKsPiPiP);
308 numchan.push_back(8);
309 numchan.push_back(5);
310 numchan.push_back(2);
311 numchan.push_back(2);
312 decaylist=protonList.plus()* ksList* pionList.plus()* pionList.minus();
313 }
314 else if(channel=="LambdacPtoKPiPi0P") {
315 numchan.push_back( EvtRecDTag::kLambdacPtoKPiPi0P);
316 numchan.push_back(8);
317 numchan.push_back(1);
318 numchan.push_back(2);
319 numchan.push_back(3);
320 decaylist=protonList.plus()* kaonList.minus()* pionList.plus()* pi0List;
321 }
322 else if(channel=="LambdacPtoPiPiP") {
323 numchan.push_back( EvtRecDTag::kLambdacPtoPiPiP );
324 numchan.push_back(8);
325 numchan.push_back(2);
326 numchan.push_back(2);
327 decaylist=protonList.plus()* pionList.plus()* pionList.minus();
328 }
329 else if(channel=="LambdacPtoLambdaPi") {
330 numchan.push_back( EvtRecDTag::kLambdacPtoLambdaPi );
331 numchan.push_back(9);
332 numchan.push_back(2);
333 decaylist=lambdaList()* pionList.plus();
334 }
335 else if(channel=="LambdacPtoLambdaPiPi0") {
336 numchan.push_back( EvtRecDTag::kLambdacPtoLambdaPiPi0 );
337 numchan.push_back(9);
338 numchan.push_back(2);
339 numchan.push_back(3);
340 decaylist=lambdaList()* pionList.plus()* pi0List;
341 }
342 else if(channel=="LambdacPtoLambdaPiEta") {
343 numchan.push_back( EvtRecDTag::kLambdacPtoLambdaPiEta );
344 numchan.push_back(9);
345 numchan.push_back(2);
346 numchan.push_back(4);
347 decaylist=lambdaList()* pionList.plus()* etaList;;
348 }
349 else if(channel=="LambdacPtoLambdaPiPiPi") {
350 numchan.push_back( EvtRecDTag::kLambdacPtoLambdaPiPiPi );
351 numchan.push_back(9);
352 numchan.push_back(2);
353 numchan.push_back(2);
354 numchan.push_back(2);
355 decaylist=lambdaList()* pionList.plus()* pionList.minus() *pionList.plus();
356 }
357 else if(channel=="LambdacPtoLambdaPiOmega") {
358 numchan.push_back( EvtRecDTag::kLambdacPtoLambdaPiOmega );
359 numchan.push_back(9);
360 numchan.push_back(2);
361 numchan.push_back(12);
363 omgList=pionList.plus()* pionList.minus() *pi0List;
364 decaylist=lambdaList()* pionList.plus()* omgList;
365 }
366 else if(channel=="LambdacPtoPiSIGMA0LambdaGam") {
367 numchan.push_back( EvtRecDTag::kLambdacPtoPiSIGMA0LambdaGam );
368 numchan.push_back(2);
369 numchan.push_back(10);
371 sgmList=lambdaList()* photonList;
372 decaylist=pionList.plus()* sgmList;
373 }
374 else if(channel=="LambdacPtoPiPi0SIGMA0LambdaGam") {
376 numchan.push_back(2);
377 numchan.push_back(3);
378 numchan.push_back(10);
380 sgmList=lambdaList()* photonList;
381 decaylist=pionList.plus()* pi0List* sgmList;
382 }
383 else if(channel=="LambdacPtoPi0SIGMAPi0P") {
384 numchan.push_back( EvtRecDTag::kLambdacPtoPi0SIGMAPi0P );
385 numchan.push_back(3);
386 numchan.push_back(11);
388 sgmList=pi0List* protonList.plus();
389 decaylist=pi0List* sgmList;
390 }
391 else if(channel=="LambdacPtoPiPiSIGMAPi0P") {
392 numchan.push_back( EvtRecDTag::kLambdacPtoPiPiSIGMAPi0P );
393 numchan.push_back(2);
394 numchan.push_back(2);
395 numchan.push_back(11);
397 sgmList=pi0List* protonList.plus();
398 decaylist=pionList.plus()* pionList.minus()* sgmList;
399 }
400 else if(channel=="LambdacPtoOmegaSIGMAPi0P") {
401 numchan.push_back( EvtRecDTag::kLambdacPtoOmegaSIGMAPi0P );
402 numchan.push_back(12);
403 numchan.push_back(11);
405 omgList=pionList.plus()* pionList.minus()* pi0List;
407 sgmList=pi0List* protonList.plus();
408 decaylist=omgList* sgmList;
409 }
410 else if(channel=="LambdacPtoPiPiPi0SIGMAPi0P") {
411 numchan.push_back( EvtRecDTag::kLambdacPtoPiPiPi0SIGMAPi0P );
412 numchan.push_back(2);
413 numchan.push_back(2);
414 numchan.push_back(3);
415 numchan.push_back(11);
417 sgmList=pi0List* protonList.plus();
418 decaylist=pionList.plus()* pionList.minus()*pi0List* sgmList;
419 }
420
421
422 CDDecayList::iterator Lc_begin =decaylist.particle_begin();
423 CDDecayList::iterator Lc_end =decaylist.particle_end();
424
425 for ( CDDecayList::iterator it = Lc_begin; it != Lc_end; it++ ) {
426
427 EvtRecDTag* recDTag = new EvtRecDTag;
428 recDTag->setdecayMode( (EvtRecDTag::DecayMode)numchan[0] );
429
430 vector<int> trackid, showerid;
431 vector<int> kaonid, pionid, protonid;
432 int numofchildren=numchan.size()-1;
433
434 for(int i=0; i< numofchildren;i++){
435
436 const CDCandidate& daughter=(*it).particle().child(i);
437
438 if(numchan[i+1]==1){
439 const EvtRecTrack* track=daughter.track();
440 trackid.push_back(track->trackId());
441 kaonid.push_back(track->trackId());
442 }
443 else if(numchan[i+1]==2){
444 const EvtRecTrack* track=daughter.track();
445 trackid.push_back(track->trackId());
446 pionid.push_back(track->trackId());
447 }
448 else if(numchan[i+1]==8){
449 const EvtRecTrack* track=daughter.track();
450 trackid.push_back(track->trackId());
451 protonid.push_back(track->trackId());
452 }
453 else if ( numchan[i+1]==3){
454 const EvtRecTrack* hiEnGamma=daughter.navPi0()->hiEnGamma();
455 const EvtRecTrack* loEnGamma=daughter.navPi0()->loEnGamma();
456 showerid.push_back(hiEnGamma->trackId());
457 showerid.push_back(loEnGamma->trackId());
458 }
459 else if ( numchan[i+1]==4){
460 const EvtRecTrack* hiEnGamma=daughter.navEta()->hiEnGamma();
461 const EvtRecTrack* loEnGamma=daughter.navEta()->loEnGamma();
462 showerid.push_back(hiEnGamma->trackId());
463 showerid.push_back(loEnGamma->trackId());
464 }
465 else if ( numchan[i+1]==5){
466 EvtRecVeeVertex* aKsCand = const_cast<EvtRecVeeVertex*>( daughter.navKshort() );
467 recDTag->addToFitInfo(aKsCand->mass(),fitinfo_Ks[aKsCand][0],fitinfo_Ks[aKsCand][1],fitinfo_Ks[aKsCand][2]);
468 EvtRecTrack* pion1Trk = aKsCand->daughter(0);
469 EvtRecTrack* pion2Trk = aKsCand->daughter(1);
470 trackid.push_back(pion1Trk->trackId());
471 trackid.push_back(pion2Trk->trackId());
472 }
473 else if ( numchan[i+1]==9){
474 EvtRecVeeVertex* aLambdaCand = const_cast<EvtRecVeeVertex*>( daughter.navLambda() );
475 recDTag->addToFitInfo(aLambdaCand->mass(),fitinfo_Lambda[aLambdaCand][0],fitinfo_Lambda[aLambdaCand][1],fitinfo_Lambda[aLambdaCand][2]);
476
477 int index[2] = {0, 1};
478 if (aLambdaCand->vertexId() < 0){
479 index[0] = 1;
480 index[1] = 0;
481 }
482
483 EvtRecTrack* protonTrk = aLambdaCand->daughter(index[0]);
484 EvtRecTrack* pionTrk = aLambdaCand->daughter(index[1]);
485 trackid.push_back(protonTrk->trackId());
486 trackid.push_back(pionTrk->trackId());
487 }
488 else if (numchan[i+1]==6){
489 const CDCandidate& apion = daughter.decay().child(0);
490 const CDCandidate& spion = daughter.decay().child(1);
491 const CDCandidate& eta = daughter.decay().child(2);
492 const EvtRecTrack* apiontrk = apion.track();
493 const EvtRecTrack* spiontrk = spion.track();
494 const EvtRecTrack* hiEnGamma=eta.navEta()->hiEnGamma();
495 const EvtRecTrack* loEnGamma=eta.navEta()->loEnGamma();
496
497 trackid.push_back(apiontrk->trackId());
498 trackid.push_back(spiontrk->trackId());
499 showerid.push_back(hiEnGamma->trackId());
500 showerid.push_back(loEnGamma->trackId());
501
502 }
503 else if (numchan[i+1]==7){
504 const CDCandidate& rho = daughter.decay().child(0);
505 const CDCandidate& apion = rho.decay().child(0);
506 const CDCandidate& spion = rho.decay().child(1);
507 const CDCandidate& gamma = daughter.decay().child(1);
508
509 const EvtRecTrack* apiontrk = apion.track();
510 const EvtRecTrack* spiontrk = spion.track();
511 const EvtRecTrack* gammatrk = gamma.photon();
512
513
514 trackid.push_back(apiontrk->trackId());
515 trackid.push_back(spiontrk->trackId());
516 showerid.push_back(gammatrk->trackId());
517
518 }
519 else if (numchan[i+1]==10){
520 const CDCandidate& gamma = daughter.decay().child(1);
521 const EvtRecTrack* gammatrk = gamma.photon();
522 showerid.push_back(gammatrk->trackId());
523
524 EvtRecVeeVertex* aLambdaCand = const_cast<EvtRecVeeVertex*>( daughter.decay().child(0).navLambda() );
525 recDTag->addToFitInfo(aLambdaCand->mass(),fitinfo_Lambda[aLambdaCand][0],fitinfo_Lambda[aLambdaCand][1],fitinfo_Lambda[aLambdaCand][2]);
526
527 int index[2] = {0, 1};
528 if (aLambdaCand->vertexId() < 0){
529 index[0] = 1;
530 index[1] = 0;
531 }
532
533 EvtRecTrack* protonTrk = aLambdaCand->daughter(index[0]);
534 EvtRecTrack* pionTrk = aLambdaCand->daughter(index[1]);
535 trackid.push_back(protonTrk->trackId());
536 trackid.push_back(pionTrk->trackId());
537
538 }
539 else if (numchan[i+1]==11){
540 const CDCandidate& pi0 = daughter.decay().child(0);
541 const CDCandidate& agam = pi0.decay().child(0);
542 const CDCandidate& sgam = pi0.decay().child(1);
543 const CDCandidate& P = daughter.decay().child(1);
544
545 const EvtRecTrack* agamtrk = agam.photon();
546 const EvtRecTrack* sgamtrk = sgam.photon();
547 const EvtRecTrack* Ptrk = P.track();
548
549
550 showerid.push_back(agamtrk->trackId());
551 showerid.push_back(sgamtrk->trackId());
552 trackid.push_back(Ptrk->trackId());
553 }
554 else if (numchan[i+1]==12){
555 const CDCandidate& apion = daughter.decay().child(0);
556 const CDCandidate& spion = daughter.decay().child(1);
557 const CDCandidate& pi0 = daughter.decay().child(2);
558 const EvtRecTrack* apiontrk = apion.track();
559 const EvtRecTrack* spiontrk = spion.track();
560 const EvtRecTrack* hiEnGamma=pi0.navPi0()->hiEnGamma();
561 const EvtRecTrack* loEnGamma=pi0.navPi0()->loEnGamma();
562
563 trackid.push_back(apiontrk->trackId());
564 trackid.push_back(spiontrk->trackId());
565 showerid.push_back(hiEnGamma->trackId());
566 showerid.push_back(loEnGamma->trackId());
567
568 }
569
570 }//end of filling track and shower ids
571
572
573 saveLcInfo(it, ebeam, numofchildren, recDTag);
574 if(m_useBFC){
575 //After use BFC package, we need to update information of Ks and Lambda to calculate D.
576 updateKsLambdaInfo(it, ebeam, numofchildren, recDTag, numchan, vtxsvc, m_useVFrefine);
577 }
578 savetrack(trackid,showerid,charged_begin,charged_end,neutral_begin,neutral_end,recDTag);
579 pidtag(kaonid,pionid,protonid, kaonList_tight, pionList_tight, protonList_tight, recDTag);
580
581 if(m_usevertexfit){
582 if(m_debug) cout<<"beforevfit:"<<endl;
583
584 HepLorentzVector p4change_vfit;
585
586 if(m_useVFrefine){
587 p4change_vfit=util.vfitref(channel, kaonid, pionid, xorigin, charged_begin);
588 }else{
589 p4change_vfit=util.vfit(channel, kaonid, pionid, xorigin, charged_begin);
590 }
591
592 recDTag->setp4(recDTag->p4()+p4change_vfit);
593 }
594
595
596 trackid.clear();
597 showerid.clear();
598 kaonid.clear();
599 pionid.clear();
600 protonid.clear();
601
602 //write dtag object out
603 recDTagCol->push_back(recDTag);
604
605 }//end of decaylist iterator
606
607 numchan.clear();
608
609 }//end of reconstrucing all D+ decay lists
610
611 return StatusCode::SUCCESS;
612}
613
614
615void LambdaCReconstruction::saveLcInfo(CDDecayList::iterator it, double ebeam, int numofchildren, EvtRecDTag* recDTag){
616
617 double mass = (*it).particle().mass();
618 int charge= (*it).particle().charge();
619 HepLorentzVector p4((*it).particle().momentum(), (*it).particle().energy());
620 recDTag->setp4(p4);
621
622 p4.boost(-m_beta);
623 double mbc2_CMS = ebeam*ebeam - p4.v().mag2();
624 double mbc_CMS = mbc2_CMS > 0 ? sqrt( mbc2_CMS ) : -10;
625 double deltaE_CMS = p4.t() - ebeam;
626
627 if((*it).particle().userTag()==1)
628 recDTag->settype( EvtRecDTag::Tight );
629 else
630 recDTag->settype( EvtRecDTag::Loose );
631 recDTag->setcharge(charge);
632 recDTag->setcharm(charge);
633 recDTag->setnumOfChildren(numofchildren);
634 recDTag->setmass(mass);
635 recDTag->setmBC(mbc_CMS);
636 recDTag->setbeamE(ebeam);
637 recDTag->setdeltaE(deltaE_CMS);
638
639}
640
641void LambdaCReconstruction::savetrack(vector<int> trackid, vector<int> showerid, EvtRecTrackIterator charged_begin, EvtRecTrackIterator charged_end,
642 EvtRecTrackIterator neutral_begin, EvtRecTrackIterator neutral_end,EvtRecDTag* recDTag){
643
644 vector<EvtRecTrackIterator> trktemp;
645 vector<EvtRecTrackIterator> shrtemp;
646
647 //fill tracks
648 for(EvtRecTrackIterator trk=charged_begin; trk<charged_end;trk++){
649
650 bool isothertrack=true;
651 for(int i=0; i<trackid.size(); i++){
652 if( (*trk)->trackId()==trackid[i] ){
653 trktemp.push_back(trk);
654 isothertrack=false;
655 break;
656 }
657 }
658 if(isothertrack)
659 recDTag->addOtherTrack(*trk);
660 }
661 for(int i=0; i<trackid.size();i++){
662 for(int j=0; j<trktemp.size(); j++){
663 EvtRecTrackIterator trk=trktemp[j];
664 if( (*trk)->trackId()==trackid[i])
665 recDTag->addTrack(*trktemp[j]);
666 }
667 }
668
669
670 //fill showers
671 for(EvtRecTrackIterator shr=neutral_begin; shr<neutral_end;shr++){
672 bool isothershower=true;
673 for(int i=0; i<showerid.size(); i++){
674 if( (*shr)->trackId()==showerid[i] ){
675 shrtemp.push_back(shr);
676 isothershower=false;
677 break;
678 }
679 }
680 if(isothershower)
681 recDTag->addOtherShower(*shr);
682 }
683
684 for(int i=0; i<showerid.size();i++){
685 for(int j=0; j<shrtemp.size(); j++){
686 EvtRecTrackIterator shr=shrtemp[j];
687 if( (*shr)->trackId()==showerid[i])
688 recDTag->addShower(*shrtemp[j]);
689 }
690 }
691
692
693}
694
695void LambdaCReconstruction::pidtag(vector<int> kaonid, vector<int> pionid, vector<int> protonid, CDChargedKaonList& kaonList, CDChargedPionList& pionList, CDProtonList& protonList,EvtRecDTag* recDTag){
696
697 bool iskaon=false,ispion=false,isproton=false;
698
699
700 // save track ids which passed pion/kaon cuts
701
702 for (CDChargedKaonList::iterator kit = kaonList.particle_begin(); kit != kaonList.particle_end(); kit++) {
703 recDTag->addKaonId( (*kit).particle().track() );
704 }
705
706 for (CDChargedPionList::iterator pit = pionList.particle_begin(); pit != pionList.particle_end(); pit++) {
707 recDTag->addPionId( (*pit).particle().track() );
708 }
709 for (CDProtonList::iterator pt = protonList.particle_begin(); pt != protonList.particle_end(); pt++) {
710 recDTag->addProtonId( (*pt).particle().track() );
711 }
712
713
714 /*
715 for(int i=0; i<kaonid.size(); i++){
716 bool ithkaon=false;
717 for (CDChargedKaonList::iterator kit = kaonList.particle_begin(); kit != kaonList.particle_end(); kit++) {
718 if((*kit).particle().track()->trackId()==kaonid[i]){
719 ithkaon=true;
720 break;
721 }
722 }
723 if(!ithkaon) break;
724 if(i==kaonid.size()-1)
725 iskaon=true;
726 }
727
728 for(int i=0; i<pionid.size(); i++){
729 bool ithpion=false;
730 for (CDChargedPionList::iterator pit = pionList.particle_begin(); pit != pionList.particle_end(); pit++) {
731 if((*pit).particle().track()->trackId()==pionid[i]){
732 ithpion=true;
733 break;
734 }
735 }
736 if(!ithpion) break;
737 if(i==pionid.size()-1)
738 ispion=true;
739 }
740
741
742 if( iskaon && ispion)
743 recDTag->settype( EvtRecDTag::Tight );
744 else if( (kaonid.size()==0 && ispion) || (pionid.size()==0 && iskaon))
745 recDTag->settype( EvtRecDTag::Tight );
746 else if( kaonid.size()==0 && pionid.size()==0 )
747 recDTag->settype( EvtRecDTag::Tight );
748 */
749
750}
751
752
753
754vector<string> LambdaCReconstruction::getlist(string& filename ){
755
756 string channel;
757 vector<string> temp;
758
759 ifstream inFile;
760
761 inFile.open(filename.c_str());
762 if (!inFile) {
763 cout << "Unable to open decay list file";
764 exit(1); // terminate with error
765 }
766
767 while (inFile >> channel) {
768 temp.push_back(channel);
769 }
770
771 inFile.close();
772
773 return temp;
774
775}
776
777
778void LambdaCReconstruction::updateKsLambdaInfo(CDDecayList::iterator it, double ebeam, int numofchildren, EvtRecDTag* recDTag, vector<int> numchan, IVertexDbSvc* vtxsvc, bool m_useVFrefine){
779
780//This function is used to update the information of Ks and Lambda. Because DTagAlg package uses the list from VeeVertexFit package which input the information of Ks and Lambda while reconstructing the dst, the information of them don't use the MBF correction and we need to update them here.
781
782 //If we don't use BF Correctoin, please close this function.
783
784 HepLorentzVector p4Lc((*it).particle().momentum(), (*it).particle().energy());
785 HepLorentzVector p4Lc_New;
786
787 for(int i = 0; i < numofchildren; i++){
788 const CDCandidate& daughter=(*it).particle().child(i);
789
790 if(numchan[i+1]==5){
791 EvtRecVeeVertex* aKsCand = const_cast<EvtRecVeeVertex*>(daughter.navKshort());
792 HepVector veewks = aKsCand->w(); //px, py, pz, E, x, y, z
793 HepLorentzVector p4KsCand;
794 p4KsCand.setX(veewks[0]);
795 p4KsCand.setY(veewks[1]);
796 p4KsCand.setZ(veewks[2]);
797 p4KsCand.setE(veewks[3]);
798 HepLorentzVector p4wks = p4KsCand;
799
800 utility util;
801
802 //by default: px, py, pz, E, chisq, ifok
803 vector<double> vp4ks_new = util.UpdatedKsIfo(aKsCand,vtxsvc,m_useVFrefine);
804 HepLorentzVector p4wks_new;
805 p4wks_new.setX(vp4ks_new[0]);
806 p4wks_new.setY(vp4ks_new[1]);
807 p4wks_new.setZ(vp4ks_new[2]);
808 p4wks_new.setE(vp4ks_new[3]);
809
810 p4Lc = p4Lc - p4wks + p4wks_new;
811
812 }
813
814 if(numchan[i+1]==9){
815 EvtRecVeeVertex* aLambdaCand = const_cast<EvtRecVeeVertex*>(daughter.navLambda());
816 HepVector veewlambda = aLambdaCand->w(); //px, py, pz, E, x, y, z
817 HepLorentzVector p4LambdaCand;
818 p4LambdaCand.setX(veewlambda[0]);
819 p4LambdaCand.setY(veewlambda[1]);
820 p4LambdaCand.setZ(veewlambda[2]);
821 p4LambdaCand.setE(veewlambda[3]);
822 HepLorentzVector p4wlambda = p4LambdaCand;
823
824 utility util;
825
826 //by default: px, py, pz, E, chisq, ifok
827 vector<double> vp4lambda_new = util.UpdatedLambdaIfo(aLambdaCand,vtxsvc,m_useVFrefine);
828 HepLorentzVector p4wlambda_new;
829 p4wlambda_new.setX(vp4lambda_new[0]);
830 p4wlambda_new.setY(vp4lambda_new[1]);
831 p4wlambda_new.setZ(vp4lambda_new[2]);
832 p4wlambda_new.setE(vp4lambda_new[3]);
833
834 p4Lc = p4Lc - p4wlambda + p4wlambda_new;
835
836 }
837
838 if(numchan[i+1]==10){
839 EvtRecVeeVertex* aLambdaCand = const_cast<EvtRecVeeVertex*>(daughter.decay().child(0).navLambda());
840 HepVector veewlambda = aLambdaCand->w(); //px, py, pz, E, x, y, z
841 HepLorentzVector p4LambdaCand;
842 p4LambdaCand.setX(veewlambda[0]);
843 p4LambdaCand.setY(veewlambda[1]);
844 p4LambdaCand.setZ(veewlambda[2]);
845 p4LambdaCand.setE(veewlambda[3]);
846 HepLorentzVector p4wlambda = p4LambdaCand;
847
848 utility util;
849
850 //by default: px, py, pz, E, chisq, ifok
851 vector<double> vp4lambda_new = util.UpdatedLambdaIfo(aLambdaCand,vtxsvc,m_useVFrefine);
852 HepLorentzVector p4wlambda_new;
853 p4wlambda_new.setX(vp4lambda_new[0]);
854 p4wlambda_new.setY(vp4lambda_new[1]);
855 p4wlambda_new.setZ(vp4lambda_new[2]);
856 p4wlambda_new.setE(vp4lambda_new[3]);
857
858 p4Lc = p4Lc - p4wlambda + p4wlambda_new;
859
860 }
861
862 }
863
864 p4Lc_New = p4Lc;
865
866 double mass = p4Lc_New.m();
867 int charge = (*it).particle().charge();
868 recDTag->setp4(p4Lc_New);
869 p4Lc_New.boost(-m_beta);
870 double mbc2_CMS = ebeam*ebeam - p4Lc_New.v().mag2();
871 double mbc_CMS = mbc2_CMS > 0 ? sqrt( mbc2_CMS ) : -10;
872 double deltaE_CMS = p4Lc_New.t() - ebeam;
873
874 int tag=(*it).particle().userTag();
875 if(tag==1)
876 recDTag->settype( EvtRecDTag::Tight );
877 else
878 recDTag->settype( EvtRecDTag::Loose );
879 recDTag->setcharge(charge);
880 recDTag->setcharm(charge);
881 recDTag->setnumOfChildren(numofchildren);
882 recDTag->setmass(mass);
883 recDTag->setmBC(mbc_CMS);
884 recDTag->setbeamE(ebeam);
885 recDTag->setdeltaE(deltaE_CMS);
886
887
888}
889
890
891
892
893
double P(RecMdcKalTrack *trk)
double mass
void dc_fill(DCFillableChargedList< Charged > &aFillableList, WitnessIterator first, WitnessIterator last)
double ebeam
ObjectVector< EvtRecDTag > EvtRecDTagCol
Definition EvtRecDTag.h:329
EvtRecTrackCol::iterator EvtRecTrackIterator
LambdaCSelector lambdaCSelector
LocalChargedSigmaSelector chargedsigmaSelector
LocalEtatoGGSelector etatoGGSelector
LocalKaonSelector kaonSelector
LocalKsSelector ksSelector
LocalLambdaSelector lambdaSelector
LocalPhotonSelector photonSelector
LocalPi0Selector pi0Selector
LocalPionSelector pionSelector
LocalProtonSelector protonSelector
LocalSigma0Selector sigma0Selector
LocalomegatoPiPiPi0Selector omegatoPiPiPi0Selector
IMessageSvc * msgSvc()
virtual const DecayEvidence & decay() const
virtual const EvtRecTrack * photon() const
virtual const EvtRecVeeVertex * navLambda() const
virtual const EvtRecTrack * track() const
virtual const EvtRecVeeVertex * navKshort() const
virtual const EvtRecPi0 * navPi0() const
virtual const EvtRecEtaToGG * navEta() const
const CDCandidate & child(unsigned int aPosition) const
Definition CDDecay.cxx:247
@ kLambdacPtoLambdaPiOmega
Definition EvtRecDTag.h:214
@ kLambdacPtoPiSIGMA0LambdaGam
Definition EvtRecDTag.h:216
@ kLambdacPtoKPiPi0P
Definition EvtRecDTag.h:207
@ kLambdacPtoOmegaSIGMAPi0P
Definition EvtRecDTag.h:220
@ kLambdacPtoKsPi0P
Definition EvtRecDTag.h:205
@ kLambdacPtoLambdaPi
Definition EvtRecDTag.h:210
@ kLambdacPtoPi0SIGMAPi0P
Definition EvtRecDTag.h:218
@ kLambdacPtoLambdaPiPi0
Definition EvtRecDTag.h:211
@ kLambdacPtoPiPiSIGMAPi0P
Definition EvtRecDTag.h:219
@ kLambdacPtoLambdaPiEta
Definition EvtRecDTag.h:212
@ kLambdacPtoKsPiPiP
Definition EvtRecDTag.h:206
@ kLambdacPtoPiPiPi0SIGMAPi0P
Definition EvtRecDTag.h:221
@ kLambdacPtoPiPi0SIGMA0LambdaGam
Definition EvtRecDTag.h:217
@ kLambdacPtoLambdaPiPiPi
Definition EvtRecDTag.h:213
void addOtherTrack(const SmartRef< EvtRecTrack > track)
Definition EvtRecDTag.h:275
void settype(SelType type)
Definition EvtRecDTag.h:254
void setdecayMode(DecayMode decayMode)
Definition EvtRecDTag.h:253
HepLorentzVector p4() const
Definition EvtRecDTag.h:237
void setp4(HepLorentzVector p4)
Definition EvtRecDTag.h:262
void setmass(double mass)
Definition EvtRecDTag.h:256
void addToFitInfo(double ksmass, double chi2, double length, double error)
Definition EvtRecDTag.h:264
void addOtherShower(const SmartRef< EvtRecTrack > shower)
Definition EvtRecDTag.h:277
void addKaonId(const SmartRef< EvtRecTrack > kaonId)
Definition EvtRecDTag.h:281
void setdeltaE(double deltaE)
Definition EvtRecDTag.h:258
void setcharm(int charm)
Definition EvtRecDTag.h:260
void setmBC(double mBC)
Definition EvtRecDTag.h:257
void setcharge(int charge)
Definition EvtRecDTag.h:259
void addPionId(const SmartRef< EvtRecTrack > pionId)
Definition EvtRecDTag.h:279
void setbeamE(double beamE)
Definition EvtRecDTag.h:255
void addProtonId(const SmartRef< EvtRecTrack > protonId)
Definition EvtRecDTag.h:283
void addShower(const SmartRef< EvtRecTrack > shower)
Definition EvtRecDTag.h:273
void setnumOfChildren(int numOfChildren)
Definition EvtRecDTag.h:261
void addTrack(const SmartRef< EvtRecTrack > track)
Definition EvtRecDTag.h:271
const EvtRecTrack * hiEnGamma() const
const EvtRecTrack * loEnGamma() const
const EvtRecTrack * loEnGamma() const
Definition EvtRecPi0.h:31
const EvtRecTrack * hiEnGamma() const
Definition EvtRecPi0.h:30
int trackId() const
Definition EvtRecTrack.h:32
SmartRef< EvtRecTrack > & daughter(int i)
int vertexId() const
double mass() const
const HepVector & w() const
virtual bool isVertexValid()=0
virtual double * PrimaryVertex()=0
void savetrack(vector< int >, vector< int >, EvtRecTrackIterator, EvtRecTrackIterator, EvtRecTrackIterator, EvtRecTrackIterator, EvtRecDTag *)
void updateKsLambdaInfo(CDDecayList::iterator, double, int, EvtRecDTag *, vector< int >, IVertexDbSvc *, bool)
void pidtag(vector< int >, vector< int >, vector< int >, CDChargedKaonList &, CDChargedPionList &, CDProtonList &, EvtRecDTag *)
void saveLcInfo(CDDecayList::iterator, double, int, EvtRecDTag *)
vector< string > getlist(string &filename)
void setebeam(double ebeam)
void setbeta(Hep3Vector beta)
void setpidtype(int type)
void setpidtype(int type)
virtual int size() const
ChosenChargeList< Charged, CandidateClass > & plus() const
ChosenChargeList< Charged, CandidateClass > & minus() const
virtual iterator particle_begin()
Definition DecayList.cc:169
virtual iterator particle_end()
Definition DecayList.cc:176
HepLorentzVector vfitref(string channel, vector< int > kaonid, vector< int > pionid, HepPoint3D vx, EvtRecTrackIterator charged_begin)
Definition utility.cxx:59
vector< double > SecondaryVFit_Lambdaref(EvtRecVeeVertex *lambda, IVertexDbSvc *vtxsvc)
Definition utility.cxx:297
vector< double > SecondaryVFit_Lambda(EvtRecVeeVertex *lambda, IVertexDbSvc *vtxsvc)
Definition utility.cxx:640
vector< double > SecondaryVFitref(EvtRecVeeVertex *ks, IVertexDbSvc *vtxsvc)
Definition utility.cxx:199
vector< double > UpdatedKsIfo(EvtRecVeeVertex *ks, IVertexDbSvc *vtxsvc, bool m_useVFrefine)
Definition utility.cxx:752
vector< double > UpdatedLambdaIfo(EvtRecVeeVertex *lambda, IVertexDbSvc *vtxsvc, bool m_useVFrefine)
Definition utility.cxx:882
HepLorentzVector vfit(string channel, vector< int > kaonid, vector< int > pionid, HepPoint3D vx, EvtRecTrackIterator charged_begin)
Definition utility.cxx:406
vector< double > SecondaryVFit(EvtRecVeeVertex *ks, IVertexDbSvc *vtxsvc)
Definition utility.cxx:540
_EXTERN_ std::string EvtRecEvent
Definition EventModel.h:116
_EXTERN_ std::string EvtRecDTagCol
Definition EventModel.h:122
_EXTERN_ std::string EvtRecTrackCol
Definition EventModel.h:117
Definition Event.h:21
float charge
double double double * p4
Definition qcdloop1.h:77