ATLAS Offline Software
Loading...
Searching...
No Matches
DisambiguationIncl3.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 * DisambiguationIncl3.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 EM vs TAU , if those not match, check agains 3rd object, passed if no match with 3rd
9 *
10 * @param NumberLeading
11**********************************/
12
13#include <cmath>
14
19
20REGISTER_ALG_TCS(DisambiguationIncl3)
21
22
23// not the best solution but we will move to athena where this comes for free
24#define LOG std::cout << "TCS::DisambiguationIncl3: "
25
27{
28 defineParameter("InputWidth1", 9);
29 defineParameter("InputWidth2", 9);
30 defineParameter("InputWidth3", 9);
31 defineParameter("MaxTob1", 0);
32 defineParameter("MaxTob2", 0);
33 defineParameter("MaxTob3", 0);
34 defineParameter("NumResultBits", 2);
35 defineParameter("ApplyDR",0);
36 defineParameter("MinET1",1,0);
37 defineParameter("MinET2",1,0);
38 defineParameter("MinET3",1,0);
39 defineParameter("DisambDRSqr",0,0);
40 defineParameter("MinET1",1,1);
41 defineParameter("MinET2",1,1);
42 defineParameter("MinET3",1,1);
43 defineParameter("DisambDRSqr",0,1);
45}
46
48
49
52 p_NumberLeading1 = parameter("InputWidth1").value();
53 p_NumberLeading2 = parameter("InputWidth2").value();
54 p_NumberLeading3 = parameter("InputWidth3").value();
55
56 if(parameter("MaxTob1").value() > 0) p_NumberLeading1 = parameter("MaxTob1").value();
57 if(parameter("MaxTob2").value() > 0) p_NumberLeading2 = parameter("MaxTob2").value();
58 if(parameter("MaxTob3").value() > 0) p_NumberLeading3 = parameter("MaxTob3").value();
59
60
61 for(unsigned int i=0; i<numberOutputBits(); ++i) {
62 p_MinET1[i] = parameter("MinET1",i).value();
63 p_MinET2[i] = parameter("MinET2",i).value();
64 p_MinET3[i] = parameter("MinET3",i).value();
65
66 p_DisambDR[i] = parameter("DisambDRSqr", i).value();
67
68 TRG_MSG_INFO("MinET1 " << i << " : "<< p_MinET1[i]);
69 TRG_MSG_INFO("MinET2 " << i << " : "<< p_MinET2[i]);
70 TRG_MSG_INFO("MinET3 " << i << " : "<< p_MinET3[i]);
71 TRG_MSG_INFO("DisambDR " << i << " : "<< p_DisambDR[i]);
72
73
74
75
76 }
77
78
79
80 TRG_MSG_INFO("number output : " << numberOutputBits());
81
82
84}
85
86
87
89TCS::DisambiguationIncl3::processBitCorrect( const std::vector<TCS::TOBArray const *> & input,
90 const std::vector<TCS::TOBArray *> & output,
91 Decision & decision )
92{
93
94
95 if( input.size() == 3) {
96
97
98 for( TOBArray::const_iterator tob1 = input[0]->begin();
99 tob1 != input[0]->end() && distance(input[0]->begin(), tob1) < p_NumberLeading1;
100 ++tob1)
101 {
102
103
104 for( TCS::TOBArray::const_iterator tob2 = input[1]->begin();
105 tob2 != input[1]->end() && distance(input[1]->begin(), tob2) < p_NumberLeading2;
106 ++tob2) {
107
108
109 // test Deltaeta, Deltaphi
110
111 if (((*tob1)->eta() == (*tob2)->eta()) && ((*tob1)->phi() == (*tob2)->phi()) ) continue; // EM matches TAU
112
113 for( TCS::TOBArray::const_iterator tob3 = input[2]->begin();
114 tob3 != input[2]->end() ;
115 ++tob3) {
116
117
118 unsigned int deltaR13 = calcDeltaR2BW( *tob1, *tob3 );
119 unsigned int deltaR23 = calcDeltaR2BW( *tob2, *tob3 );
120
121 for(unsigned int i=0; i<numberOutputBits(); ++i) {
122 bool accept = false;
123 if( parType_t((*tob1)->Et()) <= p_MinET1[i]) continue; // ET cut
124 if( parType_t((*tob2)->Et()) <= p_MinET2[i]) continue; // ET cut
125 if( parType_t((*tob3)->Et()) <= p_MinET3[i]) continue; // ET cut
126
127 accept = deltaR13 > p_DisambDR[i] && deltaR23 > p_DisambDR[i] ;
128 if( accept ) {
129 decision.setBit(i, true);
130 output[i]->push_back(TCS::CompositeTOB(*tob1, *tob2));
131 }
132 TRG_MSG_DEBUG("Decision " << i << ": " << (accept?"pass":"fail") << " deltaR13 = " << deltaR13 << " deltaR23 = " << deltaR23);
133
134 }
135
136 }
137
138
139
140
141 }
142 }
143 for (unsigned int i=0; i < numberOutputBits(); ++i) {
144 bool hasAmbiguousInputs = TSU::isAmbiguousTruncation(input[0], p_NumberLeading1, p_MinET1[i])
147 output[i]->setAmbiguityFlag(hasAmbiguousInputs);
148 }
149
150 } else {
151
152 TCS_EXCEPTION("DisambiguationIncl3 alg must have 3 inputs, but got " << input.size());
153
154 }
156
157}
158
160TCS::DisambiguationIncl3::process( const std::vector<TCS::TOBArray const *> & input,
161 const std::vector<TCS::TOBArray *> & output,
162 Decision & decision )
163{
164
165
166 if( input.size() == 3) {
167
168
169 for( TOBArray::const_iterator tob1 = input[0]->begin();
170 tob1 != input[0]->end() && distance(input[0]->begin(), tob1) < p_NumberLeading1;
171 ++tob1)
172 {
173
174
175 for( TCS::TOBArray::const_iterator tob2 = input[1]->begin();
176 tob2 != input[1]->end() && distance(input[1]->begin(), tob2) < p_NumberLeading2;
177 ++tob2) {
178
179
180 // test Deltaeta, Deltaphi
181
182 if (((*tob1)->etaDouble() == (*tob2)->etaDouble()) && ((*tob1)->phiDouble() == (*tob2)->phiDouble()) ) continue; // EM matches TAU
183
184 for( TCS::TOBArray::const_iterator tob3 = input[2]->begin();
185 tob3 != input[2]->end() ;
186 ++tob3) {
187
188
189 unsigned int deltaR13 = calcDeltaR2( *tob1, *tob3 );
190 unsigned int deltaR23 = calcDeltaR2( *tob2, *tob3 );
191
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_MinET2[i]) continue; // ET cut
196 if( parType_t((*tob3)->Et()) <= p_MinET3[i]) continue; // ET cut
197 accept = deltaR13 > p_DisambDR[i] && deltaR23 > p_DisambDR[i] ;
198 if( accept ) {
199 decision.setBit(i, true);
200 output[i]->push_back(TCS::CompositeTOB(*tob1, *tob2));
201 }
202 TRG_MSG_DEBUG("Decision " << i << ": " << (accept?"pass":"fail") << " deltaR13 = " << deltaR13 << " deltaR23 = " << deltaR23);
203 }
204
205 }
206
207
208
209
210 }
211 }
212
213 } else {
214
215 TCS_EXCEPTION("DisambiguationIncl3 alg must have 3 inputs, but got " << input.size());
216
217 }
219}
#define REGISTER_ALG_TCS(CLASS)
Definition AlgFactory.h:62
const Parameter & parameter(const std::string &parameterName) const
const std::string & name() const
unsigned int calcDeltaR2BW(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)
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 initialize()
virtual StatusCode process(const std::vector< TCS::TOBArray const * > &input, const std::vector< TCS::TOBArray * > &output, Decision &decison)
virtual StatusCode processBitCorrect(const std::vector< TCS::TOBArray const * > &input, const std::vector< TCS::TOBArray * > &output, Decision &decison)
DisambiguationIncl3(const std::string &name)
uint32_t parType_t
Definition Parameter.h:22
bool isAmbiguousTruncation(TCS::TOBArray const *tobs, size_t pos, unsigned minEt=0)