 |
DAS
3.0
Das Analysis System
|
Go to the documentation of this file.
4 #include <boost/algorithm/string.hpp>
5 #include <boost/assert/source_location.hpp>
7 #include <correction.h>
16 if (metainfo.
Find(
"flags",
"labels",
"CHS" ))
return "chs";
17 if (metainfo.
Find(
"flags",
"labels",
"PUPPI"))
return "Puppi";
19 std::cerr <<
orange <<
"Couldn't identify CHS or PUPPI. Running default "
20 "CHS for Run 2 (PUPPI foir Run 3)\n" <<
def;
22 auto year = metainfo.
Get<
int>(
"flags",
"year");
23 if (
year > 2019)
return "Puppi";
24 if (
year > 2014)
return "chs";
33 regex r(
"^(Summer|Fall|Autumn|Winter|Spring)[0-9]{2}[A-Za-z0-9]*");
34 smatch campaign_short;
35 if (!regex_search(
campaign, campaign_short, r))
36 BOOST_THROW_EXCEPTION( invalid_argument(
"The campaign could not be identified"));
37 return campaign_short.str();
44 const std::string&
key =
"")
47 s <<
"Available corrections:";
48 for (
const auto& correction: corrections) {
49 bool found = correction.first ==
key;
51 s <<
' ' << correction.first;
59 template<
typename CorrectionType>
62 const std::string& type,
63 const std::string& level,
64 const std::string& suffix)
66 namespace al = boost::algorithm;
67 for (
const auto& correction: corrections) {
68 if (!al::starts_with(correction.first,
campaign) ||
69 !al::contains (correction.first, type) ||
70 !al::contains (correction.first, level) ||
71 !al::ends_with (correction.first, suffix))
74 return correction.second;
77 BOOST_THROW_EXCEPTION(
79 "No `"s +
campaign +
"*"s + type +
"*" + level +
"*"s + suffix
80 +
"` correction can be found in the given tables. "s
97 const std::optional<float>&
rho = {},
98 const std::optional<GenJet>& genJet = {},
99 const std::optional<RecEvent>& recEvt = {},
100 const std::optional<std::string>& systematic = {},
101 const std::optional<float>& JER = {},
102 const std::optional<float>& JERSF = {}
107 cout << correction->name();
108 vector<correction::Variable::Type>
inputs;
111 auto push_back = [&cout,&
inputs](
const auto& v) {
116 for (
const correction::Variable&
input: correction->inputs()) {
117 const string& n =
input.name();
119 if (n ==
"JetPt" ) push_back(recJet.
CorrPt());
120 else if (n ==
"JetEta" ) push_back(recJet.
p4.Eta());
121 else if (n ==
"JetPhi" ) push_back(recJet.
p4.Phi());
122 else if (n ==
"JetEta" ) push_back(recJet.
p4.Phi());
123 else if (n ==
"JetA" ) push_back(recJet.
area);
124 else if (n ==
"Rho" ) push_back(*
rho);
125 else if (n ==
"systematic") push_back(*systematic);
126 else if (n ==
"GenPt" ) push_back(genJet ? genJet->CorrPt() : -1);
127 else if (n ==
"EventID" ) push_back((
int) recEvt->evtNo);
128 else if (n ==
"run" ) push_back((
float) recEvt->runNo);
129 else if (n ==
"JER" ) push_back(*JER);
130 else if (n ==
"JERSF" ) push_back(*JERSF);
131 else BOOST_THROW_EXCEPTION( invalid_argument(
"`"s + n +
"` is needed by "s
132 + correction->name() +
" but not recognized."s) );
137 auto corr = correction->evaluate(
inputs);
138 cout <<
" -> " << corr << endl;
141 catch (std::runtime_error& e) {
142 const char *
name =
typeid(*correction).name();
144 auto location = boost::source_location(__FILE__, __LINE__,
name);
145 boost::throw_exception(e, location);
152 auto year = metainfo.
Get<
int>(
"flags",
"year"),
153 R = metainfo.
Get<
int>(
"flags",
"R");
155 std::string warning =
"Not a standard jet size.\n";
157 if (R != 4 && R != 8)
159 return R < 6 ? 4 : 8;
162 if (R != 5 && R != 7)
164 return R < 6 ? 5 : 7;
name
Definition: DYToLL_M-50_13TeV_pythia8_cff_GEN_SIM_RECOBEFMIX_DIGI_L1_DIGI2RAW_L1Reco_RECO.py:48
cerr
Definition: Ntupliser_cfg.py:105
static const char * def
Definition: Step.h:36
FourVector p4
raw four-momentum directly after reconstruction
Definition: PhysicsObject.h:50
float Evaluate(const auto &correction, std::ostream &cout, const RecJet &recJet, const std::optional< float > &rho={}, const std::optional< GenJet > &genJet={}, const std::optional< RecEvent > &recEvt={}, const std::optional< std::string > &systematic={}, const std::optional< float > &JER={}, const std::optional< float > &JERSF={})
Wrapper to evaluate scale factors with DAS objects from correctionlib with exceptions.
Definition: toolbox.h:94
int year
Definition: Ntupliser_cfg.py:67
std::string ScanCorrections(const auto &corrections, const std::string &key="")
Definition: toolbox.h:43
string key
Definition: jercExample.py:109
std::string GetShortCampaign(const std::string &campaign)
Extracts for isntance Summer19UL18 from Summer19UL18_RunA
Definition: toolbox.h:30
static const char * orange
Definition: colours.h:6
input
Definition: DYToLL_M-50_13TeV_pythia8_cff_GEN_SIM_RECOBEFMIX_DIGI_L1_DIGI2RAW_L1Reco_RECO.py:35
float CorrPt(size_t i) const
corrected transverse momentum
Definition: PhysicsObject.h:55
float area
Jet area (should be peaked at pi*R^2), used for the JES corrections.
Definition: Jet.h:42
static const char * green
Definition: Step.h:33
int GetR(const Darwin::Tools::UserInfo &metainfo)
Determine the R values for which JetMET provides corrections.
Definition: toolbox.h:150
CorrectionType GetCorrection(const auto &corrections, const std::string &campaign, const std::string &type, const std::string &level, const std::string &suffix)
Returns the correction corresponding to a key.
Definition: toolbox.h:60
def inputs
Definition: jercExample.py:118
campaign
Definition: generate_html.py:86
std::string GetAlgo(const Darwin::Tools::UserInfo &metainfo)
Determine from metainfo if CHS or PUPPI has been used to reconstruct the jets.
Definition: toolbox.h:14
Definition: applyJERsmearing.cc:42
rho
Definition: Ntupliser_cfg.py:333
static const char * bold
Definition: Step.h:35