ATLAS Offline Software
Classes | Public Member Functions | Private Types | Private Member Functions | Private Attributes | Friends | List of all members
Athena::RootNtupleEventSelector Class Reference

Class implementing the GAUDI IEvtSelector interface using ROOT TTree as a backend. More...

#include <RootNtupleEventSelector.h>

Inheritance diagram for Athena::RootNtupleEventSelector:
Collaboration diagram for Athena::RootNtupleEventSelector:

Classes

struct  CollMetaData
 

Public Member Functions

 RootNtupleEventSelector (const std::string &name, ISvcLocator *svcLoc)
 Constructor with parameters: More...
 
virtual ~RootNtupleEventSelector ()
 Destructor: More...
 
virtual StatusCode initialize () override
 
virtual StatusCode finalize () override
 
virtual void handle (const Incident &incident) override
 
virtual StatusCode io_reinit () override
 Callback method to reinitialize the internal state of the component for I/O purposes (e.g. More...
 
virtual int size (Context &refCtxt) const override
 ICollectionSize interface More...
 
virtual StatusCode createContext (Context *&refpCtxt) const override
 
virtual StatusCode last (Context &refContext) const override
 
virtual StatusCode next (Context &refCtxt) const override
 
virtual StatusCode next (Context &refCtxt, int jump) const override
 
virtual StatusCode previous (Context &refCtxt) const override
 
virtual StatusCode previous (Context &refCtxt, int jump) const override
 
virtual StatusCode rewind (Context &refCtxt) const override
 
virtual StatusCode createAddress (const Context &refCtxt, IOpaqueAddress *&) const override
 
virtual StatusCode releaseContext (Context *&refCtxt) const override
 
virtual StatusCode resetCriteria (const std::string &cr, Context &ctx) const override
 
virtual StatusCode seek (Context &refCtxt, int evtnum) const override
 Seek to a given event number. More...
 
virtual int curEvent (const Context &refCtxt) const override
 return the current event number. More...
 
virtual StatusCode preLoadAddresses (StoreID::type storeID, tadList &list) override
 
virtual StatusCode loadAddresses (StoreID::type storeID, tadList &list) override
 get all new addresses from Provider for this Event. More...
 
virtual StatusCode updateAddress (StoreID::type storeID, SG::TransientAddress *tad, const EventContext &ctx) override
 update a transient Address More...
 

Private Types

typedef ServiceHandle< StoreGateSvcStoreGateSvc_t
 
typedef ServiceHandle< IClassIDSvc > ICLIDSvc_t
 
typedef ServiceHandle< IDictLoaderSvcIDictSvc_t
 
typedef ServiceHandle< IIncidentSvc > IIncSvc_t
 

Private Member Functions

StatusCode endInputFile (RootNtupleEventContext *rctx) const
 
void setupInputCollection (Gaudi::Details::PropertyBase &inputCollectionsName)
 callback to synchronize the list of input files More...
 
StatusCode createRootBranchAddresses (StoreID::type storeID, tadList &tads)
 helper method to create proxies More...
 
TTree * fetchNtuple (const std::string &fname, const std::string &tupleName) const
 helper method to retrieve the correct tuple More...
 
void addMetadataFromDirectoryName (const std::string &metadirname, TFile *fileObj, const std::string &prefix="") const
 
void addMetadataFromDirectory (TDirectoryFile *metadir, const std::string &prefix="") const
 
void addMetadata (TTree *metatree, const std::string &path="") const
 
void addMetadata (TObjString *metastring, const std::string &path="") const
 
StatusCode createMetaDataRootBranchAddresses (StoreGateSvc *store, TTree *tree, const std::string &prefix) const
 helper method to create proxies for the metadata store More...
 
StatusCode do_init_io ()
 helper method to init the i/o components More...
 
void find_coll_idx (int evtidx, long &coll_idx, long &tuple_idx) const
 helper method to get the collection index (into m_inputCollectionsName) and tuple index (into ‘m_tupleNames’) for a given event index evtidx. More...
 
RootNtupleEventSelectorself () const
 non-const access to self (b/c next() is const) More...
 

Private Attributes

StoreGateSvc_t m_dataStore
 Pointer to the StoreGateSvc event store. More...
 
StoreGateSvc_t m_imetaStore
 Pointer to the StoreGateSvc input metadata store. More...
 
StoreGateSvc_t m_ometaStore
 Pointer to the StoreGateSvc output metadata store. More...
 
ICLIDSvc_t m_clidsvc
 Pointer to the IClassIDSvc. More...
 
IDictSvc_t m_dictsvc
 Pointer to the IDictLoaderSvc. More...
 
IIncSvc_t m_incsvc
 Handle to the incident service. More...
 
StringArrayProperty m_inputCollectionsName
 List of input files containing TTree. More...
 
StringProperty m_tupleName
 Name of TTree to load from collection of input files. More...
 
StringArrayProperty m_activeBranchNames
 List of branches to activate in the TTree. More...
 
long m_skipEvts
 Number of events to skip at the beginning. More...
 
std::vector< std::string > m_tupleNames
 Names of all trees over which to iterate. More...
 
long m_nbrEvts
 Number of Events read so far. More...
 
long m_curEvt
 current event index More...
 
std::vector< std::vector< CollMetaData > > m_collEvts
 cache of the number of entries for each collection Indexed like [tuple][collection] More...
 
TTree * m_tuple
 current tree being read More...
 
bool m_needReload
 The (python) selection function to apply on the TChain we are reading. More...
 
bool m_fireBIF
 
std::vector< TFile * > m_files
 

Friends

class Athena::RootNtupleEventContext
 

Detailed Description

Class implementing the GAUDI IEvtSelector interface using ROOT TTree as a backend.

Definition at line 45 of file RootNtupleEventSelector.h.

Member Typedef Documentation

◆ ICLIDSvc_t

Definition at line 195 of file RootNtupleEventSelector.h.

◆ IDictSvc_t

Definition at line 199 of file RootNtupleEventSelector.h.

◆ IIncSvc_t

Definition at line 203 of file RootNtupleEventSelector.h.

◆ StoreGateSvc_t

Definition at line 185 of file RootNtupleEventSelector.h.

Constructor & Destructor Documentation

◆ RootNtupleEventSelector()

Athena::RootNtupleEventSelector::RootNtupleEventSelector ( const std::string &  name,
ISvcLocator *  svcLoc 
)

Constructor with parameters:

Definition at line 222 of file RootNtupleEventSelector.cxx.

223  :
224  extends ( name, svcLoc ),
225  m_dataStore( "StoreGateSvc/StoreGateSvc", name ),
226  m_imetaStore( "StoreGateSvc/InputMetaDataStore", name ),
227  m_ometaStore( "StoreGateSvc/MetaDataStore", name ),
228  m_clidsvc ( "ClassIDSvc", name ),
229  m_dictsvc ( "AthDictLoaderSvc", name ),
230  m_incsvc ( "IncidentSvc", name ),
231  m_nbrEvts ( 0 ),
232  m_curEvt ( 0 ),
233  m_collEvts ( ),
234  m_tuple (NULL),
235  m_needReload (true),
236  m_fireBIF (true)
237 {
238  declareProperty( "DataStore",
239  m_dataStore,
240  "Store where to publish data");
241 
242  declareProperty( "InputMetaStore",
243  m_imetaStore,
244  "Store where to publish (input) metadata");
245 
246  declareProperty( "MetaStore",
247  m_ometaStore,
248  "Store where to publish (output) metadata");
249 
250  declareProperty( "InputCollections",
252  "List of input (ROOT) file names" );
253  m_inputCollectionsName.declareUpdateHandler
255 
256  declareProperty( "TupleName",
257  m_tupleName = "CollectionTree",
258  "Name of the TTree to load/read from input file(s). "
259  "May be a semicolon-separated string to read multiple TTrees.");
260 
261  declareProperty( "SkipEvents",
262  m_skipEvts = 0,
263  "Number of events to skip at the beginning" );
264 
265  declareProperty( "ActiveBranches",
267  "List of branch names to activate" );
268 }

◆ ~RootNtupleEventSelector()

Athena::RootNtupleEventSelector::~RootNtupleEventSelector ( )
virtual

Destructor:

Definition at line 272 of file RootNtupleEventSelector.cxx.

273 {}

Member Function Documentation

◆ addMetadata() [1/2]

void Athena::RootNtupleEventSelector::addMetadata ( TObjString *  metastring,
const std::string &  path = "" 
) const
private

Definition at line 1180 of file RootNtupleEventSelector.cxx.

1181 {
1182  std::string *converted = new std::string(metastring->String());
1183  if (!m_imetaStore->record(converted, path).isSuccess()) {
1184  ATH_MSG_INFO("Could not create metadata for string [" << path << "]");
1185  }
1186 }

◆ addMetadata() [2/2]

void Athena::RootNtupleEventSelector::addMetadata ( TTree *  metatree,
const std::string &  path = "" 
) const
private

Definition at line 1168 of file RootNtupleEventSelector.cxx.

1169 {
1170  if (metatree->GetEntry(0) < 0) {
1171  ATH_MSG_INFO("Problem retrieving data from metadata-tree [" << path << "] !!");
1172  return;
1173  }
1174 
1175  if (!createMetaDataRootBranchAddresses(m_imetaStore.get(), metatree, path).isSuccess()) {
1176  ATH_MSG_INFO("Could not create metadata for tree [" << path << "]");
1177  }
1178 }

◆ addMetadataFromDirectory()

void Athena::RootNtupleEventSelector::addMetadataFromDirectory ( TDirectoryFile *  metadir,
const std::string &  prefix = "" 
) const
private

Definition at line 1125 of file RootNtupleEventSelector.cxx.

1126 {
1127  std::unordered_set<std::string> meta_keys;
1128  const TList *keys = metadir->GetListOfKeys();
1129  for (Int_t i=0; i < keys->GetSize(); ++i) {
1130  TKey* key = dynamic_cast<TKey*>(keys->At(i));
1131  if (!key) {
1132  continue;
1133  }
1134 
1135  const std::string meta_key = key->GetName();
1136  if (meta_keys.find(meta_key) != meta_keys.end()) {
1137  // meta_key is another cycle from a previous key entry.
1138  // *ASSUME* the highest cycle is the one we are interested in
1139  // *AND* that it was the previous one...
1140  continue;
1141  } else {
1142  meta_keys.insert(meta_key);
1143  }
1144 
1145  std::string fullPrefix(prefix);
1146  if (prefix != "") fullPrefix += "/";
1147  const std::string path = fullPrefix + key->GetName();
1148 
1149  TString fullKeyName(TString::Format("%s;%hi", key->GetName(), key->GetCycle()));
1150  TObject *objRef = metadir->Get(fullKeyName);
1151 
1152  TTree *metatree = dynamic_cast<TTree*>(objRef);
1153  if (metatree) {
1154  addMetadata(metatree, path);
1155  continue;
1156  }
1157 
1158  TObjString *metaObjString = dynamic_cast<TObjString*>(objRef);
1159  if (metaObjString) {
1160  addMetadata(metaObjString, path);
1161  continue;
1162  }
1163 
1164  ATH_MSG_WARNING("Unsupported metadata type: " << objRef->ClassName());
1165  }
1166 }

◆ addMetadataFromDirectoryName()

void Athena::RootNtupleEventSelector::addMetadataFromDirectoryName ( const std::string &  metadirname,
TFile *  fileObj,
const std::string &  prefix = "" 
) const
private

Definition at line 1118 of file RootNtupleEventSelector.cxx.

1119 {
1120  TDirectoryFile *metadir = (TDirectoryFile*)fileObj->Get(metadirname.c_str());
1121  if (!metadir) return;
1122  addMetadataFromDirectory(metadir, prefix);
1123 }

◆ createAddress()

StatusCode Athena::RootNtupleEventSelector::createAddress ( const Context &  refCtxt,
IOpaqueAddress *&   
) const
overridevirtual

Definition at line 639 of file RootNtupleEventSelector.cxx.

641 {
642  //std::cerr << "::TTES::createAddress()...\n";
643  return StatusCode::SUCCESS;
644 }

◆ createContext()

StatusCode Athena::RootNtupleEventSelector::createContext ( Context *&  refpCtxt) const
overridevirtual

IEvtSelector interface

Definition at line 631 of file RootNtupleEventSelector.cxx.

632 {
633  RootNtupleEventContext *ctx = new RootNtupleEventContext(this);
634  refCtx = ctx;
635  return StatusCode::SUCCESS;
636 }

◆ createMetaDataRootBranchAddresses()

StatusCode Athena::RootNtupleEventSelector::createMetaDataRootBranchAddresses ( StoreGateSvc store,
TTree *  tree,
const std::string &  prefix 
) const
private

helper method to create proxies for the metadata store

Definition at line 952 of file RootNtupleEventSelector.cxx.

955 {
956  if (0 == store) {
957  ATH_MSG_ERROR("null pointer to store !");
958  return StatusCode::FAILURE;
959  }
960 
961  if (0 == tree) {
962  ATH_MSG_ERROR("null pointer to n-tuple !");
963  return StatusCode::FAILURE;
964  }
965 
966  // Record tree in Storegate for later writing
967  TransferTree* temp = new TransferTree(tree);
968  if (store->record(temp,prefix).isFailure()) ATH_MSG_ERROR("Unable to record metadata tree " << tree->GetName());
969 
970  const std::string tree_name = tree->GetName();
971  TObjArray *branches = tree->GetListOfBranches();
972  if (!branches) {
973  ATH_MSG_INFO("no branches!!");
974  return StatusCode::SUCCESS;
975  }
976 
977  // loop over branches
978  for (Int_t i = 0; i < branches->GetEntries(); ++i) {
979  TBranch *branch = (TBranch *)branches->At(i);
980  if (branch) {
981 
982  CLID id = 0;
983  const void* value_ptr = tree;
984  const std::string type_name = branch->GetClassName();
985  const std::string br_name = branch->GetName();
986  const std::string sg_key = prefix.empty()
987  ? br_name
988  : prefix + "/" + br_name;
989  TClass *cls = NULL;
990  if (!type_name.empty()) {
991  cls = TClass::GetClass(type_name.c_str());
992  }
993  const std::type_info *ti = 0;
994 
995  if (cls) {
996  ti = cls->GetTypeInfo();
997  // first, try to load a dict for that class...
998  if (ti) {
999  m_dictsvc->load_type(*ti);
1000  }
1001  if (!ti) {
1002  ATH_MSG_WARNING("could not find a type-info for [" <<
1003  type_name << "]");
1004  continue;
1005  }
1006  std::string ti_typename = System::typeinfoName(*ti);
1007  if (!m_clidsvc->getIDOfTypeInfoName(ti_typename, id)
1008  .isSuccess()) {
1009  // try another one...
1010  {
1011  // Protect against data race inside TClassEdit.
1012  // https://github.com/root-project/root/issues/10353
1013  // Should be fixed in root 6.26.02.
1014  R__WRITE_LOCKGUARD(ROOT::gCoreMutex);
1015  ti_typename = TClassEdit::ShortType(ti_typename.c_str(),
1016  TClassEdit::kDropAllDefault);
1017  }
1018  if (!m_clidsvc->getIDOfTypeInfoName(ti_typename, id)
1019  .isSuccess()) {
1020  ATH_MSG_INFO("** could not find a CLID from type-info ["
1021  << System::typeinfoName(*ti) << "]");
1022  ATH_MSG_INFO("** could not find a CLID from type-info-alias ["
1023  << ti_typename << "]");
1024  continue;
1025  }
1026  }
1027  } else {
1028  // probably a built-in type...
1029  TObjArray *leaves = branch->GetListOfLeaves();
1030  if (leaves &&
1031  leaves->GetEntries() == 1) {
1032  const std::string type_name = ((TLeaf*)leaves->At(0))->GetTypeName();
1033  if (!m_clidsvc->getIDOfTypeName(::root_typename(type_name), id)
1034  .isSuccess()) {
1035  ATH_MSG_INFO("** could not find a CLID for type-name ["
1036  << type_name << "]");
1037  continue;
1038  }
1039  }
1040  }
1041  if (id == 0) {
1042  ATH_MSG_INFO("** could not find a CLID for type-name ["
1043  << type_name << "]");
1044  continue;
1045  }
1047  (ROOT_StorageType, id,
1048  tree_name,
1049  br_name,
1050  (unsigned long)(value_ptr),
1051  (unsigned long)(0));
1052  if (!store->recordAddress(sg_key, addr, true).isSuccess()) {
1053  ATH_MSG_ERROR("could not record address at [" << sg_key << "] in store ["
1054  << store->name() << "]");
1055  delete addr; addr = 0;
1056  }
1057  // SG::TransientAddress* taddr = new SG::TransientAddress
1058  // (id, sg_key, addr);
1059  // taddr->setProvider(this);
1060  // taddr->clearAddress(true);
1061  // tads.push_back(taddr);
1062  }
1063  }
1064  return StatusCode::SUCCESS;
1065 }

◆ createRootBranchAddresses()

StatusCode Athena::RootNtupleEventSelector::createRootBranchAddresses ( StoreID::type  storeID,
tadList &  tads 
)
private

helper method to create proxies

Definition at line 839 of file RootNtupleEventSelector.cxx.

841 {
842  if (storeID != StoreID::EVENT_STORE) {
843  ATH_MSG_INFO("-- not the event-store --");
844  return(StatusCode::SUCCESS);
845  }
846 
847  if (0 == m_tuple) {
848  ATH_MSG_ERROR("null pointer to n-tuple !");
849  return StatusCode::FAILURE;
850  }
851 
852  TObjArray *leaves = m_tuple->GetListOfLeaves();
853  if (!leaves) {
854  ATH_MSG_INFO("no leaves!!");
855  return StatusCode::SUCCESS;
856  }
857 
858  // loop over leaves
859  for (Int_t i = 0; i < leaves->GetEntries(); ++i) {
860  TLeaf *leaf = (TLeaf *)leaves->At(i);
861  TBranch *branch = leaf->GetBranch();
862  if (branch) {
863 
864  CLID id = 0;
865  const void* value_ptr = m_tuple;
866  const std::string type_name = leaf->GetTypeName();
867  const std::string br_name = branch->GetName();
868  const std::string sg_key = br_name;//m_tupleName.value()+"/"+br_name;
869  TClass *cls = TClass::GetClass(type_name.c_str());
870  const std::type_info *ti = 0;
871 
872  if (cls) {
873  ti = cls->GetTypeInfo();
874  // first, try to load a dict for that class...
875  if (ti) {
876  m_dictsvc->load_type(*ti);
877  }
878  if (!ti) {
879  ATH_MSG_WARNING("could not find a type-info for [" <<
880  type_name << "]");
881  continue;
882  }
883  std::string ti_typename = System::typeinfoName(*ti);
884  if (!m_clidsvc->getIDOfTypeInfoName(ti_typename, id)
885  .isSuccess()) {
886  // try another one...
887  {
888  // Protect against data race inside TClassEdit.
889  // https://github.com/root-project/root/issues/10353
890  // Should be fixed in root 6.26.02.
891  R__WRITE_LOCKGUARD(ROOT::gCoreMutex);
892  ti_typename = TClassEdit::ShortType(ti_typename.c_str(),
893  TClassEdit::kDropAllDefault);
894  }
895  if (!m_clidsvc->getIDOfTypeInfoName(ti_typename, id)
896  .isSuccess()) {
897  ATH_MSG_DEBUG("** could not find a CLID from type-info ["
898  << System::typeinfoName(*ti) << "]");
899  ATH_MSG_DEBUG("** could not find a CLID from type-info-alias ["
900  << ti_typename << "]");
901  continue;
902  }
903  }
904  } else {
905  // probably a built-in type...
906  if (!m_clidsvc->getIDOfTypeName(::root_typename(type_name), id)
907  .isSuccess()) {
908  ATH_MSG_DEBUG("** could not find a CLID for type-name ["
909  << type_name << "]");
910  continue;
911  }
912  }
913  if (id == 0) {
914  ATH_MSG_DEBUG("** could not find a CLID for type-name ["
915  << type_name << "]");
916  continue;
917  }
919  (ROOT_StorageType, id,
920  m_tuple->GetName(),
921  br_name,
922  (unsigned long)(value_ptr),
923  (unsigned long)(m_curEvt-1));
924 
925  // recycle old rootaddress, if any.
926  SG::DataProxy* proxy = m_dataStore->proxy (id, sg_key);
927  if (proxy) {
928  proxy->setAddress (addr);
929  }
930  else {
931  auto taddr = new SG::TransientAddress(id, sg_key, addr, false);
932  taddr->setProvider(this, storeID);
933  // only add the *new* TransientAddress to the input list as the *old* ones
934  // are already tracked by the datastore (via the sticky proxies)
935  tads.push_back(taddr);
936  }
937  }
938  }
939  m_needReload = false;
940  // remember that we need to fire a BeginInputFile incident.
941  // we can't fire it just now as some client may need the tree and its
942  // content loaded in the evtstore when their ::handle method is
943  // called.
944  // so we do it later.
945  //MOVED TO handle method - which is fired on BeginEvent after StoreGateSvc
946  //m_fireBIF = true;
947 
948  return StatusCode::SUCCESS;
949 }

◆ curEvent()

int Athena::RootNtupleEventSelector::curEvent ( const Context &  refCtxt) const
overridevirtual

return the current event number.

Returns
The current event number.

Definition at line 722 of file RootNtupleEventSelector.cxx.

723 {
724  return m_curEvt;
725 }

◆ do_init_io()

StatusCode Athena::RootNtupleEventSelector::do_init_io ( )
private

helper method to init the i/o components

Definition at line 1189 of file RootNtupleEventSelector.cxx.

1190 {
1191  // std::cout << "::fetchNtuple..." << std::endl;
1192 
1193  // initialize some helper structures and data
1194  {
1195  CollMetaData zero;
1196  zero.min_entries = -1;
1197  zero.max_entries = -1;
1198  zero.entries = -1;
1199  m_collEvts.resize (m_tupleNames.size());
1200  for (size_t i = 0; i < m_collEvts.size(); i++) {
1201  m_collEvts[i].resize(m_inputCollectionsName.value().size(), zero);
1202  }
1203  }
1204 
1206  m_tupleNames[0]);
1207  if (!m_tuple) {
1208  throw "RootNtupleEventSelector: Unable to fetch Ntuple";
1209  }
1210 
1211  // std::cout << "::clear-root-addresses..." << std::endl;
1212  // reset the list of branches
1213  m_needReload = true;
1214 
1215  // skip events we are asked to skip
1216  m_curEvt = m_skipEvts;
1217  m_nbrEvts = 0;
1218 
1219  // std::cout << "::fetchNtuple...[done]" << std::endl;
1220  return StatusCode::SUCCESS;
1221 }

