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

#include <TBCellNoiseCorrection.h>

Inheritance diagram for TBCellNoiseCorrection:
Collaboration diagram for TBCellNoiseCorrection:

Public Member Functions

 TBCellNoiseCorrection (const std::string &type, const std::string &name, const IInterface *parent)
virtual ~TBCellNoiseCorrection ()
virtual StatusCode initialize () override
virtual StatusCode finalize () override
void MakeCorrection (CaloCell *theCell, const EventContext &ctx) const override
virtual void handle (const Incident &) override
virtual StatusCode execute (CaloCellContainer *cellCollection, const EventContext &ctx) const
 AthAlgTool (const std::string &type, const std::string &name, const IInterface *parent)
 Constructor with parameters:
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 sysInitialize () override
 Perform system initialization for an algorithm.
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

Static Public Member Functions

static const InterfaceID & interfaceID ()

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.

Static Protected Member Functions

static void setenergy (CaloCell *lar_cell, float energy)
static void addenergy (CaloCell *lar_cell, float energy)
static void scaleenergy (CaloCell *lar_cell, float scale)

Private Types

typedef ServiceHandle< StoreGateSvcStoreGateSvc_t

Private Member Functions

Gaudi::Details::PropertyBase & declareGaudiProperty (Gaudi::Property< T, V, H > &hndl, const SG::VarHandleKeyType &)
 specialization for handling Gaudi::Property<SG::VarHandleKey>

Private Attributes

bool m_noise_correction
std::vector< std::string > m_noise_file
ServiceHandle< IAthRNGSvcm_rndmSvc { this, "RndmSvc", "AthRNGSvc", "" }
ATHRNG::RNGWrapperm_engine
TChain * m_tree
float m_xcryo
float m_ytable
float m_energy
std::vector< unsigned int > * m_cell_id
std::vector< float > * m_cell_energy
unsigned int m_entries
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

Definition at line 26 of file TBCellNoiseCorrection.h.

Member Typedef Documentation

◆ StoreGateSvc_t

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

Definition at line 388 of file AthCommonDataStore.h.

Constructor & Destructor Documentation

◆ TBCellNoiseCorrection()

TBCellNoiseCorrection::TBCellNoiseCorrection ( const std::string & type,
const std::string & name,
const IInterface * parent )

Definition at line 22 of file TBCellNoiseCorrection.cxx.

25 : CaloCellCorrection(type, name, parent),
27 m_engine(0),
28 m_tree(0), m_xcryo(0.), m_ytable(0.), m_energy(-1.), m_cell_id(0), m_cell_energy(0),m_entries(0)
29 //m_myevtnum(-1)
30{
31 declareInterface<CaloCellCorrection>(this);
32 declareProperty("NoiseFile", m_noise_file);
34 declareProperty("NoiseX", m_xcryo);
35 declareProperty("NoiseY", m_ytable);
36 declareProperty("NoiseE", m_energy);
37}
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
std::vector< std::string > m_noise_file
ATHRNG::RNGWrapper * m_engine
std::vector< float > * m_cell_energy
std::vector< unsigned int > * m_cell_id

◆ ~TBCellNoiseCorrection()

TBCellNoiseCorrection::~TBCellNoiseCorrection ( )
virtual

Definition at line 41 of file TBCellNoiseCorrection.cxx.

42{ }

Member Function Documentation

◆ addenergy()

void CaloCellCorrection::addenergy ( CaloCell * lar_cell,
float energy )
staticprotectedinherited

Definition at line 86 of file CaloCellCorrection.cxx.

87{
88 theCell->addEnergy( energy );
89}

◆ AthAlgTool()

AthAlgTool::AthAlgTool ( const std::string & type,
const std::string & name,
const IInterface * parent )
inherited

Constructor with parameters:

Definition at line 31 of file AthAlgTool.cxx.

◆ declareGaudiProperty()

Gaudi::Details::PropertyBase & AthCommonDataStore< AthCommonMsg< AlgTool > >::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 }

◆ declareProperty()

