ATLAS Offline Software
Public Member Functions | Protected Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
top::EventSaverxAOD Class Reference

Write out the selected events in xAOD format. More...

#include <EventSaverxAOD.h>

Inheritance diagram for top::EventSaverxAOD:
Collaboration diagram for top::EventSaverxAOD:

Public Member Functions

 EventSaverxAOD ()
 Kept simple, set the output container prefix (so they have a different name to the input containers). More...
 
virtual ~EventSaverxAOD ()
 
virtual void initialize (std::shared_ptr< top::TopConfig > config, TFile *file, const std::vector< std::string > &extraBranches)
 This does some configuration of the output file. More...
 
virtual StatusCode initialize ()
 Dummy implementation of the initialisation function. More...
 
virtual void saveEvent (const top::Event &event)
 Save an event. More...
 
virtual void finalize ()
 xAOD needs to write some more stuff to the file at the end of a job More...
 
virtual void execute ()
 Method to execute any calculations common for reco/particle/parton level. More...
 
virtual void saveEventToxAOD ()
 
virtual void saveTruthEvent ()
 @breif Run for every event More...
 
virtual void saveParticleLevelEvent (const top::ParticleLevelEvent &)
 Function to save the particle level event. More...
 
virtual void saveUpgradeEvent (const top::ParticleLevelEvent &)
 Function to save the upgrade event. More...
 
 ClassDef (top::EventSaverBase, 0)
 
virtual void print () const
 Print the state of the tool. More...
 
ServiceHandle< StoreGateSvc > & evtStore ()
 The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc. More...
 
const ServiceHandle< StoreGateSvc > & evtStore () const
 The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc. More...
 
const ServiceHandle< StoreGateSvc > & detStore () const
 The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc. More...
 
virtual StatusCode sysInitialize () override
 Perform system initialization for an algorithm. More...
 
virtual StatusCode sysStart () override
 Handle START transition. More...
 
virtual std::vector< Gaudi::DataHandle * > inputHandles () const override
 Return this algorithm's input handles. More...
 
virtual std::vector< Gaudi::DataHandle * > outputHandles () const override
 Return this algorithm's output handles. More...
 
Gaudi::Details::PropertyBase & declareProperty (Gaudi::Property< T > &t)
 
Gaudi::Details::PropertyBase * declareProperty (const std::string &name, SG::VarHandleKey &hndl, const std::string &doc, const SG::VarHandleKeyType &)
 Declare a new Gaudi property. More...
 
Gaudi::Details::PropertyBase * declareProperty (const std::string &name, SG::VarHandleBase &hndl, const std::string &doc, const SG::VarHandleType &)
 Declare a new Gaudi property. More...
 
Gaudi::Details::PropertyBase * declareProperty (const std::string &name, SG::VarHandleKeyArray &hndArr, const std::string &doc, const SG::VarHandleKeyArrayType &)
 
Gaudi::Details::PropertyBase * declareProperty (const std::string &name, T &property, const std::string &doc, const SG::NotHandleType &)
 Declare a new Gaudi property. More...
 
Gaudi::Details::PropertyBase * declareProperty (const std::string &name, T &property, const std::string &doc="none")
 Declare a new Gaudi property. More...
 
void updateVHKA (Gaudi::Details::PropertyBase &)
 
MsgStream & msg () const
 
MsgStream & msg (const MSG::Level lvl) const
 
bool msgLvl (const MSG::Level lvl) const
 

Protected Member Functions

void renounceArray (SG::VarHandleKeyArray &handlesArray)
 remove all handles from I/O resolution More...
 
std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > renounce (T &h)
 
void extraDeps_update_handler (Gaudi::Details::PropertyBase &ExtraDeps)
 Add StoreName to extra input/output deps as needed. More...
 

Private Types

typedef ServiceHandle< StoreGateSvcStoreGateSvc_t
 

Private Member Functions

 ClassDef (top::EventSaverxAOD, 0)
 
Gaudi::Details::PropertyBase & declareGaudiProperty (Gaudi::Property< T > &hndl, const SG::VarHandleKeyType &)
 specialization for handling Gaudi::Property<SG::VarHandleKey> More...
 
Gaudi::Details::PropertyBase & declareGaudiProperty (Gaudi::Property< T > &hndl, const SG::VarHandleKeyArrayType &)
 specialization for handling Gaudi::Property<SG::VarHandleKeyArray> More...
 
Gaudi::Details::PropertyBase & declareGaudiProperty (Gaudi::Property< T > &hndl, const SG::VarHandleType &)
 specialization for handling Gaudi::Property<SG::VarHandleBase> More...
 
Gaudi::Details::PropertyBase & declareGaudiProperty (Gaudi::Property< T > &t, const SG::NotHandleType &)
 specialization for handling everything that's not a Gaudi::Property<SG::VarHandleKey> or a <SG::VarHandleKeyArray> More...
 

Private Attributes

const std::string m_prefix
 Name to prepend to the output containers. More...
 
std::shared_ptr< top::TopConfigm_config
 We need access to the configuration file to get the container names. More...
 
TFile * m_outputFile
 We need to hold on to the output file. More...
 
StoreGateSvc_t m_evtStore
 Pointer to StoreGate (event store by default) More...
 
StoreGateSvc_t m_detStore
 Pointer to StoreGate (detector store by default) More...
 
