|
ATLAS Offline Software
|
Go to the documentation of this file.
7 #ifndef __TPILEUPREWEIGHTING__
8 #define __TPILEUPREWEIGHTING__
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);
77 Error(
"GetNumberOfEvents",
"Unknown channel: %d",
channel);
86 Error(
"GetSumOfEventWeights",
"Unknown channel: %d",
channel);
93 void RemapPeriod(Int_t periodNumber1, Int_t periodNumber2);
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");
136 Warning(
"GetUnrepresentedDataWeight",
"You should not be applying this weight unless the UnrepresentedDataAction=2");
188 Double_t
GetMetaData(
const TString& metadataName,Int_t channelNumber) {
190 Error(
"GetMetaData",
"Metadata %s not known",metadataName.Data());
194 Error(
"GetMetaData",
"Metadata %s not known in channel %d",metadataName.Data(), channelNumber);
197 return m_metadata[metadataName][channelNumber];
207 Int_t
Fill(Int_t
runNumber,Int_t channelNumber,Float_t
w,Float_t
x, Float_t
y=0.);
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");
238 Int_t
Merge(TCollection *coll);
243 std::vector<int>
out;
253 m_periods[periodNumber]->inputHists.find(channelNumber)==
m_periods[periodNumber]->inputHists.end()) {
256 return m_periods[periodNumber]->inputHists[channelNumber].get();
261 m_periods[periodNumber]->primaryHists.find(channelNumber)==
m_periods[periodNumber]->primaryHists.end()) {
264 return m_periods[periodNumber]->primaryHists[channelNumber].get();
269 m_triggerObjs[trigger]->triggerHists[periodNumber].find(triggerBits) ==
m_triggerObjs[trigger]->triggerHists[periodNumber].end())
return 0;
275 return m_triggerObjs[trigger]->triggerHists[periodNumber][triggerBits].get();
308 virtual bool runLbnOK(Int_t , Int_t ) {
return true; }
313 }
catch(...) {
return true; }
368 std::unique_ptr< CompositeTrigger >
trig1;
369 std::unique_ptr< CompositeTrigger >
trig2;
403 std::unique_ptr<CompositeTrigger>
makeTrigger(
const TString&
s);
434 std::cout <<
prefix <<
id <<
"[" <<
start <<
"," <<
end <<
"] : ";
436 std::cout << std::endl;
443 std::map<UInt_t, std::pair<Double_t,Double_t> >
lumiByLbn;
std::map< Int_t, Int_t > inputBinRedirect
std::vector< Period * > subPeriods
Int_t AddDistribution(TH1 *hist, Int_t runNumber, Int_t channelNumber)
Period(Int_t _id, UInt_t _start, UInt_t _end, Int_t _defaultChannel)
Int_t Fill(Int_t runNumber, Int_t channelNumber, Float_t w, Float_t x, Float_t y=0.)
void AddDistributionTree(TTree *tree, TFile *file)
Int_t IsBadBin(Int_t thisMCRunNumber, Int_t bin)
double eval(std::map< TString, std::map< Int_t, std::map< Int_t, Float_t > > > &m, int run, int lbn, const TPileupReweighting *tool)
Int_t SetUniformBinning(Int_t nbinsx, Double_t xlow, Double_t xup, Int_t nbinsy=0, Double_t ylow=0, Double_t yup=0)
constexpr double tolerance
void SetParentTool(TPileupReweighting *tool)
Bool_t m_lumiVectorIsLoaded
Float_t GetPrimaryWeight(Int_t periodNumber, Int_t channelNumber, Float_t x)
Int_t AddLumiCalcFile(const TString &fileName, const TString &trigger="None")
Double_t GetUnrepresentedDataFraction(Int_t periodNumber, Int_t channel)
return the unrepresented data fraction in a given channel .
std::map< TString, bool > m_triggerPassBits
std::string find(const std::string &s)
return a remapped string
Float_t GetPeriodWeight(Int_t periodNumber, Int_t channelNumber)
Bool_t IsUnrepresentedData(Int_t runNumber, Float_t x, Float_t y=0.)
Int_t AddMetaDataFile(const TString &fileName, const TString &channelBranchName="mc_channel_number")
Float_t GetDataScaleFactor() const
void SetTriggerBit(const TString &trigger, bool in=true)
std::map< TString, std::vector< TString > > m_lumicalcFiles
map storing the lumicalc file locations - used when building DataPileupWeights
std::unique_ptr< CompositeTrigger > trig2
std::map< TString, std::map< Int_t, Double_t > > m_metadata
channel metadata map
void SetDataScaleFactors(Float_t x, Float_t y=1.)
Scale the LumiMetaData mu values by this factor.
std::unique_ptr< CompositeTrigger > trig1
std::unique_ptr< TH1 > muDist
Int_t SetBinning(Int_t nbinsx, Double_t *xbins, Int_t nbinsy=0, Double_t *ybins=0)
Add a histogram binning config.
Int_t GenerateMetaDataFile(const TString &fileName, const TString &channelBranchName="mc_channel_number")
Double_t GetIntegratedLumi(const TString &trigger="")
total luminosity loaded and accepted by the tool (in inverse pb)
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.
Int_t Merge(TCollection *coll)
void SetDefaultChannel(Int_t channel)
Int_t UsePeriodConfig(const TString &configName)
use a hardcoded period configuration
Bool_t m_ignoreFilePeriods
int run(int argc, char *argv[])
Bool_t MakeWeightTree(TString channelNumbers, TString outFile, TString hashBranch="PRWHash", TString weightBranch="PileupWeight")
TH1 * GetPrimaryDistribution(Int_t channelNumber, Int_t periodNumber)
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.
Bool_t RemoveChannel(int chanNum)
Removes a channel from the inputs ...
Select isolated Photons, Electrons and Muons.
std::map< Int_t, Double_t > sumOfWeights
virtual bool passTriggerBeforePrescale(const TString &trigger) const
std::map< TString, std::unique_ptr< CompositeTrigger > > m_triggerObjs
UInt_t GetRandomRunNumber(Int_t mcRunNumber)
Gets a random data run number according to the integrated lumi distribution associated to this mcRunN...
UInt_t GetRandomLumiBlockNumber(UInt_t runNumber)
Get a random lumi block from the run number given.
void print(const char *prefix)
std::vector< int > GetPeriodNumbers() const
std::map< int, std::map< long, std::unique_ptr< TH1 > > > triggerHists
Float_t m_dataScaleFactorY
Int_t AddPeriod(Int_t periodNumber, UInt_t start, UInt_t end)
Assign an mc RunNumber to a data period.
std::map< UInt_t, std::pair< Double_t, Double_t > > lumiByLbn
std::map< Int_t, Double_t > badBins
long getBits(const TPileupReweighting *tool)
void CopyProperties(const TPileupReweighting *in)
void RemapPeriod(Int_t periodNumber1, Int_t periodNumber2)
Combine two period numbers.
void EnableDebugging(Bool_t in)
Indicate if additional debugging information should be output.
void IgnoreConfigFilePeriods(Bool_t in)
Should the tool ignore period assignments encoded in config file.
void CalculatePrescaledLuminosityHistograms(const TString &trigger, int run_dependent=0)
Int_t m_lumicalcRunNumberOffset
std::vector< TString > subTriggers
std::list< Period > m_periodList
List physically holding (owning) period objects.
Float_t GetSecondaryWeight(Int_t periodNumber, Int_t channelNumber, Float_t x, Float_t y)
Float_t GetCombinedWeight(Int_t periodNumber, Int_t channelNumber, Float_t x, Float_t y=0.)
void SetRandomSeed(int seed)
Int_t WriteToFile(const TString &filename="")
std::map< Int_t, Period * > m_periods
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 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...
Bool_t m_ignoreBadChannels
void calculateHistograms(CompositeTrigger *trigger, int run_dependent)
void normalizeHistogram(TH1 *histo)
Normalize histograms.
Int_t GetNearestGoodBin(Int_t thisMCRunNumber, Int_t bin)
std::map< UInt_t, Run > m_runs
std::unique_ptr< TRandom3 > m_random3
outFile
Comment Out Those You do not wish to run.
void PrintInfo(Bool_t in)
disable info
TPileupReweighting * m_parentTool
Bool_t m_doPrescaleWeight
void getTriggers(std::vector< TString > &s)
Int_t m_unrepresentedDataAction
Double_t GetIntegratedLumi(UInt_t start, UInt_t end)
get the amount of integrated lumi between the two given runs
Double_t GetNumberOfEvents(Int_t channel)
totalMC maps should also hold the total number of entries for each channel
void SetMCScaleFactors(Float_t x, Float_t y=1.)
std::unique_ptr< CompositeTrigger > makeTrigger(const TString &s)
Int_t AddConfigFile(const TString &fileName)
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::map< Int_t, Double_t > unrepDataByChannel
Int_t Initialize()
Initialize this class once before the event loop starts If distribution information is provided,...
std::map< TString, std::unique_ptr< TH1 > > inputHists
ULong64_t GetPRWHash(Int_t periodNumber, Int_t channelNumber, Float_t x, Float_t y=0.)
std::map< Int_t, Int_t > numberOfEntries
TTree * GetMetaDataTree()
combines loaded metadata with channel sumsofweights and entry counts
Int_t GetDefaultChannel(Int_t mcRunNumber=-1)
Double_t m_unrepDataTolerance
std::unique_ptr< TH1 > CloneEmptyHistogram(Int_t runNumber, Int_t channelNumber)
Float_t m_dataScaleFactorX
TH1 * GetPrimaryTriggerDistribution(const TString &trigger, Int_t periodNumber, long triggerBits)
double GetRunAverageMu(int run)
Double_t GetMetaData(const TString &metadataName, Int_t channelNumber)
std::map< Int_t, std::unique_ptr< TH2 > > secondaryHists
Int_t GetFirstFoundPeriodNumber(UInt_t runNumber)
Get the first period number with the data run number contained - assume all periods are disconnected ...
Float_t GetUnrepresentedDataWeight(Int_t periodNumber, Int_t channel)
virtual bool runLbnOK(Int_t, Int_t)
std::map< UInt_t, Run > & GetRunMap()
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
Double_t GetLumiBlockIntegratedLumi(Int_t runNumber, UInt_t lb)
get integrated lumi for specific run and lumiblock number .
Int_t GetRandomPeriodNumber(Int_t mcRunNumber)
Get random period number from the sub-periods assigned to this run number.
std::map< Int_t, Double_t > unrepData
void ResetCountingMode()
This method is DEFINITELY EXPERT USE ONLY.
std::string m_prwFilesPathPrefix
std::map< Int_t, std::unique_ptr< TH1 > > inputHists
Bool_t m_doGlobalDataWeight
Double_t GetSumOfEventWeights(Int_t channel)
std::vector< UInt_t > runNumbers
TH1 * GetInputHistogram(Int_t channelNumber, Int_t periodNumber)
TPileupReweighting(const char *name="TPileupReweighting")
Standard constructor.
bool contains(unsigned int runNumber)
std::map< Int_t, std::unique_ptr< TH1 > > primaryHists
void DisableWarnings(Bool_t in)
Indicate if warnings should be suppressed.
std::unique_ptr< TH1 > m_emptyHistogram
the empty histogram used for this weight...