ATLAS Offline Software
Loading...
Searching...
No Matches
L1CaloPedestalGenerator Class Reference

Algorithm to produce TriggerTowers filled with simulated pedestal runs. More...

#include <L1CaloPedestalGenerator.h>

Inheritance diagram for L1CaloPedestalGenerator:
Collaboration diagram for L1CaloPedestalGenerator:

Public Member Functions

 L1CaloPedestalGenerator (const std::string &name, ISvcLocator *pSvcLocator)
virtual ~L1CaloPedestalGenerator ()
virtual StatusCode initialize ()
virtual StatusCode execute ()
virtual StatusCode finalize ()
virtual StatusCode sysInitialize () override
 Override sysInitialize.
virtual const DataObjIDColl & extraOutputDeps () const override
 Return the list of extra output dependencies.
ServiceHandle< StoreGateSvc > & evtStore ()
 The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.
const ServiceHandle< StoreGateSvc > & detStore () const
 The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.
virtual StatusCode sysStart () override
 Handle START transition.
virtual std::vector< Gaudi::DataHandle * > inputHandles () const override
 Return this algorithm's input handles.
virtual std::vector< Gaudi::DataHandle * > outputHandles () const override
 Return this algorithm's output handles.
Gaudi::Details::PropertyBase & declareProperty (Gaudi::Property< T, V, H > &t)
void updateVHKA (Gaudi::Details::PropertyBase &)
MsgStream & msg () const
bool msgLvl (const MSG::Level lvl) const

Protected Member Functions

void renounceArray (SG::VarHandleKeyArray &handlesArray)
 remove all handles from I/O resolution
std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > renounce (T &h)
void extraDeps_update_handler (Gaudi::Details::PropertyBase &ExtraDeps)
 Add StoreName to extra input/output deps as needed.

Private Types

typedef ServiceHandle< StoreGateSvcStoreGateSvc_t

Private Member Functions

LVL1::InternalTriggerTowerfindInternalTriggerTower (const Identifier &towerId, bool bCreate=true)
LVL1::InternalTriggerTowerfindInternalTriggerTower (double tt_phi, double tt_eta, unsigned int key, bool bCreate=true)
double IDeta (const Identifier &id, const CaloLVL1_ID *l1id)
double IDphi (const Identifier &id, const CaloLVL1_ID *l1id)
Gaudi::Details::PropertyBase & declareGaudiProperty (Gaudi::Property< T, V, H > &hndl, const SG::VarHandleKeyType &)
 specialization for handling Gaudi::Property<SG::VarHandleKey>

Private Attributes

const CaloIdManagerm_caloMgr
const CaloLVL1_IDm_lvl1Helper
std::string m_TTLocation
double m_pedMean
double m_pedRMS
unsigned int m_nSamples
LVL1::TriggerTowerKeym_towerKey
std::map< unsigned int, LVL1::InternalTriggerTower * > * m_IntTTContainer
DataObjIDColl m_extendedExtraObjects
StoreGateSvc_t m_evtStore
 Pointer to StoreGate (event store by default)
StoreGateSvc_t m_detStore
 Pointer to StoreGate (detector store by default)
std::vector< SG::VarHandleKeyArray * > m_vhka
bool m_varHandleArraysDeclared

Detailed Description

Algorithm to produce TriggerTowers filled with simulated pedestal runs.

Author
Damien Prieur damie.nosp@m.n.pr.nosp@m.ieur@.nosp@m.cern.nosp@m..ch

Definition at line 27 of file L1CaloPedestalGenerator.h.

Member Typedef Documentation

◆ StoreGateSvc_t

typedef ServiceHandle<StoreGateSvc> AthCommonDataStore< AthCommonMsg< Algorithm > >::StoreGateSvc_t
privateinherited

Definition at line 388 of file AthCommonDataStore.h.

Constructor & Destructor Documentation

◆ L1CaloPedestalGenerator()

L1CaloPedestalGenerator::L1CaloPedestalGenerator ( const std::string & name,
ISvcLocator * pSvcLocator )

Definition at line 21 of file L1CaloPedestalGenerator.cxx.

22{
23}
24
25//-------------------------------------------
26// Initialize
27//-------------------------------------------
29{
30 ATH_MSG_INFO("From Initialize...");
32
33 // Retrieve CaloIdManager
#define ATH_MSG_INFO(x)
static Double_t sc
::StatusCode StatusCode
StatusCode definition for legacy code.

◆ ~L1CaloPedestalGenerator()

L1CaloPedestalGenerator::~L1CaloPedestalGenerator ( )
virtual

Definition at line 37 of file L1CaloPedestalGenerator.cxx.

41 {

Member Function Documentation

◆ declareGaudiProperty()

Gaudi::Details::PropertyBase & AthCommonDataStore< AthCommonMsg< Algorithm > >::declareGaudiProperty ( Gaudi::Property< T, V, H > & hndl,
const SG::VarHandleKeyType &  )
inlineprivateinherited

specialization for handling Gaudi::Property<SG::VarHandleKey>

Definition at line 156 of file AthCommonDataStore.h.

158 {
160 hndl.value(),
161 hndl.documentation());
162
163 }
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)

◆ declareProperty()

Gaudi::Details::PropertyBase & AthCommonDataStore< AthCommonMsg< Algorithm > >::declareProperty ( Gaudi::Property< T, V, H > & t)
inlineinherited

Definition at line 145 of file AthCommonDataStore.h.

145 {
146 typedef typename SG::HandleClassifier<T>::type htype;
148 }
Gaudi::Details::PropertyBase & declareGaudiProperty(Gaudi::Property< T, V, H > &hndl, const SG::VarHandleKeyType &)
specialization for handling Gaudi::Property<SG::VarHandleKey>

◆ detStore()

const ServiceHandle< StoreGateSvc > & AthCommonDataStore< AthCommonMsg< Algorithm > >::detStore ( ) const
inlineinherited

The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.

Definition at line 95 of file AthCommonDataStore.h.

◆ evtStore()

ServiceHandle< StoreGateSvc > & AthCommonDataStore< AthCommonMsg< Algorithm > >::evtStore ( )
inlineinherited

The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.

Definition at line 85 of file AthCommonDataStore.h.

◆ execute()

StatusCode L1CaloPedestalGenerator::execute ( )
virtual

Definition at line 104 of file L1CaloPedestalGenerator.cxx.

