ATLAS Offline Software
DeltaEtaPhiIncl1.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  * DeltaEtaPhiIncl1.cpp
6  * Created by Joerg Stelzer on 11/16/12.
7  * Modified by V Sorin
8  *
9  * @brief algorithm calculates the eta and phi-distance between one lists and applies box cut criteria
10  *
11  * @param NumberLeading
12 **********************************/
13 
14 #include <cmath>
15 
17 #include "L1TopoCommon/Exception.h"
19 
20 REGISTER_ALG_TCS(DeltaEtaPhiIncl1)
21 
22 
24 {
25  defineParameter("InputWidth", 3);
26  defineParameter("MaxTob", 0);
27  defineParameter("NumResultBits", 3);
28  defineParameter("MinET1",1,0);
29  defineParameter("MinET2",1,0);
30  defineParameter("MinDeltaEta", 0, 0);
31  defineParameter("MaxDeltaEta", 49, 0);
32  defineParameter("MinDeltaPhi", 0, 0);
33  defineParameter("MaxDeltaPhi", 63, 0);
34  defineParameter("MinET1",1,1);
35  defineParameter("MinET2",1,1);
36  defineParameter("MinDeltaEta", 0, 1);
37  defineParameter("MaxDeltaEta", 49, 1);
38  defineParameter("MinDeltaPhi", 0, 1);
39  defineParameter("MaxDeltaPhi", 63, 1);
40  defineParameter("MinET1",1,2);
41  defineParameter("MinET2",1,2);
42  defineParameter("MinDeltaEta", 0, 2);
43  defineParameter("MaxDeltaEta", 49, 2);
44  defineParameter("MinDeltaPhi", 0, 2);
45  defineParameter("MaxDeltaPhi", 63, 2);
46  setNumberOutputBits(3);
47 }
48 
50 
51 
54 
55  if(parameter("MaxTob").value() > 0) {
56  p_NumberLeading1 = parameter("MaxTob").value();
57  p_NumberLeading2 = parameter("MaxTob").value();
58  } else {
59  p_NumberLeading1 = parameter("InputWidth").value();
60  p_NumberLeading2 = parameter("InputWidth").value();
61  }
62 
63  for(unsigned int i=0; i<numberOutputBits(); ++i) {
64  p_DeltaPhiMin[i] = parameter("MinDeltaPhi", i).value();
65  p_DeltaPhiMax[i] = parameter("MaxDeltaPhi", i).value();
66  p_DeltaEtaMin[i] = parameter("MinDeltaEta", i).value();
67  p_DeltaEtaMax[i] = parameter("MaxDeltaEta", i).value();
68  p_MinET1[i] = parameter("MinET1",i).value();
69  p_MinET2[i] = parameter("MinET2",i).value();
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  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  TRG_MSG_INFO("number output : " << numberOutputBits());
82 
83  // book histograms
84  for(unsigned int i=0; i<numberOutputBits(); ++i) {
85  std::string hname_accept = "hDeltaEtaPhiIncl1_accept_bit"+std::to_string((int)i);
86  std::string hname_reject = "hDeltaEtaPhiIncl1_reject_bit"+std::to_string((int)i);
87  // deta vs dphi
88  bookHist(m_histAccept, hname_accept, "DETA vs DPHI", 100, p_DeltaEtaMin[i], p_DeltaEtaMax[i], 100, p_DeltaPhiMin[i], p_DeltaPhiMax[i]);
89  bookHist(m_histReject, hname_reject, "DETA vs DPHI", 100, p_DeltaEtaMin[i], p_DeltaEtaMax[i], 100, p_DeltaPhiMin[i], p_DeltaPhiMax[i]);
90  }
91 
92  return StatusCode::SUCCESS;
93 }
94 
95 
96 
98 TCS::DeltaEtaPhiIncl1::processBitCorrect( const std::vector<TCS::TOBArray const *> & input,
99  const std::vector<TCS::TOBArray *> & output,
100  Decision & decision )
101 {
102  if(input.size() == 1) {
103  TRG_MSG_DEBUG("input size : " << input[0]->size());
104  unsigned int nLeading = p_NumberLeading1;
105  for( TOBArray::const_iterator tob1 = input[0]->begin();
106  tob1 != input[0]->end() && distance( input[0]->begin(), tob1) < nLeading;
107  ++tob1)
108  {
109  TCS::TOBArray::const_iterator tob2 = tob1; ++tob2;
110  for( ;
111  tob2 != input[0]->end() && distance( input[0]->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()) <= std::min(p_MinET1[i],p_MinET2[i])) continue; // ET cut
125  if( parType_t((*tob2)->Et()) <= std::min(p_MinET1[i],p_MinET2[i])) continue; // ET cut
126  if( (parType_t((*tob1)->Et()) <= std::max(p_MinET1[i],p_MinET2[i])) && (parType_t((*tob2)->Et()) <= std::max(p_MinET1[i],p_MinET2[i]))) continue;
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 << "DeltaEtaPhiIncl1 alg bit" << i << (accept?" pass":" fail") << "|";
141  }
142  TRG_MSG_DEBUG(msgss.str());
143  }
144  }
145  } else {
146  TCS_EXCEPTION("DeltaEtaPhiIncl1 alg must have 1 input, but got " << input.size());
147  }
149 }
150 
152 TCS::DeltaEtaPhiIncl1::process( const std::vector<TCS::TOBArray const *> & input,
153  const std::vector<TCS::TOBArray *> & output,
154  Decision & decision )
155 {
156  if(input.size() == 1) {
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  TCS::TOBArray::const_iterator tob2 = tob1; ++tob2;
164  for( ;
165  tob2 != input[0]->end() && distance( input[0]->begin(), tob2) < p_NumberLeading2;
166  ++tob2) {
167  // DeltaPhi cuts
168  unsigned int deltaPhi = calcDeltaPhi( *tob1, *tob2 );
169  // DeltaEta cuts
170  unsigned int deltaEta = calcDeltaEta( *tob1, *tob2 );
171  //
172  // to-do change message output
173  std::stringstream msgss;
174  msgss << " Combination : " << distance( input[0]->begin(), tob1)
175  << " x " << distance( input[0]->begin(), tob2)
176  << " phi1=" << (*tob1)->phi()
177  << " , phi2=" << (*tob2)->phi()
178  << ", DeltaPhi = " << deltaPhi
179  << ", DeltaEta = " << deltaEta << " -> ";
180  for(unsigned int i=0; i<numberOutputBits(); ++i) {
181  bool accept = false;
182  if( parType_t((*tob1)->Et()) <= std::min(p_MinET1[i],p_MinET2[i])) continue; // ET cut
183  if( parType_t((*tob2)->Et()) <= std::min(p_MinET1[i],p_MinET2[i])) continue; // ET cut
184  if( (parType_t((*tob1)->Et()) <= std::max(p_MinET1[i],p_MinET2[i])) && (parType_t((*tob2)->Et()) <= std::max(p_MinET1[i],p_MinET2[i]))) continue;
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 << "DeltaEtaPhiIncl1 alg bit" << i << (accept?" pass":" fail") << "|";
199  }
200  TRG_MSG_DEBUG(msgss.str());
201  }
202  }
203  } else {
204  TCS_EXCEPTION("DeltaEtaPhiIncl1 alg must have 1 input, 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
max
constexpr double max()
Definition: ap_fixedTest.cxx:33
xAOD::deltaPhi
setSAddress setEtaMS setDirPhiMS setDirZMS setBarrelRadius setEndcapAlpha setEndcapRadius setInterceptInner setEtaMap setEtaBin setIsTgcFailure setDeltaPt deltaPhi
Definition: L2StandAloneMuon_v1.cxx:160
min
constexpr double min()
Definition: ap_fixedTest.cxx:26
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
TCS::DeltaEtaPhiIncl1::processBitCorrect
virtual StatusCode processBitCorrect(const std::vector< TCS::TOBArray const * > &input, const std::vector< TCS::TOBArray * > &output, Decision &decison)
Definition: DeltaEtaPhiIncl1.cxx:98
Decision.h
const
bool const RAWDATA *ch2 const
Definition: LArRodBlockPhysicsV0.cxx:560
TCS::DecisionAlg
Definition: Trigger/TrigT1/L1Topo/L1TopoInterfaces/L1TopoInterfaces/DecisionAlg.h:22
python.setupRTTAlg.size
int size
Definition: setupRTTAlg.py:39
DeltaEtaPhiIncl1.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:66
lumiFormat.i
int i
Definition: lumiFormat.py:85
TCS::DeltaEtaPhiIncl1::~DeltaEtaPhiIncl1
virtual ~DeltaEtaPhiIncl1()
Definition: DeltaEtaPhiIncl1.cxx:49
TCS::CompositeTOB
Definition: CompositeTOB.h:16
TCS::DeltaEtaPhiIncl1
Definition: DeltaEtaPhiIncl1.h:18
PlotPulseshapeFromCool.input
input
Definition: PlotPulseshapeFromCool.py:106
TCS::DeltaEtaPhiIncl1::process
virtual StatusCode process(const std::vector< TCS::TOBArray const * > &input, const std::vector< TCS::TOBArray * > &output, Decision &decison)
Definition: DeltaEtaPhiIncl1.cxx:152
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
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::DeltaEtaPhiIncl1::initialize
virtual StatusCode initialize()
Definition: DeltaEtaPhiIncl1.cxx:53
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