ATLAS Offline Software
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 
16 #include "L1TopoCommon/Exception.h"
18 
19 #include <cmath>
20 
21 REGISTER_ALG_TCS(DeltaRSqrIncl2Charge)
22 
23 
25 {
26  defineParameter("InputWidth1", 9);
27  defineParameter("InputWidth2", 9);
28  defineParameter("MaxTob1", 0);
29  defineParameter("MaxTob2", 0);
30  defineParameter("NumResultBits", 3);
31  defineParameter("MinET1",1,0);
32  defineParameter("MinET2",1,0);
33  defineParameter("DeltaRMin", 0, 0);
34  defineParameter("DeltaRMax", 0, 0);
35  defineParameter("MinET1",1,1);
36  defineParameter("MinET2",1,1);
37  defineParameter("DeltaRMin", 0, 1);
38  defineParameter("DeltaRMax", 0, 1);
39  defineParameter("MinET1",1,2);
40  defineParameter("MinET2",1,2);
41  defineParameter("DeltaRMin", 0, 2);
42  defineParameter("DeltaRMax", 0, 2);
43  setNumberOutputBits(3);
44 }
45 
47 
48 
51 
52  m_NumberLeading1 = parameter("InputWidth1").value();
53  m_NumberLeading2 = parameter("InputWidth2").value();
54  if(parameter("MaxTob1").value() > 0) m_NumberLeading1 = parameter("MaxTob1").value();
55  if(parameter("MaxTob2").value() > 0) m_NumberLeading2 = parameter("MaxTob2").value();
56 
57  for(unsigned int i=0; i<numberOutputBits(); ++i) {
58  m_DeltaRMin[i] = parameter("DeltaRMin", i).value();
59  m_DeltaRMax[i] = parameter("DeltaRMax", i).value();
60  m_MinET1[i] = parameter("MinET1",i).value();
61  m_MinET2[i] = parameter("MinET2",i).value();
62  TRG_MSG_INFO("DeltaRMin" << i << " : " << m_DeltaRMin[i]);
63  TRG_MSG_INFO("DeltaRMax" << i << " : " << m_DeltaRMax[i]);
64 
65  TRG_MSG_INFO("MinET1 : " << m_MinET1[i]);
66  TRG_MSG_INFO("MinET2 : " << m_MinET2[i]);
67 
68  }
69 
70  TRG_MSG_INFO("NumberLeading1 : " << m_NumberLeading1);
71  TRG_MSG_INFO("NumberLeading2 : " << m_NumberLeading2);
72 
73  TRG_MSG_INFO("number output : " << numberOutputBits());
74 
75  // book histograms
76  for(unsigned int i=0; i<numberOutputBits(); ++i) {
77  std::string hname_accept = "hDeltaRSqrIncl2Charge_accept_bit"+std::to_string(static_cast<int>(i));
78  std::string hname_reject = "hDeltaRSqrIncl2Charge_reject_bit"+std::to_string(static_cast<int>(i));
79  // dR
80  bookHist(m_histAccept, hname_accept, "DR", 100, std::sqrt(m_DeltaRMin[i]), std::sqrt(m_DeltaRMax[i]));
81  bookHist(m_histReject, hname_reject, "DR", 100, std::sqrt(m_DeltaRMin[i]), std::sqrt(m_DeltaRMax[i]));
82  // eta2 vs. eta1
83  bookHist(m_histAcceptEta1Eta2, hname_accept, "ETA vs ETA", 100, -70, 70, 100, -70, 70);
84  bookHist(m_histRejectEta1Eta2, hname_reject, "ETA vs ETA", 100, -70, 70, 100, -70, 70);
85  }
86 
87  return StatusCode::SUCCESS;
88 }
89 
90 
92 TCS::DeltaRSqrIncl2Charge::processBitCorrect( const std::vector<TCS::TOBArray const *> & input,
93  const std::vector<TCS::TOBArray *> & output,
94  Decision & decision )
95 {
96 
97  if( input.size() == 2) {
98 
99  for( TOBArray::const_iterator tob1 = input[0]->begin();
100  tob1 != input[0]->end() && distance(input[0]->begin(), tob1) < m_NumberLeading1;
101  ++tob1)
102  {
103  for( TCS::TOBArray::const_iterator tob2 = input[1]->begin();
104  tob2 != input[1]->end() && distance(input[1]->begin(), tob2) < m_NumberLeading2;
105  ++tob2) {
106  // test DeltaR2Min, DeltaR2Max
107  unsigned int deltaR2 = calcDeltaR2BW( *tob1, *tob2 );
108  TRG_MSG_DEBUG("Jet1 = " << **tob1 << ", Jet2 = " << **tob2 << ", deltaR2 = " << deltaR2);
109  // Charge cut ( 1 = positive, -1 = negative, 0 = undefined (RPC) )
110  int charge1 = (*tob1)->charge();
111  int charge2 = (*tob2)->charge();
112  int totalCharge = charge1 + charge2;
113  bool acceptCharge = true;
114  if ( std::abs(totalCharge) == 2 ) { acceptCharge = false; }
115  for(unsigned int i=0; i<numberOutputBits(); ++i) {
116  bool accept = false;
117  if( parType_t((*tob1)->Et()) <= m_MinET1[i]) continue; // ET cut
118  if( parType_t((*tob2)->Et()) <= m_MinET2[i]) continue; // ET cut
119  accept = deltaR2 >= m_DeltaRMin[i] && deltaR2 <= m_DeltaRMax[i] && acceptCharge;
120  const bool fillAccept = fillHistos() and (fillHistosBasedOnHardware() ? getDecisionHardwareBit(i) : accept);
121  const bool fillReject = fillHistos() and not fillAccept;
122  const bool alreadyFilled = decision.bit(i);
123  if( accept ) {
124  decision.setBit(i, true);
125  output[i]->push_back(TCS::CompositeTOB(*tob1, *tob2));
126  }
127  if(fillAccept and not alreadyFilled) {
128  fillHist1D(m_histAccept[i],std::sqrt(static_cast<float>(deltaR2)));
129  fillHist2D(m_histAcceptEta1Eta2[i],(*tob1)->eta(),(*tob2)->eta());
130  } else if(fillReject) {
131  fillHist1D(m_histReject[i],std::sqrt(static_cast<float>(deltaR2)));
132  fillHist2D(m_histRejectEta1Eta2[i],(*tob1)->eta(),(*tob2)->eta());
133  }
134  TRG_MSG_DEBUG("Decision " << i << ": " << (accept?"pass":"fail") << " deltaR2 = " << deltaR2);
135  }
136  }
137  }
138  } else {
139  TCS_EXCEPTION("DeltaRSqrIncl2Charge alg must have 2 inputs, but got " << input.size());
140  }
142 }
143 
145 TCS::DeltaRSqrIncl2Charge::process( const std::vector<TCS::TOBArray const *> & input,
146  const std::vector<TCS::TOBArray *> & output,
147  Decision & decision )
148 {
149 
150  if( input.size() == 2) {
151 
152  for( TOBArray::const_iterator tob1 = input[0]->begin();
153  tob1 != input[0]->end() && distance(input[0]->begin(), tob1) < m_NumberLeading1;
154  ++tob1)
155  {
156 
157 
158  for( TCS::TOBArray::const_iterator tob2 = input[1]->begin();
159  tob2 != input[1]->end() && distance(input[1]->begin(), tob2) < m_NumberLeading2;
160  ++tob2) {
161  // test DeltaR2Min, DeltaR2Max
162  unsigned int deltaR2 = calcDeltaR2( *tob1, *tob2 );
163  TRG_MSG_DEBUG("Jet1 = " << **tob1 << ", Jet2 = " << **tob2 << ", deltaR2 = " << deltaR2);
164  // Charge cut ( 1 = positive, -1 = negative, 0 = undefined (RPC) )
165  int charge1 = (*tob1)->charge();
166  int charge2 = (*tob2)->charge();
167  int totalCharge = charge1 + charge2;
168  bool acceptCharge = true;
169  if ( std::abs(totalCharge) == 2 ) { acceptCharge = false; }
170  for(unsigned int i=0; i<numberOutputBits(); ++i) {
171  bool accept = false;
172  if( parType_t((*tob1)->Et()) <= m_MinET1[i]) continue; // ET cut
173  if( parType_t((*tob2)->Et()) <= m_MinET2[i]) continue; // ET cut
174  accept = deltaR2 >= m_DeltaRMin[i] && deltaR2 <= m_DeltaRMax[i] && acceptCharge;
175  const bool fillAccept = fillHistos() and (fillHistosBasedOnHardware() ? getDecisionHardwareBit(i) : accept);
176  const bool fillReject = fillHistos() and not fillAccept;
177  const bool alreadyFilled = decision.bit(i);
178  if( accept ) {
179  decision.setBit(i, true);
180  output[i]->push_back(TCS::CompositeTOB(*tob1, *tob2));
181  }
182  if(fillAccept and not alreadyFilled) {
183  fillHist1D(m_histAccept[i],std::sqrt(static_cast<float>(deltaR2)));
184  fillHist2D(m_histAcceptEta1Eta2[i],(*tob1)->eta(),(*tob2)->eta());
185  } else if(fillReject) {
186  fillHist1D(m_histReject[i],std::sqrt(static_cast<float>(deltaR2)));
187  fillHist2D(m_histRejectEta1Eta2[i],(*tob1)->eta(),(*tob2)->eta());
188  }
189  TRG_MSG_DEBUG("Decision " << i << ": " << (accept?"pass":"fail") << " deltaR2 = " << deltaR2);
190  }
191  }
192  }
193  } else {
194  TCS_EXCEPTION("DeltaRSqrIncl2Charge alg must have 2 inputs, but got " << input.size());
195  }
197 }
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
TCS::DeltaRSqrIncl2Charge::initialize
virtual StatusCode initialize()
Definition: DeltaRSqrIncl2Charge.cxx:50
athena.value
value
Definition: athena.py:124
Decision.h
const
bool const RAWDATA *ch2 const
Definition: LArRodBlockPhysicsV0.cxx:560
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::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::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
DeltaRSqrIncl2Charge.h
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:221
ActsTrk::to_string
std::string to_string(const DetectorType &type)
Definition: GeometryDefs.h:34
TCS::DeltaRSqrIncl2Charge::process
virtual StatusCode process(const std::vector< TCS::TOBArray const * > &input, const std::vector< TCS::TOBArray * > &output, Decision &decison)
Definition: DeltaRSqrIncl2Charge.cxx:145
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::DeltaRSqrIncl2Charge::processBitCorrect
virtual StatusCode processBitCorrect(const std::vector< TCS::TOBArray const * > &input, const std::vector< TCS::TOBArray * > &output, Decision &decison)
Definition: DeltaRSqrIncl2Charge.cxx:92
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
TCS::DeltaRSqrIncl2Charge::~DeltaRSqrIncl2Charge
virtual ~DeltaRSqrIncl2Charge()
Definition: DeltaRSqrIncl2Charge.cxx:46
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
TCS::DeltaRSqrIncl2Charge
Definition: DeltaRSqrIncl2Charge.h:15