◆ endInputFile()

StatusCode Athena::RootNtupleEventSelector::endInputFile ( RootNtupleEventContext rctx) const
private

Definition at line 426 of file RootNtupleEventSelector.cxx.

427 {
428  const FileNames_t& fnames = rctx->files();
429  std::size_t fidx = rctx->fileIndex();
430  m_incsvc->fireIncident(FileIncident(name(), "EndInputFile", fnames[fidx]));
431 
432  // prepare for next file, if any...
433  // std::cout << "=========================================================="
434  // << std::endl;
435  // std::cerr << "::switch to next file...\n";
436 
437  // iterate over proxies and
438  // mark as garbage and drop the RootBranchAddress (as a side effect of
439  // ::setAddress(NULL).
440  // this way, the next time we hit ::createRootBranchAddress or ::updateAddress
441  // all internal states are kosher.
442  for (const SG::DataProxy* cdp : m_dataStore->proxies()) {
443  if (dynamic_cast<Athena::RootBranchAddress*> (cdp->address()) != nullptr) {
444  if (SG::DataProxy* dp = m_dataStore->proxy_exact (cdp->sgkey())) {
445  dp->setAddress (nullptr);
446  }
447  }
448  }
449 
450  const bool forceRemove = false;
451  CHECK( m_dataStore->clearStore(forceRemove) ); //must clear the storegate so that any tampering user did in EndInputFile incident is cleared
452  m_needReload = true;m_fireBIF=true;
453 
454  return StatusCode::SUCCESS;
455 }

