ATLAS Offline Software
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 
16 #include "L1TopoCommon/Exception.h"
19 
20 REGISTER_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 
83  return StatusCode::SUCCESS;
84 }
85 
86 
87 
89 TCS::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])
145  || TSU::isAmbiguousTruncation(input[1], p_NumberLeading2, p_MinET2[i])
146  || TSU::isAmbiguousTruncation(input[2], p_NumberLeading3, p_MinET3[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 
160 TCS::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 }
TCS::StatusCode::SUCCESS
@ SUCCESS
Definition: Trigger/TrigT1/L1Topo/L1TopoCommon/L1TopoCommon/StatusCode.h:17
TCS::parType_t
uint32_t parType_t
Definition: Parameter.h:22
TCS::DataArrayImpl< GenericTOB >::const_iterator
data_t::const_iterator const_iterator
Definition: DataArrayImpl.h:18
CutsMETMaker::accept
StatusCode accept(const xAOD::Muon *mu)
Definition: CutsMETMaker.cxx:18
TSU::isAmbiguousTruncation
bool isAmbiguousTruncation(TCS::TOBArray const *tobs, size_t pos, unsigned minEt=0)
Definition: Trigger/TrigT1/L1Topo/L1TopoSimulationUtils/Root/Helpers.cxx:23
PlotCalibFromCool.begin
begin
Definition: PlotCalibFromCool.py:94
athena.value
value
Definition: athena.py:124
Decision.h
TCS::DecisionAlg
Definition: Trigger/TrigT1/L1Topo/L1TopoInterfaces/L1TopoInterfaces/DecisionAlg.h:22
TCS::Decision::setBit
void setBit(unsigned int index, bool value)
Definition: L1Topo/L1TopoInterfaces/Root/Decision.cxx:12
TCS::DisambiguationIncl3::processBitCorrect
virtual StatusCode processBitCorrect(const std::vector< TCS::TOBArray const * > &input, const std::vector< TCS::TOBArray * > &output, Decision &decison)
Definition: DisambiguationIncl3.cxx:89
lumiFormat.i
int i
Definition: lumiFormat.py:85
TCS::ConfigurableAlg::defineParameter
void defineParameter(const std::string &name, TCS::parType_t value)
Definition: ConfigurableAlg.cxx:201
TCS::DisambiguationIncl3::DisambiguationIncl3
DisambiguationIncl3(const std::string &name)
Definition: DisambiguationIncl3.cxx:26
TCS::CompositeTOB
Definition: CompositeTOB.h:16
TCS::DisambiguationIncl3::initialize
virtual StatusCode initialize()
Definition: DisambiguationIncl3.cxx:51
TCS_EXCEPTION
#define TCS_EXCEPTION(MSG)
Definition: Trigger/TrigT1/L1Topo/L1TopoCommon/L1TopoCommon/Exception.h:14
TCS::Decision
Definition: L1Topo/L1TopoInterfaces/L1TopoInterfaces/Decision.h:19
TRG_MSG_INFO
#define TRG_MSG_INFO(x)
Definition: Trigger/TrigConfiguration/TrigConfBase/TrigConfBase/MsgStreamMacros.h:27
REGISTER_ALG_TCS
#define REGISTER_ALG_TCS(CLASS)
Definition: AlgFactory.h:62
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:240
DisambiguationIncl3.h
TCS::DecisionAlg::setNumberOutputBits
void setNumberOutputBits(unsigned int numberOutputBits)
Definition: Trigger/TrigT1/L1Topo/L1TopoInterfaces/L1TopoInterfaces/DecisionAlg.h:40
TCS::DisambiguationIncl3::process
virtual StatusCode process(const std::vector< TCS::TOBArray const * > &input, const std::vector< TCS::TOBArray * > &output, Decision &decison)
Definition: DisambiguationIncl3.cxx:160
Helpers.h
Exception.h
Amg::distance
float distance(const Amg::Vector3D &p1, const Amg::Vector3D &p2)
calculates the distance between two point in 3D space
Definition: GeoPrimitivesHelpers.h:54
TCS::DisambiguationIncl3::~DisambiguationIncl3
virtual ~DisambiguationIncl3()
Definition: DisambiguationIncl3.cxx:47
TRG_MSG_DEBUG
#define TRG_MSG_DEBUG(x)
Definition: Trigger/TrigConfiguration/TrigConfBase/TrigConfBase/MsgStreamMacros.h:25
TCS::StatusCode
Definition: Trigger/TrigT1/L1Topo/L1TopoCommon/L1TopoCommon/StatusCode.h:15