ATLAS Offline Software
WeightsAgregator.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 // ReweightUtils includes
7 
9 
10 
12  : WeightToolBase( name ),
13  m_eventInfoName("EventInfo"),
14  m_toolArray() {
15  declareProperty("Ingredients", m_toolArray, "List of helpers to offload some tasks to" );
16  declareProperty("EventInfoName", m_eventInfoName, "Name of the xAOD::EventInfo object");
17 }
18 
19 
21  ATH_MSG_DEBUG ("Initializing " << name() << "...");
23 
24  // Retrieve the needed weight tools
25  ATH_CHECK(m_toolArray.retrieve());
26 
27  return StatusCode::SUCCESS;
28 }
29 
30 
31 
32 // returns: the value that was calculated from the xAOD::IParticle composite built event
34 {
35  ATH_MSG_DEBUG ("Evaluating " << name() << "...");
36 
37  double weight=1.0;
38  for ( const auto& wToolHandle : m_toolArray ){
39  const IWeightTool* wtool = &(*wToolHandle);
40  ATH_MSG_DEBUG (" In WeightsAgregator::evaluate(), having tool to deal with called " << wtool->name());
41  if( const IObservableTool* obstool = dynamic_cast< const IObservableTool* >( wtool ) )
42  weight *= obstool->evaluate(part);
43  }
44 
45  ATH_MSG_DEBUG ("Got weight in WeightsAgregator::evaluate() = " << weight << ".");
46  return weight;
47 }
48 
49 
51  //Retrieveing eventInfo
52  const xAOD::EventInfo* evtInfo;
53  StatusCode sc = evtStore()->retrieve( evtInfo, m_eventInfoName );
54  if(sc.isFailure() || !evtInfo) {
55  ATH_MSG_ERROR (" EventInfo could not be retrieved !!");
56  return 0.;
57  }
58 
59  // don't do anything for data
61  ATH_MSG_DEBUG (" Returning weight=1. for data.");
62  return 1.;
63  }
64 
65  float weight=1.;
66  ToolHandleArray< IWeightTool >::const_iterator itPriv = m_toolArray.begin(), itPrivEnd = m_toolArray.end();
67  for ( ; itPriv != itPrivEnd; ++itPriv ) {
68  /*if (!(*itPriv))
69  ATH_MSG_ERROR("tool " << (*itPriv).typeAndName() << " failed it's task ... stop!");*/
70  weight *= (*itPriv)->getWeight();
71  }
72 
73  //Decorate EventInfo with weight for later use
74  this->addDecoration(evtInfo, weight);
75 
76 
77  ATH_MSG_DEBUG (" " << name() << " returning weight= " << weight << ".");
78  return weight;
79 }
LArG4FSStartPointFilter.part
part
Definition: LArG4FSStartPointFilter.py:21
CompositeParticle.h
AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
IObservableTool
Interface for tools that want to calculate a quantity from an xAOD::IParticle.
Definition: IObservableTool.h:32
WeightToolBase::initialize
virtual StatusCode initialize() override
Usual initialize method of the framework.
Definition: WeightToolBase.cxx:21
WeightsAgregator::getWeight
virtual double getWeight() const override
returns: the value that was calculated from the usual Athena storegate
Definition: WeightsAgregator.cxx:50
WeightsAgregator::evaluate
virtual double evaluate(const xAOD::IParticle *part) const override
returns: the value that was calculated from the xAOD::IParticle (composite built event object for ins...
Definition: WeightsAgregator.cxx:33
xAOD::IParticle
Class providing the definition of the 4-vector interface.
Definition: Event/xAOD/xAODBase/xAODBase/IParticle.h:41
xAOD::EventInfo_v1::IS_SIMULATION
@ IS_SIMULATION
true: simulation, false: data
Definition: EventInfo_v1.h:151
AthenaPoolTestRead.sc
sc
Definition: AthenaPoolTestRead.py:27
dqt_zlumi_pandas.weight
int weight
Definition: dqt_zlumi_pandas.py:189
AthCommonDataStore< AthCommonMsg< AlgTool > >::evtStore
ServiceHandle< StoreGateSvc > & evtStore()
The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.
Definition: AthCommonDataStore.h:85
WeightsAgregator::m_eventInfoName
std::string m_eventInfoName
Name of the xAOD::EventInfo object.
Definition: WeightsAgregator.h:47
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
IWeightTool
Interface for tools that want to calculate a weight from different event information.
Definition: IWeightTool.h:21
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
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
WeightsAgregator::initialize
virtual StatusCode initialize() override
Usual initialize method of the framework.
Definition: WeightsAgregator.cxx:20
WeightsAgregator::WeightsAgregator
WeightsAgregator(const std::string &name)
Create a proper constructor for Athena.
Definition: WeightsAgregator.cxx:11
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
xAOD::EventInfo_v1
Class describing the basic event information.
Definition: EventInfo_v1.h:43
WeightToolBase
Definition: WeightToolBase.h:29
WeightsAgregator.h
WeightToolBase::addDecoration
bool addDecoration(const xAOD::EventInfo *evtInfo, float weight) const
Definition: WeightToolBase.cxx:42
xAOD::EventInfo_v1::eventType
bool eventType(EventType type) const
Check for one particular bitmask value.
WeightsAgregator::m_toolArray
ToolHandleArray< IWeightTool > m_toolArray
Array of ingredient weight tools.
Definition: WeightsAgregator.h:50