◆ fetchNtuple()

TTree * Athena::RootNtupleEventSelector::fetchNtuple ( const std::string &  fname,
const std::string &  tupleName 
) const
private

helper method to retrieve the correct tuple

Definition at line 1068 of file RootNtupleEventSelector.cxx.

1070 {
1071  // std::cout << "::fetchNtuple(" << fname << ")..." << std::endl;
1072  TTree* tree = NULL;
1073  RootGlobalsRestore rgr;
1074  // std::cout << "::TFile::Open()..." << std::endl;
1075  TFile *f = (TFile*)gROOT->GetListOfFiles()->FindObject(fname.c_str());
1076  TFile* fnew = nullptr;
1077  if (!f) {
1078  f = TFile::Open(fname.c_str(), "READ");
1079  fnew = f;
1080  if (f) {
1081  f->SetName(fname.c_str());
1082  }
1083  }
1084  if (!f || f->IsZombie()) {
1085  ATH_MSG_ERROR("could not open next file in input collection ["
1086  << fname << "]");
1087  if (f) {
1088  f->Close();
1089  }
1090  return tree;
1091  }
1092  // std::cout << "::TFile::GetTree(" << m_tupleName << ")..." << std::endl;
1093  tree = (TTree*)f->Get(tupleName.c_str());
1094  if (!tree) {
1095  ATH_MSG_ERROR("could not retrieve tree [" << tupleName << "]"
1096  << " from file [" << fname << "]");
1097  f->Close();
1098  return tree;
1099  }
1100 
1101  if (fnew)
1102  m_files.push_back(fnew);
1103 
1104  // std::cout << "::TTree::SetBranchStatus()..." << std::endl;
1105  // disable all branches
1106  tree->SetBranchStatus("*", 0);
1107 
1108  if (!m_imetaStore->clearStore().isSuccess()) {
1109  ATH_MSG_INFO("could not clear store [" << m_imetaStore.typeAndName() << "]");
1110  return tree;
1111  }
1112 
1113  addMetadataFromDirectoryName(tupleName+"Meta", f);
1114  addMetadataFromDirectoryName("Lumi", f, "Lumi");
1115  return tree;
1116 }

