ATLAS Offline Software
ExclusiveJets.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  * ExclusiveJets.cxx
6  * Created by Carlos Moreno based on InvariantMassInclusive1 by V Sorin
7  *
8  * For questions contact atlas-trig-l1topo-algcom@cern.ch.
9  * @brief algorithm for exclusive jets acceptance
10  *
11  * @param NumberLeading
12  *
13 **********************************/
14 #include <cmath>
15 #include <string>
16 #include <iostream>
17 #include <sstream>
18 #include <vector>
19 
21 #include "L1TopoCommon/Exception.h"
24 
25 REGISTER_ALG_TCS(ExclusiveJets)
26 
28 {
29  defineParameter("InputWidth", 3);
30  defineParameter("MaxTob", 0);
31  defineParameter("NumResultBits", 6);
32  setNumberOutputBits(6);
33 
34  defineParameter("PtScale",0);
35  defineParameter("PtShift",0);
36  for (unsigned int i=0;i<numberOutputBits();i++){
37  defineParameter("MinXi", 0, i);
38  defineParameter("MaxXi", 999, i);
39  defineParameter("MinET1",0,i);
40  defineParameter("ApplyEtaCut",0,i);
41  defineParameter("MinEta1",0,i);
42  defineParameter("MaxEta1",999,i);
43  defineParameter("MinEta2",0,i);
44  defineParameter("MaxEta2",999,i);
45  }
46 
47 }
51  if(parameter("MaxTob").value() > 0) {
52  p_NumberLeading1 = parameter("MaxTob").value();
53  } else {
54  p_NumberLeading1 = parameter("InputWidth").value();
55  }
56  p_PtScale = parameter("PtScale").value();
57  p_PtShift = parameter("PtShift").value();
58  for(unsigned int i=0; i<numberOutputBits(); ++i) {
59 
60  p_XiMin[i] = parameter("MinXi", i).value();
61  p_XiMax[i] = parameter("MaxXi", i).value();
62 
63  p_MinET1[i] = parameter("MinET1",i).value();
64 
65  p_ApplyEtaCut[i] = parameter("ApplyEtaCut",i).value();
66  p_MinEta1[i] = parameter("MinEta1" ,i).value();
67  p_MaxEta1[i] = parameter("MaxEta1" ,i).value();
68  p_MinEta2[i] = parameter("MinEta2" ,i).value();
69  p_MaxEta2[i] = parameter("MaxEta2" ,i).value();
70  }
71  TRG_MSG_INFO("NumberLeading1 : " << p_NumberLeading1);
72  TRG_MSG_INFO("PtScale : " << p_PtScale);
73  TRG_MSG_INFO("PtShift : " << p_PtShift);
74  for(unsigned int i=0; i<numberOutputBits(); ++i) {
75  TRG_MSG_INFO("XiMin : " << p_XiMin[i]);
76  TRG_MSG_INFO("XiMax : " << p_XiMax[i]);
77 
78  TRG_MSG_INFO("MinET1 : " << p_MinET1[i]);
79 
80 
81  TRG_MSG_INFO("ApplyEtaCut : "<<p_ApplyEtaCut[i] );
82 
83  TRG_MSG_INFO("MinEta1 : "<<p_MinEta1[i] );
84  TRG_MSG_INFO("MaxEta1 : "<<p_MaxEta1[i] );
85  TRG_MSG_INFO("MinEta2 : "<<p_MinEta2[i] );
86  TRG_MSG_INFO("MaxEta2 : "<<p_MaxEta2[i] );
87  }
88 
89  TRG_MSG_INFO("number output : " << numberOutputBits());
90 
91  // book histograms
92  for(unsigned int i=0; i<numberOutputBits(); ++i) {
93  std::string hname_accept = "hExclusiveJets_accept_bit"+std::to_string((int)i);
94  std::string hname_reject = "hExclusiveJets_reject_bit"+std::to_string((int)i);
95  // mass
96  bookHist(m_histAcceptX, hname_accept, "Xi1 vs Xi2", 100, p_XiMin[i], p_XiMax[i], 100, p_XiMin[i], p_XiMax[i]);
97  bookHist(m_histRejectX, hname_reject, "Xi1 vs Xi2", 100, p_XiMin[i], p_XiMax[i], 100, p_XiMin[i], p_XiMax[i]);
98  // eta2 vs. eta1
99  bookHist(m_histAcceptEta1Eta2, hname_accept, "ETA vs ETA", 100, p_MinEta1[i], p_MaxEta1[i], 100, p_MinEta2[i], p_MaxEta2[i]);
100  bookHist(m_histRejectEta1Eta2, hname_reject, "ETA vs ETA", 100, p_MinEta1[i], p_MaxEta1[i], 100, p_MinEta2[i], p_MaxEta2[i]);
101  }
102 
103 
104  return StatusCode::SUCCESS;
105 }
107 TCS::ExclusiveJets::processBitCorrect( const std::vector<TCS::TOBArray const *> & input,
108  const std::vector<TCS::TOBArray *> & output,
109  Decision & decision ) // Not really bitwise, keep the name for the future
110 {
111  if(input.size() == 1) {
112 
113  for( TOBArray::const_iterator tob1 = input[0]->begin();
114  tob1 != input[0]->end() && distance( input[0]->begin(), tob1) < p_NumberLeading1;
115  ++tob1)
116  {
117 
118  TCS::TOBArray::const_iterator tob2 = tob1; ++tob2;
119  for( ;
120  tob2 != input[0]->end() && distance( input[0]->begin(), tob2) < p_NumberLeading1;
121  ++tob2) {
122 
123  //In the ticket ATR-17320, pT_offline were defined as A*pT_L1+B, where A=1.4 and B=20 for run2
124  //A and B definition might change according to run3 configuration -> menu parameter
125  unsigned int xi_1 = TSU::Kinematics::calcXi1(*tob1,*tob2, p_PtShift, p_PtScale);
126  unsigned int xi_2 = TSU::Kinematics::calcXi2(*tob1,*tob2, p_PtShift, p_PtScale);
127 
128  const int eta1 = (*tob1)->eta();
129  const int eta2 = (*tob2)->eta();
130  const unsigned int aeta1 = std::abs(eta1);
131  const unsigned int aeta2 = std::abs(eta2);
132  for(unsigned int i=0; i<numberOutputBits(); ++i) {
133  bool accept = false;
134  if( parType_t((*tob1)->Et()) <= p_MinET1[i]) continue; // ET cut
135  if( parType_t((*tob2)->Et()) <= p_MinET1[i]) continue; // ET cut
136  if(p_ApplyEtaCut[i] && //skip if not in range. eta ranges are inclusive at lower edge, exclusive at upper edge
137  ((aeta1 < p_MinEta1[i] || aeta1 >= p_MaxEta1[i] ) ||
138  (aeta2 < p_MinEta2[i] || aeta2 >= p_MaxEta2[i] ) )) continue;
139 
140  //ExclusiveJets algo definition is inclusive of both edges for Xi
141  accept = (xi_1 >= p_XiMin[i]) && (xi_1 <= p_XiMax[i]) && (xi_2 >= p_XiMin[i]) && (xi_2 <= p_XiMax[i]); //
142  const bool fillAccept = fillHistos() and (fillHistosBasedOnHardware() ? getDecisionHardwareBit(i) : accept);
143  const bool fillReject = fillHistos() and not fillAccept;
144  const bool alreadyFilled = decision.bit(i);
145  if( accept ) {
146  decision.setBit(i, true);
147  output[i]->push_back( TCS::CompositeTOB(*tob1, *tob2) );
148  }
149  if(fillAccept and not alreadyFilled) {
150  fillHist2D(m_histAcceptX[i],xi_1,xi_2);
151  fillHist2D(m_histAcceptEta1Eta2[i],eta1, eta2);
152  } else if(fillReject) {
153  fillHist2D(m_histRejectX[i],xi_1,xi_2);
154  fillHist2D(m_histRejectEta1Eta2[i],eta1, eta2);
155  }
156  TRG_MSG_DEBUG("Decision " << i << ": " << (accept?"pass":"fail") << " xi_1 = " << xi_1);
157 
158  }
159  }
160  }
161  } else {
162  TCS_EXCEPTION("ExclusiveJets alg must have 1 input list, but got " << input.size());
163  }
165 }
167 TCS::ExclusiveJets::process( const std::vector<TCS::TOBArray const *> & input,
168  const std::vector<TCS::TOBArray *> & output,
169  Decision & decision )
170 {
171  if(input.size() == 1) {
172 
173  for( TOBArray::const_iterator tob1 = input[0]->begin();
174  tob1 != input[0]->end() && distance( input[0]->begin(), tob1) < p_NumberLeading1;
175  ++tob1)
176  {
177 
178  TCS::TOBArray::const_iterator tob2 = tob1; ++tob2;
179  for( ;
180  tob2 != input[0]->end() && distance( input[0]->begin(), tob2) < p_NumberLeading1;
181  ++tob2) {
182 
183  //In the ticket ATR-17320, pT_offline were defined as A*pT_L1+B, where A=1.4 and B=20 for run2
184  //A and B definition might change according to run3 configuration.
185  double xi_1 = (1.4*parType_t((*tob1)->Et())+20.)*exp((*tob1)->etaDouble())+(1.4*parType_t((*tob2)->Et())+20.)*exp((*tob2)->etaDouble());
186  double xi_2 = (1.4*parType_t((*tob1)->Et())+20.)*exp(-1.*(*tob1)->etaDouble())+(1.4*parType_t((*tob2)->Et())+20.)*exp(-1.*(*tob2)->etaDouble());
187 
188  const int eta1 = (*tob1)->eta();
189  const int eta2 = (*tob2)->eta();
190  const unsigned int aeta1 = std::abs(eta1);
191  const unsigned int aeta2 = std::abs(eta2);
192  for(unsigned int i=0; i<numberOutputBits(); ++i) {
193  bool accept = false;
194  if( parType_t((*tob1)->Et()) <= p_MinET1[i]) continue; // ET cut
195  if( parType_t((*tob2)->Et()) <= p_MinET1[i]) continue; // ET cut
196  if(p_ApplyEtaCut[i] &&
197  ((aeta1 < p_MinEta1[i] || aeta1 > p_MaxEta1[i] ) ||
198  (aeta2 < p_MinEta2[i] || aeta2 > p_MaxEta2[i] ) )) continue;
199 
200  accept = (xi_1 >p_XiMin[i]) && (xi_1 < p_XiMax[i]) && (xi_2 > p_XiMin[i]) && (xi_2 < p_XiMax[i]); //
201  const bool fillAccept = fillHistos() and (fillHistosBasedOnHardware() ? getDecisionHardwareBit(i) : accept);
202  const bool fillReject = fillHistos() and not fillAccept;
203  const bool alreadyFilled = decision.bit(i);
204  if( accept ) {
205  decision.setBit(i, true);
206  output[i]->push_back( TCS::CompositeTOB(*tob1, *tob2) );
207  }
208  if(fillAccept and not alreadyFilled) {
209  fillHist2D(m_histAcceptX[i],xi_1,xi_2);
210  fillHist2D(m_histAcceptEta1Eta2[i],eta1, eta2);
211  } else if(fillReject) {
212  fillHist2D(m_histRejectX[i],xi_1,xi_2);
213  fillHist2D(m_histRejectEta1Eta2[i],eta1, eta2);
214  }
215  TRG_MSG_DEBUG("Decision " << i << ": " << (accept?"pass":"fail") << " xi_1 = " << xi_1);
216 
217  }
218  }
219  }
220  } else {
221  TCS_EXCEPTION("ExclusiveJets alg must have 1 input list, but got " << input.size());
222  }
224 }
Kinematics.h
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
athena.value
value
Definition: athena.py:124
xAOD::eta1
setEt setPhi setE277 setWeta2 eta1
Definition: TrigEMCluster_v1.cxx:41
Decision.h
const
bool const RAWDATA *ch2 const
Definition: LArRodBlockPhysicsV0.cxx:560
drawFromPickle.exp
exp
Definition: drawFromPickle.py:36
TSU::Kinematics::calcXi1
static unsigned int calcXi1(const TCS::GenericTOB *tob1, const TCS::GenericTOB *tob2, unsigned ptShift, unsigned ptScale)
Definition: Kinematics.cxx:174
TSU::Kinematics::calcXi2
static unsigned int calcXi2(const TCS::GenericTOB *tob1, const TCS::GenericTOB *tob2, unsigned ptShift, unsigned ptScale)
Definition: Kinematics.cxx:188
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::ExclusiveJets::~ExclusiveJets
virtual ~ExclusiveJets()
Definition: ExclusiveJets.cxx:48
lumiFormat.i
int i
Definition: lumiFormat.py:85
TCS::CompositeTOB
Definition: CompositeTOB.h:16
PlotPulseshapeFromCool.input
input
Definition: PlotPulseshapeFromCool.py:106
TCS::ExclusiveJets::initialize
virtual StatusCode initialize() override final
Definition: ExclusiveJets.cxx:50
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:221
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::ExclusiveJets
Definition: ExclusiveJets.h:13
TCS::ExclusiveJets::processBitCorrect
virtual StatusCode processBitCorrect(const std::vector< TCS::TOBArray const * > &input, const std::vector< TCS::TOBArray * > &output, Decision &decison) override final
Definition: ExclusiveJets.cxx:107
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::ExclusiveJets::process
virtual StatusCode process(const std::vector< TCS::TOBArray const * > &input, const std::vector< TCS::TOBArray * > &output, Decision &decison) override final
Definition: ExclusiveJets.cxx:167
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
ExclusiveJets.h