ATLAS Offline Software
Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | Private Types | Private Member Functions | Private Attributes | List of all members
CP::PileupReweightingTool Class Reference

Implementation of the PileupReweighting tool. More...

#include <PileupReweightingTool.h>

Inheritance diagram for CP::PileupReweightingTool:
Collaboration diagram for CP::PileupReweightingTool:

Public Member Functions

virtual UInt_t GetRandomLumiBlockNumber (UInt_t runNumber)
 Get a random lumiblock number for the given run number. More...
 
virtual Double_t GetIntegratedLumi (UInt_t start, UInt_t end)
 Get the integrated luminosity (in pb-1) between start and end run (inclusive) More...
 
virtual Double_t GetIntegratedLumi (const TString &trigger)
 Total lumi (in pb-1) for a given trigger combination .. leave blank for the unprescaled. More...
 
virtual Double_t GetIntegratedLumi (Int_t periodNumber, UInt_t start, UInt_t end)
 similar to above, but for only the given mcRunNumber/periodNumber More...
 
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 run numbers More...
 
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 start and end data run numbers More...
 
virtual Int_t AddPeriod (Int_t periodNumber, UInt_t start, UInt_t end)
 use these methods when generating config files More...
 
virtual Int_t SetBinning (Int_t nbinsx, Double_t *xbins, Int_t nbinsy=0, Double_t *ybins=0)
 
virtual Int_t SetUniformBinning (Int_t nbinsx, Double_t xlow, Double_t xup, Int_t nbinsy=0, Double_t ylow=0, Double_t yup=0)
 
virtual Int_t SetBinning (TH1 *hist)
 
virtual Double_t GetSumOfEventWeights (Int_t channel)
 helpful alternative to using the EventBookkeepers info ... assuming you made your PRW Config file!! More...
 
virtual Double_t GetNumberOfEvents (Int_t channel)
 
 PileupReweightingTool (const std::string &name)
 Constructor for standalone usage. More...
 
virtual StatusCode initialize ()
 Function initialising the tool. More...
 
virtual StatusCode finalize ()
 Finalize - can call the WriteToFile for us. More...
 
virtual StatusCode apply (const xAOD::EventInfo &eventInfo, bool mu_dependent)
 Decorates with: MC: PileupWeight (CombinedWeight[*UnrepresentedDataWeight if action=2]), RandomRunNumber, RandomLumiBlockNumber Data: corrected_averageInteractionsPerCrossing mu_dependent says if the mu_dependency should be used for random run numbers or the data weights. More...
 
virtual float getCombinedWeight (const xAOD::EventInfo &eventInfo, bool correctUnrepresented)
 Return combined pileup weight. More...
 
virtual float getCombinedWeight (const xAOD::EventInfo &eventInfo, Double_t x, Double_t y, bool correctUnrepresented)
 Same as above, but for a 'custom weight' variable. More...
 
virtual float getCombinedWeight (const xAOD::EventInfo &eventInfo, const TString &trigger, bool mu_dependent, bool correctUnrepresented)
 get combined weight (i.e. pileup weight) but with a 1./dataWeight factor applied, this if used for 'prescaling' MC More...
 
virtual ULong64_t getPRWHash (const xAOD::EventInfo &eventInfo)
 return the prw hash used for fast updates of weights at the post-processing level ... see the share/makeWeightTree.C script for usage More...
 
virtual float getCorrectedAverageInteractionsPerCrossing (const xAOD::EventInfo &eventInfo, bool includeDataScaleFactor)
 Get the mu of a lumiblock ... needed to 'correct' the number in datasets. More...
 
virtual float getCorrectedActualInteractionsPerCrossing (const xAOD::EventInfo &eventInfo, bool includeDataScaleFactor)
 Get the corrected 'actual' interactions per crossing. More...
 
virtual double getLumiBlockIntegratedLumi (const xAOD::EventInfo &eventInfo)
 Get the integrated lumi of a lumiblock (in pb-1) More...
 
virtual float getUnrepresentedDataWeight (const xAOD::EventInfo &eventInfo)
 When using UnrepresentedDataAction=2, you may want to apply this additional weight to ensure sum of weights are preserved. More...
 
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. mu_dependency is recommended to be true. More...
 
virtual float getPrescaleWeight (const xAOD::EventInfo &eventInfo, const TString &trigger, bool mu_dependent)
 Get weight used to 'prescale' Monte Carlo for given trigger comibnation. More...
 
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 ... jetetmiss seem to like it muchly. More...
 
virtual int fill (const xAOD::EventInfo &eventInfo)
 Call this method once per event when in config file generating mode and you want standard mu reweighting. More...
 
virtual int fill (const xAOD::EventInfo &eventInfo, Double_t x, Double_t y)
 Use this method if you want to do a generic reweighting instead. More...
 
virtual CP::TPileupReweightingexpert ()
 Get pointer to the underlying tool - expert use only. Will require #include "PileupReweighting/TPileupReweighting.h". More...
 
bool isAffectedBySystematic (const CP::SystematicVariation &systematic) const
 The ISystematicsTool methods. More...
 
CP::SystematicSet affectingSystematics () const
 the list of all systematics this tool can be affected by More...
 
CP::SystematicSet recommendedSystematics () const
 the list of all systematics this tool recommends to use More...
 
StatusCode applySystematicVariation (const CP::SystematicSet &systConfig)
 effects: configure this tool for the given list of systematic variations. More...
 
void updateHandler (Gaudi::Details::PropertyBase &)
 
virtual void print () const
 Print the state of the tool. More...
 
ServiceHandle< StoreGateSvc > & evtStore ()
 The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc. More...
 
const ServiceHandle< StoreGateSvc > & evtStore () const
 The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc. More...
 
const ServiceHandle< StoreGateSvc > & detStore () const
 The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc. More...
 
virtual StatusCode sysInitialize () override
 Perform system initialization for an algorithm. More...
 
virtual StatusCode sysStart () override
 Handle START transition. More...
 
virtual std::vector< Gaudi::DataHandle * > inputHandles () const override
 Return this algorithm's input handles. More...
 
virtual std::vector< Gaudi::DataHandle * > outputHandles () const override
 Return this algorithm's output handles. More...
 
Gaudi::Details::PropertyBase & declareProperty (Gaudi::Property< T > &t)
 
Gaudi::Details::PropertyBase * declareProperty (const std::string &name, SG::VarHandleKey &hndl, const std::string &doc, const SG::VarHandleKeyType &)
 Declare a new Gaudi property. More...
 
Gaudi::Details::PropertyBase * declareProperty (const std::string &name, SG::VarHandleBase &hndl, const std::string &doc, const SG::VarHandleType &)
 Declare a new Gaudi property. More...
 
Gaudi::Details::PropertyBase * declareProperty (const std::string &name, SG::VarHandleKeyArray &hndArr, const std::string &doc, const SG::VarHandleKeyArrayType &)
 
Gaudi::Details::PropertyBase * declareProperty (const std::string &name, T &property, const std::string &doc, const SG::NotHandleType &)
 Declare a new Gaudi property. More...
 
Gaudi::Details::PropertyBase * declareProperty (const std::string &name, T &property, const std::string &doc="none")
 Declare a new Gaudi property. More...
 
void updateVHKA (Gaudi::Details::PropertyBase &)
 
MsgStream & msg () const
 
MsgStream & msg (const MSG::Level lvl) const
 
bool msgLvl (const MSG::Level lvl) const
 
virtual float getCorrectedMu (const xAOD::EventInfo &eventInfo, bool includedDataScaleFactor=false)
 Get the corrected average mu of a lumiblock ... More...
 

Static Public Member Functions

static Version_t Class_Version ()
 

Protected Member Functions

virtual bool runLbnOK (Int_t runNbr, Int_t lbn)
 
virtual bool passTriggerBeforePrescale (const TString &trigger) const
 
void renounceArray (SG::VarHandleKeyArray &handlesArray)
 remove all handles from I/O resolution More...
 
std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > renounce (T &h)
 
void extraDeps_update_handler (Gaudi::Details::PropertyBase &ExtraDeps)
 Add StoreName to extra input/output deps as needed. More...
 
Int_t UsePeriodConfig (const TString &configName)
 use a hardcoded period configuration More...
 
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. More...
 
Int_t GetDefaultChannel (Int_t mcRunNumber=-1)
 
void RemapPeriod (Int_t periodNumber1, Int_t periodNumber2)
 Combine two period numbers. More...
 
Double_t GetLumiBlockIntegratedLumi (Int_t runNumber, UInt_t lb)
 get integrated lumi for specific run and lumiblock number . More...
 
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 More...
 
void DisableWarnings (Bool_t in)
 Indicate if warnings should be suppressed. More...
 
void EnableDebugging (Bool_t in)
 Indicate if additional debugging information should be output. More...
 
