ATLAS Offline Software
EtaPhiWindow.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 
6 
8 
11 
12 #include <cmath>
13 #include <iterator>
14 
15 
16 REGISTER_ALG_TCS(EtaPhiWindow)
17 
18 using std::distance;
19 
20 //----------------------------------------------------------
22 {
23  defineParameter("InputWidth", 3);
24  defineParameter("NumResultBits", 1);
25  defineParameter("MaxTob", 0);
26  defineParameter("MinET",1);
27  defineParameter("EtaMin", 0);
28  defineParameter("EtaMax", 5);
29  defineParameter("PhiMin", 0);
30  defineParameter("PhiMax", 63);
32 }
33 //----------------------------------------------------------
35 {
36 }
37 //----------------------------------------------------------
40 {
41  parType_t inputWidth = parameter("InputWidth").value();
42  p_MaxTob = parameter("MaxTob").value();
43  if(p_MaxTob>inputWidth) {
44  TRG_MSG_DEBUG("MaxTob ("<<p_MaxTob<<")"
45  <<" is larger than InputWidth ("<<inputWidth<<")"
46  <<" : restricting to InputWidth");
47  p_MaxTob = inputWidth;
48  }
49  p_MinET = parameter("MinET").value();
50  p_EtaMin = parameter("EtaMin").value();
51  p_EtaMax = parameter("EtaMax").value();
52  p_PhiMin = parameter("PhiMin").value();
53  p_PhiMax = parameter("PhiMax").value();
54 
55  TRG_MSG_INFO("MaxTob : "<<p_MaxTob);
56  TRG_MSG_INFO("MinET : "<<p_MinET);
57  TRG_MSG_INFO("EtaMin : "<<(int)p_EtaMin);
58  TRG_MSG_INFO("EtaMax : "<<(int)p_EtaMax);
59  TRG_MSG_INFO("PhiMin : "<<p_PhiMin);
60  TRG_MSG_INFO("PhiMax : "<<p_PhiMax);
61  TRG_MSG_INFO("number of output bits : "<<numberOutputBits());
62 
63  // book histograms
64  for(unsigned int i=0; i<numberOutputBits(); ++i) {
65  std::string hname_accept = "hEtaPhiWindow_accept_bit"+std::to_string((int)i);
66  std::string hname_reject = "hEtaPhiWindow_reject_bit"+std::to_string((int)i);
67  // deta vs dphi
68  bookHist(m_histAccept, hname_accept, "ETA vs PHI", 100, p_EtaMin, p_EtaMax, 100, p_PhiMin, p_PhiMax);
69  bookHist(m_histReject, hname_reject, "ETA vs PHI", 100, p_EtaMin, p_EtaMax, 100, p_PhiMin, p_PhiMax);
70  }
71 
72  return StatusCode::SUCCESS;
73 }
74 //----------------------------------------------------------
76 TCS::EtaPhiWindow::processBitCorrect(const std::vector<TCS::TOBArray const *> &input,
77  const std::vector<TCS::TOBArray *> &output,
78  Decision &decision)
79 
80 {
81  if(input.size() == 1) {
82  TRG_MSG_DEBUG("input size : "<<input[0]->size());
83  const unsigned int nLeading = p_MaxTob;
84  bool accept{false};
85  for(TOBArray::const_iterator tob1 = input[0]->begin();
86  tob1 != input[0]->end();
87  ++tob1) {
88  const std::ptrdiff_t iTob = distance( input[0]->begin(), tob1);
89  if(nLeading!=0 and iTob>=nLeading) continue;
90  if( parType_t((*tob1)->Et()) <= p_MinET ) continue;
91  if( (int)parType_t((*tob1)->eta()) < (int)p_EtaMin ) continue;
92  if( (int)parType_t((*tob1)->eta()) >= (int)p_EtaMax ) continue;
93  if( (int)parType_t((*tob1)->phi()) < (int)p_PhiMin ) continue;
94  if( (int)parType_t((*tob1)->phi()) >= (int)p_PhiMax ) continue;
95  accept = true;
96  const bool fillAccept = fillHistos() and (fillHistosBasedOnHardware() ? getDecisionHardwareBit(0) : accept);
97  const bool fillReject = fillHistos() and not fillAccept;
98  const bool alreadyFilled = decision.bit(0);
99  output[0]->push_back(TCS::CompositeTOB(*tob1));
100  if(fillAccept and not alreadyFilled) {
101  fillHist2D(m_histAccept[0],(float)(*tob1)->eta(),(float)(*tob1)->phi());
102  } else if(fillReject) {
103  fillHist2D(m_histReject[0],(float)(*tob1)->eta(),(float)(*tob1)->phi());
104  }
105  TRG_MSG_DEBUG("TOB "<<iTob
106  <<" ET = "<<(*tob1)->Et()
107  <<" Eta = "<<(*tob1)->eta()
108  <<" phi = "<<(*tob1)->phi());
109  }
110  decision.setBit( 0, accept );
111  } else {
112  TCS_EXCEPTION("EtaPhiWindow alg must have 1 input, but got "<<input.size());
113  }
115 }
116 //----------------------------------------------------------
118 TCS::EtaPhiWindow::process(const std::vector<TCS::TOBArray const *> &input,
119  const std::vector<TCS::TOBArray *> &output,
120  Decision &decision)
121 {
122  if(input.size() == 1) {
123  TRG_MSG_DEBUG("input size : "<<input[0]->size());
124  const unsigned int nLeading = p_MaxTob;
125  bool accept{false};
126  for(TOBArray::const_iterator tob1 = input[0]->begin();
127  tob1 != input[0]->end();
128  ++tob1) {
129  const std::ptrdiff_t iTob = distance( input[0]->begin(), tob1);
130  if(nLeading!=0 and iTob>=nLeading) continue;
131  if( parType_t((*tob1)->Et()) <= p_MinET ) continue;
132  if( (int)parType_t((*tob1)->eta()) < (int)p_EtaMin ) continue;
133  if( (int)parType_t((*tob1)->eta()) >= (int)p_EtaMax ) continue;
134  if( (int)parType_t((*tob1)->phi()) < (int)p_PhiMin ) continue;
135  if( (int)parType_t((*tob1)->phi()) >= (int)p_PhiMax ) continue;
136  accept = true;
137  const bool fillAccept = fillHistos() and (fillHistosBasedOnHardware() ? getDecisionHardwareBit(0) : accept);
138  const bool fillReject = fillHistos() and not fillAccept;
139  const bool alreadyFilled = decision.bit(0);
140  output[0]->push_back(TCS::CompositeTOB(*tob1));
141  if(fillAccept and not alreadyFilled) {
142  fillHist2D(m_histAccept[0],(float)(*tob1)->eta(),(float)(*tob1)->phi());
143  } else if(fillReject) {
144  fillHist2D(m_histReject[0],(float)(*tob1)->eta(),(float)(*tob1)->phi());
145  }
146  TRG_MSG_DEBUG("TOB "<<iTob
147  <<" ET = "<<(*tob1)->Et()
148  <<" Eta = "<<(*tob1)->eta()
149  <<" phi = "<<(*tob1)->phi());
150  }
151  decision.setBit( 0, accept );
152  } else {
153  TCS_EXCEPTION("EtaPhiWindow alg must have 1 input, but got "<<input.size());
154  }
156 }
157 //----------------------------------------------------------
TCS::EtaPhiWindow::~EtaPhiWindow
virtual ~EtaPhiWindow()
Definition: EtaPhiWindow.cxx:34
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
CutsMETMaker::accept
StatusCode accept(const xAOD::Muon *mu)
Definition: CutsMETMaker.cxx:18
PlotCalibFromCool.begin
begin
Definition: PlotCalibFromCool.py:94
TCS::EtaPhiWindow::EtaPhiWindow
EtaPhiWindow(const std::string &name)
Definition: EtaPhiWindow.cxx:21
Decision.h
TCS::EtaPhiWindow::processBitCorrect
virtual StatusCode processBitCorrect(const std::vector< TCS::TOBArray const * > &input, const std::vector< TCS::TOBArray * > &output, Decision &decison)
Definition: EtaPhiWindow.cxx:76
TCS::EtaPhiWindow::initialize
virtual StatusCode initialize()
Definition: EtaPhiWindow.cxx:39
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
TCS::EtaPhiWindow::process
virtual StatusCode process(const std::vector< TCS::TOBArray const * > &input, const std::vector< TCS::TOBArray * > &output, Decision &decison)
Definition: EtaPhiWindow.cxx:118
lumiFormat.i
int i
Definition: lumiFormat.py:92
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::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:195
ActsTrk::to_string
std::string to_string(const DetectorType &type)
Definition: GeometryDefs.h:34
EtaPhiWindow.h
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