ATLAS Offline Software
DisambiguationDRIncl2.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  * DisambiguationDRIncl2.cpp
6  * Created by Joerg Stelzer / V Sorin on 9/16/14.
7  *
8  * @brief algorithm calculates the dR distance between objects in two lists,
9  * but minimum value uses > instead of >= as dr algos
10  *
11  * @param NumberLeading
12 **********************************/
13 
14 #include <cmath>
15 
17 #include "L1TopoCommon/Exception.h"
19 
20 REGISTER_ALG_TCS(DisambiguationDRIncl2)
21 
22 
23 // not the best solution but we will move to athena where this comes for free
24 #define LOG std::cout << "TCS::DisambiguationDRIncl2: "
25 
26 
28 {
29  defineParameter("InputWidth1", 9);
30  defineParameter("InputWidth2", 9);
31  defineParameter("MaxTob1", 0);
32  defineParameter("MaxTob2", 0);
33  defineParameter("NumResultBits", 2);
34  defineParameter("ClusterOnly",0);
35  defineParameter("MinET1",1,0);
36  defineParameter("MinET2",1,0);
37  defineParameter("DisambDRSqrMin",0,0);
38  defineParameter("DisambDRSqrMax",0,0);
39  defineParameter("MinET1",1,1);
40  defineParameter("MinET2",1,1);
41  defineParameter("DisambDRSqrMin",0,1);
42  defineParameter("DisambDRSqrMax",0,1);
43 
45 }
46 
48 
49 
52  p_NumberLeading1 = parameter("InputWidth1").value();
53  p_NumberLeading2 = parameter("InputWidth2").value();
54  if(parameter("MaxTob1").value() > 0) p_NumberLeading1 = parameter("MaxTob1").value();
55  if(parameter("MaxTob2").value() > 0) p_NumberLeading2 = parameter("MaxTob2").value();
56 
57 
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 
64  p_DRCutMin[i] = parameter("DisambDRSqrMin", i).value();
65  p_DRCutMax[i] = parameter("DisambDRSqrMax", 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("DisambDRmin " << i << " : "<< p_DRCutMin[i]);
70  TRG_MSG_INFO("DisambDRmax " << i << " : "<< p_DRCutMax[i]);
71 
72 
73  }
74 
75 
76  TRG_MSG_INFO("number output : " << numberOutputBits());
77 
78 
79  return StatusCode::SUCCESS;
80 }
81 
82 
83 
85 TCS::DisambiguationDRIncl2::processBitCorrect( const std::vector<TCS::TOBArray const *> & input,
86  const std::vector<TCS::TOBArray *> & output,
87  Decision & decision )
88 {
89 
90 
91  if( input.size() == 2) {
92 
93 
94  for( TOBArray::const_iterator tob1 = input[0]->begin();
95  tob1 != input[0]->end() && distance(input[0]->begin(), tob1) < p_NumberLeading1;
96  ++tob1)
97  {
98 
99 
100  for( TCS::TOBArray::const_iterator tob2 = input[1]->begin();
101  tob2 != input[1]->end() && distance(input[1]->begin(), tob2) < p_NumberLeading2;
102  ++tob2) {
103  // test DeltaR2Min, DeltaR2Max
104  unsigned int deltaR2Cut = calcDeltaR2BW( *tob1, *tob2 );
105  for(unsigned int i=0; i<numberOutputBits(); ++i) {
106  bool accept = false;
107  if( parType_t((*tob1)->Et()) <= p_MinET1[i]) continue; // ET cut
108  if( parType_t((*tob2)->Et()) <= p_MinET2[i]) continue; // ET cut
109  accept = deltaR2Cut > p_DRCutMin[i] && deltaR2Cut <= p_DRCutMax[i] ;
110 
111  if( accept ) {
112  decision.setBit(i, true);
113  output[i]->push_back(TCS::CompositeTOB(*tob1, *tob2));
114  }
115  TRG_MSG_DEBUG("Decision " << i << ": " << (accept?"pass":"fail") << " deltaR = " << deltaR2Cut );
116 
117 
118  }
119 
120  }
121 
122 
123 
124  }
125 
126  } else {
127 
128  TCS_EXCEPTION("DisambiguationDRIncl2 alg must have 2 inputs, but got " << input.size());
129 
130  }
132 
133 }
134 
136 TCS::DisambiguationDRIncl2::process( const std::vector<TCS::TOBArray const *> & input,
137  const std::vector<TCS::TOBArray *> & output,
138  Decision & decision )
139 {
140 
141 
142  if( input.size() == 2) {
143 
144 
145  for( TOBArray::const_iterator tob1 = input[0]->begin();
146  tob1 != input[0]->end() && distance(input[0]->begin(), tob1) < p_NumberLeading1;
147  ++tob1)
148  {
149  for( TCS::TOBArray::const_iterator tob2 = input[1]->begin();
150  tob2 != input[1]->end() && distance(input[1]->begin(), tob2) < p_NumberLeading2;
151  ++tob2) {
152  // test DeltaR2Min, DeltaR2Max
153  unsigned int deltaR2Cut = calcDeltaR2( *tob1, *tob2 );
154  for(unsigned int i=0; i<numberOutputBits(); ++i) {
155  bool accept = false;
156  if( parType_t((*tob1)->Et()) <= p_MinET1[i]) continue; // ET cut
157  if( parType_t((*tob2)->Et()) <= p_MinET2[i]) continue; // ET cut
158  accept = deltaR2Cut > p_DRCutMin[i] && deltaR2Cut <= p_DRCutMax[i] ;
159  if( accept ) {
160  decision.setBit(i, true);
161  output[i]->push_back(TCS::CompositeTOB(*tob1, *tob2));
162  }
163  TRG_MSG_DEBUG("Decision " << i << ": " << (accept?"pass":"fail") << " deltaR = " << deltaR2Cut );
164  }
165  }
166  }
167  } else {
168  TCS_EXCEPTION("DisambiguationDRIncl2 alg must have 2 inputs, but got " << input.size());
169  }
171 }
TCS::StatusCode::SUCCESS
@ SUCCESS
Definition: Trigger/TrigT1/L1Topo/L1TopoCommon/L1TopoCommon/StatusCode.h:17
TCS::DisambiguationDRIncl2::initialize
virtual StatusCode initialize()
Definition: DisambiguationDRIncl2.cxx:51
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
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::DisambiguationDRIncl2::process
virtual StatusCode process(const std::vector< TCS::TOBArray const * > &input, const std::vector< TCS::TOBArray * > &output, Decision &decison)
Definition: DisambiguationDRIncl2.cxx:136
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
TCS::DisambiguationDRIncl2::processBitCorrect
virtual StatusCode processBitCorrect(const std::vector< TCS::TOBArray const * > &input, const std::vector< TCS::TOBArray * > &output, Decision &decison)
Definition: DisambiguationDRIncl2.cxx:85
REGISTER_ALG_TCS
#define REGISTER_ALG_TCS(CLASS)
Definition: AlgFactory.h:62
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
DisambiguationDRIncl2.h
TCS::DisambiguationDRIncl2::~DisambiguationDRIncl2
virtual ~DisambiguationDRIncl2()
Definition: DisambiguationDRIncl2.cxx:47
TCS::DecisionAlg::setNumberOutputBits
void setNumberOutputBits(unsigned int numberOutputBits)
Definition: Trigger/TrigT1/L1Topo/L1TopoInterfaces/L1TopoInterfaces/DecisionAlg.h:40
TCS::DisambiguationDRIncl2::DisambiguationDRIncl2
DisambiguationDRIncl2(const std::string &name)
Definition: DisambiguationDRIncl2.cxx:27
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