std::vector< SG::VarHandleKeyArray * > m_vhka
 
bool m_varHandleArraysDeclared
 

Detailed Description

Write out the selected events in xAOD format.

At some point this will be the future. But probably not right now. Still too many missing features.

Definition at line 20 of file EventSaverxAOD.h.

Member Typedef Documentation

◆ StoreGateSvc_t

typedef ServiceHandle<StoreGateSvc> AthCommonDataStore< AthCommonMsg< AlgTool > >::StoreGateSvc_t
privateinherited

Definition at line 388 of file AthCommonDataStore.h.

Constructor & Destructor Documentation

◆ EventSaverxAOD()

top::EventSaverxAOD::EventSaverxAOD ( )

Kept simple, set the output container prefix (so they have a different name to the input containers).

Definition at line 20 of file EventSaverxAOD.cxx.

20  :
21  asg::AsgTool("top::EventSaverxAOD"),
22  m_prefix("CorrectedSelected"),
23  m_config(nullptr),
24  m_outputFile(nullptr) {
25  }

◆ ~EventSaverxAOD()

top::EventSaverxAOD::~EventSaverxAOD ( )
virtual

Definition at line 27 of file EventSaverxAOD.cxx.

27  {
28  }

Member Function Documentation

◆ ClassDef() [1/2]

top::EventSaverBase::ClassDef ( top::EventSaverBase  ,
 
)
inherited

◆ ClassDef() [2/2]

top::EventSaverxAOD::ClassDef ( top::EventSaverxAOD  ,
 
)
private

◆ declareGaudiProperty() [1/4]

Gaudi::Details::PropertyBase& AthCommonDataStore< AthCommonMsg< AlgTool > >::declareGaudiProperty ( Gaudi::Property< T > &  hndl,
const SG::VarHandleKeyArrayType  
)
inlineprivateinherited

specialization for handling Gaudi::Property<SG::VarHandleKeyArray>

Definition at line 170 of file AthCommonDataStore.h.

172  {
173  return *AthCommonDataStore<PBASE>::declareProperty(hndl.name(),
174  hndl.value(),
175  hndl.documentation());
176 
177  }

◆ declareGaudiProperty() [2/4]

Gaudi::Details::PropertyBase& AthCommonDataStore< AthCommonMsg< AlgTool > >::declareGaudiProperty ( Gaudi::Property< T > &  hndl,
const SG::VarHandleKeyType  
)
inlineprivateinherited

specialization for handling Gaudi::Property<SG::VarHandleKey>

Definition at line 156 of file AthCommonDataStore.h.

158  {
159  return *AthCommonDataStore<PBASE>::declareProperty(hndl.name(),
160  hndl.value(),
161  hndl.documentation());
162 
163  }

◆ declareGaudiProperty() [3/4]

Gaudi::Details::PropertyBase& AthCommonDataStore< AthCommonMsg< AlgTool > >::declareGaudiProperty ( Gaudi::Property< T > &  hndl,
const SG::VarHandleType  
)
inlineprivateinherited

specialization for handling Gaudi::Property<SG::VarHandleBase>

Definition at line 184 of file AthCommonDataStore.h.

186  {
187  return *AthCommonDataStore<PBASE>::declareProperty(hndl.name(),
188  hndl.value(),
189  hndl.documentation());
190  }

◆ declareGaudiProperty() [4/4]

Gaudi::Details::PropertyBase& AthCommonDataStore< AthCommonMsg< AlgTool > >::declareGaudiProperty ( Gaudi::Property< T > &  t,
const SG::NotHandleType  
)
inlineprivateinherited

specialization for handling everything that's not a Gaudi::Property<SG::VarHandleKey> or a <SG::VarHandleKeyArray>

Definition at line 199 of file AthCommonDataStore.h.

200  {
201  return PBASE::declareProperty(t);
202  }

◆ declareProperty() [1/6]

Gaudi::Details::PropertyBase* AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty ( const std::string &  name,
SG::VarHandleBase hndl,
const std::string &  doc,
const SG::VarHandleType  
)
inlineinherited

Declare a new Gaudi property.

Parameters
nameName of the property.
hndlObject holding the property value.
docDocumentation string for the property.

This is the version for types that derive from SG::VarHandleBase. The property value object is put on the input and output lists as appropriate; then we forward to the base class.

Definition at line 245 of file AthCommonDataStore.h.

249  {
250  this->declare(hndl.vhKey());
251  hndl.vhKey().setOwner(this);
252 
253  return PBASE::declareProperty(name,hndl,doc);
254  }

◆ declareProperty() [2/6]

Gaudi::Details::PropertyBase* AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty ( const std::string &  name,
SG::VarHandleKey hndl,
const std::string &  doc,
const SG::VarHandleKeyType  
)
inlineinherited

Declare a new Gaudi property.

Parameters
nameName of the property.
hndlObject holding the property value.
docDocumentation string for the property.

This is the version for types that derive from SG::VarHandleKey. The property value object is put on the input and output lists as appropriate; then we forward to the base class.

Definition at line 221 of file AthCommonDataStore.h.

225  {
226  this->declare(hndl);
227  hndl.setOwner(this);
228 
229  return PBASE::declareProperty(name,hndl,doc);
230  }