116 {
117 double eta = it->second->eta();
118 double phi = it->second->phi();
119 unsigned int key = it->second->key();
120
121 std::vector<double> vEmAmps = it->second->EmAmps();
122 std::vector<int> emDigits(vEmAmps.size());
123 for (size_t i = 0; i < vEmAmps.size(); i++)
124 emDigits[i] = static_cast<int> (vEmAmps[i]);
125
126 std::vector<double> vHadAmps = it->second->HadAmps();
127 std::vector<int> hadDigits(vHadAmps.size());
128 for (size_t i = 0; i < vHadAmps.size(); i++)
129 hadDigits[i] = static_cast<int> (vHadAmps[i]);
130
131 //need to put some fake push back to be able to use TriggerTowers2Ntuple
132 // cause LVL1::TriggerTower::emEnergy() make a m_em_energy[m_em_peak];
133 // instead of using m_em_energy.at(m_em_peak);
134 std::vector<int> emEt; emEt.push_back(0);
135 std::vector<int> hadEt; hadEt.push_back(0);
136 std::vector<int> emBCID; emBCID.push_back(0);
137 std::vector<int> hadBCID; hadBCID.push_back(0);
138 std::vector<int> emExt; emExt.push_back(0);
139 std::vector<int> hadExt; hadExt.push_back(0);
140 int peak = 0;
141 int emADCPeak = 0;
142 int hadADCPeak = 0;
143
144 // Create TT
145 LVL1::TriggerTower* tower = new LVL1::TriggerTower(phi,eta,key,
146 emDigits, emEt, emExt, emBCID, 0, peak, emADCPeak,
147 hadDigits, hadEt, hadExt, hadBCID, 0, peak, hadADCPeak);
148
149 VectorOfTTs->push_back(tower);
150
151 } //-- End Loop on InternalTriggerTowers --
152
153 ATH_MSG_DEBUG( VectorOfTTs->size()<<" TTs have been generated");
154
155 sc = evtStore()->setConst(VectorOfTTs);
156 if (sc.isSuccess()) ATH_MSG_DEBUG( "TT container locked");
157 else {
158 ATH_MSG_ERROR( "failed to lock TT container");
159 return StatusCode::FAILURE;
160 }
161
162 it = m_IntTTContainer->begin();
163 for(;it!=m_IntTTContainer->end();++it) delete it->second;
164 delete m_IntTTContainer;
165
166 ATH_MSG_DEBUG("End of Execute...");
167 return StatusCode::SUCCESS;
168}
169
170//-----------------------------------------
171// Finalize
172//-----------------------------------------
174{
175 delete m_towerKey;
176
177 return StatusCode::SUCCESS;
178}
179
180LVL1::InternalTriggerTower* L1CaloPedestalGenerator::findInternalTriggerTower(const Identifier& towerId, bool bCreate) {
181 // Create tower key from towerId
182 double tower_eta = IDeta(towerId,m_lvl1Helper);
183 double tower_phi = IDphi(towerId,m_lvl1Helper);
184 unsigned int key = m_towerKey->ttKey(tower_phi,tower_eta);
185 double tt_phi = m_towerKey->phi();
186 double tt_eta = m_towerKey->eta();
187
188 return findInternalTriggerTower(tt_phi, tt_eta, key, bCreate);
189}
190
191LVL1::InternalTriggerTower* L1CaloPedestalGenerator::findInternalTriggerTower(double tt_phi, double tt_eta, unsigned int key, bool bCreate) {
192 std::map<unsigned int, LVL1::InternalTriggerTower*>::iterator it = m_IntTTContainer->find( key );
193 LVL1::InternalTriggerTower* TT = 0;
194 if (it == m_IntTTContainer->end()){
195 if(bCreate) {
196 // no TT yet. Create it!
197 TT = new LVL1::InternalTriggerTower(tt_phi,tt_eta, key);
198 m_IntTTContainer->insert(std::map<unsigned int, LVL1::InternalTriggerTower*>::value_type(key,TT)); //and put it in the map.
199 }
200 }else{
201 TT = (it->second);
202 } // end else
203 return TT;
204}
205
206double L1CaloPedestalGenerator::IDeta(const Identifier& id, const CaloLVL1_ID* l1id) {
207 int region = l1id->region(id);
208 int ieta = l1id->eta(id);
209 int sign = l1id->pos_neg_z(id);
210
211 double gran[4] = {0.1, 0.2, 0.1, 0.425};
212 double offset[4] = {0., 2.5, 3.1, 3.2};
213 double eta;
214
215 if (region>=0 && region<=3) {
216 eta = sign* ( ( (ieta+0.5) * gran[region] ) + offset[region] );
217 }
218 else {
219 eta = 0.;
220 }
221 return eta;
222}
223
224double L1CaloPedestalGenerator::IDphi(const Identifier& id, const CaloLVL1_ID* l1id) {
225 Identifier regId = l1id->region_id(id);
226
227 double phiMax = l1id->phi_max(regId);
228 int iphi = l1id->phi(id);
229
230 double phi = (iphi+0.5)*2*M_PI/(phiMax+1);
231
232 return phi;
233}
234
#define M_PI
Scalar eta() const
pseudorapidity method
Scalar phi() const
phi method
#define ATH_MSG_ERROR(x)
#define ATH_MSG_DEBUG(x)
int sign(int a)
int phi_max(const Identifier regId) const
min value of phi index (-999 == failure)
Identifier region_id(int pos_neg_z, int sampling, int region) const
build a region (of towers) identifier
int region(const Identifier id) const
return region according to :
int pos_neg_z(const Identifier id) const
return pos_neg_z according to :
int eta(const Identifier id) const
return eta according to :
int phi(const Identifier id) const
return phi according to :
double IDeta(const Identifier &id, const CaloLVL1_ID *l1id)
double IDphi(const Identifier &id, const CaloLVL1_ID *l1id)
LVL1::TriggerTowerKey * m_towerKey
LVL1::InternalTriggerTower * findInternalTriggerTower(const Identifier &towerId, bool bCreate=true)
std::map< unsigned int, LVL1::InternalTriggerTower * > * m_IntTTContainer

◆ extraDeps_update_handler()

void AthCommonDataStore< AthCommonMsg< Algorithm > >::extraDeps_update_handler ( Gaudi::Details::PropertyBase & ExtraDeps)
protectedinherited

Add StoreName to extra input/output deps as needed.

use the logic of the VarHandleKey to parse the DataObjID keys supplied via the ExtraInputs and ExtraOuputs Properties to add the StoreName if it's not explicitly given

◆ extraOutputDeps()

const DataObjIDColl & AthAlgorithm::extraOutputDeps ( ) const
overridevirtualinherited

Return the list of extra output dependencies.

This list is extended to include symlinks implied by inheritance relations.

Definition at line 50 of file AthAlgorithm.cxx.

51{
52 // If we didn't find any symlinks to add, just return the collection
53 // from the base class. Otherwise, return the extended collection.
54 if (!m_extendedExtraObjects.empty()) {
56 }
57 return Algorithm::extraOutputDeps();
58}
DataObjIDColl m_extendedExtraObjects

◆ finalize()

StatusCode L1CaloPedestalGenerator::finalize ( )
virtual

Definition at line 336 of file L1CaloPedestalGenerator.cxx.

