BOSS 8.0.0
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)

Detailed Description

Definition at line 14 of file TagWriterAlg.h.

Constructor & Destructor Documentation

◆ TagWriterAlg()

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

Definition at line 36 of file TagWriterAlg.cxx.

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

Referenced by TagWriterAlg().

Member Function Documentation

◆ execute()

StatusCode TagWriterAlg::execute ( )

Definition at line 96 of file TagWriterAlg.cxx.

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

◆ finalize()

StatusCode TagWriterAlg::finalize ( )

Definition at line 178 of file TagWriterAlg.cxx.

178 {
179
180 MsgStream log( msgSvc(), name() );
181
182 m_oFile->Write();
183
184 log << MSG::INFO << "in finalize()" << endmsg;
185 return StatusCode::SUCCESS;
186}

◆ getTagInfo()

StatusCode TagWriterAlg::getTagInfo ( )

Definition at line 148 of file TagWriterAlg.cxx.

148 {
149 MsgStream log( msgSvc(), name() );
150 log << MSG::INFO << "reading event data from DST" << endmsg;
151
152 SmartDataPtr<Event::EventHeader> eventHeader( eventSvc(), "/Event/EventHeader" );
153 if ( !eventHeader )
154 {
155 log << MSG::FATAL << "Could not find EventHeader." << endmsg;
156 return StatusCode::FAILURE;
157 }
158
159 m_runNo = eventHeader->runNumber();
160 m_eventId = eventHeader->eventNumber();
161 log << MSG::DEBUG << "run, evtnum = " << m_runNo << " , " << m_eventId << endmsg;
162
163 SmartDataPtr<EvtRecEvent> evtRecEvent( eventSvc(), EventModel::EvtRec::EvtRecEvent );
164 if ( !evtRecEvent )
165 {
166 log << MSG::FATAL << "Could not find EvtRecEvent." << endmsg;
167 return StatusCode::FAILURE;
168 }
169 log << MSG::DEBUG << "ncharg, nneu, tottks = " << evtRecEvent->totalCharged() << " , "
170 << evtRecEvent->totalNeutral() << " , " << evtRecEvent->totalTracks() << endmsg;
171 m_totalCharged = evtRecEvent->totalCharged();
172 m_totalNeutral = evtRecEvent->totalNeutral();
173 m_totalTrks = evtRecEvent->totalTracks();
174 return StatusCode::SUCCESS;
175}

Referenced by execute().

◆ initialize()

StatusCode TagWriterAlg::initialize ( )

Definition at line 45 of file TagWriterAlg.cxx.

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

◆ openOutputTagFile()

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

Definition at line 189 of file TagWriterAlg.cxx.

189 {
190 m_oFile = new TFile( ofile.c_str(), "RECREATE", "ROOT file for TAG" );
191 m_oTree = new TTree( "Tag", "Tags for DST file" );
192 m_oTree->Branch( "entry", &m_entry, "entry/I" );
193 m_oTree->Branch( "runNo", &m_runNo, "runNo/I" );
194 m_oTree->Branch( "eventId", &m_eventId, "eventId/I" );
195 m_oTree->Branch( "totalCharged", &m_totalCharged, "totalCharged/I" );
196 m_oTree->Branch( "totalNeutral", &m_totalNeutral, "totalNeutral/I" );
197 m_oTree->Branch( "totalTrks", &m_totalTrks, "totalTrks/I" );
198 m_oFileTree = new TTree( "File", "DST file names" );
199 m_oFileTree->Branch( "fileName", &m_dstFile );
200}

Referenced by execute().


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