void PrintInfo (Bool_t in)
 disable info More...
 
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=Default (Throw exception), 1=Subtract lumi from normalizations (i.e. More...
 
Double_t GetUnrepresentedDataFraction (Int_t periodNumber, Int_t channel)
 return the unrepresented data fraction in a given channel . More...
 
Float_t GetUnrepresentedDataWeight (Int_t periodNumber, Int_t channel)
 
Bool_t IsUnrepresentedData (Int_t runNumber, Float_t x, Float_t y=0.)
 
void IgnoreConfigFilePeriods (Bool_t in)
 Should the tool ignore period assignments encoded in config file. More...
 
Int_t GetFirstFoundPeriodNumber (UInt_t runNumber)
 Get the first period number with the data run number contained - assume all periods are disconnected for this to be useful. More...
 
void SetDataScaleFactors (Float_t x, Float_t y=1.)
 Scale the LumiMetaData mu values by this factor. More...
 
void SetMCScaleFactors (Float_t x, Float_t y=1.)
 
Int_t AddConfigFile (const TString &fileName)
 
Int_t AddLumiCalcFile (const TString &fileName, const TString &trigger="None")
 
Int_t AddMetaDataFile (const TString &fileName, const TString &channelBranchName="mc_channel_number")
 
Bool_t RemoveChannel (int chanNum)
 Removes a channel from the inputs ... More...
 
Int_t Initialize ()
 Initialize this class once before the event loop starts If distribution information is provided, it is assumed to be for the standard pileup reweighting. More...
 
Float_t GetCombinedWeight (Int_t periodNumber, Int_t channelNumber, Float_t x, Float_t y=0.)
 
Float_t GetPeriodWeight (Int_t periodNumber, Int_t channelNumber)
 
Float_t GetPrimaryWeight (Int_t periodNumber, Int_t channelNumber, Float_t x)
 
Float_t GetSecondaryWeight (Int_t periodNumber, Int_t channelNumber, Float_t x, Float_t y)
 
Double_t GetMetaData (const TString &metadataName, Int_t channelNumber)
 
TTree * GetMetaDataTree ()
 combines loaded metadata with channel sumsofweights and entry counts More...
 
Int_t GenerateMetaDataFile (const TString &fileName, const TString &channelBranchName="mc_channel_number")
 
Int_t Fill (Int_t runNumber, Int_t channelNumber, Float_t w, Float_t x, Float_t y=0.)
 
Int_t WriteToFile (const TString &filename="")
 
Int_t WriteToFile (TFile *outFile)
 
ULong64_t GetPRWHash (Int_t periodNumber, Int_t channelNumber, Float_t x, Float_t y=0.)
 
Bool_t MakeWeightTree (TString channelNumbers, TString outFile, TString hashBranch="PRWHash", TString weightBranch="PileupWeight")
 
void SetRandomSeed (int seed)
 
int GetRandomSeed ()
 
UInt_t GetRandomRunNumber (Int_t mcRunNumber)
 Gets a random data run number according to the integrated lumi distribution associated to this mcRunNumber. More...
 
UInt_t GetRandomRunNumber (Int_t mcRunNumber, Double_t mu)
 Get random run number according to integrated lumi distribution for the given mu value (uses the binning of the mu histogram) More...
 
Int_t GetRandomPeriodNumber (Int_t mcRunNumber)
 Get random period number from the sub-periods assigned to this run number. More...
 
Int_t Merge (TCollection *coll)
 
std::vector< int > GetPeriodNumbers () const
 
TH1 * GetInputHistogram (Int_t channelNumber, Int_t periodNumber)
 
TH1 * GetPrimaryDistribution (Int_t channelNumber, Int_t periodNumber)
 
TH1 * GetPrimaryTriggerDistribution (const TString &trigger, Int_t periodNumber, long triggerBits)
 
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. More...
 
Double_t GetDataWeight (Int_t runNumber, const TString &trigger)
 
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. More...
 
Double_t GetPrescaleWeight (Int_t runNumber, const TString &trigger)
 
Bool_t IsInitialized ()
 
Int_t AddDistribution (TH1 *hist, Int_t runNumber, Int_t channelNumber)
 
void ResetCountingMode ()
 This method is DEFINITELY EXPERT USE ONLY. More...
 
void SetParentTool (TPileupReweighting *tool)
 
Float_t GetDataScaleFactor () const
 
void SetTriggerBit (const TString &trigger, bool in=true)
 
void ResetTriggerBits ()
 
double GetRunAverageMu (int run)
 
Int_t GetNearestGoodBin (Int_t thisMCRunNumber, Int_t bin)
 
Int_t IsBadBin (Int_t thisMCRunNumber, Int_t bin)
 
std::unique_ptr< TH1 > CloneEmptyHistogram (Int_t runNumber, Int_t channelNumber)
 
void normalizeHistogram (TH1 *histo)
 Normalize histograms. More...
 
void AddDistributionTree (TTree *tree, TFile *file)
 
void CalculatePrescaledLuminosityHistograms (const TString &trigger, int run_dependent=0)
 
std::unique_ptr< CompositeTriggermakeTrigger (const TString &s)
 
void calculateHistograms (CompositeTrigger *trigger, int run_dependent)
 
void PrintPeriods ()
 
std::map< UInt_t, Run > & GetRunMap ()
 
void CopyProperties (const TPileupReweighting *in)
 

Protected Attributes

std::map< TString, bool > m_triggerPassBits
 
TPileupReweightingm_parentTool
 
Bool_t m_SetWarnings
 
Bool_t m_debugging
 
Bool_t m_printInfo
 
Bool_t m_countingMode
 
Int_t m_unrepresentedDataAction
 
Bool_t m_isInitialized
 
Bool_t m_lumiVectorIsLoaded
 
Float_t m_dataScaleFactorX
 
Float_t m_dataScaleFactorY
 
Float_t m_mcScaleFactorX
 
Float_t m_mcScaleFactorY
 
Int_t m_nextPeriodNumber
 
Bool_t m_ignoreFilePeriods
 
TTree * m_metadatatree
 
Double_t m_unrepDataTolerance
 
Bool_t m_doGlobalDataWeight
 
Bool_t m_doPrescaleWeight = false
 
Int_t m_lumicalcRunNumberOffset
 
std::map< TString, std::vector< TString > > m_lumicalcFiles
 map storing the lumicalc file locations - used when building DataPileupWeights More...
 
std::unique_ptr< TH1 > m_emptyHistogram
 the empty histogram used for this weight... More...
 
std::map< TString, std::map< Int_t, Double_t > > m_metadata
 channel metadata map More...
 
std::map< TString, std::unique_ptr< CompositeTrigger > > m_triggerObjs
 
std::list< Periodm_periodList
 List physically holding (owning) period objects. More...
 
std::map< Int_t, Period * > m_periods
 
std::map< UInt_t, Runm_runs
 
std::map< Int_t, Double_t > unrepDataByChannel
 
std::string m_prwFilesPathPrefix
 
std::unique_ptr< TRandom3 > m_random3
 
Bool_t m_ignoreBadChannels
 
Bool_t m_useMultiPeriods = true
 
int m_autoRunStart = 0
 
int m_autoRunEnd = 0
 

Private Types

typedef ServiceHandle< StoreGateSvcStoreGateSvc_t
 

Private Member Functions

Gaudi::Details::PropertyBase & declareGaudiProperty (Gaudi::Property< T > &hndl, const SG::VarHandleKeyType &)
 specialization for handling Gaudi::Property<SG::VarHandleKey> More...
 
Gaudi::Details::PropertyBase & declareGaudiProperty (Gaudi::Property< T > &hndl, const SG::VarHandleKeyArrayType &)
 specialization for handling Gaudi::Property<SG::VarHandleKeyArray> More...
 
Gaudi::Details::PropertyBase & declareGaudiProperty (Gaudi::Property< T > &hndl, const SG::VarHandleType &)
 specialization for handling Gaudi::Property<SG::VarHandleBase> More...
 
Gaudi::Details::PropertyBase & declareGaudiProperty (Gaudi::Property< T > &t, const SG::NotHandleType &)
 specialization for handling everything that's not a Gaudi::Property<SG::VarHandleKey> or a <SG::VarHandleKeyArray> More...
 

Private Attributes

std::string m_configStream
 
bool m_inConfigMode
 
std::unique_ptr< CP::TPileupReweightingm_upTool
 
std::unique_ptr< CP::TPileupReweightingm_downTool
 
double m_upVariation
 
double m_downVariation
 
CP::SystematicVariation m_systUp
 
CP::SystematicVariation m_systDown
 
CP::TPileupReweightingm_activeTool
 
std::vector< std::string > m_prwFiles
 
std::vector< std::string > m_toolLumicalcFiles
 
std::string m_prefix
 
int m_defaultChannel
 
std::string m_usePeriodConfig
 
std::map< int, bool > m_doneConfigs
 
bool m_noWeightsMode
 
bool m_varyRunNumber
 
bool m_useRunDependentPrescaleWeight
 
std::vector< int > m_customPeriods
 Default weight tool in standalone mode. More...
 
std::unique_ptr< IWeightToolm_defaultWeightTool
 
ToolHandle< IWeightToolm_weightTool
 
ToolHandle< IGoodRunsListSelectionToolm_grlTool
 
ToolHandle< Trig::ITrigDecisionToolm_tdt
 
StoreGateSvc_t m_evtStore
 Pointer to StoreGate (event store by default) More...
 
StoreGateSvc_t m_detStore
 Pointer to StoreGate (detector store by default) More...
 
std::vector< SG::VarHandleKeyArray * > m_vhka
 
bool m_varHandleArraysDeclared
 

Detailed Description

Implementation of the PileupReweighting tool.

Author
Will Buttinger

Definition at line 33 of file PileupReweightingTool.h.

Member Typedef Documentation

◆ StoreGateSvc_t

typedef ServiceHandle<StoreGateSvc> AthCommonDataStore< AthCommonMsg< AlgTool > >::StoreGateSvc_t
privateinherited

Definition at line 388 of file AthCommonDataStore.h.

Constructor & Destructor Documentation

◆ PileupReweightingTool()

CP::PileupReweightingTool::PileupReweightingTool ( const std::string &  name)

Constructor for standalone usage.

Definition at line 34 of file PileupReweightingTool.cxx.

35  m_inConfigMode(false),
36  m_upTool(), m_downTool(), m_systUp("PRW_DATASF", 1 ), m_systDown("PRW_DATASF", -1),
37  m_activeTool(this),
38  m_noWeightsMode(false),
39 #ifdef XAOD_STANDALONE
40  m_defaultWeightTool( new McEventWeight( "DefaultWeightTool" ) ),
41 #endif // XAOD_STANDALONE
42  m_weightTool("McEventWeight/myWeightTool"),
43  m_grlTool(""), m_tdt("") {
44 
46 
47 #ifndef XAOD_STANDALONE
48  declareProperty("ConfigOutputStream", m_configStream="", "When creating PRW config files, this is the THistSvc stream it goes into. If blank, it wont write this way");
49 #endif
50 
51  declareProperty("ConfigFiles", m_prwFiles, "List of prw config files"); //array of files
52  declareProperty("ConfigFilesPathPrefix", m_prwFilesPathPrefix="", "Path of additional folder structure in prw config files"); //string prefix
53  declareProperty("LumiCalcFiles", m_toolLumicalcFiles, "List of lumicalc files, in the format '<filename>:<trigger>' .. if no trigger given, 'None' is assumed"); //array of files
54  declareProperty("Prefix",m_prefix="","Prefix to attach to all decorations ... only used in the 'apply' method");
55  declareProperty("UnrepresentedDataAction",m_unrepresentedDataAction=3,"1 = remove unrepresented data, 2 = leave it there, 3 = reassign it to nearest represented bin");
56  declareProperty("UnrepresentedDataThreshold",m_unrepDataTolerance=0.05,"When unrepresented data is above this level, will require the PRW config file to be repaired");
57  declareProperty("UseMultiPeriods",m_useMultiPeriods=true,"If true, will try to treat each mc runNumber in a single mc dataset (channel) as a modelling a distinct period of data taking");
58  declareProperty("UseRunDependentPrescaleWeight",m_useRunDependentPrescaleWeight=false,"If true, prescale weights in the getCombinedWeight method with Trigger string are determined with the specific random run number");
59  declareProperty("DataScaleFactor",m_dataScaleFactorX=1./1.03);
60  declareProperty("UsePeriodConfig",m_usePeriodConfig="auto","Use this period configuration when in config generating mode. Set to 'auto' to auto-detect");
61  declareProperty("IgnoreBadChannels",m_ignoreBadChannels=true,"If true, will ignore channels with too much unrepresented data, printing a warning for them");
62  declareProperty("DataScaleFactorUP",m_upVariation=1./0.99,"Set to a value representing the 'up' fluctuation - will report a PRW_DATASF uncertainty to Systematic Registry");
63  declareProperty("DataScaleFactorDOWN",m_downVariation=1./1.07,"Set to a value representing the 'down' fluctuation - will report a PRW_DATASF uncertainty to Systematic Registry");
64  declareProperty("VaryRandomRunNumber",m_varyRunNumber=false,"If true, then when doing systematic variations, RandomRunNumber will fluctuate as well. Off by default as believed to lead to overestimated uncertainties");
65  declareProperty("PeriodAssignments", m_customPeriods={284500,222222,324300,300000,324300,344495,310000,344496,367384,410000,422633,440613,450000,450360,461002,470000,472553,999999}, "Specify period number assignments to run numbers ranges - this is usually an expert option");
66  declareProperty("GRLTool", m_grlTool, "If you provide a GoodRunsListSelectionTool, any information from lumicalc files will be automatically filtered" );
67  declareProperty("TrigDecisionTool",m_tdt, "When using the getDataWeight method, the TDT will be used to check decisions before prescale. Alternatively do expert()->SetTriggerBit('trigger',0) to flag which triggers are not fired before prescale (assumed triggers are fired if not specified)");
68 
69 #ifdef XAOD_STANDALONE
70  declareProperty( "WeightTool", m_weightTool = m_defaultWeightTool.get(),
71  "The tool to compute the weight in the sumOfWeights" );
72 #else
73  declareProperty( "WeightTool", m_weightTool,
74  "The tool to compute the weight in the sumOfWeights" );
75 #endif
76 
77 #ifndef XAOD_STANDALONE
78  //attached update handler to the outputlevel property, so we can pass changes on to the underlying tool
79  auto props = getProperties();
80  for( Gaudi::Details::PropertyBase* prop : props ) {
81  if( prop->name() != "OutputLevel" ) {
82  continue;
83  }
84  prop->declareUpdateHandler( &PileupReweightingTool::updateHandler, this );
85  break;
86  }
87 #endif
88 }

Member Function Documentation

◆ AddConfigFile()

Int_t TPileupReweighting::AddConfigFile ( const TString &  fileName)
inherited

Definition at line 936 of file TPileupReweighting.cxx.

936  {
937 
938  //open the file and look for config TTrees
939  //recognised TTrees are: ChannelMetaData, MCPileupReweighting, MCCustomReweighting, DataCustomReweighting
940 
941  if(m_isInitialized) {
942  Error("AddConfigFile","You cannot AddConfigFile after initializing the tool. Reorder your code!");
943  throw std::runtime_error("Throwing 5: You cannot AddConfigFile after initializing the tool. Reorder your code!");
944  }
945 
946  TDirectory* origDir = gDirectory;
947  // Load the data ROOT file
948  TFile* rootFile = TFile::Open( fileName, "READ" );
949  if ( rootFile->IsZombie() ) {
950  Error("AddConfigFile","Could not open file: %s",fileName.Data());
951  std::string toThrow = "Throwing 6: Could not open file: "; toThrow += fileName.Data();
952  throw std::runtime_error(toThrow);
953  } else {
954  //try to get the the known TTrees
955  TTree *tmp = (TTree*)rootFile->Get( std::string(m_prwFilesPathPrefix+"MCPileupReweighting").c_str() );
956  if(tmp) {
957  //Info("AddConfigFile","Adding MCPileupReweighting...");
959  m_countingMode=false;
960  }
961  tmp = 0;tmp = (TTree*)rootFile->Get( std::string(m_prwFilesPathPrefix+"MCCustomReweighting").c_str() );
962  if(tmp) {
963  //Info("AddConfigFile","Adding MCCustomReweighting...");
965  m_countingMode=false;
966  }
967  tmp = 0;tmp = (TTree*)rootFile->Get( std::string(m_prwFilesPathPrefix+"DataCustomReweighting").c_str() );
968  if(tmp) {
969  //Info("AddConfigFile","Adding DataCustomReweighting...");
971  m_countingMode=false;
972  }
973  tmp=0; tmp = (TTree*)rootFile->Get( std::string(m_prwFilesPathPrefix+"PileupReweighting/MCPileupReweighting").c_str() ); //allow trees in the PileupReweighting dir instead
974  if(tmp) {
975  //Info("AddConfigFile","Adding MCPileupReweighting...");
977  m_countingMode=false;
978  }
979  tmp = 0;tmp = (TTree*)rootFile->Get( std::string(m_prwFilesPathPrefix+"PileupReweighting/MCCustomReweighting").c_str() );
980  if(tmp) {
981  //Info("AddConfigFile","Adding MCCustomReweighting...");
983  m_countingMode=false;
984  }
985  tmp = 0;tmp = (TTree*)rootFile->Get( std::string(m_prwFilesPathPrefix+"PileupReweighting/DataCustomReweighting").c_str() );
986  if(tmp) {
987  //Info("AddConfigFile","Adding DataCustomReweighting...");
989  m_countingMode=false;
990  }
991  }
992 
993  delete rootFile;
994 
995  // Return to the original ROOT directory
997 
998  return 0;
999 }

◆ AddDistribution()

Int_t TPileupReweighting::AddDistribution ( TH1 *  hist,
Int_t  runNumber,
Int_t  channelNumber 
)
inherited

Definition at line 728 of file TPileupReweighting.cxx.

728  {
729 
730  //NOTE: should probably just ignore histograms with 0 entries
731 
732  if(m_isInitialized) {
733  Error("AddDistribution","You cannot AddDistribution after initializing the tool. Reorder your code!");
734  throw std::runtime_error("Throwing 5: You cannot AddLumiCalcFile after initializing the tool. Reorder your code!");
735  }
736 
737  if(channelNumber>=0 && !m_periods[runNumber]) {
738  Error("AddDistribution","Unrecognised periodNumber: %d .. please use AddPeriod to define a period",runNumber);
739  throw std::runtime_error("Throwing 6: Unrecognised periodNumber. Please use AddPeriod to define a period");
740  }
741 
742  if(!m_useMultiPeriods && runNumber>=0) {
743  //not allowing multi periods in a single channel, so before we go any further, require no periods other than this incoming one to have a hist defined for this channel
744  //the global one can though
745  for(auto& period : m_periods) {
746  if(period.first<0) continue; //global sum period
747  if(period.first==runNumber) continue; //ok to add to this
748  if(period.second->inputHists.find(channelNumber)!=period.second->inputHists.end()) {
749  TString myMsg = TString::Format("Attempt to add distribution for channel %d to period %d, but this channels already has period %d defined.\nThis is indicative of use of incompatible PRW config files, please check your config files for multiple periods/runNumbers for the same channel.",channelNumber,runNumber,period.first);
750  Error("AddDistribution","%s",myMsg.Data());
751  throw std::runtime_error(myMsg.Data());
752  }
753  }
754  }
755 
756 
757  auto& inputHist = (channelNumber<0) ? m_runs[runNumber].inputHists["None"] : m_periods[runNumber]->inputHists[channelNumber];
758 
759  if(!inputHist) {
760  //if no emptyHistogram specified, we will use this histogram as the structure for the empty;
761  if(!m_emptyHistogram) {
762  //check if the input histogram is a TH1D or not. We like TH1D, not yucky TH1F
763  if(strcmp(hist->IsA()->GetName(),"TH1D")==0 || strcmp(hist->IsA()->GetName(),"TH2D")==0) {
764  m_emptyHistogram.reset( dynamic_cast<TH1*>(hist->Clone("default")) );
765  } else {
766  //check dimensionality
767  if(hist->GetDimension()==1) {
768  std::vector<Double_t> binsX;
769  for(int i=0;i<=hist->GetNbinsX();i++) binsX.push_back(hist->GetXaxis()->GetBinLowEdge(i+1));
770  TH1D tmpHist("tmpHist","tmpHist",binsX.size()-1,&binsX[0]);
771  m_emptyHistogram.reset( dynamic_cast<TH1*>(tmpHist.Clone("default")) );
772  } else if(hist->GetDimension()==2) {
773  std::vector<Double_t> binsX;std::vector<Double_t> binsY;
774  for(int i=0;i<=hist->GetNbinsX();i++) binsX.push_back(hist->GetXaxis()->GetBinLowEdge(i+1));
775  for(int i=0;i<=hist->GetNbinsY();i++) binsY.push_back(hist->GetYaxis()->GetBinLowEdge(i+1));
776  TH2D tmpHist("tmpHist","tmpHist",binsX.size()-1,&binsX[0],binsY.size()-1,&binsY[0]);
777  m_emptyHistogram.reset( dynamic_cast<TH1*>(tmpHist.Clone("default")) );
778  } else {
779  Error("AddDistribution","Unknown input histogram dimensionality: %d",hist->GetDimension());
780  throw std::runtime_error("Throwing 98");
781  }
782  }
783  if (m_emptyHistogram)
784  {
785  m_emptyHistogram->Reset();m_emptyHistogram->SetEntries(0);m_emptyHistogram->SetDirectory(0);//clear the histogram
786  }
787  }
788  inputHist = CloneEmptyHistogram(runNumber,channelNumber);
789 
790  }
791 
792 
793  //iterator over bins of histogram, filling the TH1 stored in the data map
794  Double_t numEntries = inputHist->GetEntries();
795 
796  std::unique_ptr<TH1> tmpHist;
797  if(channelNumber<0) {
798  m_runs[runNumber].nominalFromHists = true;
799  //for data we will do an interpolation to build the shape and then scale it to the integral ...
800  tmpHist.reset( static_cast<TH1*>(inputHist->Clone("tmpHist")) );
801  tmpHist->Reset();
802  Int_t bin,binx,biny;
803  for(biny=1; biny<=tmpHist->GetNbinsY(); biny++) {
804  for(binx=1; binx<=tmpHist->GetNbinsX(); binx++) {
805  bin = tmpHist->GetBin(binx,biny);
806  Double_t x = tmpHist->GetXaxis()->GetBinCenter(binx)/m_dataScaleFactorX;
807  Double_t y = tmpHist->GetYaxis()->GetBinCenter(biny)/m_dataScaleFactorY;
808  if(tmpHist->GetDimension()==1){
809  tmpHist->SetBinContent(bin, hist->Interpolate(x));
810  } else {
811  tmpHist->SetBinContent(bin, hist->Interpolate(x,y));
812  }
813  }
814  }
815  tmpHist->Scale( hist->Integral() / tmpHist->Integral() );
816  tmpHist->SetEntries( hist->GetEntries() );
817  hist = tmpHist.get();
818  }
819 
820  Int_t bin,binx,biny;
821  for(biny=1; biny<=hist->GetNbinsY(); biny++) {
822  for(binx=1; binx<=hist->GetNbinsX(); binx++) {
823  bin = hist->GetBin(binx,biny);
824  Double_t value = hist->GetBinContent(bin);
825  Double_t x = hist->GetXaxis()->GetBinCenter(binx);
826  Double_t y = hist->GetYaxis()->GetBinCenter(biny);
827  //shift x,y,z by the MCScaleFactors as appropriate
828  if(channelNumber>=0) {x *= m_mcScaleFactorX; y *= m_mcScaleFactorY;}
829  //data scale factor now dealt with in above interpolation
830  Int_t inBin = inputHist->FindFixBin(x,y);
831  Double_t inValue = inputHist->GetBinContent(inBin);
832  inputHist->SetBinContent(inBin,inValue+value);
833  }
834  }
835 
836  //also keep track of the number of entries
837  //SetBinContent screws with the entry count, so had to record it before the loops above
838  inputHist->SetEntries(numEntries+hist->GetEntries());
839 
840 
841  m_countingMode=false;
842  return 0;
843 
844 }

◆ AddDistributionTree()

void TPileupReweighting::AddDistributionTree ( TTree *  tree,
TFile *  file 
)
protectedinherited

Definition at line 648 of file TPileupReweighting.cxx.

648  {
649 
650  bool isMC=true;
651  //should have the standard structure
652  Int_t channel = 0; UInt_t runNbr = 0;
653  auto pStarts = std::make_unique< std::vector< UInt_t > >();
654  auto pStartsPtr = pStarts.get();
655  auto pEnds = std::make_unique< std::vector< UInt_t > >();
656  auto pEndsPtr = pEnds.get();
657  Char_t histName[150];
658  Char_t customName[150];
659  Bool_t isDefaultForRunNumber(false); bool hasDefaultsBranch=false;
660  if(strcmp(tree->GetName(),"MCPileupReweighting")==0) {strcpy(customName,"pileup");isMC=true;}
661  else {
662  if(tree->SetBranchAddress("CustomName",&customName)!=0) {
663  Error("AddDistributionTree","Could not find CustomName branch in TTree");throw std::runtime_error("Throwing 18");
664  }
665  }
666  if(strcmp(tree->GetName(),"DataCustomReweighting")==0) {channel=-1;isMC=false;}
667  else {
668  if(tree->SetBranchAddress("Channel",&channel)!=0) {
669  Error("AddDistributionTree","Could not find Channel branch in TTree");throw std::runtime_error("Throwing 18");
670  }
671  }
672  if(tree->SetBranchAddress("RunNumber",&runNbr)!=0) {
673  Error("AddDistributionTree","Could not find RunNumber branch in TTree");throw std::runtime_error("Throwing 18");
674  }
675  if(isMC) {
676  if(tree->SetBranchAddress("PeriodStarts",&pStartsPtr)!=0) {
677  Error("AddDistributionTree","Could not find PeriodStarts branch in TTree");throw std::runtime_error("Throwing 18");
678  }
679  if(tree->SetBranchAddress("PeriodEnds",&pEndsPtr)!=0) {
680  Error("AddDistributionTree","Could not find PeriodEnds branch in TTree");throw std::runtime_error("Throwing 18");
681  }
682  if(tree->FindBranch("IsDefaultForRunNumber")!=0) {
683  tree->SetBranchAddress("IsDefaultForRunNumber",&isDefaultForRunNumber);
684  hasDefaultsBranch=true;
685  }
686  }
687 
688  if(tree->SetBranchAddress("HistName",&histName)!=0) {
689  Error("AddDistributionTree","Could not find HistName branch in TTree");throw std::runtime_error("Throwing 18");
690  }
691  long n = tree->GetEntries();
692  std::map<TString,bool> loadedHistos; //avoid double-loading from this file
693  for(long i=0;i<n;i++) {
694  tree->GetEntry(i);
695  TString sHistName(histName);
696  TString weightName(customName);
697  const auto &[ptr, inserted] = loadedHistos.try_emplace(sHistName, true);
698 
699  if(inserted) {
700  if(( (!m_ignoreFilePeriods) || m_periods.find(runNbr)==m_periods.end()) && isMC) {
701  //if ignoring file periods, will still add the period if it doesnt exist!
702  for(unsigned int j=0;j<pStarts->size();j++) {
703  unsigned int start = pStarts->at(j);
704  unsigned int end = pEnds->at(j);
705  AddPeriod(runNbr,start,end);
706  }
707  }
708  //load the histogram
709  TH1 *histo = (TH1*)file->Get( sHistName );
710  if(!histo) histo = (TH1*)file->Get( TString::Format("%sPileupReweighting/%s",m_prwFilesPathPrefix.c_str(),sHistName.Data()) ); //try from subdir
711  if(!histo) {
712  Error("AddDistributionTree","Unable to find the histogram %s in the File %s",sHistName.Data(),file->GetName());
713  throw std::runtime_error("Throwing 21");
714  }
715  //add it to the histograms
716  AddDistribution(histo, runNbr, channel);
717  //we also add it to the global count, if this isn't data
719  }
720  if(hasDefaultsBranch) {
721  if(isDefaultForRunNumber && m_periods.find(runNbr)!=m_periods.end()) m_periods[runNbr]->defaultChannel=channel;
722  }
723  }
724 
725 }

◆ AddLumiCalcFile()

Int_t TPileupReweighting::AddLumiCalcFile ( const TString &  fileName,
const TString &  trigger = "None" 
)
inherited

Definition at line 847 of file TPileupReweighting.cxx.

847  {
848 
849  if(m_isInitialized) {
850  Error("AddLumiCalcFile","You cannot AddLumiCalcFile after initializing the tool. Reorder your code!");
851  throw std::runtime_error("Throwing 5: You cannot AddLumiCalcFile after initializing the tool. Reorder your code!");
852  }
853  TDirectory* origDir = gDirectory;
854  // Load the data ROOT file
855  TFile* rootFile = TFile::Open( fileName, "READ" );
856  if ( rootFile->IsZombie() ) {
857  Error("AddConfigFile","Could not open file: %s",fileName.Data());
858  std::string toThrow = "Throwing 6: Could not open file: "; toThrow += fileName.Data();
859  throw std::runtime_error(toThrow);
860  } else {
861  //try to get the the known TTrees
862  TTree *tmp = (TTree*)rootFile->Get( "LumiMetaData" );
863  if(tmp) {
864  m_lumicalcFiles[trigger].push_back(fileName);
865  if(trigger=="None") {
866  if (m_printInfo) {
867  Info("AddLumiCalcFile","Adding LumiMetaData (scale factor=%f)...",m_dataScaleFactorX);
868  }
869  //structure expected is as given by iLumiCalc:
870  // RunNbr, AvergeInteractionPerXing, IntLumi
871  UInt_t runNbr=0;Float_t intLumi=0;UInt_t lbn=0;TBranch *b_runNbr=0;TBranch *b_intLumi=0;TBranch *b_lbn=0;
872  Float_t mu=0.; TBranch *b_mu=0;
873  if(tmp->SetBranchAddress("RunNbr",&runNbr,&b_runNbr)!=0) {
874  Error("AddLumiCalcFile","Could not find RunNbr branch in Data TTree");throw std::runtime_error("Could not find RunNbr branch in Data TTree");
875  }
876  if(tmp->SetBranchAddress("AvergeInteractionPerXing",&mu,&b_mu)!=0) {
877  Error("AddLumiCalcFile","Could not find AvergeInteractionPerXing branch in Data TTree");throw std::runtime_error("Could not find AvergeInteractionPerXing branch in Data TTree");
878  }
879  if(tmp->SetBranchAddress("IntLumi",&intLumi,&b_intLumi)!=0) {
880  Error("AddLumiCalcFile","Could not find IntLumi branch in Data TTree");throw std::runtime_error("Could not find IntLumi branch in Data TTree");
881  }
882  if(tmp->SetBranchAddress("LBStart",&lbn,&b_lbn)!=0) {
883  Error("AddLumiCalcFile","Could not find LBStart branch in Data TTree");throw std::runtime_error("Could not find LBStart branch in Data TTree");
884  }
885  long nEntries = tmp->GetEntries();
886 
887  for(long i=0;i<nEntries;i++) {
888  b_runNbr->GetEntry(i);b_intLumi->GetEntry(i);b_mu->GetEntry(i);
889  runNbr += m_lumicalcRunNumberOffset;
890  //save the lumi by run and lbn
891  b_lbn->GetEntry(i);
892 
893  //before going any further, check the runnbr and lbn are ok
894  if(!m_parentTool->runLbnOK(runNbr,lbn)) continue;
895 
896  Run& r = m_runs[runNbr];
897  if(trigger=="None") {
898  r.lumiByLbn[lbn].first += intLumi;
899  r.lumiByLbn[lbn].second = mu;
900  if(r.nominalFromHists) continue; //don't fill runs that we already filled from hists ... only happens for the 'None' trigger
901  }
902 
903  //rescale the mu value ... do this *after* having stored the mu value in the lumiByLbn map
905  //fill into input data histograms
906  //check if we need to create an empty histogram
907 
908  std::unique_ptr<TH1>& histptr = r.inputHists[trigger];
909  if (!histptr) {
910  histptr = CloneEmptyHistogram(runNbr,-1);
911  }
912  histptr->Fill(mu,intLumi);
913  }
914  m_countingMode=false;
916  } else {
917  if (m_printInfo) {
918  Info("AddLumiCalcFile","Adding LumiMetaData for DataWeight (trigger=%s) (scale factor=%f)...",trigger.Data(),m_dataScaleFactorX);
919  }
920  }
921 
922  } else {
923  Error("AddLumiCalcFile","No LumiMetaData found in file %s. not a LumiCalcFile?", fileName.Data());
924  throw std::runtime_error("No LumiMetaData found in file, not a LumiCalcFile?");
925  }
926  }
927 
928  delete rootFile;
929 
930  // Return to the original ROOT directory
932 
933  return 0;
934 }

◆ AddMetaDataFile()

Int_t TPileupReweighting::AddMetaDataFile ( const TString &  fileName,
const TString &  channelBranchName = "mc_channel_number" 
)
inherited

Definition at line 506 of file TPileupReweighting.cxx.

506  {
507  TDirectory* origDir = gDirectory;
508  TTree* tmp = 0;
509  TFile* rootFile = 0;
510  if(fileName.EndsWith(".root")) {
511  //looks for ChannelMetaData ttree
512  // Load the data ROOT file
513  rootFile = TFile::Open( fileName, "READ" );
514  if ( rootFile->IsZombie() ) {
515  Error("AddMetaDataFile","Could not open file: %s",fileName.Data());
516  throw std::runtime_error("Throwing 6");
517  } else {
518  //try to get the the known TTrees
519  tmp = (TTree*)rootFile->Get( "ChannelMetaData" );
520  if(!tmp) {
521  Error("AddMetaDataFile","%s is not a valid metadata file. Should have a ChannelMetaData TTree",fileName.Data());
522  throw std::runtime_error("Throwing 7");
523  }
524  rootFile->Close();
525  }
526  delete rootFile;
527  } else {
528  //try to make the TTree by reading the file
529  tmp = new TTree("ChannelMetaData","ChannelMetaData");
530  tmp->ReadFile(fileName);
531  }
532  Int_t chanNum;
533  std::map<TString, Double_t> data;
534  TObjArray *leaves = tmp->GetListOfLeaves();
535  if(leaves==0) {Error("AddMetaDataFile","No leaves"); return -1; }
536  for(Int_t i=0;i<leaves->GetEntries();++i) {
537  TLeaf *leaf = (TLeaf *)leaves->At(i);
538  if(leaf) {
539  TBranch *branch = leaf->GetBranch();
540  if(strcmp(branch->GetName(),channelBranchName)==0) {
541  //this is the channel branch
542  if(strcmp(leaf->GetTypeName(),"Int_t")!=0) {
543  Error("AddMetaDataFile","Channel Branch must be type Int_t");
544  throw std::runtime_error("Throwing 7");
545  }
546  branch->SetAddress(&chanNum);
547  } else if(strcmp(leaf->GetTypeName(),"Double_t")!=0) {
548  Warning("AddMetaDataFile","Cannot read non-double branch: %s",branch->GetName());
549  } else {
550  branch->SetAddress(&(data[branch->GetName()]));
551  }
552  }
553  }
554  //loop over tree entries and read in the values
555  for(Int_t i=0;i<tmp->GetEntries();++i) {
556  tmp->GetEntry(i);
557  for(std::map<TString, Double_t>::iterator it = data.begin();it!=data.end();++it) {
558  if(m_metadata.find(it->first)!=m_metadata.end()&&m_metadata[it->first].find(chanNum)!=m_metadata[it->first].end() && m_metadata[it->first][chanNum]!=it->second) {
559  Warning("AddMetaDataFile", "Overriding metadata [%s,%d]. %f becomes %f",(it->first).Data(),chanNum,m_metadata[it->first][chanNum],it->second);
560  }
561  m_metadata[it->first][chanNum] = it->second;
562  }
563  }
564 
565  delete tmp;
566  if(rootFile) { rootFile->Close();delete rootFile;}
567 
568  // Return to the original ROOT directory
570 
571  return 0;
572 }

◆ AddPeriod()

virtual Int_t CP::PileupReweightingTool::AddPeriod ( Int_t  periodNumber,
UInt_t  start,
UInt_t  end 
)
inlinevirtual

use these methods when generating config files

Implements CP::IPileupReweightingTool.

Definition at line 59 of file PileupReweightingTool.h.

59 { return m_activeTool->AddPeriod(periodNumber, start, end); }

◆ affectingSystematics()

CP::SystematicSet CP::PileupReweightingTool::affectingSystematics ( ) const
virtual

the list of all systematics this tool can be affected by

Implements CP::IReentrantSystematicsTool.

Definition at line 119 of file PileupReweightingTool.cxx.

119  {
121  if(m_upVariation) result.insert( m_systUp );
122  if(m_downVariation) result.insert( m_systDown );
123  return result;
124 }

◆ apply()

StatusCode CP::PileupReweightingTool::apply ( const xAOD::EventInfo eventInfo,
bool  mu_dependent 
)
virtual

Decorates with: MC: PileupWeight (CombinedWeight[*UnrepresentedDataWeight if action=2]), RandomRunNumber, RandomLumiBlockNumber Data: corrected_averageInteractionsPerCrossing mu_dependent says if the mu_dependency should be used for random run numbers or the data weights.

You will get random run numbers of 0 for events with zero pileup weight

Implements CP::IPileupReweightingTool.

Definition at line 451 of file PileupReweightingTool.cxx.

451  {
452 
453  if(m_inConfigMode) {
454  fill( eventInfo );
455  return StatusCode::SUCCESS;
456  }
457 
458  SG::Decorator<float> corrAvgIntPerXingDec(m_prefix+"corrected_averageInteractionsPerCrossing");
460  if(!corrAvgIntPerXingDec.isAvailable(eventInfo))
461  corrAvgIntPerXingDec(eventInfo) = getCorrectedAverageInteractionsPerCrossing(eventInfo,false);
462  return StatusCode::SUCCESS;
463  }
464 
465  //just copy the value over for MC
466  if(!corrAvgIntPerXingDec.isAvailable(eventInfo))
467  corrAvgIntPerXingDec(eventInfo) = eventInfo.averageInteractionsPerCrossing();
468 
469  //decorate with random run number etc
470  SG::Decorator<unsigned int> rrnDec(m_prefix+"RandomRunNumber");
471  SG::ConstAccessor<unsigned int> rrnAcc(rrnDec.auxid());
472  if(!rrnDec.isAvailable(eventInfo)){
473  unsigned int rrn = getRandomRunNumber( eventInfo, mu_dependent );
474  rrnDec(eventInfo) = (rrn==0) ? getRandomRunNumber(eventInfo, false) : rrn;
475  }
476  SG::Decorator<unsigned int> rlbnDec(m_prefix+"RandomLumiBlockNumber");
477  SG::Decorator<unsigned int> rlbnAcc(rlbnDec.auxid());
478  if(!rlbnDec.isAvailable(eventInfo))
479  rlbnDec(eventInfo) = (rrnAcc(eventInfo)==0) ? 0 : /*m_tool->*/GetRandomLumiBlockNumber( rrnAcc(eventInfo) );
480  SG::Decorator<ULong64_t> prwHashDec(m_prefix+"PRWHash");
481  if(!prwHashDec.isAvailable(eventInfo))
482  prwHashDec(eventInfo) = getPRWHash( eventInfo );
483 
484  //decorate with standard PileupWeight
485  SG::Decorator<float> puWeightDec(m_prefix+"PileupWeight");
486  SG::ConstAccessor<float> puWeightAcc(puWeightDec.auxid());
487  if(!m_noWeightsMode && !puWeightDec.isAvailable(eventInfo))
488  puWeightDec(eventInfo) = getCombinedWeight(eventInfo, true);
489 
490  ATH_MSG_VERBOSE("PileupWeight = " << puWeightAcc(eventInfo) << " RandomRunNumber = " << rrnAcc(eventInfo) << " RandomLumiBlockNumber = " << rlbnAcc(eventInfo));
491 
492  return StatusCode::SUCCESS;
493 }

◆ applySystematicVariation()

StatusCode CP::PileupReweightingTool::applySystematicVariation ( const CP::SystematicSet systConfig)
virtual

effects: configure this tool for the given list of systematic variations.

any requested systematics that are not affecting this tool will be silently ignored (unless they cause other errors). failures: systematic unknown failures: requesting multiple variations on the same systematic (e.g. up & down) failures: requesting an unsupported variation on an otherwise supported systematic (e.g. a 2 sigma variation and the tool only supports 1 sigma variations) failures: unsupported combination of supported systematic failures: other tool specific errors

Implements CP::ISystematicsTool.

Definition at line 130 of file PileupReweightingTool.cxx.

130  {
131  if(systConfig.find( m_systUp ) != systConfig.end() && systConfig.find( m_systDown ) != systConfig.end()) {
132  ATH_MSG_ERROR("Errr... what the!? You're trying to do both PRW_DATASF directions at the same time!!!??");
133  return StatusCode::FAILURE;
134  }
135  if(systConfig.find( m_systUp ) != systConfig.end()) {
136  if(!m_upTool) { ATH_MSG_ERROR("Requested up variation of PRW_DATASF, but not configured to do this :-("); return StatusCode::FAILURE; }
137  m_activeTool = m_upTool.get();
138  }
139  else if(systConfig.find( m_systDown ) != systConfig.end() ) {
140  if(!m_downTool) { ATH_MSG_ERROR("Requested down variation of PRW_DATASF, but not configured to do this :-("); return StatusCode::FAILURE; }
141  m_activeTool = m_downTool.get();
142  }
143  else m_activeTool = this;
144  return StatusCode::SUCCESS;
145 }

◆ calculateHistograms()

void TPileupReweighting::calculateHistograms ( CompositeTrigger trigger,
int  run_dependent 
)
protectedinherited

Definition at line 2109 of file TPileupReweighting.cxx.

