ATLAS Offline Software
DisambiguationIncl2.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  * DisambiguationIncl2.cpp
6  * Created by Joerg Stelzer / V Sorin on 2014.
7  *
8  * @brief algorithm calculates the dR distance between objects in two lists, accept if at least a pair does not match in dR
9  *
10  * @param NumberLeading
11 **********************************/
12 
13 #include <cmath>
14 
16 #include "L1TopoCommon/Exception.h"
18 
19 REGISTER_ALG_TCS(DisambiguationIncl2)
20 
21 
22 // not the best solution but we will move to athena where this comes for free
23 #define LOG std::cout << "TCS::DisambiguationIncl2: "
24 
26 {
27  defineParameter("InputWidth1", 9);
28  defineParameter("InputWidth2", 9);
29  defineParameter("MaxTob1", 0);
30  defineParameter("MaxTob2", 0);
31  defineParameter("NumResultBits", 2);
32  defineParameter("ClusterOnly",0);
33  defineParameter("ApplyDR",0);
34  defineParameter("MinET1",1,0);
35  defineParameter("MinET2",1,0);
36  defineParameter("DisambDRSqrMin",0,0);
37  defineParameter("MinET1",1,1);
38  defineParameter("MinET2",1,1);
39  defineParameter("DisambDRSqrMin",0,1);
41 }
42 
44 
45 
48  p_NumberLeading1 = parameter("InputWidth1").value();
49  p_NumberLeading2 = parameter("InputWidth2").value();
50  if(parameter("MaxTob1").value() > 0) p_NumberLeading1 = parameter("MaxTob1").value();
51  if(parameter("MaxTob2").value() > 0) p_NumberLeading2 = parameter("MaxTob2").value();
52 
53  for(unsigned int i=0; i<numberOutputBits(); ++i) {
54  p_MinET1[i] = parameter("MinET1",i).value();
55  p_MinET2[i] = parameter("MinET2",i).value();
56 
57  p_DisambDR[i] = parameter("DisambDRSqrMin", i).value();
58 
59  TRG_MSG_INFO("MinET1 " << i << " : "<< p_MinET1[i]);
60  TRG_MSG_INFO("MinET2 " << i << " : "<< p_MinET2[i]);
61  TRG_MSG_INFO("DisambDR " << i << " : "<< p_DisambDR[i]);
62 
63 
64  }
65 
66 
67  TRG_MSG_INFO("number output : " << numberOutputBits());
68 
69 
70  return StatusCode::SUCCESS;
71 }
72 
73 
74 
76 TCS::DisambiguationIncl2::processBitCorrect( const std::vector<TCS::TOBArray const *> & input,
77  const std::vector<TCS::TOBArray *> & output,
78  Decision & decision )
79 {
80 
81 
82  if( input.size() == 2) {
83 
84 
85  for( TOBArray::const_iterator tob1 = input[0]->begin();
86  tob1 != input[0]->end() && distance(input[0]->begin(), tob1) < p_NumberLeading1;
87  ++tob1)
88  {
89 
90 
91  for( TCS::TOBArray::const_iterator tob2 = input[1]->begin();
92  tob2 != input[1]->end() && distance(input[1]->begin(), tob2) < p_NumberLeading2;
93  ++tob2) {
94 
95 
96  // test DeltaR2Min, DeltaR2Max
97  unsigned int deltaR2 = calcDeltaR2BW( *tob1, *tob2 );
98 
99  for(unsigned int i=0; i<numberOutputBits(); ++i) {
100  bool accept = false;
101  if( parType_t((*tob1)->Et()) <= p_MinET1[i]) continue; // ET cut
102  if( parType_t((*tob2)->Et()) <= p_MinET2[i]) continue; // ET cut
103  accept = deltaR2 > p_DisambDR[i] ;
104  if( accept ) {
105  decision.setBit(i, true);
106  output[i]->push_back(TCS::CompositeTOB(*tob1, *tob2));
107  }
108  TRG_MSG_DEBUG("Decision " << i << ": " << (accept?"pass":"fail") << " deltaR2 = " << deltaR2);
109  }
110  }
111  }
112  } else {
113 
114  TCS_EXCEPTION("DisambiguationIncl2 alg must have 2 inputs, but got " << input.size());
115 
116  }
118 
119 }
120 
122 TCS::DisambiguationIncl2::process( const std::vector<TCS::TOBArray const *> & input,
123  const std::vector<TCS::TOBArray *> & output,
124  Decision & decision )
125 {
126 
127 
128  if( input.size() == 2) {
129 
130 
131  for( TOBArray::const_iterator tob1 = input[0]->begin();
132  tob1 != input[0]->end() && distance(input[0]->begin(), tob1) < p_NumberLeading1;
133  ++tob1)
134  {
135 
136 
137  for( TCS::TOBArray::const_iterator tob2 = input[1]->begin();
138  tob2 != input[1]->end() && distance(input[1]->begin(), tob2) < p_NumberLeading2;
139  ++tob2) {
140 
141 
142  // test DeltaR2Min, DeltaR2Max
143  unsigned int deltaR2 = calcDeltaR2( *tob1, *tob2 );
144 
145  for(unsigned int i=0; i<numberOutputBits(); ++i) {
146  bool accept = false;
147  if( parType_t((*tob1)->Et()) <= p_MinET1[i]) continue; // ET cut
148  if( parType_t((*tob2)->Et()) <= p_MinET2[i]) continue; // ET cut
149  accept = deltaR2 > p_DisambDR[i] ;
150  if( accept ) {
151  decision.setBit(i, true);
152  output[i]->push_back(TCS::CompositeTOB(*tob1, *tob2));
153  }
154  TRG_MSG_DEBUG("Decision " << i << ": " << (accept?"pass":"fail") << " deltaR2 = " << deltaR2);
155  }
156  }
157  }
158  } else {
159 
160  TCS_EXCEPTION("DisambiguationIncl2 alg must have 2 inputs, but got " << input.size());
161 
162  }
164 }
TCS::StatusCode::SUCCESS
@ SUCCESS
Definition: Trigger/TrigT1/L1Topo/L1TopoCommon/L1TopoCommon/StatusCode.h:17
DisambiguationIncl2.h
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
xAOD::P4Helpers::deltaR2
double deltaR2(double rapidity1, double phi1, double rapidity2, double phi2)
from bare rapidity,phi
Definition: xAODP4Helpers.h:111
TCS::DisambiguationIncl2::~DisambiguationIncl2
virtual ~DisambiguationIncl2()
Definition: DisambiguationIncl2.cxx:43
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::CompositeTOB
Definition: CompositeTOB.h:16
PlotPulseshapeFromCool.input
input
Definition: PlotPulseshapeFromCool.py:106
TCS::DisambiguationIncl2::processBitCorrect
virtual StatusCode processBitCorrect(const std::vector< TCS::TOBArray const * > &input, const std::vector< TCS::TOBArray * > &output, Decision &decison)
Definition: DisambiguationIncl2.cxx:76
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:221
TCS::DisambiguationIncl2::process
virtual StatusCode process(const std::vector< TCS::TOBArray const * > &input, const std::vector< TCS::TOBArray * > &output, Decision &decison)
Definition: DisambiguationIncl2.cxx:122
TCS::DisambiguationIncl2::initialize
virtual StatusCode initialize()
Definition: DisambiguationIncl2.cxx:47
TCS::DecisionAlg::setNumberOutputBits
void setNumberOutputBits(unsigned int numberOutputBits)
Definition: Trigger/TrigT1/L1Topo/L1TopoInterfaces/L1TopoInterfaces/DecisionAlg.h:40
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::DisambiguationIncl2::DisambiguationIncl2
DisambiguationIncl2(const std::string &name)
Definition: DisambiguationIncl2.cxx:25
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