ATLAS Offline Software
Loading...
Searching...
No Matches
CaloCellRandomizer.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
3*/
4
5// ****************************************************************************************
6// Randomize calo cell energy according to CaloNoise
7//
8// D. Varouchas
9//
10// ****************************************************************************************
11
12#include "CaloCellRandomizer.h"
13#include "CaloEvent/CaloCell.h"
14#include "CaloDetDescr/CaloDetDescrElement.h"
17#include "GaudiKernel/ThreadLocalContext.h"
18#include "CLHEP/Random/Randomize.h"
19
20using CLHEP::RandGauss;
21
22
23// ======================================================
24// Constructor
25
27 const std::string& type,
28 const std::string& name,
29 const IInterface* parent)
30 : CaloCellCorrection(type, name, parent),
32 m_athRNGSvc ("AthRNGSvc", name),
33 m_randomEngine (nullptr)
34{
35 declareInterface<CaloCellCorrection>(this);
36 // declareProperty("SampleNums",m_sampleNums);
37 declareProperty("DoRandomSampleMin",m_corrSampleMin);
38 declareProperty("DoRandomSampleMax",m_corrSampleMax);
39 declareProperty("RandomiseGroupedSampleCells",m_GaussRandGroupedSamples);
40 declareProperty("DoGaussRandomization",m_GaussRand);
41 declareProperty("DoShiftedGaussRandomization",m_GaussRandShifted);
42 declareProperty("FractionOfSigmaNoiseInShifting",m_fractionSigma);
43
44 declareProperty("DoShiftedGaussRandomizationCustomisedInCalo",m_GaussRandShifted_Custom);
45 declareProperty("CustomShiftEMB",m_shift_EMB);
46 declareProperty("CustomShiftEMEC",m_shift_EMEC);
47 declareProperty("CustomShiftHEC",m_shift_HEC);
48 declareProperty("CustomShiftTileBar",m_shift_TileBar);
49 declareProperty("CustomShiftTileGap",m_shift_TileGap);
50 declareProperty("CustomShiftTileExt",m_shift_TileExt);
51 declareProperty("CustomShiftFCAL",m_shift_FCAL);
52 declareProperty("AthRNGSvc", m_athRNGSvc);
53 declareProperty("RandomStream", m_randomStream = "CaloCellRandomizer");
54}
55
56//========================================================
57// Initialize
58
60{
61 ATH_MSG_INFO( " in CaloCellRandomizer::initialize() " );
62 ATH_CHECK( m_caloNoiseKey.initialize() );
63 ATH_MSG_INFO( "Noise Tool retrieved" );
64 ATH_MSG_INFO( "CaloCellRandomizer initialize() end" );
65 ATH_CHECK( m_athRNGSvc.retrieve() );
66 m_randomEngine = m_athRNGSvc->getEngine (this, m_randomStream);
67 if (!m_randomEngine) {
68 ATH_MSG_ERROR("Could not get random number engine from AthRNGSvc. Abort.");
69 return StatusCode::FAILURE;
70 }
71 return StatusCode::SUCCESS;
72}
73
74
75// ============================================================================
76
78 const EventContext& ctx) const
79{
80 CLHEP::HepRandomEngine* engine = m_randomEngine->getEngine (ctx);
81
82 int sampl = 0;
83 float Gauss = 0;
84 float GaussShifted = 0;
85
86 const CaloDetDescrElement* caloDDE = theCell->caloDDE();
87 sampl=caloDDE->getSampling();
88
89 //CaloNoise
91 double SigmaNoise = caloNoise->getNoise(theCell->ID(), theCell->gain());
92
93
94 Gauss = RandGauss::shoot(engine, 0.,1.);
95
96 GaussShifted = Gauss+m_fractionSigma;
97
98
99 if( m_GaussRand ){
100 setenergy(theCell,(Gauss*SigmaNoise));
101 }
102
103
105 // setenergy(theCell,(GaussShifted));
106 setenergy(theCell,(GaussShifted*SigmaNoise));
107 }
108
109
111 if (sampl<4){
112 GaussShifted = RandGauss::shoot(engine, m_shift_EMB*SigmaNoise,SigmaNoise);
113 setenergy(theCell,(GaussShifted));
114 }
115 if (sampl>3 && sampl<8){
116 GaussShifted = RandGauss::shoot(engine, m_shift_EMEC*SigmaNoise,SigmaNoise);
117 setenergy(theCell,(GaussShifted));
118 }
119 if (sampl>7 && sampl<12){
120 GaussShifted = RandGauss::shoot(engine, m_shift_HEC*SigmaNoise,SigmaNoise);
121 setenergy(theCell,(GaussShifted));
122 }
123 if (sampl>11 && sampl<15){
124 GaussShifted = RandGauss::shoot(engine, m_shift_TileBar*SigmaNoise,SigmaNoise);
125 setenergy(theCell,(GaussShifted));
126 }
127 if (sampl>14 && sampl<18){
128 GaussShifted = RandGauss::shoot(engine, m_shift_TileGap*SigmaNoise,SigmaNoise);
129 setenergy(theCell,(GaussShifted));
130 }
131 if (sampl>17 && sampl<21){
132 GaussShifted = RandGauss::shoot(engine, m_shift_TileExt*SigmaNoise,SigmaNoise);
133 setenergy(theCell,(GaussShifted));
134 }
135 if (sampl>20 && sampl<24){
136 GaussShifted = RandGauss::shoot(engine, m_shift_FCAL*SigmaNoise,SigmaNoise);
137 setenergy(theCell,(GaussShifted));
138 }
139
140 }
141
142
144 if(sampl>m_corrSampleMin && sampl<m_corrSampleMax){
145 setenergy(theCell,(Gauss*SigmaNoise));
146 }
147 }
148
149
150 //check if cells were masked before from tile reco alg, so to remove them, Tile Case only
151 // const TileCell* aTileCell = dynamic_cast<const TileCell*> (theCell);
152 //if CaloNoise big values means we have bad cells (for tile when badcell is not applicalble). get ride of these cells
153 if ( (sampl>11 && sampl<21) && SigmaNoise>999){
154 setenergy(theCell,0);
155 }
156
157
158}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_INFO(x)
Property holding a SG store/key/clid from which a ReadHandle is made.
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
static void setenergy(CaloCell *lar_cell, float energy)
ServiceHandle< IAthRNGSvc > m_athRNGSvc
virtual void MakeCorrection(CaloCell *theCell, const EventContext &ctx) const override
virtual StatusCode initialize() override
ATHRNG::RNGWrapper * m_randomEngine
CaloCellRandomizer(const std::string &type, const std::string &name, const IInterface *parent)
SG::ReadCondHandleKey< CaloNoise > m_caloNoiseKey
Data object for each calorimeter readout cell.
Definition CaloCell.h:57
const CaloDetDescrElement * caloDDE() const
get pointer to CaloDetDescrElement (data member)
Definition CaloCell.h:321
CaloGain::CaloGain gain() const
get gain (data member )
Definition CaloCell.h:361
Identifier ID() const
get ID (from cached data member) non-virtual and inline for fast access
Definition CaloCell.h:295
This class groups all DetDescr information related to a CaloCell.
CaloCell_ID::CaloSample getSampling() const
cell sampling