2109  {
2110  TH1* unprescaledLumi = 0;
2111  if(runDependentRun) {
2112  unprescaledLumi = m_triggerObjs["None"]->triggerHists[-runDependentRun][0].get();
2113  }
2114  bool fillUnprescaledLumi = (unprescaledLumi==0); //only fill the unprescaled histogram once ... so if it already exists, it must have already been filled
2115 
2116  //now we need the trigger bits for this trigger for this event
2117  long tbits = t->getBits(this);
2118  //1. Open all the lumicalc files
2119  //2. For each entry in the 'None' lumicalc file, lookup the run and lb in the subTriggers, and get the prescales (if not found, assume trigger not in, prescale=infinity)
2120  //3. perform calculation of lumi as: Lumi*(1 - Prod_triggers(1-1/prescale)) .. sum this up into the output histogram
2121  // Note: Put each lumi into the period that contains the run ( use )
2122 
2123  TDirectory* origDir = gDirectory;
2124 
2125  std::map<TString, std::map<Int_t, std::map<Int_t, Float_t> > > prescaleByRunAndLbn;
2126 
2127  //Load the prescales for each lumicalc subTrigger
2128  for(std::vector<TString>::iterator it = t->subTriggers.begin();it!=t->subTriggers.end();++it) {
2129  //Info("aa","subtrigger %s Int lumi is %f", it->Data(), m_triggerPrimaryDistributions[*it][1]->Integral());
2130  for(auto& fileName : m_lumicalcFiles[*it]) {
2131  //if the file is also in the "None" list, then we will now the prescale must be 0
2132  //it seems that in these no-trigger files used for unprescaled lumi the prescales are all set to -1
2133  bool isUnprescaled = (std::find(m_lumicalcFiles["None"].begin(),m_lumicalcFiles["None"].end(),fileName)!=m_lumicalcFiles["None"].end());
2134 
2135  TFile* rootFile = TFile::Open( fileName, "READ" );
2136  if ( rootFile->IsZombie() ) {
2137  Error("CalculatePrescaledLuminosityHistograms","Could not open file: %s",fileName.Data());
2138  std::string toThrow = "Throwing 6: Could not open file: "; toThrow += fileName.Data();
2139  throw std::runtime_error(toThrow);
2140  } else {
2141  //try to get the the known TTrees
2142  TTree *tmp = (TTree*)rootFile->Get( "LumiMetaData" );
2143  if(tmp) {
2144  //structure expected is as given by iLumiCalc:
2145  // RunNbr, AvergeInteractionPerXing, IntLumi
2146  UInt_t runNbr=0;Float_t ps1=0;Float_t ps2=0; Float_t ps3=0;UInt_t lbn=0;TBranch *b_runNbr=0;TBranch *b_L1Presc=0;TBranch *b_L2Presc=0;TBranch *b_L3Presc=0;TBranch *b_lbn=0;
2147  if(tmp->SetBranchAddress("RunNbr",&runNbr,&b_runNbr)!=0) {
2148  Error("CalculatePrescaledLuminosityHistograms","Could not find RunNbr branch in Data TTree");throw std::runtime_error("Could not find RunNbr branch in Data TTree");
2149  }
2150  if(tmp->SetBranchAddress("L1Presc",&ps1,&b_L1Presc)!=0) {
2151  Error("CalculatePrescaledLuminosityHistograms","Could not find L1Presc branch in Data TTree");throw std::runtime_error("Could not find L1Presc branch in Data TTree");
2152  }
2153  if(tmp->SetBranchAddress("L2Presc",&ps2,&b_L2Presc)!=0) {
2154  Error("CalculatePrescaledLuminosityHistograms","Could not find L2Presc branch in Data TTree");throw std::runtime_error("Could not find L2Presc branch in Data TTree");
2155  }
2156  if(tmp->SetBranchAddress("L3Presc",&ps3,&b_L3Presc)!=0) {
2157  Error("CalculatePrescaledLuminosityHistograms","Could not find L3Presc branch in Data TTree");throw std::runtime_error("Could not find L3Presc branch in Data TTree");
2158  }
2159  if(tmp->SetBranchAddress("LBStart",&lbn,&b_lbn)!=0) {
2160  Error("CalculatePrescaledLuminosityHistograms","Could not find LBStart branch in Data TTree");throw std::runtime_error("Could not find LBStart branch in Data TTree");
2161  }
2162  long nEntries = tmp->GetEntries();
2163  for(long i=0;i<nEntries;i++) {
2164  b_runNbr->GetEntry(i);b_L1Presc->GetEntry(i);b_L2Presc->GetEntry(i);b_L3Presc->GetEntry(i);b_lbn->GetEntry(i);
2165  runNbr += m_lumicalcRunNumberOffset;
2166  if(runDependentRun && int(runNbr)!=runDependentRun) continue; //only use the given run with doing calculation run-dependently
2167  //save the prescale by run and lbn
2168  //if(runNbr==215643)
2169  if(m_debugging && m_printInfo) Info("...","prescale in [%d,%d] = %f %f %f", runNbr,lbn,ps1,ps2,ps3);
2170  if(ps1>0&&ps2>0&&ps3>0) prescaleByRunAndLbn[*it][runNbr][lbn] = ps1*ps2*ps3;
2171  else if(isUnprescaled) prescaleByRunAndLbn[*it][runNbr][lbn] = 1; //special case where the trigger is an unprescaled one and user is reusing the unprescaled lumicalc
2172  }
2173  }
2174  rootFile->Close();
2175  }
2176  delete rootFile;
2177  } //end of loop over lumicalc files for this trigger
2178  }
2179 
2180  for(auto& fileName : m_lumicalcFiles["None"]) {
2181  // Load the data ROOT file for the 'None' lumicalc file
2182  TFile* rootFile = TFile::Open( fileName, "READ" );
2183  if ( rootFile->IsZombie() ) {
2184  Error("CalculatePrescaledLuminosityHistograms","Could not open file: %s",fileName.Data());
2185  std::string toThrow = "Throwing 6: Could not open file: "; toThrow += fileName.Data();
2186  throw std::runtime_error(toThrow);
2187  } else {
2188  //try to get the the known TTrees
2189  TTree *tmp = (TTree*)rootFile->Get( "LumiMetaData" );
2190  if(tmp) {
2191  //structure expected is as given by iLumiCalc:
2192  // RunNbr, AvergeInteractionPerXing, IntLumi
2193  UInt_t runNbr=0;Float_t intLumi=0;UInt_t lbn=0;TBranch *b_runNbr=0;TBranch *b_intLumi=0;TBranch *b_lbn=0;
2194  Float_t mu=0.; TBranch *b_mu=0;
2195  if(tmp->SetBranchAddress("RunNbr",&runNbr,&b_runNbr)!=0) {
2196  Error("CalculatePrescaledLuminosityHistograms","Could not find RunNbr branch in Data TTree");throw std::runtime_error("Could not find RunNbr branch in Data TTree");
2197  }
2198  if(tmp->SetBranchAddress("AvergeInteractionPerXing",&mu,&b_mu)!=0) {
2199  Error("CalculatePrescaledLuminosityHistograms","Could not find AvergeInteractionPerXing branch in Data TTree");throw std::runtime_error("Could not find AvergeInteractionPerXing branch in Data TTree");
2200  }
2201  if(tmp->SetBranchAddress("IntLumi",&intLumi,&b_intLumi)!=0) {
2202  Error("CalculatePrescaledLuminosityHistograms","Could not find IntLumi branch in Data TTree");throw std::runtime_error("Could not find IntLumi branch in Data TTree");
2203  }
2204  if(tmp->SetBranchAddress("LBStart",&lbn,&b_lbn)!=0) {
2205  Error("CalculatePrescaledLuminosityHistograms","Could not find LBStart branch in Data TTree");throw std::runtime_error("Could not find LBStart branch in Data TTree");
2206  }
2207  long nEntries = tmp->GetEntries();
2208  //this loop ends up calling the triggerBeforePrescale method each time, but this should hopefully stop once the loading is done
2209  for(long i=0;i<nEntries;i++) {
2210  b_runNbr->GetEntry(i);b_intLumi->GetEntry(i);b_mu->GetEntry(i);
2211  b_lbn->GetEntry(i);
2212 
2213  runNbr += m_lumicalcRunNumberOffset;
2214  if(runDependentRun && int(runNbr)!=runDependentRun) continue; //only use the given run with doing calculation run-dependently
2215  //for each subtrigger, lookup prescale, and calculate pFactor
2216 
2217  double pFactor = t->eval(prescaleByRunAndLbn,runNbr,lbn,this);
2218 
2219  //Info("...","prescale in [%d,%d] = %f", runNbr,lbn,1./pFactor);
2220 
2221  int bin = m_emptyHistogram->FindFixBin(mu*m_dataScaleFactorX);
2222 
2223  //add into all periods that contain this runNbr
2224  bool firstFill=false;
2225  for(auto p : m_periods) {
2226  if(p.first != p.second->id) continue; //skips remappings
2227  if(!p.second->contains(runNbr)) continue;
2228  if(runDependentRun && firstFill) continue; //only fill runDependentRun once, since they aren't kept in the period they go in their own run-indexed histogram
2229 
2230  int idx = (runDependentRun) ? -runDependentRun : p.second->id; //use negative runNumber to avoid clash with periodID
2231 
2232 
2233  auto& triggerHists = t->triggerHists[idx];
2234  std::unique_ptr<TH1>& histptr = triggerHists[tbits];
2235  if(!histptr) {
2236  histptr = CloneEmptyHistogram(p.first,-1);
2237  if(m_debugging && m_printInfo) Info("CalculatePrescaledLuminosityHistograms","Created Data Weight Histogram for [%s,%d,%d,%ld]",t->val.Data(),p.first,idx,tbits);
2238  }
2239  //check if we were about to fill a bad bin ... if we are, we either skipp the fill (unrep action=1) or redirect (unrep action=3)
2240  if( (m_unrepresentedDataAction==1) && p.second->inputBinRedirect[bin]!=bin) { } //do nothing
2241  else if( m_unrepresentedDataAction==3 ) {histptr->Fill(triggerHists[tbits]->GetBinCenter(p.second->inputBinRedirect[bin]), intLumi*pFactor);}
2242  else triggerHists[tbits]->Fill(mu*m_dataScaleFactorX,intLumi*pFactor);
2243 
2244 
2245  if(runDependentRun && fillUnprescaledLumi) {
2246  //need to fill unprescaled lumi histogram for this particular run ...
2247  if(unprescaledLumi==0) {
2248  m_triggerObjs["None"]->triggerHists[-runDependentRun][0] = CloneEmptyHistogram(p.first,-1);
2249  unprescaledLumi = m_triggerObjs["None"]->triggerHists[-runDependentRun][0].get();
2250  }
2251  if( (m_unrepresentedDataAction==1) && p.second->inputBinRedirect[bin]!=bin) { } //do nothing
2252  else if( m_unrepresentedDataAction==3 ) {unprescaledLumi->Fill(unprescaledLumi->GetBinCenter(p.second->inputBinRedirect[bin]), intLumi);}
2253  else unprescaledLumi->Fill(mu*m_dataScaleFactorX,intLumi);
2254  }
2255 
2256  firstFill=true;
2257 
2258  }
2259  }
2260  rootFile->Close();
2261  }
2262  }
2263  delete rootFile;
2264  } //end loop over unprescaled lumicalc files
2265 
2266 
2267  //Info("aa","Int lumi is %f", m_triggerPrimaryDistributions[trigger][1]->Integral());
2268 
2269 
2270 
2271  // Return to the original ROOT directory
2272  gDirectory = origDir;
2273 
2274 
2275 }

◆ CalculatePrescaledLuminosityHistograms()

void TPileupReweighting::CalculatePrescaledLuminosityHistograms ( const TString &  trigger,
int  run_dependent = 0 
)
protectedinherited

Definition at line 2086 of file TPileupReweighting.cxx.

2086  {
2087  //check if this is a composite trigger (user has provided OR of triggers that are passed before prescale)
2088 
2089  TString triggerCopy = trigger; triggerCopy.ReplaceAll(" ",""); triggerCopy.ReplaceAll("&&","&");triggerCopy.ReplaceAll("||","|");
2090  auto t = makeTrigger(triggerCopy);
2091  if( ! t ) {
2092  Error("GetDataWeight","Error parsing composite trigger set: %s",trigger.Data());
2093  throw std::runtime_error("Could not parse composite trigger");
2094  }
2095 
2096  std::vector<TString> subTriggers;
2097 
2098  t->getTriggers(subTriggers); //fills the vector
2099 
2100  t->subTriggers = subTriggers; //cache the vector of triggers
2101 
2102  calculateHistograms(t.get(),runDependentRun);
2103 
2104  //save trigger object
2105  m_triggerObjs[trigger] = std::move( t );
2106 
2107 }

◆ Class_Version()

static Version_t CP::PileupReweightingTool::Class_Version ( )
inlinestatic

Definition at line 177 of file PileupReweightingTool.h.

177 { return 0; }

◆ CloneEmptyHistogram()

std::unique_ptr< TH1 > TPileupReweighting::CloneEmptyHistogram ( Int_t  runNumber,
Int_t  channelNumber 
)
protectedinherited

Definition at line 435 of file TPileupReweighting.cxx.

435  {
436 
437  TString s("pileup");
438  if(channelNumber>=0) {
439  s += "_chan"; s += channelNumber;
440  } else {
441  s += "_data";
442  }
443  s+="_run"; s+= runNumber;
444  //get the empty histogram
445  if(!m_emptyHistogram) {
446  Error("CloneEmptyHistogram","There is no binning info - use SetBinning/SetUniformBinning or load a prw config file (This usually means you need to call AddConfigFile BEFORE AddLumiCalcFile)");
447  throw std::runtime_error("Throwing 47: There is no binning info - use SetBinning/SetUniformBinning or load a prw config file (This usually means you need to call AddConfigFile BEFORE AddLumiCalcFile)");
448  }
449 
450  std::unique_ptr< TH1 > out( dynamic_cast<TH1*>(m_emptyHistogram->Clone(s)) );
451  if (out) {
452  out->SetTitle(s);
453  out->SetDirectory(0); //take ownership
454  out->SetEntries(0);
455  }
456  return out;
457 
458 }

◆ CopyProperties()

void CP::TPileupReweighting::CopyProperties ( const TPileupReweighting in)
inlineinherited

Definition at line 473 of file TPileupReweighting.h.

473  {
474  m_prwFilesPathPrefix = in->m_prwFilesPathPrefix;
475  m_ignoreBadChannels = in->m_ignoreBadChannels;
476  m_unrepresentedDataAction = in->m_unrepresentedDataAction;
477  m_unrepDataTolerance= in->m_unrepDataTolerance;
478  }

◆ declareGaudiProperty() [1/4]

Gaudi::Details::PropertyBase& AthCommonDataStore< AthCommonMsg< AlgTool > >::declareGaudiProperty ( Gaudi::Property< T > &  hndl,
const SG::VarHandleKeyArrayType  
)
inlineprivateinherited

specialization for handling Gaudi::Property<SG::VarHandleKeyArray>

Definition at line 170 of file AthCommonDataStore.h.

172  {
173  return *AthCommonDataStore<PBASE>::declareProperty(hndl.name(),
174  hndl.value(),
175  hndl.documentation());
176 
177  }

◆ declareGaudiProperty() [2/4]

Gaudi::Details::PropertyBase& AthCommonDataStore< AthCommonMsg< AlgTool > >::declareGaudiProperty ( Gaudi::Property< T > &  hndl,
const SG::VarHandleKeyType  
)
inlineprivateinherited

specialization for handling Gaudi::Property<SG::VarHandleKey>

Definition at line 156 of file AthCommonDataStore.h.

158  {
159  return *AthCommonDataStore<PBASE>::declareProperty(hndl.name(),
160  hndl.value(),
161  hndl.documentation());
162 
163  }

◆ declareGaudiProperty() [3/4]

Gaudi::Details::PropertyBase& AthCommonDataStore< AthCommonMsg< AlgTool > >::declareGaudiProperty ( Gaudi::Property< T > &  hndl,
const SG::VarHandleType  
)
inlineprivateinherited

specialization for handling Gaudi::Property<SG::VarHandleBase>

Definition at line 184 of file AthCommonDataStore.h.

186  {
187  return *AthCommonDataStore<PBASE>::declareProperty(hndl.name(),
188  hndl.value(),
189  hndl.documentation());
190  }

◆ declareGaudiProperty() [4/4]

Gaudi::Details::PropertyBase& AthCommonDataStore< AthCommonMsg< AlgTool > >::declareGaudiProperty ( Gaudi::Property< T > &  t,
const SG::NotHandleType  
)
inlineprivateinherited

specialization for handling everything that's not a Gaudi::Property<SG::VarHandleKey> or a <SG::VarHandleKeyArray>

Definition at line 199 of file AthCommonDataStore.h.

200  {
201  return PBASE::declareProperty(t);
202  }

◆ declareProperty() [1/6]

Gaudi::Details::PropertyBase* AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty ( const std::string &  name,
SG::VarHandleBase hndl,
const std::string &  doc,
const SG::VarHandleType  
)
inlineinherited

Declare a new Gaudi property.

Parameters
nameName of the property.
hndlObject holding the property value.
docDocumentation string for the property.

This is the version for types that derive from SG::VarHandleBase. The property value object is put on the input and output lists as appropriate; then we forward to the base class.

Definition at line 245 of file AthCommonDataStore.h.

249  {
250  this->declare(hndl.vhKey());
251  hndl.vhKey().setOwner(this);
252 
253  return PBASE::declareProperty(name,hndl,doc);
254  }

◆ declareProperty() [2/6]

Gaudi::Details::PropertyBase* AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty ( const std::string &  name,
SG::VarHandleKey hndl,
const std::string &  doc,
const SG::VarHandleKeyType  
)
inlineinherited

Declare a new Gaudi property.

Parameters
nameName of the property.
hndlObject holding the property value.
docDocumentation string for the property.

This is the version for types that derive from SG::VarHandleKey. The property value object is put on the input and output lists as appropriate; then we forward to the base class.

Definition at line 221 of file AthCommonDataStore.h.

225  {
226  this->declare(hndl);
227  hndl.setOwner(this);
228 
229  return PBASE::declareProperty(name,hndl,doc);
230  }

◆ declareProperty() [3/6]

Gaudi::Details::PropertyBase* AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty ( const std::string &  name,
SG::VarHandleKeyArray hndArr,
const std::string &  doc,
const SG::VarHandleKeyArrayType  
)
inlineinherited

Definition at line 259 of file AthCommonDataStore.h.

263  {
264 
265  // std::ostringstream ost;
266  // ost << Algorithm::name() << " VHKA declareProp: " << name
267  // << " size: " << hndArr.keys().size()
268  // << " mode: " << hndArr.mode()
269  // << " vhka size: " << m_vhka.size()
270  // << "\n";
271  // debug() << ost.str() << endmsg;
272 
273  hndArr.setOwner(this);
274  m_vhka.push_back(&hndArr);
275 
276  Gaudi::Details::PropertyBase* p = PBASE::declareProperty(name, hndArr, doc);
277  if (p != 0) {
278  p->declareUpdateHandler(&AthCommonDataStore<PBASE>::updateVHKA, this);
279  } else {
280  ATH_MSG_ERROR("unable to call declareProperty on VarHandleKeyArray "
281  << name);
282  }
283 
284  return p;
285 
286  }

◆ declareProperty() [4/6]

Gaudi::Details::PropertyBase* AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty ( const std::string &  name,
T &  property,
const std::string &  doc,
const SG::NotHandleType  
)
inlineinherited

Declare a new Gaudi property.

Parameters
nameName of the property.
propertyObject holding the property value.
docDocumentation string for the property.

This is the generic version, for types that do not derive from SG::VarHandleKey. It just forwards to the base class version of declareProperty.

Definition at line 333 of file AthCommonDataStore.h.

337  {
338  return PBASE::declareProperty(name, property, doc);
339  }

◆ declareProperty() [5/6]

Gaudi::Details::PropertyBase* AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty ( const std::string &  name,
T &  property,
const std::string &  doc = "none" 
)
inlineinherited

Declare a new Gaudi property.

Parameters
nameName of the property.
propertyObject holding the property value.
docDocumentation string for the property.

This dispatches to either the generic declareProperty or the one for VarHandle/Key/KeyArray.

Definition at line 352 of file AthCommonDataStore.h.

355  {
356  typedef typename SG::HandleClassifier<T>::type htype;
357  return declareProperty (name, property, doc, htype());
358  }

◆ declareProperty() [6/6]

Gaudi::Details::PropertyBase& AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty ( Gaudi::Property< T > &  t)
inlineinherited

Definition at line 145 of file AthCommonDataStore.h.

145  {
146  typedef typename SG::HandleClassifier<T>::type htype;
148  }

◆ detStore()

const ServiceHandle<StoreGateSvc>& AthCommonDataStore< AthCommonMsg< AlgTool > >::detStore ( ) const
inlineinherited

The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.

Definition at line 95 of file AthCommonDataStore.h.

95 { return m_detStore; }

◆ DisableWarnings()

void CP::TPileupReweighting::DisableWarnings ( Bool_t  in)
inlineinherited

Indicate if warnings should be suppressed.

Definition at line 116 of file TPileupReweighting.h.

116 { m_SetWarnings = !in;}

◆ EnableDebugging()

void CP::TPileupReweighting::EnableDebugging ( Bool_t  in)
inlineinherited

Indicate if additional debugging information should be output.

Definition at line 118 of file TPileupReweighting.h.

118 { m_debugging = in;}

◆ evtStore() [1/2]

ServiceHandle<StoreGateSvc>& AthCommonDataStore< AthCommonMsg< AlgTool > >::evtStore ( )
inlineinherited

The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.

Definition at line 85 of file AthCommonDataStore.h.

85 { return m_evtStore; }

◆ evtStore() [2/2]

const ServiceHandle<StoreGateSvc>& AthCommonDataStore< AthCommonMsg< AlgTool > >::evtStore ( ) const
inlineinherited

The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.

Definition at line 90 of file AthCommonDataStore.h.

90 { return m_evtStore; }

◆ expert()

virtual CP::TPileupReweighting* CP::PileupReweightingTool::expert ( )
inlinevirtual

Get pointer to the underlying tool - expert use only. Will require #include "PileupReweighting/TPileupReweighting.h".

Implements CP::IPileupReweightingTool.

Definition at line 121 of file PileupReweightingTool.h.

121 { return m_activeTool; }

◆ extraDeps_update_handler()

void AthCommonDataStore< AthCommonMsg< AlgTool > >::extraDeps_update_handler ( Gaudi::Details::PropertyBase &  ExtraDeps)
protectedinherited

Add StoreName to extra input/output deps as needed.

use the logic of the VarHandleKey to parse the DataObjID keys supplied via the ExtraInputs and ExtraOuputs Properties to add the StoreName if it's not explicitly given

◆ fill() [1/2]

int CP::PileupReweightingTool::fill ( const xAOD::EventInfo eventInfo)
virtual

Call this method once per event when in config file generating mode and you want standard mu reweighting.

Implements CP::IPileupReweightingTool.

Definition at line 425 of file PileupReweightingTool.cxx.

425  {
426  return fill(eventInfo,eventInfo.averageInteractionsPerCrossing(),0);
427 }

◆ fill() [2/2]

int CP::PileupReweightingTool::fill ( const xAOD::EventInfo eventInfo,
Double_t  x,
Double_t  y 
)
virtual

Use this method if you want to do a generic reweighting instead.

Implements CP::IPileupReweightingTool.

Definition at line 429 of file PileupReweightingTool.cxx.

429  {
430 
431  //auto-detect the period config if necessary
432  if(m_usePeriodConfig=="auto" && !m_doneConfigs[eventInfo.runNumber()]) { //try autodetect based on runnum of first event ...
433  //if data, we only need to ensure a binning is done ... for now, we assume the MC15 binning
434  if(!eventInfo.eventType(xAOD::EventInfo::IS_SIMULATION)) {
435  if(!m_emptyHistogram) { SetUniformBinning(100,0,100.); } //use a default binning
436  } else {
437  switch(eventInfo.runNumber()) {
438  case 212272: UsePeriodConfig("MC14_8TeV");break;
439  case 222222: UsePeriodConfig("MC14_13TeV");break;
440  case 222510: case 222525: case 222526: case 284500: UsePeriodConfig("MC15"); break;
441  }
442  if(eventInfo.runNumber()>284500) UsePeriodConfig("Run2"); //this is the automatic period config, allows any run numbers to be added
443  }
444  m_doneConfigs[eventInfo.runNumber()] = true;
445  }
446 
447  return TPileupReweighting::Fill(eventInfo.runNumber(), eventInfo.eventType(xAOD::EventInfo::IS_SIMULATION) ? eventInfo.mcChannelNumber() : -1 /*data*/, eventInfo.eventType(xAOD::EventInfo::IS_SIMULATION) ? m_weightTool->getWeight() : 1., x, y);
448 
449 }

◆ Fill()

Int_t TPileupReweighting::Fill ( Int_t  runNumber,
Int_t  channelNumber,
Float_t  w,
Float_t  x,
Float_t  y = 0. 
)
inherited

Definition at line 1837 of file TPileupReweighting.cxx.

1837  {
1838  if(!m_isInitialized ) {
1839  if (m_printInfo) Info("Fill","Initializing the subtool..");
1840  Initialize();
1841  }
1842  //should only be given genuine mcRunNumbers if mc (channel>=0). We don't fill periodNumber distributions
1843 
1844  TH1* hist = 0;
1845 
1846  //get the period if mc, get the data run if data
1847  if(channelNumber>=0) {
1848  if(m_periods.find(runNumber)==m_periods.end()) {
1849  //if assume default binning is true, will add binning from 0 to 100 for this run number
1850  if(m_autoRunStart || m_autoRunEnd) {
1852  }
1853  if(m_periods.find(runNumber)==m_periods.end()) {
1854  Error("Fill","Unrecognised runNumber: %d. Check your period configuration (AddPeriod or UsePeriodConfig)",runNumber);
1855  throw std::runtime_error("Throwing 1: Unrecognised periodNumber");
1856  }
1857  }
1859  if(!p) {
1860  Error("Fill","Unrecognised runNumber: %d. Check your period configuration (AddPeriod or UsePeriodConfig) ... but should never have got here so please report this!",runNumber);
1861  throw std::runtime_error("Throwing 1: Unrecognised periodNumber");
1862  }
1863  std::unique_ptr<TH1>& histptr = p->inputHists[channelNumber];
1864  if(!histptr) {
1865  //need to create my period histogram
1866  histptr = CloneEmptyHistogram(runNumber,channelNumber);
1867  }
1868  hist = histptr.get();
1869  } else {
1870  Run& r = m_runs[runNumber];
1871  if( ! r.inputHists["None"]) r.inputHists["None"]=CloneEmptyHistogram(runNumber,channelNumber);
1872  hist = r.inputHists["None"].get();
1873  }
1874 
1875  if(!hist) {
1876  Error("Fill","Unknown [run,channel] = [%d,%d]",runNumber,channelNumber);
1877  throw std::runtime_error("Throwing 45: Fill:: Unknown [run,channel] ");
1878  }
1879 
1880  if(hist->GetDimension()==1) {
1881  return hist->Fill(x,w);
1882  } else if(hist->GetDimension()==2) {
1883  return (static_cast<TH2*>(hist))->Fill(x,y,w);
1884  }
1885  return -1;
1886 }

◆ finalize()

StatusCode CP::PileupReweightingTool::finalize ( )
virtual

Finalize - can call the WriteToFile for us.

Definition at line 299 of file PileupReweightingTool.cxx.

299  {
300  if(m_inConfigMode) {
301 #ifndef XAOD_STANDALONE
302  if(m_configStream=="") {
303  //write the prw config files
304  std::string nameWithoutParent = this->name().substr(this->name().find(".")+1);
305  TString fileName = TString::Format("%s.prw.root", nameWithoutParent.c_str());
306  /*m_tool->*/WriteToFile(fileName);
307  } else {
308  //write to the histsvc stream instead ...
309 
310  ServiceHandle<ITHistSvc> histSvc("THistSvc",name());
311  CHECK( histSvc.retrieve() );
312 
313  TTree *outTreeMC=0;
314  TTree *outTreeData=0;
315  Int_t channel = 0;UInt_t runNumber = 0;
316  std::vector<UInt_t> pStarts;
317  std::vector<UInt_t> pEnds;
318  std::vector<UInt_t>* pStartsPtr = &pStarts;
319  std::vector<UInt_t>* pEndsPtr = &pEnds;
320  Char_t histName[150];
321 
322 
323  //loop over periods ... periods only get entry in table if they have an input histogram
324  for(auto period : m_periods) {
325  if(!period.second) continue; //should never happen, but just in case!
326  if(period.first<0) continue; //avoid the global run number
327  if(period.first != period.second->id) continue; //skips redirects
328  runNumber = period.first;
329  pStarts.clear();
330  pEnds.clear();
331  if(period.second->subPeriods.size()==0) {
332  pStarts.push_back(period.second->start); pEnds.push_back(period.second->end);
333  }
334  else {
335  for(auto subp : period.second->subPeriods) {
336  pStarts.push_back(subp->start); pEnds.push_back(subp->end);
337  }
338  }
339  for(auto& inHist : period.second->inputHists) {
340  channel = inHist.first;
341  TH1* hist = inHist.second.release();
342  strncpy(histName,hist->GetName(),sizeof(histName)-1);
343  CHECK( histSvc->regHist(TString::Format("/%s/PileupReweighting/%s",m_configStream.c_str(),hist->GetName()).Data(),hist) );
344  if(!outTreeMC) {
345  outTreeMC = new TTree("MCPileupReweighting","MCPileupReweighting");
346  outTreeMC->Branch("Channel",&channel);
347  outTreeMC->Branch("RunNumber",&runNumber);
348  outTreeMC->Branch("PeriodStarts",&pStartsPtr);
349  outTreeMC->Branch("PeriodEnds",&pEndsPtr);
350  outTreeMC->Branch("HistName",&histName,"HistName/C");
351  CHECK( histSvc->regTree(TString::Format("/%s/PileupReweighting/%s",m_configStream.c_str(),outTreeMC->GetName()).Data(),outTreeMC) );
352  }
353  outTreeMC->Fill();
354  }
355  }
356 
357  //loop over data
358  for(auto& run : m_runs) {
359  runNumber = run.first;
360  if(run.second.inputHists.find("None")==run.second.inputHists.end()) continue;
361 
362  TH1* hist = run.second.inputHists["None"].release();
363  strncpy(histName,hist->GetName(),sizeof(histName)-1);
364  CHECK( histSvc->regHist(TString::Format("/%s/PileupReweighting/%s",m_configStream.c_str(),hist->GetName()).Data(),hist) );
365  if(!outTreeData) {
366  outTreeData = new TTree("DataPileupReweighting","DataPileupReweighting");
367  outTreeData->Branch("RunNumber",&runNumber);
368  outTreeData->Branch("HistName",&histName,"HistName/C");
369  CHECK( histSvc->regTree(TString::Format("/%s/PileupReweighting/%s",m_configStream.c_str(),outTreeData->GetName()).Data(),outTreeData) );
370  }
371  outTreeData->Fill();
372  }
373 
374  Info("WriteToFile", "Successfully generated config file to stream: %s",m_configStream.c_str());
375  Info("WriteToFile", "Happy Reweighting :-)");
376 
377  }
378 
379 #else
380  //write the prw config files
381  std::string nameWithoutParent = this->name().substr(this->name().find(".")+1);
382  TString fileName = TString::Format("%s.prw.root", nameWithoutParent.c_str());
383  /*m_tool->*/WriteToFile(fileName);
384 #endif
385  }
386 
387  m_upTool.reset(); m_downTool.reset();
388 
389  return StatusCode::SUCCESS;
390 }

◆ GenerateMetaDataFile()

Int_t TPileupReweighting::GenerateMetaDataFile ( const TString &  fileName,
const TString &  channelBranchName = "mc_channel_number" 
)
inherited

Definition at line 460 of file TPileupReweighting.cxx.

460  {
461 
462  TTree inTree("in","in");
463  inTree.ReadFile(fileName);
464  TTree outTree("ChannelMetaData","ChannelMetaData");
465  Int_t chanNum;
466  std::map<TString, Double_t> data;
467  TObjArray *leaves = inTree.GetListOfLeaves();
468  if(leaves==0) {Error("GenerateMetaDataFile","No leaves"); return -1; }
469  for(Int_t i=0;i<leaves->GetEntries();++i) {
470  TLeaf *leaf = (TLeaf *)leaves->At(i);
471  if(leaf) {
472  TBranch *branch = leaf->GetBranch();
473  if(strcmp(branch->GetName(),channelBranchName)==0) {
474  //this is the channel branch
475  if(strcmp(leaf->GetTypeName(),"Int_t")!=0) {
476  Error("GenerateMetaDataFile","Channel Branch must be type Int_t"); return -1;
477  }
478  branch->SetAddress(&chanNum);
479  outTree.Branch(channelBranchName,&chanNum);
480  } else if(strcmp(leaf->GetTypeName(),"Double_t")!=0) {
481  Warning("GenerateMetaDataFile","Cannot read non-double branch: %s",branch->GetName());
482  } else {
483  branch->SetAddress(&(data[branch->GetName()]));
484  outTree.Branch(branch->GetName(),&(data[branch->GetName()]));
485  }
486  }
487  }
488  //loop over tree entries and read in the values according to property type
489  for(Int_t i=0;i<inTree.GetEntries();++i) {
490  inTree.GetEntry(i);
491  outTree.Fill();
492  }
493 
494  //remove the file extension and replace with .root
495  TString outName = fileName(0,fileName.Last('.'));
496  outName += ".prw.root";
497  TFile f1(outName,"RECREATE");
498  outTree.Write();
499  f1.Close();
500  if (m_printInfo) {
501  Info("GenerateMetaDataFile","Succesfully Generated File %s",outName.Data());
502  }
503  return 0;
504 }

