ATLAS Offline Software
Loading...
Searching...
No Matches
TPileupReweighting.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// Dear emacs, this is -*-c++-*-
6
7#ifndef __TPILEUPREWEIGHTING__
8#define __TPILEUPREWEIGHTING__
9
19
20/* Developer notes:
21* Could have incorporated the pileup histos in to the generic custom maps
22* but decided to keep them seperate for probable slight performance improvement
23* Allow the user to change the histo binning through AddBinning with name="pileup"
24* */
25
26#include "TNamed.h"
27#include <TFile.h>
28#include <TString.h>
29#include "TVectorD.h"
30#include <map>
31#include <vector>
32#include <TRandom3.h>
33
34// STL includes
35#include <iostream>
36#include <stdexcept>
37#include <memory>
38#include <list>
39
40#include <TH1.h>
41#include <TH2.h>
42
43
44class TTree;
45class TFile;
46
47
48
49namespace CP {
50 class TPileupReweighting : public TNamed {
51
52 public:
54 TPileupReweighting(const char* name="TPileupReweighting");
55
56 public:
57
59 Int_t UsePeriodConfig(const TString& configName);
61 Int_t SetBinning(Int_t nbinsx, Double_t* xbins, Int_t nbinsy=0, Double_t* ybins=0);
62 Int_t SetUniformBinning(Int_t nbinsx, Double_t xlow, Double_t xup, Int_t nbinsy=0, Double_t ylow=0, Double_t yup=0);
63 Int_t SetBinning(TH1* hist);
64
67 void SetDefaultChannel(Int_t channel, Int_t mcRunNumber=-1);
68 Int_t GetDefaultChannel(Int_t mcRunNumber=-1);
69
71 Double_t GetIntegratedLumi(const TString& trigger="");
73 inline Double_t GetNumberOfEvents(Int_t channel) {
74 Period* global = m_periods[-1];
75 if(!global) return 0;
76 if(global->numberOfEntries.find(channel)==global->numberOfEntries.end()) {
77 Error("GetNumberOfEvents", "Unknown channel: %d",channel);
78 return 0;
79 }
80 return global->numberOfEntries[channel];
81 }
82 inline Double_t GetSumOfEventWeights(Int_t channel) {
83 Period* global = m_periods[-1];
84 if(!global) return 0;
85 if(global->sumOfWeights.find(channel)==global->sumOfWeights.end()) {
86 Error("GetSumOfEventWeights", "Unknown channel: %d",channel);
87 return 0;
88 }
89 return global->sumOfWeights[channel];
90 }
91
93 void RemapPeriod(Int_t periodNumber1, Int_t periodNumber2);
94
95
97 Double_t GetIntegratedLumiFraction(Int_t periodNumber, UInt_t start, UInt_t end);
99 Double_t GetIntegratedLumiFraction(Int_t periodNumber, Double_t mu, UInt_t start, UInt_t end);
100
102 inline Double_t GetIntegratedLumi(UInt_t start, UInt_t end) { return GetIntegratedLumi(-1,start,end); }
104 Double_t GetIntegratedLumi(Int_t periodNumber, UInt_t start, UInt_t end);
105
107 Double_t GetLumiBlockIntegratedLumi(Int_t runNumber, UInt_t lb);
108
110 Float_t GetLumiBlockMu(Int_t runNumber, UInt_t lb);
111
112 //-----------------------------------------------------
113 //General Tool Configuring methods
114 //-----------------------------------------------------
116 inline void DisableWarnings(Bool_t in) { m_SetWarnings = !in;}
118 inline void EnableDebugging(Bool_t in) { m_debugging = in;}
120 inline void PrintInfo(Bool_t in) { m_printInfo = in; }
121
124 inline void SetUnrepresentedDataAction(Int_t action, Double_t tolerance=0.05) {
125 if(action<0 || action>3) {
126 Fatal("SetUnrepresentedDataAction","Set action=%d - I'm afraid I can't let you do that, Dave",action);
127 throw std::runtime_error("Throwing 2001");
128 }
130 m_unrepDataTolerance=tolerance; //applicable for action=2 mode. Default is 5%
131 }
132
133 Double_t GetUnrepresentedDataFraction(Int_t periodNumber,Int_t channel);
134 inline Float_t GetUnrepresentedDataWeight(Int_t periodNumber,Int_t channel) {
136 Warning("GetUnrepresentedDataWeight","You should not be applying this weight unless the UnrepresentedDataAction=2");
137 }
138 return 1./(1. - GetUnrepresentedDataFraction(periodNumber,channel));
139 }
140 //-----------------------------------------------------
141 //Methods to veto data in Action=1 mode
142 //-----------------------------------------------------
143 Bool_t IsUnrepresentedData(Int_t runNumber, Float_t x, Float_t y=0.);
144
146 inline void IgnoreConfigFilePeriods(Bool_t in) { m_ignoreFilePeriods=in; }
147
149 Int_t AddPeriod(Int_t periodNumber, UInt_t start, UInt_t end);
151 Int_t GetFirstFoundPeriodNumber(UInt_t runNumber);
152
153
154
156 inline void SetDataScaleFactors(Float_t x,Float_t y=1.) { m_dataScaleFactorX=x;m_dataScaleFactorY=y; }
157 inline void SetMCScaleFactors(Float_t x,Float_t y=1.) { m_mcScaleFactorX=x;m_mcScaleFactorY=y;}
158
159
160
161 //-----------------------------------------------------
162 //Methods to load config files
163 //-----------------------------------------------------
164 Int_t AddConfigFile(const TString& fileName);
165 Int_t AddLumiCalcFile(const TString& fileName, const TString& trigger="None");
166 Int_t AddMetaDataFile(const TString& fileName,const TString& channelBranchName="mc_channel_number");
167
169 Bool_t RemoveChannel(int chanNum);
170
174 Int_t Initialize();
175
176
177 //-----------------------------------------------------
178 //Methods to get the various weights
179 //-----------------------------------------------------
180 Float_t GetCombinedWeight(Int_t periodNumber, Int_t channelNumber,Float_t x,Float_t y=0.);
181 Float_t GetPeriodWeight(Int_t periodNumber, Int_t channelNumber);
182 Float_t GetPrimaryWeight(Int_t periodNumber, Int_t channelNumber,Float_t x);
183 Float_t GetSecondaryWeight(Int_t periodNumber, Int_t channelNumber,Float_t x,Float_t y);
184
185 //-----------------------------------------------------
186 //Methods to work with the metadata
187 //-----------------------------------------------------
188 Double_t GetMetaData(const TString& metadataName,Int_t channelNumber) {
189 if(m_metadata.find(metadataName)==m_metadata.end()) {
190 Error("GetMetaData","Metadata %s not known",metadataName.Data());
191 return 0;
192 }
193 if(m_metadata[metadataName].find(channelNumber)==m_metadata[metadataName].end()) {
194 Error("GetMetaData","Metadata %s not known in channel %d",metadataName.Data(), channelNumber);
195 return 0;
196 }
197 return m_metadata[metadataName][channelNumber];
198 }
199
200 TTree* GetMetaDataTree();
201 Int_t GenerateMetaDataFile(const TString& fileName,const TString& channelBranchName="mc_channel_number");
202
203
204 //-----------------------------------------------------
205 //Methods to generate config files
206 //-----------------------------------------------------
207 Int_t Fill(Int_t runNumber,Int_t channelNumber,Float_t w,Float_t x, Float_t y=0.);
208 Int_t WriteToFile(const TString& filename=""); //if no name given, will use tool name
209 Int_t WriteToFile(TFile* outFile);
210
211
212 //
213 //Methods used to do the prwTree - for fast recalculation of prw weights when processing ntuples
214 //
215 ULong64_t GetPRWHash(Int_t periodNumber, Int_t channelNumber, Float_t x, Float_t y=0.);
216 Bool_t MakeWeightTree(TString channelNumbers, TString outFile, TString hashBranch="PRWHash", TString weightBranch="PileupWeight");
217
218 //-----------------------------------------------------
219 //RandomDataPeriod functionality stuff
220 //numbers generated seperately for each mc period
221 //-----------------------------------------------------
222 void SetRandomSeed(int seed) {m_random3->SetSeed(seed);}
223 int GetRandomSeed() {return m_random3->GetSeed();}
226 UInt_t GetRandomRunNumber(Int_t mcRunNumber);
228 UInt_t GetRandomRunNumber(Int_t mcRunNumber, Double_t mu);
230 Int_t GetRandomPeriodNumber(Int_t mcRunNumber);
232 UInt_t GetRandomLumiBlockNumber(UInt_t runNumber);
233
234
235 //-----------------------------------------------------
236 //Methods for PROOF cluster merging of generated histos
237 //-----------------------------------------------------
238 Int_t Merge(TCollection *coll);
239 //*std::map<Int_t,std::map<Int_t, TH1*> > & GetInputHistograms() { return m_inputHistograms;}
240
241
242 std::vector<int> GetPeriodNumbers() const {
243 std::vector<int> out;
244 for(auto& p : m_periods) { out.push_back(p.first); }
245 return out;
246 }
247
248 //-----------------------------------------------------
249 //Methods to inspect the input and weighting histograms
250 //-----------------------------------------------------
251 TH1* GetInputHistogram(Int_t channelNumber, Int_t periodNumber) {
252 if(m_periods.find(periodNumber)==m_periods.end()||
253 m_periods[periodNumber]->inputHists.find(channelNumber)==m_periods[periodNumber]->inputHists.end()) {
254 return 0;
255 }
256 return m_periods[periodNumber]->inputHists[channelNumber].get();
257 }
258
259 TH1* GetPrimaryDistribution(Int_t channelNumber, Int_t periodNumber) {
260 if(m_periods.find(periodNumber)==m_periods.end()||
261 m_periods[periodNumber]->primaryHists.find(channelNumber)==m_periods[periodNumber]->primaryHists.end()) {
262 return 0;
263 }
264 return m_periods[periodNumber]->primaryHists[channelNumber].get();
265 }
266
267 TH1* GetPrimaryTriggerDistribution(const TString& trigger, Int_t periodNumber, long triggerBits) {
268 if(m_triggerObjs.find(trigger)==m_triggerObjs.end() || m_triggerObjs[trigger]->triggerHists.find(periodNumber) ==m_triggerObjs[trigger]->triggerHists.end() ||
269 m_triggerObjs[trigger]->triggerHists[periodNumber].find(triggerBits) == m_triggerObjs[trigger]->triggerHists[periodNumber].end()) return 0;
270 /*
271 if(m_triggerObjs.find(trigger)==m_triggerObjs.end() || m_triggerObjs.at(trigger).second->triggerHists.find(periodNumber)==m_triggerObjs.at(trigger).second->->triggerHists.end() ||
272 m_triggerObjs.at(trigger).second->triggerHists.at(periodNumber).find(triggerBits) == m_triggerObjs.at(trigger).second.at(periodNumber).end()) return 0;
273 */
274
275 return m_triggerObjs[trigger]->triggerHists[periodNumber][triggerBits].get();
276 }
277
279 Double_t GetDataWeight(Int_t runNumber, const TString& trigger, Double_t x, bool run_dependent=false);
280 Double_t GetDataWeight(Int_t runNumber, const TString& trigger);//version without mu dependence
281
283 Double_t GetPrescaleWeight(Int_t runNumber, const TString& trigger, Double_t x, bool run_dependent=false);
284 Double_t GetPrescaleWeight(Int_t runNumber, const TString& trigger);//version without mu dependence
285
286
287 // other methods
288 Bool_t IsInitialized() { return m_isInitialized; }
289//
290 Int_t AddDistribution(TH1* hist, Int_t runNumber, Int_t channelNumber);
291
294
295
297
298 Float_t GetDataScaleFactor() const { return m_dataScaleFactorX; }
299
300 void SetTriggerBit(const TString& trigger, bool in=true) { m_triggerPassBits[trigger]=in; }
302
303 double GetRunAverageMu(int run) { return m_runs[run].inputHists["None"]->GetMean(); }
304
305
306
307 protected:
308 virtual bool runLbnOK(Int_t /*runNbr*/, Int_t /*lbn*/) { return true; } //override in the ASG tool
309 virtual bool passTriggerBeforePrescale(const TString& trigger) const {
310 if(m_triggerPassBits.size()==0) return true;
311 try {
312 return m_triggerPassBits.at(trigger);
313 } catch(...) { return true; }
314 } //override in the ASG tool
315 std::map<TString, bool> m_triggerPassBits;
316
317
318 Int_t GetNearestGoodBin(Int_t thisMCRunNumber, Int_t bin);
319 Int_t IsBadBin(Int_t thisMCRunNumber, Int_t bin);
320
321
322 std::unique_ptr< TH1 > CloneEmptyHistogram(Int_t runNumber, Int_t channelNumber);
324 void normalizeHistogram(TH1* histo);
325 void AddDistributionTree(TTree *tree, TFile *file);
326 //*Int_t FactorizeDistribution(TH1* hist, const TString weightName, Int_t channelNumber, Int_t periodNumber,bool includeInMCRun,bool includeInGlobal);
327
328 void CalculatePrescaledLuminosityHistograms(const TString& trigger, int run_dependent=0);
329
330 //********** Private members*************************
331 TPileupReweighting* m_parentTool; //points to self if not a 'systematic varion' tool instance
336 Int_t m_unrepresentedDataAction; //used as property in wrapper tool
338 Float_t m_dataScaleFactorX;Float_t m_dataScaleFactorY; //first is used as property in wrapper tool
344 Bool_t m_doGlobalDataWeight; //used in GetDataWeight to flag mu-independent version
345 Bool_t m_doPrescaleWeight = false;
346 Int_t m_lumicalcRunNumberOffset; //used for 'faking' a lumicalc file for run2
347
349 std::map<TString,std::vector<TString> > m_lumicalcFiles;
350
351 //-----------------------------------------------------
352 //Shared private data members
353 //-----------------------------------------------------
354
355
356
358 std::unique_ptr< TH1 > m_emptyHistogram;
359
360
361
363 std::map<TString, std::map<Int_t, Double_t> > m_metadata;
364
365public:
367 int op;
368 std::unique_ptr< CompositeTrigger > trig1;
369 std::unique_ptr< CompositeTrigger > trig2;
370 TString val;
371 std::vector<TString> subTriggers; //only set for top-level object
372 CompositeTrigger() : op(0),trig1(),trig2(),val("") { }
373 double eval(std::map<TString, std::map<Int_t, std::map<Int_t, Float_t> > >& m, int run, int lbn, const TPileupReweighting* tool) {
374 switch(op) {
375 case 0: if(m[val][run].find(lbn)==m[val][run].end() || !m[val][run][lbn] || !tool->passTriggerBeforePrescale(val)) return 0; /*trigger/failed disabled, so cannot contribute*/
376 return 1./m[val][run][lbn];
377 case 1: return 1. - (1. - trig1->eval(m,run,lbn,tool))*(1.-trig2->eval(m,run,lbn,tool)); //OR
378 case 2: return trig1->eval(m,run,lbn,tool)*trig2->eval(m,run,lbn,tool);
379 default: return 1;
380 }
381 }
382 void getTriggers(std::vector<TString>& s) {
383 if(trig1==0&&trig2==0&&val.Length()>0) s.push_back(val);
384 else { trig1->getTriggers(s); trig2->getTriggers(s); }
385 }
386
387 long getBits(const TPileupReweighting* tool) {
388 long out(0);
389 for(uint i=0;i<subTriggers.size();i++) out += (tool->passTriggerBeforePrescale(subTriggers[i]) << i);
390 return out;
391 }
392
393 // unnormalized ... i.e. integral should be equal to the lumi!
394 // ... indexed by PeriodID,tbits
395 // ... if doing run-dependent weights, PeriodID is replaced by -runNumber (negative number!)
396 std::map<int, std::map<long, std::unique_ptr< TH1 > > > triggerHists;
397
398 };
399protected:
400
401 std::map<TString, std::unique_ptr<CompositeTrigger> > m_triggerObjs; //map from trigger string to composite trigger object
402
403 std::unique_ptr<CompositeTrigger> makeTrigger(const TString& s);
404 void calculateHistograms(CompositeTrigger* trigger, int run_dependent);
405
406public:
407 inline void PrintPeriods() { for(auto p : m_periods) {std::cout << p.first << " -> "; p.second->print("");} }
408 struct Period {
409 Period(Int_t _id, UInt_t _start, UInt_t _end, Int_t _defaultChannel) : id(_id),start(_start),end(_end),defaultChannel(_defaultChannel) {};
410 Int_t id;
411 UInt_t start;
412 UInt_t end;
414 std::map<Int_t, Int_t> inputBinRedirect;
415 std::map<Int_t, Double_t> unrepData; //indexed by channel number
416 std::vector<Period*> subPeriods;
417 std::vector<UInt_t> runNumbers; //populated with runNumbers that actually had some data available
418 std::map<Int_t, std::unique_ptr< TH1 > > inputHists;
419 std::map<Int_t, Double_t> sumOfWeights;
420 std::map<Int_t, Int_t> numberOfEntries;
421 std::map<Int_t, std::unique_ptr< TH1 > > primaryHists; //normalized histograms, indexed by channelNumber. -1 holds the data
422 std::map<Int_t, std::unique_ptr< TH2 > > secondaryHists; //semi-normalized histograms, only used in 2D reweighting
423 //std::map<TString, TH1D*> triggerHists; //unnormalized ... i.e. integral should be equal to the lumi! ... should really only be filled in the channel=-1 case (i.e. data)
424 bool contains(unsigned int runNumber) {
425 if(runNumber >= start && runNumber <= end) return true;
426 for(auto p : subPeriods) if(p->contains(runNumber)) return true;
427 return false;
428 };
429 void SetDefaultChannel(Int_t channel) {
430 defaultChannel=channel;
431 for(auto p : subPeriods) p->SetDefaultChannel(channel);
432 };
433 void print(const char* prefix) {
434 std::cout << prefix << id << "[" << start << "," << end << "] : ";
435 for(auto& hist : inputHists) std::cout << hist.first << " , ";
436 std::cout << std::endl;
437 for(auto p : subPeriods) p->print(TString::Format(" %s",prefix).Data()); };
438 };
439 struct Run {
440 std::map< TString, std::unique_ptr< TH1 > > inputHists; //key is the 'trigger'
441 std::map<Int_t,Double_t> badBins;
442 Double_t lumi; //total data in run
443 std::map<UInt_t, std::pair<Double_t,Double_t> > lumiByLbn; //key=lbn, value = <lumi,mu>
444 std::unique_ptr< TH1 > muDist; //mu distribution for this run
445 bool nominalFromHists = false; //flag if nominal 'None' hist came from histogram files (rather than lumicalc files)
446 };
447 std::map<UInt_t, Run>& GetRunMap() { return m_runs; }
448protected:
450 std::list< Period > m_periodList;
451 std::map<Int_t, Period*> m_periods; //periods mapped by id. -1 = the "global" period (0->9999999). Uses a pointer so can easily implement remap as two entries pointing at same period
452 std::map<UInt_t, Run> m_runs; //runs mapped by runNumber
453
454 std::map<Int_t, Double_t> unrepDataByChannel; // -1 holds the total unrepData!
455
457
458 //-----------------------------------------------------
459 //RandomDataPeriod functionality stuff
460 //numbers generated seperately for each mc period
461 //-----------------------------------------------------
462 std::unique_ptr< TRandom3 > m_random3;
463
464 Bool_t m_ignoreBadChannels; //if true, will print a warning about any channels with too much unrepresented data, but will then just ignore them
465 Bool_t m_useMultiPeriods = true; //if true, will allow for runDependentMC
466
467 //these two numbers are used in the auto-configurations, e.g. "Run2" .. fills additional periods
470
471public:
472 //this method is a convenience for copying over properties to the tools that are used for systematic variations
479
480 ClassDef(TPileupReweighting,0)
481
482
483 }; // End: class definition
484
485} // End: namespace Root
486
487#endif
@ Data
Definition BaseObject.h:11
unsigned int uint
#define y
#define x
void normalizeHistogram(TH1 *histo)
Normalize histograms.
Double_t GetLumiBlockIntegratedLumi(Int_t runNumber, UInt_t lb)
get integrated lumi for specific run and lumiblock number .
Int_t Fill(Int_t runNumber, Int_t channelNumber, Float_t w, Float_t x, Float_t y=0.)
std::map< UInt_t, Run > & GetRunMap()
void RemapPeriod(Int_t periodNumber1, Int_t periodNumber2)
Combine two period numbers.
void ResetCountingMode()
This method is DEFINITELY EXPERT USE ONLY.
Int_t WriteToFile(const TString &filename="")
std::map< Int_t, Double_t > unrepDataByChannel
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 ...
virtual bool passTriggerBeforePrescale(const TString &trigger) const
double GetRunAverageMu(int run)
Int_t Merge(TCollection *coll)
std::map< TString, std::map< Int_t, Double_t > > m_metadata
channel metadata map
TH1 * GetInputHistogram(Int_t channelNumber, Int_t periodNumber)
Float_t GetSecondaryWeight(Int_t periodNumber, Int_t channelNumber, Float_t x, Float_t y)
std::map< UInt_t, Run > m_runs
Double_t GetNumberOfEvents(Int_t channel)
totalMC maps should also hold the total number of entries for each channel
Float_t GetDataScaleFactor() const
Int_t Initialize()
Initialize this class once before the event loop starts If distribution information is provided,...
void SetMCScaleFactors(Float_t x, Float_t y=1.)
Int_t GetRandomPeriodNumber(Int_t mcRunNumber)
Get random period number from the sub-periods assigned to this run number.
Int_t AddPeriod(Int_t periodNumber, UInt_t start, UInt_t end)
Assign an mc RunNumber to a data period.
std::unique_ptr< TRandom3 > m_random3
Double_t GetIntegratedLumi(UInt_t start, UInt_t end)
get the amount of integrated lumi between the two given runs
void EnableDebugging(Bool_t in)
Indicate if additional debugging information should be output.
Int_t GetNearestGoodBin(Int_t thisMCRunNumber, Int_t bin)
TH1 * GetPrimaryDistribution(Int_t channelNumber, Int_t periodNumber)
std::list< Period > m_periodList
List physically holding (owning) period objects.
Float_t GetCombinedWeight(Int_t periodNumber, Int_t channelNumber, Float_t x, Float_t y=0.)
Int_t UsePeriodConfig(const TString &configName)
use a hardcoded period configuration
void SetDefaultChannel(Int_t channel, Int_t mcRunNumber=-1)
Set which channel should be used as a default when specific mc channel distributions cannot be found.
std::vector< int > GetPeriodNumbers() const
std::unique_ptr< CompositeTrigger > makeTrigger(const TString &s)
Bool_t IsUnrepresentedData(Int_t runNumber, Float_t x, Float_t y=0.)
void CalculatePrescaledLuminosityHistograms(const TString &trigger, int run_dependent=0)
Double_t GetIntegratedLumi(const TString &trigger="")
total luminosity loaded and accepted by the tool (in inverse pb)
Int_t SetUniformBinning(Int_t nbinsx, Double_t xlow, Double_t xup, Int_t nbinsy=0, Double_t ylow=0, Double_t yup=0)
Double_t GetDataWeight(Int_t runNumber, const TString &trigger, Double_t x, bool run_dependent=false)
Method for weighting data to account for prescales and mu bias.
std::map< Int_t, Period * > m_periods
Int_t AddMetaDataFile(const TString &fileName, const TString &channelBranchName="mc_channel_number")
std::unique_ptr< TH1 > m_emptyHistogram
the empty histogram used for this weight... effectively holds the configuration of the binning
Bool_t RemoveChannel(int chanNum)
Removes a channel from the inputs ... this is for experts only.
UInt_t GetRandomRunNumber(Int_t mcRunNumber)
Gets a random data run number according to the integrated lumi distribution associated to this mcRunN...
Float_t GetPrimaryWeight(Int_t periodNumber, Int_t channelNumber, Float_t x)
Int_t GenerateMetaDataFile(const TString &fileName, const TString &channelBranchName="mc_channel_number")
void SetTriggerBit(const TString &trigger, bool in=true)
TH1 * GetPrimaryTriggerDistribution(const TString &trigger, Int_t periodNumber, long triggerBits)
Double_t GetPrescaleWeight(Int_t runNumber, const TString &trigger, Double_t x, bool run_dependent=false)
Method for prescaling MC to account for prescales in data.
void PrintInfo(Bool_t in)
disable info
Int_t AddLumiCalcFile(const TString &fileName, const TString &trigger="None")
Int_t GetFirstFoundPeriodNumber(UInt_t runNumber)
Get the first period number with the data run number contained - assume all periods are disconnected ...
void calculateHistograms(CompositeTrigger *trigger, int run_dependent)
Int_t AddConfigFile(const TString &fileName)
UInt_t GetRandomLumiBlockNumber(UInt_t runNumber)
Get a random lumi block from the run number given.
void DisableWarnings(Bool_t in)
Indicate if warnings should be suppressed.
std::map< TString, bool > m_triggerPassBits
Float_t GetLumiBlockMu(Int_t runNumber, UInt_t lb)
get the lumiblock mu, useful for 'updating' the mu coming from data to account for new lumitags
Int_t GetDefaultChannel(Int_t mcRunNumber=-1)
void AddDistributionTree(TTree *tree, TFile *file)
Int_t SetBinning(Int_t nbinsx, Double_t *xbins, Int_t nbinsy=0, Double_t *ybins=0)
Add a histogram binning config.
std::map< TString, std::unique_ptr< CompositeTrigger > > m_triggerObjs
void CopyProperties(const TPileupReweighting *in)
Double_t GetUnrepresentedDataFraction(Int_t periodNumber, Int_t channel)
return the unrepresented data fraction in a given channel .
Float_t GetUnrepresentedDataWeight(Int_t periodNumber, Int_t channel)
TTree * GetMetaDataTree()
combines loaded metadata with channel sumsofweights and entry counts
virtual bool runLbnOK(Int_t, Int_t)
TPileupReweighting(const char *name="TPileupReweighting")
Standard constructor.
ULong64_t GetPRWHash(Int_t periodNumber, Int_t channelNumber, Float_t x, Float_t y=0.)
void IgnoreConfigFilePeriods(Bool_t in)
Should the tool ignore period assignments encoded in config file.
Int_t IsBadBin(Int_t thisMCRunNumber, Int_t bin)
TPileupReweighting * m_parentTool
Float_t GetPeriodWeight(Int_t periodNumber, Int_t channelNumber)
void SetUnrepresentedDataAction(Int_t action, Double_t tolerance=0.05)
Set how to handle configurations where some of your data has no corresponding mc to describe it 0=Def...
std::unique_ptr< TH1 > CloneEmptyHistogram(Int_t runNumber, Int_t channelNumber)
std::map< TString, std::vector< TString > > m_lumicalcFiles
map storing the lumicalc file locations - used when building DataPileupWeights
Int_t AddDistribution(TH1 *hist, Int_t runNumber, Int_t channelNumber)
Double_t GetSumOfEventWeights(Int_t channel)
void SetParentTool(TPileupReweighting *tool)
Bool_t MakeWeightTree(TString channelNumbers, TString outFile, TString hashBranch="PRWHash", TString weightBranch="PileupWeight")
void SetDataScaleFactors(Float_t x, Float_t y=1.)
Scale the LumiMetaData mu values by this factor.
Double_t GetMetaData(const TString &metadataName, Int_t channelNumber)
int lb
Definition globals.cxx:23
std::string find(const std::string &s)
return a remapped string
Definition hcg.cxx:138
Select isolated Photons, Electrons and Muons.
Definition run.py:1
std::unique_ptr< CompositeTrigger > trig2
long getBits(const TPileupReweighting *tool)
void getTriggers(std::vector< TString > &s)
double eval(std::map< TString, std::map< Int_t, std::map< Int_t, Float_t > > > &m, int run, int lbn, const TPileupReweighting *tool)
std::map< int, std::map< long, std::unique_ptr< TH1 > > > triggerHists
std::unique_ptr< CompositeTrigger > trig1
std::map< Int_t, std::unique_ptr< TH1 > > inputHists
std::map< Int_t, Double_t > sumOfWeights
std::map< Int_t, std::unique_ptr< TH1 > > primaryHists
std::map< Int_t, Int_t > inputBinRedirect
bool contains(unsigned int runNumber)
std::map< Int_t, Int_t > numberOfEntries
std::map< Int_t, std::unique_ptr< TH2 > > secondaryHists
std::map< Int_t, Double_t > unrepData
std::vector< Period * > subPeriods
Period(Int_t _id, UInt_t _start, UInt_t _end, Int_t _defaultChannel)
void print(const char *prefix)
std::map< Int_t, Double_t > badBins
std::map< TString, std::unique_ptr< TH1 > > inputHists
std::map< UInt_t, std::pair< Double_t, Double_t > > lumiByLbn
std::unique_ptr< TH1 > muDist
TChain * tree
TFile * file