1#include "GaudiKernel/MsgStream.h"
2#include "GaudiKernel/AlgFactory.h"
3#include "GaudiKernel/ISvcLocator.h"
4#include "GaudiKernel/SmartDataPtr.h"
5#include "GaudiKernel/IDataProviderSvc.h"
6#include "GaudiKernel/PropertyMgr.h"
7#include "GaudiKernel/Bootstrap.h"
8#include "GaudiKernel/ISvcLocator.h"
17#include "GaudiKernel/INTupleSvc.h"
18#include "GaudiKernel/NTuple.h"
19#include "GaudiKernel/Bootstrap.h"
20#include "GaudiKernel/IHistogramSvc.h"
21#include "CLHEP/Vector/ThreeVector.h"
22#include "CLHEP/Vector/LorentzVector.h"
23#include "CLHEP/Vector/TwoVector.h"
24#include "CLHEP/Geometry/Point3D.h"
29#include "GaudiKernel/SmartIF.h"
30#include "GaudiKernel/IJobOptionsSvc.h"
39 Algorithm(name, pSvcLocator) {
42 declareProperty(
"OutputTagFile", m_outputTagFile);
48 MsgStream log(
msgSvc(), name());
50 log << MSG::INFO <<
"in initialize()" << endmsg;
52 SmartIF<IJobOptionsSvc> iSvc(serviceLocator()->service(
"JobOptionsSvc"));
53 if ( iSvc.isValid() ) {
55 const std::vector<const Property*>* ps = 0;
56 if ( iSvc->getProperties(
"RootCnvSvc") != 0 )
57 ps = iSvc->getProperties(
"RootCnvSvc");
58 if ( iSvc->getProperties(
"EventCnvSvc") != 0 )
59 ps = iSvc->getProperties(
"EventCnvSvc");
60 if ( iSvc->getProperties(
"WriteDst") != 0 )
61 ps = iSvc->getProperties(
"WriteDst");
65 for(
int i=0;i<ps->size();i++)
67 if( (*ps)[i]->name() ==
"digiRootOutputFile" )
70 m_dstOutput = (*ps)[i]->toString();
71 std::cout<<
"read from JobOptionSvc, dstOutput: "<< m_dstOutput<<std::endl;
80 log << MSG::INFO <<
"RootInteface TotalFileNum: "<<m_rootInterface->
getTotalFileNum()<<endreq;
81 std::cout<<
"getTotalFileNum: "<<m_rootInterface->
getTotalFileNum()<<std::endl;
87 std::cout<<
"the input file num != output file number, please check your jobOptions"<<std::endl;
96 return StatusCode::SUCCESS;
102 MsgStream log(
msgSvc(), name());
103 log << MSG::INFO <<
"in execute()" << endreq;
110 std::cout <<
"TagWriterAlg: write tag during reconstruction" << std::endl;
111 m_dstFile = m_dstOutput;
112 std::cout<<
"dst file: "<< m_dstFile << std::endl;
121 std::cout<<
"TagWriterAlg, current file: "<<m_rootInterface->
getCurrentFileName()<<std::endl;
134 log << MSG::INFO <<
"open ROOT output TAG file: "<<m_outputTagFile[m_fileNum]<<endreq;
142 log << MSG::INFO <<
"writing TAG information to ROOT TAG file"<<endreq;
146 return StatusCode::SUCCESS;
153 MsgStream log(
msgSvc(), name());
154 log << MSG::INFO <<
"reading event data from DST"<<endreq;
156 SmartDataPtr<Event::EventHeader> eventHeader(eventSvc(),
"/Event/EventHeader");
159 log << MSG::FATAL <<
"Could not find EventHeader." << endreq;
160 return StatusCode::FAILURE;
163 m_runNo=eventHeader->runNumber();
164 m_eventId=eventHeader->eventNumber();
165 log << MSG::DEBUG <<
"run, evtnum = " << m_runNo <<
" , "<< m_eventId <<endreq;
170 log << MSG::FATAL <<
"Could not find EvtRecEvent." << endreq;
171 return StatusCode::FAILURE;
173 log << MSG::DEBUG <<
"ncharg, nneu, tottks = "
174 << evtRecEvent->totalCharged() <<
" , "
175 << evtRecEvent->totalNeutral() <<
" , "
176 << evtRecEvent->totalTracks() <<endreq;
177 m_totalCharged = evtRecEvent->totalCharged();
178 m_totalNeutral = evtRecEvent->totalNeutral();
179 m_totalTrks = evtRecEvent->totalTracks();
180 return StatusCode::SUCCESS;
186 MsgStream log(
msgSvc(), name());
190 log << MSG::INFO <<
"in finalize()" << endmsg;
191 return StatusCode::SUCCESS;
198 m_oFile =
new TFile(ofile.c_str(),
"RECREATE",
"ROOT file for TAG");
199 m_oTree =
new TTree(
"Tag",
"Tags for DST file");
200 m_oTree->Branch(
"entry",&m_entry,
"entry/I");
201 m_oTree->Branch(
"runNo",&m_runNo,
"runNo/I");
202 m_oTree->Branch(
"eventId",&m_eventId,
"eventId/I");
203 m_oTree->Branch(
"totalCharged",&m_totalCharged,
"totalCharged/I");
204 m_oTree->Branch(
"totalNeutral",&m_totalNeutral,
"totalNeutral/I");
205 m_oTree->Branch(
"totalTrks",&m_totalTrks,
"totalTrks/I");
206 m_oFileTree =
new TTree(
"File",
"DST file names");
207 m_oFileTree->Branch(
"fileName", &m_dstFile);
virtual int getTotalFileNum()
static RootInterface * Instance(MsgStream log)
singleton behaviour
virtual std::string getCurrentFileName()
TagWriterAlg(const std::string &name, ISvcLocator *pSvcLocator)
void openOutputTagFile(std::string file)
_EXTERN_ std::string EvtRecEvent