BOSS 7.0.1
BESIII Offline Software System
Loading...
Searching...
No Matches
DSemilepAlg Class Reference

#include <DSemilepAlg.h>

+ Inheritance diagram for DSemilepAlg:

Public Member Functions

 DSemilepAlg (const std::string &name, ISvcLocator *pSvcLocator)
 
StatusCode initialize ()
 
StatusCode execute ()
 
StatusCode finalize ()
 
bool isGoodTrack (EvtRecTrack *trk, Hep3Vector xorigin)
 
void calU (DTagToolIterator sditer, RecMdcKalTrack *Etrack, RecMdcKalTrack *Ktrack, double &U, double &MM2, double &q2)
 
Hep3Vector tagDP3 (DTagToolIterator iter_dtag)
 
 DSemilepAlg (const std::string &name, ISvcLocator *pSvcLocator)
 
StatusCode initialize ()
 
StatusCode execute ()
 
StatusCode finalize ()
 
bool isGoodTrack (EvtRecTrack *trk, Hep3Vector xorigin)
 
void calU (DTagToolIterator sditer, RecMdcKalTrack *Etrack, RecMdcKalTrack *Ktrack, double &U, double &MM2, double &q2)
 
Hep3Vector tagDP3 (DTagToolIterator iter_dtag)
 

Detailed Description

Constructor & Destructor Documentation

◆ DSemilepAlg() [1/2]

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

Definition at line 56 of file DSemilepAlg.cxx.

56 : Algorithm(name, pSvcLocator){
57}

◆ DSemilepAlg() [2/2]

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

Member Function Documentation

◆ calU() [1/2]

void DSemilepAlg::calU ( DTagToolIterator  sditer,
RecMdcKalTrack Etrack,
RecMdcKalTrack Ktrack,
double &  U,
double &  MM2,
double &  q2 
)

Definition at line 342 of file DSemilepAlg.cxx.

342 {
343
346
347 Hep3Vector P3_tag = tagDP3(sditer);
348
349 Hep3Vector P3_E(Etrack->px(), Etrack->py(),Etrack->pz());
350 Hep3Vector P3_K(Ktrack->px(), Ktrack->py(),Ktrack->pz());
351
352 HepLorentzVector P4_E(P3_E, sqrt( P3_E.mag2() + me * me));
353 HepLorentzVector P4_K(P3_K, sqrt( P3_K.mag2() + mkaon * mkaon));
354
355 // Boost
356 P4_E.boost(-0.011,0,0);
357 P4_K.boost(-0.011,0,0);
358
359 double e_miss = (*sditer)->beamE() - P4_E.e() - P4_K.e();
360 Hep3Vector P3_miss = -P3_tag - P4_E.vect() - P4_K.vect();
361
362 U = e_miss - P3_miss.mag();
363 MM2 = U * (e_miss + P3_miss.mag());
364
365 HepLorentzVector P4_W(P3_E+P3_miss*fabs(e_miss/P3_miss.mag()),e_miss+P4_E.e());
366 q2 = P4_W.m2();
367
368}
const double mkaon
Definition: DSemilepAlg.cxx:52
const double me
Definition: PipiJpsi.cxx:48
Hep3Vector tagDP3(DTagToolIterator iter_dtag)

Referenced by execute().

◆ calU() [2/2]

void DSemilepAlg::calU ( DTagToolIterator  sditer,
RecMdcKalTrack Etrack,
RecMdcKalTrack Ktrack,
double &  U,
double &  MM2,
double &  q2 
)

◆ execute() [1/2]

StatusCode DSemilepAlg::execute ( )

Accessing Ks list

Accessing pi0 list

Definition at line 100 of file DSemilepAlg.cxx.

