ATLAS Offline Software
L1Topo/L1TopoAlgorithms/Root/SimpleCone.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  * SimpleCone.cpp
6  *
7  * @brief algorithm calculates the sum of jets ET around each jet within radius R, makes cut on leading sum ET
8  *
9  * @param NumberLeading
10 **********************************/
11 
12 #include <cmath>
13 #include <string>
14 #include <iostream>
15 #include <sstream>
16 #include <vector>
17 #include <algorithm>
18 
20 #include "L1TopoCommon/Exception.h"
22 
23 
24 REGISTER_ALG_TCS(SimpleCone)
25 
26 // not the best solution but we will move to athena where this comes for free
27 #define LOG std::cout << name() << ": "
28 
29 
31 {
32  defineParameter("InputWidth", 0);
33  defineParameter("MaxTob", 0);
34  defineParameter("NumResultBits",6);
35  defineParameter("NumRegisters", 2);
36  defineParameter("MaxRSqr",10*10);
37  defineParameter("MinET",0);
38  defineParameter("MinSumET",0,0);
39  defineParameter("MinSumET",0,1);
40  defineParameter("MinSumET",0,2);
41  defineParameter("MinSumET",0,3);
42  defineParameter("MinSumET",0,4);
43  defineParameter("MinSumET",0,5);
45 }
46 
48 {}
49 
50 
53  p_NumberLeading1 = parameter("InputWidth").value();
54  if(parameter("MaxTob").value() > 0) p_NumberLeading1 = parameter("MaxTob").value();
55  p_R2 = parameter("MaxRSqr").value();
56  p_MinET = parameter("MinET").value();
57 
58  TRG_MSG_INFO("MaxTob : " << p_NumberLeading1);
59  TRG_MSG_INFO("MaxRSqr : " << p_R2);
60  TRG_MSG_INFO("MinET : " << p_MinET);
61  for(unsigned int i=0; i<numberOutputBits(); ++i) {
62  p_MinSumET[i] = parameter("MinSumET", i).value();
63  TRG_MSG_INFO("SimpleCone " << i << " : " << p_MinSumET[i]);
64  }
65  TRG_MSG_INFO("number output : " << numberOutputBits());
66 
67  // book histograms
68  for(unsigned int i=0; i<numberOutputBits(); ++i) {
69  std::string hname_accept = "hSimpleCone_accept_bit"+std::to_string((int)i);
70  std::string hname_reject = "hSimpleCone_reject_bit"+std::to_string((int)i);
71  // mass
72  bookHist(m_histAccept, hname_accept, "ET", 100, 0, p_MinSumET[i]);
73  bookHist(m_histReject, hname_reject, "ET", 100, 0, p_MinSumET[i]);
74  }
75 
76  return StatusCode::SUCCESS;
77 }
78 
80 TCS::SimpleCone::processBitCorrect( const std::vector<TCS::TOBArray const *> & input,
81  const std::vector<TCS::TOBArray *> & output,
82  Decision & decision )
83 
84 {
85  return process(input,output,decision);
86 }
87 
88 
90 TCS::SimpleCone::process( const std::vector<TCS::TOBArray const *> & input,
91  const std::vector<TCS::TOBArray *> & output,
92  Decision & decision )
93 {
94 
95  if(input.size()!=1) {
96  TCS_EXCEPTION("SimpleCone alg must have exactly 1 input list, but got " << input.size());
97  }
98 
99  unsigned int leadingET = 0;
100 
101  // loop over jets
102  for( TOBArray::const_iterator tob = input[0]->begin();
103  tob != input[0]->end() && distance(input[0]->begin(), tob) < p_NumberLeading1;
104  ++tob) {
105 
106  if( parType_t((*tob)->Et()) <= p_MinET ) continue; // E_T cut
107 
108  TRG_MSG_DEBUG("Jet : ET = " << (*tob)->Et());
109 
110  unsigned int tmp_SumET = (*tob)->Et();
111 
112  for( TOBArray::const_iterator tob1 = input[0]->begin();
113  tob1 != input[0]->end() && distance(input[0]->begin(), tob1) < p_NumberLeading1;
114  ++tob1) {
115 
116  if( tob1 == tob ) continue; // Avoid double counting of central jet
117  if( parType_t((*tob1)->Et()) <= p_MinET ) continue; // E_T cut
118 
119  unsigned int deltaR2 = calcDeltaR2BW( *tob1, *tob );
120 
121  if (deltaR2 > p_R2) continue; // Exclude jets outside cone
122 
123  tmp_SumET += (*tob1)->Et();
124  }
125 
126  if (tmp_SumET > leadingET) leadingET = tmp_SumET;
127  }
128 
129  for(unsigned int i=0; i<numberOutputBits(); ++i) {
130 
131  bool accept = leadingET > p_MinSumET[i];
132  const bool fillAccept = fillHistos() and (fillHistosBasedOnHardware() ? getDecisionHardwareBit(i) : accept);
133  const bool fillReject = fillHistos() and not fillAccept;
134  decision.setBit( i, accept );
135 
136  if(accept) {
137  output[i]->push_back( CompositeTOB( GenericTOB::createOnHeap( GenericTOB(leadingET,0,0) ) ));
138  }
139  if(fillAccept)
140  fillHist1D(m_histAccept[i],leadingET);
141  else if(fillReject)
142  fillHist1D(m_histReject[i],leadingET);
143 
144 
145  TRG_MSG_DEBUG("Decision " << i << ": " << (accept?"pass":"fail") << " SimpleCone = " << leadingET);
146 
147  }
148 
150 }
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::SimpleCone::~SimpleCone
virtual ~SimpleCone()
Definition: L1Topo/L1TopoAlgorithms/Root/SimpleCone.cxx:47
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
SUSY_SimplifiedModel_PostInclude.process
string process
Definition: SUSY_SimplifiedModel_PostInclude.py:42
TCS::DecisionAlg
Definition: Trigger/TrigT1/L1Topo/L1TopoInterfaces/L1TopoInterfaces/DecisionAlg.h:22
TCS::SimpleCone::SimpleCone
SimpleCone(const std::string &name)
Definition: L1Topo/L1TopoAlgorithms/Root/SimpleCone.cxx:30
TCS::GenericTOB::createOnHeap
static GenericTOB * createOnHeap(const GenericTOB &)
Definition: GenericTOB.cxx:264
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
SimpleCone.h
TRG_MSG_INFO
#define TRG_MSG_INFO(x)
Definition: Trigger/TrigConfiguration/TrigConfBase/TrigConfBase/MsgStreamMacros.h:27
merge.output
output
Definition: merge.py:17
TCS::GenericTOB
Definition: GenericTOB.h:35
REGISTER_ALG_TCS
#define REGISTER_ALG_TCS(CLASS)
Definition: AlgFactory.h:62
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
ActsTrk::to_string
std::string to_string(const DetectorType &type)
Definition: GeometryDefs.h:34
TCS::SimpleCone::process
virtual StatusCode process(const std::vector< TCS::TOBArray const * > &input, const std::vector< TCS::TOBArray * > &output, Decision &decison)
Definition: L1Topo/L1TopoAlgorithms/Root/SimpleCone.cxx:90
TCS::SimpleCone::initialize
virtual StatusCode initialize()
Definition: L1Topo/L1TopoAlgorithms/Root/SimpleCone.cxx:52
TCS::SimpleCone::processBitCorrect
virtual StatusCode processBitCorrect(const std::vector< TCS::TOBArray const * > &input, const std::vector< TCS::TOBArray * > &output, Decision &decison)
Definition: L1Topo/L1TopoAlgorithms/Root/SimpleCone.cxx:80
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