ATLAS Offline Software
DeltaEtaPhiIncl2.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  * DeltaEtaPhiIncl2.cpp
6  * Created by Joerg Stelzer on 11/16/12.
7  * Modified by V SOrin 2014
8  * @brief algorithm calculates the eta and phi-distance between two lists and applies box cut criteria
9  *
10  * @param NumberLeading
11 **********************************/
12 
13 #include <cmath>
14 
16 #include "L1TopoCommon/Exception.h"
18 
19 
20 REGISTER_ALG_TCS(DeltaEtaPhiIncl2)
21 
22 
24 {
25  defineParameter("InputWidth1", 5);
26  defineParameter("InputWidth2", 3);
27  defineParameter("MaxTob1", 0);
28  defineParameter("MaxTob2", 0);
29  defineParameter("NumResultBits", 3);
30  defineParameter("MinET1",1,0);
31  defineParameter("MinET2",1,0);
32  defineParameter("DeltaEtaMin", 0, 0);
33  defineParameter("DeltaEtaMax", 63, 0);
34  defineParameter("DeltaPhiMin", 0, 0);
35  defineParameter("DeltaPhiMax", 63, 0);
36  defineParameter("MinET1",1,1);
37  defineParameter("MinET2",1,1);
38  defineParameter("DeltaEtaMin", 0, 1);
39  defineParameter("DeltaEtaMax", 5, 1);
40  defineParameter("DeltaPhiMin", 0, 1);
41  defineParameter("DeltaPhiMax", 5, 1);
42  defineParameter("MinET1",1,2);
43  defineParameter("MinET2",1,2);
44  defineParameter("DeltaEtaMin", 25, 2);
45  defineParameter("DeltaEtaMax", 32, 2);
46  defineParameter("DeltaPhiMin", 25, 2);
47  defineParameter("DeltaPhiMax", 32, 2);
48  setNumberOutputBits(3);
49 }
50 
52 
53 
56  p_NumberLeading1 = parameter("InputWidth1").value();
57  p_NumberLeading2 = parameter("InputWidth2").value();
58  if(parameter("MaxTob1").value() > 0) p_NumberLeading1 = parameter("MaxTob1").value();
59  if(parameter("MaxTob2").value() > 0) p_NumberLeading2 = parameter("MaxTob2").value();
60 
61  for(unsigned int i=0; i<numberOutputBits(); ++i) {
62  p_DeltaPhiMin[i] = parameter("DeltaPhiMin", i).value();
63  p_DeltaPhiMax[i] = parameter("DeltaPhiMax", i).value();
64  p_DeltaEtaMin[i] = parameter("DeltaEtaMin", i).value();
65  p_DeltaEtaMax[i] = parameter("DeltaEtaMax", i).value();
66  p_MinET1[i] = parameter("MinET1",i).value();
67  p_MinET2[i] = parameter("MinET2",i).value();
68 
69  TRG_MSG_INFO("MinET1 : " << p_MinET1[i]);
70  TRG_MSG_INFO("MinET2 : " << p_MinET2[i]);
71  TRG_MSG_INFO("DeltaEtaMin : " << p_DeltaEtaMin[i]);
72  TRG_MSG_INFO("DeltaEtaMax : " << p_DeltaEtaMax[i]);
73  TRG_MSG_INFO("DeltaPhiMin : " << p_DeltaPhiMin[i]);
74  TRG_MSG_INFO("DeltaPhiMax : " << p_DeltaPhiMax[i]);
75 
76  }
77 
78 
79  TRG_MSG_INFO("NumberLeading1 : " << p_NumberLeading1); // note that the reading of generic parameters doesn't work yet
80  TRG_MSG_INFO("NumberLeading2 : " << p_NumberLeading2);
81 
82  TRG_MSG_INFO("number output : " << numberOutputBits());
83 
84  // book histograms
85  for(unsigned int i=0; i<numberOutputBits(); ++i) {
86  std::string hname_accept = "hDeltaEtaPhiIncl2_accept_bit"+std::to_string((int)i);
87  std::string hname_reject = "hDeltaEtaPhiIncl2_reject_bit"+std::to_string((int)i);
88  // deta vs dphi
89  bookHist(m_histAccept, hname_accept, "DETA vs DPHI", 100, p_DeltaEtaMin[i], p_DeltaEtaMax[i], 100, p_DeltaPhiMin[i], p_DeltaPhiMax[i]);
90  bookHist(m_histReject, hname_reject, "DETA vs DPHI", 100, p_DeltaEtaMin[i], p_DeltaEtaMax[i], 100, p_DeltaPhiMin[i], p_DeltaPhiMax[i]);
91  }
92 
93  return StatusCode::SUCCESS;
94 }
95 
96 
97 
99 TCS::DeltaEtaPhiIncl2::processBitCorrect( const std::vector<TCS::TOBArray const *> & input,
100  const std::vector<TCS::TOBArray *> & output,
101  Decision & decision )
102 {
103  if(input.size() == 2) {
104  TRG_MSG_DEBUG("input size : " << input[0]->size());
105  unsigned int nLeading = p_NumberLeading1;
106  for( TOBArray::const_iterator tob1 = input[0]->begin();
107  tob1 != input[0]->end() && distance( input[0]->begin(), tob1) < nLeading;
108  ++tob1)
109  {
110  for( TOBArray::const_iterator tob2 = input[1]->begin();
111  tob2 != input[1]->end() && distance( input[1]->begin(), tob2) < p_NumberLeading2;
112  ++tob2) {
113  // DeltaPhi cuts
114  unsigned int deltaPhi = calcDeltaPhiBW( *tob1, *tob2 );
115  // DeltaEta cuts
116  unsigned int deltaEta = calcDeltaEtaBW( *tob1, *tob2 );
117  //
118  // to-do change message output
119  std::stringstream msgss;
120  msgss << " phi1=" << (*tob1)->phi() << " , phi2=" << (*tob2)->phi()
121  << ", DeltaPhi = " << deltaPhi << ", DeltaEta = " << deltaEta <<" -> ";
122  for(unsigned int i=0; i<numberOutputBits(); ++i) {
123  bool accept = false;
124  if( parType_t((*tob1)->Et()) <= p_MinET1[i] ) continue; // ET cut
125  if( parType_t((*tob2)->Et()) <= p_MinET2[i]) continue; // ET cut
126  accept = ( deltaEta >= p_DeltaEtaMin[i] || deltaPhi >= p_DeltaPhiMin[i] ) && deltaPhi <= p_DeltaPhiMax[i] && deltaEta <= p_DeltaEtaMax[i];
127  const bool fillAccept = fillHistos() and (fillHistosBasedOnHardware() ? getDecisionHardwareBit(i) : accept);
128  const bool fillReject = fillHistos() and not fillAccept;
129  const bool alreadyFilled = decision.bit(i);
130  if( accept ) {
131  decision.setBit(i, true);
132  output[i]->push_back( TCS::CompositeTOB(*tob1, *tob2) );
133  }
134  if(fillAccept and not alreadyFilled) {
135  fillHist2D(m_histAccept[i],(float)deltaEta,(float)deltaPhi);
136  } else if(fillReject) {
137  fillHist2D(m_histReject[i],(float)deltaEta,(float)deltaPhi);
138  }
139  msgss << "DeltaRApproxBoxCutIncl2 alg bit" << i << (accept?" pass":" fail") << "|";
140  }
141  TRG_MSG_DEBUG(msgss.str());
142  }
143  }
144  } else {
145  TCS_EXCEPTION("DeltaEtaPhiIncl2 alg must have 2 inputs, but got " << input.size());
146  }
148 }
149 
150 
152 TCS::DeltaEtaPhiIncl2::process( const std::vector<TCS::TOBArray const *> & input,
153  const std::vector<TCS::TOBArray *> & output,
154  Decision & decision )
155 {
156  if(input.size() == 2) {
157  TRG_MSG_DEBUG("input size : " << input[0]->size());
158  unsigned int nLeading = p_NumberLeading1;
159  for( TOBArray::const_iterator tob1 = input[0]->begin();
160  tob1 != input[0]->end() && distance( input[0]->begin(), tob1) < nLeading;
161  ++tob1)
162  {
163  for( TOBArray::const_iterator tob2 = input[1]->begin();
164  tob2 != input[1]->end() && distance( input[1]->begin(), tob2) < p_NumberLeading2;
165  ++tob2) {
166  // DeltaPhi cuts
167  unsigned int deltaPhi = calcDeltaPhi( *tob1, *tob2 );
168  // DeltaEta cuts
169  unsigned int deltaEta = calcDeltaEta( *tob1, *tob2 );
170  //
171  // to-do change message output
172  std::stringstream msgss;
173  msgss << " Combination : " << distance( input[0]->begin(), tob1) << " x " << distance( input[1]->begin(), tob2) << " phi1=" << (*tob1)->phi() << " , phi2=" << (*tob2)->phi()
174  << ", DeltaPhi = " << deltaPhi << ", DeltaEta = " << deltaEta <<" -> ";
175  for(unsigned int i=0; i<numberOutputBits(); ++i) {
176  bool accept = false;
177  if( parType_t((*tob1)->Et()) <= p_MinET1[i] ) continue; // ET cut
178  if( parType_t((*tob2)->Et()) <= p_MinET2[i]) continue; // ET cut
179  accept = ( deltaEta >= p_DeltaEtaMin[i] || deltaPhi >= p_DeltaPhiMin[i] ) && deltaPhi <= p_DeltaPhiMax[i] && deltaEta <= p_DeltaEtaMax[i];
180  const bool fillAccept = fillHistos() and (fillHistosBasedOnHardware() ? getDecisionHardwareBit(i) : accept);
181  const bool fillReject = fillHistos() and not fillAccept;
182  const bool alreadyFilled = decision.bit(i);
183  if( accept ) {
184  decision.setBit(i, true);
185  output[i]->push_back( TCS::CompositeTOB(*tob1, *tob2) );
186  }
187  if(fillAccept and not alreadyFilled) {
188  fillHist2D(m_histAccept[i],(float)deltaEta,(float)deltaPhi);
189  } else if(fillReject) {
190  fillHist2D(m_histReject[i],(float)deltaEta,(float)deltaPhi);
191  }
192  msgss << "DeltaRApproxBoxCutIncl2 alg bit" << i << (accept?" pass":" fail") << "|";
193  }
194  TRG_MSG_DEBUG(msgss.str());
195  }
196  }
197  } else {
198  TCS_EXCEPTION("DeltaEtaPhiIncl2 alg must have 2 inputs, but got " << input.size());
199  }
201 }
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:124
Decision.h
const
bool const RAWDATA *ch2 const
Definition: LArRodBlockPhysicsV0.cxx:560
TCS::DeltaEtaPhiIncl2::process
virtual StatusCode process(const std::vector< TCS::TOBArray const * > &input, const std::vector< TCS::TOBArray * > &output, Decision &decison)
Definition: DeltaEtaPhiIncl2.cxx:152
TCS::DecisionAlg
Definition: Trigger/TrigT1/L1Topo/L1TopoInterfaces/L1TopoInterfaces/DecisionAlg.h:22
python.setupRTTAlg.size
int size
Definition: setupRTTAlg.py:39
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:66
lumiFormat.i
int i
Definition: lumiFormat.py:85
TCS::CompositeTOB
Definition: CompositeTOB.h:16
PlotPulseshapeFromCool.input
input
Definition: PlotPulseshapeFromCool.py:106
DeltaEtaPhiIncl2.h
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
ActsTrk::to_string
std::string to_string(const DetectorType &type)
Definition: GeometryDefs.h:34
TCS::DeltaEtaPhiIncl2
Definition: DeltaEtaPhiIncl2.h:18
TCS
Definition: Global/GlobalSimulation/src/IO/Decision.h:18
TCS::Decision::bit
bool bit(unsigned int index) const
Definition: L1Topo/L1TopoInterfaces/L1TopoInterfaces/Decision.h:40
TCS::DeltaEtaPhiIncl2::processBitCorrect
virtual StatusCode processBitCorrect(const std::vector< TCS::TOBArray const * > &input, const std::vector< TCS::TOBArray * > &output, Decision &decison)
Definition: DeltaEtaPhiIncl2.cxx:99
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::DeltaEtaPhiIncl2::initialize
virtual StatusCode initialize()
Definition: DeltaEtaPhiIncl2.cxx:55
TCS::DeltaEtaPhiIncl2::~DeltaEtaPhiIncl2
virtual ~DeltaEtaPhiIncl2()
Definition: DeltaEtaPhiIncl2.cxx:51
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