ATLAS Offline Software
TimeSignificanceCondition.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3 */
4 
7 #include <sstream>
8 #include <stdexcept>
9 #include <limits>
10 #include <memory>
11 
12 TimeSignificanceCondition::TimeSignificanceCondition(double t_minTimeSignificance, double t_maxTime):
13  m_minTimeSignificance(t_minTimeSignificance), m_maxTime(t_maxTime) {
14 }
15 
16 
17 float TimeSignificanceCondition::getTmin(const float pt, const float minTimeSignificance) const {
18 
19  // for now these are hardcoded, but they should eventually be taken from the conditions db so they can be updated more easily
20  float a {-0.812};
21  float b {-0.014};
22  float c {0.682};
23 
24  float minTime = minTimeSignificance*(std::exp(a+b*(pt/1000)) + c);
25  return minTime;
26 }
27 
28 bool TimeSignificanceCondition::isSatisfied(const HypoJetVector& ips, const std::unique_ptr<ITrigJetHypoInfoCollector>& collector) const{
29 
30  if (ips.size() != 1) {
31  std::stringstream ss;
32  ss << "TimeSignificanceCondition::isSatisfied must see exactly 1 particle, but received " << ips.size() << '\n';
33  throw std::runtime_error(ss.str());
34  }
35 
36  auto jet = ips[0];
37 
38  float timing {0.};
39  if (!(jet->getAttribute("Timing", timing))) {
40  throw std::runtime_error("ERROR: TimeSignificanceCondition cannot retrieve jet moment 'Timing'");
41  }
42 
43  float pt {0.};
44  if (!(pt = jet->pt())) {
45  throw std::runtime_error("ERROR: TimeSignificanceCondition cannot retrieve jet pt");
46  }
47 
48  float t_minTime = getTmin(pt, m_minTimeSignificance);
49 
50  bool pass = (timing >= t_minTime) and (timing < m_maxTime);
51 
52  if (collector) {
53  std::stringstream ss0;
54  const void* address = static_cast<const void*>(this);
55  ss0 << "TimeSignificanceCondition: (" << address << ") timing[" << t_minTime << ", " << m_maxTime << "]"
56  << " pass: " << std::boolalpha << pass << '\n';
57 
58  auto j_addr = static_cast<const void*>(jet.get());
59  std::stringstream ss1;
60 
61  ss1 << " jet : " << j_addr << ") timing " << timing << '\n';
62  collector->collect(ss0.str(), ss1.str());
63  }
64  return pass;
65 
66 }
67 
69 
70  std::stringstream ss;
71 
72  const void* address = static_cast<const void*>(this);
73  ss << "TimeSignificanceCondition: (" << address << ") Capacity: " << s_capacity
74  << " timeSignificanceMin "<< m_minTimeSignificance
75  << " timeMax " << m_maxTime
76  <<'\n';
77 
78  return ss.str();
79 }
TimeSignificanceCondition::m_maxTime
double m_maxTime
Definition: TimeSignificanceCondition.h:41
PowhegControl_ttHplus_NLO.ss
ss
Definition: PowhegControl_ttHplus_NLO.py:83
TimeSignificanceCondition::TimeSignificanceCondition
TimeSignificanceCondition(double t_minTimeSignificance, double t_maxTime)
Definition: TimeSignificanceCondition.cxx:12
test_pyathena.pt
pt
Definition: test_pyathena.py:11
ITrigJetHypoInfoCollector::collect
virtual void collect(const std::string &, const std::string &)=0
drawFromPickle.exp
exp
Definition: drawFromPickle.py:36
TimeSignificanceCondition::getTmin
float getTmin(const float pt, const float m_minTimeSignificance) const
Definition: TimeSignificanceCondition.cxx:17
jet
Definition: JetCalibTools_PlotJESFactors.cxx:23
trigDumpTimers.timing
def timing(hist)
Definition: trigDumpTimers.py:13
TimeSignificanceCondition::s_capacity
static const unsigned int s_capacity
Definition: TimeSignificanceCondition.h:42
TimeSignificanceCondition::isSatisfied
bool isSatisfied(const HypoJetVector &, const std::unique_ptr< ITrigJetHypoInfoCollector > &) const override
Definition: TimeSignificanceCondition.cxx:28
HypoJetVector
std::vector< pHypoJet > HypoJetVector
Definition: HypoJetDefs.h:27
TimeSignificanceCondition.h
plotBeamSpotMon.b
b
Definition: plotBeamSpotMon.py:77
RTTAlgmain.address
address
Definition: RTTAlgmain.py:55
ITrigJetHypoInfoCollector.h
a
TList * a
Definition: liststreamerinfos.cxx:10
TimeSignificanceCondition::m_minTimeSignificance
double m_minTimeSignificance
Definition: TimeSignificanceCondition.h:40
TimeSignificanceCondition::toString
std::string toString() const override
Definition: TimeSignificanceCondition.cxx:68
python.compressB64.c
def c
Definition: compressB64.py:93