ATLAS Offline Software
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 
26 namespace 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 
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); }
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;
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 //
CP::PileupReweightingTool::getCorrectedAverageInteractionsPerCrossing
virtual float getCorrectedAverageInteractionsPerCrossing(const xAOD::EventInfo &eventInfo, bool includeDataScaleFactor)
Get the mu of a lumiblock ... needed to 'correct' the number in datasets.
Definition: PileupReweightingTool.cxx:148
CP::PileupReweightingTool::m_defaultChannel
int m_defaultChannel
Definition: PileupReweightingTool.h:156
CP::PileupReweightingTool::m_toolLumicalcFiles
std::vector< std::string > m_toolLumicalcFiles
Definition: PileupReweightingTool.h:152
asg::AsgTool
Base class for the dual-use tool implementation classes.
Definition: AsgTool.h:47
CP::TPileupReweighting::SetUniformBinning
Int_t SetUniformBinning(Int_t nbinsx, Double_t xlow, Double_t xup, Int_t nbinsy=0, Double_t ylow=0, Double_t yup=0)
Definition: TPileupReweighting.cxx:93
CP::PileupReweightingTool::m_useRunDependentPrescaleWeight
bool m_useRunDependentPrescaleWeight
Definition: PileupReweightingTool.h:163
plotting.yearwise_efficiency.channel
channel
Definition: yearwise_efficiency.py:24
CP::PileupReweightingTool::GetIntegratedLumiFraction
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...
Definition: PileupReweightingTool.h:57
CP::PileupReweightingTool::m_grlTool
ToolHandle< IGoodRunsListSelectionTool > m_grlTool
Definition: PileupReweightingTool.h:171
CP::TPileupReweighting
Definition: TPileupReweighting.h:50
CP::PileupReweightingTool::m_prefix
std::string m_prefix
Definition: PileupReweightingTool.h:154
CP::TPileupReweighting::SetBinning
Int_t SetBinning(Int_t nbinsx, Double_t *xbins, Int_t nbinsy=0, Double_t *ybins=0)
Add a histogram binning config.
Definition: TPileupReweighting.cxx:83
CP::PileupReweightingTool::getPRWHash
virtual ULong64_t getPRWHash(const xAOD::EventInfo &eventInfo)
return the prw hash used for fast updates of weights at the post-processing level ....
Definition: PileupReweightingTool.cxx:392
plotmaker.hist
hist
Definition: plotmaker.py:148
CP::PileupReweightingTool::m_systDown
CP::SystematicVariation m_systDown
Definition: PileupReweightingTool.h:148
mergePhysValFiles.start
start
Definition: DataQuality/DataQualityUtils/scripts/mergePhysValFiles.py:14
CP::TPileupReweighting::GetIntegratedLumi
Double_t GetIntegratedLumi(const TString &trigger="")
total luminosity loaded and accepted by the tool (in inverse pb)
Definition: TPileupReweighting.cxx:115
CP::TPileupReweighting::Merge
Int_t Merge(TCollection *coll)
Definition: TPileupReweighting.cxx:2039
CP::PileupReweightingTool::GetIntegratedLumi
virtual Double_t GetIntegratedLumi(UInt_t start, UInt_t end)
Get the integrated luminosity (in pb-1) between start and end run (inclusive)
Definition: PileupReweightingTool.h:49
PixelAthClusterMonAlgCfg.ybins
ybins
Definition: PixelAthClusterMonAlgCfg.py:169
CP::SystematicSet
Class to wrap a set of SystematicVariations.
Definition: SystematicSet.h:31
CP::PileupReweightingTool::m_varyRunNumber
bool m_varyRunNumber
Definition: PileupReweightingTool.h:162
CP::PileupReweightingTool::m_weightTool
ToolHandle< IWeightTool > m_weightTool
Definition: PileupReweightingTool.h:170
CP::PileupReweightingTool::m_doneConfigs
std::map< int, bool > m_doneConfigs
Definition: PileupReweightingTool.h:158
CP::PileupReweightingTool::getDataWeight
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....
Definition: PileupReweightingTool.cxx:495
CP::SystematicVariation
Definition: SystematicVariation.h:47
x
#define x
CP::PileupReweightingTool::getCorrectedActualInteractionsPerCrossing
virtual float getCorrectedActualInteractionsPerCrossing(const xAOD::EventInfo &eventInfo, bool includeDataScaleFactor)
Get the corrected 'actual' interactions per crossing.
Definition: PileupReweightingTool.cxx:157
CP
Select isolated Photons, Electrons and Muons.
Definition: Control/xAODRootAccess/xAODRootAccess/TEvent.h:48
CP::PileupReweightingTool::m_defaultWeightTool
std::unique_ptr< IWeightTool > m_defaultWeightTool
Definition: PileupReweightingTool.h:168
CP::PileupReweightingTool::isAffectedBySystematic
bool isAffectedBySystematic(const CP::SystematicVariation &systematic) const
The ISystematicsTool methods.
Definition: PileupReweightingTool.cxx:115
mergePhysValFiles.end
end
Definition: DataQuality/DataQualityUtils/scripts/mergePhysValFiles.py:93
CP::PileupReweightingTool::m_usePeriodConfig
std::string m_usePeriodConfig
Definition: PileupReweightingTool.h:157
CP::PileupReweightingTool::affectingSystematics
CP::SystematicSet affectingSystematics() const
the list of all systematics this tool can be affected by
Definition: PileupReweightingTool.cxx:119
CP::PileupReweightingTool::m_customPeriods
std::vector< int > m_customPeriods
Default weight tool in standalone mode.
Definition: PileupReweightingTool.h:165
CP::PileupReweightingTool::m_prwFiles
std::vector< std::string > m_prwFiles
Definition: PileupReweightingTool.h:151
CP::TPileupReweighting::GetRandomLumiBlockNumber
UInt_t GetRandomLumiBlockNumber(UInt_t runNumber)
Get a random lumi block from the run number given.
Definition: TPileupReweighting.cxx:1469
CP::PileupReweightingTool::GetSumOfEventWeights
virtual Double_t GetSumOfEventWeights(Int_t channel)
helpful alternative to using the EventBookkeepers info ... assuming you made your PRW Config file!...
Definition: PileupReweightingTool.h:64
TPileupReweighting.h
CP::TPileupReweighting::AddPeriod
Int_t AddPeriod(Int_t periodNumber, UInt_t start, UInt_t end)
Assign an mc RunNumber to a data period.
Definition: TPileupReweighting.cxx:368
IPileupReweightingTool.h
CP::PileupReweightingTool::finalize
virtual StatusCode finalize()
Finalize - can call the WriteToFile for us.
Definition: PileupReweightingTool.cxx:299
CP::PileupReweightingTool::m_inConfigMode
bool m_inConfigMode
Definition: PileupReweightingTool.h:141
ITrigDecisionTool.h
CP::PileupReweightingTool::GetIntegratedLumi
virtual Double_t GetIntegratedLumi(const TString &trigger)
Total lumi (in pb-1) for a given trigger combination .. leave blank for the unprescaled.
Definition: PileupReweightingTool.h:51
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
CP::PileupReweightingTool::AddPeriod
virtual Int_t AddPeriod(Int_t periodNumber, UInt_t start, UInt_t end)
use these methods when generating config files
Definition: PileupReweightingTool.h:59
CP::PileupReweightingTool::SetUniformBinning
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)
Definition: PileupReweightingTool.h:61
CP::PileupReweightingTool::GetIntegratedLumiFraction
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 ...
Definition: PileupReweightingTool.h:55
CP::PileupReweightingTool::m_tdt
ToolHandle< Trig::ITrigDecisionTool > m_tdt
Definition: PileupReweightingTool.h:172
CP::PileupReweightingTool::fill
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...
Definition: PileupReweightingTool.cxx:425
CP::PileupReweightingTool
Implementation of the PileupReweighting tool.
Definition: PileupReweightingTool.h:34
CP::PileupReweightingTool::initialize
virtual StatusCode initialize()
Function initialising the tool.
Definition: PileupReweightingTool.cxx:169
CP::PileupReweightingTool::apply
virtual StatusCode apply(const xAOD::EventInfo &eventInfo, bool mu_dependent)
Decorates with: MC: PileupWeight (CombinedWeight[*UnrepresentedDataWeight if action=2]),...
Definition: PileupReweightingTool.cxx:451
CP::PileupReweightingTool::getLumiBlockIntegratedLumi
virtual double getLumiBlockIntegratedLumi(const xAOD::EventInfo &eventInfo)
Get the integrated lumi of a lumiblock (in pb-1)
Definition: PileupReweightingTool.cxx:167
CP::PileupReweightingTool::runLbnOK
virtual bool runLbnOK(Int_t runNbr, Int_t lbn)
Definition: PileupReweightingTool.cxx:101
CP::PileupReweightingTool::getCombinedWeight
virtual float getCombinedWeight(const xAOD::EventInfo &eventInfo, bool correctUnrepresented)
Return combined pileup weight.
Definition: PileupReweightingTool.cxx:397
CP::PileupReweightingTool::recommendedSystematics
CP::SystematicSet recommendedSystematics() const
the list of all systematics this tool recommends to use
Definition: PileupReweightingTool.cxx:126
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
CP::PileupReweightingTool::SetBinning
virtual Int_t SetBinning(Int_t nbinsx, Double_t *xbins, Int_t nbinsy=0, Double_t *ybins=0)
Definition: PileupReweightingTool.h:60
CP::PileupReweightingTool::getRandomRunNumber
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 ....
Definition: PileupReweightingTool.cxx:418
CP::TPileupReweighting::GetNumberOfEvents
Double_t GetNumberOfEvents(Int_t channel)
totalMC maps should also hold the total number of entries for each channel
Definition: TPileupReweighting.h:73
CP::PileupReweightingTool::expert
virtual CP::TPileupReweighting * expert()
Get pointer to the underlying tool - expert use only. Will require #include "PileupReweighting/TPileu...
Definition: PileupReweightingTool.h:121
CP::PileupReweightingTool::m_upTool
std::unique_ptr< CP::TPileupReweighting > m_upTool
Definition: PileupReweightingTool.h:144
xAOD::EventInfo_v1
Class describing the basic event information.
Definition: EventInfo_v1.h:43
CP::PileupReweightingTool::m_upVariation
double m_upVariation
Definition: PileupReweightingTool.h:147
LArCellBinning.xbins
int xbins
Definition: LArCellBinning.py:163
DeMoAtlasDataLoss.runNumber
string runNumber
Definition: DeMoAtlasDataLoss.py:64
CP::TPileupReweighting::GetIntegratedLumiFraction
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 ...
Definition: TPileupReweighting.cxx:182
CP::PileupReweightingTool::getUnrepresentedDataWeight
virtual float getUnrepresentedDataWeight(const xAOD::EventInfo &eventInfo)
When using UnrepresentedDataAction=2, you may want to apply this additional weight to ensure sum of w...
Definition: PileupReweightingTool.cxx:412
y
#define y
CP::PileupReweightingTool::GetNumberOfEvents
virtual Double_t GetNumberOfEvents(Int_t channel)
Definition: PileupReweightingTool.h:65
ASG_TOOL_CLASS
#define ASG_TOOL_CLASS(CLASSNAME, INT1)
Definition: AsgToolMacros.h:68
CP::PileupReweightingTool::m_activeTool
CP::TPileupReweighting * m_activeTool
Definition: PileupReweightingTool.h:149
IWeightTool.h
CP::PileupReweightingTool::m_downTool
std::unique_ptr< CP::TPileupReweighting > m_downTool
Definition: PileupReweightingTool.h:145
CP::PileupReweightingTool::Class_Version
static Version_t Class_Version()
Definition: PileupReweightingTool.h:177
ToolHandle.h
CP::PileupReweightingTool::SetBinning
virtual Int_t SetBinning(TH1 *hist)
Definition: PileupReweightingTool.h:62
CP::PileupReweightingTool::PileupReweightingTool
PileupReweightingTool(const std::string &name)
Constructor for standalone usage.
Definition: PileupReweightingTool.cxx:34
AsgTool.h
CP::PileupReweightingTool::m_configStream
std::string m_configStream
Definition: PileupReweightingTool.h:140
CaloNoise_fillDB.mu
mu
Definition: CaloNoise_fillDB.py:53
CP::PileupReweightingTool::updateHandler
void updateHandler(Gaudi::Details::PropertyBase &)
Definition: PileupReweightingTool.cxx:92
CP::PileupReweightingTool::getPrescaleWeight
virtual float getPrescaleWeight(const xAOD::EventInfo &eventInfo, const TString &trigger, bool mu_dependent)
Get weight used to 'prescale' Monte Carlo for given trigger comibnation.
Definition: PileupReweightingTool.cxx:514
CP::PileupReweightingTool::applySystematicVariation
StatusCode applySystematicVariation(const CP::SystematicSet &systConfig)
effects: configure this tool for the given list of systematic variations.
Definition: PileupReweightingTool.cxx:130
CP::PileupReweightingTool::GetIntegratedLumi
virtual Double_t GetIntegratedLumi(Int_t periodNumber, UInt_t start, UInt_t end)
similar to above, but for only the given mcRunNumber/periodNumber
Definition: PileupReweightingTool.h:53
CP::TPileupReweighting::GetSumOfEventWeights
Double_t GetSumOfEventWeights(Int_t channel)
Definition: TPileupReweighting.h:82
CP::PileupReweightingTool::GetRandomLumiBlockNumber
virtual UInt_t GetRandomLumiBlockNumber(UInt_t runNumber)
Get a random lumiblock number for the given run number.
Definition: PileupReweightingTool.h:47
CP::PileupReweightingTool::m_systUp
CP::SystematicVariation m_systUp
Definition: PileupReweightingTool.h:148
CP::PileupReweightingTool::m_downVariation
double m_downVariation
Definition: PileupReweightingTool.h:147
CP::PileupReweightingTool::m_noWeightsMode
bool m_noWeightsMode
Definition: PileupReweightingTool.h:160
CP::IPileupReweightingTool
Definition: IPileupReweightingTool.h:29
CP::PileupReweightingTool::passTriggerBeforePrescale
virtual bool passTriggerBeforePrescale(const TString &trigger) const
Definition: PileupReweightingTool.cxx:106