ATLAS Offline Software
Loading...
Searching...
No Matches
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
16REGISTER_ALG_TCS(EtaPhiWindow)
17
18using 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//----------------------------------------------------------
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
73}
74//----------------------------------------------------------
76TCS::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//----------------------------------------------------------
118TCS::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//----------------------------------------------------------
#define REGISTER_ALG_TCS(CLASS)
Definition AlgFactory.h:62
const Parameter & parameter(const std::string &parameterName) const
const std::string & name() const
void bookHist(std::vector< std::string > &regName, const std::string &name, const std::string &title, const int binx, const int xmin, const int xmax)
void defineParameter(const std::string &name, TCS::parType_t value)
void fillHist2D(const std::string &histName, double x, double y)
data_t::const_iterator const_iterator
void setNumberOutputBits(unsigned int numberOutputBits)
Definition DecisionAlg.h:40
DecisionAlg(const std::string &name)
Definition DecisionAlg.h:25
bool fillHistosBasedOnHardware() const
! getter
bool fillHistos() const
whether the monitoring histograms should be filled
std::vector< std::string > m_histAccept
Definition DecisionAlg.h:73
std::vector< std::string > m_histReject
Definition DecisionAlg.h:74
unsigned int numberOutputBits() const
Definition DecisionAlg.h:39
bool getDecisionHardwareBit(const unsigned int &bitNumber) const
! get one hardware decision bit from this algo
bool bit(unsigned int index) const
Definition Decision.h:40
void setBit(unsigned int index, bool value)
Definition Decision.cxx:12
virtual StatusCode processBitCorrect(const std::vector< TCS::TOBArray const * > &input, const std::vector< TCS::TOBArray * > &output, Decision &decison)
virtual ~EtaPhiWindow()
virtual StatusCode process(const std::vector< TCS::TOBArray const * > &input, const std::vector< TCS::TOBArray * > &output, Decision &decison)
EtaPhiWindow(const std::string &name)
virtual StatusCode initialize()
uint32_t parType_t
Definition Parameter.h:22