ATLAS Offline Software
DeltaEtaIncl2.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  * DeltaEtaIncl2.cpp
6  * Created by Joerg Stelzer on 11/16/12.
7  * Modified V Sorin 2014
8  *
9  * @brief algorithm calculates the eta-distance between two lists and applies delta-eta criteria
10  *
11  * @param NumberLeading
12 **********************************/
13 
14 #include <cmath>
15 #include <string>
16 #include <iostream>
17 #include <sstream>
18 #include <vector>
19 
21 #include "L1TopoCommon/Exception.h"
24 
25 REGISTER_ALG_TCS(DeltaEtaIncl2)
26 
27 // not the best solution but we will move to athena where this comes for free
28 #define LOG cout << fullname() << ": "
29 
30 
31 
32 
33 
35 {
36  defineParameter("InputWidth1", 0);
37  defineParameter("InputWidth2", 0);
38  defineParameter("MaxTob1", 0);
39  defineParameter("MaxTob2", 0);
40  defineParameter("NumResultBits", 4);
41  defineParameter("MinET1",0,0);
42  defineParameter("MinET2",0,0);
43  defineParameter("MinET1",0,1);
44  defineParameter("MinET2",0,1);
45  defineParameter("MinET1",0,2);
46  defineParameter("MinET2",0,2);
47  defineParameter("MinET1",0,3);
48  defineParameter("MinET2",0,3);
49  defineParameter("MinDeltaEta", 0, 0);
50  defineParameter("MaxDeltaEta", 127, 0);
51  defineParameter("MinDeltaEta", 0, 1);
52  defineParameter("MaxDeltaEta", 127, 1);
53  defineParameter("MinDeltaEta", 0, 2);
54  defineParameter("MaxDeltaEta", 127, 2);
55  defineParameter("MinDeltaEta", 0, 3);
56  defineParameter("MaxDeltaEta", 127, 3);
57 
59 }
60 
62 
63 
66  p_NumberLeading1 = parameter("InputWidth1").value();
67  p_NumberLeading2 = parameter("InputWidth2").value();
68  if(parameter("MaxTob1").value() > 0) p_NumberLeading1 = parameter("MaxTob1").value();
69  if(parameter("MaxTob2").value() > 0) p_NumberLeading2 = parameter("MaxTob2").value();
70 
71  for(unsigned int i=0; i<numberOutputBits(); ++i) {
72  p_DeltaEtaMin[i] = parameter("MinDeltaEta", i).value();
73  p_DeltaEtaMax[i] = parameter("MaxDeltaEta", i).value();
74 
75  p_MinET1[i] = parameter("MinET1",i).value();
76  p_MinET2[i] = parameter("MinET2",i).value();
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  for(unsigned int i=0; i<numberOutputBits(); ++i) {
82  TRG_MSG_INFO("DeltaEtaMin0 : " << p_DeltaEtaMin[i]);
83  TRG_MSG_INFO("DeltaEtaMax0 : " << p_DeltaEtaMax[i]);
84  TRG_MSG_INFO("MinET1 : " << p_MinET1[i]);
85  TRG_MSG_INFO("MinET2 : " << p_MinET2[i]);
86  }
87  TRG_MSG_INFO("number output : " << numberOutputBits());
88 
89  // book histograms
90  for(unsigned int i=0; i<numberOutputBits(); ++i) {
91  std::string hname_accept = "hDeltaEtaIncl2_accept_bit"+std::to_string((int)i);
92  std::string hname_reject = "hDeltaEtaIncl2_reject_bit"+std::to_string((int)i);
93  // mass
94  bookHist(m_histAccept, hname_accept, "DETA", 100, p_DeltaEtaMin[i], p_DeltaEtaMax[i]);
95  bookHist(m_histReject, hname_reject, "DETA", 100, p_DeltaEtaMin[i], p_DeltaEtaMax[i]);
96  }
97 
98 
99  return StatusCode::SUCCESS;
100 }
101 
103 TCS::DeltaEtaIncl2::processBitCorrect( const std::vector<TCS::TOBArray const *> & input,
104  const std::vector<TCS::TOBArray *> & output,
105  Decision & decision )
106 
107 {
108  if( input.size() == 2) {
109  for( TOBArray::const_iterator tob1 = input[0]->begin();
110  tob1 != input[0]->end() && distance(input[0]->begin(), tob1) < p_NumberLeading1;
111  ++tob1)
112  {
113  for( TCS::TOBArray::const_iterator tob2 = input[1]->begin();
114  tob2 != input[1]->end() && distance(input[1]->begin(), tob2) < p_NumberLeading2;
115  ++tob2) {
116  // test DeltaEtaMin, DeltaEtaMax
117  unsigned int deltaEta = calcDeltaEtaBW( *tob1, *tob2 );
118  for(unsigned int i=0; i<numberOutputBits(); ++i) {
119  bool accept = false;
120  if( parType_t((*tob1)->Et()) <= p_MinET1[i]) continue; // ET cut
121  if( parType_t((*tob2)->Et()) <= p_MinET2[i]) continue; // ET cut
122  accept = deltaEta >= p_DeltaEtaMin[i] && deltaEta <= p_DeltaEtaMax[i];
123  const bool fillAccept = fillHistos() and (fillHistosBasedOnHardware() ? getDecisionHardwareBit(i) : accept);
124  const bool fillReject = fillHistos() and not fillAccept;
125  const bool alreadyFilled = decision.bit(i);
126  if( accept ) {
127  decision.setBit(i, true);
128  output[i]->push_back( TCS::CompositeTOB(*tob1, *tob2) );
129  }
130  if(fillAccept and not alreadyFilled) {
131  fillHist1D(m_histAccept[i],(float)deltaEta);
132  } else if(fillReject) {
133  fillHist1D(m_histReject[i],(float)deltaEta);
134  }
135  TRG_MSG_DEBUG("DeltaEta = " << deltaEta << " -> accept bit " << i << " -> "
136  << (accept?"pass":"fail"));
137  }
138  }
139  }
140  for (unsigned int i=0; i < numberOutputBits(); ++i) {
141  bool hasAmbiguousInputs = TSU::isAmbiguousTruncation(input[0], p_NumberLeading1, p_MinET1[i])
142  || TSU::isAmbiguousTruncation(input[1], p_NumberLeading2, p_MinET2[i]);
143  output[i]->setAmbiguityFlag(hasAmbiguousInputs);
144  }
145  } else {
146  TCS_EXCEPTION("DeltaEtaIncl2 alg must have 2 inputs, but got " << input.size());
147  }
149 }
150 
152 TCS::DeltaEtaIncl2::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  for( TOBArray::const_iterator tob1 = input[0]->begin();
158  tob1 != input[0]->end() && distance(input[0]->begin(), tob1) < p_NumberLeading1;
159  ++tob1)
160  {
161  for( TCS::TOBArray::const_iterator tob2 = input[1]->begin();
162  tob2 != input[1]->end() && distance(input[1]->begin(), tob2) < p_NumberLeading2;
163  ++tob2) {
164  // test DeltaEtaMin, DeltaEtaMax
165  unsigned int deltaEta = calcDeltaEta( *tob1, *tob2 );
166  for(unsigned int i=0; i<numberOutputBits(); ++i) {
167  bool accept = false;
168  if( parType_t((*tob1)->Et()) <= p_MinET1[i]) continue; // ET cut
169  if( parType_t((*tob2)->Et()) <= p_MinET2[i]) continue; // ET cut
170  accept = deltaEta >= p_DeltaEtaMin[i] && deltaEta <= p_DeltaEtaMax[i];
171  const bool fillAccept = fillHistos() and (fillHistosBasedOnHardware() ? getDecisionHardwareBit(i) : accept);
172  const bool fillReject = fillHistos() and not fillAccept;
173  const bool alreadyFilled = decision.bit(i);
174  if( accept ) {
175  decision.setBit(i, true);
176  output[i]->push_back( TCS::CompositeTOB(*tob1, *tob2) );
177  }
178  if(fillAccept and not alreadyFilled) {
179  fillHist1D(m_histAccept[i],(float)deltaEta);
180  } else if(fillReject) {
181  fillHist1D(m_histReject[i],(float)deltaEta);
182  }
183  TRG_MSG_DEBUG("DeltaEta = " << deltaEta << " -> accept bit " << i << " -> "
184  << (accept?"pass":"fail"));
185  }
186  }
187  }
188  } else {
189  TCS_EXCEPTION("DeltaEtaIncl2 alg must have 2 inputs, but got " << input.size());
190  }
192 }
193 
TCS::StatusCode::SUCCESS
@ SUCCESS
Definition: Trigger/TrigT1/L1Topo/L1TopoCommon/L1TopoCommon/StatusCode.h:17
TCS::DeltaEtaIncl2::DeltaEtaIncl2
DeltaEtaIncl2(const std::string &name)
Definition: DeltaEtaIncl2.cxx:34
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
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
TCS::DeltaEtaIncl2::initialize
virtual StatusCode initialize()
Definition: DeltaEtaIncl2.cxx:65
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
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::DeltaEtaIncl2::process
virtual StatusCode process(const std::vector< TCS::TOBArray const * > &input, const std::vector< TCS::TOBArray * > &output, Decision &decison)
Definition: DeltaEtaIncl2.cxx:152
TCS::ConfigurableAlg::defineParameter
void defineParameter(const std::string &name, TCS::parType_t value)
Definition: ConfigurableAlg.cxx:201
TCS::CompositeTOB
Definition: CompositeTOB.h:16
TCS_EXCEPTION
#define TCS_EXCEPTION(MSG)
Definition: Trigger/TrigT1/L1Topo/L1TopoCommon/L1TopoCommon/Exception.h:14
TCS::DeltaEtaIncl2::processBitCorrect
virtual StatusCode processBitCorrect(const std::vector< TCS::TOBArray const * > &input, const std::vector< TCS::TOBArray * > &output, Decision &decison)
Definition: DeltaEtaIncl2.cxx:103
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
DeltaEtaIncl2.h
TCS::DeltaEtaIncl2::~DeltaEtaIncl2
virtual ~DeltaEtaIncl2()
Definition: DeltaEtaIncl2.cxx:61
TCS::Decision::bit
bool bit(unsigned int index) const
Definition: L1Topo/L1TopoInterfaces/L1TopoInterfaces/Decision.h:40
TCS::DecisionAlg::setNumberOutputBits
void setNumberOutputBits(unsigned int numberOutputBits)
Definition: Trigger/TrigT1/L1Topo/L1TopoInterfaces/L1TopoInterfaces/DecisionAlg.h:40
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
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