348 : AthAlgorithm(name, pSvcLocator), m_caloMgr(0), m_lvl1Helper(0), m_towerKey(0), m_IntTTContainer(0)
349{
350 declareProperty("TriggerTowerLocation", m_TTLocation = "LVL1TriggerTowers");
351 declareProperty("PedestalMean", m_pedMean = 10.);
352 declareProperty("PedestalRMS", m_pedRMS = 0.);
353 declareProperty("NSamples", m_nSamples = 5);
354}
355
357{
358}
359
360//-------------------------------------------
361// Initialize
362//-------------------------------------------
364{
365 ATH_MSG_INFO("From Initialize...");
367
368 // Retrieve CaloIdManager
369 sc = detStore()->retrieve(m_caloMgr);
370 if (sc.isFailure()) {
371 ATH_MSG_ERROR( "Unable to retrieve CaloIdManager from DetectorStore" );
372 return StatusCode::FAILURE;
373 }
374
375 m_lvl1Helper = m_caloMgr->getLVL1_ID();
376 if (!m_lvl1Helper) {
377 ATH_MSG_ERROR( "Could not access CaloLVL1_ID helper" );
378 return StatusCode::FAILURE;
379 }
380
381 m_towerKey = new LVL1::TriggerTowerKey();
382
383 return StatusCode::SUCCESS;
384}
385
386//----------------------------------------
387// Execute
388//----------------------------------------
390{
391 ATH_MSG_DEBUG("From Execute...");
392
394
395 m_IntTTContainer = new std::map<unsigned int, LVL1::InternalTriggerTower*>;
396
398 sc = evtStore()->record(VectorOfTTs, m_TTLocation);
399
400 if (sc.isSuccess()) ATH_MSG_DEBUG( "Stored TTs in TES at "<< m_TTLocation );
401 else {
402 ATH_MSG_ERROR( "failed to write TTs to TES at " << m_TTLocation );
403 return StatusCode::FAILURE;
404 }
405
406 //---
407 // Loop on all Trigger Towers to create the TT objects
408 // and store them into containers
409
410 std::vector<Identifier>::const_iterator tower_it = m_lvl1Helper->tower_begin();
411
412 // -- Loop on Trigger Tower offline Ids --
413 for(;tower_it!=m_lvl1Helper->tower_end();++tower_it) {
414 Identifier towerId = (*tower_it);
415
416 //---
417 // Check detector type
418 bool bIsTile = m_lvl1Helper->is_tile(towerId);
419 bool bIsHadronic = m_lvl1Helper->sampling(towerId); // check if tt is an HEC tt
420
421 //---
422 // Generate pedestal samples
423 std::vector<double> vnoise;
424 for(unsigned int sample=0;sample<m_nSamples;++sample) vnoise.push_back(CLHEP::RandGaussZiggurat::shoot(0.,m_pedRMS));
425
426 std::vector< std::vector<double> > vAutoCorrMatrix(m_nSamples, std::vector<double>(m_nSamples,0));
427 for(unsigned int sample=0;sample<m_nSamples;++sample) vAutoCorrMatrix[sample][sample] = 1;
428
429 std::vector<double> vsamples;
430 for(unsigned int sample=0;sample<m_nSamples;++sample) {
431 double noise = 0;
432 for(unsigned int jj=0;jj<m_nSamples;++jj) noise+= vAutoCorrMatrix[sample][jj]*vnoise[jj];
433 vsamples.push_back(m_pedMean + noise);
434 }
435
436 //---
437 // Seek for an existing or create a new InternalTriggerTower
438 LVL1::InternalTriggerTower* TT = findInternalTriggerTower(towerId);
439
440 if(bIsTile||bIsHadronic) TT->addHadAmps(vsamples);
441 else TT->addEMAmps(vsamples);
442
443 } //-- End Loop on Trigger Tower offline Ids --
444
445
446 //---
447 // Loop over Internal Trigger Tower and create fake TT with
448 // only the Digits parts filled
449
450 std::map<unsigned int, LVL1::InternalTriggerTower*>::const_iterator it = m_IntTTContainer->begin();
451 for(;it!=m_IntTTContainer->end();++it) {
452 double eta = it->second->eta();
453 double phi = it->second->phi();
454 unsigned int key = it->second->key();
455
456 std::vector<double> vEmAmps = it->second->EmAmps();
457 std::vector<int> emDigits(vEmAmps.size());
458 for (size_t i = 0; i < vEmAmps.size(); i++)
459 emDigits[i] = static_cast<int> (vEmAmps[i]);
460
461 std::vector<double> vHadAmps = it->second->HadAmps();
462 std::vector<int> hadDigits(vHadAmps.size());
463 for (size_t i = 0; i < vHadAmps.size(); i++)
464 hadDigits[i] = static_cast<int> (vHadAmps[i]);
465
466 //need to put some fake push back to be able to use TriggerTowers2Ntuple
467 // cause LVL1::TriggerTower::emEnergy() make a m_em_energy[m_em_peak];
468 // instead of using m_em_energy.at(m_em_peak);
469 std::vector<int> emEt; emEt.push_back(0);
470 std::vector<int> hadEt; hadEt.push_back(0);
471 std::vector<int> emBCID; emBCID.push_back(0);
472 std::vector<int> hadBCID; hadBCID.push_back(0);
473 std::vector<int> emExt; emExt.push_back(0);
474 std::vector<int> hadExt; hadExt.push_back(0);
475 int peak = 0;
476 int emADCPeak = 0;
477 int hadADCPeak = 0;
478
479 // Create TT
480 LVL1::TriggerTower* tower = new LVL1::TriggerTower(phi,eta,key,
481 emDigits, emEt, emExt, emBCID, 0, peak, emADCPeak,
482 hadDigits, hadEt, hadExt, hadBCID, 0, peak, hadADCPeak);
483
484 VectorOfTTs->push_back(tower);
485
486 } //-- End Loop on InternalTriggerTowers --
487
488 ATH_MSG_DEBUG( VectorOfTTs->size()<<" TTs have been generated");
489
490 sc = evtStore()->setConst(VectorOfTTs);
491 if (sc.isSuccess()) ATH_MSG_DEBUG( "TT container locked");
492 else {
493 ATH_MSG_ERROR( "failed to lock TT container");
494 return StatusCode::FAILURE;
495 }
496
497 it = m_IntTTContainer->begin();
498 for(;it!=m_IntTTContainer->end();++it) delete it->second;
499 delete m_IntTTContainer;
500
501 ATH_MSG_DEBUG("End of Execute...");
502 return StatusCode::SUCCESS;
503}
504
505//-----------------------------------------
506// Finalize
507//-----------------------------------------
509{
510 delete m_towerKey;
511
512 return StatusCode::SUCCESS;
513}
514
515LVL1::InternalTriggerTower* L1CaloPedestalGenerator::findInternalTriggerTower(const Identifier& towerId, bool bCreate) {
516 // Create tower key from towerId
517 double tower_eta = IDeta(towerId,m_lvl1Helper);
518 double tower_phi = IDphi(towerId,m_lvl1Helper);
519 unsigned int key = m_towerKey->ttKey(tower_phi,tower_eta);
520 double tt_phi = m_towerKey->phi();
521 double tt_eta = m_towerKey->eta();
522
523 return findInternalTriggerTower(tt_phi, tt_eta, key, bCreate);
524}
525
526LVL1::InternalTriggerTower* L1CaloPedestalGenerator::findInternalTriggerTower(double tt_phi, double tt_eta, unsigned int key, bool bCreate) {
527 std::map<unsigned int, LVL1::InternalTriggerTower*>::iterator it = m_IntTTContainer->find( key );
528 LVL1::InternalTriggerTower* TT = 0;
529 if (it == m_IntTTContainer->end()){
530 if(bCreate) {
531 // no TT yet. Create it!
532 TT = new LVL1::InternalTriggerTower(tt_phi,tt_eta, key);
533 m_IntTTContainer->insert(std::map<unsigned int, LVL1::InternalTriggerTower*>::value_type(key,TT)); //and put it in the map.
534 }
535 }else{
536 TT = (it->second);
537 } // end else
538 return TT;
539}
540
541double L1CaloPedestalGenerator::IDeta(const Identifier& id, const CaloLVL1_ID* l1id) {
542 int region = l1id->region(id);
543 int ieta = l1id->eta(id);
544 int sign = l1id->pos_neg_z(id);
545
546 double gran[4] = {0.1, 0.2, 0.1, 0.425};
547 double offset[4] = {0., 2.5, 3.1, 3.2};
548 double eta;
549
550 if (region>=0 && region<=3) {
551 eta = sign* ( ( (ieta+0.5) * gran[region] ) + offset[region] );
552 }
553 else {
554 eta = 0.;
555 }
556 return eta;
557}
558
559double L1CaloPedestalGenerator::IDphi(const Identifier& id, const CaloLVL1_ID* l1id) {
560 Identifier regId = l1id->region_id(id);
561
562 double phiMax = l1id->phi_max(regId);
563 int iphi = l1id->phi(id);
564
565 double phi = (iphi+0.5)*2*M_PI/(phiMax+1);
566
567 return phi;
568}
569
DataVector< LVL1::TriggerTower > TriggerTowerCollection
AthAlgorithm()
Default constructor:
const ServiceHandle< StoreGateSvc > & detStore() const
value_type push_back(value_type pElem)
Add an element to the end of the collection.
size_type size() const noexcept
Returns the number of elements in the collection.
const CaloIdManager * m_caloMgr

◆ findInternalTriggerTower() [1/2]

LVL1::InternalTriggerTower * L1CaloPedestalGenerator::findInternalTriggerTower ( const Identifier & towerId,
bool bCreate = true )
private

Definition at line 351 of file L1CaloPedestalGenerator.cxx.