◆ declareProperty() [3/6]

Gaudi::Details::PropertyBase* AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty ( const std::string &  name,
SG::VarHandleKeyArray hndArr,
const std::string &  doc,
const SG::VarHandleKeyArrayType  
)
inlineinherited

Definition at line 259 of file AthCommonDataStore.h.

263  {
264 
265  // std::ostringstream ost;
266  // ost << Algorithm::name() << " VHKA declareProp: " << name
267  // << " size: " << hndArr.keys().size()
268  // << " mode: " << hndArr.mode()
269  // << " vhka size: " << m_vhka.size()
270  // << "\n";
271  // debug() << ost.str() << endmsg;
272 
273  hndArr.setOwner(this);
274  m_vhka.push_back(&hndArr);
275 
276  Gaudi::Details::PropertyBase* p = PBASE::declareProperty(name, hndArr, doc);
277  if (p != 0) {
278  p->declareUpdateHandler(&AthCommonDataStore<PBASE>::updateVHKA, this);
279  } else {
280  ATH_MSG_ERROR("unable to call declareProperty on VarHandleKeyArray "
281  << name);
282  }
283 
284  return p;
285 
286  }

◆ declareProperty() [4/6]

Gaudi::Details::PropertyBase* AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty ( const std::string &  name,
T &  property,
const std::string &  doc,
const SG::NotHandleType  
)
inlineinherited

Declare a new Gaudi property.

Parameters
nameName of the property.
propertyObject holding the property value.
docDocumentation string for the property.

This is the generic version, for types that do not derive from SG::VarHandleKey. It just forwards to the base class version of declareProperty.

Definition at line 333 of file AthCommonDataStore.h.

337  {
338  return PBASE::declareProperty(name, property, doc);
339  }

◆ declareProperty() [5/6]

Gaudi::Details::PropertyBase* AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty ( const std::string &  name,
T &  property,
const std::string &  doc = "none" 
)
inlineinherited

Declare a new Gaudi property.

Parameters
nameName of the property.
propertyObject holding the property value.
docDocumentation string for the property.

This dispatches to either the generic declareProperty or the one for VarHandle/Key/KeyArray.

Definition at line 352 of file AthCommonDataStore.h.

355  {
356  typedef typename SG::HandleClassifier<T>::type htype;
357  return declareProperty (name, property, doc, htype());
358  }

◆ declareProperty() [6/6]

Gaudi::Details::PropertyBase& AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty ( Gaudi::Property< T > &  t)
inlineinherited

Definition at line 145 of file AthCommonDataStore.h.

145  {
146  typedef typename SG::HandleClassifier<T>::type htype;
148  }

◆ detStore()

const ServiceHandle<StoreGateSvc>& AthCommonDataStore< AthCommonMsg< AlgTool > >::detStore ( ) const
inlineinherited

The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.

Definition at line 95 of file AthCommonDataStore.h.

95 { return m_detStore; }

◆ evtStore() [1/2]

ServiceHandle<StoreGateSvc>& AthCommonDataStore< AthCommonMsg< AlgTool > >::evtStore ( )
inlineinherited

The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.

Definition at line 85 of file AthCommonDataStore.h.

85 { return m_evtStore; }

◆ evtStore() [2/2]

const ServiceHandle<StoreGateSvc>& AthCommonDataStore< AthCommonMsg< AlgTool > >::evtStore ( ) const
inlineinherited

The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.

Definition at line 90 of file AthCommonDataStore.h.

90 { return m_evtStore; }

◆ execute()

virtual void top::EventSaverBase::execute ( )
inlinevirtualinherited

Method to execute any calculations common for reco/particle/parton level.

Reimplemented in top::EventSaverFlatNtuple.

Definition at line 48 of file EventSaverBase.h.

48 {return;}

◆ extraDeps_update_handler()

void AthCommonDataStore< AthCommonMsg< AlgTool > >::extraDeps_update_handler ( Gaudi::Details::PropertyBase &  ExtraDeps)
protectedinherited

Add StoreName to extra input/output deps as needed.

use the logic of the VarHandleKey to parse the DataObjID keys supplied via the ExtraInputs and ExtraOuputs Properties to add the StoreName if it's not explicitly given

◆ finalize()

void top::EventSaverxAOD::finalize ( )
virtual

xAOD needs to write some more stuff to the file at the end of a job

Reimplemented from top::EventSaverBase.

Definition at line 208 of file EventSaverxAOD.cxx.

208  {
209  m_outputFile->Write();
210  top::check(evtStore()->event()->finishWritingTo(
211  m_outputFile), "EventSaverxAOD::finalise trying to call finishWritingTo");
212  }

◆ getKey()

SG::sgkey_t asg::AsgTool::getKey ( const void *  ptr) const
inherited

Get the (hashed) key of an object that is in the event store.

This is a bit of a special one. StoreGateSvc and xAOD::TEvent both provide ways for getting the SG::sgkey_t key for an object that is in the store, based on a bare pointer. But they provide different interfaces for doing so.

In order to allow tools to efficiently perform this operation, they can use this helper function.

See also
asg::AsgTool::getName
Parameters
ptrThe bare pointer to the object that the event store should know about
Returns
The hashed key of the object in the store. If not found, an invalid (zero) key.

Definition at line 119 of file AsgTool.cxx.

