ATLAS Offline Software
DeltaPhiIncl1.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  * DeltaPhiIncl1.cpp
6  * Created by Joerg Stelzer on 11/16/12.
7  * Modified by V SOrin 2014
8  *
9  * @brief algorithm calculates the phi-distance between one lists and applies delta-phi criteria
10  *
11  * @param NumberLeading
12 **********************************/
13 
14 #include <cmath>
15 
17 #include "L1TopoCommon/Exception.h"
19 
20 REGISTER_ALG_TCS(DeltaPhiIncl1)
21 
22 
24 {
25  defineParameter("InputWidth", 0);
26  defineParameter("MaxTob", 0);
27  defineParameter("NumResultBits", 2);
28  defineParameter("MinET1",0,0);
29  defineParameter("MinET2",0,0);
30  defineParameter("MinDeltaPhi", 0, 0);
31  defineParameter("MaxDeltaPhi", 31, 0);
32  defineParameter("MinET1",0,1);
33  defineParameter("MinET2",0,1);
34  defineParameter("MinDeltaPhi", 0, 1);
35  defineParameter("MaxDeltaPhi", 31, 1);
36 
37  setNumberOutputBits(2);
38 }
39 
41 
42 
45 
46  if(parameter("MaxTob").value() > 0) {
47  p_NumberLeading1 = parameter("MaxTob").value();
48  p_NumberLeading2 = parameter("MaxTob").value();
49  } else {
50  p_NumberLeading1 = parameter("InputWidth").value();
51  p_NumberLeading2 = parameter("InputWidth").value();
52  }
53 
54  for(unsigned int i=0; i<numberOutputBits(); ++i) {
55  p_DeltaPhiMin[i] = parameter("MinDeltaPhi", i).value();
56  p_DeltaPhiMax[i] = parameter("MaxDeltaPhi", i).value();
57  p_MinET1[i] = parameter("MinET1",i).value();
58  p_MinET2[i] = parameter("MinET2",i).value();
59 
60  TRG_MSG_INFO("DeltaPhiMin : " << p_DeltaPhiMin[i]);
61  TRG_MSG_INFO("DeltaPhiMax : " << p_DeltaPhiMax[i]);
62  TRG_MSG_INFO("MinET1 : " << p_MinET1[i]);
63  TRG_MSG_INFO("MinET2 : " << p_MinET2[i]);
64 
65  }
66 
67  TRG_MSG_INFO("NumberLeading1 : " << p_NumberLeading1); // note that the reading of generic parameters doesn't work yet
68  TRG_MSG_INFO("NumberLeading2 : " << p_NumberLeading2);
69  TRG_MSG_INFO("number output : " << numberOutputBits());
70 
71  // book histograms
72  for(unsigned int i=0; i<numberOutputBits(); ++i) {
73  std::string hname_accept = "hDeltaPhiIncl1_accept_bit"+std::to_string((int)i);
74  std::string hname_reject = "hDeltaPhiIncl1_reject_bit"+std::to_string((int)i);
75  // mass
76  bookHist(m_histAccept, hname_accept, "DPHI", 100, p_DeltaPhiMin[i], p_DeltaPhiMax[i]);
77  bookHist(m_histReject, hname_reject, "DPHI", 100, p_DeltaPhiMin[i], p_DeltaPhiMax[i]);
78  }
79 
80 
81  return StatusCode::SUCCESS;
82 }
83 
84 
85 
87 TCS::DeltaPhiIncl1::processBitCorrect( const std::vector<TCS::TOBArray const *> & input,
88  const std::vector<TCS::TOBArray *> & output,
89  Decision & decision )
90 {
91  if(input.size() == 1) {
92  TRG_MSG_DEBUG("input size : " << input[0]->size());
93  unsigned int nLeading = p_NumberLeading1;
94  unsigned int nLeading2 = p_NumberLeading2;
95  for( TOBArray::const_iterator tob1 = input[0]->begin();
96  tob1 != input[0]->end() && distance( input[0]->begin(), tob1) < nLeading;
97  ++tob1)
98  {
99  if (nLeading < input[0]->size()) {
100  TCS::TOBArray::const_iterator tob1_plus1 = tob1; ++tob1_plus1;
101  if ((*tob1)->Et() == (*tob1_plus1)->Et() && distance(input[0]->begin(), tob1) == nLeading - 1) {
102  for(unsigned int i=0; i<numberOutputBits(); ++i) {
103  output[i]->setAmbiguityFlag(true);
104  }
105  }
106  }
107  TCS::TOBArray::const_iterator tob2 = tob1; ++tob2;
108  for( ;
109  tob2 != input[0]->end() && distance( input[0]->begin(), tob2) < nLeading2;
110  ++tob2) {
111  // DeltaPhi cuts
112  unsigned int deltaPhi = calcDeltaPhiBW( *tob1, *tob2 );
113  std::stringstream msgss;
114  msgss << " phi1=" << (*tob1)->phi() << " , phi2=" << (*tob2)->phi()
115  << ", DeltaPhi = " << deltaPhi << " -> ";
116  for(unsigned int i=0; i<numberOutputBits(); ++i) {
117  bool accept = false;
118  if( parType_t((*tob1)->Et()) <= std::min(p_MinET1[i],p_MinET2[i])) continue; // ET cut
119  if( parType_t((*tob2)->Et()) <= std::min(p_MinET1[i],p_MinET2[i])) continue; // ET cut
120  if( (parType_t((*tob1)->Et()) <= std::max(p_MinET1[i],p_MinET2[i])) && (parType_t((*tob2)->Et()) <= std::max(p_MinET1[i],p_MinET2[i]))) continue;
121  accept = deltaPhi >= p_DeltaPhiMin[i] && deltaPhi <= p_DeltaPhiMax[i];
122  const bool fillAccept = fillHistos() and (fillHistosBasedOnHardware() ? getDecisionHardwareBit(i) : accept);
123  const bool fillReject = fillHistos() and not fillAccept;
124  const bool alreadyFilled = decision.bit(i);
125  if( accept ) {
126  decision.setBit(i, true);
127  output[i]->push_back( TCS::CompositeTOB(*tob1, *tob2) );
128  }
129  if(fillAccept and not alreadyFilled) {
130  fillHist1D(m_histAccept[i],deltaPhi);
131  } else if(fillReject) {
132  fillHist1D(m_histReject[i],deltaPhi);
133  }
134  TRG_MSG_DEBUG("DeltaPhiIncl1 = " << deltaPhi << " -> "
135  << (accept?"pass":"fail"));
136  }
137  }
138  }
139  } else {
140  TCS_EXCEPTION("DeltaPhiIncl1 alg must have 1 input, but got " << input.size());
141  }
143 }
144 
146 TCS::DeltaPhiIncl1::process( const std::vector<TCS::TOBArray const *> & input,
147  const std::vector<TCS::TOBArray *> & output,
148  Decision & decision )
149 {
150  if(input.size() == 1) {
151  TRG_MSG_DEBUG("input size : " << input[0]->size());
152  unsigned int nLeading = p_NumberLeading1;
153  unsigned int nLeading2 = p_NumberLeading2;
154  for( TOBArray::const_iterator tob1 = input[0]->begin();
155  tob1 != input[0]->end() && distance( input[0]->begin(), tob1) < nLeading;
156  ++tob1)
157  {
158  if (nLeading < input[0]->size()) {
159  TCS::TOBArray::const_iterator tob1_plus1 = tob1; ++tob1_plus1;
160  if ((*tob1)->Et() == (*tob1_plus1)->Et() && distance(input[0]->begin(), tob1) == nLeading - 1) {
161  for(unsigned int i=0; i<numberOutputBits(); ++i) {
162  output[i]->setAmbiguityFlag(true);
163  }
164  }
165  }
166  TCS::TOBArray::const_iterator tob2 = tob1; ++tob2;
167  for( ;
168  tob2 != input[0]->end() && distance( input[0]->begin(), tob2) < nLeading2;
169  ++tob2) {
170  // DeltaPhi cuts
171  unsigned int deltaPhi = calcDeltaPhi( *tob1, *tob2 );
172  std::stringstream msgss;
173  msgss << " Combination : " << distance( input[0]->begin(), tob1)
174  << " x " << distance( input[0]->begin(), tob2)
175  << " phi1=" << (*tob1)->phi()
176  << " , phi2=" << (*tob2)->phi()
177  << ", DeltaPhi = " << deltaPhi << " -> ";
178  for(unsigned int i=0; i<numberOutputBits(); ++i) {
179  bool accept = false;
180  if( parType_t((*tob1)->Et()) <= std::min(p_MinET1[i],p_MinET2[i])) continue; // ET cut
181  if( parType_t((*tob2)->Et()) <= std::min(p_MinET1[i],p_MinET2[i])) continue; // ET cut
182  if( (parType_t((*tob1)->Et()) <= std::max(p_MinET1[i],p_MinET2[i])) && (parType_t((*tob2)->Et()) <= std::max(p_MinET1[i],p_MinET2[i]))) continue;
183  accept = deltaPhi >= p_DeltaPhiMin[i] && deltaPhi <= p_DeltaPhiMax[i];
184  const bool fillAccept = fillHistos() and (fillHistosBasedOnHardware() ? getDecisionHardwareBit(i) : accept);
185  const bool fillReject = fillHistos() and not fillAccept;
186  const bool alreadyFilled = decision.bit(i);
187  if( accept ) {
188  decision.setBit(i, true);
189  output[i]->push_back( TCS::CompositeTOB(*tob1, *tob2) );
190  }
191  if(fillAccept and not alreadyFilled) {
192  fillHist1D(m_histAccept[i],deltaPhi);
193  } else if(fillReject) {
194  fillHist1D(m_histReject[i],deltaPhi);
195  }
196  TRG_MSG_DEBUG("DeltaPhiIncl1 = " << deltaPhi << " -> "
197  << (accept?"pass":"fail"));
198  }
199  }
200  }
201  } else {
202  TCS_EXCEPTION("DeltaPhiIncl1 alg must have 1 input, but got " << input.size());
203  }
205 }
TCS::DeltaPhiIncl1::processBitCorrect
virtual StatusCode processBitCorrect(const std::vector< TCS::TOBArray const * > &input, const std::vector< TCS::TOBArray * > &output, Decision &decison)
Definition: DeltaPhiIncl1.cxx:87
TCS::StatusCode::SUCCESS
@ SUCCESS
Definition: Trigger/TrigT1/L1Topo/L1TopoCommon/L1TopoCommon/StatusCode.h:17
max
#define max(a, b)
Definition: cfImp.cxx:41
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
TCS::DeltaPhiIncl1::process
virtual StatusCode process(const std::vector< TCS::TOBArray const * > &input, const std::vector< TCS::TOBArray * > &output, Decision &decison)
Definition: DeltaPhiIncl1.cxx:146
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
athena.value
value
Definition: athena.py:122
Decision.h
const
bool const RAWDATA *ch2 const
Definition: LArRodBlockPhysicsV0.cxx:562
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
lumiFormat.i
int i
Definition: lumiFormat.py:92
TCS::CompositeTOB
Definition: CompositeTOB.h:16
TCS::DeltaPhiIncl1::initialize
virtual StatusCode initialize()
Definition: DeltaPhiIncl1.cxx:44
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
TRG_MSG_INFO
#define TRG_MSG_INFO(x)
Definition: Trigger/TrigConfiguration/TrigConfBase/TrigConfBase/MsgStreamMacros.h:27
min
#define min(a, b)
Definition: cfImp.cxx:40
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
DeltaPhiIncl1.h
TCS::DeltaPhiIncl1
Definition: DeltaPhiIncl1.h:16
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::DeltaPhiIncl1::~DeltaPhiIncl1
virtual ~DeltaPhiIncl1()
Definition: DeltaPhiIncl1.cxx:40
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