Gaudi::Details::PropertyBase & AthCommonDataStore< AthCommonMsg< AlgTool > >::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< AlgTool > >::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< AlgTool > >::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 CaloCellCorrection::execute ( CaloCellContainer * cellCollection,
const EventContext & ctx ) const
virtualinherited

Definition at line 50 of file CaloCellCorrection.cxx.

52{
53
54 ATH_MSG_DEBUG("Executing CaloCellCorrection");
55
56 if (!cellCollection) {
57 ATH_MSG_ERROR( "Cell Correction tool receives invalid cell Collection" );
58 return StatusCode::FAILURE;
59 }
60
61 // Loop over all the CaloCell Objects and call Make Correction.
62 // Note that this is the base class of all the concrete correction
63 // classes which implement a Make Correction method.
64
65 for (CaloCell* cell : *cellCollection) {
66 MakeCorrection ( cell, ctx );
67 }
68
69 // Done, Return success
70
71 return StatusCode::SUCCESS;
72
73}
#define ATH_MSG_ERROR(x)
#define ATH_MSG_DEBUG(x)
virtual void MakeCorrection(CaloCell *cellCollection, const EventContext &ctx) const =0

◆ extraDeps_update_handler()

void AthCommonDataStore< AthCommonMsg< AlgTool > >::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

◆ finalize()

StatusCode TBCellNoiseCorrection::finalize ( )
overridevirtual

Definition at line 124 of file TBCellNoiseCorrection.cxx.

125{
126// m_root->Close();
127// m_root = NULL;
128 if(m_tree) m_tree->Delete() ;
129// m_cell_id = NULL;
130// m_cell_energy = NULL;
131
132 return StatusCode::SUCCESS;
133}

◆ handle()

void TBCellNoiseCorrection::handle ( const Incident & inc)
overridevirtual

Definition at line 164 of file TBCellNoiseCorrection.cxx.

164 {
165 ATH_MSG_DEBUG( " Handle BeginEvent " );
166
167 if ( inc.type() == "BeginEvent") {
168 m_engine->setSeed ("TBCellNoseCorrection", inc.context());
169 unsigned int random = int(RandFlat::shoot(m_engine->getEngine (inc.context()), 0., m_entries-1.));
170 ATH_MSG_DEBUG( "Reading noise event: "<<random );
171 m_tree->GetEntry(random);
172 unsigned int size = m_cell_id->size();
173 unsigned int sizee = m_cell_energy->size();
174 if(size != sizee) {
175 ATH_MSG_ERROR( "Not equal size of noise vectors !!!! Something wrong !!!" );
176 }
177 }
178}

◆ initialize()

StatusCode TBCellNoiseCorrection::initialize ( )
overridevirtual

Incident Service

Definition at line 45 of file TBCellNoiseCorrection.cxx.