◆ getCombinedWeight() [1/3]

float CP::PileupReweightingTool::getCombinedWeight ( const xAOD::EventInfo eventInfo,
bool  correctUnrepresented 
)
virtual

Return combined pileup weight.

Implements CP::IPileupReweightingTool.

Definition at line 397 of file PileupReweightingTool.cxx.

397  {
398  float weight = m_activeTool->GetCombinedWeight( eventInfo.runNumber(), eventInfo.mcChannelNumber(), eventInfo.averageInteractionsPerCrossing() );
399  if(correctUnrepresented && m_unrepresentedDataAction==2)
400  weight *= getUnrepresentedDataWeight( eventInfo );
401  return weight;
402 }

◆ getCombinedWeight() [2/3]

float CP::PileupReweightingTool::getCombinedWeight ( const xAOD::EventInfo eventInfo,
const TString &  trigger,
bool  mu_dependent,
bool  correctUnrepresented 
)
virtual

get combined weight (i.e. pileup weight) but with a 1./dataWeight factor applied, this if used for 'prescaling' MC

Implements CP::IPileupReweightingTool.

Definition at line 525 of file PileupReweightingTool.cxx.

525  {
526  float out = getCombinedWeight(eventInfo, correctUnrepresented);
527  if(!out) return out; //don't try to evaluate DataWeight if our PRW is 0 ... means there is no data available at that mu anyway
528 
529  out *= getPrescaleWeight(eventInfo, trigger, mu_dependent);
530  return out;
531 }

◆ getCombinedWeight() [3/3]

float CP::PileupReweightingTool::getCombinedWeight ( const xAOD::EventInfo eventInfo,
Double_t  x,
Double_t  y,
bool  correctUnrepresented 
)
virtual

Same as above, but for a 'custom weight' variable.

Implements CP::IPileupReweightingTool.

Definition at line 404 of file PileupReweightingTool.cxx.

404  {
405  float weight = m_activeTool->GetCombinedWeight( eventInfo.runNumber(), eventInfo.mcChannelNumber(), x, y );
406  if(correctUnrepresented && m_unrepresentedDataAction==2)
407  weight *= getUnrepresentedDataWeight( eventInfo );
408  return weight;
409 }

◆ GetCombinedWeight()

Float_t TPileupReweighting::GetCombinedWeight ( Int_t  periodNumber,
Int_t  channelNumber,
Float_t  x,
Float_t  y = 0. 
)
inherited

Definition at line 1603 of file TPileupReweighting.cxx.

1603  {
1604  if(!m_isInitialized) {
1605  if (m_printInfo) Info("GetCombinedWeight","Initializing the subtool..");
1606  Initialize();
1607  }
1608  if(m_countingMode) return 0.;
1609 
1610  //decide how many dimensions this weight has - use the emptyHistogram to tell...
1611  TH1* hist = m_emptyHistogram.get();
1612  if(!hist) {
1613  Error("GetCombinedWeight","Tool not configured properly ... please report this!");
1614  throw std::runtime_error("Throwing 47: Tool not configured properly ... please report this!");
1615  }
1616 
1617  Float_t out = GetPeriodWeight(periodNumber,channelNumber)*GetPrimaryWeight(periodNumber,channelNumber,x);
1618  if(hist->GetDimension()>1) out *= GetSecondaryWeight(periodNumber,channelNumber,x,y);
1619 
1620  return out;
1621 }

◆ getCorrectedActualInteractionsPerCrossing()

float CP::PileupReweightingTool::getCorrectedActualInteractionsPerCrossing ( const xAOD::EventInfo eventInfo,
bool  includeDataScaleFactor 
)
virtual

Get the corrected 'actual' interactions per crossing.

Implements CP::IPileupReweightingTool.

Definition at line 157 of file PileupReweightingTool.cxx.

157  {
159  return eventInfo.actualInteractionsPerCrossing(); //no correction needed for MC
160  }
161  float correctedMu = CP::TPileupReweighting::GetLumiBlockMu(eventInfo.runNumber(),eventInfo.lumiBlock());
162  if(correctedMu<0) return correctedMu; //will be -1
163  return eventInfo.actualInteractionsPerCrossing() * (correctedMu/eventInfo.averageInteractionsPerCrossing()) * ( (includeDataScaleFactor) ? m_activeTool->GetDataScaleFactor() : 1.);
164 }

◆ getCorrectedAverageInteractionsPerCrossing()

float CP::PileupReweightingTool::getCorrectedAverageInteractionsPerCrossing ( const xAOD::EventInfo eventInfo,
bool  includeDataScaleFactor 
)
virtual

Get the mu of a lumiblock ... needed to 'correct' the number in datasets.

Implements CP::IPileupReweightingTool.

Definition at line 148 of file PileupReweightingTool.cxx.

148  {
150  return eventInfo.averageInteractionsPerCrossing(); //no correction needed for MC
151  }
152  float out = CP::TPileupReweighting::GetLumiBlockMu(eventInfo.runNumber(),eventInfo.lumiBlock());
153  if(out<0) return out; //will be -1
154  return out * ( (includeDataScaleFactor) ? m_activeTool->GetDataScaleFactor() : 1.);
155 }

◆ getCorrectedMu()

virtual float CP::IPileupReweightingTool::getCorrectedMu ( const xAOD::EventInfo eventInfo,
bool  includedDataScaleFactor = false 
)
inlinevirtualinherited

Get the corrected average mu of a lumiblock ...

(averaging is over all filled BCID in the fill) The additional flag indicates if the returned value should include the data scale factor or not. Note: if the lumiblock is not present in the input lumicalc file, then -1.0 will be returned This method will soon be deprecated in favour of the new naming: getCorrectedAverageInteractionsPerCrossing

Definition at line 61 of file IPileupReweightingTool.h.

61  {
62  return getCorrectedAverageInteractionsPerCrossing( eventInfo, includedDataScaleFactor );
63  }

◆ GetDataScaleFactor()

Float_t CP::TPileupReweighting::GetDataScaleFactor ( ) const
inlineinherited

Definition at line 298 of file TPileupReweighting.h.

298 { return m_dataScaleFactorX; }

◆ getDataWeight()

float CP::PileupReweightingTool::getDataWeight ( const xAOD::EventInfo eventInfo,
const TString &  trigger,
bool  mu_dependent 
)
virtual

Get the dataWeight used to 'unprescale' data collected from a given trigger combination. mu_dependency is recommended to be true.

Implements CP::IPileupReweightingTool.

Definition at line 495 of file PileupReweightingTool.cxx.

495  {
496 
498  ATH_MSG_WARNING("Requesting Data Weight is not intended for simulated events. Returning 1.");
499  return 1; //no data weights for simulated events
500  }
501 
502  if(!mu_dependent) return /*m_tool->*/m_activeTool->GetDataWeight(eventInfo.runNumber(), trigger);
503 
504  double correctedMu = getCorrectedAverageInteractionsPerCrossing(eventInfo,false);
505  if(correctedMu<0) {
506  ATH_MSG_ERROR("Unrecognised run+lumiblock number (" << eventInfo.runNumber() << "," << eventInfo.lumiBlock() << ") ... please ensure your lumicalc files are complete! Returning 1.");
507  return 1;
508  }
509 
510  return /*m_tool->*/m_activeTool->GetDataWeight( eventInfo.runNumber(), trigger, correctedMu/*use the 'correct' mu instead of the one from the file!!*/ );
511 
512 }

◆ GetDataWeight() [1/2]

Double_t TPileupReweighting::GetDataWeight ( Int_t  runNumber,
const TString &  trigger 
)
inherited

Definition at line 1722 of file TPileupReweighting.cxx.

1722  {
1723  //special mu-independent version of GetDataWeight. Will just use the global luminosity
1724  m_doGlobalDataWeight=true;
1725  double out = GetDataWeight(runNumber, trigger, 0);
1726  m_doGlobalDataWeight=false;
1727  return out;
1728 }

◆ GetDataWeight() [2/2]

Double_t TPileupReweighting::GetDataWeight ( Int_t  runNumber,
const TString &  trigger,
Double_t  x,
bool  run_dependent = false 
)
inherited

Method for weighting data to account for prescales and mu bias.

Use by giving the tool multiple lumicalc files, one for each trigger

Definition at line 1730 of file TPileupReweighting.cxx.

1730  {
1731 
1732  if(!m_isInitialized ) {
1733  if (m_printInfo) Info("GetDataWeight","Initializing the subtool..");
1734  Initialize();
1735  }
1736  if(m_countingMode) return 0.;
1737 
1738  //determine which period this run number is in
1739  Int_t periodNumber = GetFirstFoundPeriodNumber(runNumber);
1740 
1741  Period* p = m_periods[periodNumber];
1742  if(!p) {
1743  Error("GetDataWeight","Unrecognised periodNumber: %d",periodNumber);
1744  throw std::runtime_error("Throwing 1: Unrecognised periodNumber");
1745  }
1746 
1747  //see if we already made this trigger hist
1748  auto tobj = m_triggerObjs.find(trigger);
1749 
1750 
1751  if(tobj==m_triggerObjs.end()) {
1752  //try to do a subtrigger calculation we need to reopen all the lumicalc files and do the fiddily prescaled luminosity calculation
1753  //will throw errors if can't
1755  tobj = m_triggerObjs.find(trigger);
1756  }
1757 
1758  //check
1759 
1760 
1761 
1762  if(tobj->second->triggerHists.find(p->id) == tobj->second->triggerHists.end()) {
1763  Error("GetDataWeight","Could not find trigger %s in period %d",trigger.Data(),p->id);
1764  throw std::runtime_error("GetDataWeight: Could not find trigger 1");
1765  }
1766 
1767 
1768  //now we need to evaluate the trigger bits, and if necessary calculate the new trigger hist for the new bits combination
1769  long tbits = tobj->second->getBits(this);
1770 
1771  if(tbits==0) return 1; //no trigger passed
1772 
1773  int idx = (runDependent) ? -runNumber : p->id;
1774 
1775 
1776  auto dItr = tobj->second->triggerHists[idx].find(tbits);
1777 
1778  TH1* denomHist = 0;
1779  if(dItr == tobj->second->triggerHists[idx].end()) {
1780  //possible that the tbits for this event have not been encountered before, so just redo the calculation ...
1781  calculateHistograms(tobj->second.get(),(runDependent) ? runNumber:0);
1782 
1783  denomHist = tobj->second->triggerHists[idx][tbits].get();
1784  if(denomHist==0) {
1785  Error("GetDataWeight","Could not find trigger %s in period %d with bits %ld",trigger.Data(),idx, tbits);
1786  throw std::runtime_error("GetDataWeight: Could not find trigger 2");
1787  }
1788  } else {
1789  denomHist = dItr->second.get();
1790  }
1791 
1792 
1793  TH1* numerHist = m_triggerObjs["None"]->triggerHists[idx][0].get();
1794  if(numerHist==0) {
1795  Error("GetDataWeight","Could not find unprescaled trigger in period %d",idx);
1796  throw std::runtime_error("GetDataWeight: Could not find unprescaled trigger. Please AddLumiCalc with a 'None' trigger");
1797  }
1798 
1799  if(m_doGlobalDataWeight) return numerHist->Integral(0,numerHist->GetNbinsX()+1)/denomHist->Integral(0,denomHist->GetNbinsX()+1);
1800 
1801  Int_t bin=(m_doPrescaleWeight) ? numerHist->FindFixBin(x) : //DO NOT SHIFT IF GETTING A PRESCALE WEIGHT - applied to MC, we only shift incoming mu if we are data
1802  numerHist->FindFixBin(x*m_dataScaleFactorX); //if getting a data weight (i.e. running on data) MUST SCALE BY THE DATA SCALE FACTOR! (assume incoming is raw unscaled)
1803 
1804  //we also need to redirect the binning if necessary (unrepData=3)
1805  if( (!m_doPrescaleWeight) && m_unrepresentedDataAction==3) bin = p->inputBinRedirect[bin];
1806 
1807  if(!denomHist->GetBinContent(bin)) {
1808  if(m_doPrescaleWeight) return -1; //happens if trigger was disabled/unavailable for that mu, even though that mu is in the dataset
1809  Error("GetDataWeight","Unrecognised mu value %f ... are you sure you included all lumicalc files",x);
1810  throw std::runtime_error("GetDataWeight: Unrecognised mu value. Please AddLumiCalc enough lumi with 'None' trigger");
1811  }
1812 
1813  return numerHist->GetBinContent(bin)/denomHist->GetBinContent(bin);
1814 }

◆ GetDefaultChannel()

Int_t TPileupReweighting::GetDefaultChannel ( Int_t  mcRunNumber = -1)
inherited

Definition at line 109 of file TPileupReweighting.cxx.

109  {
110  if(m_parentTool != this) return m_parentTool->GetDefaultChannel(mcRunNumber);
111  return m_periods[mcRunNumber]->defaultChannel;
112 }

◆ GetFirstFoundPeriodNumber()

Int_t TPileupReweighting::GetFirstFoundPeriodNumber ( UInt_t  runNumber)
inherited

Get the first period number with the data run number contained - assume all periods are disconnected for this to be useful.

Definition at line 422 of file TPileupReweighting.cxx.

422  {
423  //go through periods, first period that includes this runNumber wins!
424  //otherwise it returns the 'global period number': -1
425  for(auto period : m_periods) {
426  if(period.second->id==-1) continue;
427  if(period.second->contains(runNumber)) return period.second->id;
428  }
429  return -1;
430 
431 }

◆ GetInputHistogram()

TH1* CP::TPileupReweighting::GetInputHistogram ( Int_t  channelNumber,
Int_t  periodNumber 
)
inlineinherited

Definition at line 251 of file TPileupReweighting.h.

251  {
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  }

◆ GetIntegratedLumi() [1/3]

virtual Double_t CP::PileupReweightingTool::GetIntegratedLumi ( const TString &  trigger)
inlinevirtual

Total lumi (in pb-1) for a given trigger combination .. leave blank for the unprescaled.

Implements CP::IPileupReweightingTool.

Definition at line 51 of file PileupReweightingTool.h.

51 { return m_activeTool->GetIntegratedLumi(trigger); }

◆ GetIntegratedLumi() [2/3]

virtual Double_t CP::PileupReweightingTool::GetIntegratedLumi ( Int_t  periodNumber,
UInt_t  start,
UInt_t  end 
)
inlinevirtual

similar to above, but for only the given mcRunNumber/periodNumber

Implements CP::IPileupReweightingTool.

Definition at line 53 of file PileupReweightingTool.h.

53 { return m_activeTool->GetIntegratedLumi(periodNumber, start, end); }

◆ GetIntegratedLumi() [3/3]

virtual Double_t CP::PileupReweightingTool::GetIntegratedLumi ( UInt_t  start,
UInt_t  end 
)
inlinevirtual

Get the integrated luminosity (in pb-1) between start and end run (inclusive)

Implements CP::IPileupReweightingTool.

Definition at line 49 of file PileupReweightingTool.h.

◆ GetIntegratedLumiFraction() [1/2]

virtual Double_t CP::PileupReweightingTool::GetIntegratedLumiFraction ( Int_t  periodNumber,
Double_t  mu,
UInt_t  start,
UInt_t  end 
)
inlinevirtual

return fraction of lumi assigned to periodNumber (or mcRunNumber) with given mu, that is between start and end data run numbers

Implements CP::IPileupReweightingTool.

Definition at line 57 of file PileupReweightingTool.h.

57 { return m_activeTool->GetIntegratedLumiFraction(periodNumber, mu, start, end); }

◆ GetIntegratedLumiFraction() [2/2]

virtual Double_t CP::PileupReweightingTool::GetIntegratedLumiFraction ( Int_t  periodNumber,
UInt_t  start,
UInt_t  end 
)
inlinevirtual

return fraction of lumi assigned to periodNumber (or mcRunNumber) that is between start and end data run numbers

Implements CP::IPileupReweightingTool.

Definition at line 55 of file PileupReweightingTool.h.

55 { return m_activeTool->GetIntegratedLumiFraction(periodNumber, start, end); }

◆ getKey()

SG::sgkey_t asg::AsgTool::getKey ( const void *  ptr) const
inherited

Get the (hashed) key of an object that is in the event store.

This is a bit of a special one. StoreGateSvc and xAOD::TEvent both provide ways for getting the SG::sgkey_t key for an object that is in the store, based on a bare pointer. But they provide different interfaces for doing so.

In order to allow tools to efficiently perform this operation, they can use this helper function.

See also
asg::AsgTool::getName
Parameters
ptrThe bare pointer to the object that the event store should know about
Returns
The hashed key of the object in the store. If not found, an invalid (zero) key.

Definition at line 119 of file AsgTool.cxx.

119  {
120 
121 #ifdef XAOD_STANDALONE
122  // In case we use @c xAOD::TEvent, we have a direct function call
123  // for this.
124  return evtStore()->event()->getKey( ptr );
125 #else
126  const SG::DataProxy* proxy = evtStore()->proxy( ptr );
127  return ( proxy == nullptr ? 0 : proxy->sgkey() );
128 #endif // XAOD_STANDALONE
129  }

◆ getLumiBlockIntegratedLumi()

double CP::PileupReweightingTool::getLumiBlockIntegratedLumi ( const xAOD::EventInfo eventInfo)
virtual

Get the integrated lumi of a lumiblock (in pb-1)

Implements CP::IPileupReweightingTool.

Definition at line 167 of file PileupReweightingTool.cxx.

◆ GetLumiBlockIntegratedLumi()

Double_t TPileupReweighting::GetLumiBlockIntegratedLumi ( Int_t  runNumber,
UInt_t  lb 
)
inherited

get integrated lumi for specific run and lumiblock number .

. comes from the 'unprescaled lumi', and is in pb

Definition at line 154 of file TPileupReweighting.cxx.

154  {
155  if(!m_isInitialized) {
156  if (m_printInfo) {
157  Info("GetIntegratedLumi","Initializing the subtool..");
158  }
159  Initialize();
160  }
161  if(m_runs.find(runNumber)==m_runs.end()) return 0.;
162  auto& run = m_runs[runNumber];
163 
164  if(run.lumiByLbn.find(lb)==run.lumiByLbn.end()) return 0.;
165  return run.lumiByLbn[lb].first*1E-6;
166 }

◆ GetLumiBlockMu()

Float_t TPileupReweighting::GetLumiBlockMu ( Int_t  runNumber,
UInt_t  lb 
)
inherited

get the lumiblock mu, useful for 'updating' the mu coming from data to account for new lumitags

Definition at line 168 of file TPileupReweighting.cxx.

168  {
169  if(!m_isInitialized) {
170  if (m_printInfo) {
171  Info("GetLumiBlockMu","Initializing the subtool..");
172  }
173  Initialize();
174  }
175  if(m_runs.find(runNumber)==m_runs.end()) return -1.0;
176  auto& run = m_runs[runNumber];
177 
178  if(run.lumiByLbn.find(lb)==run.lumiByLbn.end()) return -1.0;
179  return run.lumiByLbn[lb].second;
180 }

◆ GetMetaData()

Double_t CP::TPileupReweighting::GetMetaData ( const TString &  metadataName,
Int_t  channelNumber 
)
inlineinherited

Definition at line 188 of file TPileupReweighting.h.

188  {
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  }

◆ GetMetaDataTree()

TTree * TPileupReweighting::GetMetaDataTree ( )
inherited

combines loaded metadata with channel sumsofweights and entry counts

Definition at line 574 of file TPileupReweighting.cxx.

574  {
575  if(m_metadatatree) delete m_metadatatree;
576  m_metadatatree = new TTree(TString(this->GetName())+"MetaData",TString(this->GetName())+"MetaData");
577  m_metadatatree->SetDirectory(0);
578  Int_t channel=0;
579  m_metadatatree->Branch("mc_channel_number",&channel);
580  std::map<TString,Double_t> data;
581  std::map<Int_t,bool> channels;
582  //create a branch for each metadata item
583  for(std::map<TString,std::map<Int_t,Double_t> >::iterator it=m_metadata.begin();it!=m_metadata.end();++it) {
584  for(std::map<Int_t,Double_t>::iterator it2=(it->second).begin();it2!=(it->second).end();++it2) {
585  channels[it2->first]=true; //records which channels we have metadata for
586  }
587  const auto &[ptr, inserted ] = data.try_emplace(it->first, 0.);
588  if (inserted){
589  m_metadatatree->Branch(it->first,&(data[it->first]));
590  }
591  }
592  //also create branches for the NumberOfEvents and SumOfEventWeights
593  data["NumberOfEvents"]=0.;
594  m_metadatatree->Branch("NumberOfEvents",&(data["NumberOfEvents"]));
595  data["SumOfEventWeights"]=0.;
596  m_metadatatree->Branch("SumOfEventWeights",&(data["SumOfEventWeights"]));
597  //and add to channels list any channels that have events
598  auto& myMap = m_periods[-1]->sumOfWeights;
599  for(std::map<Int_t,Double_t>::iterator it=myMap.begin();it!=myMap.end();++it) {
600  if(it->first>=0 && it->second>0.) channels[it->first]=true;
601  }
602 
603  //now loop over the channels and fill the TTree
604  for(std::map<Int_t,bool>::iterator it=channels.begin();it!=channels.end();++it) {
605  channel=it->first;
606  for(std::map<TString,Double_t>::iterator it2=data.begin();it2!=data.end();++it2) {
607  if(it2->first=="NumberOfEvents") {
608  //check for this in globalNumberOfEntries
609  if(myMap.find(channel)==myMap.end()) {
610  data[it2->first]=0.;
611  Warning("GetMetaDataTree","Channel %d does not have MetaData %s",it->first,(it2->first).Data());
612  } else {
613  data[it2->first]=m_periods[-1]->numberOfEntries[channel];
614  }
615  } else if(it2->first=="SumOfEventWeights") {
616  //check for this in globalTotals
617  auto& myMap2 = m_periods[-1]->sumOfWeights;
618  if(myMap2.find(channel)==myMap2.end()) {
619  data[it2->first]=0.;
620  Warning("GetMetaDataTree","Channel %d does not have MetaData %s",it->first,(it2->first).Data());
621  } else {
622  data[it2->first]=m_periods[-1]->sumOfWeights[channel];
623  }
624  } else {
625  auto& myMap2 = m_metadata[it2->first];
626  if(myMap2.find(channel)==myMap2.end()) {
627  //this channel doesn't have this property
628  data[it2->first]=0.;
629  Warning("GetMetaDataTree","Channel %d does not have MetaData %s",it->first,(it2->first).Data());
630  } else {
631  data[it2->first]=myMap2[channel];
632  }
633  }
634  }
635  m_metadatatree->Fill();
636  }
637 
638  m_metadatatree->BuildIndex("mc_channel_number");
639  m_metadatatree->ResetBranchAddresses();
640 
641  return m_metadatatree;
642 }

◆ getName()

const std::string & asg::AsgTool::getName ( const void *  ptr) const
inherited

Get the name of an object that is / should be in the event store.

This is a bit of a special one. StoreGateSvc and xAOD::TEvent both provide ways for getting the std::string name for an object that is in the store, based on a bare pointer. But they provide different interfaces for doing so.

In order to allow tools to efficiently perform this operation, they can use this helper function.

See also
asg::AsgTool::getKey
Parameters
ptrThe bare pointer to the object that the event store should know about
Returns
The string name of the object in the store. If not found, an empty string.

Definition at line 106 of file AsgTool.cxx.

106  {
107 
108 #ifdef XAOD_STANDALONE
109  // In case we use @c xAOD::TEvent, we have a direct function call
110  // for this.
111  return evtStore()->event()->getName( ptr );
112 #else
113  const SG::DataProxy* proxy = evtStore()->proxy( ptr );
114  static const std::string dummy = "";
115  return ( proxy == nullptr ? dummy : proxy->name() );
116 #endif // XAOD_STANDALONE
117  }

◆ GetNearestGoodBin()

Int_t TPileupReweighting::GetNearestGoodBin ( Int_t  thisMCRunNumber,
Int_t  bin 
)
protectedinherited

Definition at line 1367 of file TPileupReweighting.cxx.

1367  {
1368 
1369  int binDistance = 1;
1370  do {
1371  int res1 = IsBadBin(thisMCRunNumber,bin+binDistance);
1372  if(!res1) return bin+binDistance;
1373  int res2 = IsBadBin(thisMCRunNumber,bin-binDistance);
1374  if(!res2) return bin-binDistance;
1375  if(res1==2 && res2==2) { //run out of bins
1376  Error("GetNearestGoodBin", "None of the bins are good!!??");
1377  return -1;
1378  }
1379  binDistance++;
1380  } while(true); //scary!
1381 
1382  return -1;
1383 
1384 }

◆ GetNumberOfEvents()

virtual Double_t CP::PileupReweightingTool::GetNumberOfEvents ( Int_t  channel)
inlinevirtual

Implements CP::IPileupReweightingTool.

Definition at line 65 of file PileupReweightingTool.h.

◆ GetPeriodNumbers()

std::vector<int> CP::TPileupReweighting::GetPeriodNumbers ( ) const
inlineinherited

Definition at line 242 of file TPileupReweighting.h.

242  {
243  std::vector<int> out;
244  for(auto& p : m_periods) { out.push_back(p.first); }
245  return out;
246  }

◆ GetPeriodWeight()

Float_t TPileupReweighting::GetPeriodWeight ( Int_t  periodNumber,
Int_t  channelNumber 
)
inherited

Definition at line 1623 of file TPileupReweighting.cxx.

1623  {
1624  //= L_A/L / N_A/N
1625  if(!m_isInitialized) {
1626  if (m_printInfo) Info("GetPeriodWeight","Initializing the subtool..");
1627  Initialize();
1628  }
1629  if(m_countingMode) return 0.;
1630 
1631  Period* p = m_periods[periodNumber];
1632  if(!p) {
1633  Error("GetPeriodWeight","Unrecognised periodNumber: %d",periodNumber);
1634  throw std::runtime_error("Throwing 1: Unrecognised periodNumber");
1635  }
1636  if(p->sumOfWeights.find(channelNumber) == p->sumOfWeights.end()) {
1637  channelNumber = GetDefaultChannel(periodNumber);//p->defaultChannel;
1638  if(channelNumber!=0) {
1639  Warning("GetPeriodWeight","You're using a default config file ... you're gonna have a bad time!!");
1640  Warning("GetPeriodWeight","Please generate proper config files!");
1641  }
1642  }
1643 
1644  double n_a = p->sumOfWeights[channelNumber];
1645  double n = m_periods[-1]->sumOfWeights[channelNumber];
1646 
1647  double l_a = p->sumOfWeights[-1];
1648  double l = m_periods[-1]->sumOfWeights[-1];
1649 
1650  return (l_a/l) / (n_a/n);
1651 }

◆ getPrescaleWeight()

float CP::PileupReweightingTool::getPrescaleWeight ( const xAOD::EventInfo eventInfo,
const TString &  trigger,
bool  mu_dependent 
)
virtual

Get weight used to 'prescale' Monte Carlo for given trigger comibnation.

Implements CP::IPileupReweightingTool.

Definition at line 514 of file PileupReweightingTool.cxx.

514  {
515  //need to use the random run number ... only used to pick the subperiod, but in run2 so far we only have one subperiod
516  SG::ConstAccessor<unsigned int> rrnAcc (m_prefix+"RandomRunNumber");
517  unsigned int randomRunNum = rrnAcc.withDefault (eventInfo, 0);
518  if (randomRunNum == 0) {
519  randomRunNum = getRandomRunNumber( eventInfo, mu_dependent );
520  }
521  if(!mu_dependent) return m_activeTool->GetPrescaleWeight(randomRunNum, trigger);
522  return m_activeTool->GetPrescaleWeight( randomRunNum, trigger, getCorrectedAverageInteractionsPerCrossing(eventInfo,false) /*use the 'correct' mu instead of the one from the file!!*/, m_useRunDependentPrescaleWeight /*run-dependent*/ );
523 }

◆ GetPrescaleWeight() [1/2]

Double_t TPileupReweighting::GetPrescaleWeight ( Int_t  runNumber,
const TString &  trigger 
)
inherited

Definition at line 1817 of file TPileupReweighting.cxx.

1817  {
1818  //special mu-independent version of GetPrescaleWeight. Will just use the global luminosity
1819  m_doGlobalDataWeight=true;
1820  double out = GetPrescaleWeight(runNumber, trigger, 0);
1821  m_doGlobalDataWeight=false;
1822  return out;
1823 }

◆ GetPrescaleWeight() [2/2]

Double_t TPileupReweighting::GetPrescaleWeight ( Int_t  runNumber,
const TString &  trigger,
Double_t  x,
bool  run_dependent = false 
)
inherited

Method for prescaling MC to account for prescales in data.

Definition at line 1825 of file TPileupReweighting.cxx.

1825  {
1826 
1827  m_doPrescaleWeight = true;
1828  double out = GetDataWeight(runNumber,trigger,x,runDependent);
1829  m_doPrescaleWeight = false;
1830  if(out<=0) return 0; //happens when triggers disabled/unavailable for a given mu ... therefore the prescale weight is 0
1831  return 1./out;
1832 
1833 }

◆ GetPrimaryDistribution()

TH1* CP::TPileupReweighting::GetPrimaryDistribution ( Int_t  channelNumber,
Int_t  periodNumber 
)
inlineinherited

Definition at line 259 of file TPileupReweighting.h.

259  {
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  }

◆ GetPrimaryTriggerDistribution()

TH1* CP::TPileupReweighting::GetPrimaryTriggerDistribution ( const TString &  trigger,
Int_t  periodNumber,
long  triggerBits 
)
inlineinherited

Definition at line 267 of file TPileupReweighting.h.

267  {
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  }

◆ GetPrimaryWeight()

Float_t TPileupReweighting::GetPrimaryWeight ( Int_t  periodNumber,
Int_t  channelNumber,
Float_t  x 
)
inherited

Definition at line 1653 of file TPileupReweighting.cxx.

1653  {
1654  //= L_i/L_A / N_i/N_A .. primaryHists have already been normalized
1655  if(!m_isInitialized ) {
1656  if (m_printInfo) Info("GetPrimaryWeight","Initializing the subtool..");
1657  Initialize();
1658  }
1659  if(m_countingMode) return 0.;
1660 
1661  Period* p = m_periods[periodNumber];
1662  if(!p) {
1663  Error("GetPrimaryWeight","Unrecognised periodNumber: %d",periodNumber);
1664  throw std::runtime_error("Throwing 1: Unrecognised periodNumber");
1665  }
1666  int oChanNumber = channelNumber;
1667  if(p->sumOfWeights.find(channelNumber) == p->sumOfWeights.end()) channelNumber = GetDefaultChannel(periodNumber);//p->defaultChannel;
1668 
1669  if(!p->primaryHists[channelNumber]) {
1670  Error("GetPrimaryWeight","Unrecognised channelNumber %d for periodNumber %d",oChanNumber,periodNumber);
1671  throw std::runtime_error("Throwing 2: Unrecognised channelNumber");
1672  }
1673 
1674  int bin = p->primaryHists[channelNumber]->FindFixBin(x);
1675 
1676  double n = p->primaryHists[channelNumber]->GetBinContent(bin);
1677 
1678  // There is a special case that needs some additional protection
1679  // If you have the sum of weights ==0 for a given mu then you will have 0 in the PRW
1680  // profile leading to an exception or FPE later
1681  if (n==0){
1682  Warning("GetPrimaryWeight","No events expected in channelNumber %d for periodNumber %d with x=%g. Incorrect PRW profile or are you very unlucky???",channelNumber,periodNumber,x);
1683  return 1.;
1684  }
1685 
1686  if(!p->primaryHists[-1]) {
1687  Error("GetPrimaryWeight","No data loaded for period %d. Did you forget to load a lumicalc file or data config file?",periodNumber);
1688  throw std::runtime_error("Throwing 3: No data loaded. Did you forget to load a lumicalc file or data config file?");
1689  }
1690 
1691  double l = p->primaryHists[-1]->GetBinContent(bin);
1692 
1693  if (l==0 && n==0){
1694  Error("GetPrimaryWeight","No events expected with this mu. Incorrect PRW profile? Throwing exception ...");
1695  throw std::runtime_error(Form("Incorrect PRW profile detected. x=%g is not in the config file profile for channel %d, period %d", x, channelNumber, periodNumber ));
1696  }
1697 
1698  return l/n;
1699 }

◆ getProperty()

template<class T >
const T* asg::AsgTool::getProperty ( const std::string &  name) const
inherited

Get one of the tool's properties.

◆ getPRWHash()

ULong64_t CP::PileupReweightingTool::getPRWHash ( const xAOD::EventInfo eventInfo)
virtual

return the prw hash used for fast updates of weights at the post-processing level ... see the share/makeWeightTree.C script for usage

Implements CP::IPileupReweightingTool.

Definition at line 392 of file PileupReweightingTool.cxx.

392  {
393  return m_activeTool->GetPRWHash(eventInfo.runNumber(), eventInfo.mcChannelNumber(), eventInfo.averageInteractionsPerCrossing() );
394 }

◆ GetPRWHash()

ULong64_t TPileupReweighting::GetPRWHash ( Int_t  periodNumber,
Int_t  channelNumber,
Float_t  x,
Float_t  y = 0. 
)
inherited

Definition at line 1584 of file TPileupReweighting.cxx.

1584  {
1585  if(!m_isInitialized) {
1586  if (m_printInfo) Info("GetPRWHash","Initializing the subtool..");
1587  Initialize();
1588  }
1589  TH1* hist = m_emptyHistogram.get();
1590  if(!hist) {
1591  Error("GetPRWHash","Tool not configured properly ... please report this!");
1592  throw std::runtime_error("Throwing 47: Tool not configured properly ... please report this!");
1593  }
1594 
1595  ULong64_t out = hist->FindFixBin(x,y);
1596  out += (unsigned long)(channelNumber)*10000000000;
1597  out += (unsigned long)(periodNumber)*10000;
1598 
1599  return out;
1600 
1601 }

◆ GetRandomLumiBlockNumber()

virtual UInt_t CP::PileupReweightingTool::GetRandomLumiBlockNumber ( UInt_t  runNumber)
inlinevirtual

Get a random lumiblock number for the given run number.

Implements CP::IPileupReweightingTool.

Definition at line 47 of file PileupReweightingTool.h.

◆ GetRandomPeriodNumber()

Int_t TPileupReweighting::GetRandomPeriodNumber ( Int_t  mcRunNumber)
inherited

Get random period number from the sub-periods assigned to this run number.

Definition at line 1492 of file TPileupReweighting.cxx.

1492  {
1493  if(!m_isInitialized) {
1494  if (m_printInfo) Info("GetRandomPeriodNumber","Initializing the subtool..");
1495  Initialize();
1496  }
1497  if(m_countingMode) { return 0; } //do nothing when in counting mode
1498 
1499  Period* p = m_periods[periodNumber];
1500  if(!p) {
1501  Error("GetRandomPeriodNumber","Unrecognised periodNumber: %d",periodNumber);
1502  throw std::runtime_error("Throwing 1: Unrecognised periodNumber");
1503  }
1504 
1505  //if no subperiods, we just return ourselves
1506  if(p->subPeriods.size()==0) return p->id;
1507 
1508  //need the total lumi of this period
1509  double lumi = p->sumOfWeights[-1] * m_random3->Rndm();
1510 
1511  //loop over subPeriods ..
1512  double lumiSum=0;
1513  for(auto subp : p->subPeriods) {
1514  lumiSum += subp->sumOfWeights[-1];
1515  if(lumiSum >= lumi) return subp->id;
1516  }
1517 
1518  Error("GetRandomPeriodNumber","overran integrated luminosity for periodNumber=%d",periodNumber);
1519  throw std::runtime_error("Throwing 46.1: overran integrated luminosity for GetRandomPeriodNumber");
1520  return 0;
1521 
1522 }

◆ getRandomRunNumber()

int CP::PileupReweightingTool::getRandomRunNumber ( const xAOD::EventInfo eventInfo,
bool  mu_dependent 
)
virtual

Get a random run number for this MC event, using mu-dependent randomization by default ... jetetmiss seem to like it muchly.

Get a random run number for this MC event, mu_dependency is not recommended for this.

Implements CP::IPileupReweightingTool.

Definition at line 418 of file PileupReweightingTool.cxx.

418  {
420  tool->SetRandomSeed(314159+eventInfo.mcChannelNumber()*2718+eventInfo.eventNumber()); //to make randomization repeatable
421  if(mu_dependent) return tool->GetRandomRunNumber( eventInfo.runNumber(), eventInfo.averageInteractionsPerCrossing() );
422  else return tool->GetRandomRunNumber( eventInfo.runNumber() );
423 }

◆ GetRandomRunNumber() [1/2]

UInt_t TPileupReweighting::GetRandomRunNumber ( Int_t  mcRunNumber)
inherited

Gets a random data run number according to the integrated lumi distribution associated to this mcRunNumber.

allows use of custom reweighting config files

Definition at line 1412 of file TPileupReweighting.cxx.

1412  {
1413  if(!m_isInitialized) {
1414  if (m_printInfo)Info("GetRandomRunNumber","Initializing the subtool..");
1415  Initialize();
1416  }
1417  if(m_countingMode) { return 0; } //do nothing when in counting mode
1418 
1419  Period* p = m_periods[periodNumber];
1420  if(!p || !p->primaryHists[-1]) {
1421  Error("GetRandomRunNumber","Unrecognised periodNumber or no data loaded for: %d",periodNumber);
1422  throw std::runtime_error("Throwing 1: Unrecognised periodNumber");
1423  }
1424 
1425  double lumi = p->sumOfWeights[-1] * m_random3->Rndm();
1426 
1427  //go through the runs assigned to this period ...
1428  double lumiSum=0;
1429  for(auto runNum : p->runNumbers) {
1430  lumiSum += m_runs[runNum].inputHists["None"]->GetSumOfWeights();
1431  if(lumiSum >= lumi-0.00001) return runNum; //small difference is to catch rounding errors
1432  }
1433  Error("GetRandomRunNumber","overran integrated luminosity for periodNumber=%d (%f vs %f)",periodNumber,lumiSum,lumi);
1434  throw std::runtime_error("Throwing 46.1: overran integrated luminosity for GetRandomRunNumber");
1435  return 0;
1436 }

◆ GetRandomRunNumber() [2/2]

UInt_t TPileupReweighting::GetRandomRunNumber ( Int_t  mcRunNumber,
Double_t  mu 
)
inherited

Get random run number according to integrated lumi distribution for the given mu value (uses the binning of the mu histogram)

Definition at line 1438 of file TPileupReweighting.cxx.

1438  {
1439  if(!m_isInitialized) {
1440  if (m_printInfo) Info("GetRandomRunNumber","Initializing the subtool..");
1441  Initialize();
1442  }
1443  if(m_countingMode) { return 0; } //do nothing when in counting mode
1444 
1445  Period* p = m_periods[periodNumber];
1446  if(!p || !p->primaryHists[-1]) {
1447  Error("GetRandomRunNumber","Unrecognised periodNumber or no data loaded for: %d",periodNumber);
1448  throw std::runtime_error("Throwing 1: Unrecognised periodNumber");
1449  }
1450 
1451  int bin = m_emptyHistogram->FindFixBin(x);
1452 
1453  double lumi = p->primaryHists[-1]->GetBinContent(bin) * p->sumOfWeights[-1] * m_random3->Rndm();
1454 
1455  if(!lumi) { return 0; } //no lumi with that mu
1456 
1457 
1458  //go through the runs assigned to this period ...
1459  double lumiSum=0;
1460  for(auto runNum : p->runNumbers) {
1461  lumiSum += m_runs[runNum].inputHists["None"]->GetBinContent(bin);
1462  if(lumiSum >= lumi-0.00001) return runNum; //small difference is to catch rounding errors
1463  }
1464  Error("GetRandomRunNumber","overran integrated luminosity for periodNumber=%d (%f vs %f)",periodNumber,lumiSum,lumi);
1465  throw std::runtime_error("Throwing 46.1: overran integrated luminosity for GetRandomRunNumber");
1466  return 0;
1467 }

◆ GetRandomSeed()

int CP::TPileupReweighting::GetRandomSeed ( )
inlineinherited

Definition at line 223 of file TPileupReweighting.h.

223 {return m_random3->GetSeed();}

◆ GetRunAverageMu()

double CP::TPileupReweighting::GetRunAverageMu ( int  run)
inlineinherited

Definition at line 303 of file TPileupReweighting.h.

303 { return m_runs[run].inputHists["None"]->GetMean(); }

◆ GetRunMap()

std::map<UInt_t, Run>& CP::TPileupReweighting::GetRunMap ( )
inlineinherited

Definition at line 447 of file TPileupReweighting.h.

447 { return m_runs; }

◆ GetSecondaryWeight()

Float_t TPileupReweighting::GetSecondaryWeight ( Int_t  periodNumber,
Int_t  channelNumber,
Float_t  x,
Float_t  y 
)
inherited

Definition at line 1701 of file TPileupReweighting.cxx.

1701  {
1702  //= L_j/L_i / N_j/N_i .. secondary hists have already been normalized
1703  if(!m_isInitialized ) {
1704  if (m_printInfo) Info("GetSecondaryWeight","Initializing the subtool..");
1705  Initialize();
1706  }
1707  if(m_countingMode) return 0.;
1708 
1709  Period* p = m_periods[periodNumber];
1710  if(!p) {
1711  Error("GetSecondaryWeight","Unrecognised periodNumber: %d",periodNumber);
1712  throw std::runtime_error("Throwing 1: Unrecognised periodNumber");
1713  }
1714  if(p->sumOfWeights.find(channelNumber) == p->sumOfWeights.end()) channelNumber = GetDefaultChannel(periodNumber);//p->defaultChannel;
1715  int bin = p->secondaryHists[channelNumber]->FindFixBin(x,y);
1716  double n = p->secondaryHists[channelNumber]->GetBinContent(bin);
1717  double l = p->secondaryHists[-1]->GetBinContent(bin);
1718 
1719  return l/n;
1720 }

◆ GetSumOfEventWeights()

virtual Double_t CP::PileupReweightingTool::GetSumOfEventWeights ( Int_t  channel)
inlinevirtual

helpful alternative to using the EventBookkeepers info ... assuming you made your PRW Config file!!

Implements CP::IPileupReweightingTool.

Definition at line 64 of file PileupReweightingTool.h.

◆ GetUnrepresentedDataFraction()

Double_t TPileupReweighting::GetUnrepresentedDataFraction ( Int_t  periodNumber,
Int_t  channel 
)
inherited

return the unrepresented data fraction in a given channel .

. when using action=2, you will want to scale up all MC events by 1/(1-unrepFraction) to account for missed data

Definition at line 1386 of file TPileupReweighting.cxx.

1386  {
1387 
1388  //return unrepDataByChannel[channel]/GetSumOfEventWeights(-1); //the denominator is equivalent to asking for the total data!
1389 
1390 
1391  Period* p = m_periods[periodNumber];
1392  if(!p) {
1393  Error("GetUnrepresentedDataFraction","Unrecognised periodNumber: %d",periodNumber);
1394  throw std::runtime_error("Throwing 1: Unrecognised periodNumber");
1395  }
1396 
1397  //look for channel through sumOfWeights - because if the channel has no unrepData, it will have no entry in the unrepData map
1398  if(p->sumOfWeights.find(channel) == p->sumOfWeights.end()) channel = GetDefaultChannel(periodNumber);
1399 
1400 
1401  if(p->sumOfWeights.find(channel) == p->sumOfWeights.end()) {
1402  Error("GetUnrepresentedDataFraction","Unrecognised channel: %d",channel);
1403  throw std::runtime_error("GetUnrepresentedDataFraction: Unrecognised channel");
1404  }
1405 
1406  return p->unrepData[channel]/p->sumOfWeights[-1];
1407 
1408 }

◆ getUnrepresentedDataWeight()

float CP::PileupReweightingTool::getUnrepresentedDataWeight ( const xAOD::EventInfo eventInfo)
virtual

When using UnrepresentedDataAction=2, you may want to apply this additional weight to ensure sum of weights are preserved.

Implements CP::IPileupReweightingTool.

Definition at line 412 of file PileupReweightingTool.cxx.

412  {
413  return m_activeTool->GetUnrepresentedDataWeight( eventInfo.runNumber(), eventInfo.mcChannelNumber() );
414 }

◆ GetUnrepresentedDataWeight()

Float_t CP::TPileupReweighting::GetUnrepresentedDataWeight ( Int_t  periodNumber,
Int_t  channel 
)
inlineinherited

Definition at line 134 of file TPileupReweighting.h.

134  {
136  Warning("GetUnrepresentedDataWeight","You should not be applying this weight unless the UnrepresentedDataAction=2");
137  }
138  return 1./(1. - GetUnrepresentedDataFraction(periodNumber,channel));
139  }

◆ IgnoreConfigFilePeriods()

void CP::TPileupReweighting::IgnoreConfigFilePeriods ( Bool_t  in)
inlineinherited

Should the tool ignore period assignments encoded in config file.

Definition at line 146 of file TPileupReweighting.h.

146 { m_ignoreFilePeriods=in; }

◆ initialize()

StatusCode CP::PileupReweightingTool::initialize ( )
virtual

Function initialising the tool.

Reimplemented from asg::AsgTool.

Definition at line 169 of file PileupReweightingTool.cxx.

169  {
170 
171  //set debugging if debugging is on:
173  PrintInfo(msgLvl(MSG::INFO));
174 
175  //convert custom periods vector to a vector of vectors (length 3) ...
176  std::vector<std::vector<int>> customPeriods;
177  for(auto& num : m_customPeriods) {
178  if(customPeriods.size()==0 || customPeriods.back().size()==3) customPeriods.resize(customPeriods.size()+1);
179  customPeriods.back().push_back(num);
180  }
181 
182  for(auto& period : customPeriods) {
183  if(period.size()!=3) {
184  ATH_MSG_FATAL("Recevied period with " << period.size() << " numbers. Period configuration requires 3 numbers: periodNumber, startNumber, endNumber");
185  return StatusCode::FAILURE;
186  }
187  AddPeriod(period[0],period[1],period[2]);
188  }
189 
190  //see if we need variations
191  if(m_upVariation && (m_prwFiles.size()+m_toolLumicalcFiles.size())!=0) {
192  m_upTool.reset( new TPileupReweighting((name()+"_upVariation").c_str()) );
193  m_upTool->PrintInfo(msgLvl(MSG::INFO));
194  m_upTool->SetParentTool(this);
195  m_upTool->CopyProperties(this);
196  m_upTool->SetDataScaleFactors(m_upVariation);
197  for(auto& period : customPeriods) m_upTool->AddPeriod(period[0],period[1],period[2]); //already checked sizes above
198  }
199  if(m_downVariation && (m_prwFiles.size()+m_toolLumicalcFiles.size())!=0) {
200  m_downTool.reset( new TPileupReweighting((name()+"_downVariation").c_str()) );
201  m_downTool->PrintInfo(msgLvl(MSG::INFO));
202  m_downTool->SetParentTool(this);
203  m_downTool->CopyProperties(this);
204  m_downTool->SetDataScaleFactors(m_downVariation);
205  for(auto& period : customPeriods) m_downTool->AddPeriod(period[0],period[1],period[2]); //already checked sizes above
206  }
207 
208  SetDefaultChannel(m_defaultChannel); //handled in GetDefaultChannel method now! if(m_upTool) m_upTool->SetDefaultChannel(m_defaultChannel); if(m_downTool) m_downTool->SetDefaultChannel(m_defaultChannel);
209 
210 
211  //should we set the period config (file maker mode)
212  if(m_prwFiles.size()+m_toolLumicalcFiles.size()==0) {
213  m_inConfigMode=true;
214  ATH_MSG_INFO("In Config file making mode.");
215  if(m_usePeriodConfig!="auto" && m_usePeriodConfig!="") {
216  /*m_tool->*/UsePeriodConfig(m_usePeriodConfig);
217  }
218 #ifndef XAOD_STANDALONE
219  //retrieve histsvc now, otherwise it wont get correctly configured by the time it's used in the finalize ... so it seems
220  ServiceHandle<ITHistSvc> histSvc("THistSvc",name());
221  CHECK( histSvc.retrieve() );
222 #endif
223  } else {
224  //have we any prw to load
225  if(m_prwFiles.size() && m_usePeriodConfig=="auto") {
226  //will override the input config period assignments, will assume PRW is so standardized by r21 that we know best!
228  if(m_upTool) m_upTool->IgnoreConfigFilePeriods(true);
229  if(m_downTool) m_downTool->IgnoreConfigFilePeriods(true);
230  UsePeriodConfig("MC16"); //hardcoded period assignments
231  if(m_upTool) m_upTool->UsePeriodConfig("MC16");
232  if(m_downTool) m_downTool->UsePeriodConfig("MC16");
233  }
234 
235  for(unsigned int j=0;j<m_prwFiles.size();j++) {
236  ATH_MSG_VERBOSE("Locating File: " << m_prwFiles[j]);
237  std::string file = PathResolverFindCalibFile(m_prwFiles[j]);
238  if(file=="") { ATH_MSG_ERROR("Unable to find the PRW Config file: " << m_prwFiles[j]); return StatusCode::FAILURE; }
239  ATH_MSG_VERBOSE("Adding Config file: " << file);
240  /*m_tool->*/AddConfigFile(file.c_str());
241  if(m_upTool) m_upTool->AddConfigFile(file.c_str());
242  if(m_downTool) m_downTool->AddConfigFile(file.c_str());
243  }
244 
245  //have we any lumicalc files to load? .. if we do and had no prwFiles then the user must specify the period configuration
246  if(m_toolLumicalcFiles.size()>0 && m_prwFiles.size()==0) {
247  if(m_usePeriodConfig!="auto" && m_usePeriodConfig!="") {
248  ATH_MSG_INFO("Setting up without a PRW config file, but with period config " << m_usePeriodConfig << ". You will only be able to use random run number and data weight functionality... no reweighting!");
250  ATH_MSG_ERROR("Unrecognised PeriodConfig: " << m_usePeriodConfig); return StatusCode::FAILURE;
251  }
252  m_noWeightsMode=true; //will stop the prw weight being decorated in apply method
253  if(m_upTool) m_upTool->UsePeriodConfig(m_usePeriodConfig);
254  if(m_downTool) m_downTool->UsePeriodConfig(m_usePeriodConfig);
255  } else {
256  ATH_MSG_WARNING("No config files provided, but " << m_toolLumicalcFiles.size() << " lumicalc file provided. Assuming a period config of MC16 ");
257  UsePeriodConfig("MC16");
258  m_noWeightsMode=true; //will stop the prw weight being decorated in apply method
259  if(m_upTool) m_upTool->UsePeriodConfig("MC16");
260  if(m_downTool) m_downTool->UsePeriodConfig("MC16");
261  }
262  }
263 
264  for(unsigned int j=0;j<m_toolLumicalcFiles.size();j++) {
265  //see if there's a trigger at the end of the filename .. format is "file:trigger"
266  TString myFile = m_toolLumicalcFiles[j];
267  TString myTrigger = (myFile.Contains(':')) ? TString(myFile(myFile.Last(':')+1,myFile.Length()-myFile.Last(':'))) : TString("None");
268  myFile = (myFile.Contains(':')) ? TString(myFile(0,myFile.Last(':'))) : myFile;
269  ATH_MSG_VERBOSE("Locating File: " << myFile);
270  std::string file = PathResolverFindCalibFile(myFile.Data());
271  if(file=="") { ATH_MSG_ERROR("Unable to find the Lumicalc file: " << myFile); return StatusCode::FAILURE; }
272  /*m_tool->*/AddLumiCalcFile(file.c_str(),myTrigger);
273  if(m_upTool) m_upTool->AddLumiCalcFile(file.c_str(),myTrigger);
274  if(m_downTool) m_downTool->AddLumiCalcFile(file.c_str(),myTrigger);
275  }
276  }
277 
278  //register ourselves with the systematic registry!
280  if( registry.registerSystematics( *this ) != StatusCode::SUCCESS ) return StatusCode::FAILURE;
281 
282 
283  //delay initializing underlying tool until first usage, just in case user wants to do any advanced initialization options
284 
285  ATH_MSG_DEBUG("Retrieving weight tool...");
286  StatusCode sc = m_weightTool.retrieve();
287  if (sc != StatusCode::SUCCESS) {
288  ATH_MSG_ERROR(" " << m_weightTool->name() << " could not be retrieved.");
289  return sc;
290  }
291  else {
292  ATH_MSG_DEBUG(" " << m_weightTool->name() << " retrieved.");
293  m_weightTool->print();
294  }
295 
296  return StatusCode::SUCCESS;
297 }

◆ Initialize()

Int_t TPileupReweighting::Initialize ( )
inherited

Initialize this class once before the event loop starts If distribution information is provided, it is assumed to be for the standard pileup reweighting.

Definition at line 1021 of file TPileupReweighting.cxx.

