DSemilepAlg Class Reference

#include <DSemilepAlg.h>

List of all members.

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)

Private Attributes

ISimplePIDSvcm_simplePIDSvc
std::string m_pdt
NTuple::Tuple * m_tuple0
NTuple::Item< double > m_mBC
NTuple::Item< double > m_deltaE
NTuple::Item< double > m_U
NTuple::Item< double > m_mode
NTuple::Item< double > m_MM2
NTuple::Item< double > m_q2


Detailed Description

Definition at line 12 of file DSemilepAlg.h.


Constructor & Destructor Documentation

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

Definition at line 56 of file DSemilepAlg.cxx.

00056                                                                         : Algorithm(name, pSvcLocator){
00057 }


Member Function Documentation

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

Definition at line 342 of file DSemilepAlg.cxx.

References DstMdcKalTrack::electron, DstMdcKalTrack::kaon, me, mkaon, DstMdcKalTrack::px(), DstMdcKalTrack::py(), DstMdcKalTrack::pz(), DstMdcKalTrack::setPidType(), and tagDP3().

Referenced by execute().

00342                                                                                                                                {
00343 
00344         Etrack->setPidType(RecMdcKalTrack::electron);
00345         Ktrack->setPidType(RecMdcKalTrack::kaon);
00346 
00347         Hep3Vector P3_tag = tagDP3(sditer);
00348 
00349         Hep3Vector P3_E(Etrack->px(), Etrack->py(),Etrack->pz());
00350         Hep3Vector P3_K(Ktrack->px(), Ktrack->py(),Ktrack->pz());
00351 
00352         HepLorentzVector P4_E(P3_E, sqrt( P3_E.mag2() + me * me));
00353         HepLorentzVector P4_K(P3_K, sqrt( P3_K.mag2() + mkaon * mkaon));
00354 
00355         // Boost
00356         P4_E.boost(-0.011,0,0);
00357         P4_K.boost(-0.011,0,0);
00358 
00359         double e_miss = (*sditer)->beamE() - P4_E.e() - P4_K.e();
00360         Hep3Vector P3_miss = -P3_tag - P4_E.vect() - P4_K.vect();
00361 
00362         U = e_miss - P3_miss.mag();
00363         MM2 = U * (e_miss + P3_miss.mag());
00364 
00365         HepLorentzVector P4_W(P3_E+P3_miss*fabs(e_miss/P3_miss.mag()),e_miss+P4_E.e());
00366   q2 = P4_W.m2();
00367 
00368 }

StatusCode DSemilepAlg::execute (  ) 

Definition at line 100 of file DSemilepAlg.cxx.

References calU(), DstMdcKalTrack::charge(), DTagTool::clear(), DTagTool::cosmicandleptonVeto(), eventNo, Bes_Common::FATAL, DTagTool::findSTag(), genRecEmupikp::i, Bes_Common::INFO, DTagTool::isDTagListEmpty(), ISimplePIDSvc::iselectron(), isGoodTrack(), ISimplePIDSvc::iskaon(), IVertexDbSvc::isVertexValid(), EvtRecDTag::kD0toKPi, EvtRecDTag::kD0toKPiPi0, EvtRecDTag::kD0toKPiPiPi, m_deltaE, m_mBC, m_MM2, m_mode, m_q2, m_simplePIDSvc, m_tuple0, m_U, DTagTool::modes_begin(), DTagTool::modes_end(), msgSvc(), ISimplePIDSvc::preparePID(), IVertexDbSvc::PrimaryVertex(), runNo, and DTagTool::stag().

