Skip to content
Snippets Groups Projects
Commit fcfb4cc3 authored by Kin Yip Fung's avatar Kin Yip Fung
Browse files

Correct L1 name for HLT_2mu6_bBmumuxv2_L1LFV_MU6

parent 22691bca
No related branches found
No related tags found
No related merge requests found
......@@ -25,10 +25,10 @@
namespace CP {
PileupReweightingTool::PileupReweightingTool( const std::string& name ) :CP::TPileupReweighting(name.c_str()), asg::AsgTool( name ),
m_inConfigMode(false),
m_upTool(), m_downTool(), m_systUp("PRW_DATASF", 1 ), m_systDown("PRW_DATASF", -1),
m_activeTool(this),
PileupReweightingTool::PileupReweightingTool( const std::string& name ) :CP::TPileupReweighting(name.c_str()), asg::AsgTool( name ),
m_inConfigMode(false),
m_upTool(), m_downTool(), m_systUp("PRW_DATASF", 1 ), m_systDown("PRW_DATASF", -1),
m_activeTool(this),
m_noWeightsMode(false),
#ifdef XAOD_STANDALONE
m_defaultWeightTool( new McEventWeight( "DefaultWeightTool" ) ),
......@@ -56,9 +56,9 @@ PileupReweightingTool::PileupReweightingTool( const std::string& name ) :CP::TPi
declareProperty("DataScaleFactorUP",m_upVariation=1./0.99,"Set to a value representing the 'up' fluctuation - will report a PRW_DATASF uncertainty to Systematic Registry");
declareProperty("DataScaleFactorDOWN",m_downVariation=1./1.07,"Set to a value representing the 'down' fluctuation - will report a PRW_DATASF uncertainty to Systematic Registry");
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");
declareProperty("PeriodAssignments", m_customPeriods={284500,222222,324300,300000,324300,344495,310000,344496,999999}, "Specify period number assignments to run numbers ranges - this is usually an expert option");
declareProperty("GRLTool", m_grlTool, "If you provide a GoodRunsListSelectionTool, any information from lumicalc files will be automatically filtered" );
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)");
......@@ -87,7 +87,7 @@ PileupReweightingTool::PileupReweightingTool( const std::string& name ) :CP::TPi
#ifndef XAOD_STANDALONE
//rootcore can't do this yet!
void PileupReweightingTool::updateHandler(Property& p) {
//call the original update handler
//call the original update handler
this->msg_update_handler(p);
EnableDebugging(this->msgLvl(MSG::DEBUG));
}
......@@ -102,8 +102,8 @@ bool PileupReweightingTool::passTriggerBeforePrescale(const TString& trigger) co
if(m_tdt.empty()){
ATH_MSG_INFO("the TDT is empty, so we're reverting to the TPileupReweighting method");
return TPileupReweighting::passTriggerBeforePrescale(trigger);
return TPileupReweighting::passTriggerBeforePrescale(trigger);
}
ATH_MSG_VERBOSE("Checking tdt decision of " << trigger);
//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
......@@ -111,18 +111,21 @@ bool PileupReweightingTool::passTriggerBeforePrescale(const TString& trigger) co
//if it's not rerun, all we will get back here is the TAP result
ATH_MSG_DEBUG( "HEATHER DEBUG trigger string: " << trigger);
std::string trigger_str = std::string(trigger.Data());
std::string delimiter = "_L1";
std::string trigger_hlt = trigger_str.substr(0, trigger_str.find(delimiter));
std::string trigger_l1 = trigger_str.erase(0, trigger_str.find(delimiter) +1);
std::string trigger_l1 = trigger_str.erase(0, trigger_str.find(delimiter) +1);
if (trigger_l1 == "L1LFV-MU6") trigger_l1 = "L1_LFV-MU6"; //testing
ATH_MSG_DEBUG(" L1 string " << trigger_l1);
ATH_MSG_DEBUG(" HLT string " << trigger_hlt);
ATH_MSG_DEBUG(" L1 passed? " << m_tdt->isPassed( trigger_l1 ));
ATH_MSG_DEBUG(" HLT passed? " << m_tdt->isPassed( trigger_hlt, 1/*TrigDefs::requireDecision*/ ));
ATH_MSG_DEBUG(" HLT passed? " << m_tdt->isPassed( trigger_hlt, 1/*TrigDefs::requireDecision*/ ));
//ATH_MSG_DEBUG("HEATHER DEBUG trigger string: " << trigger);
return (m_tdt->isPassed( trigger_l1 ) && m_tdt->isPassed( trigger_hlt, 1/*TrigDefs::requireDecision*/ ));
//return m_tdt->isPassed( trigger.Data() , 37 /*physics|allowRessurectedDecision*/ ); //FIXME: need Trigger people to move Condition.h to interface package!
}
......@@ -141,10 +144,10 @@ CP::SystematicSet PileupReweightingTool::recommendedSystematics() const {
return affectingSystematics();
}
CP::SystematicCode PileupReweightingTool::applySystematicVariation( const CP::SystematicSet& systConfig ) {
CP::SystematicCode PileupReweightingTool::applySystematicVariation( const CP::SystematicSet& systConfig ) {
if(systConfig.find( m_systUp ) != systConfig.end() && systConfig.find( m_systDown ) != systConfig.end()) {
ATH_MSG_ERROR("Errr... what the!? You're trying to do both PRW_DATASF directions at the same time!!!??");
return SystematicCode::Unsupported;
ATH_MSG_ERROR("Errr... what the!? You're trying to do both PRW_DATASF directions at the same time!!!??");
return SystematicCode::Unsupported;
}
if(systConfig.find( m_systUp ) != systConfig.end()) {
if(!m_upTool) { ATH_MSG_ERROR("Requested up variation of PRW_DATASF, but not configured to do this :-("); return SystematicCode::Unsupported; }
......@@ -159,22 +162,22 @@ CP::SystematicCode PileupReweightingTool::applySystematicVariation( const CP::Sy
}
float PileupReweightingTool::getCorrectedAverageInteractionsPerCrossing( const xAOD::EventInfo& eventInfo, bool includeDataScaleFactor ) {
float PileupReweightingTool::getCorrectedAverageInteractionsPerCrossing( const xAOD::EventInfo& eventInfo, bool includeDataScaleFactor ) {
if(eventInfo.eventType(xAOD::EventInfo::IS_SIMULATION)) {
return eventInfo.averageInteractionsPerCrossing(); //no correction needed for MC
}
float out = CP::TPileupReweighting::GetLumiBlockMu(eventInfo.runNumber(),eventInfo.lumiBlock());
if(out<0) return out; //will be -1
return out * ( (includeDataScaleFactor) ? m_activeTool->GetDataScaleFactor() : 1.);
return out * ( (includeDataScaleFactor) ? m_activeTool->GetDataScaleFactor() : 1.);
}
float PileupReweightingTool::getCorrectedActualInteractionsPerCrossing( const xAOD::EventInfo& eventInfo, bool includeDataScaleFactor ) {
float PileupReweightingTool::getCorrectedActualInteractionsPerCrossing( const xAOD::EventInfo& eventInfo, bool includeDataScaleFactor ) {
if(eventInfo.eventType(xAOD::EventInfo::IS_SIMULATION)) {
return eventInfo.actualInteractionsPerCrossing(); //no correction needed for MC
}
float correctedMu = CP::TPileupReweighting::GetLumiBlockMu(eventInfo.runNumber(),eventInfo.lumiBlock());
if(correctedMu<0) return correctedMu; //will be -1
return eventInfo.actualInteractionsPerCrossing() * (correctedMu/eventInfo.averageInteractionsPerCrossing()) * ( (includeDataScaleFactor) ? m_activeTool->GetDataScaleFactor() : 1.);
return eventInfo.actualInteractionsPerCrossing() * (correctedMu/eventInfo.averageInteractionsPerCrossing()) * ( (includeDataScaleFactor) ? m_activeTool->GetDataScaleFactor() : 1.);
}
......@@ -200,7 +203,7 @@ StatusCode PileupReweightingTool::initialize() {
AddPeriod(period[0],period[1],period[2]);
}
//see if we need variations
//see if we need variations
if(m_upVariation && (m_prwFiles.size()+m_lumicalcFiles.size())!=0) {
m_upTool.reset( new TPileupReweighting((name()+"_upVariation").c_str()) );
m_upTool->SetParentTool(this);
......@@ -222,7 +225,7 @@ StatusCode PileupReweightingTool::initialize() {
//should we set the period config (file maker mode)
if(m_prwFiles.size()+m_lumicalcFiles.size()==0) {
m_inConfigMode=true;
ATH_MSG_INFO("In Config file making mode.");
ATH_MSG_INFO("In Config file making mode.");
if(m_usePeriodConfig!="auto" && m_usePeriodConfig!="") {
/*m_tool->*/UsePeriodConfig(m_usePeriodConfig);
}
......@@ -242,7 +245,7 @@ StatusCode PileupReweightingTool::initialize() {
if(m_upTool) m_upTool->UsePeriodConfig("MC16");
if(m_downTool) m_downTool->UsePeriodConfig("MC16");
}
for(unsigned int j=0;j<m_prwFiles.size();j++) {
ATH_MSG_VERBOSE("Locating File: " << m_prwFiles[j]);
std::string file = PathResolverFindCalibFile(m_prwFiles[j]);
......@@ -271,9 +274,9 @@ StatusCode PileupReweightingTool::initialize() {
if(m_downTool) m_downTool->UsePeriodConfig("MC16");
}
}
for(unsigned int j=0;j<m_lumicalcFiles.size();j++) {
//see if there's a trigger at the end of the filename .. format is "file:trigger"
//see if there's a trigger at the end of the filename .. format is "file:trigger"
TString myFile = m_lumicalcFiles[j];
TString myTrigger = (myFile.Contains(':')) ? TString(myFile(myFile.Last(':')+1,myFile.Length()-myFile.Last(':'))) : TString("None");
myFile = (myFile.Contains(':')) ? TString(myFile(0,myFile.Last(':'))) : myFile;
......@@ -286,7 +289,7 @@ StatusCode PileupReweightingTool::initialize() {
}
}
//register ourselves with the systematic registry!
//register ourselves with the systematic registry!
CP::SystematicRegistry& registry = CP::SystematicRegistry::getInstance();
if( registry.registerSystematics( *this ) != CP::SystematicCode::Ok ) return StatusCode::FAILURE;
......@@ -317,30 +320,30 @@ StatusCode PileupReweightingTool::finalize() {
/*m_tool->*/WriteToFile(fileName);
} else {
//write to the histsvc stream instead ...
ServiceHandle<ITHistSvc> histSvc("THistSvc",name());
CHECK( histSvc.retrieve() );
TTree *outTreeMC=0;
TTree *outTreeData=0;
Int_t channel = 0;UInt_t runNumber = 0;
Int_t channel = 0;UInt_t runNumber = 0;
std::vector<UInt_t> pStarts;
std::vector<UInt_t> pEnds;
std::vector<UInt_t>* pStartsPtr = &pStarts;
std::vector<UInt_t>* pEndsPtr = &pEnds;
Char_t histName[150];
//loop over periods ... periods only get entry in table if they have an input histogram
//loop over periods ... periods only get entry in table if they have an input histogram
for(auto period : m_periods) {
if(!period.second) continue; //should never happen, but just in case!
if(period.first<0) continue; //avoid the global run number
if(period.first != period.second->id) continue; //skips redirects
if(period.first != period.second->id) continue; //skips redirects
runNumber = period.first;
pStarts.clear();
pEnds.clear();
if(period.second->subPeriods.size()==0) {
pStarts.push_back(period.second->start); pEnds.push_back(period.second->end);
if(period.second->subPeriods.size()==0) {
pStarts.push_back(period.second->start); pEnds.push_back(period.second->end);
}
else {
for(auto subp : period.second->subPeriods) {
......@@ -365,11 +368,11 @@ StatusCode PileupReweightingTool::finalize() {
}
}
//loop over data
//loop over data
for(auto& run : m_runs) {
runNumber = run.first;
if(run.second.inputHists.find("None")==run.second.inputHists.end()) continue;
TH1* hist = run.second.inputHists["None"].release();
strncpy(histName,hist->GetName(),sizeof(histName)-1);
CHECK( histSvc->regHist(TString::Format("/%s/PileupReweighting/%s",m_configStream.c_str(),hist->GetName()).Data(),hist) );
......@@ -395,7 +398,7 @@ StatusCode PileupReweightingTool::finalize() {
#endif
}
m_upTool.reset(); m_downTool.reset();
m_upTool.reset(); m_downTool.reset();
return StatusCode::SUCCESS;
}
......@@ -432,9 +435,9 @@ int PileupReweightingTool::fill( const xAOD::EventInfo& eventInfo ) {
}
int PileupReweightingTool::fill( const xAOD::EventInfo& eventInfo, Double_t x, Double_t y) {
//auto-detect the period config if necessary
if(m_usePeriodConfig=="auto" && !m_doneConfigs[eventInfo.runNumber()]) { //try autodetect based on runnum of first event ...
//auto-detect the period config if necessary
if(m_usePeriodConfig=="auto" && !m_doneConfigs[eventInfo.runNumber()]) { //try autodetect based on runnum of first event ...
//if data, we only need to ensure a binning is done ... for now, we assume the MC15 binning
if(!eventInfo.eventType(xAOD::EventInfo::IS_SIMULATION)) {
if(!m_emptyHistogram) { SetUniformBinning(100,0,100.); } //use a default binning
......@@ -475,7 +478,7 @@ StatusCode PileupReweightingTool::apply(const xAOD::EventInfo& eventInfo, bool m
//just copy the value over for MC
eventInfo.auxdecor<float>(m_prefix+"corrected_averageInteractionsPerCrossing") = eventInfo.averageInteractionsPerCrossing();
//decorate with standard PileupWeight
//decorate with standard PileupWeight
if(!m_noWeightsMode) {
double weight = /*m_tool->*/getCombinedWeight( eventInfo );
if(m_unrepresentedDataAction==2) weight *= getUnrepresentedDataWeight( eventInfo );
......@@ -501,13 +504,13 @@ float PileupReweightingTool::getDataWeight(const xAOD::EventInfo& eventInfo, con
}
if(!mu_dependent) return /*m_tool->*/m_activeTool->GetDataWeight(eventInfo.runNumber(), trigger);
double correctedMu = getCorrectedAverageInteractionsPerCrossing(eventInfo,false);
if(correctedMu<0) {
ATH_MSG_ERROR("Unrecognised run+lumiblock number (" << eventInfo.runNumber() << "," << eventInfo.lumiBlock() << ") ... please ensure your lumicalc files are complete! Returning 1.");
return 1;
}
return /*m_tool->*/m_activeTool->GetDataWeight( eventInfo.runNumber(), trigger, correctedMu/*use the 'correct' mu instead of the one from the file!!*/ );
}
......@@ -516,7 +519,7 @@ float PileupReweightingTool::getCombinedWeight( const xAOD::EventInfo& eventInfo
float out = getCombinedWeight(eventInfo);
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
ATH_MSG_DEBUG("Get combined weight returned: " << out);
//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){
......@@ -524,7 +527,7 @@ float PileupReweightingTool::getCombinedWeight( const xAOD::EventInfo& eventInfo
} 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*/ );
ATH_MSG_DEBUG("Get now * prescale weight, returned: " << out);
}
}
return out;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment