ATLAS Offline Software
Loading...
Searching...
No Matches
TransverseMassInclusive1.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 * TransverseMassInclusive1.cpp
6 * Created by V Sorin 2014.
7 *
8 * @brief algorithm calculates the sqr of the transverse MASS between one list and XE and applies mass criteria
9 *
10 * @param NumberLeading
11**********************************/
12
13#include <cmath>
14#include <string>
15#include <sstream>
16#include <vector>
17
21
22//
23REGISTER_ALG_TCS(TransverseMassInclusive1)
24
25// not the best solution but we will move to athena where this comes for free
26#define LOG std::cout << "TCS::TransverseMassInclusive1: "
27
28
30{
31 defineParameter("InputWidth", 3);
32 defineParameter("MaxTob", 0);
33 defineParameter("NumResultBits", 6);
34 defineParameter("MinET1",0,0);
35 defineParameter("MinET2",0,0);
36 defineParameter("MinMTSqr", 0, 0);
37 defineParameter("MinET1",0,1);
38 defineParameter("MinET2",0,1);
39 defineParameter("MinMTSqr", 0, 1);
40 defineParameter("MinET1",0,2);
41 defineParameter("MinET2",0,2);
42 defineParameter("MinMTSqr", 0, 2);
43 defineParameter("MinET1",0,3);
44 defineParameter("MinET2",0,3);
45 defineParameter("MinMTSqr", 0, 3);
46 defineParameter("MinET1",0,4);
47 defineParameter("MinET2",0,4);
48 defineParameter("MinMTSqr", 0, 4);
49 defineParameter("MinET1",0,5);
50 defineParameter("MinET2",0,5);
51 defineParameter("MinMTSqr", 0, 5);
52
54}
55
57
58
61 if(parameter("MaxTob").value() > 0) {
62 p_NumberLeading1 = parameter("MaxTob").value();
63 } else {
64 p_NumberLeading1 = parameter("InputWidth").value();
65 }
66
67 for(unsigned int i=0; i<numberOutputBits(); ++i) {
68 p_TMassMin[i] = parameter("MinMTSqr", i).value();
69
70 p_MinET1[i] = parameter("MinET1",i).value();
71 TRG_MSG_INFO("MinET1 : " << p_MinET1[i]);
72 p_MinET2[i] = parameter("MinET2",i).value();
73 TRG_MSG_INFO("MinET2 : " << p_MinET2[i]);
74
75 TRG_MSG_INFO("TMassMin : " << p_TMassMin[i]);
76 }
77 TRG_MSG_INFO("NumberLeading1 : " << p_NumberLeading1);
78 TRG_MSG_INFO("number output : " << numberOutputBits());
79
80 // book histograms
81 for(unsigned int i=0; i<numberOutputBits(); ++i) {
82 std::string hname_accept = "hTransverseMassInclusive1_accept_bit"+std::to_string((int)i);
83 std::string hname_reject = "hTransverseMassInclusive1_reject_bit"+std::to_string((int)i);
84 // mass
85 bookHist(m_histAccept, hname_accept, "MT", 100, p_TMassMin[i], 2000);
86 bookHist(m_histReject, hname_reject, "MT", 100, p_TMassMin[i], 2000);
87 }
88
90}
91
92
93
95TCS::TransverseMassInclusive1::processBitCorrect( const std::vector<TCS::TOBArray const *> & input,
96 const std::vector<TCS::TOBArray *> & output,
97 Decision & decision )
98{
99
100 if(input.size() == 2) { // 2 lists because one is always MET
101
102
103
104 for( TOBArray::const_iterator tob1 = input[0]->begin();
105 tob1 != input[0]->end() && distance( input[0]->begin(), tob1) < p_NumberLeading1;
106 ++tob1)
107 {
108
109
110 for( TOBArray::const_iterator tob2 = input[1]->begin();
111 tob2 != input[1]->end() ;
112 ++tob2) {
113
114 // T Mass calculation
115
116 unsigned int tmass2 = calcTMassBW( *tob1, *tob2 );
117
118
119 for(unsigned int i=0; i<numberOutputBits(); ++i) {
120 bool accept = false;
121 if( parType_t((*tob1)->Et()) <= p_MinET1[i]) continue; // ET cut
122 if( parType_t((*tob2)->Et()) <= p_MinET2[i]) continue; // ET cut
123 accept = tmass2 >= p_TMassMin[i] ; //
124 const bool fillAccept = fillHistos() and (fillHistosBasedOnHardware() ? getDecisionHardwareBit(i) : accept);
125 const bool fillReject = fillHistos() and not fillAccept;
126 const bool alreadyFilled = decision.bit(i);
127 if(accept) {
128 decision.setBit(i, true);
129 output[i]->push_back( TCS::CompositeTOB(*tob1, *tob2) );
130 }
131 if(fillAccept and not alreadyFilled) {
132 fillHist1D(m_histAccept[i],(float)tmass2);
133 } else if(fillReject) {
134 fillHist1D(m_histReject[i],(float)tmass2);
135 }
136 TRG_MSG_DEBUG("Decision " << i << ": " << (accept?"pass":"fail") << " tmass2 = " << tmass2);
137 }
138 }
139 }
140 } else {
141
142 TCS_EXCEPTION("TransverseMassInclusive1 alg must have either 1 inputs, but got " << input.size());
143
144 }
146
147}
148
150TCS::TransverseMassInclusive1::process( const std::vector<TCS::TOBArray const *> & input,
151 const std::vector<TCS::TOBArray *> & output,
152 Decision & decision )
153{
154
155 if(input.size() == 2) { // 2 lists because one is always MET
156
157
158
159 for( TOBArray::const_iterator tob1 = input[0]->begin();
160 tob1 != input[0]->end() && distance( input[0]->begin(), tob1) < p_NumberLeading1;
161 ++tob1)
162 {
163
164
165 for( TOBArray::const_iterator tob2 = input[1]->begin();
166 tob2 != input[1]->end() ;
167 ++tob2) {
168
169 // T Mass calculation
170
171 unsigned int tmass2 = calcTMass( *tob1, *tob2 );
172
173 for(unsigned int i=0; i<numberOutputBits(); ++i) {
174 bool accept = false;
175 if( parType_t((*tob1)->Et()) <= p_MinET1[i]) continue; // ET cut
176
177 if( parType_t((*tob2)->Et()) <= p_MinET2[i]) continue; // ET cut
178
179 accept = tmass2 >= p_TMassMin[i] ; //
180 const bool fillAccept = fillHistos() and (fillHistosBasedOnHardware() ? getDecisionHardwareBit(i) : accept);
181 const bool fillReject = fillHistos() and not fillAccept;
182 const bool alreadyFilled = decision.bit(i);
183 if( accept ) {
184 decision.setBit(i, true);
185 output[i]->push_back( TCS::CompositeTOB(*tob1, *tob2) );
186 }
187 if(fillAccept and not alreadyFilled) {
188 fillHist1D(m_histAccept[i],(float)tmass2);
189 } else if(fillReject) {
190 fillHist1D(m_histReject[i],(float)tmass2);
191 }
192 TRG_MSG_DEBUG("Decision " << i << ": " << (accept?"pass":"fail") << " tmass2 = " << tmass2);
193
194 }
195 }
196 }
197 } else {
198
199 TCS_EXCEPTION("TransverseMassInclusive1 alg must have either 1 inputs, but got " << input.size());
200
201 }
203}
#define REGISTER_ALG_TCS(CLASS)
Definition AlgFactory.h:62
const Parameter & parameter(const std::string &parameterName) const
unsigned int calcTMass(const TCS::GenericTOB *tob1, const TCS::GenericTOB *tob2)
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)
void defineParameter(const std::string &name, TCS::parType_t value)
unsigned int calcTMassBW(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
virtual StatusCode process(const std::vector< TCS::TOBArray const * > &input, const std::vector< TCS::TOBArray * > &output, Decision &decison)
TransverseMassInclusive1(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