diff --git a/PhysicsAnalysis/Algorithms/TriggerAnalysisAlgorithms/Root/TrigPrescalesAlg.cxx b/PhysicsAnalysis/Algorithms/TriggerAnalysisAlgorithms/Root/TrigPrescalesAlg.cxx index 0ea5deac04308baa19c5ec422f1f809839e06890..c271df0c55276b54d11000b4db8da23d3ddbaca5 100644 --- a/PhysicsAnalysis/Algorithms/TriggerAnalysisAlgorithms/Root/TrigPrescalesAlg.cxx +++ b/PhysicsAnalysis/Algorithms/TriggerAnalysisAlgorithms/Root/TrigPrescalesAlg.cxx @@ -49,6 +49,7 @@ namespace CP m_prescaleAccessors.emplace_back(m_prescaleDecoration); m_prescaleFunctions.emplace_back([this](const xAOD::EventInfo *evtInfo, const std::string &trigger) { + if(m_prescaleMC) return m_pileupReweightingTool->getPrescaleWeight(*evtInfo, trigger, true); return m_pileupReweightingTool->getDataWeight (*evtInfo, trigger, true); }); // By putting the formula into` m_trigListAll` @@ -73,6 +74,7 @@ namespace CP { m_prescaleFunctions.emplace_back([this](const xAOD::EventInfo *evtInfo, const std::string &trigger) { + if(m_prescaleMC) return m_pileupReweightingTool->getPrescaleWeight(*evtInfo, trigger, true); return m_pileupReweightingTool->getDataWeight (*evtInfo, trigger, true); }); } diff --git a/PhysicsAnalysis/Algorithms/TriggerAnalysisAlgorithms/TriggerAnalysisAlgorithms/TrigPrescalesAlg.h b/PhysicsAnalysis/Algorithms/TriggerAnalysisAlgorithms/TriggerAnalysisAlgorithms/TrigPrescalesAlg.h index 260a4cce17c353241e7cac7d2c1b4d3021549c76..63baf0a0cb7a367b9a5088fbc2948ad7b2638061 100644 --- a/PhysicsAnalysis/Algorithms/TriggerAnalysisAlgorithms/TriggerAnalysisAlgorithms/TrigPrescalesAlg.h +++ b/PhysicsAnalysis/Algorithms/TriggerAnalysisAlgorithms/TriggerAnalysisAlgorithms/TrigPrescalesAlg.h @@ -57,6 +57,10 @@ namespace CP private: Gaudi::Property<std::string> m_prescaleDecoration {this, "prescaleDecoration", "", "decoration to store prescales"}; + /// \brief whether to prescale MC instead of unprescale dat + private: + Gaudi::Property<bool> m_prescaleMC {this, "prescaleMC", false, "whether to do prescaling of MC instead of unprescaling of data"}; + /// \brief the accessors for \ref m_prescaleDecoration and \ref m_trigList combination private: std::vector<SG::AuxElement::Decorator<float>> m_prescaleAccessors; diff --git a/PhysicsAnalysis/AnalysisCommon/PileupReweighting/PileupReweighting/PileupReweightingTool.h b/PhysicsAnalysis/AnalysisCommon/PileupReweighting/PileupReweighting/PileupReweightingTool.h index e5c4824c96b172dac360b4014d3f17f059e04c90..398089325d2026b241c0180a13bcc0b56782874a 100644 --- a/PhysicsAnalysis/AnalysisCommon/PileupReweighting/PileupReweighting/PileupReweightingTool.h +++ b/PhysicsAnalysis/AnalysisCommon/PileupReweighting/PileupReweighting/PileupReweightingTool.h @@ -105,6 +105,9 @@ namespace CP { /// Get the dataWeight used to 'unprescale' data collected from a given trigger combination. mu_dependency is recommended to be true virtual float getDataWeight( const xAOD::EventInfo& eventInfo, const TString& trigger, bool mu_dependent ); + /// Get weight used to 'prescale' Monte Carlo for given trigger comibnation. + virtual float getPrescaleWeight( const xAOD::EventInfo& eventInfo , const TString& trigger, bool mu_dependent ); + /// Get a random run number for this MC event, using mu-dependent randomization by default ... jetetmiss seem to like it muchly virtual int getRandomRunNumber( const xAOD::EventInfo& eventInfo , bool mu_dependent ); diff --git a/PhysicsAnalysis/AnalysisCommon/PileupReweighting/Root/PileupReweightingTool.cxx b/PhysicsAnalysis/AnalysisCommon/PileupReweighting/Root/PileupReweightingTool.cxx index f38a3841ae896cc7924b68fd9deffae3b9370821..f7081ac82c19956ef46e9d8685b7d9d2da8b2e94 100644 --- a/PhysicsAnalysis/AnalysisCommon/PileupReweighting/Root/PileupReweightingTool.cxx +++ b/PhysicsAnalysis/AnalysisCommon/PileupReweighting/Root/PileupReweightingTool.cxx @@ -500,14 +500,18 @@ float PileupReweightingTool::getDataWeight(const xAOD::EventInfo& eventInfo, con } +float PileupReweightingTool::getPrescaleWeight( const xAOD::EventInfo& eventInfo , const TString& trigger, bool mu_dependent ) { + //need to use the random run number ... only used to pick the subperiod, but in run2 so far we only have one subperiod + unsigned int randomRunNum = (eventInfo.isAvailable<unsigned int>(m_prefix+"RandomRunNumber")) ? eventInfo.auxdataConst<unsigned int>(m_prefix+"RandomRunNumber") : getRandomRunNumber( eventInfo, mu_dependent ); + if(!mu_dependent) return m_activeTool->GetPrescaleWeight(randomRunNum, trigger); + return m_activeTool->GetPrescaleWeight( randomRunNum, trigger, getCorrectedAverageInteractionsPerCrossing(eventInfo,false) /*use the 'correct' mu instead of the one from the file!!*/, m_useRunDependentPrescaleWeight /*run-dependent*/ ); +} + float PileupReweightingTool::getCombinedWeight( const xAOD::EventInfo& eventInfo , const TString& trigger, bool mu_dependent, bool correctUnrepresented ) { float out = getCombinedWeight(eventInfo, correctUnrepresented); 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 - //need to use the random run number ... only used to pick the subperiod, but in run2 so far we only have one subperiod - unsigned int randomRunNum = (eventInfo.isAvailable<unsigned int>(m_prefix+"RandomRunNumber")) ? eventInfo.auxdataConst<unsigned int>(m_prefix+"RandomRunNumber") : getRandomRunNumber( eventInfo, mu_dependent ); - if(!mu_dependent) out *= m_activeTool->GetPrescaleWeight(randomRunNum, trigger); - else out *= m_activeTool->GetPrescaleWeight( randomRunNum, trigger, getCorrectedAverageInteractionsPerCrossing(eventInfo,false) /*use the 'correct' mu instead of the one from the file!!*/, m_useRunDependentPrescaleWeight /*run-dependent*/ ); + out *= getPrescaleWeight(eventInfo, trigger, mu_dependent); return out; } diff --git a/PhysicsAnalysis/Interfaces/AsgAnalysisInterfaces/AsgAnalysisInterfaces/IPileupReweightingTool.h b/PhysicsAnalysis/Interfaces/AsgAnalysisInterfaces/AsgAnalysisInterfaces/IPileupReweightingTool.h index ed3a10876768dc92ccfb91cf5fb59b2ba45cc061..956df9218b5edebd53637c778a95234533580cf3 100644 --- a/PhysicsAnalysis/Interfaces/AsgAnalysisInterfaces/AsgAnalysisInterfaces/IPileupReweightingTool.h +++ b/PhysicsAnalysis/Interfaces/AsgAnalysisInterfaces/AsgAnalysisInterfaces/IPileupReweightingTool.h @@ -48,6 +48,9 @@ class TPileupReweighting; /// Get the dataWeight used to 'unprescale' data collected from a given trigger combination. mu_dependency is recommended to be true virtual float getDataWeight( const xAOD::EventInfo& eventInfo, const TString& trigger, bool mu_dependent=true ) = 0; + /// Get weight used to 'prescale' Monte Carlo for given trigger comibnation. + virtual float getPrescaleWeight( const xAOD::EventInfo& eventInfo , const TString& trigger, bool mu_dependent=true ) = 0; + /// Get a random run number for this MC event, mu_dependency is recommended ... jetetmiss seem to like it muchly virtual int getRandomRunNumber( const xAOD::EventInfo& eventInfo , bool mu_dependent=true) = 0;