119  {
120 
121 #ifdef XAOD_STANDALONE
122  // In case we use @c xAOD::TEvent, we have a direct function call
123  // for this.
124  return evtStore()->event()->getKey( ptr );
125 #else
126  const SG::DataProxy* proxy = evtStore()->proxy( ptr );
127  return ( proxy == nullptr ? 0 : proxy->sgkey() );
128 #endif // XAOD_STANDALONE
129  }

◆ getName()

const std::string & asg::AsgTool::getName ( const void *  ptr) const
inherited

Get the name of an object that is / should be in the event store.

This is a bit of a special one. StoreGateSvc and xAOD::TEvent both provide ways for getting the std::string name for an object that is in the store, based on a bare pointer. But they provide different interfaces for doing so.

In order to allow tools to efficiently perform this operation, they can use this helper function.

See also
asg::AsgTool::getKey
Parameters
ptrThe bare pointer to the object that the event store should know about
Returns
The string name of the object in the store. If not found, an empty string.

Definition at line 106 of file AsgTool.cxx.

106  {
107 
108 #ifdef XAOD_STANDALONE
109  // In case we use @c xAOD::TEvent, we have a direct function call
110  // for this.
111  return evtStore()->event()->getName( ptr );
112 #else
113  const SG::DataProxy* proxy = evtStore()->proxy( ptr );
114  static const std::string dummy = "";
115  return ( proxy == nullptr ? dummy : proxy->name() );
116 #endif // XAOD_STANDALONE
117  }

◆ getProperty()

template<class T >
const T* asg::AsgTool::getProperty ( const std::string &  name) const
inherited

Get one of the tool's properties.

◆ initialize() [1/2]

virtual StatusCode top::EventSaverxAOD::initialize ( )
inlinevirtual

Dummy implementation of the initialisation function.

It's here to allow the dual-use tools to skip defining an initialisation function. Since many are doing so...

Reimplemented from asg::AsgTool.

Definition at line 51 of file EventSaverxAOD.h.

51 {return StatusCode::SUCCESS;}

◆ initialize() [2/2]

void top::EventSaverxAOD::initialize ( std::shared_ptr< top::TopConfig config,
TFile *  file,
const std::vector< std::string > &  extraBranches 
)
virtual

This does some configuration of the output file.

It also keeps track of which branches should be saved.

You surely don't need all the branches, but if you do remove the corresponding line.

We can't do much in the constructor, like I would like, because we're letting root make this. So instead we have a function here.

Parameters
configThe top::TopConfig object that contains lots of settings and stuff.
fileThe output TFile that you want to save things to.
extraBranchesList of extra branches that (currently) are attached to EventInfo. e.g. the branch that tells you if an event passed a certain selection. If you add it here, it'll be written to the output file.

Implements top::EventSaverBase.

Definition at line 30 of file EventSaverxAOD.cxx.

31  {
32  m_config = config;
34  top::check(evtStore()->event()->writeTo(m_outputFile), "EventSaverxAOD trying to call writeTo on output file");
35 
36  //EventInfo
37  std::string eventInfoList = "runNumber.eventNumber.eventTypeBitmask.averageInteractionsPerCrossing";
38  if (config->isMC()) eventInfoList += ".mcChannelNumber.mcEventWeights.PileupWeight";
39 
40  //Add extra branches - e.g. if it passed the ee / mumu / emu selection per event
41  for (const auto& branchName : extraBranches)
42  eventInfoList += "." + branchName;
43 
44  evtStore()->event()->setAuxItemList("EventInfoAux.", eventInfoList);
45 
46  //Electrons
47  evtStore()->event()->setAuxItemList(m_prefix + m_config->sgKeyElectrons() + "Aux.", "pt.eta.phi.m.charge");
48 
49  //Muons
50  evtStore()->event()->setAuxItemList(
51  m_prefix + m_config->sgKeyMuons() + "Aux.", "pt.eta.phi.m.charge.muonType.combinedTrackParticleLink");
52 
53  //Once mu has a built-in charge we can get rid of this
54  //Muon charge is a property of the associated track - e.g. d0.z0.phi.theta.qOverP
55  evtStore()->event()->setAuxItemList("InDetTrackParticlesAux.", "qOverP");
56  evtStore()->event()->setAuxItemList("ExtrapolatedMuonTrackParticlesAux.", "qOverP");
57  evtStore()->event()->setAuxItemList("CombinedMuonTrackParticlesAux.", "qOverP");
58 
59  //Jets
60  evtStore()->event()->setAuxItemList(m_prefix + m_config->sgKeyJets() + "Aux.", "pt.eta.phi.m.btaggingLink");
61 
62  }

◆ inputHandles()

virtual std::vector<Gaudi::DataHandle*> AthCommonDataStore< AthCommonMsg< AlgTool > >::inputHandles ( ) const
overridevirtualinherited

Return this algorithm's input handles.

We override this to include handle instances from key arrays if they have not yet been declared. See comments on updateVHKA.

◆ msg() [1/2]

MsgStream& AthCommonMsg< AlgTool >::msg ( ) const
inlineinherited

Definition at line 24 of file AthCommonMsg.h.

24  {
25  return this->msgStream();
26  }

◆ msg() [2/2]

MsgStream& AthCommonMsg< AlgTool >::msg ( const MSG::Level  lvl) const
inlineinherited