00100                                 {
00101 
00102         MsgStream log(msgSvc(), name());
00103         log << MSG::INFO << "in execute()" << endreq;
00104 
00105         SmartDataPtr<Event::EventHeader> eventHeader(eventSvc(),"/Event/EventHeader");
00106         int runNo=eventHeader->runNumber();
00107         int eventNo=eventHeader->eventNumber();
00108 
00109         //
00110         //if(eventNo % 1000 == 0)
00111         //cout << "Event: "<< eventNo << endl;
00112 
00113         SmartDataPtr<EvtRecEvent> evtRecEvent(eventSvc(), "/Event/EvtRec/EvtRecEvent");
00114         if ( ! evtRecEvent ) {
00115                 log << MSG::FATAL << "Could not find EvtRecEvent" << endreq;
00116                 return StatusCode::FAILURE;
00117         }
00118 
00119         SmartDataPtr<EvtRecTrackCol> evtRecTrackCol( eventSvc(), "/Event/EvtRec/EvtRecTrackCol");
00120         if ( ! evtRecTrackCol ) {
00121                 log << MSG::FATAL << "Could not find EvtRecTrackCol" << endreq;
00122                 return StatusCode::FAILURE;
00123         }
00124 
00126         SmartDataPtr<EvtRecVeeVertexCol> evtRecVeeVertexCol(eventSvc(), "/Event/EvtRec/EvtRecVeeVertexCol");
00127         if ( ! evtRecVeeVertexCol ) {
00128                 log << MSG::FATAL << "Could not find EvtRecVeeVertexCol" << endreq;
00129                 return StatusCode::FAILURE;
00130         }
00131 
00133         SmartDataPtr<EvtRecPi0Col> recPi0Col(eventSvc(), "/Event/EvtRec/EvtRecPi0Col");
00134         if ( ! recPi0Col ) {
00135                 log << MSG::FATAL << "Could not find EvtRecPi0Col" << endreq;
00136                 return StatusCode::FAILURE;
00137 
00138         }
00139 
00140         //get primary vertex from db
00141         Hep3Vector xorigin(0,0,0);
00142         IVertexDbSvc*  vtxsvc;
00143         Gaudi::svcLocator()->service("VertexDbSvc", vtxsvc);
00144         if (vtxsvc->isVertexValid()) {
00145                 //vertex[0] = vx; vertex[1]= vy; vertex[2] = vz;
00146                 double* vertex = vtxsvc->PrimaryVertex();
00147                 xorigin.setX(vertex[0]);
00148                 xorigin.setY(vertex[1]);
00149                 xorigin.setZ(vertex[2]);
00150         }
00151 
00152         // DTAGTOOL
00153         DTagTool dtagTool;
00154 
00155 
00156         if( dtagTool.isDTagListEmpty() ){
00157                 // cout<<"no D candidates found"<<endl;
00158                 return StatusCode::SUCCESS;
00159         }
00160         //else{
00161         //   cout<<"found D candidates found"<<endl;
00162         //}
00163 
00164         DTagToolIterator iter_begin = dtagTool.modes_begin();
00165         DTagToolIterator iter_end = dtagTool.modes_end();
00166 
00167         //find semileptonic decay candidate
00168         vector<DTagToolIterator> vsditer;
00169 
00170         // Using modes 0,1 and 3 (D0->KPi, D0->KPiPi0, D0->KPiPiPi ) fill dtagtool
00171         // Combining three modes to look at the signal side of all of them
00172         if(dtagTool.findSTag( EvtRecDTag::kD0toKPi,1) && dtagTool.cosmicandleptonVeto())
00173                 vsditer.push_back(dtagTool.stag());
00174         if(dtagTool.findSTag( EvtRecDTag::kD0toKPi,-1) && dtagTool.cosmicandleptonVeto())
00175                 vsditer.push_back(dtagTool.stag());
00176         if(dtagTool.findSTag( EvtRecDTag::kD0toKPiPi0,1))
00177                 vsditer.push_back(dtagTool.stag());
00178         if(dtagTool.findSTag( EvtRecDTag::kD0toKPiPi0,-1))
00179                 vsditer.push_back(dtagTool.stag());
00180         if(dtagTool.findSTag( EvtRecDTag::kD0toKPiPiPi,1) )
00181                 vsditer.push_back(dtagTool.stag());
00182         if(dtagTool.findSTag( EvtRecDTag::kD0toKPiPiPi,-1) )
00183                 vsditer.push_back(dtagTool.stag());
00184 
00185 
00186         typedef vector<DTagToolIterator>::size_type vec_sz;
00187 
00188         //loop over single tag to reconstruct signal side
00189         for(vec_sz i = 0 ; i < vsditer.size() ; i++){
00190 
00191                 //fill single tags only before selection
00192                 m_deltaE = (*vsditer[i])->deltaE();
00193                 m_mode = (*vsditer[i])->decayMode();
00194                 m_mBC = (*vsditer[i])->mBC();
00195 
00196                 //Get the DTagToolIterator of the tag for easier usage in the code
00197                 DTagToolIterator sditer = vsditer[i];
00198 
00199                 // Check signal side for good tracks and charge of the tracks
00200                 SmartRefVector<EvtRecTrack> othertracks = (*sditer)->otherTracks();
00201                 vector<int> iGood;      int tcharge=0;
00202 
00203                 for(int i = 0 ; i < othertracks.size() ; i++){
00204                         if(isGoodTrack(othertracks[i],xorigin)){
00205                                 iGood.push_back(i);
00206                                 RecMdcKalTrack *mdcKalTrk = othertracks[i]->mdcKalTrack();
00207                                 tcharge += mdcKalTrk->charge();
00208                         }
00209                 }
00210 
00211                 // Keeping only events with 2 good signal tracks with zero total charge
00212                 if(iGood.size() != 2 || tcharge != 0)
00213                         continue;
00214 
00215                 // Use SimplePIDSvc package to identify the tracks
00216                 m_simplePIDSvc->preparePID(othertracks[iGood[0]]);
00217                 bool FtrkElectron = m_simplePIDSvc->iselectron(); 
00218                 bool FtrkKaon           = m_simplePIDSvc->iskaon();
00219 
00220                 m_simplePIDSvc->preparePID(othertracks[iGood[1]]);
00221                 bool StrkElectron = m_simplePIDSvc->iselectron();
00222                 bool StrkKaon           = m_simplePIDSvc->iskaon();
00223 
00224                 //
00225                 // As at the signal side tracks are not listed in a particular order, there are two senarios
00226                 //
00227                 // Senario 1: Track 0 is electron, track 1 is kaon
00228                 if(FtrkElectron && StrkKaon) {
00229 
00230                         RecMdcKalTrack* ftrk = othertracks[iGood[0]]->mdcKalTrack();
00231                         RecMdcKalTrack* strk = othertracks[iGood[1]]->mdcKalTrack();
00232 
00233                         SmartRefVector<EvtRecTrack> tracks = (*sditer)->tracks();   
00234                         RecMdcKalTrack* tagsidektrk = tracks[0]->mdcKalTrack();
00235 
00236                         //Requiring electron having the same charge as the tag side kaon
00237                         if(ftrk->charge() * tagsidektrk->charge() > 0){
00238                                 double U_1 = 0;
00239                                 double MM2_1 = 0;
00240                                 double q2_1 = 0;
00241         
00242                                 //Calculate U and MM2 using a function
00243                                 calU(sditer,strk,ftrk,U_1,MM2_1,q2_1);
00244 
00245                                 m_U = U_1;
00246                                 m_MM2 = MM2_1;
00247                                 m_q2 = q2_1;
00248 
00249                                 m_tuple0->write();
00250                         }
00251 
00252 
00253                 }//end of senario 1 
00254 
00255                 //Senario 2: Track 0 is kaon, track 1 is electon
00256                 if(StrkElectron && FtrkKaon){
00257 
00258                         RecMdcKalTrack* ftrk = othertracks[iGood[0]]->mdcKalTrack();
00259                         RecMdcKalTrack* strk = othertracks[iGood[1]]->mdcKalTrack();
00260 
00261                         SmartRefVector<EvtRecTrack> tracks = (*sditer)->tracks();  
00262 
00263                         RecMdcKalTrack* tagsidektrk = tracks[0]->mdcKalTrack();
00264 
00265                         //Requiring electron having the same charge as the tag side kaon
00266                         if(strk->charge() * tagsidektrk->charge() > 0){
00267 
00268                                 double U_1 = 0;
00269                                 double MM2_1 = 0;
00270                                 double q2_1 = 0;
00271         
00272                                 //Calculate U and MM2 using a function
00273                                 calU(sditer,strk,ftrk,U_1,MM2_1,q2_1);
00274 
00275                                 m_U = U_1;
00276                                 m_MM2 = MM2_1;
00277                                 m_q2 = q2_1;
00278 
00279                                 m_tuple0->write();
00280                         }
00281                 }//end of senario 2
00282 
00283         }
00284 
00285         //Clear DTagTool
00286         dtagTool.clear();
00287 }

