ATLAS Offline Software
InvariantMassInclusiveDeltaRSqrIncl2.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  * Based on InvariantMassInclusive2 and DeltaRSqrIncl2. 01/03/2019.
6  * Created by V Sorin and Joerg Stelzer 2014.
7  *
8  * @brief algorithm calculates the sqr of the INVMASS and DeltaR between two lists and applies invmass and deltaR criteria
9  *
10  * @param NumberLeading
11  *
12  * For questions contact atlas-trig-l1topo-algcom@cern.ch.
13 **********************************/
14 
15 
17 #include "L1TopoCommon/Exception.h"
19 
20 #include <cmath>
21 
22 REGISTER_ALG_TCS(InvariantMassInclusiveDeltaRSqrIncl2)
23 
24 
25 
27 {
28  defineParameter("InputWidth1", 9);
29  defineParameter("InputWidth2", 9);
30  defineParameter("MaxTob1", 0);
31  defineParameter("MaxTob2", 0);
32  defineParameter("NumResultBits", 6);
33  defineParameter("MinMSqr", 0, 0);
34  defineParameter("MaxMSqr", 999, 0);
35  defineParameter("MinMSqr", 0, 1);
36  defineParameter("MaxMSqr", 999, 1);
37  defineParameter("MinMSqr", 0, 2);
38  defineParameter("MaxMSqr", 999, 2);
39  defineParameter("MinMSqr", 0, 3);
40  defineParameter("MaxMSqr", 999, 3);
41  defineParameter("MinMSqr", 0, 4);
42  defineParameter("MaxMSqr", 999, 4);
43  defineParameter("MinMSqr", 0, 5);
44  defineParameter("MaxMSqr", 999, 5);
45  defineParameter("MinET1",0,0);
46  defineParameter("MinET2",0,0);
47  defineParameter("MinET1",0,1);
48  defineParameter("MinET2",0,1);
49  defineParameter("MinET1",0,2);
50  defineParameter("MinET2",0,2);
51  defineParameter("MinET1",0,3);
52  defineParameter("MinET2",0,3);
53  defineParameter("MinET1",0,4);
54  defineParameter("MinET2",0,4);
55  defineParameter("MinET1",0,5);
56  defineParameter("MinET2",0,5);
57  defineParameter("ApplyEtaCut", 0);
58  defineParameter("MinEta1", 0);
59  defineParameter("MaxEta1", 31);
60  defineParameter("MinEta2", 0);
61  defineParameter("MaxEta2", 31);
62  defineParameter("DeltaRMin", 0, 0);
63  defineParameter("DeltaRMax", 0, 0);
64  defineParameter("DeltaRMin", 0, 1);
65  defineParameter("DeltaRMax", 0, 1);
66  defineParameter("DeltaRMin", 0, 2);
67  defineParameter("DeltaRMax", 0, 2);
68  defineParameter("DeltaRMin", 0, 3);
69  defineParameter("DeltaRMax", 0, 3);
70  defineParameter("DeltaRMin", 0, 4);
71  defineParameter("DeltaRMax", 0, 4);
72  defineParameter("DeltaRMin", 0, 5);
73  defineParameter("DeltaRMax", 0, 5);
74 
75  setNumberOutputBits(6);
76 }
77 
79 
80 
83 
84  p_NumberLeading1 = parameter("InputWidth1").value();
85  p_NumberLeading2 = parameter("InputWidth2").value();
86  if(parameter("MaxTob1").value() > 0) p_NumberLeading1 = parameter("MaxTob1").value();
87  if(parameter("MaxTob2").value() > 0) p_NumberLeading2 = parameter("MaxTob2").value();
88  TRG_MSG_INFO("NumberLeading1 : " << p_NumberLeading1);
89  TRG_MSG_INFO("NumberLeading2 : " << p_NumberLeading2);
90 
91  for(unsigned int i=0; i<numberOutputBits(); ++i) {
92 
93  p_InvMassMin[i] = parameter("MinMSqr", i).value();
94  p_InvMassMax[i] = parameter("MaxMSqr", i).value();
95  p_MinET1[i] = parameter("MinET1",i).value();
96  p_MinET2[i] = parameter("MinET2",i).value();
97  p_DeltaRMin[i] = parameter("DeltaRMin", i).value();
98  p_DeltaRMax[i] = parameter("DeltaRMax", i).value();
99 
100  TRG_MSG_INFO("InvMassMin "<< i << " : " << p_InvMassMin[i]);
101  TRG_MSG_INFO("InvMassMax "<< i << " : " << p_InvMassMax[i]);
102  TRG_MSG_INFO("MinET1 "<< i << " : " << p_MinET1[i]);
103  TRG_MSG_INFO("MinET2 "<< i << " : " << p_MinET2[i]);
104  TRG_MSG_INFO("DeltaRMin "<< i << " : " << p_DeltaRMin[i]);
105  TRG_MSG_INFO("DeltaRMax "<< i << " : " << p_DeltaRMax[i]);
106 
107  }
108 
109  p_ApplyEtaCut = parameter("ApplyEtaCut").value();
110  p_MinEta1 = parameter("MinEta1" ).value();
111  p_MaxEta1 = parameter("MaxEta1" ).value();
112  p_MinEta2 = parameter("MinEta2" ).value();
113  p_MaxEta2 = parameter("MaxEta2" ).value();
114  TRG_MSG_INFO("ApplyEtaCut : "<<p_ApplyEtaCut );
115  TRG_MSG_INFO("MinEta1 : "<<p_MinEta1 );
116  TRG_MSG_INFO("MaxEta1 : "<<p_MaxEta1 );
117  TRG_MSG_INFO("MinEta2 : "<<p_MinEta2 );
118  TRG_MSG_INFO("MaxEta2 : "<<p_MaxEta2 );
119 
120  TRG_MSG_INFO("number output : " << numberOutputBits());
121 
122  // book histograms
123  for(unsigned int i=0; i<numberOutputBits(); ++i) {
124  std::string hname_accept = "hInvariantMassInclusiveDeltaRSqrIncl2_accept_bit"+std::to_string((int)i);
125  std::string hname_reject = "hInvariantMassInclusiveDeltaRSqrIncl2_reject_bit"+std::to_string((int)i);
126  // mass
127  bookHist(m_histAcceptM, hname_accept, "INVM vs DR", 100, sqrt(p_InvMassMin[i]), sqrt(p_InvMassMax[i]), 100, sqrt(p_DeltaRMin[i]), sqrt(p_DeltaRMax[i]));
128  bookHist(m_histRejectM, hname_reject, "INVM vs DR", 100, sqrt(p_InvMassMin[i]), sqrt(p_InvMassMax[i]), 100, sqrt(p_DeltaRMin[i]), sqrt(p_DeltaRMax[i]));
129 
130  }
131 
132  return StatusCode::SUCCESS;
133 }
134 
135 
136 
138 TCS::InvariantMassInclusiveDeltaRSqrIncl2::processBitCorrect( const std::vector<TCS::TOBArray const *> & input,
139  const std::vector<TCS::TOBArray *> & output,
140  Decision & decision )
141 {
142 
143  if( input.size() == 2) {
144  for( TOBArray::const_iterator tob1 = input[0]->begin();
145  tob1 != input[0]->end() && distance(input[0]->begin(), tob1) < p_NumberLeading1;
146  ++tob1)
147  {
148 
149 
150  for( TCS::TOBArray::const_iterator tob2 = input[1]->begin();
151  tob2 != input[1]->end() && distance(input[1]->begin(), tob2) < p_NumberLeading2;
152  ++tob2) {
153  // Inv Mass calculation
154  unsigned int invmass2 = calcInvMassBW( *tob1, *tob2 );
155  // test DeltaR2Min, DeltaR2Max
156  unsigned int deltaR2 = calcDeltaR2BW( *tob1, *tob2 );
157  TRG_MSG_DEBUG("Jet1 = " << **tob1 << ", Jet2 = " << **tob2 << ", invmass2 = " << invmass2 << ", deltaR2 = " << deltaR2);
158  const int eta1 = (*tob1)->eta();
159  const int eta2 = (*tob2)->eta();
160  const unsigned int aeta1 = std::abs(eta1);
161  const unsigned int aeta2 = std::abs(eta2);
162  for(unsigned int i=0; i<numberOutputBits(); ++i) {
163  bool accept = false;
164  if( parType_t((*tob1)->Et()) <= p_MinET1[i]) continue; // ET cut
165  if( parType_t((*tob2)->Et()) <= p_MinET2[i]) continue; // ET cut
166  if(p_ApplyEtaCut &&
167  ((aeta1 < p_MinEta1 || aeta1 > p_MaxEta1 ) ||
168  (aeta2 < p_MinEta2 || aeta2 > p_MaxEta2 ) )) continue;
169  accept = invmass2 >= p_InvMassMin[i] && invmass2 <= p_InvMassMax[i] && deltaR2 >= p_DeltaRMin[i] && deltaR2 <= p_DeltaRMax[i];
170  const bool fillAccept = fillHistos() and (fillHistosBasedOnHardware() ? getDecisionHardwareBit(i) : accept);
171  const bool fillReject = fillHistos() and not fillAccept;
172  const bool alreadyFilled = decision.bit(i);
173  if( accept ) {
174  decision.setBit(i, true);
175  output[i]->push_back( TCS::CompositeTOB(*tob1, *tob2) );
176  }
177  if(fillAccept and not alreadyFilled) {
178  fillHist2D(m_histAcceptM[i],sqrt((float)invmass2),sqrt((float)deltaR2));
179  } else if(fillReject) {
180  fillHist2D(m_histRejectM[i],sqrt((float)invmass2),sqrt((float)deltaR2));
181  }
182  TRG_MSG_DEBUG("Decision " << i << ": " << (accept?"pass":"fail") << " invmass2 = " << invmass2 << " deltaR2 = " << deltaR2 );
183  }
184  }
185  }
186  } else {
187 
188  TCS_EXCEPTION("InvariantMassInclusiveDeltaRSqrIncl2 alg must have 2 inputs, but got " << input.size());
189 
190  }
192 
193 }
194 
196 TCS::InvariantMassInclusiveDeltaRSqrIncl2::process( const std::vector<TCS::TOBArray const *> & input,
197  const std::vector<TCS::TOBArray *> & output,
198  Decision & decision )
199 {
200 
201 
202  if( input.size() == 2) {
203  for( TOBArray::const_iterator tob1 = input[0]->begin();
204  tob1 != input[0]->end() && distance(input[0]->begin(), tob1) < p_NumberLeading1;
205  ++tob1)
206  {
207  for( TCS::TOBArray::const_iterator tob2 = input[1]->begin();
208  tob2 != input[1]->end() && distance(input[1]->begin(), tob2) < p_NumberLeading2;
209  ++tob2) {
210  // Inv Mass calculation
211  unsigned int invmass2 = calcInvMass( *tob1, *tob2 );
212  // test DeltaR2Min, DeltaR2Max
213  unsigned int deltaR2 = calcDeltaR2( *tob1, *tob2 );
214  TRG_MSG_DEBUG("Jet1 = " << **tob1 << ", Jet2 = " << **tob2 << ", invmass2 = " << invmass2 << ", deltaR2 = " << deltaR2);
215  const int eta1 = (*tob1)->eta();
216  const int eta2 = (*tob2)->eta();
217  const unsigned int aeta1 = std::abs(eta1);
218  const unsigned int aeta2 = std::abs(eta2);
219  for(unsigned int i=0; i<numberOutputBits(); ++i) {
220  if( parType_t((*tob1)->Et()) <= p_MinET1[i]) continue; // ET cut
221  if( parType_t((*tob2)->Et()) <= p_MinET2[i]) continue; // ET cut
222  if(p_ApplyEtaCut &&
223  ((aeta1 < p_MinEta1 || aeta1 > p_MaxEta1 ) ||
224  (aeta2 < p_MinEta2 || aeta2 > p_MaxEta2 ) )) continue;
225  bool accept = invmass2 >= p_InvMassMin[i] && invmass2 <= p_InvMassMax[i] && deltaR2 >= p_DeltaRMin[i] && deltaR2 <= p_DeltaRMax[i];
226  const bool fillAccept = fillHistos() and (fillHistosBasedOnHardware() ? getDecisionHardwareBit(i) : accept);
227  const bool fillReject = fillHistos() and not fillAccept;
228  const bool alreadyFilled = decision.bit(i);
229  if( accept ) {
230  decision.setBit(i, true);
231  output[i]->push_back( TCS::CompositeTOB(*tob1, *tob2) );
232  }
233  if(fillAccept and not alreadyFilled) {
234  fillHist2D(m_histAcceptM[i],sqrt((float)invmass2),sqrt((float)deltaR2));
235  } else if(fillReject) {
236  fillHist2D(m_histRejectM[i],sqrt((float)invmass2),sqrt((float)deltaR2));
237  }
238  TRG_MSG_DEBUG("Decision " << i << ": " << (accept?"pass":"fail") << " invmass2 = " << invmass2 << " deltaR2 = " << deltaR2 );
239  }
240  }
241  }
242  } else {
243  TCS_EXCEPTION("InvariantMassInclusiveDeltaRSqrIncl2 alg must have 2 inputs, but got " << input.size());
244  }
246 }
TCS::StatusCode::SUCCESS
@ SUCCESS
Definition: Trigger/TrigT1/L1Topo/L1TopoCommon/L1TopoCommon/StatusCode.h:17
TCS::parType_t
uint32_t parType_t
Definition: Parameter.h:22
ParticleGun_SamplingFraction.eta2
eta2
Definition: ParticleGun_SamplingFraction.py:96
TCS::DataArrayImpl< GenericTOB >::const_iterator
data_t::const_iterator const_iterator
Definition: DataArrayImpl.h:18
CutsMETMaker::accept
StatusCode accept(const xAOD::Muon *mu)
Definition: CutsMETMaker.cxx:18
PlotCalibFromCool.begin
begin
Definition: PlotCalibFromCool.py:94
TCS::InvariantMassInclusiveDeltaRSqrIncl2
Definition: InvariantMassInclusiveDeltaRSqrIncl2.h:18
athena.value
value
Definition: athena.py:122
xAOD::eta1
setEt setPhi setE277 setWeta2 eta1
Definition: TrigEMCluster_v1.cxx:41
Decision.h
const
bool const RAWDATA *ch2 const
Definition: LArRodBlockPhysicsV0.cxx:562
xAOD::P4Helpers::deltaR2
double deltaR2(double rapidity1, double phi1, double rapidity2, double phi2)
from bare rapidity,phi
Definition: xAODP4Helpers.h:111
TCS::DecisionAlg
Definition: Trigger/TrigT1/L1Topo/L1TopoInterfaces/L1TopoInterfaces/DecisionAlg.h:22
TCS::InvariantMassInclusiveDeltaRSqrIncl2::~InvariantMassInclusiveDeltaRSqrIncl2
virtual ~InvariantMassInclusiveDeltaRSqrIncl2()
Definition: InvariantMassInclusiveDeltaRSqrIncl2.cxx:78
TCS::Decision::setBit
void setBit(unsigned int index, bool value)
Definition: L1Topo/L1TopoInterfaces/Root/Decision.cxx:12
TCS::InvariantMassInclusiveDeltaRSqrIncl2::processBitCorrect
virtual StatusCode processBitCorrect(const std::vector< TCS::TOBArray const * > &input, const std::vector< TCS::TOBArray * > &output, Decision &decison) override final
Definition: InvariantMassInclusiveDeltaRSqrIncl2.cxx:138
lumiFormat.i
int i
Definition: lumiFormat.py:92
TCS::CompositeTOB
Definition: CompositeTOB.h:16
PlotPulseshapeFromCool.input
input
Definition: PlotPulseshapeFromCool.py:106
InvariantMassInclusiveDeltaRSqrIncl2.h
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
TCS::InvariantMassInclusiveDeltaRSqrIncl2::process
virtual StatusCode process(const std::vector< TCS::TOBArray const * > &input, const std::vector< TCS::TOBArray * > &output, Decision &decison) override final
Definition: InvariantMassInclusiveDeltaRSqrIncl2.cxx:196
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:192
ActsTrk::to_string
std::string to_string(const DetectorType &type)
Definition: GeometryDefs.h:34
TCS
Definition: Global/GlobalSimulation/src/IO/Decision.h:18
TCS::Decision::bit
bool bit(unsigned int index) const
Definition: L1Topo/L1TopoInterfaces/L1TopoInterfaces/Decision.h:40
TCS::InvariantMassInclusiveDeltaRSqrIncl2::initialize
virtual StatusCode initialize() override final
Definition: InvariantMassInclusiveDeltaRSqrIncl2.cxx:82
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