◆ finalize()

StatusCode Athena::RootNtupleEventSelector::finalize ( )
overridevirtual

Definition at line 405 of file RootNtupleEventSelector.cxx.

406 {
407  ATH_MSG_INFO ("Finalize...");
408  // FIXME: this should be tweaked/updated if/when a selection function
409  // or filtering predicate is applied (one day?)
410  ATH_MSG_INFO ("Total events read: " << (m_nbrEvts - m_skipEvts));
411 
412  // Explicitly delete all the files we created.
413  // If we leave it up to root, then xrootd can get cleaned up before
414  // the root destructors run, leading to a crash.
415  for (TFile* f : m_files)
416  delete f;
417  m_files.clear();
418 
419  return StatusCode::SUCCESS;
420 }

◆ find_coll_idx()

void Athena::RootNtupleEventSelector::find_coll_idx ( int  evtidx,
long &  coll_idx,
long &  tuple_idx 
) const
private

helper method to get the collection index (into m_inputCollectionsName) and tuple index (into ‘m_tupleNames’) for a given event index evtidx.

returns -1 if not found.

Definition at line 1228 of file RootNtupleEventSelector.cxx.

1231 {
1232  coll_idx = -1;
1233  tuple_idx = -1;
1234 
1235  // std::cout << "--find_coll_idx(" << evtidx << ")..." << std::endl
1236  // << "--collsize: " << m_collEvts.size() << std::endl;
1237  for (size_t ituple = 0; ituple < m_collEvts.size(); ++ituple) {
1238  for (size_t icoll = 0; icoll < m_collEvts[ituple].size(); ++icoll) {
1239  CollMetaData &itr = m_collEvts[ituple][icoll];
1240  if (itr.min_entries == -1) {
1241  TTree *tree = fetchNtuple(m_inputCollectionsName.value()[icoll],
1242  m_tupleNames[ituple]);
1243  if (tree) {
1244  long offset = 0;
1245  if (icoll > 0) {
1246  offset = m_collEvts[ituple][icoll-1].max_entries;
1247  }
1248  else if (ituple > 0) {
1249  offset = m_collEvts[ituple-1].back().max_entries;
1250  }
1251  itr.entries = tree->GetEntriesFast();
1252  itr.min_entries = offset;
1253  itr.max_entries = offset + itr.entries;
1254  } else {
1255  throw "RootNtupleEventSelector: Unable to fetch ntuple";
1256  }
1257  }
1258  // std::cout << "--[" << i << "] => [" << itr.min_entries << ", "
1259  // << itr.max_entries << ") evtidx=[" << evtidx << "]"
1260  // << std::endl;
1261  if (itr.min_entries <= evtidx && evtidx < itr.max_entries) {
1262  coll_idx = icoll;
1263  tuple_idx = ituple;
1264  return;
1265  }
1266  }
1267  }
1268 }

◆ handle()

void Athena::RootNtupleEventSelector::handle ( const Incident &  incident)
overridevirtual

Definition at line 1279 of file RootNtupleEventSelector.cxx.

1279  {
1280  if(m_fireBIF && incident.type() == IncidentType::BeginEvent) {
1281  //fire the BeginInputFile
1282  m_incsvc->fireIncident(FileIncident(name(), "BeginInputFile", m_tuple->GetCurrentFile()->GetName()));
1283  m_fireBIF=false;
1284  }
1285 }

◆ initialize()

StatusCode Athena::RootNtupleEventSelector::initialize ( )
overridevirtual

Definition at line 275 of file RootNtupleEventSelector.cxx.

276 {
277  ATH_MSG_INFO ("Enter RootNtupleEventSelector initialization...");
278 
279  // retrieve clidsvc
280  if ( !m_clidsvc.retrieve().isSuccess() ) {
282  ("Could not retrieve [" << m_clidsvc.typeAndName() << "]");
283  return StatusCode::FAILURE;
284  }
285 
286  // retrieve dictsvc
287  if ( !m_dictsvc.retrieve().isSuccess() ) {
289  ("Could not retrieve [" << m_dictsvc.typeAndName() << "]");
290  return StatusCode::FAILURE;
291  }
292 
293  typedef boost::tokenizer<boost::char_separator<char> > tokenizer;
294  boost::char_separator<char> sep (" ;");
295  tokenizer tokens (m_tupleName.value(), sep);
296  m_tupleNames.assign (tokens.begin(), tokens.end());
297 
298  if ( m_tupleNames.empty() ) {
300  ("You have to give a TTree name to read from the ROOT files !");
301  return StatusCode::FAILURE;
302  }
303 
304  CHECK( m_incsvc.retrieve() );
305  m_incsvc->addListener(this,IncidentType::BeginEvent,99); //used to trigger BeginInputFile on start of first event of file - 99 priority so AFTER storegatesvc done
306 
307 
309  const std::size_t nbrInputFiles = m_inputCollectionsName.value().size();
310  if ( nbrInputFiles < 1 ) {
312  ("You need to give at least 1 input file !!" << endmsg
313  << "(Got [" << nbrInputFiles << "] file instead !)");
314  return StatusCode::FAILURE;
315  } else {
317  ("Selector configured to read [" << nbrInputFiles << "] file(s)..."
318  << endmsg
319  << " TTree [" << m_tupleName.value() << "]");
320  }
321 
322  {
323  // register this service for 'I/O' events
324  ServiceHandle<IIoComponentMgr> iomgr("IoComponentMgr", name());
325  if (!iomgr.retrieve().isSuccess()) {
326  ATH_MSG_FATAL("Could not retrieve IoComponentMgr !");
327  return StatusCode::FAILURE;
328  }
329  if (!iomgr->io_register(this).isSuccess()) {
330  ATH_MSG_FATAL("Could not register myself with the IoComponentMgr !");
331  return StatusCode::FAILURE;
332  }
333  // register input file's names with the I/O manager
334  const std::vector<std::string>& incol = m_inputCollectionsName.value();
335  bool allGood = true;
336  for (std::size_t icol = 0, imax = incol.size(); icol < imax; icol++) {
337  if (!iomgr->io_register(this,
339  incol[icol]).isSuccess()) {
340  ATH_MSG_FATAL("could not register [" << incol[icol] << "] for output !");
341  allGood = false;
342  } else {
343  ATH_MSG_VERBOSE("io_register[" << this->name() << "](" << incol[icol] << ") [ok]");
344  }
345  }
346  if (!allGood) {
347  return StatusCode::FAILURE;
348  }
349  }
350 
351  if (!do_init_io().isSuccess()) {
352  return StatusCode::FAILURE;
353  }
354 
355  // retrieve event store
356  // this needs to happen *after* having initialized the i/o
357  // as our branches (which need a valid m_ntuple pointer)
358  // may be asked to be registered as we are a ProxyProvider.
359  // retrieving the event store will poke the ProxyProviderSvc...
360  /*
361  if ( !m_dataStore.retrieve().isSuccess() ) {
362  ATH_MSG_ERROR
363  ("Could not retrieve [" << m_dataStore.typeAndName() << "] !!");
364  return StatusCode::FAILURE;
365  }
366 
367  // ditto for (input) meta data store
368  if (!m_imetaStore.retrieve().isSuccess()) {
369  ATH_MSG_ERROR
370  ("Could not retrieve [" << m_imetaStore.typeAndName() << "] !!");
371  return StatusCode::FAILURE;
372  }
373 
374  // ditto for (output) meta data store
375  if (!m_ometaStore.retrieve().isSuccess()) {
376  ATH_MSG_ERROR
377  ("Could not retrieve [" << m_ometaStore.typeAndName() << "] !!");
378  return StatusCode::FAILURE;
379  }
380  */
381 
382  //ensure the Athena::NtupleCnvSvc is in the EventPersistencySvc
383  ServiceHandle<IProperty> epSvc("EventPersistencySvc",name());
384  std::vector<std::string> propVal;
385  CHECK( Gaudi::Parsers::parse( propVal , epSvc->getProperty("CnvServices").toString() ) );
386  bool foundSvc(false);
387  for(const std::string& s : propVal) {
388  if(s=="Athena::xAODCnvSvc") { foundSvc=true; break; }
389  }
390  if(!foundSvc) {
391  propVal.push_back("Athena::NtupleCnvSvc");
392  CHECK( epSvc->setProperty("CnvServices", Gaudi::Utils::toString( propVal ) ));
393  }
394 
395  //we should also add ourself as a proxy provider
396  ServiceHandle<IProxyProviderSvc> ppSvc("ProxyProviderSvc",name());
397  CHECK( ppSvc.retrieve() );
398  ppSvc->addProvider( this );
399 
400 
401 
402  return StatusCode::SUCCESS;
403 }

◆ io_reinit()

StatusCode Athena::RootNtupleEventSelector::io_reinit ( )
overridevirtual

Callback method to reinitialize the internal state of the component for I/O purposes (e.g.

upon fork(2))

Definition at line 730 of file RootNtupleEventSelector.cxx.

731 {
732  ATH_MSG_INFO("I/O reinitialization...");
733 
734  ServiceHandle<IIoComponentMgr> iomgr("IoComponentMgr", name());
735  if (!iomgr.retrieve().isSuccess()) {
736  ATH_MSG_FATAL("Could not retrieve IoComponentMgr !");
737  return StatusCode::FAILURE;
738  }
739  if (!iomgr->io_hasitem(this)) {
740  ATH_MSG_FATAL("IoComponentMgr does not know about myself !");
741  return StatusCode::FAILURE;
742  }
743  std::vector<std::string> inputCollections = m_inputCollectionsName.value();
744 
745  for (std::size_t
746  i = 0,
747  imax = m_inputCollectionsName.value().size();
748  i < imax;
749  ++i) {
750  std::string &fname = inputCollections[i];
751  // std::cout << "--retrieve new name for [" << fname << "]...\n";
752  if (!iomgr->io_contains(this, fname)) {
753  ATH_MSG_ERROR("IoComponentMgr does not know about [" << fname << "] !");
754  return StatusCode::FAILURE;
755  }
756  if (!iomgr->io_retrieve(this, fname).isSuccess()) {
757  ATH_MSG_FATAL("Could not retrieve new value for [" << fname << "] !");
758  return StatusCode::FAILURE;
759  }
760  // std::cout << "--> [" << fname << "]\n" << std::flush;
761  }
762  // all good... copy over.
764 
765  // remove our EventInfo if any...
766  // {
767  // const bool force_remove = true;
768  // if (!m_dataStore->clearStore(force_remove).isSuccess()) {
769  // ATH_MSG_ERROR("could not clear event store!");
770  // return StatusCode::FAILURE;
771  // } else {
772  // ATH_MSG_INFO("sgdump: \n" << m_dataStore->dump());
773  // }
774  // }
775 
776  // std::cout << "--> do_init_io...\n" << std::flush;
777  if (!do_init_io().isSuccess()) {
778  return StatusCode::FAILURE;
779  }
780 
781  ATH_MSG_INFO("I/O reinitialization... [done]");
782  return StatusCode::SUCCESS;
783 }

◆ last()

StatusCode Athena::RootNtupleEventSelector::last ( Context &  refContext) const
overridevirtual

Definition at line 617 of file RootNtupleEventSelector.cxx.

618 {
619  ATH_MSG_ERROR ("............. Last Event Not Implemented .............");
620  return StatusCode::FAILURE;
621 }

◆ loadAddresses()

StatusCode Athena::RootNtupleEventSelector::loadAddresses ( StoreID::type  storeID,
tadList &  list 
)
overridevirtual

get all new addresses from Provider for this Event.

Definition at line 801 of file RootNtupleEventSelector.cxx.

802 {
803  if (m_needReload) {
804  return createRootBranchAddresses(storeID, tads);
805  }
806 
807  return StatusCode::SUCCESS;
808 }

◆ next() [1/2]

StatusCode Athena::RootNtupleEventSelector::next ( IEvtSelector::Context &  ctx) const
overridevirtual

Definition at line 458 of file RootNtupleEventSelector.cxx.

