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