46{
47 ATH_MSG_DEBUG( " TBCellNoiseCorrection initialization " );
48
49 // RandomNumbers
50 ATH_CHECK( m_rndmSvc.retrieve() );
51 m_engine = m_rndmSvc->getEngine(this, "TB_NOISE");
52
53 if(m_energy > 0.) { // Do we have run parameters (x,y,energy) ?
54 ATH_MSG_DEBUG( " Trying to patch the noise file name " );
55 std::string fname = PathResolver::find_file ("xcryo_ytable.txt", "DATAPATH");
56 std::ifstream xfile;
57 xfile.open(fname.c_str());
58 if(!xfile.good()){
59 ATH_MSG_FATAL( "Could not open file xcryo_ytable.txt" );
60 return StatusCode::FAILURE;
61 }
62 int runnumber;
63 float x,y,en=-1;
64 std::string line;
65 while (getline(xfile, line, '\n')) {
66 std::istringstream buf(line);
67 buf >> runnumber >> x >> y >> en;
68 if(en < 0. || !(x == m_xcryo && y == m_ytable && en == m_energy)) continue;
69 break;
70 }
71 if(en < 0.) {
72 ATH_MSG_FATAL( " Do not have X: "<<m_xcryo<<" Y: "<<m_ytable<< " E: "<<m_energy<<" in xcryo_ytable.txt" );
73 return StatusCode::FAILURE;
74 }
75 // we have run number - let's change the file name (and take only one):
76 ATH_MSG_DEBUG( "Found run number: "<<runnumber );
77 unsigned pos = m_noise_file[0].find_last_of("0123456789");
78 std::ostringstream buf;
80 m_noise_file[0].replace(pos-3,4,buf.str());
81 ATH_MSG_DEBUG( "patched name: "<<m_noise_file[0].c_str() );
82 }
83
84 // Open file and get Tree
85 /*
86 m_root = new TFile(m_noise_file.c_str(),"READ");
87 if(!m_root->IsOpen()){
88 ATH_MSG_FATAL( "Could not open root file: "<<m_noise_file );
89 return StatusCode::FAILURE;
90 }
91 m_tree = (TTree*) m_root->Get("NoiseTree");
92 if(!m_tree) {
93 ATH_MSG_FATAL( "No NoiseTree in root file: "<<m_noise_file );
94 return StatusCode::FAILURE;
95 }
96 */
97 // Make a chain
98 m_tree = new TChain("NoiseTree");
99 for(unsigned int l=0; l<m_noise_file.size(); ++l) {
100 m_tree->AddFile(m_noise_file[l].c_str());
101 }
102 m_entries = m_tree->GetEntries();
103 if(m_entries < 100) {
104 ATH_MSG_FATAL( "Noise chain has less then 100 events !!!!" );
105 return StatusCode::FAILURE;
106 }
107 m_tree->SetBranchAddress("cell_id", &m_cell_id);
108 m_tree->SetBranchAddress("cell_ener", &m_cell_energy);
109 ATH_MSG_DEBUG(" Got NoiseTree with "<<m_entries<<" entries" );
110
112 ServiceHandle<IIncidentSvc> pIncSvc("IncidentSvc", name());
113 ATH_CHECK( pIncSvc.retrieve() );
114
115 //start listening to "BeginEvent"
116 const int PRIORITY = 100;
117 pIncSvc->addListener(this, "BeginEvent", PRIORITY);
118
119 ATH_MSG_DEBUG( " TBCellNoiseCorrection initialization finished" );
120
121 return StatusCode::SUCCESS;
122}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_FATAL(x)
#define y
#define x
static std::string find_file(const std::string &logical_file_name, const std::string &search_path)
ServiceHandle< IAthRNGSvc > m_rndmSvc
static std::vector< uint32_t > runnumber
Definition iLumiCalc.h:37
l
Printing final latex table to .tex output file.

◆ inputHandles()

virtual std::vector< Gaudi::DataHandle * > AthCommonDataStore< AthCommonMsg< AlgTool > >::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.

◆ interfaceID()

const InterfaceID & CaloCellCorrection::interfaceID ( )
inlinestaticinherited

Definition at line 51 of file CaloCellCorrection.h.

static const InterfaceID IID_CaloCellCorrection("CaloCellCorrection", 1, 0)

◆ MakeCorrection()

void TBCellNoiseCorrection::MakeCorrection ( CaloCell * theCell,
const EventContext & ctx ) const
overridevirtual

Implements CaloCellCorrection.

Definition at line 136 of file TBCellNoiseCorrection.cxx.

138{
139
140// const CaloDetDescrElement* elt = theCell->caloDDE();
141
142 if (m_noise_correction) {
143 unsigned int cid = theCell->ID().get_identifier32().get_compact();
144 double e = theCell->energy();
145 unsigned int size = m_cell_id->size();
146 unsigned int i;
147 // removing this, should use the BadChannel now
148 // if(cid == 810049536) e = 0.; // Not working cell in data
149 for(i = 0; i < size; ++i) {
150 if(std::as_const(m_cell_id)->at(i) == cid) {
151 e += std::as_const(m_cell_energy)->at(i);
152 break;
153 }
154 }
155 if(i == size) {
156 ATH_MSG_ERROR( "Could not find a noise value for cell: "<<std::hex<<cid<<std::dec );
157 }
158
159 theCell->setEnergy(e);
160 }
161
162}
double energy() const
get energy (data member)
Definition CaloCell.h:327
virtual void setEnergy(float energy)
set energy
Definition CaloCell.h:472
Identifier ID() const
get ID (from cached data member) non-virtual and inline for fast access
Definition CaloCell.h:295
value_type get_compact() const
Get the compact id.
Identifier32 get_identifier32() const
Get the 32-bit version Identifier, will be invalid if >32 bits needed.

