ATLAS Offline Software
DisambiguationInvmIncl2.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  * DisambiguationInvmIncl2.cpp
6  * Created by Davide Gerbaudo on 2016-10-10.
7  *
8  * @brief compute the INVMASS**2 between distinct objects from two lists and applies invmass criteria
9  *
10  * The 'distinct object' criterion is based on the disambiguation
11  * as implemented in DisambiguationDRIncl2, where deltaR is > 0.
12  *
13 **********************************/
14 
15 #include <cmath>
16 
18 #include "L1TopoCommon/Exception.h"
20 
21 REGISTER_ALG_TCS(DisambiguationInvmIncl2)
22 
23 
24 // not the best solution but we will move to athena where this comes for free
25 #define LOG std::cout << "TCS::DisambiguationInvmIncl2: "
26 
27 
29 {
30  defineParameter("InputWidth1", 9);
31  defineParameter("InputWidth2", 9);
32  defineParameter("MaxTob1", 0);
33  defineParameter("MaxTob2", 0);
34  defineParameter("NumResultBits", 2);
35  defineParameter("MinET1", 1, 0);
36  defineParameter("MinET2", 1, 0);
37  defineParameter("MinMSqr", 0, 0);
38  defineParameter("MaxMSqr", 0, 0);
39  defineParameter("MinET1", 1, 1);
40  defineParameter("MinET2", 1, 1);
41  defineParameter("MinMSqr", 0, 1);
42  defineParameter("MaxMSqr", 0, 1);
43 
45 }
46 
48 
51  p_NumberLeading1 = parameter("InputWidth1").value();
52  p_NumberLeading2 = parameter("InputWidth2").value();
53  if(parameter("MaxTob1").value() > 0) p_NumberLeading1 = parameter("MaxTob1").value();
54  if(parameter("MaxTob2").value() > 0) p_NumberLeading2 = parameter("MaxTob2").value();
55 
56  for(unsigned int i=0; i<numberOutputBits(); ++i) {
57  p_MinET1[i] = parameter("MinET1",i).value();
58  p_MinET2[i] = parameter("MinET2",i).value();
59  p_InvMassMin[i] = parameter("MinMSqr", i).value();
60  p_InvMassMax[i] = parameter("MaxMSqr", i).value();
61  TRG_MSG_INFO("MinET1 : " << i << " : "<< p_MinET1[i]);
62  TRG_MSG_INFO("MinET2 : " << i << " : "<< p_MinET2[i]);
63  TRG_MSG_INFO("MinMSqr : " << i << " : "<< p_InvMassMin[i]);
64  TRG_MSG_INFO("MaxMSqr : " << i << " : "<< p_InvMassMin[i]);
65  }
66  TRG_MSG_INFO("number output : " << numberOutputBits());
67  return StatusCode::SUCCESS;
68 }
69 
71 TCS::DisambiguationInvmIncl2::processBitCorrect(const std::vector<TCS::TOBArray const *> & input,
72  const std::vector<TCS::TOBArray *> & output,
73  Decision & decision)
74 {
75  if(input.size() == 2) {
76  for(TOBArray::const_iterator tob1 = input[0]->begin();
77  tob1 != input[0]->end() && distance(input[0]->begin(), tob1) < p_NumberLeading1;
78  ++tob1) {
79  for(TCS::TOBArray::const_iterator tob2 = input[1]->begin();
80  tob2 != input[1]->end() && distance(input[1]->begin(), tob2) < p_NumberLeading2;
81  ++tob2) {
82  unsigned int invmass2 = calcInvMassBW( *tob1, *tob2 );
83  unsigned int deltaR2 = calcDeltaR2BW( *tob1, *tob2 );
84  for(unsigned int i=0; i<numberOutputBits(); ++i) {
85  bool accept = false;
86  if( parType_t((*tob1)->Et()) <= p_MinET1[i]) continue; // ET cut
87  if( parType_t((*tob2)->Et()) <= p_MinET2[i]) continue; // ET cut
88  accept = (deltaR2 > 0 &&
89  invmass2 >= p_InvMassMin[i] &&
90  invmass2 <= p_InvMassMax[i] );
91  if( accept ) {
92  decision.setBit(i, true);
93  output[i]->push_back(TCS::CompositeTOB(*tob1, *tob2));
94  }
95  TRG_MSG_DEBUG("Decision " << i << ": " << (accept?"pass":"fail")
96  << " deltaR = " << deltaR2
97  << " invmass2 = " << invmass2);
98  } // for(i)
99  } // for(tob2)
100  } // for(tob1)
101  } else {
102  TCS_EXCEPTION("DisambiguationInvmIncl2 alg must have 2 inputs, but got " << input.size());
103  }
105 }
106 
108 TCS::DisambiguationInvmIncl2::process(const std::vector<TCS::TOBArray const *> & input,
109  const std::vector<TCS::TOBArray *> & output,
110  Decision & decision)
111 {
112  if( input.size() == 2) {
113  for( TOBArray::const_iterator tob1 = input[0]->begin();
114  tob1 != input[0]->end() && distance(input[0]->begin(), tob1) < p_NumberLeading1;
115  ++tob1) {
116  for(TCS::TOBArray::const_iterator tob2 = input[1]->begin();
117  tob2 != input[1]->end() && distance(input[1]->begin(), tob2) < p_NumberLeading2;
118  ++tob2) {
119  unsigned int invmass2 = calcInvMass( *tob1, *tob2 );
120  unsigned int deltaR2 = calcDeltaR2( *tob1, *tob2 );
121  for(unsigned int i=0; i<numberOutputBits(); ++i) {
122  bool accept = false;
123  if( parType_t((*tob1)->Et()) <= p_MinET1[i]) continue;
124  if( parType_t((*tob2)->Et()) <= p_MinET2[i]) continue;
125  accept = (deltaR2 > 0 &&
126  invmass2 >= p_InvMassMin[i] &&
127  invmass2 <= p_InvMassMax[i] );
128  if( accept ) {
129  decision.setBit(i, true);
130  output[i]->push_back(TCS::CompositeTOB(*tob1, *tob2));
131  }
132  TRG_MSG_DEBUG("Decision " << i << ": " << (accept?"pass":"fail") << " deltaR = " << deltaR2 );
133  } // for(i)
134  } // for(tob2)
135  } // for(tob1)
136  } else {
137  TCS_EXCEPTION("DisambiguationInvmIncl2 alg must have 2 inputs, but got " << input.size());
138  }
140 }
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
CutsMETMaker::accept
StatusCode accept(const xAOD::Muon *mu)
Definition: CutsMETMaker.cxx:18
PlotCalibFromCool.begin
begin
Definition: PlotCalibFromCool.py:94
athena.value
value
Definition: athena.py:124
DisambiguationInvmIncl2.h
Decision.h
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::DisambiguationInvmIncl2::DisambiguationInvmIncl2
DisambiguationInvmIncl2(const std::string &name)
Definition: DisambiguationInvmIncl2.cxx:28
TCS::Decision::setBit
void setBit(unsigned int index, bool value)
Definition: L1Topo/L1TopoInterfaces/Root/Decision.cxx:12
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
TCS::DisambiguationInvmIncl2::initialize
virtual StatusCode initialize()
Definition: DisambiguationInvmIncl2.cxx:50
PlotPulseshapeFromCool.input
input
Definition: PlotPulseshapeFromCool.py:106
TCS::DisambiguationInvmIncl2::process
virtual StatusCode process(const std::vector< TCS::TOBArray const * > &input, const std::vector< TCS::TOBArray * > &output, Decision &decison)
Definition: DisambiguationInvmIncl2.cxx:108
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
TCS::DisambiguationInvmIncl2::processBitCorrect
virtual StatusCode processBitCorrect(const std::vector< TCS::TOBArray const * > &input, const std::vector< TCS::TOBArray * > &output, Decision &decison)
Definition: DisambiguationInvmIncl2.cxx:71
REGISTER_ALG_TCS
#define REGISTER_ALG_TCS(CLASS)
Definition: AlgFactory.h:62
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
TCS::DisambiguationInvmIncl2::~DisambiguationInvmIncl2
virtual ~DisambiguationInvmIncl2()
Definition: DisambiguationInvmIncl2.cxx:47
TCS::DecisionAlg::setNumberOutputBits
void setNumberOutputBits(unsigned int numberOutputBits)
Definition: Trigger/TrigT1/L1Topo/L1TopoInterfaces/L1TopoInterfaces/DecisionAlg.h:40
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