363 : AthAlgorithm(name, pSvcLocator), m_caloMgr(0), m_lvl1Helper(0), m_towerKey(0), m_IntTTContainer(0)
364{
365 declareProperty("TriggerTowerLocation", m_TTLocation = "LVL1TriggerTowers");
366 declareProperty("PedestalMean", m_pedMean = 10.);
367 declareProperty("PedestalRMS", m_pedRMS = 0.);
368 declareProperty("NSamples", m_nSamples = 5);
369}
370
372{
373}
374
375//-------------------------------------------
376// Initialize
377//-------------------------------------------
379{
380 ATH_MSG_INFO("From Initialize...");
382
383 // Retrieve CaloIdManager
384 sc = detStore()->retrieve(m_caloMgr);
385 if (sc.isFailure()) {
386 ATH_MSG_ERROR( "Unable to retrieve CaloIdManager from DetectorStore" );
387 return StatusCode::FAILURE;
388 }
389
390 m_lvl1Helper = m_caloMgr->getLVL1_ID();
391 if (!m_lvl1Helper) {
392 ATH_MSG_ERROR( "Could not access CaloLVL1_ID helper" );
393 return StatusCode::FAILURE;
394 }
395
396 m_towerKey = new LVL1::TriggerTowerKey();
397
398 return StatusCode::SUCCESS;
399}
400
401//----------------------------------------
402// Execute
403//----------------------------------------
405{
406 ATH_MSG_DEBUG("From Execute...");
407
409
410 m_IntTTContainer = new std::map<unsigned int, LVL1::InternalTriggerTower*>;
411
413 sc = evtStore()->record(VectorOfTTs, m_TTLocation);
414
415 if (sc.isSuccess()) ATH_MSG_DEBUG( "Stored TTs in TES at "<< m_TTLocation );
416 else {
417 ATH_MSG_ERROR( "failed to write TTs to TES at " << m_TTLocation );
418 return StatusCode::FAILURE;
419 }
420
421 //---
422 // Loop on all Trigger Towers to create the TT objects
423 // and store them into containers
424
425 std::vector<Identifier>::const_iterator tower_it = m_lvl1Helper->tower_begin();
426
427 // -- Loop on Trigger Tower offline Ids --
428 for(;tower_it!=m_lvl1Helper->tower_end();++tower_it) {
429 Identifier towerId = (*tower_it);
430
431 //---
432 // Check detector type
433 bool bIsTile = m_lvl1Helper->is_tile(towerId);
434 bool bIsHadronic = m_lvl1Helper->sampling(towerId); // check if tt is an HEC tt
435
436 //---
437 // Generate pedestal samples
438 std::vector<double> vnoise;
439 for(unsigned int sample=0;sample<m_nSamples;++sample) vnoise.push_back(CLHEP::RandGaussZiggurat::shoot(0.,m_pedRMS));
440
441 std::vector< std::vector<double> > vAutoCorrMatrix(m_nSamples, std::vector<double>(m_nSamples,0));
442 for(unsigned int sample=0;sample<m_nSamples;++sample) vAutoCorrMatrix[sample][sample] = 1;
443
444 std::vector<double> vsamples;
445 for(unsigned int sample=0;sample<m_nSamples;++sample) {
446 double noise = 0;
447 for(unsigned int jj=0;jj<m_nSamples;++jj) noise+= vAutoCorrMatrix[sample][jj]*vnoise[jj];
448 vsamples.push_back(m_pedMean + noise);
449 }
450
451 //---
452 // Seek for an existing or create a new InternalTriggerTower
453 LVL1::InternalTriggerTower* TT = findInternalTriggerTower(towerId);
454
455 if(bIsTile||bIsHadronic) TT->addHadAmps(vsamples);
456 else TT->addEMAmps(vsamples);
457
458 } //-- End Loop on Trigger Tower offline Ids --
459
460
461 //---
462 // Loop over Internal Trigger Tower and create fake TT with
463 // only the Digits parts filled
464
465 std::map<unsigned int, LVL1::InternalTriggerTower*>::const_iterator it = m_IntTTContainer->begin();
466 for(;it!=m_IntTTContainer->end();++it) {
467 double eta = it->second->eta();
468 double phi = it->second->phi();
469 unsigned int key = it->second->key();
470
471 std::vector<double> vEmAmps = it->second->EmAmps();
472 std::vector<int> emDigits(vEmAmps.size());
473 for (size_t i = 0; i < vEmAmps.size(); i++)
474 emDigits[i] = static_cast<int> (vEmAmps[i]);
475
476 std::vector<double> vHadAmps = it->second->HadAmps();
477 std::vector<int> hadDigits(vHadAmps.size());
478 for (size_t i = 0; i < vHadAmps.size(); i++)
479 hadDigits[i] = static_cast<int> (vHadAmps[i]);
480
481 //need to put some fake push back to be able to use TriggerTowers2Ntuple
482 // cause LVL1::TriggerTower::emEnergy() make a m_em_energy[m_em_peak];
483 // instead of using m_em_energy.at(m_em_peak);
484 std::vector<int> emEt; emEt.push_back(0);
485 std::vector<int> hadEt; hadEt.push_back(0);
486 std::vector<int> emBCID; emBCID.push_back(0);
487 std::vector<int> hadBCID; hadBCID.push_back(0);
488 std::vector<int> emExt; emExt.push_back(0);
489 std::vector<int> hadExt; hadExt.push_back(0);
490 int peak = 0;
491 int emADCPeak = 0;
492 int hadADCPeak = 0;
493
494 // Create TT
495 LVL1::TriggerTower* tower = new LVL1::TriggerTower(phi,eta,key,
496 emDigits, emEt, emExt, emBCID, 0, peak, emADCPeak,
497 hadDigits, hadEt, hadExt, hadBCID, 0, peak, hadADCPeak);
498
499 VectorOfTTs->push_back(tower);
500
501 } //-- End Loop on InternalTriggerTowers --
502
503 ATH_MSG_DEBUG( VectorOfTTs->size()<<" TTs have been generated");
504
505 sc = evtStore()->setConst(VectorOfTTs);
506 if (sc.isSuccess()) ATH_MSG_DEBUG( "TT container locked");
507 else {
508 ATH_MSG_ERROR( "failed to lock TT container");
509 return StatusCode::FAILURE;
510 }
511
512 it = m_IntTTContainer->begin();
513 for(;it!=m_IntTTContainer->end();++it) delete it->second;
514 delete m_IntTTContainer;
515
516 ATH_MSG_DEBUG("End of Execute...");
517 return StatusCode::SUCCESS;
518}
519
520//-----------------------------------------
521// Finalize
522//-----------------------------------------
524{
525 delete m_towerKey;
526
527 return StatusCode::SUCCESS;
528}
529
530LVL1::InternalTriggerTower* L1CaloPedestalGenerator::findInternalTriggerTower(const Identifier& towerId, bool bCreate) {
531 // Create tower key from towerId
532 double tower_eta = IDeta(towerId,m_lvl1Helper);
533 double tower_phi = IDphi(towerId,m_lvl1Helper);
534 unsigned int key = m_towerKey->ttKey(tower_phi,tower_eta);
535 double tt_phi = m_towerKey->phi();
536 double tt_eta = m_towerKey->eta();
537
538 return findInternalTriggerTower(tt_phi, tt_eta, key, bCreate);
539}
540
541LVL1::InternalTriggerTower* L1CaloPedestalGenerator::findInternalTriggerTower(double tt_phi, double tt_eta, unsigned int key, bool bCreate) {
542 std::map<unsigned int, LVL1::InternalTriggerTower*>::iterator it = m_IntTTContainer->find( key );
543 LVL1::InternalTriggerTower* TT = 0;
544 if (it == m_IntTTContainer->end()){
545 if(bCreate) {
546 // no TT yet. Create it!
547 TT = new LVL1::InternalTriggerTower(tt_phi,tt_eta, key);
548 m_IntTTContainer->insert(std::map<unsigned int, LVL1::InternalTriggerTower*>::value_type(key,TT)); //and put it in the map.
549 }
550 }else{
551 TT = (it->second);
552 } // end else
553 return TT;
554}
555
556double L1CaloPedestalGenerator::IDeta(const Identifier& id, const CaloLVL1_ID* l1id) {
557 int region = l1id->region(id);
558 int ieta = l1id->eta(id);
559 int sign = l1id->pos_neg_z(id);
560
561 double gran[4] = {0.1, 0.2, 0.1, 0.425};
562 double offset[4] = {0., 2.5, 3.1, 3.2};
563 double eta;
564
565 if (region>=0 && region<=3) {
566 eta = sign* ( ( (ieta+0.5) * gran[region] ) + offset[region] );
567 }
568 else {
569 eta = 0.;
570 }
571 return eta;
572}
573
574double L1CaloPedestalGenerator::IDphi(const Identifier& id, const CaloLVL1_ID* l1id) {
575 Identifier regId = l1id->region_id(id);
576
577 double phiMax = l1id->phi_max(regId);
578 int iphi = l1id->phi(id);
579
580 double phi = (iphi+0.5)*2*M_PI/(phiMax+1);
581
582 return phi;
583}
584

◆ findInternalTriggerTower() [2/2]

LVL1::InternalTriggerTower * L1CaloPedestalGenerator::findInternalTriggerTower ( double tt_phi,
double tt_eta,
unsigned int key,
bool bCreate = true )
private

Definition at line 373 of file L1CaloPedestalGenerator.cxx.

