ATLAS Offline Software
AANTupleStream.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3 */
4 
7 
9 
11 
12 #include "Gaudi/Interfaces/IOptionsSvc.h"
13 #include "GaudiKernel/IAlgManager.h"
14 #include "GaudiKernel/ISvcLocator.h"
15 #include "GaudiKernel/IAddressCreator.h"
16 #include "GaudiKernel/IOpaqueAddress.h"
17 #include "GaudiKernel/MsgStream.h"
18 #include "GaudiKernel/ITHistSvc.h"
19 #include "GaudiKernel/ListItem.h"
20 #include "GaudiKernel/ServiceHandle.h"
21 #include "GaudiKernel/IIoComponentMgr.h"
22 
23 #include "StoreGate/StoreGateSvc.h"
24 #include "SGTools/DataProxy.h"
26 
28 #include "CoralBase/AttributeList.h"
29 #include "CoralBase/AttributeListSpecification.h"
30 
31 #include "EventInfo/EventInfo.h"
32 #include "EventInfo/EventID.h"
34 
35 #include "TFile.h"
36 #include "TTree.h"
37 #include "TText.h"
38 #include "TBranch.h"
39 #include "TInterpreter.h"
40 
41 #include <map>
42 #include <string>
43 #include <algorithm>
44 
45 using namespace AANTupleParams;
46 
47 // Standard Constructor
48 AANTupleStream::AANTupleStream(const std::string& name, ISvcLocator* pSvcLocator)
49  : AthLegacySequence(name, pSvcLocator),
50  m_persSvc ("EventPersistencySvc", name),
51  m_attribSpec(0),
52  m_schemaDone(false),
53  m_tree(0),
54  m_tokenBranch(0),
55  m_tHistSvc ("THistSvc", name)
56 {
57  declareProperty("OutputName", m_fileName="AANTuple.root");
58  declareProperty("ExtraRefNames", m_extraRefNames);
59  declareProperty("WriteInputDataHeader", m_writeInputDH=false);
60  declareProperty("ExistDataHeader", m_existDH=true);
61  declareProperty("StreamName", m_streamName=c_streamName);
62  declareProperty("LateSchemaWriting", m_lateSchema=false);
63  declareProperty("TreeName", m_treeName=c_treeName);
64  declareProperty("Macro", m_macro="");
65  declareProperty("Members", m_membersNames);
66  declareProperty("FilterAlgs", m_acceptNames);
67 
68  m_tokenCString[0] = '\0';
69 }
70 
71 
72 // Standard Destructor
74 {
75 }
76 
77 
78 // initialize data writer
80 {
81  ATH_MSG_DEBUG ("In initialize ");
82  // register with the I/O component manager
83  {
84  ServiceHandle<IIoComponentMgr> iomgr ("IoComponentMgr", this->name());
85  if ( !iomgr.retrieve().isSuccess() ) {
86  ATH_MSG_ERROR ("Could not retrieve IIoComponentMgr/IoComponentMgr !");
87  return StatusCode::FAILURE;
88  }
89  if ( !iomgr->io_register (this).isSuccess() ) {
90  ATH_MSG_ERROR ("Could not register with the I/O component mgr !");
91  return StatusCode::FAILURE;
92  }
93  if ( !iomgr->io_register (this,
95  m_fileName).isSuccess() ) {
96  ATH_MSG_ERROR ("Could not register [" << this->name() << "]["
97  << m_fileName << "] with the I/O component manager !");
98  return StatusCode::FAILURE;
99  }
100  }
101 
102  // StoreGateSvc
103  StatusCode sc = evtStore().retrieve();
104  if ( !sc.isSuccess() )
105  {
106  ATH_MSG_ERROR ("Could not locate default store");
107  return sc;
108  }
109 
110  // set up the persistency service:
111  sc = m_persSvc.retrieve();
112  if ( !sc.isSuccess() )
113  {
114  ATH_MSG_ERROR ("Could not locate persistency service");
115  return sc;
116  }
117 
118  // instantiate AttrListSpec and add attributes for Run# and Event#
119  m_attribSpec = new coral::AttributeListSpecification;
120  m_attribSpec->extend( name_RunNumber, "unsigned int" );
121  m_attribSpec->extend( name_EventNumber, "unsigned int" );
122 
123  // Add on specification for extra refs
124  std::vector<std::string> extraRefs = m_extraRefNames.value();
125  for (unsigned int i = 0; i < extraRefs.size(); ++i)
126  {
127  // Append _ref to name of attribute
128  std::string name = extraRefs[i] + "_ref";
129  m_attribSpec->extend(name, "string");
130  }
131 
132  if (!m_lateSchema) {
133  sc = initSchema();
134  if (sc.isFailure())
135  return sc;
136  }
137 
138  // initialize sub-algos
140  if ( sc.isFailure() )
141  {
142  ATH_MSG_ERROR ("Could not initialize sub-algos");
143  return sc;
144  }
145 
146  // get filters
147  sc = getFilters();
148  if ( sc.isFailure() )
149  {
150  ATH_MSG_ERROR ("Could not get filters");
151  return sc;
152  }
153 
154  ATH_MSG_DEBUG ("End initialize ");
155 
157 }
158 
159 
160 // initialize output collection
162 {
163  // write schema
165 
166  // setup TTree
167  setupTree();
168 
169  // setup Token
170  m_tokenBranch = m_tree->GetBranch(c_tokenBranchName);
171  m_tokenBranch->SetAddress(m_tokenCString);
172 
173  return StatusCode::SUCCESS;
174 }
175 
176 
177 // terminate data writer
179 {
180  ATH_MSG_INFO ("finalize");
181 
182  // exec macro
183  if (m_macro != "")
184  {
185  // save current dir
186  std::string curDir = gDirectory->GetPath();
187  // go to the root dir of output file
188  gDirectory->cd((m_fileName+":/").c_str());
189  // exec
190  // G__exec_tempfile(m_macro.c_str());
191  // MN: that should be the equivalent new call:
192  gInterpreter->ExecuteMacro(m_macro.c_str());
193  // back to the current dir
194  gDirectory->cd(curDir.c_str());
195  }
196 
198 }
199 
200 
201 // Work entry point
203 {
204  StatusCode sc;
205 
206  if (!m_schemaDone) {
207  sc = initSchema();
208  if (sc.isFailure())
209  return sc;
210  }
211 
212  // execute sub-algos
213  sc = execute_subAlgos();
214  if ( sc.isFailure() )
215  {
216  ATH_MSG_ERROR ("Could not execute sub-algos");
217  return sc;
218  }
219 
220  std::map<std::string,std::string> inputRefs;
221  std::string ref;
222 
223  // Get tokens specified by item list
224  if (m_existDH)
225  {
226  // get token
229  StatusCode status = evtStore()->retrieve(beg,ending);
230  if (status.isFailure() || beg==ending)
231  {
232  ATH_MSG_WARNING ("No DataHeaders present in StoreGate");
233  return StatusCode::FAILURE;
234  }
235 
236  // look for header
237  for (; beg != ending; ++beg)
238  if (m_writeInputDH == beg->isInput()) break;
239 
240  if (beg==ending)
241  {
242  ATH_MSG_WARNING ("No appropriate DataHeader present in StoreGate");
243  return StatusCode::FAILURE;
244  }
245 
246  // get the ref
247  while (getRef(ClassID_traits<DataHeader>::ID(), beg.key(), ref) == StatusCode::FAILURE)
248  {
249  ++beg;
250  if (beg==ending)
251  {
252  ATH_MSG_ERROR ("No refs found");
253  return StatusCode::FAILURE;
254  }
255  }
256 
257  ATH_MSG_DEBUG ("Found token: Key=" << beg.key() << ", Ref=" << ref);
258 
259  // Get a single input header ref if requested
260  const DataHeader* hdr = &(*beg);
261  if (hdr->sizeProvenance())
262  {
263  std::vector<DataHeaderElement>::const_iterator it =
264  (const_cast<DataHeader*>(hdr)->beginProvenance());
265  std::vector<DataHeaderElement>::const_iterator itE =
266  (const_cast<DataHeader*>(hdr)->endProvenance());
267  // grab refs for those
268  for (; it!=itE; ++it)
269  {
270  std::string tmpRef = (*it).getToken() != NULL
271  ? (*it).getToken()->toString()
272  : "";
273  inputRefs.insert(std::make_pair(it->getKey(),tmpRef));
274  ATH_MSG_DEBUG ("Found ref for input header: Key=" << it->getKey()
275  << ", Ref=" << tmpRef);
276  }
277  }
278  }
279 
280  // create Attrlist, add attributes and if extra ref is requested, append to the end
281 
282  ATH_MSG_DEBUG ("create AttributeList");
283  // AthenaAttributeList newAttr(*m_attribSpec);
285 
286  unsigned int runNumber = 0;
287  unsigned int eventNumber = 0;
288 
289  // retrieve event info
290  const EventInfo* eventInfo;
291  eventInfo = evtStore()->tryConstRetrieve<EventInfo>();
292  if ( !eventInfo )
293  {
294  // Try to get the xAOD::EventInfo
295  const xAOD::EventInfo* eventInfoX{nullptr};
296  sc = evtStore()->retrieve(eventInfoX);
297  if (sc.isFailure())
298  {
299  ATH_MSG_ERROR ("Cannot get event info.");
300  return sc;
301  }
302  else
303  {
304  runNumber = eventInfoX->runNumber();
305  eventNumber = eventInfoX->eventNumber();
306  }
307  }
308  else
309  {
310  runNumber = eventInfo->event_ID()->run_number();
311  eventNumber = eventInfo->event_ID()->event_number();
312  }
313 
314  // add global event tag data
315  newAttr[ name_RunNumber ].setValue( runNumber );
316  newAttr[ name_EventNumber ].setValue( eventNumber );
317 
318  // add back nav ref's
319  ATH_MSG_DEBUG ("Append extra ref");
320  std::vector<std::string> extraRefs = m_extraRefNames.value();
321  std::map<std::string,std::string>::iterator itRef = inputRefs.begin();
322  std::map<std::string,std::string>::iterator itRefE = inputRefs.end();
323  for (; itRef != itRefE; ++itRef)
324  {
325  std::string name = itRef->first + "_ref";
326  if (extraRefs.end() != std::find(extraRefs.begin(),extraRefs.end(),itRef->first))
327  {
328  newAttr[name].setValue(std::string(itRef->second));
329  ATH_MSG_DEBUG (" Added extra ref to new attribute list - name: "
330  << name << " " << itRef->second);
331  }
332  }
333 
334  // write if filters passed
335  if (isEventAccepted())
336  {
337  ATH_MSG_DEBUG ("write attributes to collection");
338 
339  // write token plus attributes
340  try
341  {
342  writeTokenAttrList(ref, newAttr);
343  }
344  catch (std::exception &e)
345  {
347  ("Caught exception from collection add of Pool attributes. "
348  "Message: " << e.what());
349  return StatusCode::FAILURE;
350  }
351  }
352 
353  ATH_MSG_DEBUG ("done successfully");
354 
355  return StatusCode::SUCCESS;
356 }
357 
358 
360 {
361  // go to the root dir of output file
362  TDirectory::TContext save;
363  gDirectory->cd((m_fileName+":/").c_str());
364 
366  // store schema in the schema object
367  for( coral::AttributeListSpecification::const_iterator iter = m_attribSpec->begin();
368  iter != m_attribSpec->end(); ++iter) {
369  all.m_layout.push_back( make_pair( iter->name(), iter->typeName() ) );
370  }
371  // write schema object
372  all.Write(c_attributeListLayoutName);
373 }
374 
375 
377 {
378  static const std::map<std::string,char> typeDict = {
379  {"double", 'D'},
380  {"long double", 'D'}, // only 64 bit doubles are supported
381  {"float", 'F'},
382  {"int", 'i'},
383  {"unsigned int", 'I'},
384  {"long", 'i'}, // support for 64 bit integers introduced with ROOT 4.00/08
385  {"unsigned long", 'I'}, // support for 64 bit integers introduced with ROOT 4.00/08
386  {"short", 's'},
387  {"unsigned short", 'S'},
388  {"char", 'b'}, // AttributeLists's "get_root_type_char(...)" returned 'C' ???
389  {"unsigned char", 'B'}, // AttributeLists's "get_root_type_char(...)" returned 's' ???
390  {"bool", 'B'}, // AttributeLists's "get_root_type_char(...)" returned 'i' ???
391  {"string", 'C'},
392  {"Token", 'C'}
393  };
394 
395  // go to the root dir of output file
396  TDirectory::TContext save;
397  gDirectory->cd((m_fileName+":/").c_str());
398 
399  // instantiate TTree
400  m_tree = new TTree(m_treeName.c_str(), m_treeName.c_str());
401 
402  // add branches for attributes
403  for(coral::AttributeListSpecification::const_iterator iter=m_attribSpec->begin(); iter!=m_attribSpec->end(); ++iter)
404  {
405  std::string type = "/?";
406  type[1] = typeDict.at(iter->typeName());
407  std::string leaflist = iter->name() + type;
408  m_tree->Branch(iter->name().c_str(),0,leaflist.c_str());
409  }
410 
411  // add Token branch
412  std::string leaflist = c_tokenBranchName;
413  leaflist += "/C";
414  m_tree->Branch(c_tokenBranchName,0,leaflist.c_str());
415 
416  // set TTree
418 }
419 
420 
421 // Get the string form of a ref for a given clid and key
422 StatusCode AANTupleStream::getRef(CLID id, const std::string& key, std::string& ref)
423 {
424  // Must access the SG proxy to get the IOpaqueAddress
425  SG::DataProxy* itemProxy = 0;
426  ATH_MSG_DEBUG ("Retrieving proxy for " << id << " " << key);
427  itemProxy = evtStore()->proxy(id, key);
428  if (!itemProxy)
429  {
430  ATH_MSG_ERROR ("Could not get proxy ");
431  return(StatusCode::FAILURE);
432  }
433  else
434  {
435  ATH_MSG_DEBUG (" found proxy for ("<< id << ",\"" << key << "\") ");
436  }
437 
438  if (!itemProxy)
439  {
440  ATH_MSG_ERROR ("Empty proxy ");
441  return(StatusCode::FAILURE);
442  }
443 
444  // Get IOpaqueAddress from the proxy
445  IOpaqueAddress* addr = itemProxy->address();
446  if (!addr)
447  {
448  ATH_MSG_DEBUG ("Could not get address for clid "
449  << itemProxy->clID() << " " << itemProxy->name());
450  return( StatusCode::FAILURE);
451  }
452 
453  // Convert IOpaqueAddress to string via the persistency
454  // service. And then remove header to extract the token.
455  std::string saddr;
456 
457  StatusCode sc = m_persSvc->convertAddress(addr, saddr);
458  if (sc.isFailure())
459  {
461  ("Could not get string from IOpaqueAddress for clid " << id
462  << " " << key
463  << " is BAD_STORAGE_TYPE: "<< (sc == IConversionSvc::Status::BAD_STORAGE_TYPE));
464  return( StatusCode::FAILURE);
465  }
466 
467 
468  // We assume here some knowledge of the form of the AthenaPool
469  // string address
470  std::string hdr;
471  sc = splitAddress(saddr, " /> ", hdr, ref);
472  if (sc.isFailure())
473  {
474  ATH_MSG_ERROR ("Could not get split off token. string address " << saddr);
475  return( StatusCode::FAILURE);
476  }
477 
478  ATH_MSG_DEBUG ("String address " << ref);
479 
480  return StatusCode::SUCCESS;
481 }
482 
483 
484 // Extract the address header and data from an IOpaqueAddress in
485 // string form
487  const std::string& match,
488  std::string& address_header,
489  std::string& address_data ) const
490 {
491  ATH_MSG_DEBUG ("splitAddress " << endmsg
492  << " address : " << address
493  << " match : " << match);
494 
495  std::string::size_type p1;
496 
497  p1 = address.find( match );
498  if (p1 != std::string::npos)
499  {
500  address_header = address.substr( 0, p1+match.size());
501 
502  address_data = address.substr( p1+match.size() );
503  }
504  else
505  {
506  return StatusCode::FAILURE;
507  }
508 
509  ATH_MSG_DEBUG (" address_header : " << address_header
510  << endmsg
511  << " address_data : " << address_data);
512 
513  return StatusCode::SUCCESS;
514 }
515 
516 
517 // write Token and Attributes to the output collection
518 bool AANTupleStream::writeTokenAttrList( const std::string& token, const coral::AttributeList& attributeList )
519 {
520  // set addresses for attributes
521  coral::AttributeList::const_iterator attIter = attributeList.begin();
522  const TObjArray* branches = m_tree->GetListOfBranches();
523  std::vector<std::string> tokenStringDump;
524  // loop over all attributes
525  for (unsigned int i=0; i<attributeList.size(); ++i)
526  {
527  TBranch* branch = (TBranch*)branches->UncheckedAt(i);
528  // string attributes
529  if (attIter->specification().type() == typeid(std::string))
530  {
531  const std::string& str = attIter->data<std::string>();
532  if( str.length()+1 >= s_maxLengthOfStrings )
533  {
534  throw std::runtime_error("String is too long : RootCollection::pool2Root<std::string>");
535  }
536  branch->SetAddress( (void*)str.c_str() );
537  }
538  // Token
539  else if(attIter->specification().typeName() == "Token")
540  {
541  tokenStringDump.push_back( attIter->data<std::string>() );
542  branch->SetAddress( (void*) tokenStringDump.back().c_str() );
543  }
544  // else
545  else
546  {
547  branch->SetAddress( (void*)attIter->addressOfData() );
548  }
549  ++attIter;
550  }
551 
552  // set address for Token
553  m_tokenBranch->SetAddress((void*)token.c_str());
554 
555  // fill TTree
556  m_tree->Fill();
557 
558  // releases Token
559  m_tokenBranch->SetAddress(m_tokenCString);
560 
561  return true;
562 }
563 
564 
565 // initialize sub-algos
567 {
568  StatusCode sc = StatusCode::SUCCESS;
569 
570  Algorithm* algo;
571  std::vector<std::string>::const_iterator it;
572  std::vector<std::string>::const_iterator itend = m_membersNames.end( );
573  for (it = m_membersNames.begin(); it != itend; ++it)
574  {
575  // Parse the name for a syntax of the form:
576  //
577  // <type>/<name>
578  //
579  // Where <name> is the algorithm instance name, and <type> is the
580  // algorithm class type (being a subclass of Algorithm).
581  ListItem foo(*it);
582  std::string theType = foo.type();
583  std::string theName = foo.name();
584 
585  // create sub-algorithm
586  ATH_MSG_INFO (" -> creating sub-algorithm " << (*it));
587  sc = createSubAlgorithm( theType,theName, algo );
588  if (sc.isFailure())
589  {
590  ATH_MSG_FATAL (" ERROR creating sub-alg." << (*it));
591  return StatusCode::FAILURE;
592  }
593  }
594 
595  return sc;
596 }
597 
598 
599 // execute sub-algos
601 {
602  StatusCode sc = StatusCode::SUCCESS;
603 
604  ATH_MSG_DEBUG ("in execute_subAlgos() ...");
605 
606  const EventContext& ctx = Gaudi::Hive::currentContext();
607 
608  // -- run subalgorithms
609  for ( unsigned int i=0; i < m_membersNames.size(); ++i )
610  {
611  ATH_MSG_DEBUG (" -> calling sub-algorithm " << m_membersNames[i]);
612  // skip disabled algo
613  if (! (*(this->subAlgorithms()))[i]->isEnabled()) continue ;
614 
615  sc = (*(this->subAlgorithms()))[i]->execute(ctx);
616  if ( sc.isFailure())
617  {
619  (" ERROR executing sub-algorithm:" << m_membersNames[i]);
620  return StatusCode::FAILURE;
621  }
622  }
623  return sc;
624 }
625 
626 
627 // get filters
629 {
630  ATH_MSG_DEBUG ("in getFilters()");
631 
632  // no filter
633  if (m_acceptNames.empty())
634  return StatusCode::SUCCESS;
635 
636 
637 
638  // old way to get ApplicationMgr crash with gaudi 21 (dynamic_cast fails)
639  // IAlgManager* theAlgMgr;
640 // IInterface* ptmp;
641 // StatusCode sc = serviceLocator()->getService("ApplicationMgr",
642 // IAlgManager::interfaceID(),
643 // ptmp);
644 
645 // if (sc.isFailure())
646 // {
647 // ATH_MSG_FATAL ("Can't locate ApplicationMgr!!!");
648 // return sc;
649 // }
650 // theAlgMgr = dynamic_cast<IAlgManager*> (ptmp);
651 
652  // new safe way to get ApplicationMgr (gaudi 21 and backward compatible)
653  ServiceHandle<IAlgManager> theAlgMgr("ApplicationMgr", this->name());
654  if (theAlgMgr==0){
655  ATH_MSG_FATAL ("Can't locate ApplicationMgr!!!");
656  return StatusCode::FAILURE;
657  }
658 
659 
660  // loop over all alg names
661  std::vector<std::string>::const_iterator it;
662  std::vector<std::string>::const_iterator itend = m_acceptNames.end();
663  for (it = m_acceptNames.begin(); it != itend; ++it)
664  {
665  IAlgorithm* ialg;
666  // get Alg
667  StatusCode sc = theAlgMgr->getAlgorithm(*it, ialg);
668 
669  if (sc.isFailure() )
670  {
671  ATH_MSG_ERROR ("Can't get Filter Alg : " << *it);
672  return StatusCode::FAILURE;
673  }
674  Algorithm *theAlg = dynamic_cast<Algorithm*>(ialg);
675  if (theAlg==0 )
676  {
677  ATH_MSG_ERROR ("Can't cast Filter Alg : " << *it);
678  return StatusCode::FAILURE;
679  }
680  ATH_MSG_DEBUG (" -> getting Filter Alg success " << *it);
681  // push back
682  m_acceptAlgs.push_back(theAlg);
683  }
684  return StatusCode::SUCCESS;
685 }
686 
687 
688 // Loop over all Algorithms in the accept list to see
689 // whether any have been executed and have their filter
690 // passed flag set. Any match causes the event to be
691 // provisionally accepted.
693 {
694  // no filter
695  if (m_acceptAlgs.empty())
696  return true;
697 
698  const EventContext& ctx = Gaudi::Hive::currentContext();
699 
700  // loop over all algs
701  std::vector<Algorithm*>::const_iterator it;
702  std::vector<Algorithm*>::const_iterator itend = m_acceptAlgs.end();
703  for (it = m_acceptAlgs.begin(); it != itend; ++it)
704  {
705  const Algorithm* theAlgorithm = (*it);
706  if ( theAlgorithm->execState(ctx).state() == AlgExecState::State::Done &&
707  ( ! theAlgorithm->execState(ctx).filterPassed() ) )
708  return false;
709  }
710 
711  return true;
712 }
713 
716 {
717  m_schemaDone = true;
718 
719  StatusCode sc = m_tHistSvc.retrieve();
720  if (sc.isFailure())
721  {
722  ATH_MSG_ERROR ("Unable to retrieve pointer to THistSvc");
723  return sc;
724  }
725 
726  // initialize output collection
727  sc = initCollection();
728  if ( sc.isFailure() )
729  {
730  ATH_MSG_ERROR ("Could not init collection");
731  return sc;
732  }
733 
734  // register TTree to THistSvc
735  sc = m_tHistSvc->regTree("/"+m_streamName+"/"+m_treeName, m_tree);
736  if ( sc.isFailure() )
737  {
738  ATH_MSG_ERROR ("Could not register TTree");
739  return sc;
740  }
741 
743  m_tree->Print();
744 
745  return sc;
746 }
747 
750 {
751  ServiceHandle<IIoComponentMgr> iomgr ("IoComponentMgr", this->name());
752  if ( !iomgr.retrieve().isSuccess() ) {
753  ATH_MSG_ERROR ("Could not retrieve IIoComponentMgr/IoComponentMgr !");
754  return StatusCode::FAILURE;
755  }
756 
757  ServiceHandle<Gaudi::Interfaces::IOptionsSvc> josvc ("JobOptionsSvc", this->name());
758  if ( !josvc.retrieve().isSuccess() ) {
759  ATH_MSG_ERROR ("Could not retrieve IOptionsSvc/JobOptionsSvc !");
760  return StatusCode::FAILURE;
761  }
762 
763  // check the I/O manager knows about me
764  if ( !iomgr->io_hasitem (this) ) {
765  ATH_MSG_ERROR ("I/O component mgr does not know about ourselves !");
766  return StatusCode::FAILURE;
767  }
768 
769  // check there is actually something to do...
770  if ( !iomgr->io_contains (this, m_fileName) ) {
772  ("I/O component mgr does not have any entry about ["<< m_fileName<<"]");
773  return StatusCode::SUCCESS;
774  }
775 
776  if ( !iomgr->io_retrieve (this, m_fileName).isSuccess() ) {
777  ATH_MSG_ERROR ("Could not retrieve new name for [" << m_fileName << "] !");
778  return StatusCode::FAILURE;
779  }
780 
781  // recreate the proper property value...
782  std::vector<std::string> outvec = {"AANT DATAFILE='" + m_fileName + "' OPT='RECREATE'"};
783  josvc->set("THistSvc.Output", Gaudi::Utils::toString(outvec));
784 
785  // handle schema...
786  if (!m_schemaDone) {
787  if ( !initSchema().isSuccess() ) {
788  ATH_MSG_ERROR ("Could not initialize schema !");
789  }
790  }
791 
792  return StatusCode::SUCCESS;
793 }
xAOD::iterator
JetConstituentVector::iterator iterator
Definition: JetConstituentVector.cxx:68
python.tests.PyTestsLib.finalize
def finalize(self)
_info( "content of StoreGate..." ) self.sg.dump()
Definition: PyTestsLib.py:53
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition: AthMsgStreamMacros.h:34
AANTupleStream::AANTupleStream
AANTupleStream(const std::string &name, ISvcLocator *pSvcLocator)
Standard AANTupleStream Constructor.
Definition: AANTupleStream.cxx:48
AANTupleStream::finalize
virtual StatusCode finalize()
Terminate AANTupleStream.
Definition: AANTupleStream.cxx:178
AANTupleStream::execute
virtual StatusCode execute()
Working entry point.
Definition: AANTupleStream.cxx:202
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
find
std::string find(const std::string &s)
return a remapped string
Definition: hcg.cxx:135
AANTTreeMap.h
AthCommonDataStore< AthCommonMsg< Gaudi::Sequence > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
AANTupleStream::m_acceptAlgs
std::vector< Algorithm * > m_acceptAlgs
Vector of Algorithms that this stream accepts.
Definition: AANTupleStream.h:133
initialize
void initialize()
Definition: run_EoverP.cxx:894
AANTupleStream::writeTokenAttrList
bool writeTokenAttrList(const std::string &token, const coral::AttributeList &attributeList)
write Token and AttributeList
Definition: AANTupleStream.cxx:518
python.FakeAthena.Algorithm
def Algorithm(name)
Definition: FakeAthena.py:41
skel.it
it
Definition: skel.GENtoEVGEN.py:423
pool::WRITE
@ WRITE
Definition: Database/APR/StorageSvc/StorageSvc/pool.h:72
AANTupleStream::setupTree
void setupTree()
setup Tree
Definition: AANTupleStream.cxx:376
python.PyKernel.AttributeList
AttributeList
Definition: PyKernel.py:36
AthenaAttributeList.h
AANTupleStream::getRef
StatusCode getRef(CLID id, const std::string &key, std::string &ref)
Get ref from a proxy.
Definition: AANTupleStream.cxx:422
TruthTest.itE
itE
Definition: TruthTest.py:25
AthenaPoolTestRead.sc
sc
Definition: AthenaPoolTestRead.py:27
AANTupleStream::m_membersNames
std::vector< std::string > m_membersNames
Definition: AANTupleStream.h:145
AANTupleStream::splitAddress
StatusCode splitAddress(const std::string &address, const std::string &match, std::string &address_header, std::string &address_data) const
Split the address to get pool token.
Definition: AANTupleStream.cxx:486
AANTupleStream::m_persSvc
ServiceHandle< IAddressCreator > m_persSvc
Persistency service.
Definition: AANTupleStream.h:97
AANTupleStream::writeAttributeListSpecification
void writeAttributeListSpecification()
write schema of AttributeList
Definition: AANTupleStream.cxx:359
runLayerRecalibration.branches
list branches
Definition: runLayerRecalibration.py:98
AthCommonDataStore< AthCommonMsg< Gaudi::Sequence > >::evtStore
ServiceHandle< StoreGateSvc > & evtStore()
The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.
Definition: AthCommonDataStore.h:85
AANTupleStream::m_tokenBranch
TBranch * m_tokenBranch
TBranch which contains Token info.
Definition: AANTupleStream.h:139
EventID.h
This class provides a unique identification for each event, in terms of run/event number and/or a tim...
checkTP.save
def save(self, fileName="./columbo.out")
Definition: checkTP.py:178
Amg::toString
std::string toString(const Translation3D &translation, int precision=4)
GeoPrimitvesToStringConverter.
Definition: GeoPrimitivesToStringConverter.h:40
AANTupleStream::initialize
virtual StatusCode initialize()
Initialize AANTupleStream.
Definition: AANTupleStream.cxx:79
SG::DataProxy::address
virtual IOpaqueAddress * address() const override final
Retrieve IOpaqueAddress.
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
AANTupleStream::isEventAccepted
bool isEventAccepted() const
check filters passed
Definition: AANTupleStream.cxx:692
AthLegacySequence
Alias for backward compatibility.
Definition: AthLegacySequence.h:63
ParseInputs.gDirectory
gDirectory
Definition: Final2012/ParseInputs.py:133
AANTupleStream::m_macro
std::string m_macro
macro
Definition: AANTupleStream.h:121
DataHeader
This class provides the layout for summary information stored for data written to POOL.
Definition: DataHeader.h:124
lumiFormat.i
int i
Definition: lumiFormat.py:92
AANTupleStream::io_reinit
StatusCode io_reinit()
callback method to reinitialize the internal state of the component for I/O purposes (e....
Definition: AANTupleStream.cxx:749
AANTupleStream::initSchema
StatusCode initSchema()
Definition: AANTupleStream.cxx:715
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
EventInfo::event_ID
EventID * event_ID()
the unique identification of the event.
Definition: EventInfo/EventInfo/EventInfo.h:210
DataHeader::sizeProvenance
int sizeProvenance() const
Definition: DataHeader.cxx:281
ClassID_traits
Default, invalid implementation of ClassID_traits.
Definition: Control/AthenaKernel/AthenaKernel/ClassID_traits.h:40
calibdata.exception
exception
Definition: calibdata.py:496
AANTupleStream::getFilters
StatusCode getFilters()
get filter alogs
Definition: AANTupleStream.cxx:628
AANTupleParams
Definition: AANTupleParams.h:9
AANTupleStream::m_tree
TTree * m_tree
TTree.
Definition: AANTupleStream.h:136
AANTupleParams.h
AANTupleStream::m_schemaDone
bool m_schemaDone
first event
Definition: AANTupleStream.h:124
xAOD::eventNumber
eventNumber
Definition: EventInfo_v1.cxx:124
DataHeader.h
This file contains the class definition for the DataHeader and DataHeaderElement classes.
AANTupleStream::m_treeName
std::string m_treeName
Name of the output tree.
Definition: AANTupleStream.h:127
CLID
uint32_t CLID
The Class ID type.
Definition: Event/xAOD/xAODCore/xAODCore/ClassID_traits.h:47
SG::DataProxy::clID
CLID clID() const
Retrieve clid.
AANTupleStream::m_streamName
std::string m_streamName
Name of Stream.
Definition: AANTupleStream.h:115
AANTupleStream.h
AANTupleStream::m_tokenCString
char m_tokenCString[s_maxLengthOfStrings]
Definition: AANTupleStream.h:149
AANTupleStream::m_attribSpec
coral::AttributeListSpecification * m_attribSpec
Collection attribute specification.
Definition: AANTupleStream.h:100
AANTupleStream::s_maxLengthOfStrings
static const unsigned int s_maxLengthOfStrings
for string branches
Definition: AANTupleStream.h:148
AANTupleStream::initCollection
StatusCode initCollection()
Initialize the output collection.
Definition: AANTupleStream.cxx:161
AANTupleStream::m_extraRefNames
StringArrayProperty m_extraRefNames
Vector of extra parent ref names to register in collection.
Definition: AANTupleStream.h:106
WriteBchToCool.beg
beg
Definition: WriteBchToCool.py:69
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
EventInfo
This class provides general information about an event. Event information is provided by the accessor...
Definition: EventInfo/EventInfo/EventInfo.h:42
SG::DataProxy::name
virtual const name_type & name() const override final
Retrieve data object key == string.
RTTAlgmain.address
address
Definition: RTTAlgmain.py:55
EventInfo.h
xAOD::EventInfo_v1
Class describing the basic event information.
Definition: EventInfo_v1.h:43
AANTupleStream::m_lateSchema
BooleanProperty m_lateSchema
write schema in execute()
Definition: AANTupleStream.h:118
Cut::all
@ all
Definition: SUSYToolsAlg.cxx:64
DeMoAtlasDataLoss.runNumber
string runNumber
Definition: DeMoAtlasDataLoss.py:64
AttributeListLayout.h
RTTAlgmain.branch
branch
Definition: RTTAlgmain.py:61
AttributeListLayout
Definition: AttributeListLayout.h:19
DiTauMassTools::MaxHistStrategyV2::e
e
Definition: PhysicsAnalysis/TauID/DiTauMassTools/DiTauMassTools/HelperFunctions.h:26
AANTupleStream::~AANTupleStream
virtual ~AANTupleStream()
Standard Destructor.
Definition: AANTupleStream.cxx:73
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
ref
const boost::regex ref(r_ef)
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
AANTupleStream::execute_subAlgos
StatusCode execute_subAlgos()
execute sub-algos
Definition: AANTupleStream.cxx:600
str
Definition: BTagTrackIpAccessor.cxx:11
AANTupleStream::m_tHistSvc
ServiceHandle< ITHistSvc > m_tHistSvc
THistSvc.
Definition: AANTupleStream.h:142
merge.status
status
Definition: merge.py:17
AANTupleStream::m_acceptNames
std::vector< std::string > m_acceptNames
Vector of names of Algorithms that this stream accepts.
Definition: AANTupleStream.h:130
SG::DataProxy
Definition: DataProxy.h:44
AANTTreeMap::setTree
static void setTree(const std::string &stream, TTree *tree)
Definition: AANTTreeMap.h:18
StoreGateSvc.h
SG::ConstIterator
Definition: SGIterator.h:163
AANTupleStream::m_writeInputDH
BooleanProperty m_writeInputDH
Flag to signal whether or not to write input data header.
Definition: AANTupleStream.h:109
AANTupleStream::initialize_subAlgos
StatusCode initialize_subAlgos()
initialize sub-algos
Definition: AANTupleStream.cxx:566
match
bool match(std::string s1, std::string s2)
match the individual directories of two strings
Definition: hcg.cxx:356
AANTupleStream::m_existDH
BooleanProperty m_existDH
Flag to signal whether data header exists.
Definition: AANTupleStream.h:112
ServiceHandle< IIoComponentMgr >
mapkey::key
key
Definition: TElectronEfficiencyCorrectionTool.cxx:37
AANTupleStream::m_fileName
std::string m_fileName
Name of the output collection.
Definition: AANTupleStream.h:103
DataProxy.h