ATLAS Offline Software
Loading...
Searching...
No Matches
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
22
23
24REGISTER_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
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
77}
78
80TCS::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
90TCS::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}
#define REGISTER_ALG_TCS(CLASS)
Definition AlgFactory.h:62
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)
void fillHist1D(const std::string &histName, double x)
unsigned int calcDeltaR2BW(const TCS::GenericTOB *tob1, const TCS::GenericTOB *tob2)
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
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
void setBit(unsigned int index, bool value)
Definition Decision.cxx:12
static GenericTOB * createOnHeap(const GenericTOB &)
SimpleCone(const std::string &name)
virtual ~SimpleCone()
parType_t p_MinSumET[6]
Definition SimpleCone.h:34
virtual StatusCode initialize()
parType_t p_NumberLeading1
Definition SimpleCone.h:31
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)
parType_t p_R2
Definition SimpleCone.h:32
parType_t p_MinET
Definition SimpleCone.h:33
const std::string process
uint32_t parType_t
Definition Parameter.h:22