StatusCode DSemilepAlg::finalize (  ) 

Definition at line 292 of file DSemilepAlg.cxx.

References Bes_Common::INFO, and msgSvc().

00292                                  {
00293         MsgStream log(msgSvc(), name());
00294         log << MSG::INFO << "in finalize()" << endmsg;
00295 
00296         return StatusCode::SUCCESS;
00297 }

StatusCode DSemilepAlg::initialize (  ) 

Definition at line 62 of file DSemilepAlg.cxx.

References calibUtil::ERROR, Bes_Common::FATAL, Bes_Common::INFO, m_deltaE, m_mBC, m_MM2, m_mode, m_q2, m_simplePIDSvc, m_tuple0, m_U, msgSvc(), and ntupleSvc().

00062                                   {
00063 
00064         MsgStream log(msgSvc(), name());
00065         log << MSG::INFO << "in initialize()" << endmsg;
00066         StatusCode status;
00067 
00068         //NTUPLE
00069         NTuplePtr nt0(ntupleSvc(), "FILE1/dsemilep");
00070         if ( nt0 ) m_tuple0 = nt0;
00071         else {
00072                 m_tuple0 = ntupleSvc()->book ("FILE1/dsemilep", CLID_ColumnWiseTuple, "track N-Tuple example");
00073                 if ( m_tuple0 )    {
00074                         status = m_tuple0->addItem ("U", m_U);
00075                         status = m_tuple0->addItem ("MM2", m_MM2);
00076                         status = m_tuple0->addItem ("mBC", m_mBC);
00077                         status = m_tuple0->addItem ("q2", m_q2);
00078                         status = m_tuple0->addItem ("deltaE", m_deltaE);
00079                         status = m_tuple0->addItem ("mode", m_mode);
00080                 }
00081                 else    {
00082                         log << MSG::ERROR << "    Cannot book N-tuple:" << long(m_tuple0) << endmsg;
00083                         return StatusCode::FAILURE;
00084                 }
00085         }
00086 
00087         StatusCode sc = service("SimplePIDSvc", m_simplePIDSvc);
00088         if ( sc.isFailure())    {
00089                 log << MSG::FATAL << "Could not load SimplePIDSvc!" << endreq;
00090                 return sc;
00091         }
00092 
00093         log << MSG::INFO << "successfully return from initialize()" <<endmsg;
00094         return StatusCode::SUCCESS;
00095 }

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

