ATLAS Offline Software
Loading...
Searching...
No Matches
InvariantMassInclusiveDeltaRSqrIncl1.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 * Based on InvariantMassInclusive1 and DeltaRSqrIncl1. 01/03/2019.
6 * Created by V Sorin and Joerg Stelzer 2014.
7 *
8 * @brief algorithm calculates the sqr of the INVMASS and DeltaR between one list and applies invmass and deltaR criteria
9 *
10 * @param NumberLeading
11 *
12 * For questions contact atlas-trig-l1topo-algcom@cern.ch.
13**********************************/
14
15#include <cmath>
16#include <string>
17#include <sstream>
18#include <vector>
19
24
25REGISTER_ALG_TCS(InvariantMassInclusiveDeltaRSqrIncl1)
26
27
29{
30 defineParameter("InputWidth", 3);
31 defineParameter("MaxTob", 0);
32 defineParameter("NumResultBits", 6);
33 defineParameter("RequireOneBarrel", 0);
34 defineParameter("MinMSqr", 0, 0);
35 defineParameter("MaxMSqr", 999, 0);
36 defineParameter("MinMSqr", 0, 1);
37 defineParameter("MaxMSqr", 999, 1);
38 defineParameter("MinMSqr", 0, 2);
39 defineParameter("MaxMSqr", 999, 2);
40 defineParameter("MinMSqr", 0, 3);
41 defineParameter("MaxMSqr", 999, 3);
42 defineParameter("MinMSqr", 0, 4);
43 defineParameter("MaxMSqr", 999, 4);
44 defineParameter("MinMSqr", 0, 5);
45 defineParameter("MaxMSqr", 999, 5);
46 defineParameter("MinET1",0,0);
47 defineParameter("MinET2",0,0);
48 defineParameter("MinET1",0,1);
49 defineParameter("MinET2",0,1);
50 defineParameter("MinET1",0,2);
51 defineParameter("MinET2",0,2);
52 defineParameter("MinET1",0,3);
53 defineParameter("MinET2",0,3);
54 defineParameter("MinET1",0,4);
55 defineParameter("MinET2",0,4);
56 defineParameter("MinET1",0,5);
57 defineParameter("MinET2",0,5);
58 defineParameter("DeltaRMin", 0, 0);
59 defineParameter("DeltaRMax", 0, 0);
60 defineParameter("DeltaRMin", 0, 1);
61 defineParameter("DeltaRMax", 0, 1);
62 defineParameter("DeltaRMin", 0, 2);
63 defineParameter("DeltaRMax", 0, 2);
64 defineParameter("DeltaRMin", 0, 3);
65 defineParameter("DeltaRMax", 0, 3);
66 defineParameter("DeltaRMin", 0, 4);
67 defineParameter("DeltaRMax", 0, 4);
68 defineParameter("DeltaRMin", 0, 5);
69 defineParameter("DeltaRMax", 0, 5);
70
71
73}
74
76
77
80 if(parameter("MaxTob").value() > 0) {
81 p_NumberLeading1 = parameter("MaxTob").value();
82 p_NumberLeading2 = parameter("MaxTob").value();
83 } else {
84 p_NumberLeading1 = parameter("InputWidth").value();
85 p_NumberLeading2 = parameter("InputWidth").value();
86 }
87
88 p_OneBarrel = parameter("RequireOneBarrel").value();
89
90 TRG_MSG_INFO("NumberLeading1 : " << p_NumberLeading1);
91 TRG_MSG_INFO("NumberLeading2 : " << p_NumberLeading2);
92 TRG_MSG_INFO("RequireOneBarrel : " << p_OneBarrel);
93
94 for(unsigned int i=0; i<numberOutputBits(); ++i) {
95 p_InvMassMin[i] = parameter("MinMSqr", i).value();
96 p_InvMassMax[i] = parameter("MaxMSqr", i).value();
97 p_DeltaRMin[i] = parameter("DeltaRMin", i).value();
98 p_DeltaRMax[i] = parameter("DeltaRMax", i).value();
99 p_MinET1[i] = parameter("MinET1",i).value();
100 p_MinET2[i] = parameter("MinET2",i).value();
101
102 TRG_MSG_INFO("InvMassMin "<< i << " : " << p_InvMassMin[i]);
103 TRG_MSG_INFO("InvMassMax "<< i << " : " << p_InvMassMax[i]);
104 TRG_MSG_INFO("MinET1 "<< i << " : " << p_MinET1[i]);
105 TRG_MSG_INFO("MinET2 "<< i << " : " << p_MinET2[i]);
106 TRG_MSG_INFO("DeltaRMin "<< i << " : " << p_DeltaRMin[i]);
107 TRG_MSG_INFO("DeltaRMax "<< i << " : " << p_DeltaRMax[i]);
108 }
109
110 TRG_MSG_INFO("number output : " << numberOutputBits());
111
112 // book histograms
113 for(unsigned int i=0; i<numberOutputBits(); ++i) {
114 std::string hname_accept = "hInvariantMassInclusiveDeltaRSqrIncl1_accept_bit"+std::to_string((int)i);
115 std::string hname_reject = "hInvariantMassInclusiveDeltaRSqrIncl1_reject_bit"+std::to_string((int)i);
116 // mass
117 bookHist(m_histAcceptM, hname_accept, "INVM vs DR", 100, sqrt(p_InvMassMin[i]), sqrt(p_InvMassMax[i]), 100, sqrt(p_DeltaRMin[i]), sqrt(p_DeltaRMax[i]));
118 bookHist(m_histRejectM, hname_reject, "INVM vs DR", 100, sqrt(p_InvMassMin[i]), sqrt(p_InvMassMax[i]), 100, sqrt(p_DeltaRMin[i]), sqrt(p_DeltaRMax[i]));
119
120 }
121
122 return StatusCode::SUCCESS;
123}
124
125
126
128TCS::InvariantMassInclusiveDeltaRSqrIncl1::processBitCorrect( const std::vector<TCS::TOBArray const *> & input,
129 const std::vector<TCS::TOBArray *> & output,
130 Decision & decision )
131{
132
133 if(input.size() == 1) {
134
135 for( TOBArray::const_iterator tob1 = input[0]->begin();
136 tob1 != input[0]->end() && distance( input[0]->begin(), tob1) < p_NumberLeading1;
137 ++tob1)
138 {
139
140
141 TCS::TOBArray::const_iterator tob2 = tob1; ++tob2;
142 for( ;
143 tob2 != input[0]->end() && distance( input[0]->begin(), tob2) < p_NumberLeading2;
144 ++tob2) {
145
146
147 // OneBarrel
148 if (p_OneBarrel && parType_t(abs((*tob1)->eta())) > 10 && parType_t(abs((*tob2)->eta())) > 10 ) continue;
149
150 // Inv Mass calculation
151 unsigned int invmass2 = calcInvMassBW( *tob1, *tob2 );
152 // test DeltaR2Min, DeltaR2Max
153 unsigned int deltaR2 = calcDeltaR2BW( *tob1, *tob2 );
154 TRG_MSG_DEBUG("Jet1 = " << **tob1 << ", Jet2 = " << **tob2 << ", invmass2 = " << invmass2 << ", deltaR2 = " << deltaR2);
155 for(unsigned int i=0; i<numberOutputBits(); ++i) {
156 bool accept = false;
157 if( parType_t((*tob1)->Et()) <= std::min(p_MinET1[i],p_MinET2[i])) continue; // ET cut
158 if( parType_t((*tob2)->Et()) <= std::min(p_MinET1[i],p_MinET2[i])) continue; // ET cut
159 if( (parType_t((*tob1)->Et()) <= std::max(p_MinET1[i],p_MinET2[i])) && (parType_t((*tob2)->Et()) <= std::max(p_MinET1[i],p_MinET2[i]))) continue;
160 accept = invmass2 >= p_InvMassMin[i] && invmass2 <= p_InvMassMax[i] && deltaR2 >= p_DeltaRMin[i] && deltaR2 <= p_DeltaRMax[i];
161 const bool fillAccept = fillHistos() and (fillHistosBasedOnHardware() ? getDecisionHardwareBit(i) : accept);
162 const bool fillReject = fillHistos() and not fillAccept;
163 const bool alreadyFilled = decision.bit(i);
164 if( accept ) {
165 decision.setBit(i, true);
166 output[i]->push_back( TCS::CompositeTOB(*tob1, *tob2) );
167 }
168 if(fillAccept and not alreadyFilled) {
169 fillHist2D(m_histAcceptM[i],sqrt((float)invmass2),sqrt((float)deltaR2));
170 } else if(fillReject) {
171 fillHist2D(m_histRejectM[i],sqrt((float)invmass2),sqrt((float)deltaR2));
172 }
173 TRG_MSG_DEBUG("Decision " << i << ": " << (accept?"pass":"fail") << " invmass2 = " << invmass2 << " deltaR2 = " << deltaR2 );
174 }
175 }
176 }
177 for (unsigned int i=0; i < numberOutputBits(); ++i) {
178 bool hasAmbiguousInputs = TSU::isAmbiguousTruncation(input[0], p_NumberLeading1, p_MinET1[i])
180 output[i]->setAmbiguityFlag(hasAmbiguousInputs);
181 }
182 } else {
183
184 TCS_EXCEPTION("InvariantMassInclusiveDeltaRSqrIncl1 alg must have either 1 inputs, but got " << input.size());
185
186 }
187
189
190}
191
193TCS::InvariantMassInclusiveDeltaRSqrIncl1::process( const std::vector<TCS::TOBArray const *> & input,
194 const std::vector<TCS::TOBArray *> & output,
195 Decision & decision )
196{
197
198 if(input.size() == 1) {
199 for( TOBArray::const_iterator tob1 = input[0]->begin();
200 tob1 != input[0]->end() && distance( input[0]->begin(), tob1) < p_NumberLeading1;
201 ++tob1)
202 {
203
204
205 TCS::TOBArray::const_iterator tob2 = tob1; ++tob2;
206 for( ;
207 tob2 != input[0]->end() && distance( input[0]->begin(), tob2) < p_NumberLeading2;
208 ++tob2) {
209
210
211 // OneBarrel
212 if (p_OneBarrel && parType_t(abs((*tob1)->eta())) > 10 && parType_t(abs((*tob2)->eta())) > 10 ) continue;
213
214 // Inv Mass calculation
215 unsigned int invmass2 = calcInvMass( *tob1, *tob2 );
216 // test DeltaR2Min, DeltaR2Max
217 unsigned int deltaR2 = calcDeltaR2( *tob1, *tob2 );
218 TRG_MSG_DEBUG("Jet1 = " << **tob1 << ", Jet2 = " << **tob2 << ", invmass2 = " << invmass2 << ", deltaR2 = " << deltaR2);
219
220 for(unsigned int i=0; i<numberOutputBits(); ++i) {
221 bool accept = false;
222 if( parType_t((*tob1)->Et()) <= std::min(p_MinET1[i],p_MinET2[i])) continue; // ET cut
223 if( parType_t((*tob2)->Et()) <= std::min(p_MinET1[i],p_MinET2[i])) continue; // ET cut
224 if( (parType_t((*tob1)->Et()) <= std::max(p_MinET1[i],p_MinET2[i])) && (parType_t((*tob2)->Et()) <= std::max(p_MinET1[i],p_MinET2[i]))) continue;
225 accept = invmass2 >= p_InvMassMin[i] && invmass2 <= p_InvMassMax[i] && deltaR2 >= p_DeltaRMin[i] && deltaR2 <= p_DeltaRMax[i];
226 const bool fillAccept = fillHistos() and (fillHistosBasedOnHardware() ? getDecisionHardwareBit(i) : accept);
227 const bool fillReject = fillHistos() and not fillAccept;
228 const bool alreadyFilled = decision.bit(i);
229 if( accept ) {
230 decision.setBit(i, true);
231 output[i]->push_back( TCS::CompositeTOB(*tob1, *tob2) );
232 }
233 if(fillAccept and not alreadyFilled) {
234 fillHist2D(m_histAcceptM[i],sqrt((float)invmass2),sqrt((float)deltaR2));
235 } else if(fillReject) {
236 fillHist2D(m_histRejectM[i],sqrt((float)invmass2),sqrt((float)deltaR2));
237 }
238 TRG_MSG_DEBUG("Decision " << i << ": " << (accept?"pass":"fail") << " invmass2 = " << invmass2 << " deltaR2 = " << deltaR2 );
239 }
240 }
241 }
242 } else {
243
244 TCS_EXCEPTION("InvariantMassInclusiveDeltaRSqrIncl1 alg must have either 1 inputs, but got " << input.size());
245
246 }
247
249}
#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)
unsigned int calcDeltaR2BW(const TCS::GenericTOB *tob1, const TCS::GenericTOB *tob2)
unsigned int calcInvMassBW(const TCS::GenericTOB *tob1, const TCS::GenericTOB *tob2)
void defineParameter(const std::string &name, TCS::parType_t value)
unsigned int calcDeltaR2(const TCS::GenericTOB *tob1, const TCS::GenericTOB *tob2)
unsigned int calcInvMass(const TCS::GenericTOB *tob1, const TCS::GenericTOB *tob2)
void fillHist2D(const std::string &histName, double x, double y)
data_t::const_iterator const_iterator
std::vector< std::string > m_histAcceptM
Definition DecisionAlg.h:75
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
unsigned int numberOutputBits() const
Definition DecisionAlg.h:39
bool getDecisionHardwareBit(const unsigned int &bitNumber) const
! get one hardware decision bit from this algo
std::vector< std::string > m_histRejectM
Definition DecisionAlg.h:76
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
virtual StatusCode processBitCorrect(const std::vector< TCS::TOBArray const * > &input, const std::vector< TCS::TOBArray * > &output, Decision &decison) override final
uint32_t parType_t
Definition Parameter.h:22
bool isAmbiguousTruncation(TCS::TOBArray const *tobs, size_t pos, unsigned minEt=0)
STL namespace.