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"
23 
24 REGISTER_ALG_TCS(DeltaEtaIncl2)
25 
26 // not the best solution but we will move to athena where this comes for free
27 #define LOG cout << fullname() << ": "
28 
29 
30 
31 
32 
34 {
35  defineParameter("InputWidth1", 0);
36  defineParameter("InputWidth2", 0);
37  defineParameter("MaxTob1", 0);
38  defineParameter("MaxTob2", 0);
39  defineParameter("NumResultBits", 4);
40  defineParameter("MinET1",0,0);
41  defineParameter("MinET2",0,0);
42  defineParameter("MinET1",0,1);
43  defineParameter("MinET2",0,1);
44  defineParameter("MinET1",0,2);
45  defineParameter("MinET2",0,2);
46  defineParameter("MinET1",0,3);
47  defineParameter("MinET2",0,3);
48  defineParameter("MinDeltaEta", 0, 0);
49  defineParameter("MaxDeltaEta", 127, 0);
50  defineParameter("MinDeltaEta", 0, 1);
51  defineParameter("MaxDeltaEta", 127, 1);
52  defineParameter("MinDeltaEta", 0, 2);
53  defineParameter("MaxDeltaEta", 127, 2);
54  defineParameter("MinDeltaEta", 0, 3);
55  defineParameter("MaxDeltaEta", 127, 3);
56 
58 }
59 
61 
62 
65  p_NumberLeading1 = parameter("InputWidth1").value();
66  p_NumberLeading2 = parameter("InputWidth2").value();
67  if(parameter("MaxTob1").value() > 0) p_NumberLeading1 = parameter("MaxTob1").value();
68  if(parameter("MaxTob2").value() > 0) p_NumberLeading2 = parameter("MaxTob2").value();
69 
70  for(unsigned int i=0; i<numberOutputBits(); ++i) {
71  p_DeltaEtaMin[i] = parameter("MinDeltaEta", i).value();
72  p_DeltaEtaMax[i] = parameter("MaxDeltaEta", i).value();
73 
74  p_MinET1[i] = parameter("MinET1",i).value();
75  p_MinET2[i] = parameter("MinET2",i).value();
76  }
77 
78  TRG_MSG_INFO("NumberLeading1 : " << p_NumberLeading1); // note that the reading of generic parameters doesn't work yet
79  TRG_MSG_INFO("NumberLeading2 : " << p_NumberLeading2);
80  for(unsigned int i=0; i<numberOutputBits(); ++i) {
81  TRG_MSG_INFO("DeltaEtaMin0 : " << p_DeltaEtaMin[i]);
82  TRG_MSG_INFO("DeltaEtaMax0 : " << p_DeltaEtaMax[i]);
83  TRG_MSG_INFO("MinET1 : " << p_MinET1[i]);
84  TRG_MSG_INFO("MinET2 : " << p_MinET2[i]);
85  }
86  TRG_MSG_INFO("number output : " << numberOutputBits());
87 
88  // book histograms
89  for(unsigned int i=0; i<numberOutputBits(); ++i) {
90  std::string hname_accept = "hDeltaEtaIncl2_accept_bit"+std::to_string((int)i);
91  std::string hname_reject = "hDeltaEtaIncl2_reject_bit"+std::to_string((int)i);
92  // mass
93  bookHist(m_histAccept, hname_accept, "DETA", 100, p_DeltaEtaMin[i], p_DeltaEtaMax[i]);
94  bookHist(m_histReject, hname_reject, "DETA", 100, p_DeltaEtaMin[i], p_DeltaEtaMax[i]);
95  }
96 
97 
98  return StatusCode::SUCCESS;
99 }
100 
102 TCS::DeltaEtaIncl2::processBitCorrect( const std::vector<TCS::TOBArray const *> & input,
103  const std::vector<TCS::TOBArray *> & output,
104  Decision & decision )
105 
106 {
107  if( input.size() == 2) {
108  for( TOBArray::const_iterator tob1 = input[0]->begin();
109  tob1 != input[0]->end() && distance(input[0]->begin(), tob1) < p_NumberLeading1;
110  ++tob1)
111  {
112  for( TCS::TOBArray::const_iterator tob2 = input[1]->begin();
113  tob2 != input[1]->end() && distance(input[1]->begin(), tob2) < p_NumberLeading2;
114  ++tob2) {
115  // test DeltaEtaMin, DeltaEtaMax
116  unsigned int deltaEta = calcDeltaEtaBW( *tob1, *tob2 );
117  for(unsigned int i=0; i<numberOutputBits(); ++i) {
118  bool accept = false;
119  if( parType_t((*tob1)->Et()) <= p_MinET1[i]) continue; // ET cut
120  if( parType_t((*tob2)->Et()) <= p_MinET2[i]) continue; // ET cut
121  accept = deltaEta >= p_DeltaEtaMin[i] && deltaEta <= p_DeltaEtaMax[i];
122  const bool fillAccept = fillHistos() and (fillHistosBasedOnHardware() ? getDecisionHardwareBit(i) : accept);
123  const bool fillReject = fillHistos() and not fillAccept;
124  const bool alreadyFilled = decision.bit(i);
125  if( accept ) {
126  decision.setBit(i, true);
127  output[i]->push_back( TCS::CompositeTOB(*tob1, *tob2) );
128  }
129  if(fillAccept and not alreadyFilled) {
130  fillHist1D(m_histAccept[i],(float)deltaEta);
131  } else if(fillReject) {
132  fillHist1D(m_histReject[i],(float)deltaEta);
133  }
134  TRG_MSG_DEBUG("DeltaEta = " << deltaEta << " -> accept bit " << i << " -> "
135  << (accept?"pass":"fail"));
136  }
137  }
138  }
139  } else {
140  TCS_EXCEPTION("DeltaEtaIncl2 alg must have 2 inputs, but got " << input.size());
141  }
143 }
144 
146 TCS::DeltaEtaIncl2::process( const std::vector<TCS::TOBArray const *> & input,
147  const std::vector<TCS::TOBArray *> & output,
148  Decision & decision )
149 {
150  if( input.size() == 2) {
151  for( TOBArray::const_iterator tob1 = input[0]->begin();
152  tob1 != input[0]->end() && distance(input[0]->begin(), tob1) < p_NumberLeading1;
153  ++tob1)
154  {
155  for( TCS::TOBArray::const_iterator tob2 = input[1]->begin();
156  tob2 != input[1]->end() && distance(input[1]->begin(), tob2) < p_NumberLeading2;
157  ++tob2) {
158  // test DeltaEtaMin, DeltaEtaMax
159  unsigned int deltaEta = calcDeltaEta( *tob1, *tob2 );
160  for(unsigned int i=0; i<numberOutputBits(); ++i) {
161  bool accept = false;
162  if( parType_t((*tob1)->Et()) <= p_MinET1[i]) continue; // ET cut
163  if( parType_t((*tob2)->Et()) <= p_MinET2[i]) continue; // ET cut
164  accept = deltaEta >= p_DeltaEtaMin[i] && deltaEta <= p_DeltaEtaMax[i];
165  const bool fillAccept = fillHistos() and (fillHistosBasedOnHardware() ? getDecisionHardwareBit(i) : accept);
166  const bool fillReject = fillHistos() and not fillAccept;
167  const bool alreadyFilled = decision.bit(i);
168  if( accept ) {
169  decision.setBit(i, true);
170  output[i]->push_back( TCS::CompositeTOB(*tob1, *tob2) );
171  }
172  if(fillAccept and not alreadyFilled) {
173  fillHist1D(m_histAccept[i],(float)deltaEta);
174  } else if(fillReject) {
175  fillHist1D(m_histReject[i],(float)deltaEta);
176  }
177  TRG_MSG_DEBUG("DeltaEta = " << deltaEta << " -> accept bit " << i << " -> "
178  << (accept?"pass":"fail"));
179  }
180  }
181  }
182  } else {
183  TCS_EXCEPTION("DeltaEtaIncl2 alg must have 2 inputs, but got " << input.size());
184  }
186 }
187 
TCS::StatusCode::SUCCESS
@ SUCCESS
Definition: Trigger/TrigT1/L1Topo/L1TopoCommon/L1TopoCommon/StatusCode.h:17
TCS::DeltaEtaIncl2::DeltaEtaIncl2
DeltaEtaIncl2(const std::string &name)
Definition: DeltaEtaIncl2.cxx:33
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
TCS::DeltaEtaIncl2::initialize
virtual StatusCode initialize()
Definition: DeltaEtaIncl2.cxx:64
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:146
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_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:102
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
DeltaEtaIncl2.h
TCS::DeltaEtaIncl2::~DeltaEtaIncl2
virtual ~DeltaEtaIncl2()
Definition: DeltaEtaIncl2.cxx:60
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
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