ATLAS Offline Software
Loading...
Searching...
No Matches
DeltaRApproxBoxCutIncl1.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 * DeltaRApproxBoxCutIncl1.cpp
6 * Created by Joerg Stelzer on 11/16/12.
7 * Modified by V Sorin
8 *
9 * @brief algorithm calculates the eta and phi-distance between one lists and applies box cut criteria
10 *
11 * @param NumberLeading
12**********************************/
13
14#include <cmath>
15
19
20REGISTER_ALG_TCS(DeltaRApproxBoxCutIncl1)
21
23{
24 defineParameter("InputWidth", 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);
41}
42
44
45
48 p_NumberLeading1 = parameter("InputWidth").value();
49 p_NumberLeading2 = parameter("InputWidth").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 TRG_MSG_INFO("NumberLeading1 : " << p_NumberLeading1); // note that the reading of generic parameters doesn't work yet
61 TRG_MSG_INFO("NumberLeading2 : " << p_NumberLeading2);
62 TRG_MSG_INFO("DeltaPhiMin0 : " << p_DeltaPhiMin[0]);
63 TRG_MSG_INFO("DeltaPhiMax0 : " << p_DeltaPhiMax[0]);
64 TRG_MSG_INFO("DeltaPhiMin1 : " << p_DeltaPhiMin[1]);
65 TRG_MSG_INFO("DeltaPhiMax1 : " << p_DeltaPhiMax[1]);
66 TRG_MSG_INFO("DeltaPhiMin2 : " << p_DeltaPhiMin[2]);
67 TRG_MSG_INFO("DeltaPhiMax2 : " << p_DeltaPhiMax[2]);
68 TRG_MSG_INFO("DeltaEtaMin0 : " << p_DeltaEtaMin[0]);
69 TRG_MSG_INFO("DeltaEtaMax0 : " << p_DeltaEtaMax[0]);
70 TRG_MSG_INFO("DeltaEtaMin1 : " << p_DeltaEtaMin[1]);
71 TRG_MSG_INFO("DeltaEtaMax1 : " << p_DeltaEtaMax[1]);
72 TRG_MSG_INFO("DeltaEtaMin2 : " << p_DeltaEtaMin[2]);
73 TRG_MSG_INFO("DeltaEtaMax2 : " << p_DeltaEtaMax[2]);
74 TRG_MSG_INFO("MinET1 : " << p_MinET1);
75 TRG_MSG_INFO("MinET2 : " << p_MinET2);
76 TRG_MSG_INFO("number output : " << numberOutputBits());
77
78 // book histograms
79 for(unsigned int i=0; i<numberOutputBits(); ++i) {
80 std::string hname_accept = "hDeltaRApproxBoxCutIncl1_accept_bit"+std::to_string((int)i);
81 std::string hname_reject = "hDeltaRApproxBoxCutIncl1_reject_bit"+std::to_string((int)i);
82 // deta vs dphi
83 bookHist(m_histAccept, hname_accept, "DETA vs DPHI", 100, p_DeltaEtaMin[i], p_DeltaEtaMax[i], 100, p_DeltaPhiMin[i], p_DeltaPhiMax[i]);
84 bookHist(m_histReject, hname_reject, "DETA vs DPHI", 100, p_DeltaEtaMin[i], p_DeltaEtaMax[i], 100, p_DeltaPhiMin[i], p_DeltaPhiMax[i]);
85 }
86
88}
89
90
92TCS::DeltaRApproxBoxCutIncl1::processBitCorrect( const std::vector<TCS::TOBArray const *> & input,
93 const std::vector<TCS::TOBArray *> & output,
94 Decision & decision )
95
96{
97 return process(input,output,decision);
98}
99
100
102TCS::DeltaRApproxBoxCutIncl1::process( const std::vector<TCS::TOBArray const *> & input,
103 const std::vector<TCS::TOBArray *> & output,
104 Decision & decision )
105{
106 if(input.size() == 1) {
107 TRG_MSG_DEBUG("input size : " << input[0]->size());
108 unsigned int nLeading = p_NumberLeading1;
109 for( TOBArray::const_iterator tob1 = input[0]->begin();
110 tob1 != input[0]->end() && distance( input[0]->begin(), tob1) < nLeading;
111 ++tob1)
112 {
113 if( parType_t((*tob1)->Et()) <= std::min(p_MinET1,p_MinET2)) continue; // ET cut
114 TCS::TOBArray::const_iterator tob2 = tob1; ++tob2;
115 for( ;
116 tob2 != input[0]->end() && distance( input[0]->begin(), tob2) < p_NumberLeading2;
117 ++tob2) {
118 if( parType_t((*tob2)->Et()) <= std::min(p_MinET1,p_MinET2)) continue; // ET cut
119 if( (parType_t((*tob1)->Et()) <= std::max(p_MinET1,p_MinET2)) && (parType_t((*tob2)->Et()) <= std::max(p_MinET1,p_MinET2))) continue;
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[0]->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 << "DeltaRApproxBoxCutIncl1 alg bit" << i << (accept?" pass":" fail") << "|";
149 }
150 TRG_MSG_DEBUG(msgss.str());
151 }
152 }
153 } else {
154 TCS_EXCEPTION("DeltaRApproxBoxCutIncl1 alg must have 1 input, but got " << input.size());
155 }
157}
#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)
unsigned int calcDeltaEta(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)
void fillHist2D(const std::string &histName, double x, double y)
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
DeltaRApproxBoxCutIncl1(const std::string &name)
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)
const std::string process
uint32_t parType_t
Definition Parameter.h:22
STL namespace.