Definition at line 305 of file DSemilepAlg.cxx.

References VFHelix::a(), cos(), RecMdcKalTrack::getZError(), RecMdcKalTrack::getZHelix(), EvtRecTrack::isMdcKalTrackValid(), EvtRecTrack::mdcKalTrack(), DstMdcKalTrack::pion, VFHelix::pivot(), DstMdcKalTrack::setPidType(), DstMdcKalTrack::theta(), and vec.

Referenced by execute().

00305                                                                  {
00306         if(!(trk->isMdcKalTrackValid())) return false;
00307 
00308         RecMdcKalTrack *mdcKalTrk = trk->mdcKalTrack();
00309         mdcKalTrk->setPidType(RecMdcKalTrack::pion);
00310         HepVector    a  = mdcKalTrk->getZHelix();
00311         HepSymMatrix Ea = mdcKalTrk->getZError();
00312         HepPoint3D pivot(0.,0.,0.);
00313         HepPoint3D IP(xorigin[0],xorigin[1],xorigin[2]);
00314         VFHelix helixp(pivot,a,Ea);
00315         helixp.pivot(IP);
00316         HepVector vec    = helixp.a();
00317         double    vrl    = vec[0];
00318         double    vzl    = vec[3];
00319         double costheta  = cos(mdcKalTrk->theta());
00320 
00321         //Event selection criteria
00322         if(fabs(vrl) < 1 && fabs(vzl) < 10 && fabs(costheta) < 0.93)
00323                 return true;
00324         return false;
00325 }

Hep3Vector DSemilepAlg::tagDP3 ( DTagToolIterator  iter_dtag  ) 

Definition at line 329 of file DSemilepAlg.cxx.

Referenced by calU().

00329                                                         {
00330 
00331         SmartRefVector<EvtRecTrack> tracks=(*iter_dtag)->tracks();
00332         SmartRefVector<EvtRecTrack> showers=(*iter_dtag)->showers();
00333 
00334         HepLorentzVector p4=(*iter_dtag)->p4();
00335         p4.boost(-0.011,0,0);
00336         Hep3Vector p3=p4.v();
00337         return p3;
00338 }


Member Data Documentation

NTuple::Item<double> DSemilepAlg::m_deltaE [private]

Definition at line 33 of file DSemilepAlg.h.

Referenced by execute(), and initialize().

NTuple::Item<double> DSemilepAlg::m_mBC [private]

Definition at line 32 of file DSemilepAlg.h.

Referenced by execute(), and initialize().

NTuple::Item<double> DSemilepAlg::m_MM2 [private]

Definition at line 36 of file DSemilepAlg.h.

Referenced by execute(), and initialize().

NTuple::Item<double> DSemilepAlg::m_mode [private]

Definition at line 35 of file DSemilepAlg.h.

Referenced by execute(), and initialize().

std::string DSemilepAlg::m_pdt [private]

Definition at line 27 of file DSemilepAlg.h.

NTuple::Item<double> DSemilepAlg::m_q2 [private]

Definition at line 37 of file DSemilepAlg.h.

Referenced by execute(), and initialize().

ISimplePIDSvc* DSemilepAlg::m_simplePIDSvc [private]

Definition at line 26 of file DSemilepAlg.h.

Referenced by execute(), and initialize().

NTuple::Tuple* DSemilepAlg::m_tuple0 [private]

Definition at line 31 of file DSemilepAlg.h.

Referenced by execute(), and initialize().

NTuple::Item<double> DSemilepAlg::m_U [private]

Definition at line 34 of file DSemilepAlg.h.

Referenced by execute(), and initialize().


Generated on Tue Nov 29 23:18:26 2016 for BOSS_7.0.2 by  doxygen 1.4.7