1021  {
1022 
1023  //Need to calculate a period weight for each period
1024  //Need a reweighting histogram for each period
1025  //for merged mc run numbers, we must generate or modify the existing mc distributions
1026 
1027  //print out the period assignments if in debug mode
1028  if(m_debugging) {
1029  PrintPeriods();
1030  }
1031 
1032  if(m_countingMode) {
1033  if (m_printInfo) {
1034  Info("Initialize","In Config File Generating mode. Remember to call WriteToFile!");
1035  }
1036  //need to check no periods have subperiods, this is not allowed in counting mode
1037  for(auto period : m_periods) {
1038  if(period.second->subPeriods.size()!=0) {
1039  Error("Initialize","You cannot have subperiods when in Config File Generating mode");
1040  throw std::runtime_error("Throwing 44: In Config File Generating mode, but detected subperiods in the period definition. This is not allowed.");
1041  }
1042  }
1043  //histograms are instantiated in the event loop as the channels occur
1044  //can delay period definition here
1045  m_isInitialized=true;
1046  return 0;
1047  }
1048 
1049  //find all channels that have too much unrepresented data (more than tolerance). We will remove these channels entirely
1050 
1051  std::map<int,std::map<int,bool>> trackWarnings; //map used to avoid reprinting warnings as loop over histogram bins
1052 
1053  double totalData(0);
1054  //count up the unrepresented data, indexed by channel
1055  for(auto& run : m_runs) {
1056  if(run.second.inputHists.find("None") == run.second.inputHists.end()) continue;
1057  TH1* hist = run.second.inputHists["None"].get();
1058  Int_t bin,binx,biny;
1059  for(biny=1; biny<=hist->GetNbinsY(); biny++) {
1060  for(binx=1; binx<=hist->GetNbinsX(); binx++) {
1061  bin = hist->GetBin(binx,biny);
1062  Double_t value = hist->GetBinContent(bin);
1063  totalData += value;
1064  if(value==0.) continue;
1065  bool isUnrep(false);
1066  std::map<Int_t, bool> doneChannels;
1067  for(auto& period : m_periods) {
1068  if(period.first != period.second->id) continue; //skip remappings
1069  if(period.first == -1) continue; //don't look at the global period when calculating unrepresented data
1070  if(!period.second->contains(run.first)) continue;
1071  for(auto& inHist : m_periods[-1]->inputHists) { //use global period to iterate over channels
1072  if(inHist.first<0) continue; //skips any data hists (shouldn't happen really)
1073  if(doneChannels[inHist.first]) continue; //dont doublecount the data if the channel was to blame across multiple period
1074  if(period.second->inputHists.find(inHist.first)==period.second->inputHists.end()) {
1075  //all the data is missing ..
1076  isUnrep=true;doneChannels[inHist.first]=true;
1077  unrepDataByChannel[inHist.first] += value;
1078  if(!trackWarnings[inHist.first][period.first]) {
1079  trackWarnings[inHist.first][period.first]=true;
1080  Warning("Initialize","Channel %d has no configuration for period %d -- this is symptomatic of you trying to reweight an MC campaign to data not intended for that campaign (e.g. MC16a with 2017 data)",inHist.first,period.first);
1081  }
1082  } else if(period.second->inputHists[inHist.first]->GetBinContent(bin)==0) {
1083  //hist for this channel in this period exists, but this bin is empty
1084  isUnrep=true;doneChannels[inHist.first]=true;
1085  unrepDataByChannel[inHist.first] += value;
1086  }
1087  }
1088  }
1089  if(isUnrep) unrepDataByChannel[-1] += value; //store total unrep data
1090  }
1091  }
1092  }
1093 
1094  if(m_ignoreBadChannels && unrepDataByChannel[-1] && totalData && (unrepDataByChannel[-1]/totalData)>m_unrepDataTolerance) {
1095  Warning("Initialize","There is %f%% unrepresented data and 'IgnoreBadChannels' property is set to true. Will start ignoring channels until this is below the tolerance (%f%%)", 100.*(unrepDataByChannel[-1]/totalData),100.*m_unrepDataTolerance);
1096  //remove channels one-by-one until we are under tolerance
1097  while( (unrepDataByChannel[-1]/totalData)>m_unrepDataTolerance ) {
1098  int worstChannel = -1;
1099  double worstFraction = 0;
1100  for(auto& channel : unrepDataByChannel) {
1101  if(channel.first<0) continue; //ignore the data
1102  if(channel.second/totalData > worstFraction) { worstChannel=channel.first; worstFraction = channel.second/totalData; }
1103  }
1104  if(worstChannel==-1) {
1105  Error("Initialize","Run out of channels to remove. All your channels are bad ... oh dear oh dear oh dear. Please a better PRW config file");
1106  throw std::runtime_error("Throwing exception 333: Run out of channels to remove. All your channels are bad ... oh dear oh dear oh dear. Please a better PRW config file");
1107  }
1108 
1109  Warning("Initialize","Ignoring channel %d, which has %f%% unrepresented data (%f%% of the total unrep data)",worstChannel,100.*unrepDataByChannel[worstChannel]/totalData,100.*unrepDataByChannel[worstChannel]/unrepDataByChannel[-1]);
1110  //remove the bad channel
1111  RemoveChannel(worstChannel);
1112  unrepDataByChannel.erase(unrepDataByChannel.find(worstChannel));
1113 
1114  //recalculate the total unrep data
1115  unrepDataByChannel[-1] = 0;
1116  for(auto& run : m_runs) {
1117  if(run.second.inputHists.find("None") == run.second.inputHists.end()) continue;
1118  TH1* hist = run.second.inputHists["None"].get();
1119  Int_t bin,binx,biny;
1120  for(biny=1; biny<=hist->GetNbinsY(); biny++) {
1121  for(binx=1; binx<=hist->GetNbinsX(); binx++) {
1122  bin = hist->GetBin(binx,biny);
1123  Double_t value = hist->GetBinContent(bin);
1124  if(value==0.) continue;
1125  for(auto& period : m_periods) {
1126  if(period.first != period.second->id) continue; //skip remappings
1127  if(!period.second->contains(run.first)) continue;
1128  bool done(false);
1129  for(auto& inHist : period.second->inputHists) {
1130  if(inHist.first<0) continue; //skips any data hists (shouldn't happen really)
1131  if((inHist.second)->GetBinContent(bin)==0) {
1132  unrepDataByChannel[-1] += value; done=true; break;
1133  }
1134  }
1135  if(done) break;
1136  }
1137  }
1138  }
1139  }
1140  }
1141  }
1142 
1143 
1144  //need a CompositeTrigger to hold the unprescaled lumi hists ...
1145  m_triggerObjs["None"] = std::make_unique< CompositeTrigger >();
1146 
1147  //go through all periods, use inputHists to populate the primary and secondary dists, and fill sumOfWeights and numberOfEntries
1148  for(auto period : m_periods) {
1149  if(period.first != period.second->id) continue; //skips remappings
1150  for(auto& inputHist : period.second->inputHists) {
1151  int channel = inputHist.first;
1152  TH1* hist = inputHist.second.get();
1153  period.second->sumOfWeights[channel] += hist->GetSumOfWeights();
1154  period.second->numberOfEntries[channel] += hist->GetEntries();
1155  if(hist->GetDimension()==1) {
1156  period.second->primaryHists[channel] = CloneEmptyHistogram(period.first,channel);
1157  period.second->primaryHists[channel]->Add(hist);
1158  }
1159  }
1160  //also add all runs that belong to us ... only do the "None" trigger
1161  for(auto& run : m_runs) {
1162  if(!period.second->contains(run.first)) continue;
1163  if(run.second.inputHists.find("None") == run.second.inputHists.end()) continue;
1164  //add to list of runNumbers for this period
1165  period.second->runNumbers.push_back(run.first);
1166  TH1* hist = run.second.inputHists["None"].get();
1167 
1168  //sweep over bins, checking for unrepresented data and acting accordingly
1169  Int_t bin,binx,biny;
1170  for(biny=1; biny<=hist->GetNbinsY(); biny++) {
1171  for(binx=1; binx<=hist->GetNbinsX(); binx++) {
1172  bin = hist->GetBin(binx,biny);
1173  Double_t value = hist->GetBinContent(bin);
1174  if(value==0.) continue;
1175  //loop over channels, check for zero in this bin ... only need to do if we haven't checked ourselves
1176  if(period.second->inputBinRedirect.find(bin) == period.second->inputBinRedirect.end()) {
1177  for(auto& inputHist : period.second->inputHists) {
1178  if(inputHist.first<0) continue; //skips data
1179  Double_t mcValue = (inputHist.second)->GetBinContent(bin);
1180  if(mcValue==0.) {
1182  Info("Initialize","Unrepresented data at coords [%f,%f] caused by periodNumber %d in channel %d",hist->GetXaxis()->GetBinCenter(binx),hist->GetYaxis()->GetBinCenter(biny),period.first,inputHist.first);
1183  }
1184  //if we are doing unrepaction=2, just set to 'not the bin number'. if we are doing action=3, find the nearest good bin
1185  if(m_unrepresentedDataAction==0) {period.second->inputBinRedirect[bin] = bin-1;Error("Initialize","Unrepresented data at coords [%f,%f] caused by periodNumber %d in channel %d",hist->GetXaxis()->GetBinCenter(binx),hist->GetYaxis()->GetBinCenter(biny),period.first,inputHist.first);}
1186  if(m_unrepresentedDataAction==1||m_unrepresentedDataAction==2) period.second->inputBinRedirect[bin] = bin-1;
1187  else if(m_unrepresentedDataAction==3) period.second->inputBinRedirect[bin] = GetNearestGoodBin(period.first, bin);
1188  break;
1189  }
1190  }
1191  if(period.second->inputBinRedirect.find(bin) == period.second->inputBinRedirect.end()) period.second->inputBinRedirect[bin] = bin; //a good bin
1192  }
1193  //if is a bad bin, act accordingly
1194  if(period.second->inputBinRedirect[bin] != bin) {
1195  run.second.badBins[bin]=value;
1196  if(m_unrepresentedDataAction==1) {
1197  //remove this data. we have to remember to do this for the trigger data too if this is the pileup weight
1198  hist->SetBinContent(bin,0);
1199  //also modify the m_inputTriggerHistograms ...
1200  for(auto& triggerDists : run.second.inputHists) triggerDists.second->SetBinContent(bin,0);
1201  } else if(m_unrepresentedDataAction==3) {
1202  //reassign the content to that bin
1203  hist->SetBinContent(period.second->inputBinRedirect[bin],hist->GetBinContent(period.second->inputBinRedirect[bin])+hist->GetBinContent(bin));
1204  hist->SetBinContent(bin,0);
1205  //also modify the m_inputTriggerHistograms ...
1206  for(auto& triggerDists : run.second.inputHists) {
1207  triggerDists.second->SetBinContent(period.second->inputBinRedirect[bin],triggerDists.second->GetBinContent(period.second->inputBinRedirect[bin])+triggerDists.second->GetBinContent(bin));
1208  triggerDists.second->SetBinContent(bin,0);
1209  }
1210  }
1211  }
1212  }
1213  }
1214 
1215  //ensure hist is normalized correctly, if was read in from the 'actual mu' config files (where the normalization can be slightly wrong)
1216  if(run.second.nominalFromHists) {
1217  //get the total lumi for the run ...
1218  double totLumi(0);
1219  for(auto lb : run.second.lumiByLbn) {
1220  totLumi += lb.second.first;
1221  }
1222  const double integral = hist->Integral();
1223  if (std::abs(integral) > 0.) {
1224  hist->Scale(totLumi / integral);
1225  }
1226 
1227  }
1228 
1229  //create the period's 'data' hist if necessary
1230  if( hist->GetDimension()==1 ) {
1231  if(!period.second->primaryHists[-1] ) {
1232  period.second->primaryHists[-1] = CloneEmptyHistogram(period.first,-1);
1233 
1234  //this will remain unnormalized, unlike the 'primaryHist'
1235  m_triggerObjs["None"]->triggerHists[period.second->id][0] =
1237  }
1238  }
1239  else if( hist->GetDimension()==2 ) {
1240  if(!period.second->secondaryHists[-1] ) {
1241  auto h = CloneEmptyHistogram(period.first,-1);
1242  period.second->secondaryHists[-1].reset( dynamic_cast< TH2* >( h.release() ) );
1243  period.second->primaryHists[-1].reset(
1244  period.second->secondaryHists[-1]->ProjectionX() );
1245  period.second->primaryHists[-1]->SetDirectory(0);
1246  period.second->primaryHists[-1]->Reset();
1247  m_triggerObjs["None"]->triggerHists[period.second->id][0].reset(
1248  static_cast<TH1*>(period.second->primaryHists[-1]->Clone("triggerHist")) );
1249  m_triggerObjs["None"]->triggerHists[period.second->id][0]->SetDirectory(0);
1250  }
1251 
1252  }
1253 
1254  }
1255 
1256  }
1257 
1258 
1259  //now that all periods and runs have been checked, with redirects set up where necessary, we actually accumulate the data across the runs
1260  //we should also check if there are any data runs that are not covered by the period assignments
1261 
1262  double ignoredData(0);
1263  for(auto& run : m_runs) {
1264  bool covered(false);
1265  TH1* hist = run.second.inputHists["None"].get();
1266  for(auto& period : m_periods) {
1267  if(!period.second->contains(run.first)) continue;
1268  if(period.first!=-1) covered=true; //don't count the global period
1269  if(hist->GetDimension()==1) {
1270  period.second->primaryHists[-1]->Add(hist);
1271  m_triggerObjs["None"]->triggerHists[period.second->id][0]->Add(hist);
1272  } else if(hist->GetDimension()==2) {
1273  period.second->secondaryHists[-1]->Add(hist);
1274  TH1* proj = ((TH2*)hist)->ProjectionX();
1275  period.second->primaryHists[-1]->Add(proj);
1276  m_triggerObjs["None"]->triggerHists[period.second->id][0]->Add(proj);
1277  delete proj;
1278  }
1279  period.second->sumOfWeights[-1] += hist->GetSumOfWeights();
1280  period.second->numberOfEntries[-1] += hist->GetEntries();
1281  }
1282  if(!covered && m_periods.size()>1) {
1283  Warning("Initialize","loaded data in run %d that is not covered by period assignments",run.first);
1284  ignoredData += hist->GetSumOfWeights();
1285  }
1286  }
1287  //double totalData = (m_unrepresentedDataAction==1) ? (m_periods[-1]->sumOfWeights[-1]+unrepDataByChannel[-1]) : m_periods[-1]->sumOfWeights[-1];
1288 
1289  if(ignoredData>0.) Warning("Initialize", "Period Assignments missed %f%% data",100.*ignoredData/totalData);
1290 
1291 
1292 
1293  if(unrepDataByChannel[-1]) {
1294  double frac = unrepDataByChannel[-1]/totalData;
1295  if( frac > m_unrepDataTolerance) {
1296  Error("Initialize", "%f%% unrepresented data, which suggests something is wrong with your prw config. Try EnableDebugging(true) to investigate",100.* (unrepDataByChannel[-1]/totalData));
1297  }
1298  if(m_unrepresentedDataAction==1) {
1299  Warning("Initialize","has %f%% unrepresented data. This was removed (UnrepresentedDataAction=1)",100.*frac);
1300  } else if(m_unrepresentedDataAction==2) {
1301  Warning("Initialize","has %f%% unrepresented data. This was kept in (UnrepresentedDataAction=2)",100.*frac);
1302  } else if(m_unrepresentedDataAction==3) {
1303  Warning("Initialize","has %f%% unrepresented data. This was reassigned (UnrepresentedDataAction=3)",100.*frac);
1304  } else if(m_unrepresentedDataAction==0) {
1305  Error("Initialize","has %f%% unrepresented data:",100.*frac);
1306  //print the report of which channels caused it
1307  for(auto& it : unrepDataByChannel) {
1308  if(it.first<0) continue; //ignore data
1309  Error("Initialize"," Channel %d caused %f%% of the unrepresented data (nEntries=%d)",it.first,100.*it.second/unrepDataByChannel[-1],m_periods[-1]->numberOfEntries[it.first]);
1310  }
1311  Error("Initialize","Exiting. You must decide how to proceed...");
1312  Error("Initialize","1) use AddPeriod or RemapPeriod to redefine the mc periods to include this data. You should not need to regenerate your mc config file");
1313  Error("Initialize","2) use SetUnrepresentedDataAction(1) to remove this data from the weight calculations. You should also veto such data events (using IsUnrepresentedData(..,..) method)");
1314  Error("Initialize","3) use SetUnrepresentedDataAction(2) to leave this data in the calculation. I hope you know what you're doing!!");
1315  Error("Initialize","4) use SetUnrepresentedDataAction(3) to reassign the data to the nearest representable bin");
1316  throw std::runtime_error("Throwing exception 22: Unrepresented data exists. Make a choice how to handle this. See err log for details");
1317  }
1318  //if get here, through the exception if frac is bad
1319  if( frac > m_unrepDataTolerance) {
1320  throw std::runtime_error("Throwing exception 222: Some channel had too much unrepresented data. You should fix your prw file");
1321  }
1322  }
1323 
1324 
1325  if(m_debugging && m_printInfo) Info("Initialize","Normalizing histograms and cleaning up...");
1326  //now that all the distributions are built. Normalize them all
1327  for(auto period : m_periods) {
1328  if(period.first != period.second->id) continue;
1329  for(auto& pHist : period.second->primaryHists) {
1330  normalizeHistogram(pHist.second.get());
1331  }
1332  for(auto& pHist : period.second->secondaryHists) {
1333  normalizeHistogram(pHist.second.get());
1334  }
1335  period.second->inputHists.clear();
1336  }
1337 
1338  //we keep the inputHists for data, because can use that to do random run numbers based on mu
1339 
1340  if(m_debugging && m_printInfo) Info("Initialize","...Done");
1341  //if no input histograms were added, we are in counting mode
1342 
1343 
1344  m_isInitialized=true;
1345 
1346  return 0;
1347 }

◆ inputHandles()

virtual std::vector<Gaudi::DataHandle*> AthCommonDataStore< AthCommonMsg< AlgTool > >::inputHandles ( ) const
overridevirtualinherited

Return this algorithm's input handles.

We override this to include handle instances from key arrays if they have not yet been declared. See comments on updateVHKA.

◆ isAffectedBySystematic()

bool CP::PileupReweightingTool::isAffectedBySystematic ( const CP::SystematicVariation systematic) const
virtual

The ISystematicsTool methods.

Implements CP::ISystematicsTool.

Definition at line 115 of file PileupReweightingTool.cxx.

115  {
116  CP::SystematicSet sys = affectingSystematics(); return sys.find( systematic ) != sys.end();
117 }

◆ IsBadBin()

Int_t TPileupReweighting::IsBadBin ( Int_t  thisMCRunNumber,
Int_t  bin 
)
protectedinherited

Definition at line 1351 of file TPileupReweighting.cxx.

1351  {
1352 
1353  if(bin<0) return 2; //out of range
1354 
1355  Period* p = m_periods[periodNumber];
1356  for(auto& inHist : p->inputHists) {
1357  int channelNumber = inHist.first;
1358  if(channelNumber<0) continue; //skip data hists
1359  if(bin > (inHist.second->GetNbinsX()+2)*(inHist.second->GetNbinsY()+2)*(inHist.second->GetNbinsZ()+2)) return 2; //definitely out of range by this point!
1360  if(inHist.second->GetBinContent(bin)==0) return 1;
1361  }
1362  return 0;
1363 
1364 }

◆ IsInitialized()

Bool_t CP::TPileupReweighting::IsInitialized ( )
inlineinherited

Definition at line 288 of file TPileupReweighting.h.

288 { return m_isInitialized; }

◆ IsUnrepresentedData()

Bool_t TPileupReweighting::IsUnrepresentedData ( Int_t  runNumber,
Float_t  x,
Float_t  y = 0. 
)
inherited

Definition at line 1524 of file TPileupReweighting.cxx.

1524  {
1525  int bin = m_emptyHistogram->FindFixBin(x,y);
1526  return ( m_runs[runNumber].badBins[bin] );
1527 }

◆ makeTrigger()

std::unique_ptr< CP::TPileupReweighting::CompositeTrigger > TPileupReweighting::makeTrigger ( const TString &  s)
protectedinherited

Definition at line 2278 of file TPileupReweighting.cxx.

2278  {
2279 
2280  if( m_debugging && m_printInfo ) {
2281  Info( "makeTrigger", "Doing %s", s.Data() );
2282  }
2283 
2284  // Find the first operand
2285  TString oper1;
2286  std::unique_ptr< CompositeTrigger > cOper1;
2287  if( s.BeginsWith( "(" ) ) {
2288  // Find closing bracket
2289  int bCounter=1; int i=1;
2290  while( ( bCounter != 0 ) && ( i <= s.Length() ) ) {
2291  if( s( i ) == '(' ) {
2292  bCounter++;
2293  } else if( s( i ) == ')' ) {
2294  bCounter--;
2295  }
2296  i++;
2297  }
2298  if( bCounter != 0 ) {
2299  Error( "makeTrigger", "Missing closing bracket" );
2300  return std::unique_ptr< CompositeTrigger >();
2301  }
2302  oper1 = s( 1, i - 2 );
2303  if( i == s.Length() + 1 ) {
2304  return makeTrigger( oper1 ); //meainingless brackets, just return evaluation
2305  } else {
2306  cOper1 = makeTrigger( oper1 );
2307  if( ! cOper1 ) {
2308  return 0;
2309  }
2310  }
2311  }
2312 
2313  // Find the second operand. Do this by finding the first operation at
2314  // this level. If cannot find, then just set val
2315  int i=0;int bCounter=0; int op=0;
2316  while( i <= s.Length() ) {
2317  if( s( i ) == '(' ) {
2318  bCounter++;
2319  } else if( s( i ) == ')' ) {
2320  bCounter--;
2321  } else if( ( s( i ) == '&' ) && ( bCounter == 0 ) ) {
2322  op = 2;
2323  break;
2324  } else if( ( s( i ) == '|' ) && ( bCounter == 0 ) ) {
2325  op = 1;
2326  break;
2327  }
2328  i++;
2329  }
2330 
2331 
2332  if( op == 0 ) {
2333  if( m_lumicalcFiles.find( s ) == m_lumicalcFiles.end() ) {
2334  Error( "GetDataWeight", "Could not find subTrigger %s", s.Data() );
2335  return std::unique_ptr< CompositeTrigger >();
2336  }
2337  if( cOper1 ) {
2338  return cOper1;
2339  }
2340  auto out = std::make_unique< CompositeTrigger >();
2341  out->op = op;
2342  out->val = s;
2343  return out; //just a value trigger
2344  }
2345 
2346  auto out = std::make_unique< CompositeTrigger >();
2347  out->op = op;
2348 
2349  if( op == 1 ) { //an OR
2350  if( cOper1 ) {
2351  out->trig1 = std::move( cOper1 );
2352  } else {
2353  oper1 = s( 0, i );
2354  out->trig1 = makeTrigger( oper1 );
2355  if( ! out->trig1 ) {
2356  return std::unique_ptr< CompositeTrigger >();
2357  }
2358  }
2359  TString oper2 = s( i + 1, s.Length() );
2360  out->trig2 = makeTrigger( oper2 );
2361  if( ! out->trig2 ) {
2362  return std::unique_ptr< CompositeTrigger >();
2363  }
2364  return out;
2365  }
2366 
2367  // Got here, must be an AND keep going until we hit an OR at this level,
2368  // then make all that the first operand (delete cOper if necessary)
2369  int j = i;
2370  bCounter = 0;
2371  while( j <= s.Length() ) {
2372  if( s( j ) == '(' ) {
2373  bCounter++;
2374  } else if( s( j )== ')' ) {
2375  bCounter--;
2376  } else if( ( s( j ) == '|' ) && ( bCounter == 0 ) ) {
2377  op=1;
2378  break;
2379  }
2380  j++;
2381  }
2382  if( ( j == s.Length() + 1 ) && ( op == 2 ) ) { //no more OR found, set oper2 to remainder
2383  if( cOper1 ) {
2384  out->trig1 = std::move( cOper1 );
2385  } else {
2386  oper1 = s( 0, i );
2387  out->trig1 = makeTrigger( oper1 );
2388  }
2389  TString oper2 = s( i + 1, s.Length() );
2390  if( m_debugging && m_printInfo ) {
2391  Info( "makeTrigger", "Found & %s %s", oper1.Data(), oper2.Data() );
2392  }
2393  out->trig2 = makeTrigger( oper2 );
2394  if( ! out->trig2 ) {
2395  return std::unique_ptr< CompositeTrigger >();
2396  }
2397  return out;
2398  } else if( op ==1 ) { //found an OR, set oper1 to everything up to this
2399 
2400  oper1 = s( 0, j );
2401  TString oper2 = s( j + 1, s.Length() );
2402  if( m_debugging && m_printInfo ) {
2403  Info( "makeTrigger", "Found & then | %s %s", oper1.Data(),
2404  oper2.Data() );
2405  }
2406  out->op = op; //updates to an OR
2407  out->trig1 = makeTrigger( oper1 );
2408  if( ! out->trig1 ) {
2409  return std::unique_ptr< CompositeTrigger >();
2410  }
2411  out->trig2 = makeTrigger( oper2 );
2412  if( ! out->trig2 ) {
2413  return std::unique_ptr< CompositeTrigger >();
2414  }
2415  return out;
2416  }
2417  Error( "makeTrigger", "Should never have got here!, but did with %s",
2418  s.Data() );
2419  return std::unique_ptr< CompositeTrigger >();
2420 }

◆ MakeWeightTree()

Bool_t TPileupReweighting::MakeWeightTree ( TString  channelNumbers,
TString  outFile,
TString  hashBranch = "PRWHash",
TString  weightBranch = "PileupWeight" 
)
inherited

Definition at line 1530 of file TPileupReweighting.cxx.

1530  {
1531  if(!m_isInitialized ) {
1532  if (m_printInfo) Info("MakeWeightTree","Initializing the subtool..");
1533  Initialize();
1534  }
1535  TH1* hist = m_emptyHistogram.get();
1536  if(!hist) {
1537  Error("MakeWeightTree","Tool not configured properly ... please report this!");
1538  throw std::runtime_error("Throwing 47: Tool not configured properly ... please report this!");
1539  }
1540 
1541  //loop over given channels, and loop over all periods (except the global period) and get the pileup weight in each case for each bin
1542  TFile f1(outFile,"RECREATE");
1543 
1544  TTree* outTree = new TTree("prwTree","prwTree");
1545  ULong64_t prwHash(0);Float_t weight(0.);
1546  outTree->Branch(hashBranch,&prwHash);
1547  outTree->Branch(weightBranch,&weight);
1548 
1549  TObjArray *tx = channelNumbers.Tokenize(",");
1550  for (Int_t i = 0; i < tx->GetEntries(); i++) {
1551  int channelNumber = ((TObjString *)(tx->At(i)))->String().Atoi();
1552  if(channelNumber>999999 || channelNumber<0) {
1553  Error("MakeWeightTree","ChannelNumber can not be bigger than 999999 or less than 0 ... got %d",channelNumber);
1554  f1.Close();
1555  return 0;
1556  }
1557  for(auto& period : m_periods) {
1558  if(period.first==-1) continue;
1559  int periodNumber = period.first;
1560  for(int i=1;i<=hist->GetNbinsX();i++) {
1561  double x = hist->GetXaxis()->GetBinCenter(i);
1562  for(int j=1;j<=hist->GetNbinsY();j++) {
1563  double y = hist->GetYaxis()->GetBinCenter(j);
1564  weight = GetCombinedWeight(periodNumber,channelNumber,x,y);
1565  prwHash = GetPRWHash(periodNumber,channelNumber,x,y);
1566  outTree->Fill();
1567  }
1568  }
1569 
1570  }
1571  }
1572 
1573  outTree->BuildIndex(hashBranch.Data());
1574  outTree->Write();
1575  f1.Close();
1576 
1577  if (m_printInfo) {
1578  Info("MakeWeightTree","Successfully wrote prwTree to %s",outFile.Data());
1579  }
1580 
1581  return true;
1582 }

◆ Merge()

Int_t TPileupReweighting::Merge ( TCollection *  coll)
inherited

Definition at line 2039 of file TPileupReweighting.cxx.

2039  {
2040  if(!coll) return 0;
2041  if(coll->IsEmpty()) return 0;
2042 
2043  // Iterate over the elements of the collection:
2044  TIter next( coll );
2045  TObject* obj = 0;
2046  while( ( obj = next() ) ) {
2047 
2048  // Check that the element is of the right type:
2049  CP::TPileupReweighting* vobj = dynamic_cast< CP::TPileupReweighting* >( obj );
2050  if( ! vobj ) {
2051  Error( "Merge", "Unknown object type encountered: %s",obj->ClassName() );
2052  return 0;
2053  }
2054 
2055  //merge the inputHistograms ... all the periods should be identical
2056  for(auto period : vobj->m_periods) {
2057  if(period.first != period.second->id) continue;
2058  for(auto& iHist : period.second->inputHists) {
2059  if(GetInputHistogram(period.first,iHist.first)==0) {
2060  m_periods[period.first]->inputHists[iHist.first].reset(
2061  dynamic_cast<TH1*>(iHist.second->Clone(iHist.second->GetName())) );
2062  m_periods[period.first]->inputHists[iHist.first]->SetDirectory(0);
2063  } else {
2064  GetInputHistogram(period.first,iHist.first)->Add(iHist.second.get());
2065  }
2066  }
2067  }
2068  //also must remember to merge the runs too (where the data is held)
2069  for(auto& run : vobj->m_runs) {
2070  for(auto& iHist : run.second.inputHists) {
2071  if( ! m_runs[run.first].inputHists[iHist.first] ) {
2072  m_runs[run.first].inputHists[iHist.first].reset(
2073  dynamic_cast<TH1*>( iHist.second->Clone(iHist.second->GetName())) );
2074  m_runs[run.first].inputHists[iHist.first]->SetDirectory(0);
2075  } else {
2076  m_runs[run.first].inputHists[iHist.first]->Add(iHist.second.get());
2077  }
2078  }
2079  }
2080  }
2081 
2082  return 1;
2083 }

◆ msg() [1/2]

MsgStream& AthCommonMsg< AlgTool >::msg ( ) const
inlineinherited

Definition at line 24 of file AthCommonMsg.h.

24  {
25  return this->msgStream();
26  }

◆ msg() [2/2]

MsgStream& AthCommonMsg< AlgTool >::msg ( const MSG::Level  lvl) const
inlineinherited

Definition at line 27 of file AthCommonMsg.h.

27  {
28  return this->msgStream(lvl);
29  }

◆ msg_level_name()

const std::string & asg::AsgTool::msg_level_name ( ) const
inherited

A deprecated function for getting the message level's name.

Instead of using this, weirdly named function, user code should get the string name of the current minimum message level (in case they really need it...), with:

MSG::name( msg().level() )

This function's name doesn't follow the ATLAS coding rules, and as such will be removed in the not too distant future.

Returns
The string name of the current minimum message level that's printed

Definition at line 101 of file AsgTool.cxx.

101  {
102 
103  return MSG::name( msg().level() );
104  }

◆ msgLvl()