◆ msg()

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

Definition at line 24 of file AthCommonMsg.h.

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

◆ msgLvl()

bool AthCommonMsg< AlgTool >::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< AlgTool > >::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< AlgTool > >::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< AlgTool > >::renounceArray ( SG::VarHandleKeyArray & handlesArray)
inlineprotectedinherited

remove all handles from I/O resolution

Definition at line 364 of file AthCommonDataStore.h.

364 {
366 }

◆ scaleenergy()

void CaloCellCorrection::scaleenergy ( CaloCell * lar_cell,
float scale )
staticprotectedinherited

Definition at line 91 of file CaloCellCorrection.cxx.

92{
93 theCell->scaleEnergy( scale );
94}

◆ setenergy()

void CaloCellCorrection::setenergy ( CaloCell * lar_cell,
float energy )
staticprotectedinherited

Definition at line 81 of file CaloCellCorrection.cxx.

82{
83 theCell->setEnergy( energy );
84}

◆ sysInitialize()

virtual StatusCode AthCommonDataStore< AthCommonMsg< AlgTool > >::sysInitialize ( )
overridevirtualinherited

Perform system initialization for an algorithm.

We override this to declare all the elements of handle key arrays at the end of initialization. See comments on updateVHKA.

Reimplemented in asg::AsgMetadataTool, AthCheckedComponent< AthAlgTool >, AthCheckedComponent<::AthAlgTool >, and DerivationFramework::CfAthAlgTool.

◆ sysStart()

virtual StatusCode AthCommonDataStore< AthCommonMsg< AlgTool > >::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< AlgTool > >::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_cell_energy

std::vector<float>* TBCellNoiseCorrection::m_cell_energy
private

Definition at line 59 of file TBCellNoiseCorrection.h.

◆ m_cell_id

std::vector<unsigned int>* TBCellNoiseCorrection::m_cell_id
private

Definition at line 58 of file TBCellNoiseCorrection.h.

◆ m_detStore

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

Pointer to StoreGate (detector store by default)

Definition at line 393 of file AthCommonDataStore.h.

◆ m_energy

float TBCellNoiseCorrection::m_energy
private

Definition at line 56 of file TBCellNoiseCorrection.h.

◆ m_engine

ATHRNG::RNGWrapper* TBCellNoiseCorrection::m_engine
private

Definition at line 51 of file TBCellNoiseCorrection.h.

◆ m_entries

unsigned int TBCellNoiseCorrection::m_entries
private

Definition at line 60 of file TBCellNoiseCorrection.h.

◆ m_evtStore

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

Pointer to StoreGate (event store by default)

Definition at line 390 of file AthCommonDataStore.h.

◆ m_noise_correction

bool TBCellNoiseCorrection::m_noise_correction
private

Definition at line 45 of file TBCellNoiseCorrection.h.

◆ m_noise_file

std::vector<std::string> TBCellNoiseCorrection::m_noise_file
private

Definition at line 46 of file TBCellNoiseCorrection.h.

◆ m_rndmSvc

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

Definition at line 49 of file TBCellNoiseCorrection.h.

50{ this, "RndmSvc", "AthRNGSvc", "" };

◆ m_tree

TChain* TBCellNoiseCorrection::m_tree
private

Definition at line 53 of file TBCellNoiseCorrection.h.

◆ m_varHandleArraysDeclared

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

Definition at line 399 of file AthCommonDataStore.h.

◆ m_vhka

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

Definition at line 398 of file AthCommonDataStore.h.

◆ m_xcryo

float TBCellNoiseCorrection::m_xcryo
private

Definition at line 54 of file TBCellNoiseCorrection.h.

◆ m_ytable

float TBCellNoiseCorrection::m_ytable
private

Definition at line 55 of file TBCellNoiseCorrection.h.


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