100 {
101
102 MsgStream log(msgSvc(), name());
103 log << MSG::INFO << "in execute()" << endreq;
104
105 SmartDataPtr<Event::EventHeader> eventHeader(eventSvc(),"/Event/EventHeader");
106 int runNo=eventHeader->runNumber();
107 int eventNo=eventHeader->eventNumber();
108
109 //
110 //if(eventNo % 1000 == 0)
111 //cout << "Event: "<< eventNo << endl;
112
113 SmartDataPtr<EvtRecEvent> evtRecEvent(eventSvc(), "/Event/EvtRec/EvtRecEvent");
114 if ( ! evtRecEvent ) {
115 log << MSG::FATAL << "Could not find EvtRecEvent" << endreq;
116 return StatusCode::FAILURE;
117 }
118
119 SmartDataPtr<EvtRecTrackCol> evtRecTrackCol( eventSvc(), "/Event/EvtRec/EvtRecTrackCol");
120 if ( ! evtRecTrackCol ) {
121 log << MSG::FATAL << "Could not find EvtRecTrackCol" << endreq;
122 return StatusCode::FAILURE;
123 }
124
125 /// Accessing Ks list
126 SmartDataPtr<EvtRecVeeVertexCol> evtRecVeeVertexCol(eventSvc(), "/Event/EvtRec/EvtRecVeeVertexCol");
127 if ( ! evtRecVeeVertexCol ) {
128 log << MSG::FATAL << "Could not find EvtRecVeeVertexCol" << endreq;
129 return StatusCode::FAILURE;
130 }
131
132 /// Accessing pi0 list
133 SmartDataPtr<EvtRecPi0Col> recPi0Col(eventSvc(), "/Event/EvtRec/EvtRecPi0Col");
134 if ( ! recPi0Col ) {
135 log << MSG::FATAL << "Could not find EvtRecPi0Col" << endreq;
136 return StatusCode::FAILURE;
137
138 }
139
140 //get primary vertex from db
141 Hep3Vector xorigin(0,0,0);
142 IVertexDbSvc* vtxsvc;
143 Gaudi::svcLocator()->service("VertexDbSvc", vtxsvc);
144 if (vtxsvc->isVertexValid()) {
145 //vertex[0] = vx; vertex[1]= vy; vertex[2] = vz;
146 double* vertex = vtxsvc->PrimaryVertex();
147 xorigin.setX(vertex[0]);
148 xorigin.setY(vertex[1]);
149 xorigin.setZ(vertex[2]);
150 }
151
152 // DTAGTOOL
153 DTagTool dtagTool;
154
155
156 if( dtagTool.isDTagListEmpty() ){
157 // cout<<"no D candidates found"<<endl;
158 return StatusCode::SUCCESS;
159 }
160 //else{
161 // cout<<"found D candidates found"<<endl;
162 //}
163
164 DTagToolIterator iter_begin = dtagTool.modes_begin();
165 DTagToolIterator iter_end = dtagTool.modes_end();
166
167 //find semileptonic decay candidate
168 vector<DTagToolIterator> vsditer;
169
170 // Using modes 0,1 and 3 (D0->KPi, D0->KPiPi0, D0->KPiPiPi ) fill dtagtool
171 // Combining three modes to look at the signal side of all of them
172 if(dtagTool.findSTag( EvtRecDTag::kD0toKPi,1) && dtagTool.cosmicandleptonVeto())
173 vsditer.push_back(dtagTool.stag());
174 if(dtagTool.findSTag( EvtRecDTag::kD0toKPi,-1) && dtagTool.cosmicandleptonVeto())
175 vsditer.push_back(dtagTool.stag());
176 if(dtagTool.findSTag( EvtRecDTag::kD0toKPiPi0,1))
177 vsditer.push_back(dtagTool.stag());
178 if(dtagTool.findSTag( EvtRecDTag::kD0toKPiPi0,-1))
179 vsditer.push_back(dtagTool.stag());
180 if(dtagTool.findSTag( EvtRecDTag::kD0toKPiPiPi,1) )
181 vsditer.push_back(dtagTool.stag());
182 if(dtagTool.findSTag( EvtRecDTag::kD0toKPiPiPi,-1) )
183 vsditer.push_back(dtagTool.stag());
184
185
186 typedef vector<DTagToolIterator>::size_type vec_sz;
187
188 //loop over single tag to reconstruct signal side
189 for(vec_sz i = 0 ; i < vsditer.size() ; i++){
190
191 //fill single tags only before selection
192 m_deltaE = (*vsditer[i])->deltaE();
193 m_mode = (*vsditer[i])->decayMode();
194 m_mBC = (*vsditer[i])->mBC();
195
196 //Get the DTagToolIterator of the tag for easier usage in the code
197 DTagToolIterator sditer = vsditer[i];
198
199 // Check signal side for good tracks and charge of the tracks
200 SmartRefVector<EvtRecTrack> othertracks = (*sditer)->otherTracks();
201 vector<int> iGood; int tcharge=0;
202
203 for(int i = 0 ; i < othertracks.size() ; i++){
204 if(isGoodTrack(othertracks[i],xorigin)){
205 iGood.push_back(i);
206 RecMdcKalTrack *mdcKalTrk = othertracks[i]->mdcKalTrack();
207 tcharge += mdcKalTrk->charge();
208 }
209 }
210
211 // Keeping only events with 2 good signal tracks with zero total charge
212 if(iGood.size() != 2 || tcharge != 0)
213 continue;
214
215 // Use SimplePIDSvc package to identify the tracks
216 m_simplePIDSvc->preparePID(othertracks[iGood[0]]);
217 bool FtrkElectron = m_simplePIDSvc->iselectron();
218 bool FtrkKaon = m_simplePIDSvc->iskaon();
219
220 m_simplePIDSvc->preparePID(othertracks[iGood[1]]);
221 bool StrkElectron = m_simplePIDSvc->iselectron();
222 bool StrkKaon = m_simplePIDSvc->iskaon();
223
224 //
225 // As at the signal side tracks are not listed in a particular order, there are two senarios
226 //
227 // Senario 1: Track 0 is electron, track 1 is kaon
228 if(FtrkElectron && StrkKaon) {
229
230 RecMdcKalTrack* ftrk = othertracks[iGood[0]]->mdcKalTrack();
231 RecMdcKalTrack* strk = othertracks[iGood[1]]->mdcKalTrack();
232
233 SmartRefVector<EvtRecTrack> tracks = (*sditer)->tracks();
234 RecMdcKalTrack* tagsidektrk = tracks[0]->mdcKalTrack();
235
236 //Requiring electron having the same charge as the tag side kaon
237 if(ftrk->charge() * tagsidektrk->charge() > 0){
238 double U_1 = 0;
239 double MM2_1 = 0;
240 double q2_1 = 0;
241
242 //Calculate U and MM2 using a function
243 calU(sditer,strk,ftrk,U_1,MM2_1,q2_1);
244
245 m_U = U_1;
246 m_MM2 = MM2_1;
247 m_q2 = q2_1;
248
249 m_tuple0->write();
250 }
251
252
253 }//end of senario 1
254
255 //Senario 2: Track 0 is kaon, track 1 is electon
256 if(StrkElectron && FtrkKaon){
257
258 RecMdcKalTrack* ftrk = othertracks[iGood[0]]->mdcKalTrack();
259 RecMdcKalTrack* strk = othertracks[iGood[1]]->mdcKalTrack();
260
261 SmartRefVector<EvtRecTrack> tracks = (*sditer)->tracks();
262
263 RecMdcKalTrack* tagsidektrk = tracks[0]->mdcKalTrack();
264
265 //Requiring electron having the same charge as the tag side kaon
266 if(strk->charge() * tagsidektrk->charge() > 0){
267
268 double U_1 = 0;
269 double MM2_1 = 0;
270 double q2_1 = 0;
271
272 //Calculate U and MM2 using a function
273 calU(sditer,strk,ftrk,U_1,MM2_1,q2_1);
274
275 m_U = U_1;
276 m_MM2 = MM2_1;
277 m_q2 = q2_1;
278
279 m_tuple0->write();
280 }
281 }//end of senario 2
282
283 }
284
285 //Clear DTagTool
286 dtagTool.clear();
287}
EvtRecDTagCol::iterator DTagToolIterator
int runNo
Definition: DQA_TO_DB.cxx:12
int eventNo
bool isGoodTrack(EvtRecTrack *trk, Hep3Vector xorigin)
void calU(DTagToolIterator sditer, RecMdcKalTrack *Etrack, RecMdcKalTrack *Ktrack, double &U, double &MM2, double &q2)
void clear()
Definition: DTagTool.cxx:131
bool findSTag(EvtRecDTag::DecayMode mode, int tagcharm)
Definition: DTagTool.cxx:217
bool cosmicandleptonVeto(bool emc=true)
Definition: DTagTool.cxx:1134
virtual void preparePID(EvtRecTrack *track)=0
virtual bool iskaon()=0
virtual bool iselectron(bool emc=false)=0
virtual bool isVertexValid()=0
virtual double * PrimaryVertex()=0

