ATLAS Offline Software
TrigBtagEmulationChain.cxx
Go to the documentation of this file.
1 /*
2 Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 
7 #define CHAINPART_VARSEP "|"
8 #define CHAINPART_VARDEF ":"
9 #define CHAINPART_INDEX(cp,v) ((cp).find(v) +strlen(v))
10 #define CHAINPART_LENGTH(cp,v) ((cp).substr((cp).find(v) +strlen(v)).find(CHAINPART_VARSEP))
11 #define CHAINPART_VARIABLE(cp,v) (cp).substr(CHAINPART_INDEX((cp), (std::string(CHAINPART_VARSEP) + v + CHAINPART_VARDEF).c_str()), \
12  CHAINPART_LENGTH((cp), (std::string(CHAINPART_VARSEP) + v + CHAINPART_VARDEF).c_str()))
13 
14 
15 namespace Trig {
16 
18  const std::vector< std::string >& definition)
19  : AthMessaging("TrigBtagEmulationChain." + name),
20  m_name( name )
21 {
22  parseChainDefinition(definition);
23 }
24 
25 void TrigBtagEmulationChain::parseChainDefinition(const std::vector< std::string >& definition)
26 {
27  if (definition.size() == 0) {
28  ATH_MSG_ERROR( "Chain definition has not been provided" );
29  return;
30  }
31 
32  if (definition.size() == 1) {
33  ATH_MSG_ERROR( "Couldn't parse chain definition: " << definition[0] );
34  return;
35  }
36 
37  m_l1_requirement = definition[0].substr(7); // 7 -> strlen("L1item:")
38  ATH_MSG_DEBUG( name() << ":");
39  ATH_MSG_DEBUG( " - L1 item: " << m_l1_requirement);
40 
41  std::size_t n_def_size = definition.size();
42  m_chainPartName.reserve(n_def_size);
43  m_jet_multiplicity.reserve(n_def_size);
44  m_jet_pt.reserve(n_def_size);
45  m_jet_eta_min.reserve(n_def_size);
46  m_jet_eta_max.reserve(n_def_size);
47  m_jvt.reserve(n_def_size);
48  m_tagger.reserve(n_def_size);
49  m_is_PFlow.reserve(n_def_size);
50 
51  for(size_t chainPart_idx = 1; chainPart_idx < definition.size(); chainPart_idx++) {
52  // L1threshold:J20_multiplicity:1_threshold:45_etaRange:0eta290_tagger:bdl1r70_isPFlow:True
53  std::string chainPart = definition[chainPart_idx];
54  ATH_MSG_DEBUG( " > " << chainPart);
55 
56  std::string L1threshold = CHAINPART_VARIABLE(chainPart, "L1threshold");
57  int jet_multiplicity = std::stoi(CHAINPART_VARIABLE(chainPart, "multiplicity"));
58  std::string chainPartName = CHAINPART_VARIABLE(chainPart, "name");
59  double jet_pt = static_cast<double>( std::stoi(CHAINPART_VARIABLE(chainPart, "threshold")) * 1e3 );
60  std::string etaRange = CHAINPART_VARIABLE(chainPart, "etaRange");
61  double jvt = std::stod(CHAINPART_VARIABLE(chainPart, "jvt")) / 1e2;
62  std::string tagger = (CHAINPART_VARIABLE(chainPart, "tagger")).size() ? (CHAINPART_VARIABLE(chainPart, "tagger")).substr(1) : "";
63  std::string jetpresel = (CHAINPART_VARIABLE(chainPart, "jetpresel")).size() ? (CHAINPART_VARIABLE(chainPart, "jetpresel")).substr(6) : "";
64  std::string dijetmass = (CHAINPART_VARIABLE(chainPart, "dijetmass")).size() ? CHAINPART_VARIABLE(chainPart, "dijetmass") : "";
65  bool is_PFlow = (CHAINPART_VARIABLE(chainPart, "isPFlow") == "True");
66  bool is_shared = (CHAINPART_VARIABLE(chainPart, "isShared") == "True");
67 
68  double jet_eta_min = static_cast<double>( std::stoi(etaRange) / 100. );
69  double jet_eta_max = static_cast<double>( std::stoi(etaRange.substr(etaRange.find("eta") + 3)) / 100. ); // 3 -> strlen("eta")
70 
71  // jet preselection parsing
72  if(jetpresel == "el") { // nopresel (got cut to "el" by substr(6))
73  jetpresel = "";
74  }
75  else {
76  auto presel_separator = jetpresel.find("XX");
77  while(presel_separator != std::string::npos) {
78  m_jet_presel.push_back(jetpresel.substr(0, presel_separator));
79  jetpresel = jetpresel.substr(presel_separator + 2); // 2 -> strlen("XX")
80  presel_separator = jetpresel.find("XX");
81  }
82  m_jet_presel.push_back(jetpresel);
83  }
84 
85 
86  ATH_MSG_DEBUG( " - L1 threshold: " << L1threshold);
87  ATH_MSG_DEBUG( " - jet multiplicity: " << jet_multiplicity);
88  ATH_MSG_DEBUG( " - jet threshold: " << jet_pt);
89  ATH_MSG_DEBUG( " - eta range: [" << jet_eta_min << "," << jet_eta_max << "]");
90  ATH_MSG_DEBUG( " - JVT cut: " << jvt);
91  ATH_MSG_DEBUG( " - BTagging algorithm: " << tagger);
92  ATH_MSG_DEBUG( " - Jet preselection: " << m_jet_presel);
93  ATH_MSG_DEBUG( " - Dijet Mass: " << dijetmass);
94  ATH_MSG_DEBUG( " - is PFlow: " << (is_PFlow ? "YES":"NO"));
95 
96  m_chainPartName.push_back(chainPartName);
98  m_jet_pt.push_back(jet_pt);
99  m_jet_eta_min.push_back(jet_eta_min);
100  m_jet_eta_max.push_back(jet_eta_max);
101  m_jvt.push_back(jvt);
102  m_tagger.push_back(tagger);
103  m_is_PFlow.push_back(is_PFlow);
104 
105  if(is_shared) {
106  m_shared_idx = chainPart_idx;
107  }
108 
109  if(m_dijetmass.empty() || dijetmass != "None") {
111  }
112  }
113 
114  ATH_MSG_DEBUG( " ^^^ DijetMass: " << m_dijetmass);
115  ATH_MSG_DEBUG( " ^^^ is SHARED: " << (m_shared_idx ? "YES":"NO"));
116 }
117 
118 }
119 
Trig::TrigBtagEmulationChain::jet_eta_min
const std::vector< double > & jet_eta_min() const
Definition: TrigBtagEmulationChain.h:64
Trig::TrigBtagEmulationChain::parseChainDefinition
void parseChainDefinition(const std::vector< std::string > &definition)
Definition: TrigBtagEmulationChain.cxx:25
Trig::TrigBtagEmulationChain::m_tagger
std::vector< std::string > m_tagger
Definition: TrigBtagEmulationChain.h:53
Trig
The common trigger namespace for trigger analysis tools.
Definition: CaloTowerVecMon.h:44
Trig::TrigBtagEmulationChain::m_jet_presel
std::vector< std::string > m_jet_presel
Definition: TrigBtagEmulationChain.h:54
Trig::TrigBtagEmulationChain::m_shared_idx
int m_shared_idx
Definition: TrigBtagEmulationChain.h:56
LArCellBinning.etaRange
etaRange
Filling Eta range.
Definition: LArCellBinning.py:128
Trig::TrigBtagEmulationChain::jet_multiplicity
const std::vector< int > & jet_multiplicity() const
Definition: TrigBtagEmulationChain.h:62
Trig::TrigBtagEmulationChain::is_PFlow
const std::vector< bool > & is_PFlow() const
Definition: TrigBtagEmulationChain.h:67
Trig::TrigBtagEmulationChain::m_jet_pt
std::vector< double > m_jet_pt
Definition: TrigBtagEmulationChain.h:48
python.setupRTTAlg.size
int size
Definition: setupRTTAlg.py:39
CHAINPART_VARIABLE
#define CHAINPART_VARIABLE(cp, v)
Definition: TrigBtagEmulationChain.cxx:11
Trig::TrigBtagEmulationChain::m_is_PFlow
std::vector< bool > m_is_PFlow
Definition: TrigBtagEmulationChain.h:52
Trig::TrigBtagEmulationChain::name
const std::string & name() const
Name.
Definition: TrigBtagEmulationChain.h:59
Trig::TrigBtagEmulationChain::dijetmass
const std::string & dijetmass() const
Definition: TrigBtagEmulationChain.h:70
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
CheckAppliedSFs.e3
e3
Definition: CheckAppliedSFs.py:264
TrigBtagEmulationChain.h
Trig::TrigBtagEmulationChain::jvt
const std::vector< double > & jvt() const
Definition: TrigBtagEmulationChain.h:66
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
AthMessaging
Class to provide easy MsgStream access and capabilities.
Definition: AthMessaging.h:55
Trig::TrigBtagEmulationChain::jet_pt
const std::vector< double > & jet_pt() const
Definition: TrigBtagEmulationChain.h:63
Trig::TrigBtagEmulationChain::tagger
const std::vector< std::string > & tagger() const
Definition: TrigBtagEmulationChain.h:68
Trig::TrigBtagEmulationChain::chainPartName
const std::vector< std::string > & chainPartName() const
Definition: TrigBtagEmulationChain.h:61
Trig::TrigBtagEmulationChain::m_chainPartName
std::vector< std::string > m_chainPartName
Definition: TrigBtagEmulationChain.h:46
Trig::TrigBtagEmulationChain::m_dijetmass
std::string m_dijetmass
Definition: TrigBtagEmulationChain.h:55
Trig::TrigBtagEmulationChain::m_l1_requirement
std::string m_l1_requirement
Definition: TrigBtagEmulationChain.h:45
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:192
Trig::TrigBtagEmulationChain::TrigBtagEmulationChain
TrigBtagEmulationChain(const std::string &name, const std::vector< std::string > &definition)
Constructors and Destructor.
Definition: TrigBtagEmulationChain.cxx:17
Trig::TrigBtagEmulationChain::m_jvt
std::vector< double > m_jvt
Definition: TrigBtagEmulationChain.h:51
egammaEnergyPositionAllSamples::e2
double e2(const xAOD::CaloCluster &cluster)
return the uncorrected cluster energy in 2nd sampling
Trig::TrigBtagEmulationChain::m_jet_multiplicity
std::vector< int > m_jet_multiplicity
Definition: TrigBtagEmulationChain.h:47
Trig::TrigBtagEmulationChain::jet_eta_max
const std::vector< double > & jet_eta_max() const
Definition: TrigBtagEmulationChain.h:65
Trig::TrigBtagEmulationChain::m_jet_eta_max
std::vector< double > m_jet_eta_max
Definition: TrigBtagEmulationChain.h:50
Trig::TrigBtagEmulationChain::m_jet_eta_min
std::vector< double > m_jet_eta_min
Definition: TrigBtagEmulationChain.h:49