bool AthCommonMsg< AlgTool >::msgLvl ( const MSG::Level  lvl) const
inlineinherited

Definition at line 30 of file AthCommonMsg.h.

30  {
31  return this->msgLevel(lvl);
32  }

◆ normalizeHistogram()

void TPileupReweighting::normalizeHistogram ( TH1 *  histo)
protectedinherited

Normalize histograms.

Definition at line 1996 of file TPileupReweighting.cxx.

1996  {
1997  // normalize the data histogram based on which sort of histogram it is
1998  if(hist){
1999  if(hist->InheritsFrom("TH3")) {
2000  Error("normalizeHistogram","3D reweighting not supported yet");
2001  throw std::runtime_error("Throwing 3: 3D reweighting not supported yet");
2002  }
2003  else if(hist->InheritsFrom("TH2")) {
2004  bool skipNorm=false;
2005  //normalize each bin according to the projection in x
2006  TH1D* proj = ((TH2*)hist)->ProjectionX();
2007  Int_t bin,binx,biny,binz;
2008  for(binz=1; binz<=hist->GetNbinsZ(); binz++) {
2009  for(biny=1; biny<=hist->GetNbinsY(); biny++) {
2010  for(binx=1; binx<=hist->GetNbinsX(); binx++) {
2011  bin = hist->GetBin(binx,biny,binz);
2012  Double_t value = hist->GetBinContent(bin);
2013  Double_t normalizer = proj->GetBinContent(binx);
2014  if(normalizer!=0.0) {
2015  hist->SetBinContent(bin,value/normalizer);
2016  } else {
2017  skipNorm=true;
2018  }
2019  }
2020  }
2021  }
2022  delete proj;
2023  if(skipNorm && m_debugging) Warning("normalizeHistogram","Skipped normalization in hist %s",hist->GetName());
2024  } else {
2025  //normalize to the sum of weights
2026  if(hist->GetSumOfWeights()!=0.0) {
2027  hist->Scale(1.0/hist->GetSumOfWeights());
2028  } else {
2029  if (m_debugging) Warning("normalizeHistogram","Skipping Normalizing histogram %s to ~zero: %f",hist->GetName(),hist->GetSumOfWeights());
2030  }
2031  }
2032  } else {
2033  Error("normalizeHistogram","Non existent histogram for normalizing");throw std::runtime_error("Throwing 56");
2034  }
2035 }

◆ outputHandles()

virtual std::vector<Gaudi::DataHandle*> AthCommonDataStore< AthCommonMsg< AlgTool > >::outputHandles ( ) const
overridevirtualinherited

Return this algorithm's output handles.

We override this to include handle instances from key arrays if they have not yet been declared. See comments on updateVHKA.

◆ passTriggerBeforePrescale()

bool CP::PileupReweightingTool::passTriggerBeforePrescale ( const TString &  trigger) const
protectedvirtual

Reimplemented from CP::TPileupReweighting.

Definition at line 106 of file PileupReweightingTool.cxx.

106  {
107  if(m_tdt.empty()) return TPileupReweighting::passTriggerBeforePrescale(trigger);
108  ATH_MSG_VERBOSE("Checking tdt decision of " << trigger);
109  //Note that the trigger *must* be a rerun trigger if this result is to be valid ... could check this in the trigconf is absolutely necessary
110  //but for now we just assume it's a rerun
111  //if it's not rerun, all we will get back here is the TAP result
112  return m_tdt->isPassed( trigger.Data() , TrigDefs::Physics | TrigDefs::allowResurrectedDecision ); // Definitions in TrigDecisionInterface/Conditions.h
113 }

◆ print()

void asg::AsgTool::print ( ) const
virtualinherited

◆ PrintInfo()

void CP::TPileupReweighting::PrintInfo ( Bool_t  in)
inlineinherited

disable info

Definition at line 120 of file TPileupReweighting.h.

120 { m_printInfo = in; }

◆ PrintPeriods()

void CP::TPileupReweighting::PrintPeriods ( )
inlineinherited

Definition at line 407 of file TPileupReweighting.h.

407 { for(auto p : m_periods) {std::cout << p.first << " -> "; p.second->print("");} }

◆ recommendedSystematics()

CP::SystematicSet CP::PileupReweightingTool::recommendedSystematics ( ) const
virtual

the list of all systematics this tool recommends to use

Implements CP::IReentrantSystematicsTool.

Definition at line 126 of file PileupReweightingTool.cxx.

126  {
127  return affectingSystematics();
128 }

◆ RemapPeriod()

void TPileupReweighting::RemapPeriod ( Int_t  periodNumber1,
Int_t  periodNumber2 
)
inherited

Combine two period numbers.

