ATLAS Offline Software
Public Member Functions | Private Attributes | List of all members
DerivationFramework::TriggerTowerThinningAlg Class Reference

#include <TriggerTowerThinningAlg.h>

Inheritance diagram for DerivationFramework::TriggerTowerThinningAlg:
Collaboration diagram for DerivationFramework::TriggerTowerThinningAlg:

Public Member Functions

 TriggerTowerThinningAlg (const std::string &t, const std::string &n, const IInterface *p)
 
virtual ~TriggerTowerThinningAlg ()
 
virtual StatusCode initialize () override
 
virtual StatusCode finalize () override
 
virtual StatusCode doThinning () const override
 

Private Attributes

StringProperty m_streamName { this, "StreamName", "", "Name of the stream being thinned" }
 
SG::ThinningHandleKey< xAOD::TriggerTowerContainerm_triggerTowerLocation { this, "TriggerTowerLocation", LVL1::TrigT1CaloDefs::xAODTriggerTowerLocation, "" }
 
SG::ReadDecorHandleKey< xAOD::TriggerTowerContainerm_caloCellETByLayerKey { this, "CaloCellETByLayerKey", m_triggerTowerLocation.key()+".CaloCellETByLayer", "" }
 
double m_minCaloCellET
 
int m_minADC
 
bool m_useRandom
 
double m_minRandom
 
std::atomic< unsigned long > m_nEventsProcessed
 
std::atomic< unsigned long > m_nEventsAllTriggerTowersKeptByRandom
 
std::atomic< unsigned long > m_nTriggerTowersProcessed
 
std::atomic< unsigned long > m_nTriggerTowersKept
 
std::atomic< unsigned long > m_nTriggerTowersRejected
 
ServiceHandle< IAthRNGSvcm_rndmSvc { this, "RndmSvc", "AthRNGSvc", "" }
 

Detailed Description

Definition at line 41 of file TriggerTowerThinningAlg.h.

Constructor & Destructor Documentation

◆ TriggerTowerThinningAlg()

TriggerTowerThinningAlg::TriggerTowerThinningAlg ( const std::string &  t,
const std::string &  n,
const IInterface *  p 
)

Definition at line 34 of file TriggerTowerThinningAlg.cxx.

34  :
35  base_class(t,n,p),
36  m_minCaloCellET(0.4),
37  m_minADC(32),
38  m_useRandom(false),
39  m_minRandom(0.03),
45  {
46  declareProperty("MinCaloCellET",m_minCaloCellET);
47  declareProperty("MinADC",m_minADC);
48  declareProperty("UseRandom",m_useRandom);
49  declareProperty("MinRandom",m_minRandom);
50  }

◆ ~TriggerTowerThinningAlg()

TriggerTowerThinningAlg::~TriggerTowerThinningAlg ( )
virtual

Definition at line 52 of file TriggerTowerThinningAlg.cxx.

53  {
54  }

Member Function Documentation

◆ doThinning()

StatusCode TriggerTowerThinningAlg::doThinning ( ) const
overridevirtual

Definition at line 67 of file TriggerTowerThinningAlg.cxx.

67  {
68  const EventContext& ctx = Gaudi::Hive::currentContext();
69 
70  // Create the mask to be used for thinning
71  std::vector<bool> mask;
72 
73  // Counters
74  unsigned long nKeep(0),nReject(0),nTotal(0);
76 
79 
80  mask.assign(tts->size(),false); // default: don't keep any clusters
81 
82  // Should we save the trigger tower or not???
83  // If this is calibration data, then yes - save the lot
84  // Randomly save all trigger towers m_minRandom % of the time.
85  //
86  // If this is collisions data then only save if:
87  // 1.) Any ADC value is greater than m_minADC OR
88  // 2.) The CaloCell ET is greater than m_minCaloCellET
89 
90  bool globalSaveMe(false);
91  // Random number save all
92  if(m_useRandom == true){
93  if(globalSaveMe == false){
94  ATHRNG::RNGWrapper* wrapper = m_rndmSvc->getEngine (this);
95  wrapper->setSeed (this->name(), ctx);
96  CLHEP::HepRandomEngine* engine = wrapper->getEngine (ctx);
97  if (CLHEP::RandFlat::shoot (engine) < m_minRandom) {
98  globalSaveMe = true;
100  }
101  }
102  }
103 
105  bool isDecorAvailable = caloCellETByLayerHandle.isAvailable();
106 
107  // Iterate over all trigger towers
108  for(auto tt : *tts){
109 
110  bool saveMe(false);
111  if(globalSaveMe == true){saveMe = true;}
112 
113  // Test for Calo ET
114  if(saveMe == false){
115  if (isDecorAvailable) {
116  const std::vector<float>& caloCellETByLayer = caloCellETByLayerHandle(*tt);
117 
118  float totalCaloCellET(0.);
119  for (float c : caloCellETByLayer) {
120  totalCaloCellET += c;
121  }
122  if (totalCaloCellET > m_minCaloCellET) {
123  saveMe = true;
124  }
125  }
126  }
127 
128 
129  // Test for ADC values
130  if (saveMe == false) {
131  const std::vector<uint16_t>& ttADC = tt->adc();
132  for (uint16_t i : ttADC) {
133  if ( i > m_minADC) {
134  saveMe = true;
135  break;
136  }
137  }
138  }
139 
140  // assign result to mask
141  mask[nTotal] = saveMe;
142 
143  ++nTotal;
144  } // End loop over trigger towers
145 
146 
147  tts.keep (mask);
148 
149  // Counters
150  m_nTriggerTowersProcessed += nTotal;
151  // FIXME: nKeep is always 0
152  m_nTriggerTowersKept += nKeep;
153  m_nTriggerTowersRejected += nReject;
154 
155  ATH_MSG_DEBUG(" L1Calo Trigger Tower Thinning statistics: keeping " << nKeep << " cells"
156  << " and rejecting " << nReject << " cells");
157 
158 
159  return StatusCode::SUCCESS;
160  }