459 {
460  // std::cout << "::next(fidx=" << ctx->fileIndex() << ", eidx=" << m_curEvt << ")"
461  // << std::endl;
462  ATH_MSG_DEBUG ("next() : iEvt " << m_curEvt);
463 
464  // get evt context
465  RootNtupleEventContext* rctx = dynamic_cast<RootNtupleEventContext*>(&ctx);
466  if ( 0 == rctx ) {
467  ATH_MSG_ERROR ("Could not dyn-cast to RootNtupleEventContext !!");
468  throw "RootNtupleEventSelector: Unable to get RootNtupleEventContext";
469  }
470 
471  TTree *tree = rctx->tree();
472  if (!tree) {
473  const FileNames_t& fnames = rctx->files();
474  std::size_t fidx = rctx->fileIndex();
475  rctx->setTree(NULL);
476  //rctx->setEntry(-1);
477 
478  while (!tree && rctx->tupleIndex() < m_tupleNames.size()) {
479  if (fidx < rctx->files().size()) {
480  const std::string& fname = fnames[fidx];
481  tree = fetchNtuple(fname, m_tupleNames[rctx->tupleIndex()]);
482  if (!tree) {
483  throw "RootNtupleEventSelector: Unable to get tree";
484  }
485  rctx->setTree(tree);
486 
487  }
488  else {
489  // end of collections; go to next tuple.
490  rctx->setTupleIndex (rctx->tupleIndex()+1);
491  rctx->setFileIndex (0);
492  fidx = 0;
493  }
494  }
495 
496  if (!tree) {
497  return StatusCode::FAILURE;
498  }
499  }
500  int64_t global_entry = rctx->entry();
501  size_t collIdx = rctx->fileIndex();
502  size_t tupleIdx = rctx->tupleIndex();
503  int64_t entry = global_entry;
504  if (m_collEvts[tupleIdx][collIdx].min_entries < 0) {
505  // need to trigger collmetadata...
506  long coll_idx, tuple_idx;
507  const_cast<RootNtupleEventSelector*>(this)->find_coll_idx(entry,
508  coll_idx,
509  tuple_idx);
510  }
511  // rctx::entry is the *global* entry number.
512  // we need the local one...
513  entry = global_entry - m_collEvts[tupleIdx][collIdx].min_entries;
514 
515  Long64_t nentries = tree->GetEntriesFast();
516  // std::cout << "::entry=" << global_entry
517  // << ", nentries=" << nentries
518  // << ", local=" << entry
519  // << " (min=" << m_collEvts[collIdx].min_entries
520  // << ", max=" << m_collEvts[collIdx].max_entries << ")"
521  // << " (tree=" << tree << ")"
522  // << std::endl;
523  if ( nentries > entry ) {
524 
525  // load data from tuple
526  //std::cout << "--load-data--" << " " << tree->GetReadEntry() << std::endl;
527  if (tree->LoadTree(entry) < 0) {
529  ("Problem loading tree for event [" << m_curEvt << "] !!");
530  throw "RootNtupleEventSelector: Problem loading input tree";
531  } else {
532  ATH_MSG_DEBUG("==> loaded-tree(" << m_curEvt << ")");
533  }
534 
535  ++m_nbrEvts;
536  m_curEvt = global_entry + 1;
537 
538  // std::cout << "--event-info--" << std::endl;
539  // event info
540  EventType* evtType = new EventType;
541  const std::size_t runNbr = 0;
542  EventInfo* evtInfo = new EventInfo(new EventID(runNbr, m_curEvt-1, 0), evtType);
543  if ( !m_dataStore->record( evtInfo, "TTreeEventInfo" ).isSuccess() ) {
544  ATH_MSG_ERROR ("Could not record TTreeEventInfo !");
545  delete evtInfo; evtInfo = 0;
546  return StatusCode::FAILURE;
547  }
548 
549  {
550  auto ei = std::make_unique<xAOD::EventInfo>();
551  auto ei_store = std::make_unique<xAOD::EventAuxInfo>();
552  ei->setStore (ei_store.get());
553  ei->setRunNumber (runNbr);
554  ei->setEventNumber (global_entry);
555 
556  static const SG::AuxElement::Accessor<std::string> tupleName ("tupleName");
557  static const SG::AuxElement::Accessor<std::string> collName ("collectionName");
558  tupleName(*ei) = m_tupleNames[tupleIdx];
559  collName(*ei) = m_inputCollectionsName[collIdx];
560 
561  CHECK( m_dataStore->record (std::move(ei), "EventInfo") );
562  CHECK( m_dataStore->record (std::move(ei_store), "EventInfoAux.") );
563  }
564 
565  // now the data has been loaded into the store, we can
566  // notify clients and fire the BeginInputFile incident
567  //MOVED TO handle method
568  /*if (m_fireBIF) {
569  m_fireBIF = false;
570  const FileNames_t& fnames = rctx->files();
571  std::size_t fidx = rctx->fileIndex();
572  const std::string& fname = fnames[fidx];
573  // notify other clients
574  // std::cout << "::switchED to next file..." << std::endl;
575  m_incsvc->fireIncident(FileIncident(name(), "BeginInputFile", fname));
576  // std::cerr << ":: new file: [" << fname << "]\n";
577  }*/
578  return StatusCode::SUCCESS;
579 
580  } else {
581  // file is depleted
582  CHECK( endInputFile (rctx) );
583  rctx->setFileIndex (rctx->fileIndex() + 1);
584  rctx->setTree(NULL);
585  return next(*rctx);
586  }
587 
588  // NOT REACHED
589  // std::cout << "***end of collections***" << std::endl;
590  // end of collections
591  //return StatusCode::FAILURE;
592 }

◆ next() [2/2]

StatusCode Athena::RootNtupleEventSelector::next ( Context &  refCtxt,
int  jump 
) const
overridevirtual

Definition at line 594 of file RootNtupleEventSelector.cxx.

595 {
596  ATH_MSG_DEBUG ("next(" << jump << ") : iEvt " << m_curEvt);
597 
598  if (self()->seek(ctx, m_curEvt + jump).isSuccess()) {
599  return StatusCode::FAILURE;
600  }
601  return next(ctx);
602 }

◆ preLoadAddresses()

StatusCode Athena::RootNtupleEventSelector::preLoadAddresses ( StoreID::type  storeID,
tadList &  list 
)
overridevirtual

IAddressProvider interface get all addresses from Provider : Called before Begin Event

Definition at line 790 of file RootNtupleEventSelector.cxx.

792 {
793  // std::cerr << "TTES::preLoadAddresses(" << int(storeID)
794  // << "," << tads.size()
795  // << ")...\n";
796  return StatusCode::SUCCESS;
797 }

◆ previous() [1/2]

StatusCode Athena::RootNtupleEventSelector::previous ( IEvtSelector::Context &  ctx) const
overridevirtual

Definition at line 605 of file RootNtupleEventSelector.cxx.

606 {
607  return next( ctx, -1 );
608 }

◆ previous() [2/2]

StatusCode Athena::RootNtupleEventSelector::previous ( Context &  refCtxt,
int  jump 
) const
overridevirtual

Definition at line 611 of file RootNtupleEventSelector.cxx.

612 {
613  return next( ctx, -jump );
614 }

◆ releaseContext()

StatusCode Athena::RootNtupleEventSelector::releaseContext ( Context *&  refCtxt) const
overridevirtual

Definition at line 647 of file RootNtupleEventSelector.cxx.

648 {
649  RootNtupleEventContext *ctx = dynamic_cast<RootNtupleEventContext*>(refCtxt);
650  if ( ctx ) {
651  delete ctx; ctx = 0;
652  return StatusCode::SUCCESS;
653  }
654 
655  return StatusCode::FAILURE;
656 }

◆ resetCriteria()

StatusCode Athena::RootNtupleEventSelector::resetCriteria ( const std::string &  cr,
Context &  ctx 
) const
overridevirtual

Definition at line 659 of file RootNtupleEventSelector.cxx.

660 {
661  ATH_MSG_ERROR ("............. resetCriteria Not Implemented .............");
662  return StatusCode::FAILURE;
663 }

◆ rewind()

StatusCode Athena::RootNtupleEventSelector::rewind ( Context &  refCtxt) const
overridevirtual

Definition at line 625 of file RootNtupleEventSelector.cxx.

626 {
627  return self()->seek(ctxt, 0);
628 }

◆ seek()

StatusCode Athena::RootNtupleEventSelector::seek ( Context &  ctx,
int  evtnum 
) const
overridevirtual

Seek to a given event number.

IEvtSelectorSeek interface

Parameters
evtnumThe event number to which to seek.
evtnumThe event number to which to seek.

Definition at line 674 of file RootNtupleEventSelector.cxx.

675 {
676  RootNtupleEventContext* rctx = dynamic_cast<RootNtupleEventContext*>(&ctx);
677  if (!rctx) {
678  return StatusCode::FAILURE;
679  }
680 
681  // std::cout << "::seek - evtnum=" << evtnum
682  // << " curevt=" << m_curEvt
683  // << " curcol=" << rctx->fileIndex()
684  // << std::endl;
685  long coll_idx, tuple_idx;
686  find_coll_idx(evtnum, coll_idx, tuple_idx);
687  // std::cout << "::seek - evtnum=" << evtnum
688  // << " curevt=" << m_curEvt
689  // << " curcol=" << rctx->fileIndex()
690  // << " colidx=" << coll_idx
691  // << std::endl;
692  if ((coll_idx == -1 || tuple_idx == -1) && evtnum < m_curEvt) {
693  coll_idx = rctx->fileIndex();
694  tuple_idx = rctx->tupleIndex();
695  }
696 
697  if (coll_idx == -1 || tuple_idx == -1) {
698  ATH_MSG_INFO("seek: reached end of input.");
699  return StatusCode::RECOVERABLE;
700  }
701 
702  if (coll_idx != static_cast<int>(rctx->fileIndex()) ||
703  tuple_idx != static_cast<int>(rctx->tupleIndex()))
704  {
705  // tell everyone we switched files...
706  m_tuple = NULL;
707  CHECK( endInputFile (rctx) );
708  }
709 
710  rctx->setFileIndex (coll_idx);
711  rctx->setTupleIndex (tuple_idx);
712  m_curEvt = evtnum;
713 
714  return StatusCode::SUCCESS;
715 }

◆ self()

RootNtupleEventSelector* Athena::RootNtupleEventSelector::self ( ) const
inlineprivate

non-const access to self (b/c next() is const)

Definition at line 177 of file RootNtupleEventSelector.h.

178  { return const_cast<RootNtupleEventSelector*>(this); }

◆ setupInputCollection()

void Athena::RootNtupleEventSelector::setupInputCollection ( Gaudi::Details::PropertyBase &  inputCollectionsName)
private

callback to synchronize the list of input files

Definition at line 832 of file RootNtupleEventSelector.cxx.

