ATLAS Offline Software
DeltaRApproxBoxCutIncl2.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  * DeltaRApproxBoxCutIncl2.cpp
6  * Created by Joerg Stelzer on 11/16/12.
7  * Modified by V SOrin 2014
8  * @brief algorithm calculates the eta and phi-distance between two lists and applies box cut criteria
9  *
10  * @param NumberLeading
11 **********************************/
12 
13 #include <cmath>
14 
16 #include "L1TopoCommon/Exception.h"
18 
19 REGISTER_ALG_TCS(DeltaRApproxBoxCutIncl2)
20 
22 {
23  defineParameter("InputWidth1", 5);
24  defineParameter("InputWidth2", 3);
25  defineParameter("NumResultBits", 3);
26  defineParameter("DeltaPhiMin", 0, 0);
27  defineParameter("DeltaPhiMax", 63, 0);
28  defineParameter("DeltaPhiMin", 0, 1);
29  defineParameter("DeltaPhiMax", 5, 1);
30  defineParameter("DeltaPhiMin", 25, 2);
31  defineParameter("DeltaPhiMax", 32, 2);
32  defineParameter("DeltaEtaMin", 0, 0);
33  defineParameter("DeltaEtaMax", 63, 0);
34  defineParameter("DeltaEtaMin", 0, 1);
35  defineParameter("DeltaEtaMax", 5, 1);
36  defineParameter("DeltaEtaMin", 25, 2);
37  defineParameter("DeltaEtaMax", 32, 2);
38  defineParameter("MinET1",1);
39  defineParameter("MinET2",1);
40  setNumberOutputBits(3);
41 }
42 
44 
45 
48  p_NumberLeading1 = parameter("InputWidth1").value();
49  p_NumberLeading2 = parameter("InputWidth2").value();
50  for(int i=0; i<3; ++i) {
51  p_DeltaPhiMin[i] = parameter("DeltaPhiMin", i).value();
52  p_DeltaPhiMax[i] = parameter("DeltaPhiMax", i).value();
53  p_DeltaEtaMin[i] = parameter("DeltaEtaMin", i).value();
54  p_DeltaEtaMax[i] = parameter("DeltaEtaMax", i).value();
55 
56  }
57  p_MinET1 = parameter("MinET1").value();
58  p_MinET2 = parameter("MinET2").value();
59 
60 
61  TRG_MSG_INFO("NumberLeading1 : " << p_NumberLeading1); // note that the reading of generic parameters doesn't work yet
62  TRG_MSG_INFO("NumberLeading2 : " << p_NumberLeading2);
63  TRG_MSG_INFO("DeltaPhiMin0 : " << p_DeltaPhiMin[0]);
64  TRG_MSG_INFO("DeltaPhiMax0 : " << p_DeltaPhiMax[0]);
65  TRG_MSG_INFO("DeltaPhiMin1 : " << p_DeltaPhiMin[1]);
66  TRG_MSG_INFO("DeltaPhiMax1 : " << p_DeltaPhiMax[1]);
67  TRG_MSG_INFO("DeltaPhiMin2 : " << p_DeltaPhiMin[2]);
68  TRG_MSG_INFO("DeltaPhiMax2 : " << p_DeltaPhiMax[2]);
69  TRG_MSG_INFO("DeltaEtaMin0 : " << p_DeltaEtaMin[0]);
70  TRG_MSG_INFO("DeltaEtaMax0 : " << p_DeltaEtaMax[0]);
71  TRG_MSG_INFO("DeltaEtaMin1 : " << p_DeltaEtaMin[1]);
72  TRG_MSG_INFO("DeltaEtaMax1 : " << p_DeltaEtaMax[1]);
73  TRG_MSG_INFO("DeltaEtaMin2 : " << p_DeltaEtaMin[2]);
74  TRG_MSG_INFO("DeltaEtaMax2 : " << p_DeltaEtaMax[2]);
75  TRG_MSG_INFO("MinET1 : " << p_MinET1);
76  TRG_MSG_INFO("MinET2 : " << p_MinET2);
77 
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 = "hDeltaRApproxBoxCutIncl2_accept_bit"+std::to_string((int)i);
83  std::string hname_reject = "hDeltaRApproxBoxCutIncl2_reject_bit"+std::to_string((int)i);
84  // deta vs dphi
85  bookHist(m_histAccept, hname_accept, "DETA vs DPHI", 100, p_DeltaEtaMin[i], p_DeltaEtaMax[i], 100, p_DeltaPhiMin[i], p_DeltaPhiMax[i]);
86  bookHist(m_histReject, hname_reject, "DETA vs DPHI", 100, p_DeltaEtaMin[i], p_DeltaEtaMax[i], 100, p_DeltaPhiMin[i], p_DeltaPhiMax[i]);
87  }
88 
89  return StatusCode::SUCCESS;
90 }
91 
93 TCS::DeltaRApproxBoxCutIncl2::processBitCorrect( const std::vector<TCS::TOBArray const *> & input,
94  const std::vector<TCS::TOBArray *> & output,
95  Decision & decision )
96 
97 {
98  return process(input,output,decision);
99 }
100 
101 
102 
104 TCS::DeltaRApproxBoxCutIncl2::process( const std::vector<TCS::TOBArray const *> & input,
105  const std::vector<TCS::TOBArray *> & output,
106  Decision & decision )
107 {
108  if(input.size() == 2) {
109  TRG_MSG_DEBUG("input size : " << input[0]->size());
110  unsigned int nLeading = p_NumberLeading1;
111  for( TOBArray::const_iterator tob1 = input[0]->begin();
112  tob1 != input[0]->end() && distance( input[0]->begin(), tob1) < nLeading;
113  ++tob1)
114  {
115  if( parType_t((*tob1)->Et()) <= p_MinET1 ) continue; // ET cut
116  for( TOBArray::const_iterator tob2 = input[1]->begin();
117  tob2 != input[1]->end() && distance( input[1]->begin(), tob2) < p_NumberLeading2;
118  ++tob2) {
119  if( parType_t((*tob2)->Et()) <= p_MinET2) continue; // ET cut
120  // DeltaPhi cuts
121  unsigned int deltaPhi = calcDeltaPhi( *tob1, *tob2 );
122  // DeltaEta cuts
123  unsigned int deltaEta = calcDeltaEta( *tob1, *tob2 );
124  //
125  // to-do change message output
126  std::stringstream msgss;
127  msgss << " Combination : " << distance( input[0]->begin(), tob1)
128  << " x " << distance( input[1]->begin(), tob2)
129  << " phi1=" << (*tob1)->phi()
130  << " , phi2=" << (*tob2)->phi()
131  << ", DeltaPhi = " << deltaPhi
132  << ", DeltaEta = " << deltaEta <<" -> ";
133  for(unsigned int i=0; i<numberOutputBits(); ++i) {
134  bool accept = false;
135  accept = ( deltaEta >= p_DeltaEtaMin[i] || deltaPhi >= p_DeltaPhiMin[i] ) && deltaPhi <= p_DeltaPhiMax[i] && deltaEta <= p_DeltaEtaMax[i];
136  const bool fillAccept = fillHistos() and (fillHistosBasedOnHardware() ? getDecisionHardwareBit(i) : accept);
137  const bool fillReject = fillHistos() and not fillAccept;
138  const bool alreadyFilled = decision.bit(i);
139  if( accept ) {
140  decision.setBit(i, true);
141  output[i]->push_back( TCS::CompositeTOB(*tob1, *tob2) );
142  }
143  if(fillAccept and not alreadyFilled) {
144  fillHist2D(m_histAccept[i],(float)deltaEta,(float)deltaPhi);
145  } else if(fillReject) {
146  fillHist2D(m_histReject[i],(float)deltaEta,(float)deltaPhi);
147  }
148  msgss << "DeltaRApproxBoxCutIncl2 alg bit" << i << (accept?" pass":" fail") << "|";
149  }
150  TRG_MSG_DEBUG(msgss.str());
151  }
152  }
153  } else {
154  TCS_EXCEPTION("DeltaRApproxBoxCutIncl2 alg must have 2 inputs, but got " << input.size());
155  }
157 }
TCS::StatusCode::SUCCESS
@ SUCCESS
Definition: Trigger/TrigT1/L1Topo/L1TopoCommon/L1TopoCommon/StatusCode.h:17
TCS::DeltaRApproxBoxCutIncl2::~DeltaRApproxBoxCutIncl2
virtual ~DeltaRApproxBoxCutIncl2()
Definition: DeltaRApproxBoxCutIncl2.cxx:43
TCS::DeltaRApproxBoxCutIncl2::initialize
virtual StatusCode initialize()
Definition: DeltaRApproxBoxCutIncl2.cxx:47
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
xAOD::deltaPhi
setSAddress setEtaMS setDirPhiMS setDirZMS setBarrelRadius setEndcapAlpha setEndcapRadius setInterceptInner setEtaMap setEtaBin setIsTgcFailure setDeltaPt deltaPhi
Definition: L2StandAloneMuon_v1.cxx:160
CutsMETMaker::accept
StatusCode accept(const xAOD::Muon *mu)
Definition: CutsMETMaker.cxx:18
PlotCalibFromCool.begin
begin
Definition: PlotCalibFromCool.py:94
Decision.h
const
bool const RAWDATA *ch2 const
Definition: LArRodBlockPhysicsV0.cxx:560
SUSY_SimplifiedModel_PostInclude.process
string process
Definition: SUSY_SimplifiedModel_PostInclude.py:42
TCS::DecisionAlg
Definition: Trigger/TrigT1/L1Topo/L1TopoInterfaces/L1TopoInterfaces/DecisionAlg.h:22
python.setupRTTAlg.size
int size
Definition: setupRTTAlg.py:39
TCS::Decision::setBit
void setBit(unsigned int index, bool value)
Definition: L1Topo/L1TopoInterfaces/Root/Decision.cxx:12
P4Helpers::deltaEta
double deltaEta(const I4Momentum &p1, const I4Momentum &p2)
Computes efficiently .
Definition: P4Helpers.h:66
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::DeltaRApproxBoxCutIncl2::processBitCorrect
virtual StatusCode processBitCorrect(const std::vector< TCS::TOBArray const * > &input, const std::vector< TCS::TOBArray * > &output, Decision &decison)
Definition: DeltaRApproxBoxCutIncl2.cxx:93
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
Definition: Global/GlobalSimulation/src/IO/Decision.h:18
TCS::DeltaRApproxBoxCutIncl2
Definition: DeltaRApproxBoxCutIncl2.h:18
TCS::Decision::bit
bool bit(unsigned int index) const
Definition: L1Topo/L1TopoInterfaces/L1TopoInterfaces/Decision.h:40
TCS::DeltaRApproxBoxCutIncl2::process
virtual StatusCode process(const std::vector< TCS::TOBArray const * > &input, const std::vector< TCS::TOBArray * > &output, Decision &decison)
Definition: DeltaRApproxBoxCutIncl2.cxx:104
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
DeltaRApproxBoxCutIncl2.h
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