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"
23 
24 REGISTER_ALG_TCS(DeltaPhiIncl2)
25 
26 using namespace std;
27 
29 {
30  defineParameter("InputWidth1", 8);
31  defineParameter("InputWidth2", 8);
32  defineParameter("MaxTob1", 0);
33  defineParameter("MaxTob2", 0);
34  defineParameter("NumResultBits", 2);
35  defineParameter("Delay1", 0);
36  defineParameter("Delay2", 0);
37  defineParameter("MinET1",0,0);
38  defineParameter("MinET2",0,0);
39  defineParameter("MinDeltaPhi", 0, 0);
40  defineParameter("MaxDeltaPhi", 31, 0);
41  defineParameter("MinET1",0,1);
42  defineParameter("MinET2",0,1);
43  defineParameter("MinDeltaPhi", 0, 1);
44  defineParameter("MaxDeltaPhi", 31, 1);
46 }
47 
49 
50 
53  p_NumberLeading1 = parameter("InputWidth1").value();
54  p_NumberLeading2 = parameter("InputWidth2").value();
55  if(parameter("MaxTob1").value() > 0) p_NumberLeading1 = parameter("MaxTob1").value();
56  if(parameter("MaxTob2").value() > 0) p_NumberLeading2 = parameter("MaxTob2").value();
57  for(unsigned int i=0; i<numberOutputBits(); ++i) {
58  p_DeltaPhiMin[i] = parameter("MinDeltaPhi", i).value();
59  p_DeltaPhiMax[i] = parameter("MaxDeltaPhi", i).value();
60  p_MinET1[i] = parameter("MinET1",i).value();
61  p_MinET2[i] = parameter("MinET2",i).value();
62 
63  TRG_MSG_INFO("DeltaPhiMin : " << p_DeltaPhiMin[i]);
64  TRG_MSG_INFO("DeltaPhiMax : " << p_DeltaPhiMax[i]);
65  TRG_MSG_INFO("MinET1 : " << p_MinET1[i]);
66  TRG_MSG_INFO("MinET2 : " << p_MinET2[i]);
67 
68  }
69 
70  TRG_MSG_INFO("NumberLeading1 : " << p_NumberLeading1); // note that the reading of generic parameters doesn't work yet
71  TRG_MSG_INFO("NumberLeading2 : " << p_NumberLeading2);
72  TRG_MSG_INFO("number output : " << numberOutputBits());
73 
74  // book histograms
75  for(unsigned int i=0; i<numberOutputBits(); ++i) {
76  std::string hname_accept = "hDeltaPhiIncl2_accept_bit"+std::to_string((int)i);
77  std::string hname_reject = "hDeltaPhiIncl2_reject_bit"+std::to_string((int)i);
78  // mass
79  bookHist(m_histAccept, hname_accept, "DPHI", 100, p_DeltaPhiMin[i], p_DeltaPhiMax[i]);
80  bookHist(m_histReject, hname_reject, "DPHI", 100, p_DeltaPhiMin[i], p_DeltaPhiMax[i]);
81  }
82 
83 
84  return StatusCode::SUCCESS;
85 }
86 
87 
88 
90 TCS::DeltaPhiIncl2::processBitCorrect( const std::vector<TCS::TOBArray const *> & input,
91  const std::vector<TCS::TOBArray *> & output,
92  Decision & decision )
93 {
94  if( input.size() == 2) {
95  std::vector<bool> iaccept (numberOutputBits());
96  for( TOBArray::const_iterator tob1 = input[0]->begin();
97  tob1 != input[0]->end() && distance(input[0]->begin(), tob1) < p_NumberLeading1;
98  ++tob1)
99  {
100  for( TCS::TOBArray::const_iterator tob2 = input[1]->begin();
101  tob2 != input[1]->end() && distance(input[1]->begin(), tob2) < p_NumberLeading2;
102  ++tob2) {
103  // test DeltaPhiMin, DeltaPhiMax
104  unsigned int deltaPhi = calcDeltaPhiBW( *tob1, *tob2 );
105  for(unsigned int i=0; i<numberOutputBits(); ++i) {
106  bool accept = false;
107  if( parType_t((*tob1)->Et()) <= p_MinET1[i]) continue; // ET cut
108  if( parType_t((*tob2)->Et()) <= p_MinET2[i]) continue; // ET cut
109  accept = deltaPhi >= p_DeltaPhiMin[i] && deltaPhi <= p_DeltaPhiMax[i];
110  const bool fillAccept = fillHistos() and (fillHistosBasedOnHardware() ? getDecisionHardwareBit(i) : accept);
111  const bool fillReject = fillHistos() and not fillAccept;
112  const bool alreadyFilled = decision.bit(i);
113  if( accept ) {
114  decision.setBit(i, true);
115  output[i]->push_back(TCS::CompositeTOB(*tob1, *tob2));
116  }
117  if(fillAccept and not alreadyFilled) {
118  fillHist1D(m_histAccept[i],deltaPhi);
119  } else if(fillReject) {
120  fillHist1D(m_histReject[i],deltaPhi);
121  }
122  TRG_MSG_DEBUG("DeltaPhiIncl2 = " << deltaPhi << " -> "
123  << (accept?"pass":"fail"));
124  }
125  }
126  }
127  } else {
128  TCS_EXCEPTION("DeltaPhiIncl2 alg must have 2 inputs, but got " << input.size());
129  }
131 }
132 
133 
135 TCS::DeltaPhiIncl2::process( const std::vector<TCS::TOBArray const *> & input,
136  const std::vector<TCS::TOBArray *> & output,
137  Decision & decision )
138 {
139  if( input.size() == 2) {
140  std::vector<bool> iaccept (numberOutputBits());
141  for( TOBArray::const_iterator tob1 = input[0]->begin();
142  tob1 != input[0]->end() && distance(input[0]->begin(), tob1) < p_NumberLeading1;
143  ++tob1)
144  {
145  for( TCS::TOBArray::const_iterator tob2 = input[1]->begin();
146  tob2 != input[1]->end() && distance(input[1]->begin(), tob2) < p_NumberLeading2;
147  ++tob2) {
148  // test DeltaPhiMin, DeltaPhiMax
149  unsigned int deltaPhi = calcDeltaPhi( *tob1, *tob2 );
150  for(unsigned int i=0; i<numberOutputBits(); ++i) {
151  bool accept = false;
152  if( parType_t((*tob1)->Et()) <= p_MinET1[i]) continue; // ET cut
153  if( parType_t((*tob2)->Et()) <= p_MinET2[i]) continue; // ET cut
154  accept = deltaPhi >= p_DeltaPhiMin[i] && deltaPhi <= p_DeltaPhiMax[i];
155  const bool fillAccept = fillHistos() and (fillHistosBasedOnHardware() ? getDecisionHardwareBit(i) : accept);
156  const bool fillReject = fillHistos() and not fillAccept;
157  const bool alreadyFilled = decision.bit(i);
158  if( accept ) {
159  decision.setBit(i, true);
160  output[i]->push_back(TCS::CompositeTOB(*tob1, *tob2));
161  }
162  if(fillAccept and not alreadyFilled) {
163  fillHist1D(m_histAccept[i],deltaPhi);
164  } else if(fillReject) {
165  fillHist1D(m_histReject[i],deltaPhi);
166  }
167  TRG_MSG_DEBUG("DeltaPhiIncl2 = " << deltaPhi << " -> "
168  << (accept?"pass":"fail"));
169  }
170  }
171  }
172  } else {
173  TCS_EXCEPTION("DeltaPhiIncl2 alg must have 2 inputs, but got " << input.size());
174  }
176 }
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: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:124
Decision.h
TCS::DeltaPhiIncl2::~DeltaPhiIncl2
virtual ~DeltaPhiIncl2()
Definition: DeltaPhiIncl2.cxx:48
TCS::DecisionAlg
Definition: Trigger/TrigT1/L1Topo/L1TopoInterfaces/L1TopoInterfaces/DecisionAlg.h:22
TCS::DeltaPhiIncl2::DeltaPhiIncl2
DeltaPhiIncl2(const std::string &name)
Definition: DeltaPhiIncl2.cxx:28
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:90
TCS::ConfigurableAlg::defineParameter
void defineParameter(const std::string &name, TCS::parType_t value)
Definition: ConfigurableAlg.cxx:201
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
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::DeltaPhiIncl2::initialize
virtual StatusCode initialize()
Definition: DeltaPhiIncl2.cxx:52
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
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:135