ATLAS Offline Software
Loading...
Searching...
No Matches
ExclusiveJets.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 * ExclusiveJets.cxx
6 * Created by Carlos Moreno based on InvariantMassInclusive1 by V Sorin
7 *
8 * For questions contact atlas-trig-l1topo-algcom@cern.ch.
9 * @brief algorithm for exclusive jets acceptance
10 *
11 * @param NumberLeading
12 *
13**********************************/
14#include <cmath>
15#include <string>
16#include <iostream>
17#include <sstream>
18#include <vector>
19
24
25REGISTER_ALG_TCS(ExclusiveJets)
26
28{
29 defineParameter("InputWidth", 3);
30 defineParameter("MaxTob", 0);
31 defineParameter("NumResultBits", 6);
33
34 defineParameter("PtScale",0);
35 defineParameter("PtShift",0);
36 for (unsigned int i=0;i<numberOutputBits();i++){
37 defineParameter("MinXi", 0, i);
38 defineParameter("MaxXi", 999, i);
39 defineParameter("MinET1",0,i);
40 defineParameter("ApplyEtaCut",0,i);
41 defineParameter("MinEta1",0,i);
42 defineParameter("MaxEta1",999,i);
43 defineParameter("MinEta2",0,i);
44 defineParameter("MaxEta2",999,i);
45 }
46
47}
51 if(parameter("MaxTob").value() > 0) {
52 p_NumberLeading1 = parameter("MaxTob").value();
53 } else {
54 p_NumberLeading1 = parameter("InputWidth").value();
55 }
56 p_PtScale = parameter("PtScale").value();
57 p_PtShift = parameter("PtShift").value();
58 for(unsigned int i=0; i<numberOutputBits(); ++i) {
59
60 p_XiMin[i] = parameter("MinXi", i).value();
61 p_XiMax[i] = parameter("MaxXi", i).value();
62
63 p_MinET1[i] = parameter("MinET1",i).value();
64
65 p_ApplyEtaCut[i] = parameter("ApplyEtaCut",i).value();
66 p_MinEta1[i] = parameter("MinEta1" ,i).value();
67 p_MaxEta1[i] = parameter("MaxEta1" ,i).value();
68 p_MinEta2[i] = parameter("MinEta2" ,i).value();
69 p_MaxEta2[i] = parameter("MaxEta2" ,i).value();
70 }
71 TRG_MSG_INFO("NumberLeading1 : " << p_NumberLeading1);
72 TRG_MSG_INFO("PtScale : " << p_PtScale);
73 TRG_MSG_INFO("PtShift : " << p_PtShift);
74 for(unsigned int i=0; i<numberOutputBits(); ++i) {
75 TRG_MSG_INFO("XiMin : " << p_XiMin[i]);
76 TRG_MSG_INFO("XiMax : " << p_XiMax[i]);
77
78 TRG_MSG_INFO("MinET1 : " << p_MinET1[i]);
79
80
81 TRG_MSG_INFO("ApplyEtaCut : "<<p_ApplyEtaCut[i] );
82
83 TRG_MSG_INFO("MinEta1 : "<<p_MinEta1[i] );
84 TRG_MSG_INFO("MaxEta1 : "<<p_MaxEta1[i] );
85 TRG_MSG_INFO("MinEta2 : "<<p_MinEta2[i] );
86 TRG_MSG_INFO("MaxEta2 : "<<p_MaxEta2[i] );
87 }
88
89 TRG_MSG_INFO("number output : " << numberOutputBits());
90
91 // book histograms
92 for(unsigned int i=0; i<numberOutputBits(); ++i) {
93 std::string hname_accept = "hExclusiveJets_accept_bit"+std::to_string((int)i);
94 std::string hname_reject = "hExclusiveJets_reject_bit"+std::to_string((int)i);
95 // mass
96 bookHist(m_histAcceptX, hname_accept, "Xi1 vs Xi2", 100, p_XiMin[i], p_XiMax[i], 100, p_XiMin[i], p_XiMax[i]);
97 bookHist(m_histRejectX, hname_reject, "Xi1 vs Xi2", 100, p_XiMin[i], p_XiMax[i], 100, p_XiMin[i], p_XiMax[i]);
98 // eta2 vs. eta1
99 bookHist(m_histAcceptEta1Eta2, hname_accept, "ETA vs ETA", 100, p_MinEta1[i], p_MaxEta1[i], 100, p_MinEta2[i], p_MaxEta2[i]);
100 bookHist(m_histRejectEta1Eta2, hname_reject, "ETA vs ETA", 100, p_MinEta1[i], p_MaxEta1[i], 100, p_MinEta2[i], p_MaxEta2[i]);
101 }
102
103
104 return StatusCode::SUCCESS;
105}
107TCS::ExclusiveJets::processBitCorrect( const std::vector<TCS::TOBArray const *> & input,
108 const std::vector<TCS::TOBArray *> & output,
109 Decision & decision ) // Not really bitwise, keep the name for the future
110{
111 if(input.size() == 1) {
112
113 for( TOBArray::const_iterator tob1 = input[0]->begin();
114 tob1 != input[0]->end() && distance( input[0]->begin(), tob1) < p_NumberLeading1;
115 ++tob1)
116 {
117
118 TCS::TOBArray::const_iterator tob2 = tob1; ++tob2;
119 for( ;
120 tob2 != input[0]->end() && distance( input[0]->begin(), tob2) < p_NumberLeading1;
121 ++tob2) {
122
123 //In the ticket ATR-17320, pT_offline were defined as A*pT_L1+B, where A=1.4 and B=20 for run2
124 //A and B definition might change according to run3 configuration -> menu parameter
125 unsigned int xi_1 = TSU::Kinematics::calcXi1(*tob1,*tob2, p_PtShift, p_PtScale);
126 unsigned int xi_2 = TSU::Kinematics::calcXi2(*tob1,*tob2, p_PtShift, p_PtScale);
127
128 const int eta1 = (*tob1)->eta();
129 const int eta2 = (*tob2)->eta();
130 const unsigned int aeta1 = std::abs(eta1);
131 const unsigned int aeta2 = std::abs(eta2);
132 for(unsigned int i=0; i<numberOutputBits(); ++i) {
133 bool accept = false;
134 if( parType_t((*tob1)->Et()) <= p_MinET1[i]) continue; // ET cut
135 if( parType_t((*tob2)->Et()) <= p_MinET1[i]) continue; // ET cut
136 if(p_ApplyEtaCut[i] && //skip if not in range. eta ranges are inclusive at lower edge, exclusive at upper edge
137 ((aeta1 < p_MinEta1[i] || aeta1 >= p_MaxEta1[i] ) ||
138 (aeta2 < p_MinEta2[i] || aeta2 >= p_MaxEta2[i] ) )) continue;
139
140 //ExclusiveJets algo definition is inclusive of both edges for Xi
141 accept = (xi_1 >= p_XiMin[i]) && (xi_1 <= p_XiMax[i]) && (xi_2 >= p_XiMin[i]) && (xi_2 <= p_XiMax[i]); //
142 const bool fillAccept = fillHistos() and (fillHistosBasedOnHardware() ? getDecisionHardwareBit(i) : accept);
143 const bool fillReject = fillHistos() and not fillAccept;
144 const bool alreadyFilled = decision.bit(i);
145 if( accept ) {
146 decision.setBit(i, true);
147 output[i]->push_back( TCS::CompositeTOB(*tob1, *tob2) );
148 }
149 if(fillAccept and not alreadyFilled) {
150 fillHist2D(m_histAcceptX[i],xi_1,xi_2);
151 fillHist2D(m_histAcceptEta1Eta2[i],eta1, eta2);
152 } else if(fillReject) {
153 fillHist2D(m_histRejectX[i],xi_1,xi_2);
154 fillHist2D(m_histRejectEta1Eta2[i],eta1, eta2);
155 }
156 TRG_MSG_DEBUG("Decision " << i << ": " << (accept?"pass":"fail") << " xi_1 = " << xi_1);
157
158 }
159 }
160 }
161 } else {
162 TCS_EXCEPTION("ExclusiveJets alg must have 1 input list, but got " << input.size());
163 }
165}
167TCS::ExclusiveJets::process( const std::vector<TCS::TOBArray const *> & input,
168 const std::vector<TCS::TOBArray *> & output,
169 Decision & decision )
170{
171 if(input.size() == 1) {
172
173 for( TOBArray::const_iterator tob1 = input[0]->begin();
174 tob1 != input[0]->end() && distance( input[0]->begin(), tob1) < p_NumberLeading1;
175 ++tob1)
176 {
177
178 TCS::TOBArray::const_iterator tob2 = tob1; ++tob2;
179 for( ;
180 tob2 != input[0]->end() && distance( input[0]->begin(), tob2) < p_NumberLeading1;
181 ++tob2) {
182
183 //In the ticket ATR-17320, pT_offline were defined as A*pT_L1+B, where A=1.4 and B=20 for run2
184 //A and B definition might change according to run3 configuration.
185 double xi_1 = (1.4*parType_t((*tob1)->Et())+20.)*exp((*tob1)->etaDouble())+(1.4*parType_t((*tob2)->Et())+20.)*exp((*tob2)->etaDouble());
186 double xi_2 = (1.4*parType_t((*tob1)->Et())+20.)*exp(-1.*(*tob1)->etaDouble())+(1.4*parType_t((*tob2)->Et())+20.)*exp(-1.*(*tob2)->etaDouble());
187
188 const int eta1 = (*tob1)->eta();
189 const int eta2 = (*tob2)->eta();
190 const unsigned int aeta1 = std::abs(eta1);
191 const unsigned int aeta2 = std::abs(eta2);
192 for(unsigned int i=0; i<numberOutputBits(); ++i) {
193 bool accept = false;
194 if( parType_t((*tob1)->Et()) <= p_MinET1[i]) continue; // ET cut
195 if( parType_t((*tob2)->Et()) <= p_MinET1[i]) continue; // ET cut
196 if(p_ApplyEtaCut[i] &&
197 ((aeta1 < p_MinEta1[i] || aeta1 > p_MaxEta1[i] ) ||
198 (aeta2 < p_MinEta2[i] || aeta2 > p_MaxEta2[i] ) )) continue;
199
200 accept = (xi_1 >p_XiMin[i]) && (xi_1 < p_XiMax[i]) && (xi_2 > p_XiMin[i]) && (xi_2 < p_XiMax[i]); //
201 const bool fillAccept = fillHistos() and (fillHistosBasedOnHardware() ? getDecisionHardwareBit(i) : accept);
202 const bool fillReject = fillHistos() and not fillAccept;
203 const bool alreadyFilled = decision.bit(i);
204 if( accept ) {
205 decision.setBit(i, true);
206 output[i]->push_back( TCS::CompositeTOB(*tob1, *tob2) );
207 }
208 if(fillAccept and not alreadyFilled) {
209 fillHist2D(m_histAcceptX[i],xi_1,xi_2);
210 fillHist2D(m_histAcceptEta1Eta2[i],eta1, eta2);
211 } else if(fillReject) {
212 fillHist2D(m_histRejectX[i],xi_1,xi_2);
213 fillHist2D(m_histRejectEta1Eta2[i],eta1, eta2);
214 }
215 TRG_MSG_DEBUG("Decision " << i << ": " << (accept?"pass":"fail") << " xi_1 = " << xi_1);
216
217 }
218 }
219 }
220 } else {
221 TCS_EXCEPTION("ExclusiveJets alg must have 1 input list, but got " << input.size());
222 }
224}
#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 defineParameter(const std::string &name, TCS::parType_t value)
void fillHist2D(const std::string &histName, double x, double y)
data_t::const_iterator const_iterator
std::vector< std::string > m_histAcceptEta1Eta2
Definition DecisionAlg.h:79
void setNumberOutputBits(unsigned int numberOutputBits)
Definition DecisionAlg.h:40
DecisionAlg(const std::string &name)
Definition DecisionAlg.h:25
std::vector< std::string > m_histRejectEta1Eta2
Definition DecisionAlg.h:80
bool fillHistosBasedOnHardware() const
! getter
bool fillHistos() const
whether the monitoring histograms should be filled
std::vector< std::string > m_histRejectX
Definition DecisionAlg.h:78
std::vector< std::string > m_histAcceptX
Definition DecisionAlg.h:77
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
virtual StatusCode process(const std::vector< TCS::TOBArray const * > &input, const std::vector< TCS::TOBArray * > &output, Decision &decison) override final
parType_t p_MinEta2[6]
virtual StatusCode processBitCorrect(const std::vector< TCS::TOBArray const * > &input, const std::vector< TCS::TOBArray * > &output, Decision &decison) override final
ExclusiveJets(const std::string &name)
parType_t p_XiMin[6]
parType_t p_MaxEta2[6]
parType_t p_MinEta1[6]
parType_t p_MinET1[6]
parType_t p_MaxEta1[6]
parType_t p_XiMax[6]
parType_t p_ApplyEtaCut[6]
parType_t p_NumberLeading1
virtual StatusCode initialize() override final
uint32_t parType_t
Definition Parameter.h:22
STL namespace.
static unsigned int calcXi1(const TCS::GenericTOB *tob1, const TCS::GenericTOB *tob2, unsigned ptShift, unsigned ptScale)
static unsigned int calcXi2(const TCS::GenericTOB *tob1, const TCS::GenericTOB *tob2, unsigned ptShift, unsigned ptScale)