ATLAS Offline Software
Loading...
Searching...
No Matches
RatioMatch.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 * RatioMatch.cpp
6 * Created by Joerg Stelzer on 11/16/12.
7 *
8 * @brief algorithm calculates the phi-distance between one or two lists and applies delta-phi criteria
9 *
10 * @param NumberLeading
11**********************************/
12
13#include <cmath>
14
19
20REGISTER_ALG_TCS(RatioMatch)
21
22
23// not the best solution but we will move to athena where this comes for free
24#define LOG std::cout << name() << ": "
25
26/* NOT USED
27namespace {
28 unsigned int
29 calcDeltaR2(const TCS::GenericTOB* tob1, const TCS::GenericTOB* tob2) {
30 double deta = ( tob1->etaDouble() - tob2->etaDouble() );
31 double dphi = fabs( tob1->phiDouble() - tob2->phiDouble() );
32 if(dphi>M_PI)
33 dphi = 2*M_PI - dphi;
34
35 return round ( 100 * ((dphi)*(dphi) + (deta)*(deta) )) ;
36
37 }
38}
39*/
40
41
43{
44 defineParameter("InputWidth1", 9);
45 defineParameter("InputWidth2", 9);
46 defineParameter("MaxTob1", 0);
47 defineParameter("MaxTob2", 0);
48 defineParameter("NumResultBits", 2);
49 defineParameter("MinET1",0);
50 defineParameter("MinET2",0);
51 // FW version assumes clusters so no deltar, also no eta
52 //defineParameter("EtaMin",0);
53 //defineParameter("EtaMax",49);
54 //defineParameter("DeltaR",0);
55 defineParameter("Ratio",0,0);
56 defineParameter("Ratio",0,1);
58}
59
62
63
66 p_NumberLeading1 = parameter("InputWidth1").value();
67 p_NumberLeading2 = parameter("InputWidth2").value();
68 if(parameter("MaxTob1").value() > 0) p_NumberLeading1 = parameter("MaxTob1").value();
69 if(parameter("MaxTob2").value() > 0) p_NumberLeading2 = parameter("MaxTob2").value();
70
71 p_MinET1 = parameter("MinET1").value();
72 p_MinET2 = parameter("MinET2").value();
73// p_EtaMin = parameter("EtaMin").value();
74// p_EtaMax = parameter("EtaMax").value();
75// p_DeltaR = parameter("DeltaR").value();
76
77
78 TRG_MSG_INFO("Maxtob 1 : " << p_NumberLeading1);
79 TRG_MSG_INFO("Maxtob 2 : " << p_NumberLeading2);
80 TRG_MSG_INFO("MinET1 : " << p_MinET1);
81 TRG_MSG_INFO("MinET2 : " << p_MinET2);
82// TRG_MSG_INFO("EtaMin : " << p_EtaMin);
83// TRG_MSG_INFO("EtaMax : " << p_EtaMax);
84// TRG_MSG_INFO("DeltaR : " << p_DeltaR);
85
86 for(unsigned int i=0; i<numberOutputBits(); ++i) {
87 p_Ratio[i] = parameter("Ratio", i).value();
88 TRG_MSG_INFO("Ratio " << i << " : " << p_Ratio[i]);
89 }
90 TRG_MSG_INFO("number output : " << numberOutputBits());
92}
93
94
96TCS::RatioMatch::processBitCorrect( const std::vector<TCS::TOBArray const *> & input,
97 const std::vector<TCS::TOBArray *> & output,
98 Decision & decision )
99
100{
101 return process(input,output,decision);
102}
103
105TCS::RatioMatch::process( const std::vector<TCS::TOBArray const *> & input,
106 const std::vector<TCS::TOBArray *> & output,
107 Decision & decision )
108{
109
110 if(input.size()!=2) {
111 TCS_EXCEPTION("RatioMatch alg must have exactly 2 input lists, but got " << input.size());
112 }
113
114 bool hasAmbiguousTruncation = TSU::isAmbiguousTruncation(input[0], p_NumberLeading1, p_MinET1)
116 for(unsigned int i=0; i<numberOutputBits(); ++i) {
117 // minEt values are global, not per-result bit.
118 output[i]->setAmbiguityFlag(hasAmbiguousTruncation);
119 }
120
121 unsigned int deltaR2 = 999;
122
123 for( TOBArray::const_iterator tob1 = input[0]->begin();
124 tob1 != input[0]->end() && distance(input[0]->begin(), tob1) < p_NumberLeading1;
125 ++tob1)
126 {
127
128 if( parType_t((*tob1)->Et()) <= p_MinET1) continue; // ET cut
129 deltaR2 = 999;
130
131 for( TCS::TOBArray::const_iterator tob2 = input[1]->begin();
132 tob2 != input[1]->end() && distance(input[1]->begin(), tob2) < p_NumberLeading2;
133 ++tob2) {
134
135 if( parType_t((*tob2)->Et()) <= p_MinET2) continue; // ET cut
136 // if( parType_t(fabs((*tob2)->eta())) > p_EtaMax ) continue; // Eta cut
137 // if( parType_t(fabs((*tob2)->eta())) < p_EtaMin ) continue; // Eta cut
138
139 // test DeltaR2Min, DeltaR2Max
140 //deltaR2 = calcDeltaR2( *tob1, *tob2 );
141 // test Deltaeta, Deltaphi
142 //
143 if (((*tob1)->eta() != (*tob2)->eta()) || ((*tob1)->phi() != (*tob2)->phi()) ) continue; // EM does not matches TAU
144 //
145 //
146 for(unsigned int i=0; i<numberOutputBits(); ++i) {
147 bool accept = false;
148 accept = 10*parType_t((*tob1)->Et()) >= p_Ratio[i]*parType_t((*tob2)->Et());
149// accept = deltaR2 <= p_DeltaR && 10*parType_t((*tob1)->Et()) >= p_Ratio[i]*parType_t((*tob2)->Et());
150 if( accept ) {
151 decision.setBit(i, true);
152 output[i]->push_back(TCS::CompositeTOB(*tob1, *tob2));
153 }
154 TRG_MSG_DEBUG("Decision " << i << ": " << (accept?"pass":"fail") << " deltaR2 = " << deltaR2 );
155 }
156 }
157 }
159}
#define REGISTER_ALG_TCS(CLASS)
Definition AlgFactory.h:62
const Parameter & parameter(const std::string &parameterName) const
const std::string & name() const
void defineParameter(const std::string &name, TCS::parType_t value)
data_t::const_iterator const_iterator
void setNumberOutputBits(unsigned int numberOutputBits)
Definition DecisionAlg.h:40
DecisionAlg(const std::string &name)
Definition DecisionAlg.h:25
unsigned int numberOutputBits() const
Definition DecisionAlg.h:39
void setBit(unsigned int index, bool value)
Definition Decision.cxx:12
parType_t p_NumberLeading1
Definition RatioMatch.h:33
RatioMatch(const std::string &name)
virtual ~RatioMatch()
virtual StatusCode process(const std::vector< TCS::TOBArray const * > &input, const std::vector< TCS::TOBArray * > &output, Decision &decison)
virtual StatusCode initialize()
parType_t p_Ratio[2]
Definition RatioMatch.h:40
parType_t p_NumberLeading2
Definition RatioMatch.h:34
parType_t p_MinET2
Definition RatioMatch.h:36
parType_t p_MinET1
Definition RatioMatch.h:35
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
bool isAmbiguousTruncation(TCS::TOBArray const *tobs, size_t pos, unsigned minEt=0)