◆ execute() [2/2]

StatusCode DSemilepAlg::execute ( )

◆ finalize() [1/2]

StatusCode DSemilepAlg::finalize ( )

Definition at line 292 of file DSemilepAlg.cxx.

292 {
293 MsgStream log(msgSvc(), name());
294 log << MSG::INFO << "in finalize()" << endmsg;
295
296 return StatusCode::SUCCESS;
297}

◆ finalize() [2/2]

StatusCode DSemilepAlg::finalize ( )

◆ initialize() [1/2]

StatusCode DSemilepAlg::initialize ( )

Definition at line 62 of file DSemilepAlg.cxx.

62 {
63
64 MsgStream log(msgSvc(), name());
65 log << MSG::INFO << "in initialize()" << endmsg;
66 StatusCode status;
67
68 //NTUPLE
69 NTuplePtr nt0(ntupleSvc(), "FILE1/dsemilep");
70 if ( nt0 ) m_tuple0 = nt0;
71 else {
72 m_tuple0 = ntupleSvc()->book ("FILE1/dsemilep", CLID_ColumnWiseTuple, "track N-Tuple example");
73 if ( m_tuple0 ) {
74 status = m_tuple0->addItem ("U", m_U);
75 status = m_tuple0->addItem ("MM2", m_MM2);
76 status = m_tuple0->addItem ("mBC", m_mBC);
77 status = m_tuple0->addItem ("q2", m_q2);
78 status = m_tuple0->addItem ("deltaE", m_deltaE);
79 status = m_tuple0->addItem ("mode", m_mode);
80 }
81 else {
82 log << MSG::ERROR << " Cannot book N-tuple:" << long(m_tuple0) << endmsg;
83 return StatusCode::FAILURE;
84 }
85 }
86
87 StatusCode sc = service("SimplePIDSvc", m_simplePIDSvc);
88 if ( sc.isFailure()) {
89 log << MSG::FATAL << "Could not load SimplePIDSvc!" << endreq;
90 return sc;
91 }
92
93 log << MSG::INFO << "successfully return from initialize()" <<endmsg;
94 return StatusCode::SUCCESS;
95}

