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"
14#include "EventModel/EventHeader.h"
15#include "EventModel/EventModel.h"
16#include "ReconEvent/ReconEvent.h"
17#include "McTruth/McParticle.h"
18#include "McTruth/TofMcHit.h"
19#include "RawDataProviderSvc/TofData.h"
20#include "DstEvent/TofHitStatus.h"
21#include "EvTimeEvent/RecEsTime.h"
22#include "ExtEvent/RecExtTrack.h"
23#include "DstEvent/TofHitStatus.h"
24#include "TofRecEvent/RecTofTrack.h"
25#include "TofRecEvent/RecBTofCalHit.h"
26#include "TofRecEvent/RecETofCalHit.h"
27#include "TofRecEvent/RecBTofHit.h"
28#include "TofRecEvent/RecETofHit.h"
29#include "TofGeomSvc/ITofGeomSvc.h"
30#include "TofCaliSvc/ITofCaliSvc.h"
31#include "RawDataProviderSvc/IRawDataProviderSvc.h"
32#include "TofEnergyRec/TofEnergyRec.h"
33#include "TofEnergyRec/TofShower.h"
45 Algorithm(name, pSvcLocator)
47 declareProperty(
"Output", m_output =
false);
48 declareProperty(
"EventNb", m_eventNb = 0);
49 declareProperty(
"CalibConst", m_calibConst = 0.0085);
50 declareProperty(
"IsData", m_isData =
true);
57 MsgStream log(
msgSvc(), name());
58 log << MSG::INFO <<
"TofEnergyRec in initialize()" << endreq;
67 cout<<
"--------Book Tof Energy Ntuple!"<<endl;
69 NTuplePtr nt1(
ntupleSvc(),
"FILE209/shower");
70 NTuplePtr nt2(
ntupleSvc(),
"FILE209/seed");
76 m_tuple =
ntupleSvc()->book (
"FILE209/sci", CLID_ColumnWiseTuple,
"TofEnergyRec");
77 m_tuple1 =
ntupleSvc()->book (
"FILE209/shower", CLID_ColumnWiseTuple,
"TofEnergyRec");
78 m_tuple2 =
ntupleSvc()->book (
"FILE209/seed", CLID_ColumnWiseTuple,
"TofEnergyRec");
79 if ( m_tuple&&m_tuple1&&m_tuple2 ) {
80 m_tofShower->
BookNtuple(m_tuple,m_tuple1,m_tuple2);
83 log << MSG::ERROR <<
" ----- TofShower cannot book N-tuple:" << long(m_tuple) << endmsg;
88 return StatusCode::SUCCESS;
95 MsgStream log(
msgSvc(), name());
96 log << MSG::INFO <<
"TofEnergyRec in execute()!!" << endreq;
98 SmartDataPtr<Event::EventHeader> eventHeader(eventSvc(),
"/Event/EventHeader");
100 log << MSG::FATAL <<
"TofEnergyRec could not find Event Header!" << endreq;
101 return StatusCode::FAILURE;
103 int run = eventHeader->runNumber();
104 int event = eventHeader->eventNumber();
105 if( m_eventNb!=0 && m_event%m_eventNb== 0 ) std::cout <<
"--------event: " << m_event
106 <<
", run= " << run <<
" event= " <<
event << std::endl;
107 log << MSG::INFO <<
"run= " << run <<
" event= " <<
event << endreq;
111 StatusCode sc = service(
"RawDataProviderSvc",
tofDigiSvc);
112 if(sc != StatusCode::SUCCESS) {
113 log << MSG::FATAL <<
"TofEnergyRec could not find RawDataProviderSvc!" << endreq;
114 return StatusCode::SUCCESS;
118 DataObject *aReconEvent;
119 eventSvc()->findObject(
"/Event/Recon",aReconEvent);
120 if(aReconEvent==NULL) {
121 log << MSG::INFO <<
"Register ReconEvent" << endreq;
124 sc = eventSvc()->registerObject(
"/Event/Recon",aReconEvent);
125 if(sc!=StatusCode::SUCCESS) {
126 log << MSG::FATAL <<
"Could not register ReconEvent" <<endreq;
127 return StatusCode::FAILURE;
134 log << MSG::INFO <<
"Register RecTofTrackCol!" << endreq;
137 if(sc!=StatusCode::SUCCESS) {
138 log << MSG::FATAL <<
"Could not register RecTofTrackCol!" <<endreq;
145 SmartDataPtr<RecEsTimeCol> estimeCol(eventSvc(),
"/Event/Recon/RecEsTimeCol");
146 if( !estimeCol || ( estimeCol->size() == 0 ) ) {
147 log << MSG::WARNING <<
"TofRec Could not find RecEsTimeCol! Run = " << run <<
" Event = " <<
event << endreq;
148 return StatusCode::SUCCESS;
150 RecEsTimeCol::iterator iter_ESTime=estimeCol->begin();
152 t0 = (*iter_ESTime)->getTest();
153 int t0Stat = (*iter_ESTime)->getStat();
156 std::vector<TofData*> tofDataVec;
160 m_tofShower->
findShower(tofDataVec, tofTrackCol, t0);
162 return StatusCode::SUCCESS;
169 cout <<
"Total event:" << m_event << endl;
171 return StatusCode::SUCCESS;
ObjectVector< RecTofTrack > RecTofTrackCol
IRawDataProviderSvc * tofDigiSvc
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