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"
18 
19 REGISTER_ALG_TCS(DisambiguationIncl3)
20 
21 
22 // not the best solution but we will move to athena where this comes for free
23 #define LOG std::cout << "TCS::DisambiguationIncl3: "
24 
26 {
27  defineParameter("InputWidth1", 9);
28  defineParameter("InputWidth2", 9);
29  defineParameter("InputWidth3", 9);
30  defineParameter("MaxTob1", 0);
31  defineParameter("MaxTob2", 0);
32  defineParameter("MaxTob3", 0);
33  defineParameter("NumResultBits", 2);
34  defineParameter("ApplyDR",0);
35  defineParameter("MinET1",1,0);
36  defineParameter("MinET2",1,0);
37  defineParameter("MinET3",1,0);
38  defineParameter("DisambDRSqr",0,0);
39  defineParameter("MinET1",1,1);
40  defineParameter("MinET2",1,1);
41  defineParameter("MinET3",1,1);
42  defineParameter("DisambDRSqr",0,1);
44 }
45 
47 
48 
51  p_NumberLeading1 = parameter("InputWidth1").value();
52  p_NumberLeading2 = parameter("InputWidth2").value();
53  p_NumberLeading3 = parameter("InputWidth3").value();
54 
55  if(parameter("MaxTob1").value() > 0) p_NumberLeading1 = parameter("MaxTob1").value();
56  if(parameter("MaxTob2").value() > 0) p_NumberLeading2 = parameter("MaxTob2").value();
57  if(parameter("MaxTob3").value() > 0) p_NumberLeading3 = parameter("MaxTob3").value();
58 
59 
60  for(unsigned int i=0; i<numberOutputBits(); ++i) {
61  p_MinET1[i] = parameter("MinET1",i).value();
62  p_MinET2[i] = parameter("MinET2",i).value();
63  p_MinET3[i] = parameter("MinET3",i).value();
64 
65  p_DisambDR[i] = parameter("DisambDRSqr", i).value();
66 
67  TRG_MSG_INFO("MinET1 " << i << " : "<< p_MinET1[i]);
68  TRG_MSG_INFO("MinET2 " << i << " : "<< p_MinET2[i]);
69  TRG_MSG_INFO("MinET3 " << i << " : "<< p_MinET3[i]);
70  TRG_MSG_INFO("DisambDR " << i << " : "<< p_DisambDR[i]);
71 
72 
73 
74 
75  }
76 
77 
78 
79  TRG_MSG_INFO("number output : " << numberOutputBits());
80 
81 
82  return StatusCode::SUCCESS;
83 }
84 
85 
86 
88 TCS::DisambiguationIncl3::processBitCorrect( const std::vector<TCS::TOBArray const *> & input,
89  const std::vector<TCS::TOBArray *> & output,
90  Decision & decision )
91 {
92 
93 
94  if( input.size() == 3) {
95 
96 
97  for( TOBArray::const_iterator tob1 = input[0]->begin();
98  tob1 != input[0]->end() && distance(input[0]->begin(), tob1) < p_NumberLeading1;
99  ++tob1)
100  {
101 
102 
103  for( TCS::TOBArray::const_iterator tob2 = input[1]->begin();
104  tob2 != input[1]->end() && distance(input[1]->begin(), tob2) < p_NumberLeading2;
105  ++tob2) {
106 
107 
108  // test Deltaeta, Deltaphi
109 
110  if (((*tob1)->eta() == (*tob2)->eta()) && ((*tob1)->phi() == (*tob2)->phi()) ) continue; // EM matches TAU
111 
112  for( TCS::TOBArray::const_iterator tob3 = input[2]->begin();
113  tob3 != input[2]->end() ;
114  ++tob3) {
115 
116 
117  unsigned int deltaR13 = calcDeltaR2BW( *tob1, *tob3 );
118  unsigned int deltaR23 = calcDeltaR2BW( *tob2, *tob3 );
119 
120  for(unsigned int i=0; i<numberOutputBits(); ++i) {
121  bool accept = false;
122  if( parType_t((*tob1)->Et()) <= p_MinET1[i]) continue; // ET cut
123  if( parType_t((*tob2)->Et()) <= p_MinET2[i]) continue; // ET cut
124  if( parType_t((*tob3)->Et()) <= p_MinET3[i]) continue; // ET cut
125 
126  accept = deltaR13 > p_DisambDR[i] && deltaR23 > p_DisambDR[i] ;
127  if( accept ) {
128  decision.setBit(i, true);
129  output[i]->push_back(TCS::CompositeTOB(*tob1, *tob2));
130  }
131  TRG_MSG_DEBUG("Decision " << i << ": " << (accept?"pass":"fail") << " deltaR13 = " << deltaR13 << " deltaR23 = " << deltaR23);
132 
133  }
134 
135  }
136 
137 
138 
139 
140  }
141  }
142 
143  } else {
144 
145  TCS_EXCEPTION("DisambiguationIncl3 alg must have 3 inputs, but got " << input.size());
146 
147  }
149 
150 }
151 
153 TCS::DisambiguationIncl3::process( const std::vector<TCS::TOBArray const *> & input,
154  const std::vector<TCS::TOBArray *> & output,
155  Decision & decision )
156 {
157 
158 
159  if( input.size() == 3) {
160 
161 
162  for( TOBArray::const_iterator tob1 = input[0]->begin();
163  tob1 != input[0]->end() && distance(input[0]->begin(), tob1) < p_NumberLeading1;
164  ++tob1)
165  {
166 
167 
168  for( TCS::TOBArray::const_iterator tob2 = input[1]->begin();
169  tob2 != input[1]->end() && distance(input[1]->begin(), tob2) < p_NumberLeading2;
170  ++tob2) {
171 
172 
173  // test Deltaeta, Deltaphi
174 
175  if (((*tob1)->etaDouble() == (*tob2)->etaDouble()) && ((*tob1)->phiDouble() == (*tob2)->phiDouble()) ) continue; // EM matches TAU
176 
177  for( TCS::TOBArray::const_iterator tob3 = input[2]->begin();
178  tob3 != input[2]->end() ;
179  ++tob3) {
180 
181 
182  unsigned int deltaR13 = calcDeltaR2( *tob1, *tob3 );
183  unsigned int deltaR23 = calcDeltaR2( *tob2, *tob3 );
184 
185  for(unsigned int i=0; i<numberOutputBits(); ++i) {
186  bool accept = false;
187  if( parType_t((*tob1)->Et()) <= p_MinET1[i]) continue; // ET cut
188  if( parType_t((*tob2)->Et()) <= p_MinET2[i]) continue; // ET cut
189  if( parType_t((*tob3)->Et()) <= p_MinET3[i]) continue; // ET cut
190  accept = deltaR13 > p_DisambDR[i] && deltaR23 > p_DisambDR[i] ;
191  if( accept ) {
192  decision.setBit(i, true);
193  output[i]->push_back(TCS::CompositeTOB(*tob1, *tob2));
194  }
195  TRG_MSG_DEBUG("Decision " << i << ": " << (accept?"pass":"fail") << " deltaR13 = " << deltaR13 << " deltaR23 = " << deltaR23);
196  }
197 
198  }
199 
200 
201 
202 
203  }
204  }
205 
206  } else {
207 
208  TCS_EXCEPTION("DisambiguationIncl3 alg must have 3 inputs, but got " << input.size());
209 
210  }
212 }
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
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:88
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:25
TCS::CompositeTOB
Definition: CompositeTOB.h:16
PlotPulseshapeFromCool.input
input
Definition: PlotPulseshapeFromCool.py:106
TCS::DisambiguationIncl3::initialize
virtual StatusCode initialize()
Definition: DisambiguationIncl3.cxx:50
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
merge.output
output
Definition: merge.py:17
REGISTER_ALG_TCS
#define REGISTER_ALG_TCS(CLASS)
Definition: AlgFactory.h:62
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
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:153
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:46
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