ATLAS Offline Software
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 
16 #include "L1TopoCommon/Exception.h"
18 
19 
20 REGISTER_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
27 namespace {
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 
61 {}
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());
91  return StatusCode::SUCCESS;
92 }
93 
94 
96 TCS::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 
105 TCS::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  unsigned int deltaR2 = 999;
115 
116  for( TOBArray::const_iterator tob1 = input[0]->begin();
117  tob1 != input[0]->end() && distance(input[0]->begin(), tob1) < p_NumberLeading1;
118  ++tob1)
119  {
120 
121  if( parType_t((*tob1)->Et()) <= p_MinET1) continue; // ET cut
122  deltaR2 = 999;
123 
124  for( TCS::TOBArray::const_iterator tob2 = input[1]->begin();
125  tob2 != input[1]->end() && distance(input[1]->begin(), tob2) < p_NumberLeading2;
126  ++tob2) {
127 
128  if( parType_t((*tob2)->Et()) <= p_MinET2) continue; // ET cut
129  // if( parType_t(fabs((*tob2)->eta())) > p_EtaMax ) continue; // Eta cut
130  // if( parType_t(fabs((*tob2)->eta())) < p_EtaMin ) continue; // Eta cut
131 
132  // test DeltaR2Min, DeltaR2Max
133  //deltaR2 = calcDeltaR2( *tob1, *tob2 );
134  // test Deltaeta, Deltaphi
135  //
136  if (((*tob1)->eta() != (*tob2)->eta()) || ((*tob1)->phi() != (*tob2)->phi()) ) continue; // EM does not matches TAU
137  //
138  //
139  for(unsigned int i=0; i<numberOutputBits(); ++i) {
140  bool accept = false;
141  accept = 10*parType_t((*tob1)->Et()) >= p_Ratio[i]*parType_t((*tob2)->Et());
142 // accept = deltaR2 <= p_DeltaR && 10*parType_t((*tob1)->Et()) >= p_Ratio[i]*parType_t((*tob2)->Et());
143  if( accept ) {
144  decision.setBit(i, true);
145  output[i]->push_back(TCS::CompositeTOB(*tob1, *tob2));
146  }
147  TRG_MSG_DEBUG("Decision " << i << ": " << (accept?"pass":"fail") << " deltaR2 = " << deltaR2 );
148  }
149  }
150  }
152 }
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
CutsMETMaker::accept
StatusCode accept(const xAOD::Muon *mu)
Definition: CutsMETMaker.cxx:18
TCS::RatioMatch::processBitCorrect
virtual StatusCode processBitCorrect(const std::vector< TCS::TOBArray const * > &input, const std::vector< TCS::TOBArray * > &output, Decision &decison)
Definition: RatioMatch.cxx:96
PlotCalibFromCool.begin
begin
Definition: PlotCalibFromCool.py:94
athena.value
value
Definition: athena.py:124
Decision.h
xAOD::P4Helpers::deltaR2
double deltaR2(double rapidity1, double phi1, double rapidity2, double phi2)
from bare rapidity,phi
Definition: xAODP4Helpers.h:111
RatioMatch.h
TCS::RatioMatch::initialize
virtual StatusCode initialize()
Definition: RatioMatch.cxx:65
SUSY_SimplifiedModel_PostInclude.process
string process
Definition: SUSY_SimplifiedModel_PostInclude.py:42
TCS::DecisionAlg
Definition: Trigger/TrigT1/L1Topo/L1TopoInterfaces/L1TopoInterfaces/DecisionAlg.h:22
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::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
TCS::RatioMatch::~RatioMatch
virtual ~RatioMatch()
Definition: RatioMatch.cxx:60
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
TCS::RatioMatch::process
virtual StatusCode process(const std::vector< TCS::TOBArray const * > &input, const std::vector< TCS::TOBArray * > &output, Decision &decison)
Definition: RatioMatch.cxx:105
TCS::RatioMatch::RatioMatch
RatioMatch(const std::string &name)
Definition: RatioMatch.cxx:42
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