Histos are merged and the first number will be redirected to the second (the second is created if it doesn't exist)

Definition at line 63 of file TPileupReweighting.cxx.

63  {
64  //check if periodNumber2 exists
65  if(m_periods.find(periodNumber2)==m_periods.end()) {
66  m_periodList.emplace_back( periodNumber2, 0, 0, GetDefaultChannel(-1) );
67  m_periods[periodNumber2] = &( m_periodList.back() );
68  }
69  m_periods[periodNumber1] = m_periods[periodNumber2];
70 }

◆ RemoveChannel()

Bool_t TPileupReweighting::RemoveChannel ( int  chanNum)
inherited

Removes a channel from the inputs ...

this is for experts only

Definition at line 1001 of file TPileupReweighting.cxx.

1001  {
1002  if(m_isInitialized) {
1003  Error("RemoveChannel","You cannot RemoveChannel after initializing the tool. Reorder your code!");
1004  throw std::runtime_error("Throwing 5: You cannot RemoveChannel after initializing the tool. Reorder your code!");
1005  }
1006 
1007  bool found(false);
1008  for(auto& period : m_periods) {
1009  auto itr = period.second->inputHists.begin();
1010  while(itr != period.second->inputHists.end()) {
1011  if(itr->first!=chanNum) ++itr;
1012  else {
1013  found=true;
1014  itr = period.second->inputHists.erase(itr);
1015  }
1016  }
1017  }
1018  return found;
1019 }

◆ renounce()

std::enable_if_t<std::is_void_v<std::result_of_t<decltype(&T::renounce)(T)> > && !std::is_base_of_v<SG::VarHandleKeyArray, T> && std::is_base_of_v<Gaudi::DataHandle, T>, void> AthCommonDataStore< AthCommonMsg< AlgTool > >::renounce ( T &  h)
inlineprotectedinherited

Definition at line 380 of file AthCommonDataStore.h.

381  {
382  h.renounce();
383  PBASE::renounce (h);
384  }

◆ renounceArray()

void AthCommonDataStore< AthCommonMsg< AlgTool > >::renounceArray ( SG::VarHandleKeyArray handlesArray)
inlineprotectedinherited

remove all handles from I/O resolution

Definition at line 364 of file AthCommonDataStore.h.

364  {
365  handlesArray.renounce();
366  }

◆ ResetCountingMode()

void CP::TPileupReweighting::ResetCountingMode ( )
inlineinherited

This method is DEFINITELY EXPERT USE ONLY.

Used in the checkPRWConfigFile utitlity

Definition at line 293 of file TPileupReweighting.h.

293 { m_countingMode=true; }

◆ ResetTriggerBits()

void CP::TPileupReweighting::ResetTriggerBits ( )
inlineinherited

Definition at line 301 of file TPileupReweighting.h.

301 { m_triggerPassBits.clear(); }

◆ runLbnOK()

bool CP::PileupReweightingTool::runLbnOK ( Int_t  runNbr,
Int_t  lbn 
)
protectedvirtual

Reimplemented from CP::TPileupReweighting.

Definition at line 101 of file PileupReweightingTool.cxx.

101  {
102  if(m_grlTool.empty()) return true;
103  return m_grlTool->passRunLB(runNbr,lbn);
104 }

◆ SetBinning() [1/2]

virtual Int_t CP::PileupReweightingTool::SetBinning ( Int_t  nbinsx,
Double_t *  xbins,
Int_t  nbinsy = 0,
Double_t *  ybins = 0 
)
inlinevirtual

Implements CP::IPileupReweightingTool.

Definition at line 60 of file PileupReweightingTool.h.

60 { return m_activeTool->SetBinning(nbinsx, xbins, nbinsy, ybins); }

◆ SetBinning() [2/2]

virtual Int_t CP::PileupReweightingTool::SetBinning ( TH1 *  hist)
inlinevirtual

Implements CP::IPileupReweightingTool.

Definition at line 62 of file PileupReweightingTool.h.

62 { return m_activeTool->SetBinning(hist); }

◆ SetDataScaleFactors()

void CP::TPileupReweighting::SetDataScaleFactors ( Float_t  x,
Float_t  y = 1. 
)
inlineinherited

Scale the LumiMetaData mu values by this factor.

Definition at line 156 of file TPileupReweighting.h.

◆ SetDefaultChannel()

void TPileupReweighting::SetDefaultChannel ( Int_t  channel,
Int_t  mcRunNumber = -1 
)
inherited

Set which channel should be used as a default when specific mc channel distributions cannot be found.

default channels can now be assigned for each mc run number .. mcRunNumber=-1 is the global default

Definition at line 72 of file TPileupReweighting.cxx.

72  {
73  //check if periodNumber2 exists
74  if(m_periods.find(periodNumber)==m_periods.end()) {
75  m_periodList.emplace_back( periodNumber, 0, 0, channel );
76  m_periods[periodNumber] = &( m_periodList.back() );
77  } else {
78  m_periods[periodNumber]->SetDefaultChannel(channel);
79  }
80 }

◆ SetMCScaleFactors()

void CP::TPileupReweighting::SetMCScaleFactors ( Float_t  x,
Float_t  y = 1. 
)
inlineinherited

Definition at line 157 of file TPileupReweighting.h.

◆ SetParentTool()

void CP::TPileupReweighting::SetParentTool ( TPileupReweighting tool)
inlineinherited

Definition at line 296 of file TPileupReweighting.h.

296 { m_parentTool = tool; }

◆ SetRandomSeed()

void CP::TPileupReweighting::SetRandomSeed ( int  seed)
inlineinherited

Definition at line 222 of file TPileupReweighting.h.

222 {m_random3->SetSeed(seed);}

◆ SetTriggerBit()

void CP::TPileupReweighting::SetTriggerBit ( const TString &  trigger,
bool  in = true 
)
inlineinherited

Definition at line 300 of file TPileupReweighting.h.

300 { m_triggerPassBits[trigger]=in; }

◆ SetUniformBinning()

virtual Int_t CP::PileupReweightingTool::SetUniformBinning ( Int_t  nbinsx,
Double_t  xlow,
Double_t  xup,
Int_t  nbinsy = 0,
Double_t  ylow = 0,
Double_t  yup = 0 
)
inlinevirtual

Implements CP::IPileupReweightingTool.

Definition at line 61 of file PileupReweightingTool.h.

61 { return m_activeTool->SetUniformBinning(nbinsx, xlow, xup, nbinsy, ylow, yup); }

◆ SetUnrepresentedDataAction()

void CP::TPileupReweighting::SetUnrepresentedDataAction ( Int_t  action,
Double_t  tolerance = 0.05 
)
inlineinherited

Set how to handle configurations where some of your data has no corresponding mc to describe it 0=Default (Throw exception), 1=Subtract lumi from normalizations (i.e.

discard data), 2=keep lumi and continue

Definition at line 124 of file TPileupReweighting.h.

124  {
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  }

◆ sysInitialize()

virtual StatusCode AthCommonDataStore< AthCommonMsg< AlgTool > >::sysInitialize ( )
overridevirtualinherited

Perform system initialization for an algorithm.

We override this to declare all the elements of handle key arrays at the end of initialization. See comments on updateVHKA.

Reimplemented in DerivationFramework::CfAthAlgTool, AthCheckedComponent< AthAlgTool >, AthCheckedComponent<::AthAlgTool >, and asg::AsgMetadataTool.

◆ sysStart()

virtual StatusCode AthCommonDataStore< AthCommonMsg< AlgTool > >::sysStart ( )
overridevirtualinherited

Handle START transition.

We override this in order to make sure that conditions handle keys can cache a pointer to the conditions container.

◆ updateHandler()

void CP::PileupReweightingTool::updateHandler ( Gaudi::Details::PropertyBase &  )

Definition at line 92 of file PileupReweightingTool.cxx.

92  {
93  // commenting this out as it doesn't compile anymore
94  // leaving it to domain expert to decide whether to keep or remove it
95  // //call the original update handler
96  // this->msg_update_handler(p);
98 }

◆ updateVHKA()

void AthCommonDataStore< AthCommonMsg< AlgTool > >::updateVHKA ( Gaudi::Details::PropertyBase &  )
inlineinherited

Definition at line 308 of file AthCommonDataStore.h.

308  {
309  // debug() << "updateVHKA for property " << p.name() << " " << p.toString()
310  // << " size: " << m_vhka.size() << endmsg;
311  for (auto &a : m_vhka) {
312  std::vector<SG::VarHandleKey*> keys = a->keys();
313  for (auto k : keys) {
314  k->setOwner(this);
315  }
316  }
317  }

◆ UsePeriodConfig()

Int_t TPileupReweighting::UsePeriodConfig ( const TString &  configName)
inherited

use a hardcoded period configuration

Definition at line 234 of file TPileupReweighting.cxx.

234  {
235  if(configName=="MC11a") {
236  AddPeriod(180164, 177986,180481); //associates mc runnumber 180164 with data period 177986 to 180481 (period B-D)
237  AddPeriod(183003, 180614,184169); //period E-H
238  AddPeriod(185649, 185353,186934); //period I-K1. For I-K you would change the last number to 187815
239  AddPeriod(185761, 186935,191933); //everything else. Thanks Ellie!
240  SetUniformBinning(100,0,50);
241  if (m_printInfo) {
242  Info("UsePeriodConfig","Using MC11a Period configuration");
243  }
244  return 0;
245  } else if(configName=="MC11b" || configName=="MC11c") {
246  AddPeriod(180164, 177986, 180481);
247  AddPeriod(183003, 180614, 184169);
248  AddPeriod(186169, 185353, 187815);
249  AddPeriod(189751, 188902, 191933);
250  SetUniformBinning(100,0,50);
251  if (m_printInfo) {
252  Info("UsePeriodConfig","Using MC11b/c Period configuration");
253  }
254  return 0;
255  } else if(configName=="MC12a") {
256  AddPeriod(195847,200804,216432);
257  //mc12a binning is in integer values of mu
258 
259  if(m_emptyHistogram && (m_emptyHistogram->GetNbinsX()!=50 || fabs(m_emptyHistogram->GetXaxis()->GetBinLowEdge(1)+0.5)>0.01|| fabs(m_emptyHistogram->GetXaxis()->GetBinUpEdge(50)-49.5)>0.01) ) {
260  Error("UsePeriodConfig","Cannot use MC12a, an incompatible config has already been set up");
261  throw std::runtime_error("Throwing 13: Cannot use MC14, an incompatible config has already been set up");
262  return -1;
263  }
264 
265  SetUniformBinning(50,-0.5,49.5);
266  if (m_printInfo) {
267  Info("UsePeriodConfig","Using MC12a Period configuration");
268  }
269  return 0;
270  } else if(configName=="MC12b") {
271  AddPeriod(195848,200804,216432);
272  //mc12b binning is in integer values of mu
273 
274  if(m_emptyHistogram && (m_emptyHistogram->GetNbinsX()!=50 || fabs(m_emptyHistogram->GetXaxis()->GetBinLowEdge(1)+0.5)>0.01|| fabs(m_emptyHistogram->GetXaxis()->GetBinUpEdge(50)-49.5)>0.01) ) {
275  Error("UsePeriodConfig","Cannot use MC12b, an incompatible config has already been set up");
276  throw std::runtime_error("Throwing 13: Cannot use MC14, an incompatible config has already been set up");
277  return -1;
278  }
279 
280  SetUniformBinning(50,-0.5,49.5);
281  if (m_printInfo) {
282  Info("UsePeriodConfig","Using MC12b Period configuration");
283  }
284  return 0;
285  } else if(configName=="MC12ab") {
286  AddPeriod(195847,200804,216432);
287  AddPeriod(195848,200804,216432);
288 
289  if(m_emptyHistogram && (m_emptyHistogram->GetNbinsX()!=50 || fabs(m_emptyHistogram->GetXaxis()->GetBinLowEdge(1)+0.5)>0.01|| fabs(m_emptyHistogram->GetXaxis()->GetBinUpEdge(50)-49.5)>0.01) ) {
290  Error("UsePeriodConfig","Cannot use MC12ab, an incompatible config has already been set up");
291  throw std::runtime_error("Throwing 13: Cannot use MC14, an incompatible config has already been set up");
292  return -1;
293  }
294 
295  //mc12a/b binning is in integer values of mu
296  SetUniformBinning(50,-0.5,49.5);
297  if (m_printInfo) {
298  Info("UsePeriodConfig","Using MC12ab Period configuration");
299  }
300  return 0;
301  } else if(configName=="MC14_8TeV") {
302  AddPeriod(212272,200804,216432);
303  if(m_emptyHistogram && (m_emptyHistogram->GetNbinsX()!=50 || fabs(m_emptyHistogram->GetXaxis()->GetBinLowEdge(1)+0.5)>0.01 || fabs(m_emptyHistogram->GetXaxis()->GetBinUpEdge(50)-49.5)>0.01) ) {
304  Error("UsePeriodConfig","Cannot use MC14_8TeV, an incompatible config has already been set up");
305  throw std::runtime_error("Throwing 13: Cannot use MC14_8TeV, an incompatible config has already been set up");
306  return -1;
307  }
308  SetUniformBinning(50,-0.5,49.5);
309  if (m_printInfo) {
310  Info("UsePeriodConfig","Using MC14_8TeV Period configuration");
311  }
312  return 0;
313  } else if(configName=="MC14_13TeV") {
314  AddPeriod(222222,222222,999999);
315  if(m_emptyHistogram && (m_emptyHistogram->GetNbinsX()!=100 || fabs(m_emptyHistogram->GetXaxis()->GetBinLowEdge(1)+0.5)>0.01|| fabs(m_emptyHistogram->GetXaxis()->GetBinUpEdge(100)-99.5)>0.01) ) {
316  Error("UsePeriodConfig","Cannot use MC14_13TeV, an incompatible config has already been set up");
317  throw std::runtime_error("Throwing 13: Cannot use MC14_13TeV, an incompatible config has already been set up");
318  return -1;
319  }
320  SetUniformBinning(100,-0.5,99.5);
321  if (m_printInfo) {
322  Info("UsePeriodConfig","Using MC14_13TeV Period configuration");
323  }
324  return 0;
325  } else if(configName=="MC15") {
326  AddPeriod(222510,222222,999999);
327  AddPeriod(222525,222222,999999);
328  AddPeriod(222526,222222,999999);
329  AddPeriod(284500,222222,999999);
330  AddPeriod(295000,222222,999999); //mc15c for pPb data in 2016
331  if(m_emptyHistogram && (m_emptyHistogram->GetNbinsX()!=100 || fabs(m_emptyHistogram->GetXaxis()->GetBinLowEdge(1))>0.01 || fabs(m_emptyHistogram->GetXaxis()->GetBinUpEdge(100)-100.)>0.01) ) {
332  Error("UsePeriodConfig","Cannot use MC15, an incompatible config has already been set up");
333  throw std::runtime_error("Throwing 13: Cannot use MC15, an incompatible config has already been set up");
334  return -1;
335  }
336  SetUniformBinning(100,0,100);
337  if (m_printInfo) {
338  Info("UsePeriodConfig","Using MC15 Period configuration");
339  }
340  return 0;
341  } else if(configName=="Run2") {
342  m_autoRunStart = 222222; m_autoRunEnd = 999999; //periods will be automatically added during Fill
343  if(m_emptyHistogram && (m_emptyHistogram->GetNbinsX()!=100 || fabs(m_emptyHistogram->GetXaxis()->GetBinLowEdge(1))>0.01 || fabs(m_emptyHistogram->GetXaxis()->GetBinUpEdge(100)-100.)>0.01) ) {
344  Error("UsePeriodConfig","Cannot use open Run2, an incompatible config has already been set up");
345  throw std::runtime_error("Throwing 13: Cannot use Run2 config, an incompatible config has already been set up");
346  return -1;
347  }
348  SetUniformBinning(100,0,100);
349  if (m_printInfo) {
350  Info("UsePeriodConfig","Using Run2 Period configuration, which assumes period assignment of 222222 to 999999");
351  }
352  return 0;
353  } else if(configName=="MC16") {
354  /* period configs are now assigned through the parent tool for MC16 */
355 
356  SetUniformBinning(100,0,100);
357  if (m_printInfo) {
358  Info("UsePeriodConfig","Using MC16 Period configuration");
359  }
360  return 0;
361  }
362  Error("UsePeriodConfig","Unrecognized period config");
363  return -1;
364 }

◆ WriteToFile() [1/2]

Int_t TPileupReweighting::WriteToFile ( const TString &  filename = "")
inherited

Definition at line 1888 of file TPileupReweighting.cxx.

1888  {
1889 
1890  if(!m_countingMode) {Warning("WriteToFile","Not in counting mode, so no file will be written");return 0;}
1891 
1892 
1893  //build a TTree with the correct mc structure, and dump the mc histogram info in to it
1894  //also build aggregate histograms across all channels - shouldn't be used as input histograms unless for a single channel
1895  TString filename = fname;
1896  filename += (filename=="") ? TString(this->GetName()) + ".prw.root" : "";
1897 
1898  //loop over the weights. "pileup" gets it own MCPileupReweighting ttree. ... since we got rid of weightNames in this version, everything goes in MCPileupReweighting now!
1899  //data goes in to DataCustomReweighting. other goes in to MCCustomReweighting
1900  TFile* outFile = TFile::Open(filename,"RECREATE");
1901  Int_t r = WriteToFile(outFile);
1902  outFile->Close();
1903  return r;
1904 }

◆ WriteToFile() [2/2]

Int_t TPileupReweighting::WriteToFile ( TFile *  outFile)
inherited

Definition at line 1907 of file TPileupReweighting.cxx.

1907  {
1908  if(!m_countingMode) {Warning("WriteToFile","Not in counting mode, so no file will be written");return 0;}
1909 
1910  TDirectory* origDir = gDirectory;
1911 
1912  outFile->cd();
1913 
1914  std::unique_ptr< TTree > outTreeMC;
1915  std::unique_ptr< TTree > outTreeData;
1916  Int_t channel = 0; UInt_t runNumber = 0;
1917  auto pStarts = std::make_unique< std::vector< UInt_t > >();
1918  auto pStartsPtr = pStarts.get();
1919  auto pEnds = std::make_unique< std::vector< UInt_t > >();
1920  auto pEndsPtr = pEnds.get();
1921  Char_t histName[150];
1922 
1923 
1924  //loop over periods ... periods only get entry in table if they have an input histogram
1925  for(auto period : m_periods) {
1926  if(period.first != period.second->id) continue; //skips redirects
1927  if(period.first<0) continue; //avoid the global run number
1928  runNumber = period.first;
1929  pStarts->clear();
1930  pEnds->clear();
1931  if(period.second->subPeriods.size()==0) {
1932  pStarts->push_back(period.second->start); pEnds->push_back(period.second->end);
1933  }
1934  else {
1935  for(auto subp : period.second->subPeriods) {
1936  pStarts->push_back(subp->start); pEnds->push_back(subp->end);
1937  }
1938  }
1939  for(auto& inHist : period.second->inputHists) {
1940  channel = inHist.first;
1941  TH1* hist = inHist.second.get();
1942  strncpy(histName,hist->GetName(),sizeof(histName)-1);
1943  hist->Write();
1944 
1945  if(!outTreeMC) {
1946  outTreeMC.reset( new TTree("MCPileupReweighting","MCPileupReweighting") );
1947  outTreeMC->Branch("Channel",&channel);
1948  outTreeMC->Branch("RunNumber",&runNumber);
1949  outTreeMC->Branch("PeriodStarts",&pStartsPtr);
1950  outTreeMC->Branch("PeriodEnds",&pEndsPtr);
1951  outTreeMC->Branch("HistName",&histName,"HistName/C");
1952  }
1953  outTreeMC->Fill();
1954  }
1955  }
1956 
1957  //loop over data
1958  for(auto& run : m_runs) {
1959  runNumber = run.first;
1960  if(run.second.inputHists.find("None")==run.second.inputHists.end()) continue;
1961 
1962  TH1* hist = run.second.inputHists["None"].get();
1963  strncpy(histName,hist->GetName(),sizeof(histName)-1);
1964  hist->Write();
1965  if(!outTreeData) {
1966  outTreeData.reset( new TTree("DataPileupReweighting","DataPileupReweighting") );
1967  outTreeData->Branch("RunNumber",&runNumber);
1968  outTreeData->Branch("HistName",&histName,"HistName/C");
1969  }
1970  outTreeData->Fill();
1971  }
1972 
1973 
1974  //write the non-zero ttrees
1975  if( outTreeMC ) {
1976  outTreeMC->Write();
1977  }
1978  if( outTreeData ) {
1979  outTreeData->Write();
1980  }
1981 
1982  if (m_printInfo) {
1983  Info("WriteToFile", "Successfully generated config file: %s",outFile->GetName());
1984  Info("WriteToFile", "Happy Reweighting :-)");
1985  }
1986 
1987  gDirectory = origDir;
1988 
1989  return 0;
1990 }

Member Data Documentation

◆ m_activeTool

CP::TPileupReweighting* CP::PileupReweightingTool::m_activeTool
private

Definition at line 149 of file PileupReweightingTool.h.

◆ m_autoRunEnd

int CP::TPileupReweighting::m_autoRunEnd = 0
protectedinherited

Definition at line 469 of file TPileupReweighting.h.

◆ m_autoRunStart

int CP::TPileupReweighting::m_autoRunStart = 0
protectedinherited

Definition at line 468 of file TPileupReweighting.h.

◆ m_configStream

std::string CP::PileupReweightingTool::m_configStream
private

Definition at line 140 of file PileupReweightingTool.h.

◆ m_countingMode

Bool_t CP::TPileupReweighting::m_countingMode
protectedinherited

Definition at line 335 of file TPileupReweighting.h.

◆ m_customPeriods

std::vector<int> CP::PileupReweightingTool::m_customPeriods
private

Default weight tool in standalone mode.

Definition at line 165 of file PileupReweightingTool.h.

◆ m_dataScaleFactorX

Float_t CP::TPileupReweighting::m_dataScaleFactorX
protectedinherited

Definition at line 338 of file TPileupReweighting.h.

◆ m_dataScaleFactorY

Float_t CP::TPileupReweighting::m_dataScaleFactorY
protectedinherited

Definition at line 338 of file TPileupReweighting.h.

◆ m_debugging

Bool_t CP::TPileupReweighting::m_debugging
protectedinherited

Definition at line 333 of file TPileupReweighting.h.

◆ m_defaultChannel

int CP::PileupReweightingTool::m_defaultChannel
private

Definition at line 156 of file PileupReweightingTool.h.

◆ m_defaultWeightTool

std::unique_ptr< IWeightTool > CP::PileupReweightingTool::m_defaultWeightTool
private

Definition at line 168 of file PileupReweightingTool.h.

◆ m_detStore

StoreGateSvc_t AthCommonDataStore< AthCommonMsg< AlgTool > >::m_detStore
privateinherited

Pointer to StoreGate (detector store by default)

Definition at line 393 of file AthCommonDataStore.h.

◆ m_doGlobalDataWeight

Bool_t CP::TPileupReweighting::m_doGlobalDataWeight
protectedinherited

Definition at line 344 of file TPileupReweighting.h.

◆ m_doneConfigs

std::map<int, bool> CP::PileupReweightingTool::m_doneConfigs
private

Definition at line 158 of file PileupReweightingTool.h.

◆ m_doPrescaleWeight

Bool_t CP::TPileupReweighting::m_doPrescaleWeight = false
protectedinherited

Definition at line 345 of file TPileupReweighting.h.

◆ m_downTool

std::unique_ptr< CP::TPileupReweighting > CP::PileupReweightingTool::m_downTool
private

Definition at line 145 of file PileupReweightingTool.h.

◆ m_downVariation

double CP::PileupReweightingTool::m_downVariation
private

Definition at line 147 of file PileupReweightingTool.h.

◆ m_emptyHistogram

std::unique_ptr< TH1 > CP::TPileupReweighting::m_emptyHistogram
protectedinherited

the empty histogram used for this weight...

effectively holds the configuration of the binning

Definition at line 358 of file TPileupReweighting.h.

◆ m_evtStore

StoreGateSvc_t AthCommonDataStore< AthCommonMsg< AlgTool > >::m_evtStore
privateinherited

Pointer to StoreGate (event store by default)

Definition at line 390 of file AthCommonDataStore.h.

◆ m_grlTool

ToolHandle<IGoodRunsListSelectionTool> CP::PileupReweightingTool::m_grlTool
private

Definition at line 171 of file PileupReweightingTool.h.

◆ m_ignoreBadChannels

Bool_t CP::TPileupReweighting::m_ignoreBadChannels
protectedinherited

Definition at line 464 of file TPileupReweighting.h.

◆ m_ignoreFilePeriods

Bool_t CP::TPileupReweighting::m_ignoreFilePeriods
protectedinherited

Definition at line 341 of file TPileupReweighting.h.

◆ m_inConfigMode

bool CP::PileupReweightingTool::m_inConfigMode
private

Definition at line 141 of file PileupReweightingTool.h.

◆ m_isInitialized

Bool_t CP::TPileupReweighting::m_isInitialized
protectedinherited

Definition at line 337 of file TPileupReweighting.h.

◆ m_lumicalcFiles

std::map<TString,std::vector<TString> > CP::TPileupReweighting::m_lumicalcFiles
protectedinherited

map storing the lumicalc file locations - used when building DataPileupWeights

Definition at line 349 of file TPileupReweighting.h.

◆ m_lumicalcRunNumberOffset

Int_t CP::TPileupReweighting::m_lumicalcRunNumberOffset
protectedinherited

Definition at line 346 of file TPileupReweighting.h.

◆ m_lumiVectorIsLoaded

Bool_t CP::TPileupReweighting::m_lumiVectorIsLoaded
protectedinherited

Definition at line 337 of file TPileupReweighting.h.

◆ m_mcScaleFactorX

Float_t CP::TPileupReweighting::m_mcScaleFactorX
protectedinherited

Definition at line 339 of file TPileupReweighting.h.

◆ m_mcScaleFactorY

Float_t CP::TPileupReweighting::m_mcScaleFactorY
protectedinherited

Definition at line 339 of file TPileupReweighting.h.

◆ m_metadata

std::map<TString, std::map<Int_t, Double_t> > CP::TPileupReweighting::m_metadata
protectedinherited

channel metadata map

Definition at line 363 of file TPileupReweighting.h.

◆ m_metadatatree

TTree* CP::TPileupReweighting::m_metadatatree
protectedinherited

Definition at line 342 of file TPileupReweighting.h.

◆ m_nextPeriodNumber

Int_t CP::TPileupReweighting::m_nextPeriodNumber
protectedinherited

Definition at line 340 of file TPileupReweighting.h.

◆ m_noWeightsMode

bool CP::PileupReweightingTool::m_noWeightsMode
private

Definition at line 160 of file PileupReweightingTool.h.

◆ m_parentTool

TPileupReweighting* CP::TPileupReweighting::m_parentTool
protectedinherited

Definition at line 331 of file TPileupReweighting.h.

◆ m_periodList

std::list< Period > CP::TPileupReweighting::m_periodList
protectedinherited

List physically holding (owning) period objects.

Definition at line 450 of file TPileupReweighting.h.

◆ m_periods

std::map<Int_t, Period*> CP::TPileupReweighting::m_periods
protectedinherited

Definition at line 451 of file TPileupReweighting.h.

◆ m_prefix

std::string CP::PileupReweightingTool::m_prefix
private

Definition at line 154 of file PileupReweightingTool.h.

◆ m_printInfo

Bool_t CP::TPileupReweighting::m_printInfo
protectedinherited

Definition at line 334 of file TPileupReweighting.h.

◆ m_prwFiles

std::vector<std::string> CP::PileupReweightingTool::m_prwFiles
private

Definition at line 151 of file PileupReweightingTool.h.

◆ m_prwFilesPathPrefix

std::string CP::TPileupReweighting::m_prwFilesPathPrefix
protectedinherited

Definition at line 456 of file TPileupReweighting.h.

◆ m_random3

std::unique_ptr< TRandom3 > CP::TPileupReweighting::m_random3
protectedinherited

Definition at line 462 of file TPileupReweighting.h.

◆ m_runs

std::map<UInt_t, Run> CP::TPileupReweighting::m_runs
protectedinherited

Definition at line 452 of file TPileupReweighting.h.

◆ m_SetWarnings

Bool_t CP::TPileupReweighting::m_SetWarnings
protectedinherited

Definition at line 332 of file TPileupReweighting.h.

◆ m_systDown

CP::SystematicVariation CP::PileupReweightingTool::m_systDown
private

Definition at line 148 of file PileupReweightingTool.h.

◆ m_systUp

CP::SystematicVariation CP::PileupReweightingTool::m_systUp
private

Definition at line 148 of file PileupReweightingTool.h.

◆ m_tdt

ToolHandle<Trig::ITrigDecisionTool> CP::PileupReweightingTool::m_tdt
private

Definition at line 172 of file PileupReweightingTool.h.

◆ m_toolLumicalcFiles

std::vector<std::string> CP::PileupReweightingTool::m_toolLumicalcFiles
private

Definition at line 152 of file PileupReweightingTool.h.

◆ m_triggerObjs

std::map<TString, std::unique_ptr<CompositeTrigger> > CP::TPileupReweighting::m_triggerObjs
protectedinherited

Definition at line 401 of file TPileupReweighting.h.

◆ m_triggerPassBits

std::map<TString, bool> CP::TPileupReweighting::m_triggerPassBits
protectedinherited

Definition at line 315 of file TPileupReweighting.h.

◆ m_unrepDataTolerance

Double_t CP::TPileupReweighting::m_unrepDataTolerance
protectedinherited

Definition at line 343 of file TPileupReweighting.h.

◆ m_unrepresentedDataAction

Int_t CP::TPileupReweighting::m_unrepresentedDataAction
protectedinherited

Definition at line 336 of file TPileupReweighting.h.

◆ m_upTool

std::unique_ptr< CP::TPileupReweighting > CP::PileupReweightingTool::m_upTool
private

Definition at line 144 of file PileupReweightingTool.h.

◆ m_upVariation

double CP::PileupReweightingTool::m_upVariation
private

Definition at line 147 of file PileupReweightingTool.h.

◆ m_useMultiPeriods

Bool_t CP::TPileupReweighting::m_useMultiPeriods = true
protectedinherited

Definition at line 465 of file TPileupReweighting.h.

◆ m_usePeriodConfig

std::string CP::PileupReweightingTool::m_usePeriodConfig
private

Definition at line 157 of file PileupReweightingTool.h.

◆ m_useRunDependentPrescaleWeight

bool CP::PileupReweightingTool::m_useRunDependentPrescaleWeight
private

Definition at line 163 of file PileupReweightingTool.h.

◆ m_varHandleArraysDeclared

bool AthCommonDataStore< AthCommonMsg< AlgTool > >::m_varHandleArraysDeclared
privateinherited

Definition at line 399 of file AthCommonDataStore.h.

◆ m_varyRunNumber

bool CP::PileupReweightingTool::m_varyRunNumber
private

Definition at line 162 of file PileupReweightingTool.h.

◆ m_vhka

std::vector<SG::VarHandleKeyArray*> AthCommonDataStore< AthCommonMsg< AlgTool > >::m_vhka
privateinherited

Definition at line 398 of file AthCommonDataStore.h.

◆ m_weightTool

ToolHandle<IWeightTool> CP::PileupReweightingTool::m_weightTool
private

Definition at line 170 of file PileupReweightingTool.h.

◆ unrepDataByChannel

std::map<Int_t, Double_t> CP::TPileupReweighting::unrepDataByChannel
protectedinherited

Definition at line 454 of file TPileupReweighting.h.


The documentation for this class was generated from the following files:
xAOD::iterator
JetConstituentVector::iterator iterator
Definition: JetConstituentVector.cxx:68
python.Dso.registry
registry
Definition: Control/AthenaServices/python/Dso.py:159
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
python.AtlRunQueryAMI.period
period
Definition: AtlRunQueryAMI.py:225
beamspotman.r
def r
Definition: beamspotman.py:676
CP::PileupReweightingTool::m_defaultChannel
int m_defaultChannel
Definition: PileupReweightingTool.h:156
CP::TPileupReweighting::AddDistribution
Int_t AddDistribution(TH1 *hist, Int_t runNumber, Int_t channelNumber)
Definition: TPileupReweighting.cxx:728
data
char data[hepevt_bytes_allocation_ATLAS]
Definition: HepEvt.cxx:11
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::PileupReweightingTool::m_toolLumicalcFiles
std::vector< std::string > m_toolLumicalcFiles
Definition: PileupReweightingTool.h:152
CP::TPileupReweighting::IsBadBin
Int_t IsBadBin(Int_t thisMCRunNumber, Int_t bin)
Definition: TPileupReweighting.cxx:1351
asg::AsgTool
Base class for the dual-use tool implementation classes.
Definition: AsgTool.h:47
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition: AthMsgStreamMacros.h:34
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
CP::PileupReweightingTool::m_useRunDependentPrescaleWeight
bool m_useRunDependentPrescaleWeight
Definition: PileupReweightingTool.h:163
tolerance
constexpr double tolerance
Definition: runMdtGeoComparison.cxx:104
get_generator_info.result
result
Definition: get_generator_info.py:21
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
StateLessPT_NewConfig.proxy
proxy
Definition: StateLessPT_NewConfig.py:392
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
AddEmptyComponent.histName
string histName
Definition: AddEmptyComponent.py:64
plotting.yearwise_efficiency.channel
channel
Definition: yearwise_efficiency.py:24
CP::TPileupReweighting::m_triggerPassBits
std::map< TString, bool > m_triggerPassBits
Definition: TPileupReweighting.h:315
CP::TPileupReweighting::m_autoRunStart
int m_autoRunStart
Definition: TPileupReweighting.h:468
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
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
xAOD::EventInfo_v1::eventNumber
uint64_t eventNumber() const
The current event's event number.
integral
double integral(TH1 *h)
Definition: computils.cxx:58
athena_checkUpload.Period
int Period
--> Execution phase:
Definition: athena_checkUpload.py:179
CP::TPileupReweighting::GetDataScaleFactor
Float_t GetDataScaleFactor() const
Definition: TPileupReweighting.h:298
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::m_metadata
std::map< TString, std::map< Int_t, Double_t > > m_metadata
channel metadata map
Definition: TPileupReweighting.h:363
CP::PileupReweightingTool::m_grlTool
ToolHandle< IGoodRunsListSelectionTool > m_grlTool
Definition: PileupReweightingTool.h:171
CP::TPileupReweighting
Definition: TPileupReweighting.h:50
AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
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
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
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
PlotCalibFromCool.begin
begin
Definition: PlotCalibFromCool.py:94
skel.it
it
Definition: skel.GENtoEVGEN.py:396
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:169
CP::SystematicSet
Class to wrap a set of SystematicVariations.
Definition: SystematicSet.h:31
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
McEventWeight
Definition: McEventWeight.h:21
CP::TPileupReweighting::m_metadatatree
TTree * m_metadatatree
Definition: TPileupReweighting.h:342
AthCommonDataStore< AthCommonMsg< AlgTool > >::m_evtStore
StoreGateSvc_t m_evtStore
Pointer to StoreGate (event store by default)
Definition: AthCommonDataStore.h:390
AthCommonDataStore< AthCommonMsg< AlgTool > >::m_vhka
std::vector< SG::VarHandleKeyArray * > m_vhka
Definition: AthCommonDataStore.h:398
CP::PileupReweightingTool::m_varyRunNumber
bool m_varyRunNumber
Definition: PileupReweightingTool.h:162
AthCommonMsg< AlgTool >::msgLvl
bool msgLvl(const MSG::Level lvl) const
Definition: AthCommonMsg.h:30
CP::PileupReweightingTool::m_weightTool
ToolHandle< IWeightTool > m_weightTool
Definition: PileupReweightingTool.h:170
athena.value
value
Definition: athena.py:124
CP::PileupReweightingTool::m_doneConfigs
std::map< int, bool > m_doneConfigs
Definition: PileupReweightingTool.h:158
UploadAMITag.l
list l
Definition: UploadAMITag.larcaf.py:158
SG::ConstAccessor< unsigned int >
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
PURW_create_mc_default_profile.rrn
rrn
Definition: PURW_create_mc_default_profile.py:85
dbg::ptr
void * ptr(T *p)
Definition: SGImplSvc.cxx:74
skel.runNum
runNum
Definition: skel.ABtoEVGEN.py:137
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
athena.ps1
ps1
rename ourselfs to athena, both the prompt and the process (for top & ps)
Definition: athena.py:135
CP::TPileupReweighting::RemoveChannel
Bool_t RemoveChannel(int chanNum)
Removes a channel from the inputs ...
Definition: TPileupReweighting.cxx:1001
ZDCMsg::Info
@ Info
Definition: ZDCMsg.h:20
xAOD::EventInfo_v1::IS_SIMULATION
@ IS_SIMULATION
true: simulation, false: data
Definition: EventInfo_v1.h:151
x
#define x
CP::TPileupReweighting::m_autoRunEnd
int m_autoRunEnd
Definition: TPileupReweighting.h:469
mapkey::sys
@ sys
Definition: TElectronEfficiencyCorrectionTool.cxx:42
xAOD::EventInfo_v1::runNumber
uint32_t runNumber() const
The current event's run number.
CP::PileupReweightingTool::m_defaultWeightTool
std::unique_ptr< IWeightTool > m_defaultWeightTool
Definition: PileupReweightingTool.h:168
AthenaPoolTestRead.sc
sc
Definition: AthenaPoolTestRead.py:27
dq_defect_copy_defect_database.channels
def channels
Definition: dq_defect_copy_defect_database.py:56
mergePhysValFiles.end
end
Definition: DataQuality/DataQualityUtils/scripts/mergePhysValFiles.py:93
python.iconfTool.models.loaders.level
level
Definition: loaders.py:20
CP::PileupReweightingTool::m_usePeriodConfig
std::string m_usePeriodConfig
Definition: PileupReweightingTool.h:157
SG::VarHandleKeyArray::setOwner
virtual void setOwner(IDataHandleHolder *o)=0
CP::TPileupReweighting::passTriggerBeforePrescale
virtual bool passTriggerBeforePrescale(const TString &trigger) const
Definition: TPileupReweighting.h:309
CP::PileupReweightingTool::affectingSystematics
CP::SystematicSet affectingSystematics() const
the list of all systematics this tool can be affected by
Definition: PileupReweightingTool.cxx:119
dqt_zlumi_pandas.weight
int weight
Definition: dqt_zlumi_pandas.py:189
CP::PileupReweightingTool::m_customPeriods
std::vector< int > m_customPeriods
Default weight tool in standalone mode.
Definition: PileupReweightingTool.h:165
IDTPMcnv.htype
htype
Definition: IDTPMcnv.py:29
CP::TPileupReweighting::m_triggerObjs
std::map< TString, std::unique_ptr< CompositeTrigger > > m_triggerObjs
Definition: TPileupReweighting.h:401
xAOD::EventInfo_v1::mcChannelNumber
uint32_t mcChannelNumber() const
The MC generator's channel number.
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::TPileupReweighting::m_isInitialized
Bool_t m_isInitialized
Definition: TPileupReweighting.h:337
AthCommonDataStore< AthCommonMsg< AlgTool > >::evtStore
ServiceHandle< StoreGateSvc > & evtStore()
The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.
Definition: AthCommonDataStore.h:85
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
fitman.tmpHist
def tmpHist(what, wmin=-1e10, wmax=+1e10)
Definition: fitman.py:146
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:210
FortranAlgorithmOptions.fileName
fileName
Definition: FortranAlgorithmOptions.py:13
CP::TPileupReweighting::m_countingMode
Bool_t m_countingMode
Definition: TPileupReweighting.h:335
AthCommonDataStore
Definition: AthCommonDataStore.h:52
athena.ps2
ps2
Definition: athena.py:136
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
python.BunchSpacingUtils.lb
lb
Definition: BunchSpacingUtils.py:88
checkCoolLatestUpdate.chanNum
chanNum
Definition: checkCoolLatestUpdate.py:27
SG::Decorator< float >
CP::TPileupReweighting::EnableDebugging
void EnableDebugging(Bool_t in)
Indicate if additional debugging information should be output.
Definition: TPileupReweighting.h:118
fillPileUpNoiseLumi.next
next
Definition: fillPileUpNoiseLumi.py:52
CP::TPileupReweighting::IgnoreConfigFilePeriods
void IgnoreConfigFilePeriods(Bool_t in)
Should the tool ignore period assignments encoded in config file.
Definition: TPileupReweighting.h:146
ParseInputs.gDirectory
gDirectory
Definition: Final2012/ParseInputs.py:133
lumiFormat.i
int i
Definition: lumiFormat.py:85
CP::PileupReweightingTool::m_inConfigMode
bool m_inConfigMode
Definition: PileupReweightingTool.h:141
CP::TPileupReweighting::CalculatePrescaledLuminosityHistograms
void CalculatePrescaledLuminosityHistograms(const TString &trigger, int run_dependent=0)
Definition: TPileupReweighting.cxx:2086
beamspotman.n
n
Definition: beamspotman.py:731
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
checkxAOD.frac
frac
Definition: Tools/PyUtils/bin/checkxAOD.py:259
ChangeHistoRange.binsY
list binsY
Definition: ChangeHistoRange.py:59
CP::TPileupReweighting::m_lumicalcRunNumberOffset
Int_t m_lumicalcRunNumberOffset
Definition: TPileupReweighting.h:346
mergePhysValFiles.origDir
origDir
Definition: DataQuality/DataQualityUtils/scripts/mergePhysValFiles.py:24
CP::TPileupReweighting::m_debugging
Bool_t m_debugging
Definition: TPileupReweighting.h:333
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::IPileupReweightingTool::getCorrectedAverageInteractionsPerCrossing
virtual float getCorrectedAverageInteractionsPerCrossing(const xAOD::EventInfo &eventInfo, bool includedDataScaleFactor=false)=0
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
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
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
MuonSegmentReaderConfig.histSvc
histSvc
Definition: MuonSegmentReaderConfig.py:96
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::SystematicSet::end
const_iterator end() const
description: const iterator to the end of the set
Definition: SystematicSet.h:59
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
python.xAODType.dummy
dummy
Definition: xAODType.py:4
makeComparison.rootFile
rootFile
Definition: makeComparison.py:27
MSG::name
const std::string & name(Level lvl)
Convenience function for translating message levels to strings.
Definition: MsgLevel.cxx:19
CP::PileupReweightingTool::m_tdt
ToolHandle< Trig::ITrigDecisionTool > m_tdt
Definition: PileupReweightingTool.h:172
CHECK
#define CHECK(...)
Evaluate an expression and check for errors.
Definition: Control/AthenaKernel/AthenaKernel/errorcheck.h:422
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
run
Definition: run.py:1
CP::TPileupReweighting::m_mcScaleFactorX
Float_t m_mcScaleFactorX
Definition: TPileupReweighting.h:339
AthCommonDataStore< AthCommonMsg< AlgTool > >::m_detStore
StoreGateSvc_t m_detStore
Pointer to StoreGate (detector store by default)
Definition: AthCommonDataStore.h:393
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
DeMoUpdate.tmp
string tmp
Definition: DeMoUpdate.py:1167
CP::TPileupReweighting::GetNearestGoodBin
Int_t GetNearestGoodBin(Int_t thisMCRunNumber, Int_t bin)
Definition: TPileupReweighting.cxx:1367
xAOD::EventInfo_v1::lumiBlock
uint32_t lumiBlock() const
The current event's luminosity block number.
make_coralServer_rep.proj
proj
Definition: make_coralServer_rep.py:48
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
SG::VarHandleKeyArray::renounce
virtual void renounce()=0
DQPostProcessTest.outFile
outFile
Comment Out Those You do not wish to run.
Definition: DQPostProcessTest.py:37
SG::HandleClassifier::type
std::conditional< std::is_base_of< SG::VarHandleKeyArray, T >::value, VarHandleKeyArrayType, type2 >::type type
Definition: HandleClassifier.h:54
trigbs_pickEvents.num
num
Definition: trigbs_pickEvents.py:76
CP::TPileupReweighting::PrintInfo
void PrintInfo(Bool_t in)
disable info
Definition: TPileupReweighting.h:120
xAOD::EventInfo_v1::averageInteractionsPerCrossing
float averageInteractionsPerCrossing() const
Average interactions per crossing for all BCIDs - for out-of-time pile-up.
Definition: EventInfo_v1.cxx:397
CP::TPileupReweighting::m_parentTool
TPileupReweighting * m_parentTool
Definition: TPileupReweighting.h:331
CP::TPileupReweighting::m_doPrescaleWeight
Bool_t m_doPrescaleWeight
Definition: TPileupReweighting.h:345
TestSUSYToolsAlg.outName
string outName
Definition: TestSUSYToolsAlg.py:173
CP::TPileupReweighting::m_unrepresentedDataAction
Int_t m_unrepresentedDataAction
Definition: TPileupReweighting.h:336
CP::PileupReweightingTool::getCombinedWeight
virtual float getCombinedWeight(const xAOD::EventInfo &eventInfo, bool correctUnrepresented)
Return combined pileup weight.
Definition: PileupReweightingTool.cxx:397
merge_scale_histograms.doc
string doc
Definition: merge_scale_histograms.py:9
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
VP1PartSpect::E
@ E
Definition: VP1PartSpectFlags.h:21
plotBeamSpotVxVal.bin
int bin
Definition: plotBeamSpotVxVal.py:83
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
AtlCoolConsole.tool
tool
Definition: AtlCoolConsole.py:453
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::m_upTool
std::unique_ptr< CP::TPileupReweighting > m_upTool
Definition: PileupReweightingTool.h:144
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
CP::PileupReweightingTool::m_upVariation
double m_upVariation
Definition: PileupReweightingTool.h:147
LArCellBinning.xbins
int xbins
Definition: LArCellBinning.py:163
PathResolverFindCalibFile
std::string PathResolverFindCalibFile(const std::string &logical_file_name)
Definition: PathResolver.cxx:431
CP::TPileupReweighting::AddConfigFile
Int_t AddConfigFile(const TString &fileName)
Definition: TPileupReweighting.cxx:936
CP::SystematicSet::find
iterator find(const SystematicVariation &sys) const
description: find an element in the set
Definition: SystematicSet.h:63
python.AthDsoLogger.fname
string fname
Definition: AthDsoLogger.py:67
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
RTTAlgmain.branch
branch
Definition: RTTAlgmain.py:61
CP::TPileupReweighting::Initialize
Int_t Initialize()
Initialize this class once before the event loop starts If distribution information is provided,...
Definition: TPileupReweighting.cxx:1021
lumiFormat.lumi
lumi
Definition: lumiFormat.py:106
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
a
TList * a
Definition: liststreamerinfos.cxx:10
y
#define y
h
CP::TPileupReweighting::GetPRWHash
ULong64_t GetPRWHash(Int_t periodNumber, Int_t channelNumber, Float_t x, Float_t y=0.)
Definition: TPileupReweighting.cxx:1584
CondAlgsOpts.found
int found
Definition: CondAlgsOpts.py:101
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
python.CaloScaleNoiseConfig.action
action
Definition: CaloScaleNoiseConfig.py:77
CP::SystematicRegistry
This module implements the central registry for handling systematic uncertainties with CP tools.
Definition: SystematicRegistry.h:25
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
DeMoScan.first
bool first
Definition: DeMoScan.py:536
DEBUG
#define DEBUG
Definition: page_access.h:11
CP::TPileupReweighting::CloneEmptyHistogram
std::unique_ptr< TH1 > CloneEmptyHistogram(Int_t runNumber, Int_t channelNumber)
Definition: TPileupReweighting.cxx:435
AthCommonMsg< AlgTool >::msg
MsgStream & msg() const
Definition: AthCommonMsg.h:24
CP::TPileupReweighting::m_dataScaleFactorX
Float_t m_dataScaleFactorX
Definition: TPileupReweighting.h:338
LArNewCalib_DelayDump_OFC_Cali.idx
idx
Definition: LArNewCalib_DelayDump_OFC_Cali.py:69
CaloCellTimeCorrFiller.filename
filename
Definition: CaloCellTimeCorrFiller.py:24
SG::VarHandleBase::vhKey
SG::VarHandleKey & vhKey()
Return a non-const reference to the HandleKey.
Definition: StoreGate/src/VarHandleBase.cxx:623
CP::PileupReweightingTool::m_activeTool
CP::TPileupReweighting * m_activeTool
Definition: PileupReweightingTool.h:149
EventInfoRead.isMC
isMC
Definition: EventInfoRead.py:11
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
ZDCMsg::Fatal
@ Fatal
Definition: ZDCMsg.h:23
CP::TPileupReweighting::GetUnrepresentedDataWeight
Float_t GetUnrepresentedDataWeight(Int_t periodNumber, Int_t channel)
Definition: TPileupReweighting.h:134
ChangeHistoRange.binsX
list binsX
Definition: ChangeHistoRange.py:56
CP::PileupReweightingTool::m_downTool
std::unique_ptr< CP::TPileupReweighting > m_downTool
Definition: PileupReweightingTool.h:145
L1Topo::Error
Error
The different types of error that can be flagged in the L1TopoRDO.
Definition: Error.h:16
python.Bindings.keys
keys
Definition: Control/AthenaPython/python/Bindings.py:798
CP::TPileupReweighting::runLbnOK
virtual bool runLbnOK(Int_t, Int_t)
Definition: TPileupReweighting.h:308
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
CP::PileupReweightingTool::m_configStream
std::string m_configStream
Definition: PileupReweightingTool.h:140
plotBeamSpotCompare.histo
histo
Definition: plotBeamSpotCompare.py:415
python.PyAthena.obj
obj
Definition: PyAthena.py:132
dqBeamSpot.nEntries
int nEntries
Definition: dqBeamSpot.py:73
SG::DataProxy
Definition: DataProxy.h:45
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::TPileupReweighting::m_prwFilesPathPrefix
std::string m_prwFilesPathPrefix
Definition: TPileupReweighting.h:456
TileDCSDataPlotter.tx
tx
Definition: TileDCSDataPlotter.py:878
AthCommonDataStore::declareGaudiProperty
Gaudi::Details::PropertyBase & declareGaudiProperty(Gaudi::Property< T > &hndl, const SG::VarHandleKeyType &)
specialization for handling Gaudi::Property<SG::VarHandleKey>
Definition: AthCommonDataStore.h:156
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
CaloLCWConfig.Run
Run
Definition: CaloLCWConfig.py:39
CP::PileupReweightingTool::GetRandomLumiBlockNumber
virtual UInt_t GetRandomLumiBlockNumber(UInt_t runNumber)
Get a random lumiblock number for the given run number.
Definition: PileupReweightingTool.h:47
extractSporadic.myFile
myFile
Definition: extractSporadic.py:87
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
fitman.k
k
Definition: fitman.py:528
xAOD::EventInfo_v1::eventType
bool eventType(EventType type) const
Check for one particular bitmask value.
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.
CP::SystematicRegistry::getInstance
static SystematicRegistry & getInstance()
Get the singleton instance of the registry for the curren thread.
Definition: SystematicRegistry.cxx:25
xAOD::EventInfo_v1::actualInteractionsPerCrossing
float actualInteractionsPerCrossing() const
Average interactions per crossing for the current BCID - for in-time pile-up.
Definition: EventInfo_v1.cxx:380
read_hist_ntuple.f1
f1
Definition: read_hist_ntuple.py:4
ServiceHandle< ITHistSvc >
CP::TPileupReweighting::m_emptyHistogram
std::unique_ptr< TH1 > m_emptyHistogram
the empty histogram used for this weight...
Definition: TPileupReweighting.h:358