◆ initialize() [2/2]

StatusCode DSemilepAlg::initialize ( )

◆ isGoodTrack() [1/2]

bool DSemilepAlg::isGoodTrack ( EvtRecTrack trk,
Hep3Vector  xorigin 
)

Definition at line 305 of file DSemilepAlg.cxx.

305 {
306 if(!(trk->isMdcKalTrackValid())) return false;
307
308 RecMdcKalTrack *mdcKalTrk = trk->mdcKalTrack();
310 HepVector a = mdcKalTrk->getZHelix();
311 HepSymMatrix Ea = mdcKalTrk->getZError();
312 HepPoint3D pivot(0.,0.,0.);
313 HepPoint3D IP(xorigin[0],xorigin[1],xorigin[2]);
314 VFHelix helixp(pivot,a,Ea);
315 helixp.pivot(IP);
316 HepVector vec = helixp.a();
317 double vrl = vec[0];
318 double vzl = vec[3];
319 double costheta = cos(mdcKalTrk->theta());
320
321 //Event selection criteria
322 if(fabs(vrl) < 1 && fabs(vzl) < 10 && fabs(costheta) < 0.93)
323 return true;
324 return false;
325}
double cos(const BesAngle a)
dble_vec_t vec[12]
Definition: ranlxd.c:372

Referenced by execute().

◆ isGoodTrack() [2/2]

bool DSemilepAlg::isGoodTrack ( EvtRecTrack trk,
Hep3Vector  xorigin 
)

◆ tagDP3() [1/2]

Hep3Vector DSemilepAlg::tagDP3 ( DTagToolIterator  iter_dtag)

Definition at line 329 of file DSemilepAlg.cxx.

329 {
330
331 SmartRefVector<EvtRecTrack> tracks=(*iter_dtag)->tracks();
332 SmartRefVector<EvtRecTrack> showers=(*iter_dtag)->showers();
333
334 HepLorentzVector p4=(*iter_dtag)->p4();
335 p4.boost(-0.011,0,0);
336 Hep3Vector p3=p4.v();
337 return p3;
338}

Referenced by calU().

◆ tagDP3() [2/2]

Hep3Vector DSemilepAlg::tagDP3 ( DTagToolIterator  iter_dtag)

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