ATLAS Offline Software
Loading...
Searching...
No Matches
DeltaEtaPhiIncl2.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 * DeltaEtaPhiIncl2.cpp
6 * Created by Joerg Stelzer on 11/16/12.
7 * Modified by V SOrin 2014
8 * @brief algorithm calculates the eta and phi-distance between two lists and applies box cut criteria
9 *
10 * @param NumberLeading
11**********************************/
12
13#include <cmath>
14
19
20
21REGISTER_ALG_TCS(DeltaEtaPhiIncl2)
22
23
25{
26 defineParameter("InputWidth1", 5);
27 defineParameter("InputWidth2", 3);
28 defineParameter("MaxTob1", 0);
29 defineParameter("MaxTob2", 0);
30 defineParameter("NumResultBits", 3);
31 defineParameter("MinET1",1,0);
32 defineParameter("MinET2",1,0);
33 defineParameter("DeltaEtaMin", 0, 0);
34 defineParameter("DeltaEtaMax", 63, 0);
35 defineParameter("DeltaPhiMin", 0, 0);
36 defineParameter("DeltaPhiMax", 63, 0);
37 defineParameter("MinET1",1,1);
38 defineParameter("MinET2",1,1);
39 defineParameter("DeltaEtaMin", 0, 1);
40 defineParameter("DeltaEtaMax", 5, 1);
41 defineParameter("DeltaPhiMin", 0, 1);
42 defineParameter("DeltaPhiMax", 5, 1);
43 defineParameter("MinET1",1,2);
44 defineParameter("MinET2",1,2);
45 defineParameter("DeltaEtaMin", 25, 2);
46 defineParameter("DeltaEtaMax", 32, 2);
47 defineParameter("DeltaPhiMin", 25, 2);
48 defineParameter("DeltaPhiMax", 32, 2);
50}
51
53
54
57 p_NumberLeading1 = parameter("InputWidth1").value();
58 p_NumberLeading2 = parameter("InputWidth2").value();
59 if(parameter("MaxTob1").value() > 0) p_NumberLeading1 = parameter("MaxTob1").value();
60 if(parameter("MaxTob2").value() > 0) p_NumberLeading2 = parameter("MaxTob2").value();
61
62 for(unsigned int i=0; i<numberOutputBits(); ++i) {
63 p_DeltaPhiMin[i] = parameter("DeltaPhiMin", i).value();
64 p_DeltaPhiMax[i] = parameter("DeltaPhiMax", i).value();
65 p_DeltaEtaMin[i] = parameter("DeltaEtaMin", i).value();
66 p_DeltaEtaMax[i] = parameter("DeltaEtaMax", i).value();
67 p_MinET1[i] = parameter("MinET1",i).value();
68 p_MinET2[i] = parameter("MinET2",i).value();
69
70 TRG_MSG_INFO("MinET1 : " << p_MinET1[i]);
71 TRG_MSG_INFO("MinET2 : " << p_MinET2[i]);
72 TRG_MSG_INFO("DeltaEtaMin : " << p_DeltaEtaMin[i]);
73 TRG_MSG_INFO("DeltaEtaMax : " << p_DeltaEtaMax[i]);
74 TRG_MSG_INFO("DeltaPhiMin : " << p_DeltaPhiMin[i]);
75 TRG_MSG_INFO("DeltaPhiMax : " << p_DeltaPhiMax[i]);
76
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
83 TRG_MSG_INFO("number output : " << numberOutputBits());
84
85 // book histograms
86 for(unsigned int i=0; i<numberOutputBits(); ++i) {
87 std::string hname_accept = "hDeltaEtaPhiIncl2_accept_bit"+std::to_string((int)i);
88 std::string hname_reject = "hDeltaEtaPhiIncl2_reject_bit"+std::to_string((int)i);
89 // deta vs dphi
90 bookHist(m_histAccept, hname_accept, "DETA vs DPHI", 100, p_DeltaEtaMin[i], p_DeltaEtaMax[i], 100, p_DeltaPhiMin[i], p_DeltaPhiMax[i]);
91 bookHist(m_histReject, hname_reject, "DETA vs DPHI", 100, p_DeltaEtaMin[i], p_DeltaEtaMax[i], 100, p_DeltaPhiMin[i], p_DeltaPhiMax[i]);
92 }
93
95}
96
97
98
100TCS::DeltaEtaPhiIncl2::processBitCorrect( const std::vector<TCS::TOBArray const *> & input,
101 const std::vector<TCS::TOBArray *> & output,
102 Decision & decision )
103{
104 if(input.size() == 2) {
105 TRG_MSG_DEBUG("input size : " << input[0]->size());
106 unsigned int nLeading = p_NumberLeading1;
107 for( TOBArray::const_iterator tob1 = input[0]->begin();
108 tob1 != input[0]->end() && distance( input[0]->begin(), tob1) < nLeading;
109 ++tob1)
110 {
111 for( TOBArray::const_iterator tob2 = input[1]->begin();
112 tob2 != input[1]->end() && distance( input[1]->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()) <= p_MinET1[i] ) continue; // ET cut
126 if( parType_t((*tob2)->Et()) <= p_MinET2[i]) continue; // ET cut
127 accept = ( deltaEta >= p_DeltaEtaMin[i] || deltaPhi >= p_DeltaPhiMin[i] ) && deltaPhi <= p_DeltaPhiMax[i] && deltaEta <= p_DeltaEtaMax[i];
128 const bool fillAccept = fillHistos() and (fillHistosBasedOnHardware() ? getDecisionHardwareBit(i) : accept);
129 const bool fillReject = fillHistos() and not fillAccept;
130 const bool alreadyFilled = decision.bit(i);
131 if( accept ) {
132 decision.setBit(i, true);
133 output[i]->push_back( TCS::CompositeTOB(*tob1, *tob2) );
134 }
135 if(fillAccept and not alreadyFilled) {
136 fillHist2D(m_histAccept[i],(float)deltaEta,(float)deltaPhi);
137 } else if(fillReject) {
138 fillHist2D(m_histReject[i],(float)deltaEta,(float)deltaPhi);
139 }
140 msgss << "DeltaRApproxBoxCutIncl2 alg bit" << i << (accept?" pass":" fail") << "|";
141 }
142 TRG_MSG_DEBUG(msgss.str());
143 }
144 }
145 for (unsigned int i=0; i < numberOutputBits(); ++i) {
146 bool hasAmbiguousInputs = TSU::isAmbiguousTruncation(input[0], p_NumberLeading1, p_MinET1[i])
148 output[i]->setAmbiguityFlag(hasAmbiguousInputs);
149 }
150 } else {
151 TCS_EXCEPTION("DeltaEtaPhiIncl2 alg must have 2 inputs, but got " << input.size());
152 }
154}
155
156
158TCS::DeltaEtaPhiIncl2::process( const std::vector<TCS::TOBArray const *> & input,
159 const std::vector<TCS::TOBArray *> & output,
160 Decision & decision )
161{
162 if(input.size() == 2) {
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 for( TOBArray::const_iterator tob2 = input[1]->begin();
170 tob2 != input[1]->end() && distance( input[1]->begin(), tob2) < p_NumberLeading2;
171 ++tob2) {
172 // DeltaPhi cuts
173 unsigned int deltaPhi = calcDeltaPhi( *tob1, *tob2 );
174 // DeltaEta cuts
175 unsigned int deltaEta = calcDeltaEta( *tob1, *tob2 );
176 //
177 // to-do change message output
178 std::stringstream msgss;
179 msgss << " Combination : " << distance( input[0]->begin(), tob1) << " x " << distance( input[1]->begin(), tob2) << " phi1=" << (*tob1)->phi() << " , phi2=" << (*tob2)->phi()
180 << ", DeltaPhi = " << deltaPhi << ", DeltaEta = " << deltaEta <<" -> ";
181 for(unsigned int i=0; i<numberOutputBits(); ++i) {
182 bool accept = false;
183 if( parType_t((*tob1)->Et()) <= p_MinET1[i] ) continue; // ET cut
184 if( parType_t((*tob2)->Et()) <= p_MinET2[i]) continue; // ET cut
185 accept = ( deltaEta >= p_DeltaEtaMin[i] || deltaPhi >= p_DeltaPhiMin[i] ) && deltaPhi <= p_DeltaPhiMax[i] && deltaEta <= p_DeltaEtaMax[i];
186 const bool fillAccept = fillHistos() and (fillHistosBasedOnHardware() ? getDecisionHardwareBit(i) : accept);
187 const bool fillReject = fillHistos() and not fillAccept;
188 const bool alreadyFilled = decision.bit(i);
189 if( accept ) {
190 decision.setBit(i, true);
191 output[i]->push_back( TCS::CompositeTOB(*tob1, *tob2) );
192 }
193 if(fillAccept and not alreadyFilled) {
194 fillHist2D(m_histAccept[i],(float)deltaEta,(float)deltaPhi);
195 } else if(fillReject) {
196 fillHist2D(m_histReject[i],(float)deltaEta,(float)deltaPhi);
197 }
198 msgss << "DeltaRApproxBoxCutIncl2 alg bit" << i << (accept?" pass":" fail") << "|";
199 }
200 TRG_MSG_DEBUG(msgss.str());
201 }
202 }
203 } else {
204 TCS_EXCEPTION("DeltaEtaPhiIncl2 alg must have 2 inputs, but got " << input.size());
205 }
207}
#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)
virtual StatusCode initialize()
DeltaEtaPhiIncl2(const std::string &name)
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.