◆ finalize()

StatusCode TriggerTowerThinningAlg::finalize ( )
overridevirtual

Definition at line 162 of file TriggerTowerThinningAlg.cxx.

162  {
163 
164  ATH_MSG_INFO(
165  "==> finalize " << name() << "...\n"
166  << "***************************************************************\n"
167  << "Results of " << name() << " thinning algorithm:\n"
168  << "-------------");
169  ATH_MSG_INFO(" Number of processed events: " << m_nEventsProcessed);
170 
171  if(m_nTriggerTowersProcessed > 0) {
172  ATH_MSG_INFO(
173  " Average percent of Trigger Towers kept = "
174  << 100.0 * m_nTriggerTowersKept / (double)m_nTriggerTowersProcessed << " %");
175  }
176  if(m_useRandom == true && m_nEventsProcessed > 0){
177  ATH_MSG_INFO(
178  " Percentage of events where all Trigger Towers were kept (should be approx "<< 100.0*m_minRandom << ") = "
180  }
181 
182 
183  return StatusCode::SUCCESS;
184  }

◆ initialize()

StatusCode TriggerTowerThinningAlg::initialize ( )
overridevirtual

Definition at line 56 of file TriggerTowerThinningAlg.cxx.

56  {
57  ATH_MSG_INFO("L1Calo TriggerTowerThinningAlg::initialize()");
58 
61 
62  ATH_CHECK( m_rndmSvc.retrieve() );
63 
64  return StatusCode::SUCCESS;
65  }

Member Data Documentation

◆ m_caloCellETByLayerKey

SG::ReadDecorHandleKey<xAOD::TriggerTowerContainer> DerivationFramework::TriggerTowerThinningAlg::m_caloCellETByLayerKey { this, "CaloCellETByLayerKey", m_triggerTowerLocation.key()+".CaloCellETByLayer", "" }
private

Definition at line 58 of file TriggerTowerThinningAlg.h.

◆ m_minADC

int DerivationFramework::TriggerTowerThinningAlg::m_minADC
private

Definition at line 63 of file TriggerTowerThinningAlg.h.

◆ m_minCaloCellET

double DerivationFramework::TriggerTowerThinningAlg::m_minCaloCellET
private

Definition at line 62 of file TriggerTowerThinningAlg.h.

◆ m_minRandom

double DerivationFramework::TriggerTowerThinningAlg::m_minRandom
private

Definition at line 65 of file TriggerTowerThinningAlg.h.

◆ m_nEventsAllTriggerTowersKeptByRandom

std::atomic<unsigned long> DerivationFramework::TriggerTowerThinningAlg::m_nEventsAllTriggerTowersKeptByRandom
mutableprivate

Definition at line 69 of file TriggerTowerThinningAlg.h.

◆ m_nEventsProcessed

std::atomic<unsigned long> DerivationFramework::TriggerTowerThinningAlg::m_nEventsProcessed
mutableprivate

Definition at line 68 of file TriggerTowerThinningAlg.h.

◆ m_nTriggerTowersKept

std::atomic<unsigned long> DerivationFramework::TriggerTowerThinningAlg::m_nTriggerTowersKept
mutableprivate

Definition at line 71 of file TriggerTowerThinningAlg.h.

◆ m_nTriggerTowersProcessed

std::atomic<unsigned long> DerivationFramework::TriggerTowerThinningAlg::m_nTriggerTowersProcessed
mutableprivate

Definition at line 70 of file TriggerTowerThinningAlg.h.

◆ m_nTriggerTowersRejected

std::atomic<unsigned long> DerivationFramework::TriggerTowerThinningAlg::m_nTriggerTowersRejected
mutableprivate

Definition at line 72 of file TriggerTowerThinningAlg.h.

◆ m_rndmSvc

ServiceHandle<IAthRNGSvc> DerivationFramework::TriggerTowerThinningAlg::m_rndmSvc { this, "RndmSvc", "AthRNGSvc", "" }
private

Definition at line 75 of file TriggerTowerThinningAlg.h.

◆ m_streamName

StringProperty DerivationFramework::TriggerTowerThinningAlg::m_streamName { this, "StreamName", "", "Name of the stream being thinned" }
private

Definition at line 52 of file TriggerTowerThinningAlg.h.

◆ m_triggerTowerLocation

SG::ThinningHandleKey<xAOD::TriggerTowerContainer> DerivationFramework::TriggerTowerThinningAlg::m_triggerTowerLocation { this, "TriggerTowerLocation", LVL1::TrigT1CaloDefs::xAODTriggerTowerLocation, "" }
private

Definition at line 55 of file TriggerTowerThinningAlg.h.

◆ m_useRandom

bool DerivationFramework::TriggerTowerThinningAlg::m_useRandom
private

Definition at line 64 of file TriggerTowerThinningAlg.h.


The documentation for this class was generated from the following files:
ATHRNG::RNGWrapper::setSeed
void setSeed(const std::string &algName, const EventContext &ctx)
Set the random seed using a string (e.g.
Definition: RNGWrapper.h:169
DerivationFramework::TriggerTowerThinningAlg::m_rndmSvc
ServiceHandle< IAthRNGSvc > m_rndmSvc
Definition: TriggerTowerThinningAlg.h:76
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
DerivationFramework::TriggerTowerThinningAlg::m_minCaloCellET
double m_minCaloCellET
Definition: TriggerTowerThinningAlg.h:62
DerivationFramework::TriggerTowerThinningAlg::m_nEventsProcessed
std::atomic< unsigned long > m_nEventsProcessed
Definition: TriggerTowerThinningAlg.h:68
DerivationFramework::TriggerTowerThinningAlg::m_nEventsAllTriggerTowersKeptByRandom
std::atomic< unsigned long > m_nEventsAllTriggerTowersKeptByRandom
Definition: TriggerTowerThinningAlg.h:69
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
DerivationFramework::TriggerTowerThinningAlg::m_minRandom
double m_minRandom
Definition: TriggerTowerThinningAlg.h:65
DerivationFramework::TriggerTowerThinningAlg::m_nTriggerTowersRejected
std::atomic< unsigned long > m_nTriggerTowersRejected
Definition: TriggerTowerThinningAlg.h:72
DerivationFramework::TriggerTowerThinningAlg::m_useRandom
bool m_useRandom
Definition: TriggerTowerThinningAlg.h:64
DerivationFramework::TriggerTowerThinningAlg::m_minADC
int m_minADC
Definition: TriggerTowerThinningAlg.h:63
python.utils.AtlRunQueryLookup.mask
string mask
Definition: AtlRunQueryLookup.py:460
SG::ThinningHandle
Handle for requesting thinning for a data object.
Definition: ThinningHandle.h:84
DerivationFramework::TriggerTowerThinningAlg::m_nTriggerTowersKept
std::atomic< unsigned long > m_nTriggerTowersKept
Definition: TriggerTowerThinningAlg.h:71
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:210
SG::ReadDecorHandle
Handle class for reading a decoration on an object.
Definition: StoreGate/StoreGate/ReadDecorHandle.h:94
xAOD::uint16_t
setWord1 uint16_t
Definition: eFexEMRoI_v1.cxx:93
lumiFormat.i
int i
Definition: lumiFormat.py:85
beamspotman.n
n
Definition: beamspotman.py:731
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
DerivationFramework::TriggerTowerThinningAlg::m_nTriggerTowersProcessed
std::atomic< unsigned long > m_nTriggerTowersProcessed
Definition: TriggerTowerThinningAlg.h:70
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
DerivationFramework::TriggerTowerThinningAlg::m_streamName
StringProperty m_streamName
Definition: TriggerTowerThinningAlg.h:53
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
ATHRNG::RNGWrapper
A wrapper class for event-slot-local random engines.
Definition: RNGWrapper.h:56
ATHRNG::RNGWrapper::getEngine
CLHEP::HepRandomEngine * getEngine(const EventContext &ctx) const
Retrieve the random engine corresponding to the provided EventContext.
Definition: RNGWrapper.h:134
DerivationFramework::TriggerTowerThinningAlg::m_caloCellETByLayerKey
SG::ReadDecorHandleKey< xAOD::TriggerTowerContainer > m_caloCellETByLayerKey
Definition: TriggerTowerThinningAlg.h:59
DerivationFramework::TriggerTowerThinningAlg::m_triggerTowerLocation
SG::ThinningHandleKey< xAOD::TriggerTowerContainer > m_triggerTowerLocation
Definition: TriggerTowerThinningAlg.h:56
SG::AllowEmpty
@ AllowEmpty
Definition: StoreGate/StoreGate/VarHandleKey.h:30
TileDCSDataPlotter.tt
tt
Definition: TileDCSDataPlotter.py:874
python.compressB64.c
def c
Definition: compressB64.py:93