ATLAS Offline Software
Loading...
Searching...
No Matches
PileupReweightingTool.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3*/
4
5
6#ifndef PILEUPREWEIGHTING_PILEUPREWEIGHTINGTOOL_H
7#define PILEUPREWEIGHTING_PILEUPREWEIGHTINGTOOL_H
8
9// System include(s):
10#include <memory>
11
12// Framework include(s):
13#include "AsgTools/AsgTool.h"
14
16
17// Local include(s):
18
20
21#include "AsgTools/ToolHandle.h"
23
25
26namespace CP {
27
32
34 public asg::AsgTool, protected virtual CP::TPileupReweighting,public virtual IPileupReweightingTool {
35
38
39 public:
40 using CP::TPileupReweighting::operator new; //must declare the new operator as public because everything else went protected
42 using CP::TPileupReweighting::operator delete;
43 using CP::TPileupReweighting::operator delete[];
44
45
47 virtual UInt_t GetRandomLumiBlockNumber(UInt_t runNumber) { return m_activeTool->GetRandomLumiBlockNumber(runNumber); }
49 virtual Double_t GetIntegratedLumi(UInt_t start, UInt_t end) { return m_activeTool->GetIntegratedLumi(start, end); }
51 virtual Double_t GetIntegratedLumi(const TString& trigger) { return m_activeTool->GetIntegratedLumi(trigger); }
53 virtual Double_t GetIntegratedLumi(Int_t periodNumber, UInt_t start, UInt_t end) { return m_activeTool->GetIntegratedLumi(periodNumber, start, end); }
55 virtual Double_t GetIntegratedLumiFraction(Int_t periodNumber, UInt_t start, UInt_t end) { return m_activeTool->GetIntegratedLumiFraction(periodNumber, start, end); }
57 virtual Double_t GetIntegratedLumiFraction(Int_t periodNumber, Double_t mu, UInt_t start, UInt_t end) { return m_activeTool->GetIntegratedLumiFraction(periodNumber, mu, start, end); }
59 virtual Int_t AddPeriod(Int_t periodNumber, UInt_t start, UInt_t end) { return m_activeTool->AddPeriod(periodNumber, start, end); }
60 virtual Int_t SetBinning(Int_t nbinsx, Double_t* xbins, Int_t nbinsy=0, Double_t* ybins=0) { return m_activeTool->SetBinning(nbinsx, xbins, nbinsy, ybins); }
61 virtual Int_t SetUniformBinning(Int_t nbinsx, Double_t xlow, Double_t xup, Int_t nbinsy=0, Double_t ylow=0, Double_t yup=0) { return m_activeTool->SetUniformBinning(nbinsx, xlow, xup, nbinsy, ylow, yup); }
62 virtual Int_t SetBinning(TH1* hist) { return m_activeTool->SetBinning(hist); }
64 virtual Double_t GetSumOfEventWeights(Int_t channel) { return m_activeTool->GetSumOfEventWeights(channel); }
65 virtual Double_t GetNumberOfEvents(Int_t channel) { return m_activeTool->GetNumberOfEvents(channel) ; }
66
67
69 PileupReweightingTool( const std::string& name );
70
72 virtual StatusCode initialize();
73
75 virtual StatusCode finalize();
76
81 virtual StatusCode apply ( const xAOD::EventInfo& eventInfo, bool mu_dependent );
82
84 virtual float getCombinedWeight( const xAOD::EventInfo& eventInfo, bool correctUnrepresented );
85
87 virtual float getCombinedWeight( const xAOD::EventInfo& eventInfo,Double_t x, Double_t y, bool correctUnrepresented );
88
89 virtual float getCombinedWeight( const xAOD::EventInfo& eventInfo , const TString& trigger, bool mu_dependent, bool correctUnrepresented );
90
92 virtual ULong64_t getPRWHash( const xAOD::EventInfo& eventInfo );
93
95 virtual float getCorrectedAverageInteractionsPerCrossing( const xAOD::EventInfo& eventInfo, bool includeDataScaleFactor );
97 virtual float getCorrectedActualInteractionsPerCrossing( const xAOD::EventInfo& eventInfo, bool includeDataScaleFactor );
98
100 virtual double getLumiBlockIntegratedLumi(const xAOD::EventInfo& eventInfo);
101
103 virtual float getUnrepresentedDataWeight( const xAOD::EventInfo& eventInfo );
104
106 virtual float getDataWeight( const xAOD::EventInfo& eventInfo, const TString& trigger, bool mu_dependent );
107
109 virtual float getPrescaleWeight( const xAOD::EventInfo& eventInfo , const TString& trigger, bool mu_dependent );
110
112 virtual int getRandomRunNumber( const xAOD::EventInfo& eventInfo , bool mu_dependent );
113
115 virtual int fill( const xAOD::EventInfo& eventInfo );
116
118 virtual int fill( const xAOD::EventInfo& eventInfo, Double_t x, Double_t y);
119
122
123
124
126 bool isAffectedBySystematic( const CP::SystematicVariation& systematic ) const;
129 StatusCode applySystematicVariation( const CP::SystematicSet& systConfig );
130
131#ifndef XAOD_STANDALONE
132 void updateHandler(Gaudi::Details::PropertyBase& /*p*/);
133#endif
134
135 protected:
136 virtual bool runLbnOK(Int_t runNbr, Int_t lbn);
137 virtual bool passTriggerBeforePrescale(const TString& trigger) const;
138
139 private:
140 std::string m_configStream;
142
143 // Systematic variation instances for the reweighting
144 std::unique_ptr< CP::TPileupReweighting > m_upTool;
145 std::unique_ptr< CP::TPileupReweighting > m_downTool;
146
150
151 std::vector<std::string> m_prwFiles;
152 std::vector<std::string> m_toolLumicalcFiles;
153
154 std::string m_prefix;
155
157 std::string m_usePeriodConfig;
158 std::map<int, bool> m_doneConfigs;
159
161
164
165 std::vector<int> m_customPeriods;
166
168 std::unique_ptr< IWeightTool > m_defaultWeightTool;
169
170 ToolHandle<IWeightTool> m_weightTool;
171 ToolHandle<IGoodRunsListSelectionTool> m_grlTool;
172 ToolHandle<Trig::ITrigDecisionTool> m_tdt;
173
174 // MN: this prevents ROOT dict generator from complaining about lack of ClassDef()
175 // Note: inheriting from TObject and not having ClassDef makes this class unsuitable for I/O
176 public:
177 static Version_t Class_Version() { return 0; }
178
179 }; // class PileupReweightingTool
180
181} // namespace CP
182
183#endif //
#define ASG_TOOL_CLASS(CLASSNAME, INT1)
#define y
#define x
virtual CP::TPileupReweighting * expert()
Get pointer to the underlying tool - expert use only. Will require include "PileupReweighting/TPileup...
ToolHandle< Trig::ITrigDecisionTool > m_tdt
virtual int fill(const xAOD::EventInfo &eventInfo)
Call this method once per event when in config file generating mode and you want standard mu reweight...
virtual Double_t GetIntegratedLumiFraction(Int_t periodNumber, UInt_t start, UInt_t end)
return fraction of lumi assigned to periodNumber (or mcRunNumber) that is between start and end data ...
std::unique_ptr< IWeightTool > m_defaultWeightTool
std::vector< std::string > m_prwFiles
std::vector< int > m_customPeriods
Default weight tool in standalone mode.
virtual float getDataWeight(const xAOD::EventInfo &eventInfo, const TString &trigger, bool mu_dependent)
Get the dataWeight used to 'unprescale' data collected from a given trigger combination....
virtual float getCorrectedAverageInteractionsPerCrossing(const xAOD::EventInfo &eventInfo, bool includeDataScaleFactor)
Get the mu of a lumiblock ... needed to 'correct' the number in datasets.
virtual Int_t AddPeriod(Int_t periodNumber, UInt_t start, UInt_t end)
use these methods when generating config files
virtual ULong64_t getPRWHash(const xAOD::EventInfo &eventInfo)
return the prw hash used for fast updates of weights at the post-processing level ....
virtual double getLumiBlockIntegratedLumi(const xAOD::EventInfo &eventInfo)
Get the integrated lumi of a lumiblock (in pb-1)
std::unique_ptr< CP::TPileupReweighting > m_upTool
virtual Double_t GetSumOfEventWeights(Int_t channel)
helpful alternative to using the EventBookkeepers info ... assuming you made your PRW Config file!...
virtual Int_t SetUniformBinning(Int_t nbinsx, Double_t xlow, Double_t xup, Int_t nbinsy=0, Double_t ylow=0, Double_t yup=0)
virtual float getCorrectedActualInteractionsPerCrossing(const xAOD::EventInfo &eventInfo, bool includeDataScaleFactor)
Get the corrected 'actual' interactions per crossing.
CP::SystematicSet affectingSystematics() const
the list of all systematics this tool can be affected by
virtual StatusCode apply(const xAOD::EventInfo &eventInfo, bool mu_dependent)
Decorates with: MC: PileupWeight (CombinedWeight[*UnrepresentedDataWeight if action=2]),...
StatusCode applySystematicVariation(const CP::SystematicSet &systConfig)
effects: configure this tool for the given list of systematic variations.
virtual Double_t GetNumberOfEvents(Int_t channel)
virtual Int_t SetBinning(Int_t nbinsx, Double_t *xbins, Int_t nbinsy=0, Double_t *ybins=0)
void updateHandler(Gaudi::Details::PropertyBase &)
ToolHandle< IWeightTool > m_weightTool
virtual float getPrescaleWeight(const xAOD::EventInfo &eventInfo, const TString &trigger, bool mu_dependent)
Get weight used to 'prescale' Monte Carlo for given trigger comibnation.
virtual float getCombinedWeight(const xAOD::EventInfo &eventInfo, bool correctUnrepresented)
Return combined pileup weight.
CP::SystematicVariation m_systDown
virtual Double_t GetIntegratedLumiFraction(Int_t periodNumber, Double_t mu, UInt_t start, UInt_t end)
return fraction of lumi assigned to periodNumber (or mcRunNumber) with given mu, that is between star...
virtual Int_t SetBinning(TH1 *hist)
virtual Double_t GetIntegratedLumi(Int_t periodNumber, UInt_t start, UInt_t end)
similar to above, but for only the given mcRunNumber/periodNumber
std::vector< std::string > m_toolLumicalcFiles
virtual StatusCode initialize()
Function initialising the tool.
virtual UInt_t GetRandomLumiBlockNumber(UInt_t runNumber)
Get a random lumiblock number for the given run number.
virtual bool passTriggerBeforePrescale(const TString &trigger) const
std::unique_ptr< CP::TPileupReweighting > m_downTool
virtual float getUnrepresentedDataWeight(const xAOD::EventInfo &eventInfo)
When using UnrepresentedDataAction=2, you may want to apply this additional weight to ensure sum of w...
PileupReweightingTool(const std::string &name)
Constructor for standalone usage.
CP::TPileupReweighting * m_activeTool
CP::SystematicSet recommendedSystematics() const
the list of all systematics this tool recommends to use
ToolHandle< IGoodRunsListSelectionTool > m_grlTool
std::map< int, bool > m_doneConfigs
virtual Double_t GetIntegratedLumi(const TString &trigger)
Total lumi (in pb-1) for a given trigger combination .. leave blank for the unprescaled.
virtual int getRandomRunNumber(const xAOD::EventInfo &eventInfo, bool mu_dependent)
Get a random run number for this MC event, using mu-dependent randomization by default ....
bool isAffectedBySystematic(const CP::SystematicVariation &systematic) const
The ISystematicsTool methods.
CP::SystematicVariation m_systUp
virtual bool runLbnOK(Int_t runNbr, Int_t lbn)
virtual StatusCode finalize()
Finalize - can call the WriteToFile for us.
virtual Double_t GetIntegratedLumi(UInt_t start, UInt_t end)
Get the integrated luminosity (in pb-1) between start and end run (inclusive)
Class to wrap a set of SystematicVariations.
Int_t Merge(TCollection *coll)
Base class for the dual-use tool implementation classes.
Definition AsgTool.h:47
Select isolated Photons, Electrons and Muons.
EventInfo_v1 EventInfo
Definition of the latest event info version.