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