385 : AthAlgorithm(name, pSvcLocator), m_caloMgr(0), m_lvl1Helper(0), m_towerKey(0), m_IntTTContainer(0)
386{
387 declareProperty("TriggerTowerLocation", m_TTLocation = "LVL1TriggerTowers");
388 declareProperty("PedestalMean", m_pedMean = 10.);
389 declareProperty("PedestalRMS", m_pedRMS = 0.);
390 declareProperty("NSamples", m_nSamples = 5);
391}
392
394{
395}
396
397//-------------------------------------------
398// Initialize
399//-------------------------------------------
401{
402 ATH_MSG_INFO("From Initialize...");
404
405 // Retrieve CaloIdManager
406 sc = detStore()->retrieve(m_caloMgr);
407 if (sc.isFailure()) {
408 ATH_MSG_ERROR( "Unable to retrieve CaloIdManager from DetectorStore" );
409 return StatusCode::FAILURE;
410 }
411
412 m_lvl1Helper = m_caloMgr->getLVL1_ID();
413 if (!m_lvl1Helper) {
414 ATH_MSG_ERROR( "Could not access CaloLVL1_ID helper" );
415 return StatusCode::FAILURE;
416 }
417
418 m_towerKey = new LVL1::TriggerTowerKey();
419
420 return StatusCode::SUCCESS;
421}
422
423//----------------------------------------
424// Execute
425//----------------------------------------
427{
428 ATH_MSG_DEBUG("From Execute...");
429
431
432 m_IntTTContainer = new std::map<unsigned int, LVL1::InternalTriggerTower*>;
433
435 sc = evtStore()->record(VectorOfTTs, m_TTLocation);
436
437 if (sc.isSuccess()) ATH_MSG_DEBUG( "Stored TTs in TES at "<< m_TTLocation );
438 else {
439 ATH_MSG_ERROR( "failed to write TTs to TES at " << m_TTLocation );
440 return StatusCode::FAILURE;
441 }
442
443 //---
444 // Loop on all Trigger Towers to create the TT objects
445 // and store them into containers
446
447 std::vector<Identifier>::const_iterator tower_it = m_lvl1Helper->tower_begin();
448
449 // -- Loop on Trigger Tower offline Ids --
450 for(;tower_it!=m_lvl1Helper->tower_end();++tower_it) {
451 Identifier towerId = (*tower_it);
452
453 //---
454 // Check detector type
455 bool bIsTile = m_lvl1Helper->is_tile(towerId);
456 bool bIsHadronic = m_lvl1Helper->sampling(towerId); // check if tt is an HEC tt
457
458 //---
459 // Generate pedestal samples
460 std::vector<double> vnoise;
461 for(unsigned int sample=0;sample<m_nSamples;++sample) vnoise.push_back(CLHEP::RandGaussZiggurat::shoot(0.,m_pedRMS));
462
463 std::vector< std::vector<double> > vAutoCorrMatrix(m_nSamples, std::vector<double>(m_nSamples,0));
464 for(unsigned int sample=0;sample<m_nSamples;++sample) vAutoCorrMatrix[sample][sample] = 1;
465
466 std::vector<double> vsamples;
467 for(unsigned int sample=0;sample<m_nSamples;++sample) {
468 double noise = 0;
469 for(unsigned int jj=0;jj<m_nSamples;++jj) noise+= vAutoCorrMatrix[sample][jj]*vnoise[jj];
470 vsamples.push_back(m_pedMean + noise);
471 }
472
473 //---
474 // Seek for an existing or create a new InternalTriggerTower
475 LVL1::InternalTriggerTower* TT = findInternalTriggerTower(towerId);
476
477 if(bIsTile||bIsHadronic) TT->addHadAmps(vsamples);
478 else TT->addEMAmps(vsamples);
479
480 } //-- End Loop on Trigger Tower offline Ids --
481
482
483 //---
484 // Loop over Internal Trigger Tower and create fake TT with
485 // only the Digits parts filled
486
487 std::map<unsigned int, LVL1::InternalTriggerTower*>::const_iterator it = m_IntTTContainer->begin();
488 for(;it!=m_IntTTContainer->end();++it) {
489 double eta = it->second->eta();
490 double phi = it->second->phi();
491 unsigned int key = it->second->key();
492
493 std::vector<double> vEmAmps = it->second->EmAmps();
494 std::vector<int> emDigits(vEmAmps.size());
495 for (size_t i = 0; i < vEmAmps.size(); i++)
496 emDigits[i] = static_cast<int> (vEmAmps[i]);
497
498 std::vector<double> vHadAmps = it->second->HadAmps();
499 std::vector<int> hadDigits(vHadAmps.size());
500 for (size_t i = 0; i < vHadAmps.size(); i++)
501 hadDigits[i] = static_cast<int> (vHadAmps[i]);
502
503 //need to put some fake push back to be able to use TriggerTowers2Ntuple
504 // cause LVL1::TriggerTower::emEnergy() make a m_em_energy[m_em_peak];
505 // instead of using m_em_energy.at(m_em_peak);
506 std::vector<int> emEt; emEt.push_back(0);
507 std::vector<int> hadEt; hadEt.push_back(0);
508 std::vector<int> emBCID; emBCID.push_back(0);
509 std::vector<int> hadBCID; hadBCID.push_back(0);
510 std::vector<int> emExt; emExt.push_back(0);
511 std::vector<int> hadExt; hadExt.push_back(0);
512 int peak = 0;
513 int emADCPeak = 0;
514 int hadADCPeak = 0;
515
516 // Create TT
517 LVL1::TriggerTower* tower = new LVL1::TriggerTower(phi,eta,key,
518 emDigits, emEt, emExt, emBCID, 0, peak, emADCPeak,
519 hadDigits, hadEt, hadExt, hadBCID, 0, peak, hadADCPeak);
520
521 VectorOfTTs->push_back(tower);
522
523 } //-- End Loop on InternalTriggerTowers --
524
525 ATH_MSG_DEBUG( VectorOfTTs->size()<<" TTs have been generated");
526
527 sc = evtStore()->setConst(VectorOfTTs);
528 if (sc.isSuccess()) ATH_MSG_DEBUG( "TT container locked");
529 else {
530 ATH_MSG_ERROR( "failed to lock TT container");
531 return StatusCode::FAILURE;
532 }
533
534 it = m_IntTTContainer->begin();
535 for(;it!=m_IntTTContainer->end();++it) delete it->second;
536 delete m_IntTTContainer;
537
538 ATH_MSG_DEBUG("End of Execute...");
539 return StatusCode::SUCCESS;
540}
541
542//-----------------------------------------
543// Finalize
544//-----------------------------------------
546{
547 delete m_towerKey;
548
549 return StatusCode::SUCCESS;
550}
551
552LVL1::InternalTriggerTower* L1CaloPedestalGenerator::findInternalTriggerTower(const Identifier& towerId, bool bCreate) {
553 // Create tower key from towerId
554 double tower_eta = IDeta(towerId,m_lvl1Helper);
555 double tower_phi = IDphi(towerId,m_lvl1Helper);
556 unsigned int key = m_towerKey->ttKey(tower_phi,tower_eta);
557 double tt_phi = m_towerKey->phi();
558 double tt_eta = m_towerKey->eta();
559
560 return findInternalTriggerTower(tt_phi, tt_eta, key, bCreate);
561}
562
563LVL1::InternalTriggerTower* L1CaloPedestalGenerator::findInternalTriggerTower(double tt_phi, double tt_eta, unsigned int key, bool bCreate) {
564 std::map<unsigned int, LVL1::InternalTriggerTower*>::iterator it = m_IntTTContainer->find( key );
565 LVL1::InternalTriggerTower* TT = 0;
566 if (it == m_IntTTContainer->end()){
567 if(bCreate) {
568 // no TT yet. Create it!
569 TT = new LVL1::InternalTriggerTower(tt_phi,tt_eta, key);
570 m_IntTTContainer->insert(std::map<unsigned int, LVL1::InternalTriggerTower*>::value_type(key,TT)); //and put it in the map.
571 }
572 }else{
573 TT = (it->second);
574 } // end else
575 return TT;
576}
577
578double L1CaloPedestalGenerator::IDeta(const Identifier& id, const CaloLVL1_ID* l1id) {
579 int region = l1id->region(id);
580 int ieta = l1id->eta(id);
581 int sign = l1id->pos_neg_z(id);
582
583 double gran[4] = {0.1, 0.2, 0.1, 0.425};
584 double offset[4] = {0., 2.5, 3.1, 3.2};
585 double eta;
586
587 if (region>=0 && region<=3) {
588 eta = sign* ( ( (ieta+0.5) * gran[region] ) + offset[region] );
589 }
590 else {
591 eta = 0.;
592 }
593 return eta;
594}
595
596double L1CaloPedestalGenerator::IDphi(const Identifier& id, const CaloLVL1_ID* l1id) {
597 Identifier regId = l1id->region_id(id);
598
599 double phiMax = l1id->phi_max(regId);
600 int iphi = l1id->phi(id);
601
602 double phi = (iphi+0.5)*2*M_PI/(phiMax+1);
603
604 return phi;
605}
606

◆ IDeta()

double L1CaloPedestalGenerator::IDeta ( const Identifier & id,
const CaloLVL1_ID * l1id )
private

Definition at line 403 of file L1CaloPedestalGenerator.cxx.

