ATLAS Offline Software
JetHT.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3 */
4 /*********************************
5  * JetHT.cpp
6  * Created by Joerg Stelzer on 11/16/12.
7  *
8  * @brief algorithm calculates the sum of jets ET, makes cut on HT criteria
9  *
10  * @param NumberLeading
11 **********************************/
12 
13 #include <cmath>
14 #include <string>
15 #include <iostream>
16 #include <sstream>
17 #include <vector>
18 
19 #include "L1TopoAlgorithms/JetHT.h"
20 #include "L1TopoCommon/Exception.h"
22 
23 
24 REGISTER_ALG_TCS(JetHT)
25 
26 // not the best solution but we will move to athena where this comes for free
27 #define LOG std::cout << name() << ": "
28 
29 
30 TCS::JetHT::JetHT(const std::string & name) : DecisionAlg(name)
31 {
32  defineParameter("InputWidth", 0);
33  defineParameter("MaxTob", 0);
34  defineParameter("NumResultBits",6);
35  defineParameter("NumRegisters", 2);
36  defineParameter("MinET",0);
37  defineParameter("MinEta",0);
38  defineParameter("MaxEta",31);
39  defineParameter("MinHt",0,0);
40  defineParameter("MinHt",0,1);
41  defineParameter("MinHt",0,2);
42  defineParameter("MinHt",0,3);
43  defineParameter("MinHt",0,4);
44  defineParameter("MinHt",0,5);
46 }
47 
49 {}
50 
51 
54  p_NumberLeading1 = parameter("InputWidth").value();
55  if(parameter("MaxTob").value() > 0) p_NumberLeading1 = parameter("MaxTob").value();
56  p_MinET = parameter("MinET").value();
57  p_EtaMin = parameter("MinEta").value();
58  p_EtaMax = parameter("MaxEta").value();
59 
60  TRG_MSG_INFO("MaxTob : " << p_NumberLeading1);
61  TRG_MSG_INFO("MinET : " << p_MinET);
62  TRG_MSG_INFO("EtaMin : " << p_EtaMin);
63  TRG_MSG_INFO("EtaMax : " << p_EtaMax);
64  for(unsigned int i=0; i<numberOutputBits(); ++i) {
65  p_HT[i] = parameter("MinHt", i).value();
66  TRG_MSG_INFO("HT " << i << " : " << p_HT[i]);
67  }
68  TRG_MSG_INFO("number output : " << numberOutputBits());
69 
70  // book histograms
71  for(unsigned int i=0; i<numberOutputBits(); ++i) {
72  std::string hname_accept = "hJetHT_accept_bit"+std::to_string((int)i);
73  std::string hname_reject = "hJetHT_reject_bit"+std::to_string((int)i);
74  // mass
75  bookHist(m_histAccept, hname_accept, "HT", 100, 0, p_HT[i]);
76  bookHist(m_histReject, hname_reject, "HT", 100, 0, p_HT[i]);
77  }
78 
79  return StatusCode::SUCCESS;
80 }
81 
83 TCS::JetHT::processBitCorrect( const std::vector<TCS::TOBArray const *> & input,
84  const std::vector<TCS::TOBArray *> & output,
85  Decision & decision )
86 
87 {
88  return process(input,output,decision);
89 }
90 
91 
93 TCS::JetHT::process( const std::vector<TCS::TOBArray const *> & input,
94  const std::vector<TCS::TOBArray *> & output,
95  Decision & decision )
96 {
97 
98  if(input.size()!=1) {
99  TCS_EXCEPTION("JetHT alg must have exactly 1 input list, but got " << input.size());
100  }
101 
102  unsigned int sumET = 0;
103 
104  if (p_NumberLeading1 < input[0]->size()) { output[0]->setAmbiguityFlag(false); }
105 
106  // loop over jets
107  for( TOBArray::const_iterator tob = input[0]->begin();
108  tob != input[0]->end() && distance(input[0]->begin(), tob) < p_NumberLeading1;
109  ++tob)
110  {
111 
112  if (input[0]->size() >= p_NumberLeading1+1) {
113  TCS::TOBArray::const_iterator tob2 = tob; ++tob2;
114  if ((*tob)->Et() == (*tob2)->Et() && distance(input[0]->begin(), tob) == p_NumberLeading1 - 1) {
115  output[0]->setAmbiguityFlag(true);
116  }
117  }
118 
119  if( parType_t(std::abs((*tob)->eta())) > p_EtaMax ) continue; // Eta cut
120  if( parType_t(std::abs((*tob)->eta())) < p_EtaMin ) continue; // Eta cut
121  if( parType_t((*tob)->Et()) <= p_MinET ) continue; // E_T cut
122 
123  TRG_MSG_DEBUG("Jet : ET = " << (*tob)->Et());
124 
125  sumET += (*tob)->Et();
126  }
127 
128  for(unsigned int i=0; i<numberOutputBits(); ++i) {
129 
130  bool accept = sumET > p_HT[i];
131  const bool fillAccept = fillHistos() and (fillHistosBasedOnHardware() ? getDecisionHardwareBit(i) : accept);
132  const bool fillReject = fillHistos() and not fillAccept;
133  const bool alreadyFilled = decision.bit(i);
134  decision.setBit( i, accept );
135 
136  if(accept) {
137  output[i]->push_back( CompositeTOB( GenericTOB::createOnHeap( GenericTOB(sumET,0,0) ) ));
138  }
139  if(fillAccept and not alreadyFilled) {
140  fillHist1D(m_histAccept[i],sumET);
141  } else if(fillReject) {
142  fillHist1D(m_histReject[i],sumET);
143  }
144 
145  TRG_MSG_DEBUG("Decision " << i << ": " << (accept?"pass":"fail") << " HT = " << sumET);
146 
147  }
148 
150 }
TCS::StatusCode::SUCCESS
@ SUCCESS
Definition: Trigger/TrigT1/L1Topo/L1TopoCommon/L1TopoCommon/StatusCode.h:17
JetHT.h
TCS::parType_t
uint32_t parType_t
Definition: Parameter.h:22
TCS::DataArrayImpl< GenericTOB >::const_iterator
data_t::const_iterator const_iterator
Definition: DataArrayImpl.h:18
TCS::JetHT::processBitCorrect
virtual StatusCode processBitCorrect(const std::vector< TCS::TOBArray const * > &input, const std::vector< TCS::TOBArray * > &output, Decision &decison)
Definition: JetHT.cxx:83
CutsMETMaker::accept
StatusCode accept(const xAOD::Muon *mu)
Definition: CutsMETMaker.cxx:18
PlotCalibFromCool.begin
begin
Definition: PlotCalibFromCool.py:94
athena.value
value
Definition: athena.py:122
Decision.h
TCS::JetHT::JetHT
JetHT(const std::string &name)
Definition: JetHT.cxx:30
SUSY_SimplifiedModel_PostInclude.process
string process
Definition: SUSY_SimplifiedModel_PostInclude.py:42
TCS::DecisionAlg
Definition: Trigger/TrigT1/L1Topo/L1TopoInterfaces/L1TopoInterfaces/DecisionAlg.h:22
python.setupRTTAlg.size
int size
Definition: setupRTTAlg.py:39
TCS::GenericTOB::createOnHeap
static GenericTOB * createOnHeap(const GenericTOB &)
Definition: GenericTOB.cxx:264
TCS::Decision::setBit
void setBit(unsigned int index, bool value)
Definition: L1Topo/L1TopoInterfaces/Root/Decision.cxx:12
lumiFormat.i
int i
Definition: lumiFormat.py:92
TCS::ConfigurableAlg::defineParameter
void defineParameter(const std::string &name, TCS::parType_t value)
Definition: ConfigurableAlg.cxx:201
TCS::CompositeTOB
Definition: CompositeTOB.h:16
PlotPulseshapeFromCool.input
input
Definition: PlotPulseshapeFromCool.py:106
TCS_EXCEPTION
#define TCS_EXCEPTION(MSG)
Definition: Trigger/TrigT1/L1Topo/L1TopoCommon/L1TopoCommon/Exception.h:14
TCS::Decision
Definition: L1Topo/L1TopoInterfaces/L1TopoInterfaces/Decision.h:19
TRG_MSG_INFO
#define TRG_MSG_INFO(x)
Definition: Trigger/TrigConfiguration/TrigConfBase/TrigConfBase/MsgStreamMacros.h:27
merge.output
output
Definition: merge.py:17
TCS::GenericTOB
Definition: GenericTOB.h:35
REGISTER_ALG_TCS
#define REGISTER_ALG_TCS(CLASS)
Definition: AlgFactory.h:62
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
ActsTrk::to_string
std::string to_string(const DetectorType &type)
Definition: GeometryDefs.h:34
TCS::JetHT::initialize
virtual StatusCode initialize()
Definition: JetHT.cxx:53
TCS::Decision::bit
bool bit(unsigned int index) const
Definition: L1Topo/L1TopoInterfaces/L1TopoInterfaces/Decision.h:40
TCS::DecisionAlg::setNumberOutputBits
void setNumberOutputBits(unsigned int numberOutputBits)
Definition: Trigger/TrigT1/L1Topo/L1TopoInterfaces/L1TopoInterfaces/DecisionAlg.h:40
TCS::JetHT::process
virtual StatusCode process(const std::vector< TCS::TOBArray const * > &input, const std::vector< TCS::TOBArray * > &output, Decision &decison)
Definition: JetHT.cxx:93
TCS::JetHT::~JetHT
virtual ~JetHT()
Definition: JetHT.cxx:48
Exception.h
Amg::distance
float distance(const Amg::Vector3D &p1, const Amg::Vector3D &p2)
calculates the distance between two point in 3D space
Definition: GeoPrimitivesHelpers.h:54
TRG_MSG_DEBUG
#define TRG_MSG_DEBUG(x)
Definition: Trigger/TrigConfiguration/TrigConfBase/TrigConfBase/MsgStreamMacros.h:25
TCS::StatusCode
Definition: Trigger/TrigT1/L1Topo/L1TopoCommon/L1TopoCommon/StatusCode.h:15