BOSS 7.0.9
BESIII Offline Software System
Loading...
Searching...
No Matches
TofEnergyRec Class Reference

#include <TofEnergyRec.h>

+ Inheritance diagram for TofEnergyRec:

Public Member Functions

 TofEnergyRec (const std::string &name, ISvcLocator *pSvcLocator)
 
StatusCode initialize ()
 
StatusCode execute ()
 
StatusCode finalize ()
 

Detailed Description

Definition at line 15 of file TofEnergyRec.h.

Constructor & Destructor Documentation

◆ TofEnergyRec()

TofEnergyRec::TofEnergyRec ( const std::string &  name,
ISvcLocator *  pSvcLocator 
)

Definition at line 45 of file TofEnergyRec.cxx.

45 :
46 Algorithm(name, pSvcLocator)
47{
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);
52}

Member Function Documentation

◆ execute()

StatusCode TofEnergyRec::execute ( )

Definition at line 95 of file TofEnergyRec.cxx.

95 {
96
97 MsgStream log(msgSvc(), name());
98 log << MSG::INFO << "TofEnergyRec in execute()!!" << endreq;
99
100 SmartDataPtr<Event::EventHeader> eventHeader(eventSvc(),"/Event/EventHeader");
101 if( !eventHeader ) {
102 log << MSG::FATAL << "TofEnergyRec could not find Event Header!" << endreq;
103 return StatusCode::FAILURE;
104 }
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;
110 m_event++;
111
112
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;
118 }
119
120 //check whether the Recon has been already registered
121 DataObject *aReconEvent;
122 eventSvc()->findObject("/Event/Recon",aReconEvent);
123 if(aReconEvent==NULL) {
124 log << MSG::INFO << "Register ReconEvent" << endreq;
125 //then register Recon
126 aReconEvent = new ReconEvent();
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;
131 }
132 }
133
134 //Register RecTofTrackCol
135 SmartDataPtr<RecTofTrackCol> tofTrackCol(eventSvc(),EventModel::Recon::RecTofTrackCol);
136 if (!tofTrackCol) {
137 log << MSG::INFO << "Register RecTofTrackCol!" << endreq;
138 tofTrackCol = new RecTofTrackCol;
139 sc = eventSvc()->registerObject(EventModel::Recon::RecTofTrackCol, tofTrackCol);
140 if(sc!=StatusCode::SUCCESS) {
141 log << MSG::FATAL << "Could not register RecTofTrackCol!" <<endreq;
142 }
143 }
144
145
146
147 //Retrieve RecEsTimeCol
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;
152 }
153 RecEsTimeCol::iterator iter_ESTime=estimeCol->begin();
154 double t0=0;
155 t0 = (*iter_ESTime)->getTest();
156 int t0Stat = (*iter_ESTime)->getStat();
157
158
159 std::vector<TofData*> tofDataVec;
160 tofDataVec = tofDigiSvc->tofDataVectorTof();
161
162
163 m_tofShower->findShower(tofDataVec, tofTrackCol, t0);
164
165 return StatusCode::SUCCESS;
166
167}
ObjectVector< RecTofTrack > RecTofTrackCol
Definition: RecTofTrack.h:33
IMessageSvc * msgSvc()
IRawDataProviderSvc * tofDigiSvc
#define NULL
virtual TofDataVector & tofDataVectorTof(double estime=0)=0
void findShower(vector< TofData * > &tofDataVec, RecTofTrackCol *recTofTrackCol, double)
Definition: TofShower.cxx:540
_EXTERN_ std::string RecTofTrackCol
Definition: EventModel.h:97

◆ finalize()

StatusCode TofEnergyRec::finalize ( )

Definition at line 171 of file TofEnergyRec.cxx.

171 {
172 cout << "Total event:" << m_event << endl;
173 delete m_tofShower;
174 return StatusCode::SUCCESS;
175}

◆ initialize()

StatusCode TofEnergyRec::initialize ( )

Definition at line 56 of file TofEnergyRec.cxx.

56 {
57
58 MsgStream log(msgSvc(), name());
59 log << MSG::INFO << "TofEnergyRec in initialize()" << endreq;
60
61 m_event = 0;
62 m_tofShower = new TofShower;
63 m_tofShower->setCalibConst(m_calibConst);
64 m_tofShower->setIsData(m_isData);
65 //m_tofShower->readCalibPar();
66
67 if(m_output) {
68 cout<<"--------Book Tof Energy Ntuple!"<<endl;
69 NTuplePtr nt(ntupleSvc(), "FILE209/sci");
70 NTuplePtr nt1(ntupleSvc(), "FILE209/shower");
71 NTuplePtr nt2(ntupleSvc(), "FILE209/seed");
72 if ( nt&&nt1&&nt2 ) {
73 m_tuple = nt;
74 m_tuple1 = nt1;
75 m_tuple2 = nt2;
76 } else {
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);
82 }
83 else {
84 log << MSG::ERROR << " ----- TofShower cannot book N-tuple:" << long(m_tuple) << endmsg;
85 }
86 }
87 }
88
89
90 return StatusCode::SUCCESS;
91}
INTupleSvc * ntupleSvc()
void setCalibConst(const double cal)
Definition: TofShower.h:39
void BookNtuple(NTuple::Tuple *&tuple, NTuple::Tuple *&tuple1, NTuple::Tuple *&tuple2)
Definition: TofShower.cxx:39
void setIsData(const bool isData)
Definition: TofShower.h:42

The documentation for this class was generated from the following files: