BOSS 7.0.4
BESIII Offline Software System
Loading...
Searching...
No Matches
TagWriterAlg Class Reference

#include <TagWriterAlg.h>

+ Inheritance diagram for TagWriterAlg:

Public Member Functions

 TagWriterAlg (const std::string &name, ISvcLocator *pSvcLocator)
 
StatusCode initialize ()
 
StatusCode execute ()
 
StatusCode finalize ()
 
StatusCode getTagInfo ()
 
void openOutputTagFile (std::string file)
 
 TagWriterAlg (const std::string &name, ISvcLocator *pSvcLocator)
 
StatusCode initialize ()
 
StatusCode execute ()
 
StatusCode finalize ()
 
StatusCode getTagInfo ()
 
void openOutputTagFile (std::string file)
 

Detailed Description

Constructor & Destructor Documentation

◆ TagWriterAlg() [1/2]

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

Definition at line 38 of file TagWriterAlg.cxx.

38 :
39 Algorithm(name, pSvcLocator) {
40
41 //declareProperty("InputTagFile", m_inputTagFile);
42 declareProperty("OutputTagFile", m_outputTagFile);
43 //declareProperty("FilterTotalCharged", m_filterTotalCharged=2);
44}

◆ TagWriterAlg() [2/2]

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

Member Function Documentation

◆ execute() [1/2]

StatusCode TagWriterAlg::execute ( )

Definition at line 100 of file TagWriterAlg.cxx.

100 {
101
102 MsgStream log(msgSvc(), name());
103 log << MSG::INFO << "in execute()" << endreq;
104
105 //Write Tag during reconstruction
106 if(m_dstOutput!="")
107 {
108 if(m_entry==-1)
109 {
110 std::cout << "TagWriterAlg: write tag during reconstruction" << std::endl;
111 m_dstFile = m_dstOutput;
112 std::cout<< "dst file: "<< m_dstFile << std::endl;
113 openOutputTagFile(m_outputTagFile[0]);
114 m_oFileTree->Fill();
115 }
116 }
117 else //Write Tag after reconstruction
118 {
119 if( m_dstFile != m_rootInterface->getCurrentFileName() )
120 {
121 std::cout<<"TagWriterAlg, current file: "<<m_rootInterface->getCurrentFileName()<<std::endl;
122 m_fileNum++;
123 m_dstFile = m_rootInterface->getCurrentFileName();
124
125 m_entry=-1;
126 if(m_fileNum>0)
127 {
128 m_oFile->Write();
129 delete m_oTree;
130 delete m_oFileTree;
131 delete m_oFile;
132 }
133
134 log << MSG::INFO << "open ROOT output TAG file: "<<m_outputTagFile[m_fileNum]<<endreq;
135 openOutputTagFile(m_outputTagFile[m_fileNum]);
136 m_oFileTree->Fill();
137 }
138 }
139
140 m_entry++;
141 getTagInfo();
142 log << MSG::INFO << "writing TAG information to ROOT TAG file"<<endreq;
143 m_oTree->Fill();
144
145 m_entry_in_alg++;
146 return StatusCode::SUCCESS;
147}
void openOutputTagFile(std::string file)
StatusCode getTagInfo()

◆ execute() [2/2]

StatusCode TagWriterAlg::execute ( )

◆ finalize() [1/2]

StatusCode TagWriterAlg::finalize ( )

Definition at line 184 of file TagWriterAlg.cxx.

184 {
185
186 MsgStream log(msgSvc(), name());
187
188 m_oFile->Write();
189
190 log << MSG::INFO << "in finalize()" << endmsg;
191 return StatusCode::SUCCESS;
192}

◆ finalize() [2/2]

StatusCode TagWriterAlg::finalize ( )

◆ getTagInfo() [1/2]

StatusCode TagWriterAlg::getTagInfo ( )

Definition at line 151 of file TagWriterAlg.cxx.

152{
153 MsgStream log(msgSvc(), name());
154 log << MSG::INFO << "reading event data from DST"<<endreq;
155
156 SmartDataPtr<Event::EventHeader> eventHeader(eventSvc(),"/Event/EventHeader");
157 if(!eventHeader)
158 {
159 log << MSG::FATAL << "Could not find EventHeader." << endreq;
160 return StatusCode::FAILURE;
161 }
162
163 m_runNo=eventHeader->runNumber();
164 m_eventId=eventHeader->eventNumber();
165 log << MSG::DEBUG <<"run, evtnum = " << m_runNo << " , "<< m_eventId <<endreq;
166
167 SmartDataPtr<EvtRecEvent> evtRecEvent(eventSvc(), EventModel::EvtRec::EvtRecEvent);
168 if(!evtRecEvent)
169 {
170 log << MSG::FATAL << "Could not find EvtRecEvent." << endreq;
171 return StatusCode::FAILURE;
172 }
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;
181}

Referenced by execute().

◆ getTagInfo() [2/2]

StatusCode TagWriterAlg::getTagInfo ( )

◆ initialize() [1/2]

StatusCode TagWriterAlg::initialize ( )

Definition at line 47 of file TagWriterAlg.cxx.

47 {
48 MsgStream log(msgSvc(), name());
49
50 log << MSG::INFO << "in initialize()" << endmsg;
51
52 SmartIF<IJobOptionsSvc> iSvc(serviceLocator()->service("JobOptionsSvc"));
53 if ( iSvc.isValid() ) {
54 std::string dll; //sub so name
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");
62
63 if( ps !=0 )
64 {
65 for(int i=0;i<ps->size();i++)
66 {
67 if( (*ps)[i]->name() == "digiRootOutputFile" )
68
69 {
70 m_dstOutput = (*ps)[i]->toString();
71 std::cout<<"read from JobOptionSvc, dstOutput: "<< m_dstOutput<<std::endl;
72 }
73 }
74 }
75 }
76
77
78
79 m_rootInterface=RootInterface::Instance(log);
80 log << MSG::INFO <<"RootInteface TotalFileNum: "<<m_rootInterface->getTotalFileNum()<<endreq;
81 std::cout<<"getTotalFileNum: "<<m_rootInterface->getTotalFileNum()<<std::endl;
82
83 if(m_rootInterface->getTotalFileNum()>0)
84 {
85 if(m_rootInterface->getTotalFileNum() != m_outputTagFile.size() )
86 {
87 std::cout<<"the input file num != output file number, please check your jobOptions"<<std::endl;
88 exit(-1);
89 }
90 }
91
92 m_entry = -1;
93 m_entry_in_alg = -1;
94 m_dstFile = "";
95 m_fileNum=-1;
96 return StatusCode::SUCCESS;
97}
static RootInterface * Instance(MsgStream log)
singleton behaviour

◆ initialize() [2/2]

StatusCode TagWriterAlg::initialize ( )

◆ openOutputTagFile() [1/2]

void TagWriterAlg::openOutputTagFile ( std::string  file)

Definition at line 196 of file TagWriterAlg.cxx.

197{
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);
208
209}

Referenced by execute().

◆ openOutputTagFile() [2/2]

void TagWriterAlg::openOutputTagFile ( std::string  file)

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