833 {
834  // nothing ?
835  return;
836 }

◆ size()

int Athena::RootNtupleEventSelector::size ( Context &  refCtxt) const
overridevirtual

ICollectionSize interface

return total number of events in all TTree

Definition at line 1271 of file RootNtupleEventSelector.cxx.

1271  {
1272  //use find_coll_idx to trigger a population of the m_collEvts
1273  long coll_idx, tuple_idx;
1274  find_coll_idx(-1, coll_idx, tuple_idx);
1275  return m_collEvts.back().back().max_entries;
1276 }

◆ updateAddress()

StatusCode Athena::RootNtupleEventSelector::updateAddress ( StoreID::type  storeID,
SG::TransientAddress tad,
const EventContext &  ctx 
)
overridevirtual

update a transient Address

Definition at line 812 of file RootNtupleEventSelector.cxx.

814 {
815  if (tad) {
816  if (m_dataStore->proxy_exact (tad->sgkey())) {
817  return StatusCode::SUCCESS;
818  }
819  return StatusCode::FAILURE;
820  }
821  // do nothing.
822  return StatusCode::SUCCESS;
823 }

Friends And Related Function Documentation

◆ Athena::RootNtupleEventContext

friend class Athena::RootNtupleEventContext
friend

Definition at line 50 of file RootNtupleEventSelector.h.

Member Data Documentation

◆ m_activeBranchNames

StringArrayProperty Athena::RootNtupleEventSelector::m_activeBranchNames
private

List of branches to activate in the TTree.

Definition at line 214 of file RootNtupleEventSelector.h.

◆ m_clidsvc

ICLIDSvc_t Athena::RootNtupleEventSelector::m_clidsvc
private

Pointer to the IClassIDSvc.

Definition at line 197 of file RootNtupleEventSelector.h.

◆ m_collEvts

std::vector<std::vector<CollMetaData> > Athena::RootNtupleEventSelector::m_collEvts
mutableprivate

cache of the number of entries for each collection Indexed like [tuple][collection]

Definition at line 238 of file RootNtupleEventSelector.h.

◆ m_curEvt

long Athena::RootNtupleEventSelector::m_curEvt
mutableprivate

current event index

Definition at line 226 of file RootNtupleEventSelector.h.

◆ m_dataStore

StoreGateSvc_t Athena::RootNtupleEventSelector::m_dataStore
private

Pointer to the StoreGateSvc event store.

Definition at line 187 of file RootNtupleEventSelector.h.

◆ m_dictsvc

IDictSvc_t Athena::RootNtupleEventSelector::m_dictsvc
private

Pointer to the IDictLoaderSvc.

Definition at line 201 of file RootNtupleEventSelector.h.

◆ m_files

std::vector<TFile*> Athena::RootNtupleEventSelector::m_files
mutableprivate

Definition at line 265 of file RootNtupleEventSelector.h.

◆ m_fireBIF

bool Athena::RootNtupleEventSelector::m_fireBIF
mutableprivate

Definition at line 256 of file RootNtupleEventSelector.h.

◆ m_imetaStore

StoreGateSvc_t Athena::RootNtupleEventSelector::m_imetaStore
private

Pointer to the StoreGateSvc input metadata store.

Definition at line 190 of file RootNtupleEventSelector.h.

◆ m_incsvc

IIncSvc_t Athena::RootNtupleEventSelector::m_incsvc
private

Handle to the incident service.

Definition at line 205 of file RootNtupleEventSelector.h.

◆ m_inputCollectionsName

StringArrayProperty Athena::RootNtupleEventSelector::m_inputCollectionsName
private

List of input files containing TTree.

Definition at line 208 of file RootNtupleEventSelector.h.

◆ m_nbrEvts

long Athena::RootNtupleEventSelector::m_nbrEvts
mutableprivate

Number of Events read so far.

Definition at line 223 of file RootNtupleEventSelector.h.

◆ m_needReload

bool Athena::RootNtupleEventSelector::m_needReload
mutableprivate

The (python) selection function to apply on the TChain we are reading.

Definition at line 248 of file RootNtupleEventSelector.h.

◆ m_ometaStore

StoreGateSvc_t Athena::RootNtupleEventSelector::m_ometaStore
private

Pointer to the StoreGateSvc output metadata store.

Definition at line 193 of file RootNtupleEventSelector.h.

◆ m_skipEvts

long Athena::RootNtupleEventSelector::m_skipEvts
private

Number of events to skip at the beginning.

Definition at line 217 of file RootNtupleEventSelector.h.

◆ m_tuple

TTree* Athena::RootNtupleEventSelector::m_tuple
mutableprivate

current tree being read

Definition at line 241 of file RootNtupleEventSelector.h.

◆ m_tupleName

StringProperty Athena::RootNtupleEventSelector::m_tupleName
private

Name of TTree to load from collection of input files.

Definition at line 211 of file RootNtupleEventSelector.h.

◆ m_tupleNames

std::vector<std::string> Athena::RootNtupleEventSelector::m_tupleNames
private

Names of all trees over which to iterate.

Definition at line 220 of file RootNtupleEventSelector.h.


