ATLAS Offline Software
Loading...
Searching...
No Matches
DeltaRSqrIncl2Charge.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 * DeltaRSqrIncl2Charge.cxx
6 * Created by Paula Martinez based on Joerg Stelzer / V Sorin.
7 *
8 * @brief algorithm calculates the R2-distance between two lists and applies dR criteria
9 * Events containing a pair of TGC muons with same charge are rejected
10 *
11 * @param NumberLeading
12**********************************/
13
15
19
20#include <cmath>
21
22REGISTER_ALG_TCS(DeltaRSqrIncl2Charge)
23
24
26{
27 defineParameter("InputWidth1", 9);
28 defineParameter("InputWidth2", 9);
29 defineParameter("MaxTob1", 0);
30 defineParameter("MaxTob2", 0);
31 defineParameter("NumResultBits", 3);
32 defineParameter("MinET1",1,0);
33 defineParameter("MinET2",1,0);
34 defineParameter("DeltaRMin", 0, 0);
35 defineParameter("DeltaRMax", 0, 0);
36 defineParameter("MinET1",1,1);
37 defineParameter("MinET2",1,1);
38 defineParameter("DeltaRMin", 0, 1);
39 defineParameter("DeltaRMax", 0, 1);
40 defineParameter("MinET1",1,2);
41 defineParameter("MinET2",1,2);
42 defineParameter("DeltaRMin", 0, 2);
43 defineParameter("DeltaRMax", 0, 2);
45}
46
48
49
52
53 m_NumberLeading1 = parameter("InputWidth1").value();
54 m_NumberLeading2 = parameter("InputWidth2").value();
55 if(parameter("MaxTob1").value() > 0) m_NumberLeading1 = parameter("MaxTob1").value();
56 if(parameter("MaxTob2").value() > 0) m_NumberLeading2 = parameter("MaxTob2").value();
57
58 for(unsigned int i=0; i<numberOutputBits(); ++i) {
59 m_DeltaRMin[i] = parameter("DeltaRMin", i).value();
60 m_DeltaRMax[i] = parameter("DeltaRMax", i).value();
61 m_MinET1[i] = parameter("MinET1",i).value();
62 m_MinET2[i] = parameter("MinET2",i).value();
63 TRG_MSG_INFO("DeltaRMin" << i << " : " << m_DeltaRMin[i]);
64 TRG_MSG_INFO("DeltaRMax" << i << " : " << m_DeltaRMax[i]);
65
66 TRG_MSG_INFO("MinET1 : " << m_MinET1[i]);
67 TRG_MSG_INFO("MinET2 : " << m_MinET2[i]);
68
69 }
70
71 TRG_MSG_INFO("NumberLeading1 : " << m_NumberLeading1);
72 TRG_MSG_INFO("NumberLeading2 : " << m_NumberLeading2);
73
74 TRG_MSG_INFO("number output : " << numberOutputBits());
75
76 // book histograms
77 for(unsigned int i=0; i<numberOutputBits(); ++i) {
78 std::string hname_accept = "hDeltaRSqrIncl2Charge_accept_bit"+std::to_string(static_cast<int>(i));
79 std::string hname_reject = "hDeltaRSqrIncl2Charge_reject_bit"+std::to_string(static_cast<int>(i));
80 // dR
81 bookHist(m_histAccept, hname_accept, "DR", 100, std::sqrt(m_DeltaRMin[i]), std::sqrt(m_DeltaRMax[i]));
82 bookHist(m_histReject, hname_reject, "DR", 100, std::sqrt(m_DeltaRMin[i]), std::sqrt(m_DeltaRMax[i]));
83 // eta2 vs. eta1
84 bookHist(m_histAcceptEta1Eta2, hname_accept, "ETA vs ETA", 100, -70, 70, 100, -70, 70);
85 bookHist(m_histRejectEta1Eta2, hname_reject, "ETA vs ETA", 100, -70, 70, 100, -70, 70);
86 }
87
89}
90
91
93TCS::DeltaRSqrIncl2Charge::processBitCorrect( const std::vector<TCS::TOBArray const *> & input,
94 const std::vector<TCS::TOBArray *> & output,
95 Decision & decision )
96{
97
98 if( input.size() == 2) {
99
100 for( TOBArray::const_iterator tob1 = input[0]->begin();
101 tob1 != input[0]->end() && distance(input[0]->begin(), tob1) < m_NumberLeading1;
102 ++tob1)
103 {
104 for( TCS::TOBArray::const_iterator tob2 = input[1]->begin();
105 tob2 != input[1]->end() && distance(input[1]->begin(), tob2) < m_NumberLeading2;
106 ++tob2) {
107 // test DeltaR2Min, DeltaR2Max
108 unsigned int deltaR2 = calcDeltaR2BW( *tob1, *tob2 );
109 TRG_MSG_DEBUG("Jet1 = " << **tob1 << ", Jet2 = " << **tob2 << ", deltaR2 = " << deltaR2);
110 // Charge cut ( 1 = positive, -1 = negative, 0 = undefined (RPC) )
111 int charge1 = (*tob1)->charge();
112 int charge2 = (*tob2)->charge();
113 int totalCharge = charge1 + charge2;
114 bool acceptCharge = true;
115 if ( std::abs(totalCharge) == 2 ) { acceptCharge = false; }
116 for(unsigned int i=0; i<numberOutputBits(); ++i) {
117 bool accept = false;
118 if( parType_t((*tob1)->Et()) <= m_MinET1[i]) continue; // ET cut
119 if( parType_t((*tob2)->Et()) <= m_MinET2[i]) continue; // ET cut
120 accept = deltaR2 >= m_DeltaRMin[i] && deltaR2 <= m_DeltaRMax[i] && acceptCharge;
121 const bool fillAccept = fillHistos() and (fillHistosBasedOnHardware() ? getDecisionHardwareBit(i) : accept);
122 const bool fillReject = fillHistos() and not fillAccept;
123 const bool alreadyFilled = decision.bit(i);
124 if( accept ) {
125 decision.setBit(i, true);
126 output[i]->push_back(TCS::CompositeTOB(*tob1, *tob2));
127 }
128 if(fillAccept and not alreadyFilled) {
129 fillHist1D(m_histAccept[i],std::sqrt(static_cast<float>(deltaR2)));
130 fillHist2D(m_histAcceptEta1Eta2[i],(*tob1)->eta(),(*tob2)->eta());
131 } else if(fillReject) {
132 fillHist1D(m_histReject[i],std::sqrt(static_cast<float>(deltaR2)));
133 fillHist2D(m_histRejectEta1Eta2[i],(*tob1)->eta(),(*tob2)->eta());
134 }
135 TRG_MSG_DEBUG("Decision " << i << ": " << (accept?"pass":"fail") << " deltaR2 = " << deltaR2);
136 }
137 }
138 }
139 for (unsigned int i=0; i < numberOutputBits(); ++i) {
140 bool hasAmbiguousInputs = TSU::isAmbiguousTruncation(input[0], m_NumberLeading1, m_MinET1[i])
142 output[i]->setAmbiguityFlag(hasAmbiguousInputs);
143 }
144 } else {
145 TCS_EXCEPTION("DeltaRSqrIncl2Charge alg must have 2 inputs, but got " << input.size());
146 }
148}
149
151TCS::DeltaRSqrIncl2Charge::process( const std::vector<TCS::TOBArray const *> & input,
152 const std::vector<TCS::TOBArray *> & output,
153 Decision & decision )
154{
155
156 if( input.size() == 2) {
157
158 for( TOBArray::const_iterator tob1 = input[0]->begin();
159 tob1 != input[0]->end() && distance(input[0]->begin(), tob1) < m_NumberLeading1;
160 ++tob1)
161 {
162
163
164 for( TCS::TOBArray::const_iterator tob2 = input[1]->begin();
165 tob2 != input[1]->end() && distance(input[1]->begin(), tob2) < m_NumberLeading2;
166 ++tob2) {
167 // test DeltaR2Min, DeltaR2Max
168 unsigned int deltaR2 = calcDeltaR2( *tob1, *tob2 );
169 TRG_MSG_DEBUG("Jet1 = " << **tob1 << ", Jet2 = " << **tob2 << ", deltaR2 = " << deltaR2);
170 // Charge cut ( 1 = positive, -1 = negative, 0 = undefined (RPC) )
171 int charge1 = (*tob1)->charge();
172 int charge2 = (*tob2)->charge();
173 int totalCharge = charge1 + charge2;
174 bool acceptCharge = true;
175 if ( std::abs(totalCharge) == 2 ) { acceptCharge = false; }
176 for(unsigned int i=0; i<numberOutputBits(); ++i) {
177 bool accept = false;
178 if( parType_t((*tob1)->Et()) <= m_MinET1[i]) continue; // ET cut
179 if( parType_t((*tob2)->Et()) <= m_MinET2[i]) continue; // ET cut
180 accept = deltaR2 >= m_DeltaRMin[i] && deltaR2 <= m_DeltaRMax[i] && acceptCharge;
181 const bool fillAccept = fillHistos() and (fillHistosBasedOnHardware() ? getDecisionHardwareBit(i) : accept);
182 const bool fillReject = fillHistos() and not fillAccept;
183 const bool alreadyFilled = decision.bit(i);
184 if( accept ) {
185 decision.setBit(i, true);
186 output[i]->push_back(TCS::CompositeTOB(*tob1, *tob2));
187 }
188 if(fillAccept and not alreadyFilled) {
189 fillHist1D(m_histAccept[i],std::sqrt(static_cast<float>(deltaR2)));
190 fillHist2D(m_histAcceptEta1Eta2[i],(*tob1)->eta(),(*tob2)->eta());
191 } else if(fillReject) {
192 fillHist1D(m_histReject[i],std::sqrt(static_cast<float>(deltaR2)));
193 fillHist2D(m_histRejectEta1Eta2[i],(*tob1)->eta(),(*tob2)->eta());
194 }
195 TRG_MSG_DEBUG("Decision " << i << ": " << (accept?"pass":"fail") << " deltaR2 = " << deltaR2);
196 }
197 }
198 }
199 } else {
200 TCS_EXCEPTION("DeltaRSqrIncl2Charge alg must have 2 inputs, but got " << input.size());
201 }
203}
#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 calcDeltaR2BW(const TCS::GenericTOB *tob1, const TCS::GenericTOB *tob2)
void defineParameter(const std::string &name, TCS::parType_t value)
unsigned int calcDeltaR2(const TCS::GenericTOB *tob1, const TCS::GenericTOB *tob2)
void fillHist2D(const std::string &histName, double x, double y)
data_t::const_iterator const_iterator
std::vector< std::string > m_histAcceptEta1Eta2
Definition DecisionAlg.h:79
void setNumberOutputBits(unsigned int numberOutputBits)
Definition DecisionAlg.h:40
DecisionAlg(const std::string &name)
Definition DecisionAlg.h:25
std::vector< std::string > m_histRejectEta1Eta2
Definition DecisionAlg.h:80
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
DeltaRSqrIncl2Charge(const std::string &name)
virtual StatusCode process(const std::vector< TCS::TOBArray const * > &input, const std::vector< TCS::TOBArray * > &output, Decision &decison)
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.