|
ATLAS Offline Software
|
Go to the documentation of this file.
20 #ifndef XAOD_STANDALONE
21 #include "GaudiKernel/ITHistSvc.h"
24 #ifdef XAOD_STANDALONE
35 m_inConfigMode(false),
36 m_upTool(), m_downTool(), m_systUp(
"PRW_DATASF", 1 ), m_systDown(
"PRW_DATASF", -1),
38 m_noWeightsMode(false),
39 #ifdef XAOD_STANDALONE
42 m_weightTool(
"McEventWeight/myWeightTool"),
43 m_grlTool(
""), m_tdt(
"") {
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");
54 declareProperty(
"Prefix",
m_prefix=
"",
"Prefix to attach to all decorations ... only used in the 'apply' method");
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");
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)");
69 #ifdef XAOD_STANDALONE
71 "The tool to compute the weight in the sumOfWeights" );
74 "The tool to compute the weight in the sumOfWeights" );
77 #ifndef XAOD_STANDALONE
79 auto props = getProperties();
80 for( Gaudi::Details::PropertyBase* prop : props ) {
81 if( prop->name() !=
"OutputLevel" ) {
90 #ifndef XAOD_STANDALONE
112 return m_tdt->isPassed( trigger.Data() , TrigDefs::Physics | TrigDefs::allowResurrectedDecision );
132 ATH_MSG_ERROR(
"Errr... what the!? You're trying to do both PRW_DATASF directions at the same time!!!??");
133 return StatusCode::FAILURE;
136 if(!
m_upTool) {
ATH_MSG_ERROR(
"Requested up variation of PRW_DATASF, but not configured to do this :-(");
return StatusCode::FAILURE; }
140 if(!
m_downTool) {
ATH_MSG_ERROR(
"Requested down variation of PRW_DATASF, but not configured to do this :-(");
return StatusCode::FAILURE; }
144 return StatusCode::SUCCESS;
162 if(correctedMu<0)
return correctedMu;
176 std::vector<std::vector<int>> customPeriods;
178 if(customPeriods.size()==0 || customPeriods.back().size()==3) customPeriods.resize(customPeriods.size()+1);
179 customPeriods.back().push_back(
num);
182 for(
auto&
period : customPeriods) {
184 ATH_MSG_FATAL(
"Recevied period with " <<
period.size() <<
" numbers. Period configuration requires 3 numbers: periodNumber, startNumber, endNumber");
185 return StatusCode::FAILURE;
218 #ifndef XAOD_STANDALONE
235 for(
unsigned int j=0;j<
m_prwFiles.size();j++) {
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!");
280 if(
registry.registerSystematics( *
this ) != StatusCode::SUCCESS )
return StatusCode::FAILURE;
287 if (
sc != StatusCode::SUCCESS) {
296 return StatusCode::SUCCESS;
301 #ifndef XAOD_STANDALONE
304 std::string nameWithoutParent = this->
name().substr(this->
name().
find(
".")+1);
314 TTree *outTreeData=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;
325 if(!
period.second)
continue;
326 if(
period.first<0)
continue;
331 if(
period.second->subPeriods.size()==0) {
332 pStarts.push_back(
period.second->start); pEnds.push_back(
period.second->end);
335 for(
auto subp :
period.second->subPeriods) {
336 pStarts.push_back(subp->start); pEnds.push_back(subp->end);
339 for(
auto& inHist :
period.second->inputHists) {
341 TH1*
hist = inHist.second.release();
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");
360 if(
run.second.inputHists.find(
"None")==
run.second.inputHists.end())
continue;
362 TH1*
hist =
run.second.inputHists[
"None"].release();
366 outTreeData =
new TTree(
"DataPileupReweighting",
"DataPileupReweighting");
367 outTreeData->Branch(
"RunNumber",&
runNumber);
368 outTreeData->Branch(
"HistName",&
histName,
"HistName/C");
374 Info(
"WriteToFile",
"Successfully generated config file to stream: %s",
m_configStream.c_str());
375 Info(
"WriteToFile",
"Happy Reweighting :-)");
381 std::string nameWithoutParent = this->
name().substr(this->
name().
find(
".")+1);
389 return StatusCode::SUCCESS;
422 else return tool->GetRandomRunNumber( eventInfo.
runNumber() );
440 case 222510:
case 222525:
case 222526:
case 284500:
UsePeriodConfig(
"MC15");
break;
455 return StatusCode::SUCCESS;
462 return StatusCode::SUCCESS;
482 prwHashDec(eventInfo) =
getPRWHash( eventInfo );
490 ATH_MSG_VERBOSE(
"PileupWeight = " << puWeightAcc(eventInfo) <<
" RandomRunNumber = " << rrnAcc(eventInfo) <<
" RandomLumiBlockNumber = " << rlbnAcc(eventInfo));
492 return StatusCode::SUCCESS;
498 ATH_MSG_WARNING(
"Requesting Data Weight is not intended for simulated events. Returning 1.");
506 ATH_MSG_ERROR(
"Unrecognised run+lumiblock number (" << eventInfo.
runNumber() <<
"," << eventInfo.
lumiBlock() <<
") ... please ensure your lumicalc files are complete! Returning 1.");
517 unsigned int randomRunNum = rrnAcc.
withDefault (eventInfo, 0);
518 if (randomRunNum == 0) {
Int_t Fill(Int_t runNumber, Int_t channelNumber, Float_t w, Float_t x, Float_t y=0.)
Int_t AddLumiCalcFile(const TString &fileName, const TString &trigger="None")
std::string find(const std::string &s)
return a remapped string
uint64_t eventNumber() const
The current event's event number.
Float_t GetDataScaleFactor() const
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
void SetDefaultChannel(Int_t channel, Int_t mcRunNumber=-1)
Set which channel should be used as a default when specific mc channel distributions cannot be found.
Int_t UsePeriodConfig(const TString &configName)
use a hardcoded period configuration
Class to wrap a set of SystematicVariations.
bool msgLvl(const MSG::Level lvl) const
#define ATH_MSG_VERBOSE(x)
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.
SG::auxid_t auxid() const
Return the aux id for this variable.
@ IS_SIMULATION
true: simulation, false: data
Select isolated Photons, Electrons and Muons.
uint32_t runNumber() const
The current event's run number.
virtual bool passTriggerBeforePrescale(const TString &trigger) const
uint32_t mcChannelNumber() const
The MC generator's channel number.
void EnableDebugging(Bool_t in)
Indicate if additional debugging information should be output.
void IgnoreConfigFilePeriods(Bool_t in)
Should the tool ignore period assignments encoded in config file.
::StatusCode StatusCode
StatusCode definition for legacy code.
Float_t GetCombinedWeight(Int_t periodNumber, Int_t channelNumber, Float_t x, Float_t y=0.)
Int_t WriteToFile(const TString &filename="")
std::map< Int_t, Period * > m_periods
const_iterator end() const
description: const iterator to the end of the set
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.
#define CHECK(...)
Evaluate an expression and check for errors.
Bool_t m_ignoreBadChannels
uint32_t lumiBlock() const
The current event's luminosity block number.
std::map< UInt_t, Run > m_runs
void PrintInfo(Bool_t in)
disable info
float averageInteractionsPerCrossing() const
Average interactions per crossing for all BCIDs - for out-of-time pile-up.
Int_t m_unrepresentedDataAction
Class describing the basic event information.
std::string PathResolverFindCalibFile(const std::string &logical_file_name)
Int_t AddConfigFile(const TString &fileName)
iterator find(const SystematicVariation &sys) const
description: find an element in the set
ULong64_t GetPRWHash(Int_t periodNumber, Int_t channelNumber, Float_t x, Float_t y=0.)
#define ATH_MSG_WARNING(x)
This module implements the central registry for handling systematic uncertainties with CP tools.
Double_t m_unrepDataTolerance
bool isAvailable(const ELT &e) const
Test to see if this variable exists in the store.
Float_t m_dataScaleFactorX
Float_t GetUnrepresentedDataWeight(Int_t periodNumber, Int_t channel)
Helper class to provide constant type-safe access to aux data.
Float_t GetLumiBlockMu(Int_t runNumber, UInt_t lb)
get the lumiblock mu, useful for 'updating' the mu coming from data to account for new lumitags
Double_t GetLumiBlockIntegratedLumi(Int_t runNumber, UInt_t lb)
get integrated lumi for specific run and lumiblock number .
std::string m_prwFilesPathPrefix
Helper class to provide type-safe access to aux data.
bool eventType(EventType type) const
Check for one particular bitmask value.
TPileupReweighting(const char *name="TPileupReweighting")
Standard constructor.
static SystematicRegistry & getInstance()
Get the singleton instance of the registry for the curren thread.
float actualInteractionsPerCrossing() const
Average interactions per crossing for the current BCID - for in-time pile-up.
const_reference_type withDefault(const ELT &e, const T &deflt) const
Fetch the variable for one element, as a const reference, with a default.
std::unique_ptr< TH1 > m_emptyHistogram
the empty histogram used for this weight...