16 info() <<
"In initialize()" << endmsg;
18 StatusCode sc = service(
"RootCnvSvc", m_cnvSvc,
false );
19 if ( !sc.isSuccess() ) sc = service(
"EventCnvSvc", m_cnvSvc,
true );
20 if ( !sc.isSuccess() )
22 error() <<
"Unable to locate IRootCnvSvc interface" << endmsg;
26 sc = service(
"EventDataSvc", m_pDataProvider,
true );
27 if ( !sc.isSuccess() )
29 error() <<
"Unable to locate IDataProviderSvc interface" << endmsg;
35 m_outputFile =
new TFile( m_dofileName.value().c_str(),
"RECREATE" );
36 if ( m_outputFile->IsZombie() || !m_outputFile->IsWritable() )
38 error() <<
"Can't open file " << m_dofileName.value() << endmsg;
39 return StatusCode::FAILURE;
42 m_outputTree =
new TTree(
"Event",
"Event" );
43 m_jobInfoTree =
new TTree(
"JobInfoTree",
"Job info" );
46 else if ( m_mode == 3 )
48 error() <<
"The DistBossMode has been abandoned!" << endmsg;
49 return StatusCode::FAILURE;
53 error() <<
"Invalid RunMode @ initialize(): " << m_mode << endmsg;
54 return StatusCode::FAILURE;
58 if ( m_itemNames.empty() )
60 error() <<
"no ItemList from the jobOption" << endmsg;
61 return StatusCode::FAILURE;
65 for (
auto& item : m_itemLists ) {
delete item; }
69 for (
const auto& item : m_itemNames ) { addItem( m_itemLists, item ); }
74 return StatusCode::SUCCESS;
93 if ( findItem( sub_item ) ==
nullptr ) addItem( items, sub_item +
"#1" );
115 info() <<
"In write()" << endmsg;
119 for (
const auto& item : m_itemLists )
121 DataObject* obj =
nullptr;
122 IOpaqueAddress* pAddress =
nullptr;
124 sc = m_pDataProvider->retrieveObject( item->path(), obj );
125 if ( !sc.isSuccess() )
126 { error() <<
"Cannot write mandatory object(s) (Not found): " << item->path() << endmsg; }
129 sc =
dynamic_cast<IConversionSvc*
>( m_cnvSvc )->createRep( obj, pAddress );
132 if ( !sc.isSuccess() )
133 warning() <<
"Failed to create rep for " << item->path() << endmsg;
142 if ( m_commonData.m_rectrackEvt )
143 m_outputTree->Branch(
"TRecEvent",
"TRecTrackEvent", &m_commonData.m_rectrackEvt,
145 if ( m_commonData.m_evtRecObject )
146 m_outputTree->Branch(
"TEvtRecObject",
"TEvtRecObject", &m_commonData.m_evtRecObject,
148 if ( m_commonData.m_dstEvt )
149 m_outputTree->Branch(
"TDstEvent",
"TDstEvent", &m_commonData.m_dstEvt, 3200000, 1 );
150 if ( m_commonData.m_recEvt )
151 m_outputTree->Branch(
"TDigiEvent",
"TDigiEvent", &m_commonData.m_recEvt, 3200000, 1 );
152 if ( m_commonData.m_EvtHeader )
153 m_outputTree->Branch(
"TEvtHeader",
"TEvtHeader", &m_commonData.m_EvtHeader, 3200000,
155 if ( m_commonData.m_EvtNavigator )
156 m_outputTree->Branch(
"TEvtNavigator",
"TEvtNavigator", &m_commonData.m_EvtNavigator,
158 if ( m_commonData.m_hltEvt )
159 m_outputTree->Branch(
"THltEvent",
"THltEvent", &m_commonData.m_hltEvt, 3200000, 1 );
160 if ( m_commonData.m_mcEvt )
161 m_outputTree->Branch(
"TMcEvent",
"TMcEvent", &m_commonData.m_mcEvt, 3200000, 1 );
162 if ( m_commonData.m_trigEvt )
163 m_outputTree->Branch(
"TTrigEvent",
"TTrigEvent", &m_commonData.m_trigEvt, 3200000,
165 m_jobInfoTree->Branch(
"JobInfo", &m_jobInfo );
169 if ( m_outputFile->IsZombie() || !m_outputFile->IsOpen() )
171 error() <<
"Can not write to the file " << m_dofileName << endmsg;
172 return StatusCode::FAILURE;
175 int nb = m_outputTree->Fill();
178 error() <<
"Error in fill tree (EventWriter) " << m_outputTree->GetName() <<
" with "
179 << nb <<
" bytes" << endmsg;
180 return StatusCode::FAILURE;
183 m_outputFile = m_outputTree->GetCurrentFile();
185 else if ( m_mode == 3 )
187 error() <<
"The DistBossMode has been deprecated!" << endmsg;
188 return StatusCode::FAILURE;
191 m_commonData.clear();
193 return StatusCode::SUCCESS;
198 info() <<
"In finalize()" << endmsg;
202 char* bossVer = getenv(
"BES_RELEASE" );
203 info() <<
"fill boss version: " << bossVer << endmsg;
207 auto mgrProp = SmartIF<IProperty>( Gaudi::createApplicationMgr() );
208 mgrProp->getProperty(
"JobOptionsPath", path ).ignore();
210 info() <<
"JobOptions file for current job: " << path << endmsg;
212 ifstream fin( path.c_str() );
215 while ( getline( fin, tempString ) )
217 if ( tempString.size() > 0 && tempString.find(
"//" ) > tempString.size() )
219 jobOptions += tempString;
225 vector<string> jobOptionsVec = { jobOptions };
227 auto jobInfoSvc = service<IDataInfoSvc>(
"DataInfoSvc" );
229 if ( !jobInfoSvc ) warning() <<
"Could not get DataInfoSvc" << endmsg;
232 decayOptions = jobInfoSvc->getDecayOptions();
233 info() <<
"Get decay options: " << decayOptions << endmsg;
236 m_jobInfo->setBossVer( bossVer );
237 m_jobInfo->setJobOptions( jobOptionsVec );
238 m_jobInfo->setDecayOptions( decayOptions );
240 m_jobInfoTree->Fill();
242 m_st = m_outputFile->Write();
245 error() <<
"Can not write to the file " << m_dofileName << endmsg;
246 return StatusCode::FAILURE;
248 m_outputFile->Close();
253 m_outputFile =
nullptr;
254 m_outputTree =
nullptr;
259 error() <<
"The DistBossMode has been deprecated!" << endmsg;
260 return StatusCode::FAILURE;
263 return StatusCode::SUCCESS;