ATLAS Offline Software
Loading...
Searching...
No Matches
PileupReweightingProvider.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
3*/
4
5#ifndef PILEUPREWEIGHTINGPROVIDER
6#define PILEUPREWEIGHTINGPROVIDER
7
10#include "GaudiKernel/ToolHandle.h"
11
13
15
16namespace CP {
17
19
20 public:
21 PileupReweightingProvider( const std::string& name, ISvcLocator* svcloc) : AthAlgorithm(name,svcloc),m_tool("CP::PileupReweightingTool/auto") {
22 declareProperty("Tool",m_tool,"The configured PileupReweightingTool");
23 declareProperty("Input",m_inputKey="","Specify a specific EventInfo object");
24 declareProperty("Output",m_outputKey="","Specify an output EventInfo object. If differs from input, will create a clone of EventInfo and decorate that");
25 declareProperty("ConfigOutputStream",m_configStream="","Specify the stream to output config file to");
26 declareProperty("RunSystematics",m_systematics=true,"Enable systematics during run");
27 }
28
30
31 virtual StatusCode initialize() {
32 CHECK( m_tool.retrieve() );
33
34 IProperty* myTool = dynamic_cast<IProperty*>(&*m_tool);
35 if (!myTool)
36 return StatusCode::FAILURE;
37 CHECK( myTool->setProperty("ConfigOutputStream",m_configStream) );
38
39 //get the list of systematics
42
43 if(m_configStream!="") ATH_MSG_INFO("Now running config file making .... please be patient! ... ");
44
45 return StatusCode::SUCCESS;
46 }
47 virtual StatusCode execute() {
48 const xAOD::EventInfo* evtInfo =0;
49
50 if(m_inputKey.length()>0) ATH_CHECK(evtStore()->retrieve(evtInfo,m_inputKey));
51 else {
52 #ifdef XAOD_STANDALONE
53 ATH_CHECK( evtStore()->retrieve(evtInfo,"") ); //apparently TEvent can't do keyless retrieves!!??
54 #else
55 ATH_CHECK(evtStore()->retrieve(evtInfo));
56 #endif
57 }
58
59 //do we need to make a copy??
61 xAOD::EventInfo* evtInfoCopy = new xAOD::EventInfo( *evtInfo );
63 evtInfoCopy->setStore(aux);
64 ATH_CHECK( evtStore()->record( evtInfoCopy , m_outputKey ) );
65 ATH_CHECK( evtStore()->record( aux , m_outputKey+"Aux." ) );
66 evtInfo = evtInfoCopy;
67 }
68
69 CHECK( m_tool->apply(*evtInfo) );
70
71
72 //here's an example of systematic variations
73 if (m_systematics){
74 for(auto& syst : m_allSysts) {
75 ATH_MSG_VERBOSE("Doing systematic : " << syst.name());
76 if(! m_tool->isAffectedBySystematic( syst )) continue;
77 CP::SystematicSet tmp; tmp.insert( syst );
78 if( m_tool->applySystematicVariation( tmp ) != StatusCode::SUCCESS ) continue;
79 CHECK( m_tool->apply(*evtInfo) );
80 }
81 //make sure we leave the tool in the nominal mode
82 if( m_tool->applySystematicVariation( CP::SystematicSet() ) != StatusCode::SUCCESS ) return StatusCode::FAILURE;
83 }
84
85 return StatusCode::SUCCESS;
86 }
87
88 private:
89 ToolHandle<IPileupReweightingTool> m_tool;
90
92
94
96
97};
98
99} //end of CP namespace
100
101#endif
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_INFO(x)
#define ATH_MSG_VERBOSE(x)
#define CHECK(...)
Evaluate an expression and check for errors.
AthAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Constructor with parameters:
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
ToolHandle< IPileupReweightingTool > m_tool
PileupReweightingProvider(const std::string &name, ISvcLocator *svcloc)
This module implements the central registry for handling systematic uncertainties with CP tools.
const SystematicSet & recommendedSystematics() const
returns: the recommended set of systematics
static SystematicRegistry & getInstance()
Get the singleton instance of the registry for the curren thread.
Class to wrap a set of SystematicVariations.
void setStore(const SG::IConstAuxStore *store)
Set the store associated with this object.
Select isolated Photons, Electrons and Muons.
EventInfo_v1 EventInfo
Definition of the latest event info version.
EventInfoAuxContainer_v1 EventInfoAuxContainer
Define the latest version of the auxiliary container.