ATLAS Offline Software
DisambiguationDetaDPhiIncl3.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  * DisambiguationDetaDPhiIncl3.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 first two with eta/phi differences, if pass
9  * check dR 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(DisambiguationDetaDPhiIncl3)
21 
22 
23 // not the best solution but we will move to athena where this comes for free
24 #define LOG std::cout << "TCS::DisambiguationDetaDPhiIncl3: "
25 
26 
28 {
29  defineParameter("InputWidth1", 9);
30  defineParameter("InputWidth2", 9);
31  defineParameter("InputWidth3", 9);
32  defineParameter("MaxTob1", 0);
33  defineParameter("MaxTob2", 0);
34  defineParameter("MaxTob3", 0);
35  defineParameter("NumResultBits", 2);
36  defineParameter("MinET1",1);
37  defineParameter("MinET2",1);
38  defineParameter("MinET3",1);
39  defineParameter("EtaMin1",0);
40  defineParameter("EtaMax1",49);
41  defineParameter("EtaMin2",0);
42  defineParameter("EtaMax2",49);
43  defineParameter("EtaMin3",0);
44  defineParameter("EtaMax3",49);
45  defineParameter("DeltaPhiMin", 0);
46  defineParameter("DeltaPhiMax", 64);
47  defineParameter("DeltaEtaMin", 0);
48  defineParameter("DeltaEtaMax", 99);
49  defineParameter("DisambDR",0,0);
50  defineParameter("DisambDR",0,1);
52 }
53 
55 
56 
59 
60  p_NumberLeading1 = parameter("InputWidth1").value();
61  p_NumberLeading2 = parameter("InputWidth2").value();
62  p_NumberLeading3 = parameter("InputWidth3").value();
63 
64  if(parameter("MaxTob1").value() > 0) p_NumberLeading1 = parameter("MaxTob1").value();
65  if(parameter("MaxTob2").value() > 0) p_NumberLeading2 = parameter("MaxTob2").value();
66  if(parameter("MaxTob3").value() > 0) p_NumberLeading3 = parameter("MaxTob3").value();
67 
68 
69  p_MinET1 = parameter("MinET1").value();
70  p_MinET2 = parameter("MinET2").value();
71  p_MinET3 = parameter("MinET3").value();
72  p_EtaMin1 = parameter("EtaMin1").value();
73  p_EtaMax1 = parameter("EtaMax1").value();
74  p_EtaMin2 = parameter("EtaMin2").value();
75  p_EtaMax2 = parameter("EtaMax2").value();
76  p_EtaMin3 = parameter("EtaMin3").value();
77  p_EtaMax3 = parameter("EtaMax3").value();
78  p_DeltaPhiMin = parameter("DeltaPhiMin").value();
79  p_DeltaPhiMax = parameter("DeltaPhiMax").value();
80  p_DeltaEtaMin = parameter("DeltaEtaMin").value();
81  p_DeltaEtaMax = parameter("DeltaEtaMax").value();
82 
83 
84  for(unsigned int i=0; i<numberOutputBits(); ++i) {
85  p_DisambDR[i] = parameter("DisambDR", i).value();
86  }
87 
88 
89 
90  TRG_MSG_INFO("MinET1 : " << p_MinET1);
91  TRG_MSG_INFO("EtaMin1 : " << p_EtaMin1);
92  TRG_MSG_INFO("EtaMax1 : " << p_EtaMax1);
93  TRG_MSG_INFO("MinET2 : " << p_MinET2);
94  TRG_MSG_INFO("EtaMin2 : " << p_EtaMin2);
95  TRG_MSG_INFO("EtaMax2 : " << p_EtaMax2);
96  TRG_MSG_INFO("MinET3 : " << p_MinET3);
97  TRG_MSG_INFO("EtaMin3 : " << p_EtaMin3);
98  TRG_MSG_INFO("EtaMax3 : " << p_EtaMax3);
99  TRG_MSG_INFO("DisambDR0 : " << p_DisambDR[0]);
100  TRG_MSG_INFO("DisambDR1 : " << p_DisambDR[1]);
101  TRG_MSG_INFO("DeltaPhimin : " << p_DeltaPhiMin);
102  TRG_MSG_INFO("DeltaPhimin : " << p_DeltaPhiMax);
103  TRG_MSG_INFO("DeltaEtamin : " << p_DeltaEtaMin);
104  TRG_MSG_INFO("DeltaEtamin : " << p_DeltaEtaMax);
105 
106  TRG_MSG_INFO("number output : " << numberOutputBits());
107 
108 
109  return StatusCode::SUCCESS;
110 }
111 
112 
113 
115 TCS::DisambiguationDetaDPhiIncl3::processBitCorrect( const std::vector<TCS::TOBArray const *> & input,
116  const std::vector<TCS::TOBArray *> & output,
117  Decision & decision )
118 {
119 
120 
121  if( input.size() == 3) {
122 
123 
124  for( TOBArray::const_iterator tob1 = input[0]->begin();
125  tob1 != input[0]->end() && distance(input[0]->begin(), tob1) < p_NumberLeading1;
126  ++tob1)
127  {
128 
129  if( parType_t((*tob1)->Et()) <= p_MinET1) continue; // ET cut
130  if( parType_t(std::abs((*tob1)->eta())) > p_EtaMax1 ) continue; // Eta cut
131  if( parType_t(std::abs((*tob1)->eta())) < p_EtaMin1 ) continue; // Eta cut
132 
133  for( TCS::TOBArray::const_iterator tob2 = input[1]->begin();
134  tob2 != input[1]->end() && distance(input[1]->begin(), tob2) < p_NumberLeading2;
135  ++tob2) {
136 
137  if( parType_t((*tob2)->Et()) <= p_MinET2) continue; // ET cut
138  if( parType_t(std::abs((*tob2)->eta())) > p_EtaMax2 ) continue; // Eta cut
139  if( parType_t(std::abs((*tob2)->eta())) < p_EtaMin2 ) continue; // Eta cut
140 
141  // DeltaPhi cuts
142  unsigned int deltaPhi = calcDeltaPhiBW( *tob1, *tob2 );
143  // DeltaEta cuts
144  unsigned int deltaEta = calcDeltaEtaBW( *tob1, *tob2 );
145 
146  if(deltaPhi > p_DeltaPhiMax || deltaEta > p_DeltaEtaMax) continue;
147  if (deltaEta < p_DeltaEtaMin && deltaPhi < p_DeltaPhiMin ) continue;
148 
149  for( TCS::TOBArray::const_iterator tob3 = input[2]->begin();
150  tob3 != input[2]->end() ;
151  ++tob3) {
152  if( parType_t((*tob3)->Et()) <= p_MinET3) continue; // ET cut
153  if( parType_t(std::abs((*tob3)->eta())) > p_EtaMax3 ) continue; // Eta cut
154  if( parType_t(std::abs((*tob3)->eta())) < p_EtaMin3 ) continue; // Eta cut
155  unsigned int deltaR13 = calcDeltaR2BW( *tob1, *tob3 );
156  unsigned int deltaR23 = calcDeltaR2BW( *tob2, *tob3 );
157  for(unsigned int i=0; i<numberOutputBits(); ++i) {
158  bool accept = false;
159  accept = deltaR13 > p_DisambDR[i] && deltaR23 > p_DisambDR[i] ;
160  if( accept ) {
161  decision.setBit(i, true);
162  output[i]->push_back(TCS::CompositeTOB(*tob1, *tob2));
163  }
164  TRG_MSG_DEBUG("Decision " << i << ": " << (accept?"pass":"fail") << " deltaR13 = " << deltaR13 << " deltaR23 = " << deltaR23);
165  }
166  }
167  }
168  }
169  } else {
170  TCS_EXCEPTION("DisambiguationDetaDPhiIncl3 alg must have 3 inputs, but got " << input.size());
171  }
173 
174 }
175 
177 TCS::DisambiguationDetaDPhiIncl3::process( const std::vector<TCS::TOBArray const *> & input,
178  const std::vector<TCS::TOBArray *> & output,
179  Decision & decision )
180 {
181 
182 
183  if( input.size() == 3) {
184 
185 
186  for( TOBArray::const_iterator tob1 = input[0]->begin();
187  tob1 != input[0]->end() && distance(input[0]->begin(), tob1) < p_NumberLeading1;
188  ++tob1)
189  {
190 
191  if( parType_t((*tob1)->Et()) <= p_MinET1) continue; // ET cut
192  if( parType_t(std::abs((*tob1)->eta())) > p_EtaMax1 ) continue; // Eta cut
193  if( parType_t(std::abs((*tob1)->eta())) < p_EtaMin1 ) continue; // Eta cut
194 
195  for( TCS::TOBArray::const_iterator tob2 = input[1]->begin();
196  tob2 != input[1]->end() && distance(input[1]->begin(), tob2) < p_NumberLeading2;
197  ++tob2) {
198 
199  if( parType_t((*tob2)->Et()) <= p_MinET2) continue; // ET cut
200  if( parType_t(std::abs((*tob2)->eta())) > p_EtaMax2 ) continue; // Eta cut
201  if( parType_t(std::abs((*tob2)->eta())) < p_EtaMin2 ) continue; // Eta cut
202 
203  // DeltaPhi cuts
204  unsigned int deltaPhi = calcDeltaPhi( *tob1, *tob2 );
205  // DeltaEta cuts
206  unsigned int deltaEta = calcDeltaEta( *tob1, *tob2 );
207 
208  if(deltaPhi > p_DeltaPhiMax || deltaEta > p_DeltaEtaMax) continue;
209  if (deltaEta < p_DeltaEtaMin && deltaPhi < p_DeltaPhiMin ) continue;
210 
211  for( TCS::TOBArray::const_iterator tob3 = input[2]->begin();
212  tob3 != input[2]->end() ;
213  ++tob3) {
214  if( parType_t((*tob3)->Et()) <= p_MinET3) continue; // ET cut
215  if( parType_t(std::abs((*tob3)->eta())) > p_EtaMax3 ) continue; // Eta cut
216  if( parType_t(std::abs((*tob3)->eta())) < p_EtaMin3 ) continue; // Eta cut
217  unsigned int deltaR13 = calcDeltaR2( *tob1, *tob3 );
218  unsigned int deltaR23 = calcDeltaR2( *tob2, *tob3 );
219  for(unsigned int i=0; i<numberOutputBits(); ++i) {
220  bool accept = false;
221  accept = deltaR13 > p_DisambDR[i] && deltaR23 > p_DisambDR[i] ;
222  if( accept ) {
223  decision.setBit(i, true);
224  output[i]->push_back(TCS::CompositeTOB(*tob1, *tob2));
225  }
226  TRG_MSG_DEBUG("Decision " << i << ": " << (accept?"pass":"fail") << " deltaR13 = " << deltaR13 << " deltaR23 = " << deltaR23);
227  }
228  }
229  }
230  }
231  } else {
232  TCS_EXCEPTION("DisambiguationDetaDPhiIncl3 alg must have 3 inputs, but got " << input.size());
233  }
235 }
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
xAOD::deltaPhi
setSAddress setEtaMS setDirPhiMS setDirZMS setBarrelRadius setEndcapAlpha setEndcapRadius setInterceptInner setEtaMap setEtaBin setIsTgcFailure setDeltaPt deltaPhi
Definition: L2StandAloneMuon_v1.cxx:160
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:122
Decision.h
TCS::DisambiguationDetaDPhiIncl3::DisambiguationDetaDPhiIncl3
DisambiguationDetaDPhiIncl3(const std::string &name)
Definition: DisambiguationDetaDPhiIncl3.cxx:27
TCS::DisambiguationDetaDPhiIncl3::initialize
virtual StatusCode initialize()
Definition: DisambiguationDetaDPhiIncl3.cxx:58
TCS::DecisionAlg
Definition: Trigger/TrigT1/L1Topo/L1TopoInterfaces/L1TopoInterfaces/DecisionAlg.h:22
DisambiguationDetaDPhiIncl3.h
TCS::Decision::setBit
void setBit(unsigned int index, bool value)
Definition: L1Topo/L1TopoInterfaces/Root/Decision.cxx:12
P4Helpers::deltaEta
double deltaEta(const I4Momentum &p1, const I4Momentum &p2)
Computes efficiently .
Definition: P4Helpers.h:53
TCS::DisambiguationDetaDPhiIncl3::processBitCorrect
virtual StatusCode processBitCorrect(const std::vector< TCS::TOBArray const * > &input, const std::vector< TCS::TOBArray * > &output, Decision &decison)
Definition: DisambiguationDetaDPhiIncl3.cxx:115
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:192
TCS::DisambiguationDetaDPhiIncl3::process
virtual StatusCode process(const std::vector< TCS::TOBArray const * > &input, const std::vector< TCS::TOBArray * > &output, Decision &decison)
Definition: DisambiguationDetaDPhiIncl3.cxx:177
TCS::DecisionAlg::setNumberOutputBits
void setNumberOutputBits(unsigned int numberOutputBits)
Definition: Trigger/TrigT1/L1Topo/L1TopoInterfaces/L1TopoInterfaces/DecisionAlg.h:40
TCS::DisambiguationDetaDPhiIncl3::~DisambiguationDetaDPhiIncl3
virtual ~DisambiguationDetaDPhiIncl3()
Definition: DisambiguationDetaDPhiIncl3.cxx:54
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