ATLAS Offline Software
DeltaPhiIncl2.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  * DeltaPhiIncl2.cpp
6  * Created by Joerg Stelzer on 11/16/12.
7  * Modified by V Sorin
8  *
9  * @brief algorithm calculates the phi-distance between two lists and applies delta-phi criteria
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(DeltaPhiIncl2)
26 
27 using namespace std;
28 
30 {
31  defineParameter("InputWidth1", 8);
32  defineParameter("InputWidth2", 8);
33  defineParameter("MaxTob1", 0);
34  defineParameter("MaxTob2", 0);
35  defineParameter("NumResultBits", 2);
36  defineParameter("Delay1", 0);
37  defineParameter("Delay2", 0);
38  defineParameter("MinET1",0,0);
39  defineParameter("MinET2",0,0);
40  defineParameter("MinDeltaPhi", 0, 0);
41  defineParameter("MaxDeltaPhi", 31, 0);
42  defineParameter("MinET1",0,1);
43  defineParameter("MinET2",0,1);
44  defineParameter("MinDeltaPhi", 0, 1);
45  defineParameter("MaxDeltaPhi", 31, 1);
47 }
48 
50 
51 
54  p_NumberLeading1 = parameter("InputWidth1").value();
55  p_NumberLeading2 = parameter("InputWidth2").value();
56  if(parameter("MaxTob1").value() > 0) p_NumberLeading1 = parameter("MaxTob1").value();
57  if(parameter("MaxTob2").value() > 0) p_NumberLeading2 = parameter("MaxTob2").value();
58  for(unsigned int i=0; i<numberOutputBits(); ++i) {
59  p_DeltaPhiMin[i] = parameter("MinDeltaPhi", i).value();
60  p_DeltaPhiMax[i] = parameter("MaxDeltaPhi", i).value();
61  p_MinET1[i] = parameter("MinET1",i).value();
62  p_MinET2[i] = parameter("MinET2",i).value();
63 
64  TRG_MSG_INFO("DeltaPhiMin : " << p_DeltaPhiMin[i]);
65  TRG_MSG_INFO("DeltaPhiMax : " << p_DeltaPhiMax[i]);
66  TRG_MSG_INFO("MinET1 : " << p_MinET1[i]);
67  TRG_MSG_INFO("MinET2 : " << p_MinET2[i]);
68 
69  }
70 
71  TRG_MSG_INFO("NumberLeading1 : " << p_NumberLeading1); // note that the reading of generic parameters doesn't work yet
72  TRG_MSG_INFO("NumberLeading2 : " << p_NumberLeading2);
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 = "hDeltaPhiIncl2_accept_bit"+std::to_string((int)i);
78  std::string hname_reject = "hDeltaPhiIncl2_reject_bit"+std::to_string((int)i);
79  // mass
80  bookHist(m_histAccept, hname_accept, "DPHI", 100, p_DeltaPhiMin[i], p_DeltaPhiMax[i]);
81  bookHist(m_histReject, hname_reject, "DPHI", 100, p_DeltaPhiMin[i], p_DeltaPhiMax[i]);
82  }
83 
84 
85  return StatusCode::SUCCESS;
86 }
87 
88 
89 
91 TCS::DeltaPhiIncl2::processBitCorrect( const std::vector<TCS::TOBArray const *> & input,
92  const std::vector<TCS::TOBArray *> & output,
93  Decision & decision )
94 {
95  if( input.size() == 2) {
96  std::vector<bool> iaccept (numberOutputBits());
97  for( TOBArray::const_iterator tob1 = input[0]->begin();
98  tob1 != input[0]->end() && distance(input[0]->begin(), tob1) < p_NumberLeading1;
99  ++tob1)
100  {
101  for( TCS::TOBArray::const_iterator tob2 = input[1]->begin();
102  tob2 != input[1]->end() && distance(input[1]->begin(), tob2) < p_NumberLeading2;
103  ++tob2) {
104  // test DeltaPhiMin, DeltaPhiMax
105  unsigned int deltaPhi = calcDeltaPhiBW( *tob1, *tob2 );
106  for(unsigned int i=0; i<numberOutputBits(); ++i) {
107  bool accept = false;
108  if( parType_t((*tob1)->Et()) <= p_MinET1[i]) continue; // ET cut
109  if( parType_t((*tob2)->Et()) <= p_MinET2[i]) continue; // ET cut
110  accept = deltaPhi >= p_DeltaPhiMin[i] && deltaPhi <= p_DeltaPhiMax[i];
111  const bool fillAccept = fillHistos() and (fillHistosBasedOnHardware() ? getDecisionHardwareBit(i) : accept);
112  const bool fillReject = fillHistos() and not fillAccept;
113  const bool alreadyFilled = decision.bit(i);
114  if( accept ) {
115  decision.setBit(i, true);
116  output[i]->push_back(TCS::CompositeTOB(*tob1, *tob2));
117  }
118  if(fillAccept and not alreadyFilled) {
119  fillHist1D(m_histAccept[i],deltaPhi);
120  } else if(fillReject) {
121  fillHist1D(m_histReject[i],deltaPhi);
122  }
123  TRG_MSG_DEBUG("DeltaPhiIncl2 = " << deltaPhi << " -> "
124  << (accept?"pass":"fail"));
125  }
126  }
127  }
128  for (unsigned int i=0; i < numberOutputBits(); ++i) {
129  bool hasAmbiguousInputs = TSU::isAmbiguousTruncation(input[0], p_NumberLeading1, p_MinET1[i])
130  || TSU::isAmbiguousTruncation(input[1], p_NumberLeading2, p_MinET2[i]);
131  output[i]->setAmbiguityFlag(hasAmbiguousInputs);
132  }
133  } else {
134  TCS_EXCEPTION("DeltaPhiIncl2 alg must have 2 inputs, but got " << input.size());
135  }
137 }
138 
139 
141 TCS::DeltaPhiIncl2::process( const std::vector<TCS::TOBArray const *> & input,
142  const std::vector<TCS::TOBArray *> & output,
143  Decision & decision )
144 {
145  if( input.size() == 2) {
146  std::vector<bool> iaccept (numberOutputBits());
147  for( TOBArray::const_iterator tob1 = input[0]->begin();
148  tob1 != input[0]->end() && distance(input[0]->begin(), tob1) < p_NumberLeading1;
149  ++tob1)
150  {
151  for( TCS::TOBArray::const_iterator tob2 = input[1]->begin();
152  tob2 != input[1]->end() && distance(input[1]->begin(), tob2) < p_NumberLeading2;
153  ++tob2) {
154  // test DeltaPhiMin, DeltaPhiMax
155  unsigned int deltaPhi = calcDeltaPhi( *tob1, *tob2 );
156  for(unsigned int i=0; i<numberOutputBits(); ++i) {
157  bool accept = false;
158  if( parType_t((*tob1)->Et()) <= p_MinET1[i]) continue; // ET cut
159  if( parType_t((*tob2)->Et()) <= p_MinET2[i]) continue; // ET cut
160  accept = deltaPhi >= p_DeltaPhiMin[i] && deltaPhi <= p_DeltaPhiMax[i];
161  const bool fillAccept = fillHistos() and (fillHistosBasedOnHardware() ? getDecisionHardwareBit(i) : accept);
162  const bool fillReject = fillHistos() and not fillAccept;
163  const bool alreadyFilled = decision.bit(i);
164  if( accept ) {
165  decision.setBit(i, true);
166  output[i]->push_back(TCS::CompositeTOB(*tob1, *tob2));
167  }
168  if(fillAccept and not alreadyFilled) {
169  fillHist1D(m_histAccept[i],deltaPhi);
170  } else if(fillReject) {
171  fillHist1D(m_histReject[i],deltaPhi);
172  }
173  TRG_MSG_DEBUG("DeltaPhiIncl2 = " << deltaPhi << " -> "
174  << (accept?"pass":"fail"));
175  }
176  }
177  }
178  } else {
179  TCS_EXCEPTION("DeltaPhiIncl2 alg must have 2 inputs, but got " << input.size());
180  }
182 }
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
xAOD::deltaPhi
setSAddress setEtaMS setDirPhiMS setDirZMS setBarrelRadius setEndcapAlpha setEndcapRadius setInterceptInner setEtaMap setEtaBin setIsTgcFailure setDeltaPt deltaPhi
Definition: L2StandAloneMuon_v1.cxx:161
CutsMETMaker::accept
StatusCode accept(const xAOD::Muon *mu)
Definition: CutsMETMaker.cxx:18
TSU::isAmbiguousTruncation
bool isAmbiguousTruncation(TCS::TOBArray const *tobs, size_t pos, unsigned minEt=0)
Definition: Trigger/TrigT1/L1Topo/L1TopoSimulationUtils/Root/Helpers.cxx:23
PlotCalibFromCool.begin
begin
Definition: PlotCalibFromCool.py:94
athena.value
value
Definition: athena.py:124
Decision.h
TCS::DeltaPhiIncl2::~DeltaPhiIncl2
virtual ~DeltaPhiIncl2()
Definition: DeltaPhiIncl2.cxx:49
TCS::DecisionAlg
Definition: Trigger/TrigT1/L1Topo/L1TopoInterfaces/L1TopoInterfaces/DecisionAlg.h:22
TCS::DeltaPhiIncl2::DeltaPhiIncl2
DeltaPhiIncl2(const std::string &name)
Definition: DeltaPhiIncl2.cxx:29
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::DeltaPhiIncl2::processBitCorrect
virtual StatusCode processBitCorrect(const std::vector< TCS::TOBArray const * > &input, const std::vector< TCS::TOBArray * > &output, Decision &decison)
Definition: DeltaPhiIncl2.cxx:91
TCS::ConfigurableAlg::defineParameter
void defineParameter(const std::string &name, TCS::parType_t value)
Definition: ConfigurableAlg.cxx:201
TCS::CompositeTOB
Definition: CompositeTOB.h:16
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
REGISTER_ALG_TCS
#define REGISTER_ALG_TCS(CLASS)
Definition: AlgFactory.h:62
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:240
ActsTrk::to_string
std::string to_string(const DetectorType &type)
Definition: GeometryDefs.h:34
TCS::DeltaPhiIncl2::initialize
virtual StatusCode initialize()
Definition: DeltaPhiIncl2.cxx:53
TCS::Decision::bit
bool bit(unsigned int index) const
Definition: L1Topo/L1TopoInterfaces/L1TopoInterfaces/Decision.h:40
TCS::DecisionAlg::setNumberOutputBits
void setNumberOutputBits(unsigned int numberOutputBits)
Definition: Trigger/TrigT1/L1Topo/L1TopoInterfaces/L1TopoInterfaces/DecisionAlg.h:40
Helpers.h
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
DeltaPhiIncl2.h
TCS::DeltaPhiIncl2::process
virtual StatusCode process(const std::vector< TCS::TOBArray const * > &input, const std::vector< TCS::TOBArray * > &output, Decision &decison)
Definition: DeltaPhiIncl2.cxx:141