17#include "TObjString.h"
35 for(
auto prop : getProperties()) {
36 if(prop->name() !=
"EvtStore")
continue;
47 evtStore().setTypeAndName(prop.toString());
57 incSvc->removeListener(
this, IncidentType::BeginInputFile );
58 incSvc->addListener(
this, IncidentType::BeginInputFile, 0,
true );
59 incSvc->removeListener(
this, IncidentType::EndInputFile );
60 incSvc->addListener(
this, IncidentType::EndInputFile, 0,
true );
61 incSvc->removeListener(
this,
"MetaDataStop" );
62 incSvc->addListener(
this,
"MetaDataStop", 0,
true );
69 return StatusCode::SUCCESS;
77 return StatusCode::FAILURE;
89 if( inc.type() == IncidentType::BeginInputFile ) {
93 throw std::runtime_error(
"Couldn't call beginInputFile()" );
95 }
else if(inc.type() == IncidentType::EndInputFile ) {
98 throw std::runtime_error(
"Couldn't call endInputFile()" );
100 }
else if(inc.type() ==
"MetaDataStop" ) {
103 throw std::runtime_error(
"Couldn't call metaDataStop()" );
117 return StatusCode::SUCCESS;
125 return StatusCode::SUCCESS;
133 return StatusCode::SUCCESS;
142 return StatusCode::SUCCESS;
153 SmartIF<IProperty> evtSelector{service(evtSelName,
false)};
155 ATH_MSG_ERROR(
"currentFile(): Couldn't find the service: " << evtSelName);
return 0;
160 const StringArrayProperty& inputCollectionsName =
dynamic_cast<const StringArrayProperty&
>(evtSelector->getProperty(
"InputCollections"));
162 ATH_MSG_VERBOSE(
"nOpenFile=" << gROOT->GetListOfFiles()->GetSize() <<
". nFilesInInputCollection=" << inputCollectionsName.value().size());
163 if(
msgLvl(MSG::VERBOSE)) {
164 for(
int i=0;i<gROOT->GetListOfFiles()->GetSize();i++) {
165 ATH_MSG_VERBOSE(
"Open file: " << gROOT->GetListOfFiles()->At(i)->GetName());
171 for(
int i=0;i<gROOT->GetListOfFiles()->GetSize();i++) {
172 TFile *g = (TFile*)gROOT->GetListOfFiles()->At(i);
175 TString s(g->GetName());
176 TObjArray* tokens = s.Tokenize(
"/");
177 TObjString* lastToken =
static_cast<TObjString*
>(tokens->Last());
178 TString sToCompare(
"");
179 bool shortComparison(
false);
180 if(tokens->GetEntries()>1) {
181 TString beforeSlash((
static_cast<TObjString*
>(tokens->At(tokens->GetEntries()-2)))->GetString());
182 if(beforeSlash.Length()>0) sToCompare += beforeSlash;
185 shortComparison=
true;
187 sToCompare += lastToken->GetString();
188 TString sToCompare_short(lastToken->GetString());
191 for(
unsigned int j=0;j<inputCollectionsName.value().
size();j++) {
192 TString t(inputCollectionsName.value()[j].c_str());
195 ATH_MSG_VERBOSE(
"Current File is: " << inputCollectionsName.value()[j]);
199 TObjArray* tokens = t.Tokenize(
"/");
200 TObjString* lastToken =
dynamic_cast<TObjString*
>(tokens->Last());
205 TString tToCompare =
"";
206 bool shortComparison2(
false);
207 if(tokens->GetEntries()>1) {
208 TObjString* beforeSlashStr =
dynamic_cast<TObjString*
>(tokens->At(tokens->GetEntries()-2));
209 if (!beforeSlashStr) {
213 TString beforeSlash(beforeSlashStr->GetString());
214 if(beforeSlash.Length()>0) tToCompare += beforeSlash;
217 shortComparison2=
true;
219 tToCompare += lastToken->GetString();
220 TString tToCompare_short(lastToken->GetString());
223 if(shortComparison || shortComparison2) {
224 if(sToCompare_short.EqualTo(tToCompare_short)) {
225 ATH_MSG_VERBOSE(
"Current File is: " << inputCollectionsName.value()[j]);
230 if(sToCompare.EqualTo(tToCompare)) {
231 ATH_MSG_VERBOSE(
"Current File is: " << inputCollectionsName.value()[j]);
239 ATH_MSG_ERROR(
"currentFile(): Couldn't load InputCollections property of " << evtSelName);
return 0;
242 ATH_MSG_ERROR(
"currentFile(): Could not find the current file!");
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x,...)
#define ATH_MSG_WARNING(x,...)
#define ATH_MSG_VERBOSE(x,...)
#define ATH_MSG_FATAL(x,...)
size_t size() const
Number of registered mappings.
virtual TFile * currentFile(const char *evtSelName="EventSelector") final
Function returning the TFile pointer of the currently open file of the given EventSelector (in athena...
virtual StatusCode beginInputFile()
Function called when a new input file is opened user can read input metadata from inputMetaStore().
virtual StatusCode endInputFile()
Function called as an input file is being closed.
virtual StatusCode sysExecute(const EventContext &) override
override to do firstEvent method
ServiceHandle< StoreGateSvc > m_inputMetaStore
Object accessing the input metadata store.
virtual void handle(const Incident &inc) override
Function receiving incidents from IncidentSvc/TEvent Experts can override but they should ensure they...
virtual StatusCode metaDataStop()
Function called before finalize user can read output metadata from outputMetaStore().
void updateEvtStore(Gaudi::Details::PropertyBase &prop)
ServiceHandle< StoreGateSvc > m_outputMetaStore
Object accessing the output metadata store.
virtual ~AthAnalysisAlgorithm() override
virtual StatusCode firstExecute()
Function called when first execute is encountered user can read event information with evtStore().
virtual StatusCode sysInitialize() override
Function initialising the tool in the correct way in Athena.
AthAnalysisAlgorithm(const std::string &name)
Constructor taking just a name.
virtual StatusCode sysExecute(const EventContext &ctx) override
ServiceHandle< StoreGateSvc > & evtStore()
bool msgLvl(const MSG::Level lvl) const
virtual StatusCode sysInitialize()
Initialization method invoked by the framework.
AthHistogramAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Constructor with parameters:
=============================================================================