ATLAS Offline Software
Loading...
Searching...
No Matches
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
24
25REGISTER_ALG_TCS(DeltaPhiIncl2)
26
27using 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
86}
87
88
89
91TCS::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) {
120 } else if(fillReject) {
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])
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
141TCS::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) {
170 } else if(fillReject) {
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}
#define REGISTER_ALG_TCS(CLASS)
Definition AlgFactory.h:62
Scalar deltaPhi(const MatrixBase< Derived > &vec) const
const Parameter & parameter(const std::string &parameterName) const
const std::string & name() const
void bookHist(std::vector< std::string > &regName, const std::string &name, const std::string &title, const int binx, const int xmin, const int xmax)
void fillHist1D(const std::string &histName, double x)
unsigned int calcDeltaPhiBW(const TCS::GenericTOB *tob1, const TCS::GenericTOB *tob2)
void defineParameter(const std::string &name, TCS::parType_t value)
unsigned int calcDeltaPhi(const TCS::GenericTOB *tob1, const TCS::GenericTOB *tob2)
data_t::const_iterator const_iterator
void setNumberOutputBits(unsigned int numberOutputBits)
Definition DecisionAlg.h:40
DecisionAlg(const std::string &name)
Definition DecisionAlg.h:25
bool fillHistosBasedOnHardware() const
! getter
bool fillHistos() const
whether the monitoring histograms should be filled
std::vector< std::string > m_histAccept
Definition DecisionAlg.h:73
std::vector< std::string > m_histReject
Definition DecisionAlg.h:74
unsigned int numberOutputBits() const
Definition DecisionAlg.h:39
bool getDecisionHardwareBit(const unsigned int &bitNumber) const
! get one hardware decision bit from this algo
bool bit(unsigned int index) const
Definition Decision.h:40
void setBit(unsigned int index, bool value)
Definition Decision.cxx:12
parType_t p_NumberLeading2
virtual StatusCode process(const std::vector< TCS::TOBArray const * > &input, const std::vector< TCS::TOBArray * > &output, Decision &decison)
virtual StatusCode processBitCorrect(const std::vector< TCS::TOBArray const * > &input, const std::vector< TCS::TOBArray * > &output, Decision &decison)
virtual StatusCode initialize()
parType_t p_DeltaPhiMax[2]
parType_t p_MinET1[2]
DeltaPhiIncl2(const std::string &name)
parType_t p_NumberLeading1
parType_t p_DeltaPhiMin[2]
parType_t p_MinET2[2]
uint32_t parType_t
Definition Parameter.h:22
bool isAmbiguousTruncation(TCS::TOBArray const *tobs, size_t pos, unsigned minEt=0)
STL namespace.