415 : AthAlgorithm(name, pSvcLocator), m_caloMgr(0), m_lvl1Helper(0), m_towerKey(0), m_IntTTContainer(0)
416{
417 declareProperty("TriggerTowerLocation", m_TTLocation = "LVL1TriggerTowers");
418 declareProperty("PedestalMean", m_pedMean = 10.);
419 declareProperty("PedestalRMS", m_pedRMS = 0.);
420 declareProperty("NSamples", m_nSamples = 5);
421}
422
424{
425}
426
427//-------------------------------------------
428// Initialize
429//-------------------------------------------
431{
432 ATH_MSG_INFO("From Initialize...");
434
435 // Retrieve CaloIdManager
436 sc = detStore()->retrieve(m_caloMgr);
437 if (sc.isFailure()) {
438 ATH_MSG_ERROR( "Unable to retrieve CaloIdManager from DetectorStore" );
439 return StatusCode::FAILURE;
440 }
441
442 m_lvl1Helper = m_caloMgr->getLVL1_ID();
443 if (!m_lvl1Helper) {
444 ATH_MSG_ERROR( "Could not access CaloLVL1_ID helper" );
445 return StatusCode::FAILURE;
446 }
447
448 m_towerKey = new LVL1::TriggerTowerKey();
449
450 return StatusCode::SUCCESS;
451}
452
453//----------------------------------------
454// Execute
455//----------------------------------------
457{
458 ATH_MSG_DEBUG("From Execute...");
459
461
462 m_IntTTContainer = new std::map<unsigned int, LVL1::InternalTriggerTower*>;
463
465 sc = evtStore()->record(VectorOfTTs, m_TTLocation);
466
467 if (sc.isSuccess()) ATH_MSG_DEBUG( "Stored TTs in TES at "<< m_TTLocation );
468 else {
469 ATH_MSG_ERROR( "failed to write TTs to TES at " << m_TTLocation );
470 return StatusCode::FAILURE;
471 }
472
473 //---
474 // Loop on all Trigger Towers to create the TT objects
475 // and store them into containers
476
477 std::vector<Identifier>::const_iterator tower_it = m_lvl1Helper->tower_begin();
478
479 // -- Loop on Trigger Tower offline Ids --
480 for(;tower_it!=m_lvl1Helper->tower_end();++tower_it) {
481 Identifier towerId = (*tower_it);
482
483 //---
484 // Check detector type
485 bool bIsTile = m_lvl1Helper->is_tile(towerId);
486 bool bIsHadronic = m_lvl1Helper->sampling(towerId); // check if tt is an HEC tt
487
488 //---
489 // Generate pedestal samples
490 std::vector<double> vnoise;
491 for(unsigned int sample=0;sample<m_nSamples;++sample) vnoise.push_back(CLHEP::RandGaussZiggurat::shoot(0.,m_pedRMS));
492
493 std::vector< std::vector<double> > vAutoCorrMatrix(m_nSamples, std::vector<double>(m_nSamples,0));
494 for(unsigned int sample=0;sample<m_nSamples;++sample) vAutoCorrMatrix[sample][sample] = 1;
495
496 std::vector<double> vsamples;
497 for(unsigned int sample=0;sample<m_nSamples;++sample) {
498 double noise = 0;
499 for(unsigned int jj=0;jj<m_nSamples;++jj) noise+= vAutoCorrMatrix[sample][jj]*vnoise[jj];
500 vsamples.push_back(m_pedMean + noise);
501 }
502
503 //---
504 // Seek for an existing or create a new InternalTriggerTower
505 LVL1::InternalTriggerTower* TT = findInternalTriggerTower(towerId);
506
507 if(bIsTile||bIsHadronic) TT->addHadAmps(vsamples);
508 else TT->addEMAmps(vsamples);
509
510 } //-- End Loop on Trigger Tower offline Ids --
511
512
513 //---
514 // Loop over Internal Trigger Tower and create fake TT with
515 // only the Digits parts filled
516
517 std::map<unsigned int, LVL1::InternalTriggerTower*>::const_iterator it = m_IntTTContainer->begin();
518 for(;it!=m_IntTTContainer->end();++it) {
519 double eta = it->second->eta();
520 double phi = it->second->phi();
521 unsigned int key = it->second->key();
522
523 std::vector<double> vEmAmps = it->second->EmAmps();
524 std::vector<int> emDigits(vEmAmps.size());
525 for (size_t i = 0; i < vEmAmps.size(); i++)
526 emDigits[i] = static_cast<int> (vEmAmps[i]);
527
528 std::vector<double> vHadAmps = it->second->HadAmps();
529 std::vector<int> hadDigits(vHadAmps.size());
530 for (size_t i = 0; i < vHadAmps.size(); i++)
531 hadDigits[i] = static_cast<int> (vHadAmps[i]);
532
533 //need to put some fake push back to be able to use TriggerTowers2Ntuple
534 // cause LVL1::TriggerTower::emEnergy() make a m_em_energy[m_em_peak];
535 // instead of using m_em_energy.at(m_em_peak);
536 std::vector<int> emEt; emEt.push_back(0);
537 std::vector<int> hadEt; hadEt.push_back(0);
538 std::vector<int> emBCID; emBCID.push_back(0);
539 std::vector<int> hadBCID; hadBCID.push_back(0);
540 std::vector<int> emExt; emExt.push_back(0);
541 std::vector<int> hadExt; hadExt.push_back(0);
542 int peak = 0;
543 int emADCPeak = 0;
544 int hadADCPeak = 0;
545
546 // Create TT
547 LVL1::TriggerTower* tower = new LVL1::TriggerTower(phi,eta,key,
548 emDigits, emEt, emExt, emBCID, 0, peak, emADCPeak,
549 hadDigits, hadEt, hadExt, hadBCID, 0, peak, hadADCPeak);
550
551 VectorOfTTs->push_back(tower);
552
553 } //-- End Loop on InternalTriggerTowers --
554
555 ATH_MSG_DEBUG( VectorOfTTs->size()<<" TTs have been generated");
556
557 sc = evtStore()->setConst(VectorOfTTs);
558 if (sc.isSuccess()) ATH_MSG_DEBUG( "TT container locked");
559 else {
560 ATH_MSG_ERROR( "failed to lock TT container");
561 return StatusCode::FAILURE;
562 }
563
564 it = m_IntTTContainer->begin();
565 for(;it!=m_IntTTContainer->end();++it) delete it->second;
566 delete m_IntTTContainer;
567
568 ATH_MSG_DEBUG("End of Execute...");
569 return StatusCode::SUCCESS;
570}
571
572//-----------------------------------------
573// Finalize
574//-----------------------------------------
576{
577 delete m_towerKey;
578
579 return StatusCode::SUCCESS;
580}
581
582LVL1::InternalTriggerTower* L1CaloPedestalGenerator::findInternalTriggerTower(const Identifier& towerId, bool bCreate) {
583 // Create tower key from towerId
584 double tower_eta = IDeta(towerId,m_lvl1Helper);
585 double tower_phi = IDphi(towerId,m_lvl1Helper);
586 unsigned int key = m_towerKey->ttKey(tower_phi,tower_eta);
587 double tt_phi = m_towerKey->phi();
588 double tt_eta = m_towerKey->eta();
589
590 return findInternalTriggerTower(tt_phi, tt_eta, key, bCreate);
591}
592
593LVL1::InternalTriggerTower* L1CaloPedestalGenerator::findInternalTriggerTower(double tt_phi, double tt_eta, unsigned int key, bool bCreate) {
594 std::map<unsigned int, LVL1::InternalTriggerTower*>::iterator it = m_IntTTContainer->find( key );
595 LVL1::InternalTriggerTower* TT = 0;
596 if (it == m_IntTTContainer->end()){
597 if(bCreate) {
598 // no TT yet. Create it!
599 TT = new LVL1::InternalTriggerTower(tt_phi,tt_eta, key);
600 m_IntTTContainer->insert(std::map<unsigned int, LVL1::InternalTriggerTower*>::value_type(key,TT)); //and put it in the map.
601 }
602 }else{
603 TT = (it->second);
604 } // end else
605 return TT;
606}
607
608double L1CaloPedestalGenerator::IDeta(const Identifier& id, const CaloLVL1_ID* l1id) {
609 int region = l1id->region(id);
610 int ieta = l1id->eta(id);
611 int sign = l1id->pos_neg_z(id);
612
613 double gran[4] = {0.1, 0.2, 0.1, 0.425};
614 double offset[4] = {0., 2.5, 3.1, 3.2};
615 double eta;
616
617 if (region>=0 && region<=3) {
618 eta = sign* ( ( (ieta+0.5) * gran[region] ) + offset[region] );
619 }
620 else {
621 eta = 0.;
622 }
623 return eta;
624}
625
626double L1CaloPedestalGenerator::IDphi(const Identifier& id, const CaloLVL1_ID* l1id) {
627 Identifier regId = l1id->region_id(id);
628
629 double phiMax = l1id->phi_max(regId);
630 int iphi = l1id->phi(id);
631
632 double phi = (iphi+0.5)*2*M_PI/(phiMax+1);
633
634 return phi;
635}
636

◆ IDphi()

double L1CaloPedestalGenerator::IDphi ( const Identifier & id,
const CaloLVL1_ID * l1id )
private

Definition at line 439 of file L1CaloPedestalGenerator.cxx.