The documentation for this class was generated from the following files:
SGTest::store
TestStore store
Definition: TestStore.cxx:23
Athena::RootNtupleEventSelector::m_skipEvts
long m_skipEvts
Number of events to skip at the beginning.
Definition: RootNtupleEventSelector.h:217
Athena::RootBranchAddress
Definition: RootBranchAddress.h:33
Athena::RootNtupleEventSelector::m_incsvc
IIncSvc_t m_incsvc
Handle to the incident service.
Definition: RootNtupleEventSelector.h:205
TileDCSDataPlotter.dp
dp
Definition: TileDCSDataPlotter.py:840
Athena::RootNtupleEventSelector::addMetadataFromDirectoryName
void addMetadataFromDirectoryName(const std::string &metadirname, TFile *fileObj, const std::string &prefix="") const
Definition: RootNtupleEventSelector.cxx:1118
ConvertOldHistosToNewHistos.converted
converted
Definition: ConvertOldHistosToNewHistos.py:40
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition: AthMsgStreamMacros.h:34
python.SystemOfUnits.s
int s
Definition: SystemOfUnits.py:131
Athena::RootNtupleEventSelector::endInputFile
StatusCode endInputFile(RootNtupleEventContext *rctx) const
Definition: RootNtupleEventSelector.cxx:426
Athena::RootNtupleEventSelector::m_tupleName
StringProperty m_tupleName
Name of TTree to load from collection of input files.
Definition: RootNtupleEventSelector.h:211
StateLessPT_NewConfig.proxy
proxy
Definition: StateLessPT_NewConfig.py:392
athena.path
path
python interpreter configuration --------------------------------------—
Definition: athena.py:128
Gaudi::Parsers::parse
StatusCode parse(std::tuple< Tup... > &tup, const Gaudi::Parsers::InputData &input)
Definition: CaloGPUClusterAndCellDataMonitorOptions.h:284
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
SG::Accessor
Helper class to provide type-safe access to aux data.
Definition: Control/AthContainers/AthContainers/Accessor.h:68
Athena::RootNtupleEventSelector::m_inputCollectionsName
StringArrayProperty m_inputCollectionsName
List of input files containing TTree.
Definition: RootNtupleEventSelector.h:208
EventType
This class represents the "type of event" where the type is given by one or more "characteristics".
Definition: EventType.h:92
StateLessPT_NewConfig.Format
Format
Definition: StateLessPT_NewConfig.py:146
Athena::RootNtupleEventSelector::RootNtupleEventSelector
RootNtupleEventSelector(const std::string &name, ISvcLocator *svcLoc)
Constructor with parameters:
Definition: RootNtupleEventSelector.cxx:222
tree
TChain * tree
Definition: tile_monitor.h:30
EventInfo
EventInfo
Definition: EventTPCnv.cxx:47
SG::TransientAddress
Definition: TransientAddress.h:32
Athena::RootNtupleEventSelector::m_dictsvc
IDictSvc_t m_dictsvc
Pointer to the IDictLoaderSvc.
Definition: RootNtupleEventSelector.h:201
CaloClusterListBadChannel.cls
cls
Definition: CaloClusterListBadChannel.py:8
SG::TransientAddress::sgkey
sgkey_t sgkey() const
Set the primary (hashed) SG key.
Definition: TransientAddress.h:222
Athena::RootNtupleEventSelector::setupInputCollection
void setupInputCollection(Gaudi::Details::PropertyBase &inputCollectionsName)
callback to synchronize the list of input files
Definition: RootNtupleEventSelector.cxx:832
Athena::RootNtupleEventSelector::m_nbrEvts
long m_nbrEvts
Number of Events read so far.
Definition: RootNtupleEventSelector.h:223
Athena::RootNtupleEventSelector::size
virtual int size(Context &refCtxt) const override
ICollectionSize interface
Definition: RootNtupleEventSelector.cxx:1271
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
beamspotman.tokens
tokens
Definition: beamspotman.py:1284
Athena::RootNtupleEventSelector::fetchNtuple
TTree * fetchNtuple(const std::string &fname, const std::string &tupleName) const
helper method to retrieve the correct tuple
Definition: RootNtupleEventSelector.cxx:1068
Athena::RootNtupleEventSelector::m_tuple
TTree * m_tuple
current tree being read
Definition: RootNtupleEventSelector.h:241
Athena::RootNtupleEventSelector::seek
virtual StatusCode seek(Context &refCtxt, int evtnum) const override
Seek to a given event number.
Definition: RootNtupleEventSelector.cxx:674
atlasStyleMacro.icol
int icol
Definition: atlasStyleMacro.py:13
runLayerRecalibration.branches
list branches
Definition: runLayerRecalibration.py:98
Athena::RootNtupleEventSelector::addMetadata
void addMetadata(TTree *metatree, const std::string &path="") const
Definition: RootNtupleEventSelector.cxx:1168
TileAANtupleConfig.inputCollections
inputCollections
Definition: TileAANtupleConfig.py:133
PlotCalibFromCool.nentries
nentries
Definition: PlotCalibFromCool.py:798
Athena::RootNtupleEventSelector::do_init_io
StatusCode do_init_io()
helper method to init the i/o components
Definition: RootNtupleEventSelector.cxx:1189
Amg::toString
std::string toString(const Translation3D &translation, int precision=4)
GeoPrimitvesToStringConverter.
Definition: GeoPrimitivesToStringConverter.h:40
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
Athena::RootNtupleEventSelector::m_fireBIF
bool m_fireBIF
Definition: RootNtupleEventSelector.h:256
Athena::typeinfoName
std::string typeinfoName(const std::type_info &ti)
Convert a type_info to a demangled string.
Definition: AthenaKernel/src/ClassName.cxx:23
Athena::RootNtupleEventSelector::m_tupleNames
std::vector< std::string > m_tupleNames
Names of all trees over which to iterate.
Definition: RootNtupleEventSelector.h:220
StdJOSetup.ppSvc
ppSvc
Definition: StdJOSetup.py:38
lumiFormat.i
int i
Definition: lumiFormat.py:85
Athena::RootNtupleEventSelector::m_curEvt
long m_curEvt
current event index
Definition: RootNtupleEventSelector.h:226
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
Athena::RootNtupleEventSelector::m_ometaStore
StoreGateSvc_t m_ometaStore
Pointer to the StoreGateSvc output metadata store.
Definition: RootNtupleEventSelector.h:193
TransferTree
Definition: TransferTree.h:11
L1CaloPhase1Monitoring.propVal
propVal
Definition: L1CaloPhase1Monitoring.py:451
generateReferenceFile.files
files
Definition: generateReferenceFile.py:12
Athena::RootNtupleEventSelector::m_collEvts
std::vector< std::vector< CollMetaData > > m_collEvts
cache of the number of entries for each collection Indexed like [tuple][collection]
Definition: RootNtupleEventSelector.h:238
checkCorrelInHIST.prefix
dictionary prefix
Definition: checkCorrelInHIST.py:391
CHECK
#define CHECK(...)
Evaluate an expression and check for errors.
Definition: Control/AthenaKernel/AthenaKernel/errorcheck.h:422
hist_file_dump.f
f
Definition: hist_file_dump.py:135
Athena::RootNtupleEventSelector::createRootBranchAddresses
StatusCode createRootBranchAddresses(StoreID::type storeID, tadList &tads)
helper method to create proxies
Definition: RootNtupleEventSelector.cxx:839
SGTest::TestStore::name
virtual const std::string & name() const override
Definition: TestStore.cxx:97
imax
int imax(int i, int j)
Definition: TileLaserTimingTool.cxx:33
CLID
uint32_t CLID
The Class ID type.
Definition: Event/xAOD/xAODCore/xAODCore/ClassID_traits.h:47
checkRpcDigits.allGood
bool allGood
Loop over the SDOs & Digits.
Definition: checkRpcDigits.py:171
Athena::RootNtupleEventSelector::m_needReload
bool m_needReload
The (python) selection function to apply on the TChain we are reading.
Definition: RootNtupleEventSelector.h:248
GetAllXsec.entry
list entry
Definition: GetAllXsec.py:132
grepfile.sep
sep
Definition: grepfile.py:38
Athena::RootNtupleEventSelector::createMetaDataRootBranchAddresses
StatusCode createMetaDataRootBranchAddresses(StoreGateSvc *store, TTree *tree, const std::string &prefix) const
helper method to create proxies for the metadata store
Definition: RootNtupleEventSelector.cxx:952
id
SG::auxid_t id
Definition: Control/AthContainers/Root/debug.cxx:227
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
pool::READ
@ READ
Definition: Database/APR/StorageSvc/StorageSvc/pool.h:68
EventInfo
This class provides general information about an event. Event information is provided by the accessor...
Definition: EventInfo/EventInfo/EventInfo.h:43
Athena::RootNtupleEventSelector::m_files
std::vector< TFile * > m_files
Definition: RootNtupleEventSelector.h:265
SGTest::TestStore::record
void record(const T *p, const std::string &key)
Definition: TestStore.h:81
python.AthDsoLogger.fname
string fname
Definition: AthDsoLogger.py:67
Athena::RootNtupleEventSelector::m_clidsvc
ICLIDSvc_t m_clidsvc
Pointer to the IClassIDSvc.
Definition: RootNtupleEventSelector.h:197
RTTAlgmain.branch
branch
Definition: RTTAlgmain.py:61
Athena::RootNtupleEventSelector::m_dataStore
StoreGateSvc_t m_dataStore
Pointer to the StoreGateSvc event store.
Definition: RootNtupleEventSelector.h:187
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
Athena::RootNtupleEventSelector::next
virtual StatusCode next(Context &refCtxt) const override
Definition: RootNtupleEventSelector.cxx:458
convertTimingResiduals.offset
offset
Definition: convertTimingResiduals.py:71
EventID
This class provides a unique identification for each event, in terms of run/event number and/or a tim...
Definition: EventID.h:35
Athena::RootNtupleEventSelector::m_imetaStore
StoreGateSvc_t m_imetaStore
Pointer to the StoreGateSvc input metadata store.
Definition: RootNtupleEventSelector.h:190
Athena::FileNames_t
RootNtupleEventContext::FileNames_t FileNames_t
Definition: RootNtupleEventSelector.cxx:213
python.Bindings.keys
keys
Definition: Control/AthenaPython/python/Bindings.py:798
Athena::RootNtupleEventSelector::addMetadataFromDirectory
void addMetadataFromDirectory(TDirectoryFile *metadir, const std::string &prefix="") const
Definition: RootNtupleEventSelector.cxx:1125
StoreID::EVENT_STORE
@ EVENT_STORE
Definition: StoreID.h:26
SG::DataProxy
Definition: DataProxy.h:45
zero
void zero(TH2 *h)
zero the contents of a 2d histogram
Definition: comparitor.cxx:436
Athena::RootNtupleEventSelector::find_coll_idx
void find_coll_idx(int evtidx, long &coll_idx, long &tuple_idx) const
helper method to get the collection index (into m_inputCollectionsName) and tuple index (into ‘m_tupl...
Definition: RootNtupleEventSelector.cxx:1228
ServiceHandle< IIoComponentMgr >
mapkey::key
key
Definition: TElectronEfficiencyCorrectionTool.cxx:37
Athena::RootNtupleEventSelector::m_activeBranchNames
StringArrayProperty m_activeBranchNames
List of branches to activate in the TTree.
Definition: RootNtupleEventSelector.h:214