ATLAS Offline Software
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 
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 
44 class TTree;
45 class TFile;
46 
47 
48 
49 namespace 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  }
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  }
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);
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
333  Bool_t m_debugging;
334  Bool_t m_printInfo;
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 
365 public:
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 
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  };
399 protected:
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 
406 public:
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  };
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; }
448 protected:
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 
456  std::string m_prwFilesPathPrefix;
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
468  int m_autoRunStart = 0;
469  int m_autoRunEnd = 0;
470 
471 public:
472  //this method is a convenience for copying over properties to the tools that are used for systematic variations
473  inline void CopyProperties(const TPileupReweighting* in) {
478  }
479 
480  ClassDef(TPileupReweighting,0)
481 
482 
483  }; // End: class definition
484 
485 } // End: namespace Root
486 
487 #endif
CP::TPileupReweighting::Period::inputBinRedirect
std::map< Int_t, Int_t > inputBinRedirect
Definition: TPileupReweighting.h:414
CP::TPileupReweighting::Period::subPeriods
std::vector< Period * > subPeriods
Definition: TPileupReweighting.h:416
CP::TPileupReweighting::AddDistribution
Int_t AddDistribution(TH1 *hist, Int_t runNumber, Int_t channelNumber)
Definition: TPileupReweighting.cxx:728
CP::TPileupReweighting::Period::Period
Period(Int_t _id, UInt_t _start, UInt_t _end, Int_t _defaultChannel)
Definition: TPileupReweighting.h:409
CP::TPileupReweighting::Fill
Int_t Fill(Int_t runNumber, Int_t channelNumber, Float_t w, Float_t x, Float_t y=0.)
Definition: TPileupReweighting.cxx:1837
CP::TPileupReweighting::AddDistributionTree
void AddDistributionTree(TTree *tree, TFile *file)
Definition: TPileupReweighting.cxx:648
CP::TPileupReweighting::IsBadBin
Int_t IsBadBin(Int_t thisMCRunNumber, Int_t bin)
Definition: TPileupReweighting.cxx:1351
CP::TPileupReweighting::CompositeTrigger::eval
double eval(std::map< TString, std::map< Int_t, std::map< Int_t, Float_t > > > &m, int run, int lbn, const TPileupReweighting *tool)
Definition: TPileupReweighting.h:373
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
python.SystemOfUnits.s
int s
Definition: SystemOfUnits.py:131
tolerance
constexpr double tolerance
Definition: runMdtGeoComparison.cxx:105
CP::TPileupReweighting::SetParentTool
void SetParentTool(TPileupReweighting *tool)
Definition: TPileupReweighting.h:296
CP::TPileupReweighting::m_lumiVectorIsLoaded
Bool_t m_lumiVectorIsLoaded
Definition: TPileupReweighting.h:337
CP::TPileupReweighting::GetPrimaryWeight
Float_t GetPrimaryWeight(Int_t periodNumber, Int_t channelNumber, Float_t x)
Definition: TPileupReweighting.cxx:1653
python.SystemOfUnits.m
int m
Definition: SystemOfUnits.py:91
python.PerfMonSerializer.p
def p
Definition: PerfMonSerializer.py:743
CP::TPileupReweighting::AddLumiCalcFile
Int_t AddLumiCalcFile(const TString &fileName, const TString &trigger="None")
Definition: TPileupReweighting.cxx:847
CP::TPileupReweighting::GetUnrepresentedDataFraction
Double_t GetUnrepresentedDataFraction(Int_t periodNumber, Int_t channel)
return the unrepresented data fraction in a given channel .
Definition: TPileupReweighting.cxx:1386
plotting.yearwise_efficiency.channel
channel
Definition: yearwise_efficiency.py:28
CP::TPileupReweighting::m_autoRunStart
int m_autoRunStart
Definition: TPileupReweighting.h:468
CP::TPileupReweighting::m_triggerPassBits
std::map< TString, bool > m_triggerPassBits
Definition: TPileupReweighting.h:315
find
std::string find(const std::string &s)
return a remapped string
Definition: hcg.cxx:135
CP::TPileupReweighting::GetPeriodWeight
Float_t GetPeriodWeight(Int_t periodNumber, Int_t channelNumber)
Definition: TPileupReweighting.cxx:1623
CP::TPileupReweighting::IsUnrepresentedData
Bool_t IsUnrepresentedData(Int_t runNumber, Float_t x, Float_t y=0.)
Definition: TPileupReweighting.cxx:1524
CP::TPileupReweighting::AddMetaDataFile
Int_t AddMetaDataFile(const TString &fileName, const TString &channelBranchName="mc_channel_number")
Definition: TPileupReweighting.cxx:506
CP::TPileupReweighting::IsInitialized
Bool_t IsInitialized()
Definition: TPileupReweighting.h:288
CP::TPileupReweighting::GetDataScaleFactor
Float_t GetDataScaleFactor() const
Definition: TPileupReweighting.h:298
CP::TPileupReweighting::SetTriggerBit
void SetTriggerBit(const TString &trigger, bool in=true)
Definition: TPileupReweighting.h:300
CP::TPileupReweighting::m_lumicalcFiles
std::map< TString, std::vector< TString > > m_lumicalcFiles
map storing the lumicalc file locations - used when building DataPileupWeights
Definition: TPileupReweighting.h:349
CP::TPileupReweighting::CompositeTrigger::trig2
std::unique_ptr< CompositeTrigger > trig2
Definition: TPileupReweighting.h:369
CP::TPileupReweighting::m_metadata
std::map< TString, std::map< Int_t, Double_t > > m_metadata
channel metadata map
Definition: TPileupReweighting.h:363
CP::TPileupReweighting
Definition: TPileupReweighting.h:50
CP::TPileupReweighting::SetDataScaleFactors
void SetDataScaleFactors(Float_t x, Float_t y=1.)
Scale the LumiMetaData mu values by this factor.
Definition: TPileupReweighting.h:156
CP::TPileupReweighting::CompositeTrigger::trig1
std::unique_ptr< CompositeTrigger > trig1
Definition: TPileupReweighting.h:368
CP::TPileupReweighting::Run::muDist
std::unique_ptr< TH1 > muDist
Definition: TPileupReweighting.h:444
Data
@ Data
Definition: BaseObject.h:11
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
plotmaker.hist
hist
Definition: plotmaker.py:148
StateLessPT_NewConfig.Format
Format
Definition: StateLessPT_NewConfig.py:146
CP::TPileupReweighting::m_printInfo
Bool_t m_printInfo
Definition: TPileupReweighting.h:334
mergePhysValFiles.start
start
Definition: DataQuality/DataQualityUtils/scripts/mergePhysValFiles.py:14
CP::TPileupReweighting::GenerateMetaDataFile
Int_t GenerateMetaDataFile(const TString &fileName, const TString &channelBranchName="mc_channel_number")
Definition: TPileupReweighting.cxx:460
tree
TChain * tree
Definition: tile_monitor.h:30
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::m_useMultiPeriods
Bool_t m_useMultiPeriods
Definition: TPileupReweighting.h:465
CP::TPileupReweighting::SetDefaultChannel
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.
Definition: TPileupReweighting.cxx:72
CP::TPileupReweighting::Merge
Int_t Merge(TCollection *coll)
Definition: TPileupReweighting.cxx:2039
CP::TPileupReweighting::Period::SetDefaultChannel
void SetDefaultChannel(Int_t channel)
Definition: TPileupReweighting.h:429
python.AthDsoLogger.out
out
Definition: AthDsoLogger.py:71
CP::TPileupReweighting::UsePeriodConfig
Int_t UsePeriodConfig(const TString &configName)
use a hardcoded period configuration
Definition: TPileupReweighting.cxx:234
PixelAthClusterMonAlgCfg.ybins
ybins
Definition: PixelAthClusterMonAlgCfg.py:163
CP::TPileupReweighting::m_ignoreFilePeriods
Bool_t m_ignoreFilePeriods
Definition: TPileupReweighting.h:341
run
int run(int argc, char *argv[])
Definition: ttree2hdf5.cxx:28
bin
Definition: BinsDiffFromStripMedian.h:43
CP::TPileupReweighting::m_metadatatree
TTree * m_metadatatree
Definition: TPileupReweighting.h:342
CP::TPileupReweighting::Period::defaultChannel
Int_t defaultChannel
Definition: TPileupReweighting.h:413
CP::TPileupReweighting::MakeWeightTree
Bool_t MakeWeightTree(TString channelNumbers, TString outFile, TString hashBranch="PRWHash", TString weightBranch="PileupWeight")
Definition: TPileupReweighting.cxx:1530
InDetDD::global
@ global
Definition: InDetDD_Defs.h:16
CP::TPileupReweighting::GetPrimaryDistribution
TH1 * GetPrimaryDistribution(Int_t channelNumber, Int_t periodNumber)
Definition: TPileupReweighting.h:259
CP::TPileupReweighting::GetDataWeight
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.
Definition: TPileupReweighting.cxx:1730
CP::TPileupReweighting::RemoveChannel
Bool_t RemoveChannel(int chanNum)
Removes a channel from the inputs ...
Definition: TPileupReweighting.cxx:1001
x
#define x
CP
Select isolated Photons, Electrons and Muons.
Definition: Control/xAODRootAccess/xAODRootAccess/TEvent.h:48
CP::TPileupReweighting::m_autoRunEnd
int m_autoRunEnd
Definition: TPileupReweighting.h:469
mergePhysValFiles.end
end
Definition: DataQuality/DataQualityUtils/scripts/mergePhysValFiles.py:93
CP::TPileupReweighting::Period::sumOfWeights
std::map< Int_t, Double_t > sumOfWeights
Definition: TPileupReweighting.h:419
CP::TPileupReweighting::passTriggerBeforePrescale
virtual bool passTriggerBeforePrescale(const TString &trigger) const
Definition: TPileupReweighting.h:309
CP::TPileupReweighting::m_nextPeriodNumber
Int_t m_nextPeriodNumber
Definition: TPileupReweighting.h:340
CP::TPileupReweighting::m_triggerObjs
std::map< TString, std::unique_ptr< CompositeTrigger > > m_triggerObjs
Definition: TPileupReweighting.h:401
CP::TPileupReweighting::GetRandomRunNumber
UInt_t GetRandomRunNumber(Int_t mcRunNumber)
Gets a random data run number according to the integrated lumi distribution associated to this mcRunN...
Definition: TPileupReweighting.cxx:1412
CP::TPileupReweighting::GetRandomLumiBlockNumber
UInt_t GetRandomLumiBlockNumber(UInt_t runNumber)
Get a random lumi block from the run number given.
Definition: TPileupReweighting.cxx:1469
CP::TPileupReweighting::CompositeTrigger
Definition: TPileupReweighting.h:366
CP::TPileupReweighting::m_isInitialized
Bool_t m_isInitialized
Definition: TPileupReweighting.h:337
CP::TPileupReweighting::Period::print
void print(const char *prefix)
Definition: TPileupReweighting.h:433
CP::TPileupReweighting::GetPeriodNumbers
std::vector< int > GetPeriodNumbers() const
Definition: TPileupReweighting.h:242
uint
unsigned int uint
Definition: LArOFPhaseFill.cxx:20
CP::TPileupReweighting::CompositeTrigger::triggerHists
std::map< int, std::map< long, std::unique_ptr< TH1 > > > triggerHists
Definition: TPileupReweighting.h:396
CP::TPileupReweighting::m_dataScaleFactorY
Float_t m_dataScaleFactorY
Definition: TPileupReweighting.h:338
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
CP::TPileupReweighting::GetRandomSeed
int GetRandomSeed()
Definition: TPileupReweighting.h:223
CP::TPileupReweighting::Run::lumiByLbn
std::map< UInt_t, std::pair< Double_t, Double_t > > lumiByLbn
Definition: TPileupReweighting.h:443
CP::TPileupReweighting::Run::badBins
std::map< Int_t, Double_t > badBins
Definition: TPileupReweighting.h:441
CP::TPileupReweighting::CompositeTrigger::getBits
long getBits(const TPileupReweighting *tool)
Definition: TPileupReweighting.h:387
FortranAlgorithmOptions.fileName
fileName
Definition: FortranAlgorithmOptions.py:13
CP::TPileupReweighting::m_countingMode
Bool_t m_countingMode
Definition: TPileupReweighting.h:335
CP::TPileupReweighting::Run::lumi
Double_t lumi
Definition: TPileupReweighting.h:442
CP::TPileupReweighting::CopyProperties
void CopyProperties(const TPileupReweighting *in)
Definition: TPileupReweighting.h:473
CP::TPileupReweighting::RemapPeriod
void RemapPeriod(Int_t periodNumber1, Int_t periodNumber2)
Combine two period numbers.
Definition: TPileupReweighting.cxx:63
python.BunchSpacingUtils.lb
lb
Definition: BunchSpacingUtils.py:88
checkCoolLatestUpdate.chanNum
chanNum
Definition: checkCoolLatestUpdate.py:27
CP::TPileupReweighting::EnableDebugging
void EnableDebugging(Bool_t in)
Indicate if additional debugging information should be output.
Definition: TPileupReweighting.h:118
CP::TPileupReweighting::Period
Definition: TPileupReweighting.h:408
CP::TPileupReweighting::IgnoreConfigFilePeriods
void IgnoreConfigFilePeriods(Bool_t in)
Should the tool ignore period assignments encoded in config file.
Definition: TPileupReweighting.h:146
lumiFormat.i
int i
Definition: lumiFormat.py:92
CP::TPileupReweighting::Period::id
Int_t id
Definition: TPileupReweighting.h:409
CP::TPileupReweighting::CalculatePrescaledLuminosityHistograms
void CalculatePrescaledLuminosityHistograms(const TString &trigger, int run_dependent=0)
Definition: TPileupReweighting.cxx:2086
CP::TPileupReweighting::m_lumicalcRunNumberOffset
Int_t m_lumicalcRunNumberOffset
Definition: TPileupReweighting.h:346
CP::TPileupReweighting::m_debugging
Bool_t m_debugging
Definition: TPileupReweighting.h:333
CP::TPileupReweighting::CompositeTrigger::subTriggers
std::vector< TString > subTriggers
Definition: TPileupReweighting.h:371
CP::TPileupReweighting::ResetTriggerBits
void ResetTriggerBits()
Definition: TPileupReweighting.h:301
CP::TPileupReweighting::Period::end
UInt_t end
Definition: TPileupReweighting.h:412
CP::TPileupReweighting::m_periodList
std::list< Period > m_periodList
List physically holding (owning) period objects.
Definition: TPileupReweighting.h:450
CP::TPileupReweighting::GetSecondaryWeight
Float_t GetSecondaryWeight(Int_t periodNumber, Int_t channelNumber, Float_t x, Float_t y)
Definition: TPileupReweighting.cxx:1701
checkCorrelInHIST.prefix
dictionary prefix
Definition: checkCorrelInHIST.py:391
file
TFile * file
Definition: tile_monitor.h:29
CP::TPileupReweighting::GetCombinedWeight
Float_t GetCombinedWeight(Int_t periodNumber, Int_t channelNumber, Float_t x, Float_t y=0.)
Definition: TPileupReweighting.cxx:1603
CP::TPileupReweighting::SetRandomSeed
void SetRandomSeed(int seed)
Definition: TPileupReweighting.h:222
CP::TPileupReweighting::WriteToFile
Int_t WriteToFile(const TString &filename="")
Definition: TPileupReweighting.cxx:1888
CP::TPileupReweighting::m_mcScaleFactorY
Float_t m_mcScaleFactorY
Definition: TPileupReweighting.h:339
CP::TPileupReweighting::m_periods
std::map< Int_t, Period * > m_periods
Definition: TPileupReweighting.h:451
CP::TPileupReweighting::GetPrescaleWeight
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.
Definition: TPileupReweighting.cxx:1825
run
Definition: run.py:1
CP::TPileupReweighting::m_mcScaleFactorX
Float_t m_mcScaleFactorX
Definition: TPileupReweighting.h:339
CP::TPileupReweighting::SetUnrepresentedDataAction
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...
Definition: TPileupReweighting.h:124
CP::TPileupReweighting::m_ignoreBadChannels
Bool_t m_ignoreBadChannels
Definition: TPileupReweighting.h:464
CP::TPileupReweighting::calculateHistograms
void calculateHistograms(CompositeTrigger *trigger, int run_dependent)
Definition: TPileupReweighting.cxx:2109
CP::TPileupReweighting::normalizeHistogram
void normalizeHistogram(TH1 *histo)
Normalize histograms.
Definition: TPileupReweighting.cxx:1996
CP::TPileupReweighting::GetNearestGoodBin
Int_t GetNearestGoodBin(Int_t thisMCRunNumber, Int_t bin)
Definition: TPileupReweighting.cxx:1367
CP::TPileupReweighting::m_runs
std::map< UInt_t, Run > m_runs
Definition: TPileupReweighting.h:452
CP::TPileupReweighting::m_random3
std::unique_ptr< TRandom3 > m_random3
Definition: TPileupReweighting.h:462
DQPostProcessTest.outFile
outFile
Comment Out Those You do not wish to run.
Definition: DQPostProcessTest.py:37
tolerance
Definition: suep_shower.h:17
CP::TPileupReweighting::PrintInfo
void PrintInfo(Bool_t in)
disable info
Definition: TPileupReweighting.h:120
CP::TPileupReweighting::m_parentTool
TPileupReweighting * m_parentTool
Definition: TPileupReweighting.h:331
CP::TPileupReweighting::m_doPrescaleWeight
Bool_t m_doPrescaleWeight
Definition: TPileupReweighting.h:345
CP::TPileupReweighting::CompositeTrigger::getTriggers
void getTriggers(std::vector< TString > &s)
Definition: TPileupReweighting.h:382
CP::TPileupReweighting::m_unrepresentedDataAction
Int_t m_unrepresentedDataAction
Definition: TPileupReweighting.h:336
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
CP::TPileupReweighting::CompositeTrigger::val
TString val
Definition: TPileupReweighting.h:370
CP::TPileupReweighting::GetIntegratedLumi
Double_t GetIntegratedLumi(UInt_t start, UInt_t end)
get the amount of integrated lumi between the two given runs
Definition: TPileupReweighting.h:102
AtlCoolConsole.tool
tool
Definition: AtlCoolConsole.py:453
CP::TPileupReweighting::Period::start
UInt_t start
Definition: TPileupReweighting.h:411
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::TPileupReweighting::SetMCScaleFactors
void SetMCScaleFactors(Float_t x, Float_t y=1.)
Definition: TPileupReweighting.h:157
CP::TPileupReweighting::PrintPeriods
void PrintPeriods()
Definition: TPileupReweighting.h:407
CP::TPileupReweighting::m_SetWarnings
Bool_t m_SetWarnings
Definition: TPileupReweighting.h:332
CP::TPileupReweighting::makeTrigger
std::unique_ptr< CompositeTrigger > makeTrigger(const TString &s)
Definition: TPileupReweighting.cxx:2278
LArCellBinning.xbins
int xbins
Definition: LArCellBinning.py:163
CP::TPileupReweighting::AddConfigFile
Int_t AddConfigFile(const TString &fileName)
Definition: TPileupReweighting.cxx:936
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::TPileupReweighting::unrepDataByChannel
std::map< Int_t, Double_t > unrepDataByChannel
Definition: TPileupReweighting.h:454
CP::TPileupReweighting::Initialize
Int_t Initialize()
Initialize this class once before the event loop starts If distribution information is provided,...
Definition: TPileupReweighting.cxx:1021
CP::TPileupReweighting::Run::inputHists
std::map< TString, std::unique_ptr< TH1 > > inputHists
Definition: TPileupReweighting.h:440
y
#define y
CP::TPileupReweighting::GetPRWHash
ULong64_t GetPRWHash(Int_t periodNumber, Int_t channelNumber, Float_t x, Float_t y=0.)
Definition: TPileupReweighting.cxx:1584
CP::TPileupReweighting::Period::numberOfEntries
std::map< Int_t, Int_t > numberOfEntries
Definition: TPileupReweighting.h:420
CP::TPileupReweighting::CompositeTrigger::CompositeTrigger
CompositeTrigger()
Definition: TPileupReweighting.h:372
CP::TPileupReweighting::GetMetaDataTree
TTree * GetMetaDataTree()
combines loaded metadata with channel sumsofweights and entry counts
Definition: TPileupReweighting.cxx:574
python.CaloScaleNoiseConfig.action
action
Definition: CaloScaleNoiseConfig.py:77
CP::TPileupReweighting::GetDefaultChannel
Int_t GetDefaultChannel(Int_t mcRunNumber=-1)
Definition: TPileupReweighting.cxx:109
CP::TPileupReweighting::m_unrepDataTolerance
Double_t m_unrepDataTolerance
Definition: TPileupReweighting.h:343
TH1
Definition: rootspy.cxx:268
CP::TPileupReweighting::CloneEmptyHistogram
std::unique_ptr< TH1 > CloneEmptyHistogram(Int_t runNumber, Int_t channelNumber)
Definition: TPileupReweighting.cxx:435
CP::TPileupReweighting::m_dataScaleFactorX
Float_t m_dataScaleFactorX
Definition: TPileupReweighting.h:338
CP::TPileupReweighting::GetPrimaryTriggerDistribution
TH1 * GetPrimaryTriggerDistribution(const TString &trigger, Int_t periodNumber, long triggerBits)
Definition: TPileupReweighting.h:267
CP::TPileupReweighting::GetRunAverageMu
double GetRunAverageMu(int run)
Definition: TPileupReweighting.h:303
CP::TPileupReweighting::GetMetaData
Double_t GetMetaData(const TString &metadataName, Int_t channelNumber)
Definition: TPileupReweighting.h:188
CaloCellTimeCorrFiller.filename
filename
Definition: CaloCellTimeCorrFiller.py:24
CP::TPileupReweighting::Period::secondaryHists
std::map< Int_t, std::unique_ptr< TH2 > > secondaryHists
Definition: TPileupReweighting.h:422
CP::TPileupReweighting::GetFirstFoundPeriodNumber
Int_t GetFirstFoundPeriodNumber(UInt_t runNumber)
Get the first period number with the data run number contained - assume all periods are disconnected ...
Definition: TPileupReweighting.cxx:422
CP::TPileupReweighting::GetUnrepresentedDataWeight
Float_t GetUnrepresentedDataWeight(Int_t periodNumber, Int_t channel)
Definition: TPileupReweighting.h:134
CP::TPileupReweighting::Run::nominalFromHists
bool nominalFromHists
Definition: TPileupReweighting.h:445
CP::TPileupReweighting::runLbnOK
virtual bool runLbnOK(Int_t, Int_t)
Definition: TPileupReweighting.h:308
CP::TPileupReweighting::Run
Definition: TPileupReweighting.h:439
CP::TPileupReweighting::GetRunMap
std::map< UInt_t, Run > & GetRunMap()
Definition: TPileupReweighting.h:447
python.IoTestsLib.w
def w
Definition: IoTestsLib.py:200
CP::TPileupReweighting::GetLumiBlockMu
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
Definition: TPileupReweighting.cxx:168
CP::TPileupReweighting::GetLumiBlockIntegratedLumi
Double_t GetLumiBlockIntegratedLumi(Int_t runNumber, UInt_t lb)
get integrated lumi for specific run and lumiblock number .
Definition: TPileupReweighting.cxx:154
plotBeamSpotCompare.histo
histo
Definition: plotBeamSpotCompare.py:415
CP::TPileupReweighting::GetRandomPeriodNumber
Int_t GetRandomPeriodNumber(Int_t mcRunNumber)
Get random period number from the sub-periods assigned to this run number.
Definition: TPileupReweighting.cxx:1492
CP::TPileupReweighting::Period::unrepData
std::map< Int_t, Double_t > unrepData
Definition: TPileupReweighting.h:415
CaloNoise_fillDB.mu
mu
Definition: CaloNoise_fillDB.py:53
CP::TPileupReweighting::ResetCountingMode
void ResetCountingMode()
This method is DEFINITELY EXPERT USE ONLY.
Definition: TPileupReweighting.h:293
CP::TPileupReweighting::m_prwFilesPathPrefix
std::string m_prwFilesPathPrefix
Definition: TPileupReweighting.h:456
CP::TPileupReweighting::CompositeTrigger::op
int op
Definition: TPileupReweighting.h:367
CP::TPileupReweighting::Period::inputHists
std::map< Int_t, std::unique_ptr< TH1 > > inputHists
Definition: TPileupReweighting.h:418
CP::TPileupReweighting::m_doGlobalDataWeight
Bool_t m_doGlobalDataWeight
Definition: TPileupReweighting.h:344
CP::TPileupReweighting::GetSumOfEventWeights
Double_t GetSumOfEventWeights(Int_t channel)
Definition: TPileupReweighting.h:82
CP::TPileupReweighting::Period::runNumbers
std::vector< UInt_t > runNumbers
Definition: TPileupReweighting.h:417
PhysDESDM_Quirks.trigger
trigger
Definition: PhysDESDM_Quirks.py:27
CP::TPileupReweighting::GetInputHistogram
TH1 * GetInputHistogram(Int_t channelNumber, Int_t periodNumber)
Definition: TPileupReweighting.h:251
CP::TPileupReweighting::TPileupReweighting
TPileupReweighting(const char *name="TPileupReweighting")
Standard constructor.
LB_AnalMapSplitter.lbn
lbn
Definition: LB_AnalMapSplitter.py:28
CP::TPileupReweighting::Period::contains
bool contains(unsigned int runNumber)
Definition: TPileupReweighting.h:424
CP::TPileupReweighting::Period::primaryHists
std::map< Int_t, std::unique_ptr< TH1 > > primaryHists
Definition: TPileupReweighting.h:421
CP::TPileupReweighting::DisableWarnings
void DisableWarnings(Bool_t in)
Indicate if warnings should be suppressed.
Definition: TPileupReweighting.h:116
CP::TPileupReweighting::m_emptyHistogram
std::unique_ptr< TH1 > m_emptyHistogram
the empty histogram used for this weight...
Definition: TPileupReweighting.h:358