7#include "GaudiKernel/MsgStream.h"
8#include "GaudiKernel/AlgFactory.h"
9#include "GaudiKernel/ISvcLocator.h"
10#include "GaudiKernel/SmartDataPtr.h"
11#include "GaudiKernel/SmartDataLocator.h"
12#include "GaudiKernel/IDataProviderSvc.h"
13#include "GaudiKernel/PropertyMgr.h"
46 Algorithm(name, pSvcLocator)
48 declareProperty(
"Output", m_output =
false);
49 declareProperty(
"EventNb", m_eventNb = 0);
50 declareProperty(
"CalibConst", m_calibConst = 0.0085);
51 declareProperty(
"IsData", m_isData =
true);
58 MsgStream log(
msgSvc(), name());
59 log << MSG::INFO <<
"TofEnergyRec in initialize()" << endreq;
68 cout<<
"--------Book Tof Energy Ntuple!"<<endl;
70 NTuplePtr nt1(
ntupleSvc(),
"FILE209/shower");
71 NTuplePtr nt2(
ntupleSvc(),
"FILE209/seed");
77 m_tuple =
ntupleSvc()->book (
"FILE209/sci", CLID_ColumnWiseTuple,
"TofEnergyRec");
78 m_tuple1 =
ntupleSvc()->book (
"FILE209/shower", CLID_ColumnWiseTuple,
"TofEnergyRec");
79 m_tuple2 =
ntupleSvc()->book (
"FILE209/seed", CLID_ColumnWiseTuple,
"TofEnergyRec");
80 if ( m_tuple&&m_tuple1&&m_tuple2 ) {
81 m_tofShower->
BookNtuple(m_tuple,m_tuple1,m_tuple2);
84 log << MSG::ERROR <<
" ----- TofShower cannot book N-tuple:" << long(m_tuple) << endmsg;
90 return StatusCode::SUCCESS;
97 MsgStream log(
msgSvc(), name());
98 log << MSG::INFO <<
"TofEnergyRec in execute()!!" << endreq;
100 SmartDataPtr<Event::EventHeader> eventHeader(eventSvc(),
"/Event/EventHeader");
102 log << MSG::FATAL <<
"TofEnergyRec could not find Event Header!" << endreq;
103 return StatusCode::FAILURE;
105 int run = eventHeader->runNumber();
106 int event = eventHeader->eventNumber();
107 if( m_eventNb!=0 && m_event%m_eventNb== 0 ) std::cout <<
"--------event: " << m_event
108 <<
", run= " << run <<
" event= " <<
event << std::endl;
109 log << MSG::INFO <<
"run= " << run <<
" event= " <<
event << endreq;
114 StatusCode sc = service(
"RawDataProviderSvc",
tofDigiSvc);
115 if(sc != StatusCode::SUCCESS) {
116 log << MSG::FATAL <<
"TofEnergyRec could not find RawDataProviderSvc!" << endreq;
117 return StatusCode::SUCCESS;
121 DataObject *aReconEvent;
122 eventSvc()->findObject(
"/Event/Recon",aReconEvent);
123 if(aReconEvent==NULL) {
124 log << MSG::INFO <<
"Register ReconEvent" << endreq;
127 sc = eventSvc()->registerObject(
"/Event/Recon",aReconEvent);
128 if(sc!=StatusCode::SUCCESS) {
129 log << MSG::FATAL <<
"Could not register ReconEvent" <<endreq;
130 return StatusCode::FAILURE;
137 log << MSG::INFO <<
"Register RecTofTrackCol!" << endreq;
140 if(sc!=StatusCode::SUCCESS) {
141 log << MSG::FATAL <<
"Could not register RecTofTrackCol!" <<endreq;
148 SmartDataPtr<RecEsTimeCol> estimeCol(eventSvc(),
"/Event/Recon/RecEsTimeCol");
149 if( !estimeCol || ( estimeCol->size() == 0 ) ) {
150 log << MSG::WARNING <<
"TofRec Could not find RecEsTimeCol! Run = " << run <<
" Event = " <<
event << endreq;
151 return StatusCode::SUCCESS;
153 RecEsTimeCol::iterator iter_ESTime=estimeCol->begin();
155 t0 = (*iter_ESTime)->getTest();
156 int t0Stat = (*iter_ESTime)->getStat();
159 std::vector<TofData*> tofDataVec;
163 m_tofShower->
findShower(tofDataVec, tofTrackCol, t0);
165 return StatusCode::SUCCESS;
172 cout <<
"Total event:" << m_event << endl;
174 return StatusCode::SUCCESS;
ObjectVector< RecTofTrack > RecTofTrackCol
IRawDataProviderSvc * tofDigiSvc
virtual TofDataVector & tofDataVectorTof(double estime=0)=0
TofEnergyRec(const std::string &name, ISvcLocator *pSvcLocator)
void setCalibConst(const double cal)
void BookNtuple(NTuple::Tuple *&tuple, NTuple::Tuple *&tuple1, NTuple::Tuple *&tuple2)
void setIsData(const bool isData)
void findShower(vector< TofData * > &tofDataVec, RecTofTrackCol *recTofTrackCol, double)
_EXTERN_ std::string RecTofTrackCol