451 : AthAlgorithm(name, pSvcLocator), m_caloMgr(0), m_lvl1Helper(0), m_towerKey(0), m_IntTTContainer(0)
452{
453 declareProperty("TriggerTowerLocation", m_TTLocation = "LVL1TriggerTowers");
454 declareProperty("PedestalMean", m_pedMean = 10.);
455 declareProperty("PedestalRMS", m_pedRMS = 0.);
456 declareProperty("NSamples", m_nSamples = 5);
457}
458
460{
461}
462
463//-------------------------------------------
464// Initialize
465//-------------------------------------------
467{
468 ATH_MSG_INFO("From Initialize...");
470
471 // Retrieve CaloIdManager
472 sc = detStore()->retrieve(m_caloMgr);
473 if (sc.isFailure()) {
474 ATH_MSG_ERROR( "Unable to retrieve CaloIdManager from DetectorStore" );
475 return StatusCode::FAILURE;
476 }
477
478 m_lvl1Helper = m_caloMgr->getLVL1_ID();
479 if (!m_lvl1Helper) {
480 ATH_MSG_ERROR( "Could not access CaloLVL1_ID helper" );
481 return StatusCode::FAILURE;
482 }
483
484 m_towerKey = new LVL1::TriggerTowerKey();
485
486 return StatusCode::SUCCESS;
487}
488
489//----------------------------------------
490// Execute
491//----------------------------------------
493{
494 ATH_MSG_DEBUG("From Execute...");
495
497
498 m_IntTTContainer = new std::map<unsigned int, LVL1::InternalTriggerTower*>;
499
501 sc = evtStore()->record(VectorOfTTs, m_TTLocation);
502
503 if (sc.isSuccess()) ATH_MSG_DEBUG( "Stored TTs in TES at "<< m_TTLocation );
504 else {
505 ATH_MSG_ERROR( "failed to write TTs to TES at " << m_TTLocation );
506 return StatusCode::FAILURE;
507 }
508
509 //---
510 // Loop on all Trigger Towers to create the TT objects
511 // and store them into containers
512
513 std::vector<Identifier>::const_iterator tower_it = m_lvl1Helper->tower_begin();
514
515 // -- Loop on Trigger Tower offline Ids --
516 for(;tower_it!=m_lvl1Helper->tower_end();++tower_it) {
517 Identifier towerId = (*tower_it);
518
519 //---
520 // Check detector type
521 bool bIsTile = m_lvl1Helper->is_tile(towerId);
522 bool bIsHadronic = m_lvl1Helper->sampling(towerId); // check if tt is an HEC tt
523
524 //---
525 // Generate pedestal samples
526 std::vector<double> vnoise;
527 for(unsigned int sample=0;sample<m_nSamples;++sample) vnoise.push_back(CLHEP::RandGaussZiggurat::shoot(0.,m_pedRMS));
528
529 std::vector< std::vector<double> > vAutoCorrMatrix(m_nSamples, std::vector<double>(m_nSamples,0));
530 for(unsigned int sample=0;sample<m_nSamples;++sample) vAutoCorrMatrix[sample][sample] = 1;
531
532 std::vector<double> vsamples;
533 for(unsigned int sample=0;sample<m_nSamples;++sample) {
534 double noise = 0;
535 for(unsigned int jj=0;jj<m_nSamples;++jj) noise+= vAutoCorrMatrix[sample][jj]*vnoise[jj];
536 vsamples.push_back(m_pedMean + noise);
537 }
538
539 //---
540 // Seek for an existing or create a new InternalTriggerTower
541 LVL1::InternalTriggerTower* TT = findInternalTriggerTower(towerId);
542
543 if(bIsTile||bIsHadronic) TT->addHadAmps(vsamples);
544 else TT->addEMAmps(vsamples);
545
546 } //-- End Loop on Trigger Tower offline Ids --
547
548
549 //---
550 // Loop over Internal Trigger Tower and create fake TT with
551 // only the Digits parts filled
552
553 std::map<unsigned int, LVL1::InternalTriggerTower*>::const_iterator it = m_IntTTContainer->begin();
554 for(;it!=m_IntTTContainer->end();++it) {
555 double eta = it->second->eta();
556 double phi = it->second->phi();
557 unsigned int key = it->second->key();
558
559 std::vector<double> vEmAmps = it->second->EmAmps();
560 std::vector<int> emDigits(vEmAmps.size());
561 for (size_t i = 0; i < vEmAmps.size(); i++)
562 emDigits[i] = static_cast<int> (vEmAmps[i]);
563
564 std::vector<double> vHadAmps = it->second->HadAmps();
565 std::vector<int> hadDigits(vHadAmps.size());
566 for (size_t i = 0; i < vHadAmps.size(); i++)
567 hadDigits[i] = static_cast<int> (vHadAmps[i]);
568
569 //need to put some fake push back to be able to use TriggerTowers2Ntuple
570 // cause LVL1::TriggerTower::emEnergy() make a m_em_energy[m_em_peak];
571 // instead of using m_em_energy.at(m_em_peak);
572 std::vector<int> emEt; emEt.push_back(0);
573 std::vector<int> hadEt; hadEt.push_back(0);
574 std::vector<int> emBCID; emBCID.push_back(0);
575 std::vector<int> hadBCID; hadBCID.push_back(0);
576 std::vector<int> emExt; emExt.push_back(0);
577 std::vector<int> hadExt; hadExt.push_back(0);
578 int peak = 0;
579 int emADCPeak = 0;
580 int hadADCPeak = 0;
581
582 // Create TT
583 LVL1::TriggerTower* tower = new LVL1::TriggerTower(phi,eta,key,
584 emDigits, emEt, emExt, emBCID, 0, peak, emADCPeak,
585 hadDigits, hadEt, hadExt, hadBCID, 0, peak, hadADCPeak);
586
587 VectorOfTTs->push_back(tower);
588
589 } //-- End Loop on InternalTriggerTowers --
590
591 ATH_MSG_DEBUG( VectorOfTTs->size()<<" TTs have been generated");
592
593 sc = evtStore()->setConst(VectorOfTTs);
594 if (sc.isSuccess()) ATH_MSG_DEBUG( "TT container locked");
595 else {
596 ATH_MSG_ERROR( "failed to lock TT container");
597 return StatusCode::FAILURE;
598 }
599
600 it = m_IntTTContainer->begin();
601 for(;it!=m_IntTTContainer->end();++it) delete it->second;
602 delete m_IntTTContainer;
603
604 ATH_MSG_DEBUG("End of Execute...");
605 return StatusCode::SUCCESS;
606}
607
608//-----------------------------------------
609// Finalize
610//-----------------------------------------
612{
613 delete m_towerKey;
614
615 return StatusCode::SUCCESS;
616}
617
618LVL1::InternalTriggerTower* L1CaloPedestalGenerator::findInternalTriggerTower(const Identifier& towerId, bool bCreate) {
619 // Create tower key from towerId
620 double tower_eta = IDeta(towerId,m_lvl1Helper);
621 double tower_phi = IDphi(towerId,m_lvl1Helper);
622 unsigned int key = m_towerKey->ttKey(tower_phi,tower_eta);
623 double tt_phi = m_towerKey->phi();
624 double tt_eta = m_towerKey->eta();
625
626 return findInternalTriggerTower(tt_phi, tt_eta, key, bCreate);
627}
628
629LVL1::InternalTriggerTower* L1CaloPedestalGenerator::findInternalTriggerTower(double tt_phi, double tt_eta, unsigned int key, bool bCreate) {
630 std::map<unsigned int, LVL1::InternalTriggerTower*>::iterator it = m_IntTTContainer->find( key );
631 LVL1::InternalTriggerTower* TT = 0;
632 if (it == m_IntTTContainer->end()){
633 if(bCreate) {
634 // no TT yet. Create it!
635 TT = new LVL1::InternalTriggerTower(tt_phi,tt_eta, key);
636 m_IntTTContainer->insert(std::map<unsigned int, LVL1::InternalTriggerTower*>::value_type(key,TT)); //and put it in the map.
637 }
638 }else{
639 TT = (it->second);
640 } // end else
641 return TT;
642}
643
644double L1CaloPedestalGenerator::IDeta(const Identifier& id, const CaloLVL1_ID* l1id) {
645 int region = l1id->region(id);
646 int ieta = l1id->eta(id);
647 int sign = l1id->pos_neg_z(id);
648
649 double gran[4] = {0.1, 0.2, 0.1, 0.425};
650 double offset[4] = {0., 2.5, 3.1, 3.2};
651 double eta;
652
653 if (region>=0 && region<=3) {
654 eta = sign* ( ( (ieta+0.5) * gran[region] ) + offset[region] );
655 }
656 else {
657 eta = 0.;
658 }
659 return eta;
660}
661
662double L1CaloPedestalGenerator::IDphi(const Identifier& id, const CaloLVL1_ID* l1id) {
663 Identifier regId = l1id->region_id(id);
664
665 double phiMax = l1id->phi_max(regId);
666 int iphi = l1id->phi(id);
667
668 double phi = (iphi+0.5)*2*M_PI/(phiMax+1);
669
670 return phi;
671}
672

◆ initialize()