Definition at line 27 of file AthCommonMsg.h.

27  {
28  return this->msgStream(lvl);
29  }

◆ msg_level_name()

const std::string & asg::AsgTool::msg_level_name ( ) const
inherited

A deprecated function for getting the message level's name.

Instead of using this, weirdly named function, user code should get the string name of the current minimum message level (in case they really need it...), with:

MSG::name( msg().level() )

This function's name doesn't follow the ATLAS coding rules, and as such will be removed in the not too distant future.

Returns
The string name of the current minimum message level that's printed

Definition at line 101 of file AsgTool.cxx.

101  {
102 
103  return MSG::name( msg().level() );
104  }

◆ msgLvl()

bool AthCommonMsg< AlgTool >::msgLvl ( const MSG::Level  lvl) const
inlineinherited

Definition at line 30 of file AthCommonMsg.h.

30  {
31  return this->msgLevel(lvl);
32  }

◆ outputHandles()

virtual std::vector<Gaudi::DataHandle*> AthCommonDataStore< AthCommonMsg< AlgTool > >::outputHandles ( ) const
overridevirtualinherited

Return this algorithm's output handles.

We override this to include handle instances from key arrays if they have not yet been declared. See comments on updateVHKA.

◆ print()

void asg::AsgTool::print ( ) const
virtualinherited

◆ renounce()

std::enable_if_t<std::is_void_v<std::result_of_t<decltype(&T::renounce)(T)> > && !std::is_base_of_v<SG::VarHandleKeyArray, T> && std::is_base_of_v<Gaudi::DataHandle, T>, void> AthCommonDataStore< AthCommonMsg< AlgTool > >::renounce ( T &  h)
inlineprotectedinherited

Definition at line 380 of file AthCommonDataStore.h.

381  {
382  h.renounce();
383  PBASE::renounce (h);
384  }

◆ renounceArray()

void AthCommonDataStore< AthCommonMsg< AlgTool > >::renounceArray ( SG::VarHandleKeyArray handlesArray)
inlineprotectedinherited

remove all handles from I/O resolution

Definition at line 364 of file AthCommonDataStore.h.

364  {
365  handlesArray.renounce();
366  }

◆ saveEvent()

void top::EventSaverxAOD::saveEvent ( const top::Event event)
virtual

Save an event.

Why am I only writing out the nominal tree.

I thought the fill for the xaod would allow me to specify the tree name, but it seems I can only do that in the writeTo. Maybe their is a clever way around it, but I'm too tired of this.

Why not save shallow copies? This would be nice. But aren't shallow copies unsorted? We'd have to remember to sort them.

It looks like branch removal from things in containers (jets, leptons) is still not working. So the xAOD files are still huge.

Parameters
eventThe top event for this particular systematic variation.
xaodEventThe xAOD event object, so we can actually save.

Reimplemented from top::EventSaverBase.

Definition at line 64 of file EventSaverxAOD.cxx.

64  {
65  //only save the nominal variation for now - speak to Attila about TEvent.fill not taking a tree name
66  if (event.m_hashValue != m_config->nominalHashValue()) return;
67 
68  // record the event?
69  if (m_config->saveOnlySelectedEvents() && !event.m_saveEvent) return;
70 
71  // Systematic Event
72  const xAOD::SystematicEventContainer* allSystematics(nullptr);
73  top::check(evtStore()->retrieve(allSystematics,
74  m_config->sgKeyTopSystematicEvents()),
75  "Failed to retrieve xAOD::SystematicEventContainer");
76  //cppcheck-suppress uninitvar
77  xAOD::SystematicEventContainer* allSystematics_output = new xAOD::SystematicEventContainer {};
78  SG::IAuxStore* allSystematics_aux = evtStore()->event()->recordAux(m_config->sgKeyTopSystematicEvents() + "Aux.");
79  allSystematics_output->setStore(allSystematics_aux);
80  for (const auto *currentSystematic : *allSystematics) {
81  //cppcheck-suppress uninitvar
83  out->makePrivateStore(*currentSystematic);
84  allSystematics_output->push_back(out);
85  }
86  top::check(evtStore()->event()->record(allSystematics_output,
87  m_config->sgKeyTopSystematicEvents()),
88  "Failed to record xAOD::SystematicEventContainer");
89 
90 
91  // Top Parton History
92  if (m_config->doTopPartonHistory()) {
93  if (evtStore()->contains<xAOD::PartonHistoryContainer>(m_config->sgKeyTopPartonHistory())) {
94  const xAOD::PartonHistoryContainer* partonHistory(nullptr);
95  top::check(evtStore()->retrieve(partonHistory,
96  m_config->sgKeyTopPartonHistory()), "Failed to retrieve Top Parton History");
97  //cppcheck-suppress uninitvar
98  xAOD::PartonHistoryContainer* partonHistory_output = new xAOD::PartonHistoryContainer {};
99  SG::IAuxStore* partonHistory_aux = evtStore()->event()->recordAux(m_config->sgKeyTopPartonHistory() + "Aux.");
100  partonHistory_output->setStore(partonHistory_aux);
101  for (const auto *x : *partonHistory) {
102  //cppcheck-suppress uninitvar
104  out->makePrivateStore(*x);
105  partonHistory_output->push_back(out);
106  }
107  top::check(evtStore()->event()->record(partonHistory_output,
108  m_config->sgKeyTopPartonHistory()), "Failed to record Parton History");
109  }
110  }
111 
112 
113 
114  //Event Info
115  top::check(evtStore()->event()->copy("EventInfo"), "copying event info failed");
116 
117  //Electrons
118  if (m_config->useElectrons()) {
119  xAOD::ElectronContainer* electrons_output = new xAOD::ElectronContainer();
120  SG::IAuxStore* electrons_aux = evtStore()->event()->recordAux(m_prefix + m_config->sgKeyElectrons() + "Aux.");
121  electrons_output->setStore(electrons_aux);
122 
123  for (const auto* const elPtr : event.m_electrons) {
124  xAOD::Electron* outputElPtr = new xAOD::Electron();
125  outputElPtr->makePrivateStore(*elPtr);
126  electrons_output->push_back(outputElPtr);
127  }
128 
129  top::check(evtStore()->event()->record(electrons_output,
130  m_prefix + m_config->sgKeyElectrons()),
131  "xAOD::TEvent record " + m_prefix + m_config->sgKeyElectrons() + " failed");
132  }
133 
134  //Muons
135  if (m_config->useMuons()) {
136  xAOD::MuonContainer* muons_output = new xAOD::MuonContainer();
137  SG::IAuxStore* muons_aux = evtStore()->event()->recordAux(m_prefix + m_config->sgKeyMuons() + "Aux.");
138  muons_output->setStore(muons_aux);
139 
140  for (const auto* const muPtr : event.m_muons) {
141  xAOD::Muon* outputMuPtr = new xAOD::Muon();
142  outputMuPtr->makePrivateStore(*muPtr);
143  muons_output->push_back(outputMuPtr);
144  }
145 
146  top::check(evtStore()->event()->record(muons_output,
147  m_prefix + m_config->sgKeyMuons()),
148  "xAOD::TEvent record " + m_prefix + m_config->sgKeyMuons() + " failed");
149 
150  //for now...
151  //Muon charge is a property of the associated track
152  //Copy tracks (for muon charge)
153  check(evtStore()->event()->copy("InDetTrackParticles"), "xAOD::TEvent copy InDetTrackParticles failed");
154  check(evtStore()->event()->copy(
155  "ExtrapolatedMuonTrackParticles"),
156  "xAOD::TEvent copy InDetTrackParticles ExtrapolatedMuonTrackParticles");
157  check(evtStore()->event()->copy(
158  "CombinedMuonTrackParticles"), "xAOD::TEvent copy InDetTrackParticles CombinedMuonTrackParticles");
159  }
160 
161  //Jets
162  if (m_config->useJets()) {
163  xAOD::JetContainer* jets_output = new xAOD::JetContainer();
164  SG::IAuxStore* jets_aux = evtStore()->event()->recordAux(m_prefix + m_config->sgKeyJets() + "Aux.");
165  jets_output->setStore(jets_aux);
166 
167  for (const auto* const jetPtr : event.m_jets) {
168  xAOD::Jet* outputJetPtr = new xAOD::Jet();
169  outputJetPtr->makePrivateStore(*jetPtr);
170  jets_output->push_back(outputJetPtr);
171  }
172 
173  top::check(evtStore()->event()->record(jets_output,
174  m_prefix + m_config->sgKeyJets()),
175  "xAOD::TEvent record " + m_prefix + m_config->sgKeyJets() + " failed");
176 
177  //b-tagging variables need the BTagging_JetNameWithoutJetsOnTheEnd container
178  //remove Jets from the end of the container name and add BTagging_
179  const std::string btagName = "BTagging_" + m_config->sgKeyJets().substr(0, m_config->sgKeyJets().size() - 4);
180  check(evtStore()->event()->copy(btagName), "xAOD::TEvent copy " + btagName + " failed");
181  }
182 
183  //Large Jets
184  if (m_config->useLargeRJets()) {
185  xAOD::JetContainer* largeJets_output = new xAOD::JetContainer();
186  SG::IAuxStore* largeJets_aux = evtStore()->event()->recordAux(m_prefix + m_config->sgKeyLargeRJets() + "Aux.");
187  largeJets_output->setStore(largeJets_aux);
188 
189  for (const auto* const jetPtr : event.m_largeJets) {
190  xAOD::Jet* outputJetPtr = new xAOD::Jet();
191  outputJetPtr->makePrivateStore(*jetPtr);
192  largeJets_output->push_back(outputJetPtr);
193  }
194 
195  check(evtStore()->event()->record(largeJets_output,
196  m_prefix + m_config->sgKeyLargeRJets()),
197  "xAOD::TEvent record " + m_prefix + m_config->sgKeyLargeRJets() + " failed");
198  }
199 
200  //MET
201  top::check(evtStore()->event()->copy(m_config->sgKeyMissingEt()),
202  "xAOD::TEvent copy " + m_config->sgKeyMissingEt() + " failed");
203 
204  //do it!
205  top::check(evtStore()->event()->fill(), "xAOD::TEvent fill failed");
206  }

◆ saveEventToxAOD()

virtual void top::EventSaverBase::saveEventToxAOD ( )
inlinevirtualinherited

Reimplemented in top::EventSaverxAODNext.

Definition at line 60 of file EventSaverBase.h.

60 {return;}

◆ saveParticleLevelEvent()

virtual void top::EventSaverBase::saveParticleLevelEvent ( const top::ParticleLevelEvent )
inlinevirtualinherited

Function to save the particle level event.

This function has a default implementation that does ... nothing! This is deliberate since doing so does not force developers of custom EventSaver tools to implement particle level saving.

Parameters
plEventThe particle level event whose contents will be saved.

Reimplemented in top::EventSaverFlatNtuple.

Definition at line 79 of file EventSaverBase.h.

79  {
80  /* Deliberately No-Op */
81  return;
82  }

◆ saveTruthEvent()

virtual void top::EventSaverBase::saveTruthEvent ( )
inlinevirtualinherited

@breif Run for every event

This fills, if requested, the: MC truth record PDF info TopPartons

Reimplemented in top::EventSaverFlatNtuple.

Definition at line 70 of file EventSaverBase.h.

70 {return;}

◆ saveUpgradeEvent()

virtual void top::EventSaverBase::saveUpgradeEvent ( const top::ParticleLevelEvent )
inlinevirtualinherited

Function to save the upgrade event.

This function has a default implementation that does ... nothing! This is deliberate since doing so does not force developers of custom EventSaver tools to implement upgrade saving.

Parameters
upgradeEventThe upgrade event whose contents will be saved.

Definition at line 91 of file EventSaverBase.h.

91  {
92  /* Deliberately No-Op */
93  return;
94  }

◆ sysInitialize()

virtual StatusCode AthCommonDataStore< AthCommonMsg< AlgTool > >::sysInitialize ( )
overridevirtualinherited

Perform system initialization for an algorithm.

We override this to declare all the elements of handle key arrays at the end of initialization. See comments on updateVHKA.

Reimplemented in DerivationFramework::CfAthAlgTool, AthCheckedComponent< AthAlgTool >, AthCheckedComponent<::AthAlgTool >, and asg::AsgMetadataTool.

◆ sysStart()

virtual StatusCode AthCommonDataStore< AthCommonMsg< AlgTool > >::sysStart ( )
overridevirtualinherited

Handle START transition.

We override this in order to make sure that conditions handle keys can cache a pointer to the conditions container.

◆ updateVHKA()

void AthCommonDataStore< AthCommonMsg< AlgTool > >::updateVHKA ( Gaudi::Details::PropertyBase &  )
inlineinherited

Definition at line 308 of file AthCommonDataStore.h.

308  {
309  // debug() << "updateVHKA for property " << p.name() << " " << p.toString()
310  // << " size: " << m_vhka.size() << endmsg;
311  for (auto &a : m_vhka) {
312  std::vector<SG::VarHandleKey*> keys = a->keys();
313  for (auto k : keys) {
314  k->setOwner(this);
315  }
316  }
317  }

Member Data Documentation

◆ m_config

std::shared_ptr<top::TopConfig> top::EventSaverxAOD::m_config
private

We need access to the configuration file to get the container names.

Definition at line 80 of file EventSaverxAOD.h.

◆ m_detStore

StoreGateSvc_t AthCommonDataStore< AthCommonMsg< AlgTool > >::m_detStore
privateinherited

Pointer to StoreGate (detector store by default)

Definition at line 393 of file AthCommonDataStore.h.

◆ m_evtStore

StoreGateSvc_t AthCommonDataStore< AthCommonMsg< AlgTool > >::m_evtStore
privateinherited

Pointer to StoreGate (event store by default)

Definition at line 390 of file AthCommonDataStore.h.

◆ m_outputFile

TFile* top::EventSaverxAOD::m_outputFile
private

We need to hold on to the output file.

Definition at line 83 of file EventSaverxAOD.h.

◆ m_prefix

const std::string top::EventSaverxAOD::m_prefix
private

Name to prepend to the output containers.

Definition at line 77 of file EventSaverxAOD.h.

◆ m_varHandleArraysDeclared

bool AthCommonDataStore< AthCommonMsg< AlgTool > >::m_varHandleArraysDeclared
privateinherited

Definition at line 399 of file AthCommonDataStore.h.

◆ m_vhka

std::vector<SG::VarHandleKeyArray*> AthCommonDataStore< AthCommonMsg< AlgTool > >::m_vhka
privateinherited

Definition at line 398 of file AthCommonDataStore.h.


The documentation for this class was generated from the following files:
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
xAOD::PartonHistory
Interface class.
Definition: PartonHistory.h:48
asg::AsgTool
Base class for the dual-use tool implementation classes.
Definition: AsgTool.h:47
xAOD::Electron
Electron_v1 Electron
Definition of the current "egamma version".
Definition: Event/xAOD/xAODEgamma/xAODEgamma/Electron.h:17
StateLessPT_NewConfig.proxy
proxy
Definition: StateLessPT_NewConfig.py:392
python.PerfMonSerializer.p
def p
Definition: PerfMonSerializer.py:743
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
xAOD::MuonContainer
MuonContainer_v1 MuonContainer
Definition of the current "Muon container version".
Definition: Event/xAOD/xAODMuon/xAODMuon/MuonContainer.h:14
AthCommonDataStore::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
top::EventSaverxAOD::m_outputFile
TFile * m_outputFile
We need to hold on to the output file.
Definition: EventSaverxAOD.h:83
python.AthDsoLogger.out
out
Definition: AthDsoLogger.py:71
AthCommonDataStore< AthCommonMsg< AlgTool > >::m_evtStore
StoreGateSvc_t m_evtStore
Pointer to StoreGate (event store by default)
Definition: AthCommonDataStore.h:390
AthCommonDataStore< AthCommonMsg< AlgTool > >::m_vhka
std::vector< SG::VarHandleKeyArray * > m_vhka
Definition: AthCommonDataStore.h:398
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
x
#define x
xAOD::Muon_v1
Class describing a Muon.
Definition: Muon_v1.h:38
config
Definition: PhysicsAnalysis/AnalysisCommon/AssociationUtils/python/config.py:1
python.iconfTool.models.loaders.level
level
Definition: loaders.py:20
SG::VarHandleKeyArray::setOwner
virtual void setOwner(IDataHandleHolder *o)=0
AthCommonDataStore< AthCommonMsg< AlgTool > >::evtStore
ServiceHandle< StoreGateSvc > & evtStore()
The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.
Definition: AthCommonDataStore.h:85
AthCommonDataStore
Definition: AthCommonDataStore.h:52
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
event
POOL::TEvent event(POOL::TEvent::kClassAccess)
file
TFile * file
Definition: tile_monitor.h:29
top::check
void check(bool thingToCheck, const std::string &usefulFailureMessage)
Print an error message and terminate if thingToCheck is false.
Definition: EventTools.cxx:15
python.xAODType.dummy
dummy
Definition: xAODType.py:4
MSG::name
const std::string & name(Level lvl)
Convenience function for translating message levels to strings.
Definition: MsgLevel.cxx:19
AthCommonDataStore< AthCommonMsg< AlgTool > >::m_detStore
StoreGateSvc_t m_detStore
Pointer to StoreGate (detector store by default)
Definition: AthCommonDataStore.h:393
DataVector
Derived DataVector<T>.
Definition: DataVector.h:581
top::EventSaverxAOD::m_config
std::shared_ptr< top::TopConfig > m_config
We need access to the configuration file to get the container names.
Definition: EventSaverxAOD.h:80
xAOD::ElectronContainer
ElectronContainer_v1 ElectronContainer
Definition of the current "electron container version".
Definition: Event/xAOD/xAODEgamma/xAODEgamma/ElectronContainer.h:17
SG::VarHandleKeyArray::renounce
virtual void renounce()=0
SG::HandleClassifier::type
std::conditional< std::is_base_of< SG::VarHandleKeyArray, T >::value, VarHandleKeyArrayType, type2 >::type type
Definition: HandleClassifier.h:54
xAOD::Muon
Muon_v1 Muon
Reference the current persistent version:
Definition: Event/xAOD/xAODMuon/xAODMuon/Muon.h:13
merge_scale_histograms.doc
string doc
Definition: merge_scale_histograms.py:9
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:192
DataVector::push_back
value_type push_back(value_type pElem)
Add an element to the end of the collection.
SG::AuxElement::makePrivateStore
void makePrivateStore()
Create a new (empty) private store for this object.
Definition: AuxElement.cxx:172
xAOD::Electron_v1
Definition: Electron_v1.h:34
SG::IAuxStore
Interface for non-const operations on an auxiliary store.
Definition: IAuxStore.h:48
xAOD::Jet_v1
Class describing a jet.
Definition: Jet_v1.h:57
a
TList * a
Definition: liststreamerinfos.cxx:10
xAOD::SystematicEvent
SystematicEvent A simple xAOD class which we can persist into a mini-xAOD The xAOD EDM is way too com...
Definition: SystematicEvent.h:27
h
lumiFormat.fill
fill
Definition: lumiFormat.py:111
config
std::vector< std::string > config
Definition: fbtTestBasics.cxx:72
AthCommonMsg< AlgTool >::msg
MsgStream & msg() const
Definition: AthCommonMsg.h:24
SG::VarHandleBase::vhKey
SG::VarHandleKey & vhKey()
Return a non-const reference to the HandleKey.
Definition: StoreGate/src/VarHandleBase.cxx:616
declareProperty
#define declareProperty(n, p, h)
Definition: BaseFakeBkgTool.cxx:15
python.Bindings.keys
keys
Definition: Control/AthenaPython/python/Bindings.py:790
xAOD::JetContainer
JetContainer_v1 JetContainer
Definition of the current "jet container version".
Definition: JetContainer.h:17
calibdata.copy
bool copy
Definition: calibdata.py:27
top::EventSaverxAOD::m_prefix
const std::string m_prefix
Name to prepend to the output containers.
Definition: EventSaverxAOD.h:77
SG::DataProxy
Definition: DataProxy.h:44
AthCommonDataStore::declareGaudiProperty
Gaudi::Details::PropertyBase & declareGaudiProperty(Gaudi::Property< T > &hndl, const SG::VarHandleKeyType &)
specialization for handling Gaudi::Property<SG::VarHandleKey>
Definition: AthCommonDataStore.h:156
xAOD::Jet
Jet_v1 Jet
Definition of the current "jet version".
Definition: Event/xAOD/xAODJet/xAODJet/Jet.h:17
fitman.k
k
Definition: fitman.py:528