/home/bes3soft/bes3soft/Boss/7.0.2/dist/7.0.2/LumTauAlg/LumTauAlg-00-00-08/src/LumTau.cxx

Go to the documentation of this file.
00001 #include "GaudiKernel/MsgStream.h"
00002 #include "GaudiKernel/AlgFactory.h"
00003 #include "GaudiKernel/ISvcLocator.h"
00004 #include "GaudiKernel/SmartDataPtr.h"
00005 #include "GaudiKernel/IDataProviderSvc.h"
00006 #include "GaudiKernel/PropertyMgr.h"
00007 #include "VertexFit/IVertexDbSvc.h"
00008 #include "GaudiKernel/Bootstrap.h"
00009 #include "GaudiKernel/ISvcLocator.h"
00010 
00011 #include "EventModel/EventModel.h"
00012 #include "EventModel/Event.h"
00013 #include "EventModel/EventHeader.h"
00014 #include "McTruth/McParticle.h"
00015 
00016 #include "EvtRecEvent/EvtRecEvent.h"
00017 #include "EvtRecEvent/EvtRecTrack.h"
00018 #include "DstEvent/TofHitStatus.h"
00019 #include "EvTimeEvent/RecEsTime.h"
00020 #include "EventModel/EventHeader.h"
00021 #include "TMath.h"
00022 #include "GaudiKernel/INTupleSvc.h"
00023 #include "GaudiKernel/NTuple.h"
00024 #include "GaudiKernel/Bootstrap.h"
00025 #include "GaudiKernel/IHistogramSvc.h"
00026 #include "CLHEP/Vector/ThreeVector.h"
00027 #include "CLHEP/Vector/LorentzVector.h"
00028 #include "CLHEP/Vector/TwoVector.h"
00029 using CLHEP::Hep3Vector;
00030 using CLHEP::Hep2Vector;
00031 using CLHEP::HepLorentzVector;
00032 #include "CLHEP/Geometry/Point3D.h"
00033 #ifndef ENABLE_BACKWARDS_COMPATIBILITY
00034 typedef HepGeom::Point3D<double> HepPoint3D;
00035 #endif
00036 #include "VertexFit/KinematicFit.h"
00037 #include "VertexFit/KalmanKinematicFit.h"
00038 #include "VertexFit/VertexFit.h"
00039 #include "VertexFit/Helix.h"
00040 #include "VertexFit/SecondVertexFit.h"
00041 #include "ParticleID/ParticleID.h"
00042 #include "LumTauAlg/LumTau.h"
00043 #include <vector>
00044 typedef std::vector<int> Vint;
00045 typedef std::vector<HepLorentzVector> Vp4;
00046 const double ecms = 3.097;
00047 const double velc = 299.792458;
00048 const double xmass[5] = 
00049 {
00050         0.000511, 0.105658, 0.139570, 0.493677, 0.938272
00051 };
00052 const double pai=3.1415926;
00054 LumTau::LumTau(const std::string& name, ISvcLocator* pSvcLocator) :
00055         Algorithm(name, pSvcLocator) 
00056 {  
00057 }
00058 
00059 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 
00060 StatusCode LumTau::initialize()
00061 {
00062         MsgStream log(msgSvc(), name());
00063 
00064         log << MSG::INFO << "in initialize()" << endmsg;
00065 
00066         StatusCode status;
00067 
00068         NTuplePtr nt2(ntupleSvc(), "LumTau/event");
00069         if ( nt2 ) m_tuple2 = nt2;
00070         else 
00071         {
00072                 m_tuple2 = ntupleSvc()->book ("LumTau/event", CLID_ColumnWiseTuple, "Bhabha N-Tuple signal");
00073                 if ( m_tuple2 )
00074                 {
00075                         status = m_tuple2->addItem ("run",    m_run);
00076                         status = m_tuple2->addItem ("rec",    m_rec);
00077                         status = m_tuple2->addItem ("time",  m_time);  
00078                         status = m_tuple2->addItem ("etot",  m_etot);
00079                         status = m_tuple2->addItem ("e1",    m_e1);
00080                         status = m_tuple2->addItem ("e2",    m_e2);
00081                         status = m_tuple2->addItem ("costht1",    m_costht1);
00082                         status = m_tuple2->addItem ("costht2",    m_costht2);
00083                         status = m_tuple2->addItem ("dltphi",    m_dltphi);
00084                         status = m_tuple2->addItem ("dlttht",    m_dlttht);
00085                         status = m_tuple2->addItem ("phi1",    m_phi1);
00086                         status = m_tuple2->addItem ("phi2",    m_phi2);
00087                 }
00088                 else
00089                 {
00090                         log << MSG::ERROR << "Cannot book N-tuple2:"<<long(m_tuple2)<<endmsg;
00091                         return StatusCode::FAILURE;
00092                 }
00093         }
00094         return StatusCode::SUCCESS;
00095 }
00096 //*************************************************
00097 StatusCode LumTau::execute()
00098 {
00099         StatusCode sc=StatusCode::SUCCESS;
00100 
00101         MsgStream log(msgSvc(),name());
00102         log<<MSG::INFO<<"in execute()"<<endreq;
00103 
00104         SmartDataPtr<Event::EventHeader> eventHeader(eventSvc(),"/Event/EventHeader");
00105         SmartDataPtr<EvtRecEvent> evtRecEvent(eventSvc(), EventModel::EvtRec::EvtRecEvent);
00106 
00107         log<<MSG::DEBUG<<"ncharg, nneu, tottks = "<<evtRecEvent->totalCharged()<<" , "<<evtRecEvent->totalNeutral()<<" , "<<evtRecEvent->totalTracks()<<endreq;
00108         SmartDataPtr<EvtRecTrackCol> evtRecTrkCol(eventSvc(),EventModel::EvtRec::EvtRecTrackCol);
00109 
00110         log<<MSG::DEBUG <<"ncharg, nneu, tottks = "<<evtRecEvent->totalCharged()<<" , "<<evtRecEvent->totalNeutral()<<" , "<<evtRecEvent->totalTracks()<<endreq;
00111         SmartDataPtr<RecEsTimeCol> evTimeCol(eventSvc(),"/Event/Recon/RecEsTimeCol");
00112 
00113         double time = eventHeader->time();
00114         m_time = time;
00115 
00116         m_run = eventHeader->runNumber();
00117         m_rec = eventHeader->eventNumber();
00118 
00119         if(m_rec%1000==0)cout<<"Run   "<<m_run<<"     Event   "<<m_rec<<endl;
00120 
00121         double Emax1 = -1;
00122         double Emax2 = -1;
00123         int Imax[2];
00124 
00125         if((evtRecEvent->totalTracks() >= 2)){
00126                 double etot = 0.;
00127                 for(int i = 0;i < evtRecEvent->totalTracks(); i++)
00128                 {
00129                         if(i>=evtRecTrkCol->size()) break;
00130                         EvtRecTrackIterator  itTrk=evtRecTrkCol->begin() + i;
00131                         if(!(*itTrk)->isEmcShowerValid()) continue;
00132                         RecEmcShower *emcTrk = (*itTrk)->emcShower();
00133                         double Ener=emcTrk->energy();
00134                         if(Ener>Emax2)
00135                         {
00136                                 Emax2=Ener;
00137                                 Imax[1]=i;
00138                         }
00139                         if(Ener>Emax1)
00140                         {
00141                                 Emax2=Emax1;
00142                                 Imax[1]=Imax[0];
00143                                 Emax1=Ener;
00144                                 Imax[0]=i;
00145                         }
00146                         etot += Ener;
00147                 }
00148 
00149                 m_etot = etot;
00150                 m_e1 = Emax1;
00151                 m_e2 = Emax2;
00152 
00153                 log << MSG::INFO << "Emax1 = " << Emax1 <<"Emax2= "<<Emax2<< endreq;
00154                 if(Emax1 > 0 && Emax2 > 0){
00155                         double emcphi[2],emctht[2];
00156                         for(int i = 0;i < 2; i++)
00157                         {
00158                                 if(i>=evtRecTrkCol->size()) break;
00159                                 EvtRecTrackIterator  itTrk=evtRecTrkCol->begin() + Imax[i];
00160                                 if(!(*itTrk)->isEmcShowerValid()) continue;
00161                                 RecEmcShower *emcTrk = (*itTrk)->emcShower();
00162                                 emcphi[i]=emcTrk->phi();
00163                                 emctht[i]=emcTrk->theta();
00164                         }
00165 
00166                         double dltphi=(fabs(emcphi[0]-emcphi[1])-pai)*180./pai;
00167                         double dlttht=(fabs(emctht[0]+emctht[1])-pai)*180./pai;
00168                         m_costht1=cos(emctht[0]);
00169                         m_costht2=cos(emctht[1]);
00170                         m_phi1=emcphi[0];
00171                         m_phi2=emcphi[1];
00172                         m_dlttht=dlttht;
00173                         m_dltphi=dltphi;
00174                 }
00175                 else{
00176                         m_etot = -1;
00177                         m_e1 = -1;
00178                         m_e2 = -1;
00179                         m_costht1 = -1;
00180                         m_costht2 = -1;
00181                         m_phi1 = -1;
00182                         m_phi2 = -1;
00183                         m_dlttht = -1;
00184                         m_dltphi = -1;
00185                 }
00186         }
00187         else{
00188                 m_etot = -1;
00189                 m_e1 = -1;
00190                 m_e2 = -1;
00191                 m_costht1 = -1;
00192                 m_costht2 = -1;
00193                 m_phi1 = -1;
00194                 m_phi2 = -1;
00195                 m_dlttht = -1;
00196                 m_dltphi = -1;
00197         }
00198 
00199 //      m_tuple2->write();
00200 
00201         int DiskWrite = m_tuple2->write();
00202         if(DiskWrite != 1){
00203                 log<<MSG::FATAL<<"ERROR In LumTau DiskWrite!"<<endreq;
00204                 exit(1);
00205         }
00206 
00207         return StatusCode::SUCCESS;
00208 }
00209 
00210 StatusCode LumTau::finalize() 
00211 {
00212         cout<<"Event Finalize"<<endl;
00213         return StatusCode::SUCCESS;
00214 }
00215 

Generated on Tue Nov 29 23:12:44 2016 for BOSS_7.0.2 by  doxygen 1.4.7