ATLAS Offline Software
Loading...
Searching...
No Matches
DeltaEtaIncl2.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 * DeltaEtaIncl2.cpp
6 * Created by Joerg Stelzer on 11/16/12.
7 * Modified V Sorin 2014
8 *
9 * @brief algorithm calculates the eta-distance between two lists and applies delta-eta criteria
10 *
11 * @param NumberLeading
12**********************************/
13
14#include <cmath>
15#include <string>
16#include <iostream>
17#include <sstream>
18#include <vector>
19
24
25REGISTER_ALG_TCS(DeltaEtaIncl2)
26
27// not the best solution but we will move to athena where this comes for free
28#define LOG cout << fullname() << ": "
29
30
31
32
33
35{
36 defineParameter("InputWidth1", 0);
37 defineParameter("InputWidth2", 0);
38 defineParameter("MaxTob1", 0);
39 defineParameter("MaxTob2", 0);
40 defineParameter("NumResultBits", 4);
41 defineParameter("MinET1",0,0);
42 defineParameter("MinET2",0,0);
43 defineParameter("MinET1",0,1);
44 defineParameter("MinET2",0,1);
45 defineParameter("MinET1",0,2);
46 defineParameter("MinET2",0,2);
47 defineParameter("MinET1",0,3);
48 defineParameter("MinET2",0,3);
49 defineParameter("MinDeltaEta", 0, 0);
50 defineParameter("MaxDeltaEta", 127, 0);
51 defineParameter("MinDeltaEta", 0, 1);
52 defineParameter("MaxDeltaEta", 127, 1);
53 defineParameter("MinDeltaEta", 0, 2);
54 defineParameter("MaxDeltaEta", 127, 2);
55 defineParameter("MinDeltaEta", 0, 3);
56 defineParameter("MaxDeltaEta", 127, 3);
57
59}
60
62
63
66 p_NumberLeading1 = parameter("InputWidth1").value();
67 p_NumberLeading2 = parameter("InputWidth2").value();
68 if(parameter("MaxTob1").value() > 0) p_NumberLeading1 = parameter("MaxTob1").value();
69 if(parameter("MaxTob2").value() > 0) p_NumberLeading2 = parameter("MaxTob2").value();
70
71 for(unsigned int i=0; i<numberOutputBits(); ++i) {
72 p_DeltaEtaMin[i] = parameter("MinDeltaEta", i).value();
73 p_DeltaEtaMax[i] = parameter("MaxDeltaEta", i).value();
74
75 p_MinET1[i] = parameter("MinET1",i).value();
76 p_MinET2[i] = parameter("MinET2",i).value();
77 }
78
79 TRG_MSG_INFO("NumberLeading1 : " << p_NumberLeading1); // note that the reading of generic parameters doesn't work yet
80 TRG_MSG_INFO("NumberLeading2 : " << p_NumberLeading2);
81 for(unsigned int i=0; i<numberOutputBits(); ++i) {
82 TRG_MSG_INFO("DeltaEtaMin0 : " << p_DeltaEtaMin[i]);
83 TRG_MSG_INFO("DeltaEtaMax0 : " << p_DeltaEtaMax[i]);
84 TRG_MSG_INFO("MinET1 : " << p_MinET1[i]);
85 TRG_MSG_INFO("MinET2 : " << p_MinET2[i]);
86 }
87 TRG_MSG_INFO("number output : " << numberOutputBits());
88
89 // book histograms
90 for(unsigned int i=0; i<numberOutputBits(); ++i) {
91 std::string hname_accept = "hDeltaEtaIncl2_accept_bit"+std::to_string((int)i);
92 std::string hname_reject = "hDeltaEtaIncl2_reject_bit"+std::to_string((int)i);
93 // mass
94 bookHist(m_histAccept, hname_accept, "DETA", 100, p_DeltaEtaMin[i], p_DeltaEtaMax[i]);
95 bookHist(m_histReject, hname_reject, "DETA", 100, p_DeltaEtaMin[i], p_DeltaEtaMax[i]);
96 }
97
98
100}
101
103TCS::DeltaEtaIncl2::processBitCorrect( const std::vector<TCS::TOBArray const *> & input,
104 const std::vector<TCS::TOBArray *> & output,
105 Decision & decision )
106
107{
108 if( input.size() == 2) {
109 for( TOBArray::const_iterator tob1 = input[0]->begin();
110 tob1 != input[0]->end() && distance(input[0]->begin(), tob1) < p_NumberLeading1;
111 ++tob1)
112 {
113 for( TCS::TOBArray::const_iterator tob2 = input[1]->begin();
114 tob2 != input[1]->end() && distance(input[1]->begin(), tob2) < p_NumberLeading2;
115 ++tob2) {
116 // test DeltaEtaMin, DeltaEtaMax
117 unsigned int deltaEta = calcDeltaEtaBW( *tob1, *tob2 );
118 for(unsigned int i=0; i<numberOutputBits(); ++i) {
119 bool accept = false;
120 if( parType_t((*tob1)->Et()) <= p_MinET1[i]) continue; // ET cut
121 if( parType_t((*tob2)->Et()) <= p_MinET2[i]) continue; // ET cut
122 accept = deltaEta >= p_DeltaEtaMin[i] && deltaEta <= p_DeltaEtaMax[i];
123 const bool fillAccept = fillHistos() and (fillHistosBasedOnHardware() ? getDecisionHardwareBit(i) : accept);
124 const bool fillReject = fillHistos() and not fillAccept;
125 const bool alreadyFilled = decision.bit(i);
126 if( accept ) {
127 decision.setBit(i, true);
128 output[i]->push_back( TCS::CompositeTOB(*tob1, *tob2) );
129 }
130 if(fillAccept and not alreadyFilled) {
131 fillHist1D(m_histAccept[i],(float)deltaEta);
132 } else if(fillReject) {
133 fillHist1D(m_histReject[i],(float)deltaEta);
134 }
135 TRG_MSG_DEBUG("DeltaEta = " << deltaEta << " -> accept bit " << i << " -> "
136 << (accept?"pass":"fail"));
137 }
138 }
139 }
140 for (unsigned int i=0; i < numberOutputBits(); ++i) {
141 bool hasAmbiguousInputs = TSU::isAmbiguousTruncation(input[0], p_NumberLeading1, p_MinET1[i])
143 output[i]->setAmbiguityFlag(hasAmbiguousInputs);
144 }
145 } else {
146 TCS_EXCEPTION("DeltaEtaIncl2 alg must have 2 inputs, but got " << input.size());
147 }
149}
150
152TCS::DeltaEtaIncl2::process( const std::vector<TCS::TOBArray const *> & input,
153 const std::vector<TCS::TOBArray *> & output,
154 Decision & decision )
155{
156 if( input.size() == 2) {
157 for( TOBArray::const_iterator tob1 = input[0]->begin();
158 tob1 != input[0]->end() && distance(input[0]->begin(), tob1) < p_NumberLeading1;
159 ++tob1)
160 {
161 for( TCS::TOBArray::const_iterator tob2 = input[1]->begin();
162 tob2 != input[1]->end() && distance(input[1]->begin(), tob2) < p_NumberLeading2;
163 ++tob2) {
164 // test DeltaEtaMin, DeltaEtaMax
165 unsigned int deltaEta = calcDeltaEta( *tob1, *tob2 );
166 for(unsigned int i=0; i<numberOutputBits(); ++i) {
167 bool accept = false;
168 if( parType_t((*tob1)->Et()) <= p_MinET1[i]) continue; // ET cut
169 if( parType_t((*tob2)->Et()) <= p_MinET2[i]) continue; // ET cut
170 accept = deltaEta >= p_DeltaEtaMin[i] && deltaEta <= p_DeltaEtaMax[i];
171 const bool fillAccept = fillHistos() and (fillHistosBasedOnHardware() ? getDecisionHardwareBit(i) : accept);
172 const bool fillReject = fillHistos() and not fillAccept;
173 const bool alreadyFilled = decision.bit(i);
174 if( accept ) {
175 decision.setBit(i, true);
176 output[i]->push_back( TCS::CompositeTOB(*tob1, *tob2) );
177 }
178 if(fillAccept and not alreadyFilled) {
179 fillHist1D(m_histAccept[i],(float)deltaEta);
180 } else if(fillReject) {
181 fillHist1D(m_histReject[i],(float)deltaEta);
182 }
183 TRG_MSG_DEBUG("DeltaEta = " << deltaEta << " -> accept bit " << i << " -> "
184 << (accept?"pass":"fail"));
185 }
186 }
187 }
188 } else {
189 TCS_EXCEPTION("DeltaEtaIncl2 alg must have 2 inputs, but got " << input.size());
190 }
192}
193
#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 fillHist1D(const std::string &histName, double x)
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)
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
parType_t p_DeltaEtaMax[4]
virtual StatusCode processBitCorrect(const std::vector< TCS::TOBArray const * > &input, const std::vector< TCS::TOBArray * > &output, Decision &decison)
parType_t p_NumberLeading1
virtual StatusCode initialize()
parType_t p_MinET1[4]
virtual StatusCode process(const std::vector< TCS::TOBArray const * > &input, const std::vector< TCS::TOBArray * > &output, Decision &decison)
DeltaEtaIncl2(const std::string &name)
parType_t p_MinET2[4]
parType_t p_DeltaEtaMin[4]
uint32_t parType_t
Definition Parameter.h:22
bool isAmbiguousTruncation(TCS::TOBArray const *tobs, size_t pos, unsigned minEt=0)