ATLAS Offline Software
Loading...
Searching...
No Matches
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
22
23
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
30TCS::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
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
80}
81
83TCS::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
93TCS::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}
#define REGISTER_ALG_TCS(CLASS)
Definition AlgFactory.h:62
const Parameter & parameter(const std::string &parameterName) const
const std::string & name() const
void bookHist(std::vector< std::string > &regName, const std::string &name, const std::string &title, const int binx, const int xmin, const int xmax)
void fillHist1D(const std::string &histName, double x)
void defineParameter(const std::string &name, TCS::parType_t value)
data_t::const_iterator const_iterator
void setNumberOutputBits(unsigned int numberOutputBits)
Definition DecisionAlg.h:40
DecisionAlg(const std::string &name)
Definition DecisionAlg.h:25
bool fillHistosBasedOnHardware() const
! getter
bool fillHistos() const
whether the monitoring histograms should be filled
std::vector< std::string > m_histAccept
Definition DecisionAlg.h:73
std::vector< std::string > m_histReject
Definition DecisionAlg.h:74
unsigned int numberOutputBits() const
Definition DecisionAlg.h:39
bool getDecisionHardwareBit(const unsigned int &bitNumber) const
! get one hardware decision bit from this algo
bool bit(unsigned int index) const
Definition Decision.h:40
void setBit(unsigned int index, bool value)
Definition Decision.cxx:12
static GenericTOB * createOnHeap(const GenericTOB &)
parType_t p_EtaMin
Definition JetHT.h:35
virtual StatusCode processBitCorrect(const std::vector< TCS::TOBArray const * > &input, const std::vector< TCS::TOBArray * > &output, Decision &decison)
Definition JetHT.cxx:83
virtual ~JetHT()
Definition JetHT.cxx:48
virtual StatusCode process(const std::vector< TCS::TOBArray const * > &input, const std::vector< TCS::TOBArray * > &output, Decision &decison)
Definition JetHT.cxx:93
parType_t p_EtaMax
Definition JetHT.h:36
parType_t p_NumberLeading1
Definition JetHT.h:33
parType_t p_HT[6]
Definition JetHT.h:37
JetHT(const std::string &name)
Definition JetHT.cxx:30
parType_t p_MinET
Definition JetHT.h:34
virtual StatusCode initialize()
Definition JetHT.cxx:53
const std::string process
uint32_t parType_t
Definition Parameter.h:22