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