/home/bes3soft/bes3soft/Boss/7.0.2/dist/7.0.2/Reconstruction/EmcTimeRec/EmcTimeRec-00-00-03/src/EmcTimeRec.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 "EventModel/EventHeader.h"
00007 #include "EmcRecEventModel/RecEmcEventModel.h"
00008 #include "EvTimeEvent/RecEsTime.h"
00009 #include "EmcTimeRec/EmcTimeRec.h"
00010 
00011 using namespace std;
00012 using namespace Event;
00013 
00015 
00016 EmcTimeRec::EmcTimeRec(const std::string& name, ISvcLocator* pSvcLocator) :
00017   Algorithm(name, pSvcLocator)
00018 {   
00019   declareProperty("Output",m_output=false);
00020 }
00021 
00022 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 
00023 StatusCode EmcTimeRec::initialize() {
00024 
00025   MsgStream log(msgSvc(), name());
00026   log << MSG::INFO << "in initialize()" << endreq;
00027 
00028   if(m_output) {
00029     NTuplePtr nt(ntupleSvc(),"FILE303/n1");
00030     if ( nt ) m_tuple = nt;
00031     else {
00032       m_tuple=ntupleSvc()->book("FILE303/n1",CLID_ColumnWiseTuple,"EmcTimeRec");
00033       if( m_tuple ) {
00034         m_tuple->addItem ("emcTime", m_nt_emcTime);
00035         m_tuple->addItem ("estTime", m_nt_estTime);
00036         m_tuple->addItem ("corTime", m_nt_corTime);
00037         m_tuple->addItem ("npart",   m_nt_npart);
00038         m_tuple->addItem ("ntheta",  m_nt_ntheta);
00039         m_tuple->addItem ("nphi",    m_nt_nphi);
00040         m_tuple->addItem ("e5x5",    m_nt_e5x5);
00041         m_tuple->addItem ("status",  m_nt_status);
00042       }
00043       else    {   // did not manage to book the N tuple....
00044         log << MSG::ERROR << "Cannot book N-tuple:" << long(m_tuple) << endmsg;
00045         return StatusCode::FAILURE;
00046       }
00047     }
00048   }
00049 
00050   return StatusCode::SUCCESS;
00051 }
00052 
00053 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 
00054 StatusCode EmcTimeRec::execute() {
00055 
00056   MsgStream log(msgSvc(), name());
00057   log << MSG::DEBUG << "in execute()" << endreq;   
00058 
00059   SmartDataPtr<RecEsTimeCol> estimeCol(eventSvc(),"/Event/Recon/RecEsTimeCol");
00060 
00061   if( !estimeCol || ( estimeCol->size() == 0 ) ) {
00062     log << MSG::WARNING << "Could not find RecEsTimeCol!" << endreq;
00063     return StatusCode::SUCCESS;
00064   } 
00065 
00066   RecEsTimeCol::iterator iter_ESTime=estimeCol->begin();
00067   double t0  = (*iter_ESTime)->getTest(); //get t0
00068 
00069   SmartDataPtr<RecEmcShowerCol> emcRecShowerCol(eventSvc(), EventModel::Recon::RecEmcShowerCol);
00070   if(!emcRecShowerCol) {
00071     log << MSG::WARNING << "Could not find RecEmcShowerCol!" << endreq;
00072     return StatusCode::SUCCESS;
00073   } 
00074 
00075   RecEmcShowerCol::iterator iShowerCol;
00076   for(iShowerCol=emcRecShowerCol->begin();
00077       iShowerCol!=emcRecShowerCol->end();
00078       iShowerCol++) {
00079 
00080     if((*iShowerCol)->status()>=100) continue;  //estTime has been subtracted
00081 
00082     double tEmc = (*iShowerCol)->time();
00083     (*iShowerCol)->setTime(tEmc-(int)(t0/50));
00084     (*iShowerCol)->setStatus((*iShowerCol)->status()%100+100);
00085 
00086     if(m_output) {
00087       m_nt_emcTime = tEmc;
00088       m_nt_estTime = (double)(int)(t0/50);
00089       m_nt_corTime = (*iShowerCol)->time();
00090       RecEmcID id((*iShowerCol)->getShowerId());
00091       m_nt_npart = EmcID::barrel_ec(id);
00092       m_nt_ntheta = EmcID::theta_module(id);
00093       m_nt_nphi = EmcID::phi_module(id);
00094       m_nt_e5x5 = (*iShowerCol)->e5x5();
00095       m_nt_status = (*iShowerCol)->status();
00096       m_tuple->write();
00097     }
00098   }
00099 
00100   return StatusCode::SUCCESS;
00101 }
00102 
00103 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 
00104 StatusCode EmcTimeRec::finalize() {
00105 
00106   MsgStream log(msgSvc(), name());
00107   log << MSG::INFO << "in finalize()" << endreq;
00108 
00109   return StatusCode::SUCCESS;
00110 }

Generated on Tue Nov 29 23:13:20 2016 for BOSS_7.0.2 by  doxygen 1.4.7