28#include "CLHEP/Random/RandomEngine.h"
29#include "CLHEP/Random/RandFlat.h"
56 ATH_MSG_INFO(
"L1Calo TriggerTowerThinningAlg::initialize()");
63 return StatusCode::SUCCESS;
69 std::vector<bool> mask;
72 unsigned long nKeep(0),nReject(0),nTotal(0);
78 mask.assign(tts->size(),
false);
88 bool globalSaveMe(
false);
91 if(globalSaveMe ==
false){
93 wrapper->
setSeed (this->name(), ctx);
94 CLHEP::HepRandomEngine* engine = wrapper->
getEngine (ctx);
95 if (CLHEP::RandFlat::shoot (engine) <
m_minRandom) {
103 bool isDecorAvailable = caloCellETByLayerHandle.
isAvailable();
109 if(globalSaveMe ==
true){saveMe =
true;}
113 if (isDecorAvailable) {
114 const std::vector<float>& caloCellETByLayer = caloCellETByLayerHandle(*tt);
116 float totalCaloCellET(0.);
117 for (
float c : caloCellETByLayer) {
118 totalCaloCellET += c;
128 if (saveMe ==
false) {
129 const std::vector<uint16_t>& ttADC = tt->adc();
130 for (uint16_t i : ttADC) {
139 mask[nTotal] = saveMe;
153 ATH_MSG_DEBUG(
" L1Calo Trigger Tower Thinning statistics: keeping " << nKeep <<
" cells"
154 <<
" and rejecting " << nReject <<
" cells");
157 return StatusCode::SUCCESS;
163 "==> finalize " << name() <<
"...\n"
164 <<
"***************************************************************\n"
165 <<
"Results of " << name() <<
" thinning algorithm:\n"
171 " Average percent of Trigger Towers kept = "
176 " Percentage of events where all Trigger Towers were kept (should be approx "<< 100.0*
m_minRandom <<
") = "
181 return StatusCode::SUCCESS;
#define ATH_CHECK
Evaluate an expression and check for errors.
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.
void setSeed(const std::string &algName, const EventContext &ctx)
Set the random seed using a string (e.g.
CLHEP::HepRandomEngine * getEngine(const EventContext &ctx) const
Retrieve the random engine corresponding to the provided EventContext.
std::atomic< unsigned long > m_nEventsAllTriggerTowersKeptByRandom
SG::ReadDecorHandleKey< xAOD::TriggerTowerContainer > m_caloCellETByLayerKey
StringProperty m_streamName
ServiceHandle< IAthRNGSvc > m_rndmSvc
TriggerTowerThinningAlg(const std::string &t, const std::string &n, const IInterface *p)
virtual StatusCode initialize() override
std::atomic< unsigned long > m_nEventsProcessed
std::atomic< unsigned long > m_nTriggerTowersRejected
virtual ~TriggerTowerThinningAlg()
std::atomic< unsigned long > m_nTriggerTowersKept
SG::ThinningHandleKey< xAOD::TriggerTowerContainer > m_triggerTowerLocation
virtual StatusCode doThinning(const EventContext &ctx) const override
std::atomic< unsigned long > m_nTriggerTowersProcessed
virtual StatusCode finalize() 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.