/home/bes3soft/bes3soft/Boss/7.0.2/dist/7.0.2/Reconstruction/TofEnergyRec/TofEnergyRec-00-00-11/src/TofEnergyRec.cxx

Go to the documentation of this file.
00001 // add bhabha selection code 9/17
00002 //
00003 //  Package: TofEnergyRec
00004 //  BESIII Tof Energy Reconstruction Algorithm. 
00005 //  Created by He Miao (EPC IHEP)
00006 //
00007 #include "GaudiKernel/MsgStream.h"
00008 #include "GaudiKernel/AlgFactory.h"
00009 #include "GaudiKernel/ISvcLocator.h"
00010 #include "GaudiKernel/SmartDataPtr.h"
00011 #include "GaudiKernel/SmartDataLocator.h"
00012 #include "GaudiKernel/IDataProviderSvc.h"
00013 #include "GaudiKernel/PropertyMgr.h"
00014 #include "EventModel/EventHeader.h"
00015 #include "EventModel/EventModel.h"
00016 #include "ReconEvent/ReconEvent.h"
00017 #include "McTruth/McParticle.h"
00018 #include "McTruth/TofMcHit.h"
00019 #include "RawDataProviderSvc/TofData.h"
00020 #include "DstEvent/TofHitStatus.h"
00021 #include "EvTimeEvent/RecEsTime.h"
00022 #include "ExtEvent/RecExtTrack.h"
00023 #include "DstEvent/TofHitStatus.h"
00024 #include "TofRecEvent/RecTofTrack.h"
00025 #include "TofRecEvent/RecBTofCalHit.h"
00026 #include "TofRecEvent/RecETofCalHit.h"
00027 #include "TofRecEvent/RecBTofHit.h"
00028 #include "TofRecEvent/RecETofHit.h"
00029 #include "TofGeomSvc/ITofGeomSvc.h"
00030 #include "TofCaliSvc/ITofCaliSvc.h"
00031 
00032 #include "RawDataProviderSvc/IRawDataProviderSvc.h"
00033 #include "TofEnergyRec/TofEnergyRec.h"
00034 #include "TofEnergyRec/TofShower.h"
00035 #include <iostream>
00036 
00037 
00038 using namespace std;
00039 using namespace Event;
00040 
00042 
00043 IRawDataProviderSvc* tofDigiSvc;
00044 
00045 TofEnergyRec::TofEnergyRec(const std::string& name, ISvcLocator* pSvcLocator) :
00046   Algorithm(name, pSvcLocator)
00047 {   
00048   declareProperty("Output",           m_output = false);
00049   declareProperty("EventNb",          m_eventNb = 0);
00050   declareProperty("CalibConst",       m_calibConst = 0.0085);
00051   declareProperty("IsData",           m_isData = true);
00052 }
00053 
00054 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 
00055 
00056 StatusCode TofEnergyRec::initialize() {
00057 
00058   MsgStream log(msgSvc(), name());
00059   log << MSG::INFO << "TofEnergyRec in initialize()" << endreq;   
00060 
00061   m_event = 0;
00062   m_tofShower = new TofShower;
00063   m_tofShower->setCalibConst(m_calibConst);
00064   m_tofShower->setIsData(m_isData);
00065   //m_tofShower->readCalibPar();
00066 
00067   if(m_output) {
00068     cout<<"--------Book Tof Energy Ntuple!"<<endl;
00069     NTuplePtr nt(ntupleSvc(), "FILE209/sci");
00070     NTuplePtr nt1(ntupleSvc(), "FILE209/shower");
00071     NTuplePtr nt2(ntupleSvc(), "FILE209/seed");
00072     if ( nt&&nt1&&nt2 ) {
00073       m_tuple = nt;
00074       m_tuple1 = nt1;
00075       m_tuple2 = nt2;
00076     } else {
00077       m_tuple = ntupleSvc()->book ("FILE209/sci", CLID_ColumnWiseTuple, "TofEnergyRec");
00078       m_tuple1 = ntupleSvc()->book ("FILE209/shower", CLID_ColumnWiseTuple, "TofEnergyRec");
00079       m_tuple2 = ntupleSvc()->book ("FILE209/seed", CLID_ColumnWiseTuple, "TofEnergyRec");
00080       if ( m_tuple&&m_tuple1&&m_tuple2 ) {
00081         m_tofShower->BookNtuple(m_tuple,m_tuple1,m_tuple2);
00082       }
00083       else    { 
00084         log << MSG::ERROR << " ----- TofShower cannot book N-tuple:" << long(m_tuple) << endmsg;
00085       }
00086     }
00087   }
00088 
00089 
00090   return StatusCode::SUCCESS;
00091 }
00092 
00093 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 
00094 
00095 StatusCode TofEnergyRec::execute() {
00096 
00097   MsgStream log(msgSvc(), name());
00098   log << MSG::INFO << "TofEnergyRec in execute()!!" << endreq;
00099 
00100   SmartDataPtr<Event::EventHeader> eventHeader(eventSvc(),"/Event/EventHeader");
00101   if( !eventHeader ) {
00102     log << MSG::FATAL << "TofEnergyRec could not find Event Header!" << endreq;
00103     return StatusCode::FAILURE;
00104   }
00105   int run = eventHeader->runNumber();
00106   int event = eventHeader->eventNumber();
00107   if( m_eventNb!=0 && m_event%m_eventNb== 0 ) std::cout << "--------event: " << m_event 
00108     << ", run= " << run << "  event= " << event << std::endl;
00109   log << MSG::INFO << "run= " << run << "  event= " << event << endreq;
00110   m_event++;
00111 
00112 
00113   IRawDataProviderSvc* tofDigiSvc;
00114   StatusCode sc = service("RawDataProviderSvc", tofDigiSvc);
00115   if(sc != StatusCode::SUCCESS) {
00116     log << MSG::FATAL << "TofEnergyRec could not find RawDataProviderSvc!" << endreq;
00117     return StatusCode::SUCCESS;
00118   }
00119 
00120   //check whether the Recon has been already registered
00121   DataObject *aReconEvent;
00122   eventSvc()->findObject("/Event/Recon",aReconEvent);
00123   if(aReconEvent==NULL) {
00124     log << MSG::INFO << "Register ReconEvent" << endreq;
00125     //then register Recon
00126     aReconEvent = new ReconEvent();
00127     sc = eventSvc()->registerObject("/Event/Recon",aReconEvent);
00128     if(sc!=StatusCode::SUCCESS) {
00129       log << MSG::FATAL << "Could not register ReconEvent" <<endreq;
00130       return StatusCode::FAILURE;
00131     }
00132   }
00133 
00134   //Register RecTofTrackCol
00135   SmartDataPtr<RecTofTrackCol> tofTrackCol(eventSvc(),EventModel::Recon::RecTofTrackCol);
00136   if (!tofTrackCol) {
00137     log << MSG::INFO << "Register RecTofTrackCol!" << endreq;
00138     tofTrackCol = new RecTofTrackCol;
00139     sc = eventSvc()->registerObject(EventModel::Recon::RecTofTrackCol, tofTrackCol);
00140     if(sc!=StatusCode::SUCCESS) {
00141       log << MSG::FATAL << "Could not register RecTofTrackCol!" <<endreq;
00142     }
00143   }
00144 
00145 
00146 
00147   //Retrieve RecEsTimeCol 
00148   SmartDataPtr<RecEsTimeCol> estimeCol(eventSvc(),"/Event/Recon/RecEsTimeCol");
00149   if( !estimeCol || ( estimeCol->size() == 0 ) ) {
00150     log << MSG::WARNING << "TofRec Could not find RecEsTimeCol!   Run = " << run << " Event = " << event << endreq;                                                                               
00151     return StatusCode::SUCCESS;
00152   }
00153   RecEsTimeCol::iterator iter_ESTime=estimeCol->begin();
00154   double t0=0;
00155   t0  = (*iter_ESTime)->getTest();
00156   int t0Stat = (*iter_ESTime)->getStat();
00157 
00158 
00159   std::vector<TofData*> tofDataVec;
00160   tofDataVec = tofDigiSvc->tofDataVectorTof();
00161 
00162 
00163   m_tofShower->findShower(tofDataVec, tofTrackCol, t0);
00164 
00165   return StatusCode::SUCCESS;
00166 
00167 }
00168 
00169 //   * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 
00170 
00171 StatusCode TofEnergyRec::finalize() {
00172   cout << "Total event:" << m_event << endl;
00173   delete m_tofShower;
00174   return StatusCode::SUCCESS;
00175 }

Generated on Tue Nov 29 23:14:10 2016 for BOSS_7.0.2 by  doxygen 1.4.7