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"
19 
20 
21 REGISTER_ALG_TCS(DeltaEtaPhiIncl2)
22 
23 
25 {
26  defineParameter("InputWidth1", 5);
27  defineParameter("InputWidth2", 3);
28  defineParameter("MaxTob1", 0);
29  defineParameter("MaxTob2", 0);
30  defineParameter("NumResultBits", 3);
31  defineParameter("MinET1",1,0);
32  defineParameter("MinET2",1,0);
33  defineParameter("DeltaEtaMin", 0, 0);
34  defineParameter("DeltaEtaMax", 63, 0);
35  defineParameter("DeltaPhiMin", 0, 0);
36  defineParameter("DeltaPhiMax", 63, 0);
37  defineParameter("MinET1",1,1);
38  defineParameter("MinET2",1,1);
39  defineParameter("DeltaEtaMin", 0, 1);
40  defineParameter("DeltaEtaMax", 5, 1);
41  defineParameter("DeltaPhiMin", 0, 1);
42  defineParameter("DeltaPhiMax", 5, 1);
43  defineParameter("MinET1",1,2);
44  defineParameter("MinET2",1,2);
45  defineParameter("DeltaEtaMin", 25, 2);
46  defineParameter("DeltaEtaMax", 32, 2);
47  defineParameter("DeltaPhiMin", 25, 2);
48  defineParameter("DeltaPhiMax", 32, 2);
49  setNumberOutputBits(3);
50 }
51 
53 
54 
57  p_NumberLeading1 = parameter("InputWidth1").value();
58  p_NumberLeading2 = parameter("InputWidth2").value();
59  if(parameter("MaxTob1").value() > 0) p_NumberLeading1 = parameter("MaxTob1").value();
60  if(parameter("MaxTob2").value() > 0) p_NumberLeading2 = parameter("MaxTob2").value();
61 
62  for(unsigned int i=0; i<numberOutputBits(); ++i) {
63  p_DeltaPhiMin[i] = parameter("DeltaPhiMin", i).value();
64  p_DeltaPhiMax[i] = parameter("DeltaPhiMax", i).value();
65  p_DeltaEtaMin[i] = parameter("DeltaEtaMin", i).value();
66  p_DeltaEtaMax[i] = parameter("DeltaEtaMax", i).value();
67  p_MinET1[i] = parameter("MinET1",i).value();
68  p_MinET2[i] = parameter("MinET2",i).value();
69 
70  TRG_MSG_INFO("MinET1 : " << p_MinET1[i]);
71  TRG_MSG_INFO("MinET2 : " << p_MinET2[i]);
72  TRG_MSG_INFO("DeltaEtaMin : " << p_DeltaEtaMin[i]);
73  TRG_MSG_INFO("DeltaEtaMax : " << p_DeltaEtaMax[i]);
74  TRG_MSG_INFO("DeltaPhiMin : " << p_DeltaPhiMin[i]);
75  TRG_MSG_INFO("DeltaPhiMax : " << p_DeltaPhiMax[i]);
76 
77  }
78 
79 
80  TRG_MSG_INFO("NumberLeading1 : " << p_NumberLeading1); // note that the reading of generic parameters doesn't work yet
81  TRG_MSG_INFO("NumberLeading2 : " << p_NumberLeading2);
82 
83  TRG_MSG_INFO("number output : " << numberOutputBits());
84 
85  // book histograms
86  for(unsigned int i=0; i<numberOutputBits(); ++i) {
87  std::string hname_accept = "hDeltaEtaPhiIncl2_accept_bit"+std::to_string((int)i);
88  std::string hname_reject = "hDeltaEtaPhiIncl2_reject_bit"+std::to_string((int)i);
89  // deta vs dphi
90  bookHist(m_histAccept, hname_accept, "DETA vs DPHI", 100, p_DeltaEtaMin[i], p_DeltaEtaMax[i], 100, p_DeltaPhiMin[i], p_DeltaPhiMax[i]);
91  bookHist(m_histReject, hname_reject, "DETA vs DPHI", 100, p_DeltaEtaMin[i], p_DeltaEtaMax[i], 100, p_DeltaPhiMin[i], p_DeltaPhiMax[i]);
92  }
93 
94  return StatusCode::SUCCESS;
95 }
96 
97 
98 
100 TCS::DeltaEtaPhiIncl2::processBitCorrect( const std::vector<TCS::TOBArray const *> & input,
101  const std::vector<TCS::TOBArray *> & output,
102  Decision & decision )
103 {
104  if(input.size() == 2) {
105  TRG_MSG_DEBUG("input size : " << input[0]->size());
106  unsigned int nLeading = p_NumberLeading1;
107  for( TOBArray::const_iterator tob1 = input[0]->begin();
108  tob1 != input[0]->end() && distance( input[0]->begin(), tob1) < nLeading;
109  ++tob1)
110  {
111  for( TOBArray::const_iterator tob2 = input[1]->begin();
112  tob2 != input[1]->end() && distance( input[1]->begin(), tob2) < p_NumberLeading2;
113  ++tob2) {
114  // DeltaPhi cuts
115  unsigned int deltaPhi = calcDeltaPhiBW( *tob1, *tob2 );
116  // DeltaEta cuts
117  unsigned int deltaEta = calcDeltaEtaBW( *tob1, *tob2 );
118  //
119  // to-do change message output
120  std::stringstream msgss;
121  msgss << " phi1=" << (*tob1)->phi() << " , phi2=" << (*tob2)->phi()
122  << ", DeltaPhi = " << deltaPhi << ", DeltaEta = " << deltaEta <<" -> ";
123  for(unsigned int i=0; i<numberOutputBits(); ++i) {
124  bool accept = false;
125  if( parType_t((*tob1)->Et()) <= p_MinET1[i] ) continue; // ET cut
126  if( parType_t((*tob2)->Et()) <= p_MinET2[i]) continue; // ET cut
127  accept = ( deltaEta >= p_DeltaEtaMin[i] || deltaPhi >= p_DeltaPhiMin[i] ) && deltaPhi <= p_DeltaPhiMax[i] && deltaEta <= p_DeltaEtaMax[i];
128  const bool fillAccept = fillHistos() and (fillHistosBasedOnHardware() ? getDecisionHardwareBit(i) : accept);
129  const bool fillReject = fillHistos() and not fillAccept;
130  const bool alreadyFilled = decision.bit(i);
131  if( accept ) {
132  decision.setBit(i, true);
133  output[i]->push_back( TCS::CompositeTOB(*tob1, *tob2) );
134  }
135  if(fillAccept and not alreadyFilled) {
136  fillHist2D(m_histAccept[i],(float)deltaEta,(float)deltaPhi);
137  } else if(fillReject) {
138  fillHist2D(m_histReject[i],(float)deltaEta,(float)deltaPhi);
139  }
140  msgss << "DeltaRApproxBoxCutIncl2 alg bit" << i << (accept?" pass":" fail") << "|";
141  }
142  TRG_MSG_DEBUG(msgss.str());
143  }
144  }
145  for (unsigned int i=0; i < numberOutputBits(); ++i) {
146  bool hasAmbiguousInputs = TSU::isAmbiguousTruncation(input[0], p_NumberLeading1, p_MinET1[i])
147  || TSU::isAmbiguousTruncation(input[1], p_NumberLeading2, p_MinET2[i]);
148  output[i]->setAmbiguityFlag(hasAmbiguousInputs);
149  }
150  } else {
151  TCS_EXCEPTION("DeltaEtaPhiIncl2 alg must have 2 inputs, but got " << input.size());
152  }
154 }
155 
156 
158 TCS::DeltaEtaPhiIncl2::process( const std::vector<TCS::TOBArray const *> & input,
159  const std::vector<TCS::TOBArray *> & output,
160  Decision & decision )
161 {
162  if(input.size() == 2) {
163  TRG_MSG_DEBUG("input size : " << input[0]->size());
164  unsigned int nLeading = p_NumberLeading1;
165  for( TOBArray::const_iterator tob1 = input[0]->begin();
166  tob1 != input[0]->end() && distance( input[0]->begin(), tob1) < nLeading;
167  ++tob1)
168  {
169  for( TOBArray::const_iterator tob2 = input[1]->begin();
170  tob2 != input[1]->end() && distance( input[1]->begin(), tob2) < p_NumberLeading2;
171  ++tob2) {
172  // DeltaPhi cuts
173  unsigned int deltaPhi = calcDeltaPhi( *tob1, *tob2 );
174  // DeltaEta cuts
175  unsigned int deltaEta = calcDeltaEta( *tob1, *tob2 );
176  //
177  // to-do change message output
178  std::stringstream msgss;
179  msgss << " Combination : " << distance( input[0]->begin(), tob1) << " x " << distance( input[1]->begin(), tob2) << " phi1=" << (*tob1)->phi() << " , phi2=" << (*tob2)->phi()
180  << ", DeltaPhi = " << deltaPhi << ", DeltaEta = " << deltaEta <<" -> ";
181  for(unsigned int i=0; i<numberOutputBits(); ++i) {
182  bool accept = false;
183  if( parType_t((*tob1)->Et()) <= p_MinET1[i] ) continue; // ET cut
184  if( parType_t((*tob2)->Et()) <= p_MinET2[i]) continue; // ET cut
185  accept = ( deltaEta >= p_DeltaEtaMin[i] || deltaPhi >= p_DeltaPhiMin[i] ) && deltaPhi <= p_DeltaPhiMax[i] && deltaEta <= p_DeltaEtaMax[i];
186  const bool fillAccept = fillHistos() and (fillHistosBasedOnHardware() ? getDecisionHardwareBit(i) : accept);
187  const bool fillReject = fillHistos() and not fillAccept;
188  const bool alreadyFilled = decision.bit(i);
189  if( accept ) {
190  decision.setBit(i, true);
191  output[i]->push_back( TCS::CompositeTOB(*tob1, *tob2) );
192  }
193  if(fillAccept and not alreadyFilled) {
194  fillHist2D(m_histAccept[i],(float)deltaEta,(float)deltaPhi);
195  } else if(fillReject) {
196  fillHist2D(m_histReject[i],(float)deltaEta,(float)deltaPhi);
197  }
198  msgss << "DeltaRApproxBoxCutIncl2 alg bit" << i << (accept?" pass":" fail") << "|";
199  }
200  TRG_MSG_DEBUG(msgss.str());
201  }
202  }
203  } else {
204  TCS_EXCEPTION("DeltaEtaPhiIncl2 alg must have 2 inputs, but got " << input.size());
205  }
207 }
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:161
CutsMETMaker::accept
StatusCode accept(const xAOD::Muon *mu)
Definition: CutsMETMaker.cxx:18
TSU::isAmbiguousTruncation
bool isAmbiguousTruncation(TCS::TOBArray const *tobs, size_t pos, unsigned minEt=0)
Definition: Trigger/TrigT1/L1Topo/L1TopoSimulationUtils/Root/Helpers.cxx:23
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:158
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
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
REGISTER_ALG_TCS
#define REGISTER_ALG_TCS(CLASS)
Definition: AlgFactory.h:62
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:240
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:100
Helpers.h
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:56
TCS::DeltaEtaPhiIncl2::~DeltaEtaPhiIncl2
virtual ~DeltaEtaPhiIncl2()
Definition: DeltaEtaPhiIncl2.cxx:52
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