ATLAS Offline Software
Loading...
Searching...
No Matches
DisambiguationDetaDPhiIncl3.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 * DisambiguationDetaDPhiIncl3.cpp
6 * Created by Joerg Stelzer / V Sorin on 9/16/14.
7 *
8 * @brief algorithm calculates the dR distance between objects in three lists, check first two with eta/phi differences, if pass
9 * check dR agains 3rd object, passed if no match with 3rd
10 *
11 * @param NumberLeading
12**********************************/
13
14#include <cmath>
15
20
21REGISTER_ALG_TCS(DisambiguationDetaDPhiIncl3)
22
23
24// not the best solution but we will move to athena where this comes for free
25#define LOG std::cout << "TCS::DisambiguationDetaDPhiIncl3: "
26
27
29{
30 defineParameter("InputWidth1", 9);
31 defineParameter("InputWidth2", 9);
32 defineParameter("InputWidth3", 9);
33 defineParameter("MaxTob1", 0);
34 defineParameter("MaxTob2", 0);
35 defineParameter("MaxTob3", 0);
36 defineParameter("NumResultBits", 2);
37 defineParameter("MinET1",1);
38 defineParameter("MinET2",1);
39 defineParameter("MinET3",1);
40 defineParameter("EtaMin1",0);
41 defineParameter("EtaMax1",49);
42 defineParameter("EtaMin2",0);
43 defineParameter("EtaMax2",49);
44 defineParameter("EtaMin3",0);
45 defineParameter("EtaMax3",49);
46 defineParameter("DeltaPhiMin", 0);
47 defineParameter("DeltaPhiMax", 64);
48 defineParameter("DeltaEtaMin", 0);
49 defineParameter("DeltaEtaMax", 99);
50 defineParameter("DisambDR",0,0);
51 defineParameter("DisambDR",0,1);
53}
54
56
57
60
61 p_NumberLeading1 = parameter("InputWidth1").value();
62 p_NumberLeading2 = parameter("InputWidth2").value();
63 p_NumberLeading3 = parameter("InputWidth3").value();
64
65 if(parameter("MaxTob1").value() > 0) p_NumberLeading1 = parameter("MaxTob1").value();
66 if(parameter("MaxTob2").value() > 0) p_NumberLeading2 = parameter("MaxTob2").value();
67 if(parameter("MaxTob3").value() > 0) p_NumberLeading3 = parameter("MaxTob3").value();
68
69
70 p_MinET1 = parameter("MinET1").value();
71 p_MinET2 = parameter("MinET2").value();
72 p_MinET3 = parameter("MinET3").value();
73 p_EtaMin1 = parameter("EtaMin1").value();
74 p_EtaMax1 = parameter("EtaMax1").value();
75 p_EtaMin2 = parameter("EtaMin2").value();
76 p_EtaMax2 = parameter("EtaMax2").value();
77 p_EtaMin3 = parameter("EtaMin3").value();
78 p_EtaMax3 = parameter("EtaMax3").value();
79 p_DeltaPhiMin = parameter("DeltaPhiMin").value();
80 p_DeltaPhiMax = parameter("DeltaPhiMax").value();
81 p_DeltaEtaMin = parameter("DeltaEtaMin").value();
82 p_DeltaEtaMax = parameter("DeltaEtaMax").value();
83
84
85 for(unsigned int i=0; i<numberOutputBits(); ++i) {
86 p_DisambDR[i] = parameter("DisambDR", i).value();
87 }
88
89
90
91 TRG_MSG_INFO("MinET1 : " << p_MinET1);
92 TRG_MSG_INFO("EtaMin1 : " << p_EtaMin1);
93 TRG_MSG_INFO("EtaMax1 : " << p_EtaMax1);
94 TRG_MSG_INFO("MinET2 : " << p_MinET2);
95 TRG_MSG_INFO("EtaMin2 : " << p_EtaMin2);
96 TRG_MSG_INFO("EtaMax2 : " << p_EtaMax2);
97 TRG_MSG_INFO("MinET3 : " << p_MinET3);
98 TRG_MSG_INFO("EtaMin3 : " << p_EtaMin3);
99 TRG_MSG_INFO("EtaMax3 : " << p_EtaMax3);
100 TRG_MSG_INFO("DisambDR0 : " << p_DisambDR[0]);
101 TRG_MSG_INFO("DisambDR1 : " << p_DisambDR[1]);
102 TRG_MSG_INFO("DeltaPhimin : " << p_DeltaPhiMin);
103 TRG_MSG_INFO("DeltaPhimin : " << p_DeltaPhiMax);
104 TRG_MSG_INFO("DeltaEtamin : " << p_DeltaEtaMin);
105 TRG_MSG_INFO("DeltaEtamin : " << p_DeltaEtaMax);
106
107 TRG_MSG_INFO("number output : " << numberOutputBits());
108
109
110 return StatusCode::SUCCESS;
111}
112
113
114
116TCS::DisambiguationDetaDPhiIncl3::processBitCorrect( const std::vector<TCS::TOBArray const *> & input,
117 const std::vector<TCS::TOBArray *> & output,
118 Decision & decision )
119{
120
121
122 if( input.size() == 3) {
123
124
125 for( TOBArray::const_iterator tob1 = input[0]->begin();
126 tob1 != input[0]->end() && distance(input[0]->begin(), tob1) < p_NumberLeading1;
127 ++tob1)
128 {
129
130 if( parType_t((*tob1)->Et()) <= p_MinET1) continue; // ET cut
131 if( parType_t(std::abs((*tob1)->eta())) > p_EtaMax1 ) continue; // Eta cut
132 if( parType_t(std::abs((*tob1)->eta())) < p_EtaMin1 ) continue; // Eta cut
133
134 for( TCS::TOBArray::const_iterator tob2 = input[1]->begin();
135 tob2 != input[1]->end() && distance(input[1]->begin(), tob2) < p_NumberLeading2;
136 ++tob2) {
137
138 if( parType_t((*tob2)->Et()) <= p_MinET2) continue; // ET cut
139 if( parType_t(std::abs((*tob2)->eta())) > p_EtaMax2 ) continue; // Eta cut
140 if( parType_t(std::abs((*tob2)->eta())) < p_EtaMin2 ) continue; // Eta cut
141
142 // DeltaPhi cuts
143 unsigned int deltaPhi = calcDeltaPhiBW( *tob1, *tob2 );
144 // DeltaEta cuts
145 unsigned int deltaEta = calcDeltaEtaBW( *tob1, *tob2 );
146
147 if(deltaPhi > p_DeltaPhiMax || deltaEta > p_DeltaEtaMax) continue;
148 if (deltaEta < p_DeltaEtaMin && deltaPhi < p_DeltaPhiMin ) continue;
149
150 for( TCS::TOBArray::const_iterator tob3 = input[2]->begin();
151 tob3 != input[2]->end() ;
152 ++tob3) {
153 if( parType_t((*tob3)->Et()) <= p_MinET3) continue; // ET cut
154 if( parType_t(std::abs((*tob3)->eta())) > p_EtaMax3 ) continue; // Eta cut
155 if( parType_t(std::abs((*tob3)->eta())) < p_EtaMin3 ) continue; // Eta cut
156 unsigned int deltaR13 = calcDeltaR2BW( *tob1, *tob3 );
157 unsigned int deltaR23 = calcDeltaR2BW( *tob2, *tob3 );
158 for(unsigned int i=0; i<numberOutputBits(); ++i) {
159 bool accept = false;
160 accept = deltaR13 > p_DisambDR[i] && deltaR23 > p_DisambDR[i] ;
161 if( accept ) {
162 decision.setBit(i, true);
163 output[i]->push_back(TCS::CompositeTOB(*tob1, *tob2));
164 }
165 TRG_MSG_DEBUG("Decision " << i << ": " << (accept?"pass":"fail") << " deltaR13 = " << deltaR13 << " deltaR23 = " << deltaR23);
166 }
167 }
168 }
169 }
170 bool hasAmbiguousInputs = TSU::isAmbiguousTruncation(input[0], p_NumberLeading1, p_MinET1)
173 for (unsigned int i=0; i < numberOutputBits(); ++i) {
174 output[i]->setAmbiguityFlag(hasAmbiguousInputs);
175 }
176 } else {
177 TCS_EXCEPTION("DisambiguationDetaDPhiIncl3 alg must have 3 inputs, but got " << input.size());
178 }
180
181}
182
184TCS::DisambiguationDetaDPhiIncl3::process( const std::vector<TCS::TOBArray const *> & input,
185 const std::vector<TCS::TOBArray *> & output,
186 Decision & decision )
187{
188
189
190 if( input.size() == 3) {
191
192
193 for( TOBArray::const_iterator tob1 = input[0]->begin();
194 tob1 != input[0]->end() && distance(input[0]->begin(), tob1) < p_NumberLeading1;
195 ++tob1)
196 {
197
198 if( parType_t((*tob1)->Et()) <= p_MinET1) continue; // ET cut
199 if( parType_t(std::abs((*tob1)->eta())) > p_EtaMax1 ) continue; // Eta cut
200 if( parType_t(std::abs((*tob1)->eta())) < p_EtaMin1 ) continue; // Eta cut
201
202 for( TCS::TOBArray::const_iterator tob2 = input[1]->begin();
203 tob2 != input[1]->end() && distance(input[1]->begin(), tob2) < p_NumberLeading2;
204 ++tob2) {
205
206 if( parType_t((*tob2)->Et()) <= p_MinET2) continue; // ET cut
207 if( parType_t(std::abs((*tob2)->eta())) > p_EtaMax2 ) continue; // Eta cut
208 if( parType_t(std::abs((*tob2)->eta())) < p_EtaMin2 ) continue; // Eta cut
209
210 // DeltaPhi cuts
211 unsigned int deltaPhi = calcDeltaPhi( *tob1, *tob2 );
212 // DeltaEta cuts
213 unsigned int deltaEta = calcDeltaEta( *tob1, *tob2 );
214
215 if(deltaPhi > p_DeltaPhiMax || deltaEta > p_DeltaEtaMax) continue;
216 if (deltaEta < p_DeltaEtaMin && deltaPhi < p_DeltaPhiMin ) continue;
217
218 for( TCS::TOBArray::const_iterator tob3 = input[2]->begin();
219 tob3 != input[2]->end() ;
220 ++tob3) {
221 if( parType_t((*tob3)->Et()) <= p_MinET3) continue; // ET cut
222 if( parType_t(std::abs((*tob3)->eta())) > p_EtaMax3 ) continue; // Eta cut
223 if( parType_t(std::abs((*tob3)->eta())) < p_EtaMin3 ) continue; // Eta cut
224 unsigned int deltaR13 = calcDeltaR2( *tob1, *tob3 );
225 unsigned int deltaR23 = calcDeltaR2( *tob2, *tob3 );
226 for(unsigned int i=0; i<numberOutputBits(); ++i) {
227 bool accept = false;
228 accept = deltaR13 > p_DisambDR[i] && deltaR23 > p_DisambDR[i] ;
229 if( accept ) {
230 decision.setBit(i, true);
231 output[i]->push_back(TCS::CompositeTOB(*tob1, *tob2));
232 }
233 TRG_MSG_DEBUG("Decision " << i << ": " << (accept?"pass":"fail") << " deltaR13 = " << deltaR13 << " deltaR23 = " << deltaR23);
234 }
235 }
236 }
237 }
238 } else {
239 TCS_EXCEPTION("DisambiguationDetaDPhiIncl3 alg must have 3 inputs, but got " << input.size());
240 }
242}
#define REGISTER_ALG_TCS(CLASS)
Definition AlgFactory.h:62
Scalar deltaPhi(const MatrixBase< Derived > &vec) const
const Parameter & parameter(const std::string &parameterName) const
const std::string & name() const
unsigned int calcDeltaR2BW(const TCS::GenericTOB *tob1, const TCS::GenericTOB *tob2)
unsigned int calcDeltaPhiBW(const TCS::GenericTOB *tob1, const TCS::GenericTOB *tob2)
unsigned int calcDeltaEta(const TCS::GenericTOB *tob1, const TCS::GenericTOB *tob2)
unsigned int calcDeltaEtaBW(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 calcDeltaPhi(const TCS::GenericTOB *tob1, const TCS::GenericTOB *tob2)
data_t::const_iterator const_iterator
void setNumberOutputBits(unsigned int numberOutputBits)
Definition DecisionAlg.h:40
DecisionAlg(const std::string &name)
Definition DecisionAlg.h:25
unsigned int numberOutputBits() const
Definition DecisionAlg.h:39
void setBit(unsigned int index, bool value)
Definition Decision.cxx:12
virtual StatusCode processBitCorrect(const std::vector< TCS::TOBArray const * > &input, const std::vector< TCS::TOBArray * > &output, Decision &decison)
virtual StatusCode process(const std::vector< TCS::TOBArray const * > &input, const std::vector< TCS::TOBArray * > &output, Decision &decison)
uint32_t parType_t
Definition Parameter.h:22
bool isAmbiguousTruncation(TCS::TOBArray const *tobs, size_t pos, unsigned minEt=0)