ATLAS Offline Software
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 
19 #include "L1TopoCommon/Exception.h"
21 
22 //
23 REGISTER_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 
89  return StatusCode::SUCCESS;
90 }
91 
92 
93 
95 TCS::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 
150 TCS::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 }
TCS::StatusCode::SUCCESS
@ SUCCESS
Definition: Trigger/TrigT1/L1Topo/L1TopoCommon/L1TopoCommon/StatusCode.h:17
TCS::parType_t
uint32_t parType_t
Definition: Parameter.h:22
TCS::DataArrayImpl< GenericTOB >::const_iterator
data_t::const_iterator const_iterator
Definition: DataArrayImpl.h:18
TransverseMassInclusive1.h
CutsMETMaker::accept
StatusCode accept(const xAOD::Muon *mu)
Definition: CutsMETMaker.cxx:18
PlotCalibFromCool.begin
begin
Definition: PlotCalibFromCool.py:94
TCS::TransverseMassInclusive1::process
virtual StatusCode process(const std::vector< TCS::TOBArray const * > &input, const std::vector< TCS::TOBArray * > &output, Decision &decison)
Definition: TransverseMassInclusive1.cxx:150
athena.value
value
Definition: athena.py:124
Decision.h
TCS::DecisionAlg
Definition: Trigger/TrigT1/L1Topo/L1TopoInterfaces/L1TopoInterfaces/DecisionAlg.h:22
TCS::Decision::setBit
void setBit(unsigned int index, bool value)
Definition: L1Topo/L1TopoInterfaces/Root/Decision.cxx:12
TCS::TransverseMassInclusive1::TransverseMassInclusive1
TransverseMassInclusive1(const std::string &name)
Definition: TransverseMassInclusive1.cxx:29
lumiFormat.i
int i
Definition: lumiFormat.py:85
TCS::ConfigurableAlg::defineParameter
void defineParameter(const std::string &name, TCS::parType_t value)
Definition: ConfigurableAlg.cxx:201
TCS::CompositeTOB
Definition: CompositeTOB.h:16
PlotPulseshapeFromCool.input
input
Definition: PlotPulseshapeFromCool.py:106
TCS_EXCEPTION
#define TCS_EXCEPTION(MSG)
Definition: Trigger/TrigT1/L1Topo/L1TopoCommon/L1TopoCommon/Exception.h:14
TCS::Decision
Definition: L1Topo/L1TopoInterfaces/L1TopoInterfaces/Decision.h:19
TRG_MSG_INFO
#define TRG_MSG_INFO(x)
Definition: Trigger/TrigConfiguration/TrigConfBase/TrigConfBase/MsgStreamMacros.h:27
merge.output
output
Definition: merge.py:17
REGISTER_ALG_TCS
#define REGISTER_ALG_TCS(CLASS)
Definition: AlgFactory.h:62
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
ActsTrk::to_string
std::string to_string(const DetectorType &type)
Definition: GeometryDefs.h:34
TCS::TransverseMassInclusive1::processBitCorrect
virtual StatusCode processBitCorrect(const std::vector< TCS::TOBArray const * > &input, const std::vector< TCS::TOBArray * > &output, Decision &decison)
Definition: TransverseMassInclusive1.cxx:95
TCS::TransverseMassInclusive1::initialize
virtual StatusCode initialize()
Definition: TransverseMassInclusive1.cxx:60
TCS::Decision::bit
bool bit(unsigned int index) const
Definition: L1Topo/L1TopoInterfaces/L1TopoInterfaces/Decision.h:40
TCS::DecisionAlg::setNumberOutputBits
void setNumberOutputBits(unsigned int numberOutputBits)
Definition: Trigger/TrigT1/L1Topo/L1TopoInterfaces/L1TopoInterfaces/DecisionAlg.h:40
TCS::TransverseMassInclusive1::~TransverseMassInclusive1
virtual ~TransverseMassInclusive1()
Definition: TransverseMassInclusive1.cxx:56
Exception.h
Amg::distance
float distance(const Amg::Vector3D &p1, const Amg::Vector3D &p2)
calculates the distance between two point in 3D space
Definition: GeoPrimitivesHelpers.h:54
TRG_MSG_DEBUG
#define TRG_MSG_DEBUG(x)
Definition: Trigger/TrigConfiguration/TrigConfBase/TrigConfBase/MsgStreamMacros.h:25
TCS::StatusCode
Definition: Trigger/TrigT1/L1Topo/L1TopoCommon/L1TopoCommon/StatusCode.h:15