StatusCode L1CaloPedestalGenerator::initialize ( )
virtual

Definition at line 51 of file L1CaloPedestalGenerator.cxx.

55{
56 ATH_MSG_DEBUG("From Execute...");
57
59
60 m_IntTTContainer = new std::map<unsigned int, LVL1::InternalTriggerTower*>;
61
63 sc = evtStore()->record(VectorOfTTs, m_TTLocation);
64
65 if (sc.isSuccess()) ATH_MSG_DEBUG( "Stored TTs in TES at "<< m_TTLocation );
66 else {
67 ATH_MSG_ERROR( "failed to write TTs to TES at " << m_TTLocation );
68 return StatusCode::FAILURE;
69 }
70
71 //---
72 // Loop on all Trigger Towers to create the TT objects
73 // and store them into containers
74
75 std::vector<Identifier>::const_iterator tower_it = m_lvl1Helper->tower_begin();
76
77 // -- Loop on Trigger Tower offline Ids --
78 for(;tower_it!=m_lvl1Helper->tower_end();++tower_it) {
79 Identifier towerId = (*tower_it);
80
81 //---
82 // Check detector type
83 bool bIsTile = m_lvl1Helper->is_tile(towerId);
84 bool bIsHadronic = m_lvl1Helper->sampling(towerId); // check if tt is an HEC tt
85
86 //---
87 // Generate pedestal samples
88 std::vector<double> vnoise;
89 for(unsigned int sample=0;sample<m_nSamples;++sample) vnoise.push_back(CLHEP::RandGaussZiggurat::shoot(0.,m_pedRMS));
90
91 std::vector< std::vector<double> > vAutoCorrMatrix(m_nSamples, std::vector<double>(m_nSamples,0));
92 for(unsigned int sample=0;sample<m_nSamples;++sample) vAutoCorrMatrix[sample][sample] = 1;
93
94 std::vector<double> vsamples;

◆ inputHandles()

virtual std::vector< Gaudi::DataHandle * > AthCommonDataStore< AthCommonMsg< Algorithm > >::inputHandles ( ) const
overridevirtualinherited

Return this algorithm's input handles.

We override this to include handle instances from key arrays if they have not yet been declared. See comments on updateVHKA.

◆ msg()

MsgStream & AthCommonMsg< Algorithm >::msg ( ) const
inlineinherited

Definition at line 24 of file AthCommonMsg.h.

24 {
25 return this->msgStream();
26 }

◆ msgLvl()

bool AthCommonMsg< Algorithm >::msgLvl ( const MSG::Level lvl) const
inlineinherited

Definition at line 30 of file AthCommonMsg.h.

30 {
31 return this->msgLevel(lvl);
32 }

◆ outputHandles()

virtual std::vector< Gaudi::DataHandle * > AthCommonDataStore< AthCommonMsg< Algorithm > >::outputHandles ( ) const
overridevirtualinherited

Return this algorithm's output handles.

We override this to include handle instances from key arrays if they have not yet been declared. See comments on updateVHKA.

◆ renounce()

std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > AthCommonDataStore< AthCommonMsg< Algorithm > >::renounce ( T & h)
inlineprotectedinherited

Definition at line 380 of file AthCommonDataStore.h.

381 {
382 h.renounce();
384 }
std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > renounce(T &h)

◆ renounceArray()

void AthCommonDataStore< AthCommonMsg< Algorithm > >::renounceArray ( SG::VarHandleKeyArray & handlesArray)
inlineprotectedinherited

remove all handles from I/O resolution

Definition at line 364 of file AthCommonDataStore.h.

364 {
366 }

◆ sysInitialize()

StatusCode AthAlgorithm::sysInitialize ( )
overridevirtualinherited

Override sysInitialize.

Override sysInitialize from the base class.

Loop through all output handles, and if they're WriteCondHandles, automatically register them and this Algorithm with the CondSvc

Scan through all outputHandles, and if they're WriteCondHandles, register them with the CondSvc

Reimplemented from AthCommonDataStore< AthCommonMsg< Algorithm > >.

Reimplemented in AthAnalysisAlgorithm, AthFilterAlgorithm, AthHistogramAlgorithm, and PyAthena::Alg.

Definition at line 66 of file AthAlgorithm.cxx.

66 {
68
69 if (sc.isFailure()) {
70 return sc;
71 }
72 ServiceHandle<ICondSvc> cs("CondSvc",name());
73 for (auto h : outputHandles()) {
74 if (h->isCondition() && h->mode() == Gaudi::DataHandle::Writer) {
75 // do this inside the loop so we don't create the CondSvc until needed
76 if ( cs.retrieve().isFailure() ) {
77 ATH_MSG_WARNING("no CondSvc found: won't autoreg WriteCondHandles");
78 return StatusCode::SUCCESS;
79 }
80 if (cs->regHandle(this,*h).isFailure()) {
81 sc = StatusCode::FAILURE;
82 ATH_MSG_ERROR("unable to register WriteCondHandle " << h->fullKey()
83 << " with CondSvc");
84 }
85 }
86 }
87 return sc;
88}
#define ATH_MSG_WARNING(x)
virtual StatusCode sysInitialize() override
Override sysInitialize.
AthCommonDataStore(const std::string &name, T... args)
virtual std::vector< Gaudi::DataHandle * > outputHandles() const override

◆ sysStart()

virtual StatusCode AthCommonDataStore< AthCommonMsg< Algorithm > >::sysStart ( )
overridevirtualinherited

Handle START transition.

We override this in order to make sure that conditions handle keys can cache a pointer to the conditions container.

◆ updateVHKA()

void AthCommonDataStore< AthCommonMsg< Algorithm > >::updateVHKA ( Gaudi::Details::PropertyBase & )
inlineinherited

Definition at line 308 of file AthCommonDataStore.h.

308 {
309 // debug() << "updateVHKA for property " << p.name() << " " << p.toString()
310 // << " size: " << m_vhka.size() << endmsg;
311 for (auto &a : m_vhka) {
313 for (auto k : keys) {
314 k->setOwner(this);
315 }
316 }
317 }
std::vector< SG::VarHandleKeyArray * > m_vhka

Member Data Documentation

◆ m_caloMgr

const CaloIdManager* L1CaloPedestalGenerator::m_caloMgr
private

Definition at line 40 of file L1CaloPedestalGenerator.h.

◆ m_detStore

StoreGateSvc_t AthCommonDataStore< AthCommonMsg< Algorithm > >::m_detStore
privateinherited

Pointer to StoreGate (detector store by default)

Definition at line 393 of file AthCommonDataStore.h.

◆ m_evtStore

StoreGateSvc_t AthCommonDataStore< AthCommonMsg< Algorithm > >::m_evtStore
privateinherited

Pointer to StoreGate (event store by default)

Definition at line 390 of file AthCommonDataStore.h.

◆ m_extendedExtraObjects

DataObjIDColl AthAlgorithm::m_extendedExtraObjects
privateinherited

Definition at line 79 of file AthAlgorithm.h.

◆ m_IntTTContainer

std::map<unsigned int, LVL1::InternalTriggerTower*>* L1CaloPedestalGenerator::m_IntTTContainer
private

Definition at line 55 of file L1CaloPedestalGenerator.h.

◆ m_lvl1Helper

const CaloLVL1_ID* L1CaloPedestalGenerator::m_lvl1Helper
private

Definition at line 43 of file L1CaloPedestalGenerator.h.

◆ m_nSamples

unsigned int L1CaloPedestalGenerator::m_nSamples
private

Definition at line 50 of file L1CaloPedestalGenerator.h.

◆ m_pedMean

double L1CaloPedestalGenerator::m_pedMean
private

Definition at line 48 of file L1CaloPedestalGenerator.h.

◆ m_pedRMS

double L1CaloPedestalGenerator::m_pedRMS
private

Definition at line 49 of file L1CaloPedestalGenerator.h.

◆ m_towerKey

LVL1::TriggerTowerKey* L1CaloPedestalGenerator::m_towerKey
private

Definition at line 53 of file L1CaloPedestalGenerator.h.

◆ m_TTLocation

std::string L1CaloPedestalGenerator::m_TTLocation
private

Definition at line 46 of file L1CaloPedestalGenerator.h.

◆ m_varHandleArraysDeclared

bool AthCommonDataStore< AthCommonMsg< Algorithm > >::m_varHandleArraysDeclared
privateinherited

Definition at line 399 of file AthCommonDataStore.h.

◆ m_vhka

std::vector<SG::VarHandleKeyArray*> AthCommonDataStore< AthCommonMsg< Algorithm > >::m_vhka
privateinherited

Definition at line 398 of file AthCommonDataStore.h.


The documentation for this class was generated from the following files: