Commit b615a11c authored by Petr Jacka's avatar Petr Jacka
Browse files

Adding option to control large-R jet substructure variables

parent 18dd4d63
......@@ -1048,7 +1048,10 @@ namespace top {
systematicTree->makeOutputVariable(m_ljet_phi, "ljet_phi");
systematicTree->makeOutputVariable(m_ljet_e, "ljet_e");
systematicTree->makeOutputVariable(m_ljet_m, "ljet_m");
systematicTree->makeOutputVariable(m_ljet_sd12, "ljet_sd12");
for (const std::pair<std::string,std::string>& it : m_config->largeRJetSubstructureVariables()) {
systematicTree->makeOutputVariable(m_ljet_substructure[it.first],"ljet_"+it.first);
}
for (const std::string& taggerName : m_boostedJetTaggersNames) {
systematicTree->makeOutputVariable(m_ljet_isTagged[taggerName], "ljet_isTagged_" + taggerName);
......@@ -3091,7 +3094,10 @@ namespace top {
m_ljet_phi.resize(nLargeRJets);
m_ljet_e.resize(nLargeRJets);
m_ljet_m.resize(nLargeRJets);
m_ljet_sd12.resize(nLargeRJets);
for (const std::pair<std::string,std::string>& it : m_config->largeRJetSubstructureVariables()) {
m_ljet_substructure[it.first].resize(nLargeRJets);
}
for (const std::string& taggerName : m_boostedJetTaggersNames)
m_ljet_isTagged[taggerName].resize(nLargeRJets);
......@@ -3107,10 +3113,10 @@ namespace top {
m_ljet_phi[i] = jetPtr->phi();
m_ljet_e[i] = jetPtr->e();
m_ljet_m[i] = jetPtr->m();
m_ljet_sd12[i] = 0;
float Split12 = 0;
jetPtr->getAttribute("Split12", Split12);
m_ljet_sd12[i] = Split12;
for (const std::pair<std::string,std::string>& it : m_config->largeRJetSubstructureVariables()) {
m_ljet_substructure[it.first][i] = jetPtr->isAvailable<float>(it.second) ? jetPtr->auxdata<float>(it.second) : -999;
}
for (const std::string& taggerName : m_boostedJetTaggersNames) {
m_ljet_isTagged[taggerName][i] = jetPtr->getAttribute<char>("isTagged_" + taggerName);
......
......@@ -738,9 +738,9 @@ namespace top {
std::vector<float> m_ljet_phi;
std::vector<float> m_ljet_e;
std::vector<float> m_ljet_m;
std::vector<float> m_ljet_sd12;
std::vector<int> m_ljet_truthLabel;
std::unordered_map<std::string, std::vector<float> > m_ljet_substructure;
std::unordered_map<std::string, std::vector<char> > m_ljet_isTagged;
std::unordered_map<std::string, std::vector<float> > m_ljet_tagSF;
......@@ -1402,9 +1402,9 @@ namespace top {
const std::vector<float>& ljet_phi() const {return m_ljet_phi;}
const std::vector<float>& ljet_e() const {return m_ljet_e;}
const std::vector<float>& ljet_m() const {return m_ljet_m;}
const std::vector<float>& ljet_sd12() const {return m_ljet_sd12;}
const std::vector<int>& ljet_truthLabel() const {return m_ljet_truthLabel;}
const std::unordered_map<std::string, std::vector<float> >& ljet_substructure() const {return m_ljet_substructure;}
const std::unordered_map<std::string, std::vector<char> >& ljet_isTagged() const {return m_ljet_isTagged;}
const std::vector<char>& ljet_isTagged(const std::string& taggerName) {return m_ljet_isTagged[taggerName];}
......
......@@ -213,6 +213,7 @@ namespace top {
registerParameter("LargeRJetPt", "LargeRJet pT cut for object selection (in MeV). Default 150 GeV.", "150000.");
registerParameter("LargeRJetEta", "Absolute large-R jet eta cut for object selection. Default 2.0.", "2.0");
registerParameter("LargeRJetSubstructureVariables", "List of substructure variables stored in the output separated by commas. By default no variable is added to output.", " ");
registerParameter("LargeRJetUncertainties_NPModel",
"AllNuisanceParameters, CategoryReduction (default), GlobalReduction, - for LCTopo Large-R Jet Uncertainties or Scale_TCC_all - for TCC Large-R Jet Uncertainties",
"CategoryReduction");
......
......@@ -1316,6 +1316,29 @@ namespace top {
this->largeRJetPtcut(std::stof(settings->value("LargeRJetPt")));
this->largeRJetEtacut(std::stof(settings->value("LargeRJetEta")));
std::istringstream str_substructure(settings->value("LargeRJetSubstructureVariables"));
std::vector<std::string> vecSubstructure;
std::copy(std::istream_iterator<std::string>(str_substructure),
std::istream_iterator<std::string>(),
std::back_inserter(vecSubstructure));
// loop through all btagging WPs requested
for (const std::string& key: vecSubstructure) {
std::vector<std::string> pairs;
boost::split(pairs, key, boost::is_any_of(":"));
if(pairs.size() == 1) m_largeRJetSubstructureVariables[pairs[0]]=pairs[0];
else if(pairs.size() == 2) m_largeRJetSubstructureVariables[pairs[0]]=pairs[1];
else throw std::runtime_error {
"TopConfig: Options in LargeRJetSubstructureVariables should be of the form \'x:y\' or \'y\'."
};
}
this->largeRJetUncertainties_NPModel(settings->value("LargeRJetUncertainties_NPModel"));
this->largeRJetUncertaintiesConfigDir(settings->value("AdvancedUsage_LargeRJetUncertaintiesConfigDir"));
this->largeRJESJMSConfig(settings->value("LargeRJESJMSConfig"));
......
......@@ -1129,6 +1129,7 @@ namespace top {
inline virtual float largeRJetPtcut() const {return m_largeRJetPtcut;}
inline virtual float largeRJetEtacut() const {return m_largeRJetEtacut;}
inline virtual const std::map<std::string,std::string> largeRJetSubstructureVariables() const {return m_largeRJetSubstructureVariables;}
inline virtual const std::string& largeRJetUncertainties_NPModel() const {return m_largeRJetUncertainties_NPModel;}
inline virtual const std::string& largeRJetUncertaintiesConfigDir() const {return m_largeRJetUncertaintiesConfigDir;}
inline virtual const std::string& largeRJESJMSConfig() const {return m_largeRJESJMSConfig;}
......@@ -2232,6 +2233,7 @@ namespace top {
// Large R jet configuration
float m_largeRJetPtcut; // large R jet object selection pT cut
float m_largeRJetEtacut; // large R jet object selection (abs) eta cut
std::map<std::string,std::string> m_largeRJetSubstructureVariables;
std::string m_largeRJetUncertainties_NPModel; //large R JES/(plus old JMS, JMR, JER) uncertainties configuration
std::string m_largeRJetUncertaintiesConfigDir; //Relative path to directory with large R JES config
// file
......
......@@ -412,11 +412,19 @@ namespace top {
float tau3 = jet->getAttribute<float>("Tau3_wta");
float tau2 = jet->getAttribute<float>("Tau2_wta");
float tau1 = jet->getAttribute<float>("Tau1_wta");
float ECF1 = jet->getAttribute<float>("ECF1");
float ECF2 = jet->getAttribute<float>("ECF2");
float ECF3 = jet->getAttribute<float>("ECF3");
jet->auxdecor<float>("Tau32_wta") = fabs(tau2) > 1.e-6 ? (tau3 / tau2) : -999; // 999 to match
// JetSubStructureMomentTools/NSubjettinessRatiosTool
jet->auxdecor<float>("Tau21_wta") = fabs(tau1) > 1.e-6 ? (tau2 / tau1) : -999; // 999 to match
// JetSubStructureMomentTools/NSubjettinessRatiosTool
// Same definition as in JetSubStructureMomentTools/Root/EnergyCorrelatorRatiosTool.cxx
jet->auxdecor<float>("D2") = (ECF2 > 1e-8) ? (ECF3*ECF1*ECF1*ECF1) / (ECF2*ECF2*ECF2) : -999;
jet->auxdecor<float>("C2") = (ECF2 > 1e-8) ? (ECF3*ECF1) / (ECF2*ECF2) : -999;
jet->auxdecor<float>("E3") = (ECF1 > 1e-8) ? ECF3 / (ECF1*ECF1*ECF1) : -999;
top::check(m_jetCalibrationToolLargeR->applyCalibration(*jet), "Failed to applyCalibration");
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment