ATLAS Offline Software
Loading...
Searching...
No Matches
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
20
21REGISTER_ALG_TCS(DeltaEtaPhiIncl1)
22
23
25{
26 defineParameter("InputWidth", 3);
27 defineParameter("MaxTob", 0);
28 defineParameter("NumResultBits", 3);
29 defineParameter("MinET1",1,0);
30 defineParameter("MinET2",1,0);
31 defineParameter("MinDeltaEta", 0, 0);
32 defineParameter("MaxDeltaEta", 49, 0);
33 defineParameter("MinDeltaPhi", 0, 0);
34 defineParameter("MaxDeltaPhi", 63, 0);
35 defineParameter("MinET1",1,1);
36 defineParameter("MinET2",1,1);
37 defineParameter("MinDeltaEta", 0, 1);
38 defineParameter("MaxDeltaEta", 49, 1);
39 defineParameter("MinDeltaPhi", 0, 1);
40 defineParameter("MaxDeltaPhi", 63, 1);
41 defineParameter("MinET1",1,2);
42 defineParameter("MinET2",1,2);
43 defineParameter("MinDeltaEta", 0, 2);
44 defineParameter("MaxDeltaEta", 49, 2);
45 defineParameter("MinDeltaPhi", 0, 2);
46 defineParameter("MaxDeltaPhi", 63, 2);
48}
49
51
52
55
56 if(parameter("MaxTob").value() > 0) {
57 p_NumberLeading1 = parameter("MaxTob").value();
58 p_NumberLeading2 = parameter("MaxTob").value();
59 } else {
60 p_NumberLeading1 = parameter("InputWidth").value();
61 p_NumberLeading2 = parameter("InputWidth").value();
62 }
63
64 for(unsigned int i=0; i<numberOutputBits(); ++i) {
65 p_DeltaPhiMin[i] = parameter("MinDeltaPhi", i).value();
66 p_DeltaPhiMax[i] = parameter("MaxDeltaPhi", i).value();
67 p_DeltaEtaMin[i] = parameter("MinDeltaEta", i).value();
68 p_DeltaEtaMax[i] = parameter("MaxDeltaEta", i).value();
69 p_MinET1[i] = parameter("MinET1",i).value();
70 p_MinET2[i] = parameter("MinET2",i).value();
71 TRG_MSG_INFO("MinET1 : " << p_MinET1[i]);
72 TRG_MSG_INFO("MinET2 : " << p_MinET2[i]);
73 TRG_MSG_INFO("DeltaEtaMin : " << p_DeltaEtaMin[i]);
74 TRG_MSG_INFO("DeltaEtaMax : " << p_DeltaEtaMax[i]);
75 TRG_MSG_INFO("DeltaPhiMin : " << p_DeltaPhiMin[i]);
76 TRG_MSG_INFO("DeltaPhiMax : " << p_DeltaPhiMax[i]);
77
78 }
79
80 TRG_MSG_INFO("NumberLeading1 : " << p_NumberLeading1); // note that the reading of generic parameters doesn't work yet
81 TRG_MSG_INFO("NumberLeading2 : " << p_NumberLeading2);
82 TRG_MSG_INFO("number output : " << numberOutputBits());
83
84 // book histograms
85 for(unsigned int i=0; i<numberOutputBits(); ++i) {
86 std::string hname_accept = "hDeltaEtaPhiIncl1_accept_bit"+std::to_string((int)i);
87 std::string hname_reject = "hDeltaEtaPhiIncl1_reject_bit"+std::to_string((int)i);
88 // deta vs dphi
89 bookHist(m_histAccept, hname_accept, "DETA vs DPHI", 100, p_DeltaEtaMin[i], p_DeltaEtaMax[i], 100, p_DeltaPhiMin[i], p_DeltaPhiMax[i]);
90 bookHist(m_histReject, hname_reject, "DETA vs DPHI", 100, p_DeltaEtaMin[i], p_DeltaEtaMax[i], 100, p_DeltaPhiMin[i], p_DeltaPhiMax[i]);
91 }
92
94}
95
96
97
99TCS::DeltaEtaPhiIncl1::processBitCorrect( const std::vector<TCS::TOBArray const *> & input,
100 const std::vector<TCS::TOBArray *> & output,
101 Decision & decision )
102{
103 if(input.size() == 1) {
104 TRG_MSG_DEBUG("input size : " << input[0]->size());
105 unsigned int nLeading = p_NumberLeading1;
106 for( TOBArray::const_iterator tob1 = input[0]->begin();
107 tob1 != input[0]->end() && distance( input[0]->begin(), tob1) < nLeading;
108 ++tob1)
109 {
110 TCS::TOBArray::const_iterator tob2 = tob1; ++tob2;
111 for( ;
112 tob2 != input[0]->end() && distance( input[0]->begin(), tob2) < p_NumberLeading2;
113 ++tob2) {
114 // DeltaPhi cuts
115 unsigned int deltaPhi = calcDeltaPhiBW( *tob1, *tob2 );
116 // DeltaEta cuts
117 unsigned int deltaEta = calcDeltaEtaBW( *tob1, *tob2 );
118 //
119 // to-do change message output
120 std::stringstream msgss;
121 msgss << " phi1=" << (*tob1)->phi() << " , phi2=" << (*tob2)->phi()
122 << ", DeltaPhi = " << deltaPhi << ", DeltaEta = " << deltaEta << " -> ";
123 for(unsigned int i=0; i<numberOutputBits(); ++i) {
124 bool accept = false;
125 if( parType_t((*tob1)->Et()) <= std::min(p_MinET1[i],p_MinET2[i])) continue; // ET cut
126 if( parType_t((*tob2)->Et()) <= std::min(p_MinET1[i],p_MinET2[i])) continue; // ET cut
127 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;
128 accept = ( deltaEta >= p_DeltaEtaMin[i] || deltaPhi >= p_DeltaPhiMin[i] ) && deltaPhi <= p_DeltaPhiMax[i] && deltaEta <= p_DeltaEtaMax[i];
129 const bool fillAccept = fillHistos() and (fillHistosBasedOnHardware() ? getDecisionHardwareBit(i) : accept);
130 const bool fillReject = fillHistos() and not fillAccept;
131 const bool alreadyFilled = decision.bit(i);
132 if( accept ) {
133 decision.setBit(i, true);
134 output[i]->push_back( TCS::CompositeTOB(*tob1, *tob2) );
135 }
136 if(fillAccept and not alreadyFilled) {
137 fillHist2D(m_histAccept[i],(float)deltaEta,(float)deltaPhi);
138 } else if(fillReject) {
139 fillHist2D(m_histReject[i],(float)deltaEta,(float)deltaPhi);
140 }
141 msgss << "DeltaEtaPhiIncl1 alg bit" << i << (accept?" pass":" fail") << "|";
142 }
143 TRG_MSG_DEBUG(msgss.str());
144 }
145 }
146 for (unsigned int i=0; i < numberOutputBits(); ++i) {
147 bool hasAmbiguousInputs = TSU::isAmbiguousTruncation(input[0], p_NumberLeading1, p_MinET1[i])
149 output[i]->setAmbiguityFlag(hasAmbiguousInputs);
150 }
151 } else {
152 TCS_EXCEPTION("DeltaEtaPhiIncl1 alg must have 1 input, but got " << input.size());
153 }
155}
156
158TCS::DeltaEtaPhiIncl1::process( const std::vector<TCS::TOBArray const *> & input,
159 const std::vector<TCS::TOBArray *> & output,
160 Decision & decision )
161{
162 if(input.size() == 1) {
163 TRG_MSG_DEBUG("input size : " << input[0]->size());
164 unsigned int nLeading = p_NumberLeading1;
165 for( TOBArray::const_iterator tob1 = input[0]->begin();
166 tob1 != input[0]->end() && distance( input[0]->begin(), tob1) < nLeading;
167 ++tob1)
168 {
169 TCS::TOBArray::const_iterator tob2 = tob1; ++tob2;
170 for( ;
171 tob2 != input[0]->end() && distance( input[0]->begin(), tob2) < p_NumberLeading2;
172 ++tob2) {
173 // DeltaPhi cuts
174 unsigned int deltaPhi = calcDeltaPhi( *tob1, *tob2 );
175 // DeltaEta cuts
176 unsigned int deltaEta = calcDeltaEta( *tob1, *tob2 );
177 //
178 // to-do change message output
179 std::stringstream msgss;
180 msgss << " Combination : " << distance( input[0]->begin(), tob1)
181 << " x " << distance( input[0]->begin(), tob2)
182 << " phi1=" << (*tob1)->phi()
183 << " , phi2=" << (*tob2)->phi()
184 << ", DeltaPhi = " << deltaPhi
185 << ", DeltaEta = " << deltaEta << " -> ";
186 for(unsigned int i=0; i<numberOutputBits(); ++i) {
187 bool accept = false;
188 if( parType_t((*tob1)->Et()) <= std::min(p_MinET1[i],p_MinET2[i])) continue; // ET cut
189 if( parType_t((*tob2)->Et()) <= std::min(p_MinET1[i],p_MinET2[i])) continue; // ET cut
190 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;
191 accept = ( deltaEta >= p_DeltaEtaMin[i] || deltaPhi >= p_DeltaPhiMin[i] ) && deltaPhi <= p_DeltaPhiMax[i] && deltaEta <= p_DeltaEtaMax[i];
192 const bool fillAccept = fillHistos() and (fillHistosBasedOnHardware() ? getDecisionHardwareBit(i) : accept);
193 const bool fillReject = fillHistos() and not fillAccept;
194 const bool alreadyFilled = decision.bit(i);
195 if( accept ) {
196 decision.setBit(i, true);
197 output[i]->push_back( TCS::CompositeTOB(*tob1, *tob2) );
198 }
199 if(fillAccept and not alreadyFilled) {
200 fillHist2D(m_histAccept[i],(float)deltaEta,(float)deltaPhi);
201 } else if(fillReject) {
202 fillHist2D(m_histReject[i],(float)deltaEta,(float)deltaPhi);
203 }
204 msgss << "DeltaEtaPhiIncl1 alg bit" << i << (accept?" pass":" fail") << "|";
205 }
206 TRG_MSG_DEBUG(msgss.str());
207 }
208 }
209 } else {
210 TCS_EXCEPTION("DeltaEtaPhiIncl1 alg must have 1 input, but got " << input.size());
211 }
213}
#define REGISTER_ALG_TCS(CLASS)
Definition AlgFactory.h:62
Scalar deltaPhi(const MatrixBase< Derived > &vec) const
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)
unsigned int calcDeltaPhiBW(const TCS::GenericTOB *tob1, const TCS::GenericTOB *tob2)
unsigned int calcDeltaEta(const TCS::GenericTOB *tob1, const TCS::GenericTOB *tob2)
unsigned int calcDeltaEtaBW(const TCS::GenericTOB *tob1, const TCS::GenericTOB *tob2)
void defineParameter(const std::string &name, TCS::parType_t value)
unsigned int calcDeltaPhi(const TCS::GenericTOB *tob1, const TCS::GenericTOB *tob2)
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 process(const std::vector< TCS::TOBArray const * > &input, const std::vector< TCS::TOBArray * > &output, Decision &decison)
DeltaEtaPhiIncl1(const std::string &name)
virtual StatusCode initialize()
virtual StatusCode processBitCorrect(const std::vector< TCS::TOBArray const * > &input, const std::vector< TCS::TOBArray * > &output, Decision &decison)
uint32_t parType_t
Definition Parameter.h:22
bool isAmbiguousTruncation(TCS::TOBArray const *tobs, size_t pos, unsigned minEt=0)
STL namespace.