ATLAS Offline Software
Loading...
Searching...
No Matches
TriggerTowerThinningAlg.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3*/
4// ***************************************************************************
5// * Author: John Morris (john.morris@cern.ch) *
6// * Queen Mary University of London *
7// * *
8
21
23// TrigT1 common definitions
28#include "CLHEP/Random/RandomEngine.h"
29#include "CLHEP/Random/RandFlat.h"
30
31namespace DerivationFramework {
32
33 TriggerTowerThinningAlg::TriggerTowerThinningAlg(const std::string& t, const std::string& n, const IInterface* p) :
34 base_class(t,n,p),
35 m_minCaloCellET(0.4),
36 m_minADC(32),
37 m_useRandom(false),
38 m_minRandom(0.03),
44 {
45 declareProperty("MinCaloCellET",m_minCaloCellET);
46 declareProperty("MinADC",m_minADC);
47 declareProperty("UseRandom",m_useRandom);
48 declareProperty("MinRandom",m_minRandom);
49 }
50
54
56 ATH_MSG_INFO("L1Calo TriggerTowerThinningAlg::initialize()");
57
60
61 ATH_CHECK( m_rndmSvc.retrieve() );
62
63 return StatusCode::SUCCESS;
64 }
65
66 StatusCode TriggerTowerThinningAlg::doThinning(const EventContext& ctx) const{
67
68 // Create the mask to be used for thinning
69 std::vector<bool> mask;
70
71 // Counters
72 unsigned long nKeep(0),nReject(0),nTotal(0);
74
77
78 mask.assign(tts->size(),false); // default: don't keep any clusters
79
80 // Should we save the trigger tower or not???
81 // If this is calibration data, then yes - save the lot
82 // Randomly save all trigger towers m_minRandom % of the time.
83 //
84 // If this is collisions data then only save if:
85 // 1.) Any ADC value is greater than m_minADC OR
86 // 2.) The CaloCell ET is greater than m_minCaloCellET
87
88 bool globalSaveMe(false);
89 // Random number save all
90 if(m_useRandom == true){
91 if(globalSaveMe == false){
92 ATHRNG::RNGWrapper* wrapper = m_rndmSvc->getEngine (this);
93 wrapper->setSeed (this->name(), ctx);
94 CLHEP::HepRandomEngine* engine = wrapper->getEngine (ctx);
95 if (CLHEP::RandFlat::shoot (engine) < m_minRandom) {
96 globalSaveMe = true;
98 }
99 }
100 }
101
103 bool isDecorAvailable = caloCellETByLayerHandle.isAvailable();
104
105 // Iterate over all trigger towers
106 for(auto tt : *tts){
107
108 bool saveMe(false);
109 if(globalSaveMe == true){saveMe = true;}
110
111 // Test for Calo ET
112 if(saveMe == false){
113 if (isDecorAvailable) {
114 const std::vector<float>& caloCellETByLayer = caloCellETByLayerHandle(*tt);
115
116 float totalCaloCellET(0.);
117 for (float c : caloCellETByLayer) {
118 totalCaloCellET += c;
119 }
120 if (totalCaloCellET > m_minCaloCellET) {
121 saveMe = true;
122 }
123 }
124 }
125
126
127 // Test for ADC values
128 if (saveMe == false) {
129 const std::vector<uint16_t>& ttADC = tt->adc();
130 for (uint16_t i : ttADC) {
131 if ( i > m_minADC) {
132 saveMe = true;
133 break;
134 }
135 }
136 }
137
138 // assign result to mask
139 mask[nTotal] = saveMe;
140
141 ++nTotal;
142 } // End loop over trigger towers
143
144
145 tts.keep (mask);
146
147 // Counters
149 // FIXME: nKeep is always 0
150 m_nTriggerTowersKept += nKeep;
151 m_nTriggerTowersRejected += nReject;
152
153 ATH_MSG_DEBUG(" L1Calo Trigger Tower Thinning statistics: keeping " << nKeep << " cells"
154 << " and rejecting " << nReject << " cells");
155
156
157 return StatusCode::SUCCESS;
158 }
159
161
163 "==> finalize " << name() << "...\n"
164 << "***************************************************************\n"
165 << "Results of " << name() << " thinning algorithm:\n"
166 << "-------------");
167 ATH_MSG_INFO(" Number of processed events: " << m_nEventsProcessed);
168
171 " Average percent of Trigger Towers kept = "
172 << 100.0 * m_nTriggerTowersKept / (double)m_nTriggerTowersProcessed << " %");
173 }
174 if(m_useRandom == true && m_nEventsProcessed > 0){
176 " Percentage of events where all Trigger Towers were kept (should be approx "<< 100.0*m_minRandom << ") = "
178 }
179
180
181 return StatusCode::SUCCESS;
182 }
183
184} // namespace
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_INFO(x)
#define ATH_MSG_DEBUG(x)
Handle class for reading a decoration on an object.
Handle for requesting thinning for a data object.
A wrapper class for event-slot-local random engines.
Definition RNGWrapper.h:56
void setSeed(const std::string &algName, const EventContext &ctx)
Set the random seed using a string (e.g.
Definition RNGWrapper.h:169
CLHEP::HepRandomEngine * getEngine(const EventContext &ctx) const
Retrieve the random engine corresponding to the provided EventContext.
Definition RNGWrapper.h:134
std::atomic< unsigned long > m_nEventsAllTriggerTowersKeptByRandom
SG::ReadDecorHandleKey< xAOD::TriggerTowerContainer > m_caloCellETByLayerKey
TriggerTowerThinningAlg(const std::string &t, const std::string &n, const IInterface *p)
SG::ThinningHandleKey< xAOD::TriggerTowerContainer > m_triggerTowerLocation
virtual StatusCode doThinning(const EventContext &ctx) const override
Handle class for reading a decoration on an object.
bool isAvailable()
Test to see if this variable exists in the store, for the referenced object.
void keep(size_t ndx)
Mark that index ndx in the container should be kept (not thinned away).
Handle for requesting thinning for a data object.
THE reconstruction tool.