ATLAS Offline Software
Loading...
Searching...
No Matches
DeltaPhiIncl1.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 * DeltaPhiIncl1.cpp
6 * Created by Joerg Stelzer on 11/16/12.
7 * Modified by V SOrin 2014
8 *
9 * @brief algorithm calculates the phi-distance between one lists and applies delta-phi criteria
10 *
11 * @param NumberLeading
12**********************************/
13
14#include <cmath>
15
20
21REGISTER_ALG_TCS(DeltaPhiIncl1)
22
23
25{
26 defineParameter("InputWidth", 0);
27 defineParameter("MaxTob", 0);
28 defineParameter("NumResultBits", 2);
29 defineParameter("MinET1",0,0);
30 defineParameter("MinET2",0,0);
31 defineParameter("MinDeltaPhi", 0, 0);
32 defineParameter("MaxDeltaPhi", 31, 0);
33 defineParameter("MinET1",0,1);
34 defineParameter("MinET2",0,1);
35 defineParameter("MinDeltaPhi", 0, 1);
36 defineParameter("MaxDeltaPhi", 31, 1);
37
39}
40
42
43
46
47 if(parameter("MaxTob").value() > 0) {
48 p_NumberLeading1 = parameter("MaxTob").value();
49 p_NumberLeading2 = parameter("MaxTob").value();
50 } else {
51 p_NumberLeading1 = parameter("InputWidth").value();
52 p_NumberLeading2 = parameter("InputWidth").value();
53 }
54
55 for(unsigned int i=0; i<numberOutputBits(); ++i) {
56 p_DeltaPhiMin[i] = parameter("MinDeltaPhi", i).value();
57 p_DeltaPhiMax[i] = parameter("MaxDeltaPhi", i).value();
58 p_MinET1[i] = parameter("MinET1",i).value();
59 p_MinET2[i] = parameter("MinET2",i).value();
60
61 TRG_MSG_INFO("DeltaPhiMin : " << p_DeltaPhiMin[i]);
62 TRG_MSG_INFO("DeltaPhiMax : " << p_DeltaPhiMax[i]);
63 TRG_MSG_INFO("MinET1 : " << p_MinET1[i]);
64 TRG_MSG_INFO("MinET2 : " << p_MinET2[i]);
65
66 }
67
68 TRG_MSG_INFO("NumberLeading1 : " << p_NumberLeading1); // note that the reading of generic parameters doesn't work yet
69 TRG_MSG_INFO("NumberLeading2 : " << p_NumberLeading2);
70 TRG_MSG_INFO("number output : " << numberOutputBits());
71
72 // book histograms
73 for(unsigned int i=0; i<numberOutputBits(); ++i) {
74 std::string hname_accept = "hDeltaPhiIncl1_accept_bit"+std::to_string((int)i);
75 std::string hname_reject = "hDeltaPhiIncl1_reject_bit"+std::to_string((int)i);
76 // mass
77 bookHist(m_histAccept, hname_accept, "DPHI", 100, p_DeltaPhiMin[i], p_DeltaPhiMax[i]);
78 bookHist(m_histReject, hname_reject, "DPHI", 100, p_DeltaPhiMin[i], p_DeltaPhiMax[i]);
79 }
80
81
83}
84
85
86
88TCS::DeltaPhiIncl1::processBitCorrect( const std::vector<TCS::TOBArray const *> & input,
89 const std::vector<TCS::TOBArray *> & output,
90 Decision & decision )
91{
92 if(input.size() == 1) {
93 TRG_MSG_DEBUG("input size : " << input[0]->size());
94 unsigned int nLeading = p_NumberLeading1;
95 unsigned int nLeading2 = p_NumberLeading2;
96 for( TOBArray::const_iterator tob1 = input[0]->begin();
97 tob1 != input[0]->end() && distance( input[0]->begin(), tob1) < nLeading;
98 ++tob1)
99 {
100 TCS::TOBArray::const_iterator tob2 = tob1; ++tob2;
101 for( ;
102 tob2 != input[0]->end() && distance( input[0]->begin(), tob2) < nLeading2;
103 ++tob2) {
104 // DeltaPhi cuts
105 unsigned int deltaPhi = calcDeltaPhiBW( *tob1, *tob2 );
106 std::stringstream msgss;
107 msgss << " phi1=" << (*tob1)->phi() << " , phi2=" << (*tob2)->phi()
108 << ", DeltaPhi = " << deltaPhi << " -> ";
109 for(unsigned int i=0; i<numberOutputBits(); ++i) {
110 bool accept = false;
111 if( parType_t((*tob1)->Et()) <= std::min(p_MinET1[i],p_MinET2[i])) continue; // ET cut
112 if( parType_t((*tob2)->Et()) <= std::min(p_MinET1[i],p_MinET2[i])) continue; // ET cut
113 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;
114 accept = deltaPhi >= p_DeltaPhiMin[i] && deltaPhi <= p_DeltaPhiMax[i];
115 const bool fillAccept = fillHistos() and (fillHistosBasedOnHardware() ? getDecisionHardwareBit(i) : accept);
116 const bool fillReject = fillHistos() and not fillAccept;
117 const bool alreadyFilled = decision.bit(i);
118 if( accept ) {
119 decision.setBit(i, true);
120 output[i]->push_back( TCS::CompositeTOB(*tob1, *tob2) );
121 }
122 if(fillAccept and not alreadyFilled) {
124 } else if(fillReject) {
126 }
127 TRG_MSG_DEBUG("DeltaPhiIncl1 = " << deltaPhi << " -> "
128 << (accept?"pass":"fail"));
129 }
130 }
131 }
132 for (unsigned int i=0; i < numberOutputBits(); ++i) {
133 bool hasAmbiguousInputs = TSU::isAmbiguousTruncation(input[0], p_NumberLeading1, p_MinET1[i])
135 output[i]->setAmbiguityFlag(hasAmbiguousInputs);
136 }
137 } else {
138 TCS_EXCEPTION("DeltaPhiIncl1 alg must have 1 input, but got " << input.size());
139 }
141}
142
144TCS::DeltaPhiIncl1::process( const std::vector<TCS::TOBArray const *> & input,
145 const std::vector<TCS::TOBArray *> & output,
146 Decision & decision )
147{
148 if(input.size() == 1) {
149 TRG_MSG_DEBUG("input size : " << input[0]->size());
150 unsigned int nLeading = p_NumberLeading1;
151 unsigned int nLeading2 = p_NumberLeading2;
152 for( TOBArray::const_iterator tob1 = input[0]->begin();
153 tob1 != input[0]->end() && distance( input[0]->begin(), tob1) < nLeading;
154 ++tob1)
155 {
156 if (nLeading < input[0]->size()) {
157 TCS::TOBArray::const_iterator tob1_plus1 = tob1; ++tob1_plus1;
158 if ((*tob1)->Et() == (*tob1_plus1)->Et() && distance(input[0]->begin(), tob1) == nLeading - 1) {
159 for(unsigned int i=0; i<numberOutputBits(); ++i) {
160 output[i]->setAmbiguityFlag(true);
161 }
162 }
163 }
164 TCS::TOBArray::const_iterator tob2 = tob1; ++tob2;
165 for( ;
166 tob2 != input[0]->end() && distance( input[0]->begin(), tob2) < nLeading2;
167 ++tob2) {
168 // DeltaPhi cuts
169 unsigned int deltaPhi = calcDeltaPhi( *tob1, *tob2 );
170 std::stringstream msgss;
171 msgss << " Combination : " << distance( input[0]->begin(), tob1)
172 << " x " << distance( input[0]->begin(), tob2)
173 << " phi1=" << (*tob1)->phi()
174 << " , phi2=" << (*tob2)->phi()
175 << ", DeltaPhi = " << deltaPhi << " -> ";
176 for(unsigned int i=0; i<numberOutputBits(); ++i) {
177 bool accept = false;
178 if( parType_t((*tob1)->Et()) <= std::min(p_MinET1[i],p_MinET2[i])) continue; // ET cut
179 if( parType_t((*tob2)->Et()) <= std::min(p_MinET1[i],p_MinET2[i])) continue; // ET cut
180 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;
181 accept = deltaPhi >= p_DeltaPhiMin[i] && deltaPhi <= p_DeltaPhiMax[i];
182 const bool fillAccept = fillHistos() and (fillHistosBasedOnHardware() ? getDecisionHardwareBit(i) : accept);
183 const bool fillReject = fillHistos() and not fillAccept;
184 const bool alreadyFilled = decision.bit(i);
185 if( accept ) {
186 decision.setBit(i, true);
187 output[i]->push_back( TCS::CompositeTOB(*tob1, *tob2) );
188 }
189 if(fillAccept and not alreadyFilled) {
191 } else if(fillReject) {
193 }
194 TRG_MSG_DEBUG("DeltaPhiIncl1 = " << deltaPhi << " -> "
195 << (accept?"pass":"fail"));
196 }
197 }
198 }
199 } else {
200 TCS_EXCEPTION("DeltaPhiIncl1 alg must have 1 input, but got " << input.size());
201 }
203}
#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)
void fillHist1D(const std::string &histName, double x)
unsigned int calcDeltaPhiBW(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)
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
parType_t p_NumberLeading2
virtual StatusCode process(const std::vector< TCS::TOBArray const * > &input, const std::vector< TCS::TOBArray * > &output, Decision &decison)
parType_t p_MinET1[2]
DeltaPhiIncl1(const std::string &name)
parType_t p_DeltaPhiMin[2]
parType_t p_NumberLeading1
virtual StatusCode processBitCorrect(const std::vector< TCS::TOBArray const * > &input, const std::vector< TCS::TOBArray * > &output, Decision &decison)
virtual StatusCode initialize()
parType_t p_DeltaPhiMax[2]
parType_t p_MinET2[2]
uint32_t parType_t
Definition Parameter.h:22
bool isAmbiguousTruncation(TCS::TOBArray const *tobs, size_t pos, unsigned minEt=0)
STL namespace.