ATLAS Offline Software
LArNonLinearity.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 /********************************************************************
6 
7 NAME: LArNonLinearity.cxx
8 PACKAGE: offline/LArCalorimeter/LArCellRec
9 
10 AUTHORS: G.Unal
11 CREATED: August 2003
12 
13 PURPOSE: non linearity if only linear calibration fit is used
14  (for EM barrel)
15 
16 ********************************************************************/
17 
18 // INCLUDE LAr header files:
19 #include "LArNonLinearity.h"
21 
22 #include "CaloEvent/CaloCell.h"
23 // Units
24 #include "CLHEP/Units/SystemOfUnits.h"
25 
26 #include <cmath>
27 #include <iostream>
28 
29 using CLHEP::GeV;
30 
31 // Constants needed for computation of the Energy Scale:
32 
33  const double LArNonLinearity::m_etatrans = 0.8;
34 
35 // index: 0 = front A, 1 = front B, 2=middble A, 3=middle B
36 // 4 = back A and 5 = back B (A=eta<0.8 and B=eta>0.8)
37 
38 // transitions energies
39 
40  const double LArNonLinearity::m_etrans[6] =
41  {6.5*GeV, 6.0*GeV, 26.0*GeV, 50.0*GeV, 17.5*GeV, 25.0*GeV };
42 
43 // maximum energy validity
44 
45  const double LArNonLinearity::m_emax[6] =
46  {60.*GeV, 60.*GeV, 260.*GeV, 500.*GeV, 170.*GeV, 250.*GeV};
47 
48 // parameters of polynomial fit. These values give residuals in GeV
49  const double LArNonLinearity::m_p0[6][2] =
50  {{0.44e-2, 0.158}, {0.691e-3, 0.121}, // front
51  {0.166e-1, 0.226}, {0.347e-1, 0.753}, // middle
52  {0.869e-2, 0.269}, {0.422e-1, 0.3598}}; // back
53  const double LArNonLinearity::m_p1[6][2] =
54  {{-0.16e-2/GeV, -0.159e-1/GeV}, {+0.379e-2/GeV, -0.100e-1/GeV}, // front
55  {-0.105e-2/GeV, -0.1559e-2/GeV}, {-0.605e-2/GeV, -0.452e-2/GeV}, // middle
56  {+0.248e-2/GeV, -0.252e-2/GeV}, {-0.690e-2/GeV, -0.881e-2/GeV}}; // back
57  const double LArNonLinearity::m_p2[6][2] =
58  {{-0.45e-3/(GeV*GeV),+0.406e-3/(GeV*GeV)},
59  {-0.252e-2/(GeV*GeV), +0.159e-3/(GeV*GeV)}, // front
60  {-0.208e-3/(GeV*GeV),-0.263e-4/(GeV*GeV)},
61  {-0.66e-3/(GeV*GeV), -0.146e-4/(GeV*GeV)}, // middle
62  {-0.920e-3/(GeV*GeV),-0.645e-4/(GeV*GeV)},
63  {+0.689e-4/(GeV*GeV), +0.4773e-4/(GeV*GeV)}}; // back
64  const double LArNonLinearity::m_p3[6][2] =
65  {{0.1037e-3/(GeV*GeV*GeV), -0.291e-5/(GeV*GeV*GeV)},
66  {+0.332e-3/(GeV*GeV*GeV), -0.309e-7/(GeV*GeV*GeV)}, // front
67  {+0.100e-4/(GeV*GeV*GeV), +0.1300e-6/(GeV*GeV*GeV)},
68  {+0.115e-4/(GeV*GeV*GeV), +0.545e-7/(GeV*GeV*GeV)}, // middle
69  {0.472e-4/(GeV*GeV*GeV), 0.459e-6/(GeV*GeV*GeV)},
70  {0.759e-5/(GeV*GeV*GeV), -0.543e-7/(GeV*GeV*GeV)}}; // back
71 
72 // Constructor:
73 
74 LArNonLinearity::LArNonLinearity(const std::string& type, const std::string& name,
75  const IInterface* parent)
76  : CaloCellCorrection(type, name, parent),m_emID(nullptr),m_hecID(nullptr),m_fcalID(nullptr)
77 
78 {
79 
80 }
81 
82 
84 {
85  ATH_MSG_INFO( name() );
86  ATH_MSG_INFO( " Initialize LArNonLinearity " );
87 
88  // pointer to identifier helpers:
89  ATH_CHECK(detStore()->retrieve(m_emID,"LArEM_ID"));
90  ATH_CHECK(detStore()->retrieve(m_hecID,"HEC_ID"));
91  ATH_CHECK(detStore()->retrieve(m_fcalID,"FCAL_ID"));
92 
93  return StatusCode::SUCCESS;
94 }
95 
96 // Desctructor
97 
99 = default;
100 
101 // MakeCorrection: This is called with a pointer to the Cell Object.
102 
104  const EventContext& /*ctx*/) const
105 {
106  float eta = theCell->eta();
107  Identifier id = theCell->ID();
108 
109  double corr=0. ; // corr=residual to subtract to
110  // true energy
111  double energy = theCell->energy();
112 
113  if(m_emID->is_lar_em(id) &&
114  m_emID->is_em_barrel(id) ) // only for barrel EM Calorimeter:
115  {
116 
117  int sampling = m_emID->sampling(id);
118  if (sampling >0 && sampling < 4) // nothing for barrel PS
119  {
120 
121 // check A or B electrodes
122  int ielec;
123  if (fabs(eta)<m_etatrans) {ielec=0;}
124  else {ielec=1;}
125  int index =ielec + 2*(sampling-1); // from 0 to 5 (see above)
126 
127  if (energy>2.*GeV)
128  ATH_MSG_DEBUG( " energy " << energy
129  << " sampling " << sampling
130  << " eta " << eta
131  << " index " << index );
132 
133 // check E less than E maximum validity
134 
135  if (energy < m_emax[index] )
136  {
137 // energy range (high gain or middle gain)
138  int irange;
139  if (energy < m_etrans[index] ) {irange=0;}
140  else {irange=1;}
141 
142  if (irange==0)
143  { // ignore offset for high gain
144  corr = m_p1[index][irange] *energy
145  +m_p2[index][irange] *energy*energy
146  +m_p3[index][irange] *energy*energy*energy;
147  } else
148  {
149  corr = m_p0[index][irange]
150  +m_p1[index][irange] *energy
151  +m_p2[index][irange] *energy*energy
152  +m_p3[index][irange] *energy*energy*energy;
153  }
154 // convert corr back to GEV
155  corr = corr*GeV;
156 
157  if (energy>2.*GeV)
158  {
159  ATH_MSG_DEBUG( " pol coeff " << m_p0[index][irange] << " "
160  << m_p1[index][irange] << " " << m_p2[index][irange] << " "
161  << m_p3[index][irange] );
162  ATH_MSG_DEBUG( "energy,index,corr = " << energy << " " << index << " " << corr );
163  }
164 
165  }
166  }
167  } // ENDIF for barrel EM
168 
169 
170 // Correct cell energy
171 
172  setenergy(theCell, energy-corr);
173 
174 }
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
LArNonLinearity::m_emax
static const double m_emax[6]
Definition: LArNonLinearity.h:49
LArNonLinearity::m_p3
static const double m_p3[6][2]
Definition: LArNonLinearity.h:53
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
LArNonLinearity::m_p2
static const double m_p2[6][2]
Definition: LArNonLinearity.h:52
eta
Scalar eta() const
pseudorapidity method
Definition: AmgMatrixBasePlugin.h:79
LArNonLinearity.h
index
Definition: index.py:1
CaloCellCorrection
Definition: CaloCellCorrection.h:51
LArNonLinearity::m_p0
static const double m_p0[6][2]
Definition: LArNonLinearity.h:50
CaloCell.h
LArEM_Base_ID::sampling
int sampling(const Identifier id) const
return sampling according to :
LArNonLinearity::m_fcalID
const LArFCAL_ID * m_fcalID
Definition: LArNonLinearity.h:58
AthCommonDataStore< AthCommonMsg< AlgTool > >::detStore
const ServiceHandle< StoreGateSvc > & detStore() const
The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.
Definition: AthCommonDataStore.h:95
CaloCell::energy
double energy() const
get energy (data member)
Definition: CaloCell.h:311
ParticleGun_FastCalo_ChargeFlip_Config.energy
energy
Definition: ParticleGun_FastCalo_ChargeFlip_Config.py:78
Identifier
Definition: DetectorDescription/Identifier/Identifier/Identifier.h:32
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
LArNonLinearity::MakeCorrection
virtual void MakeCorrection(CaloCell *theCell, const EventContext &ctx) const override
Definition: LArNonLinearity.cxx:103
test_pyathena.parent
parent
Definition: test_pyathena.py:15
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
LArNonLinearity::~LArNonLinearity
virtual ~LArNonLinearity()
LArNonLinearity::initialize
virtual StatusCode initialize() override
Definition: LArNonLinearity.cxx:83
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
CaloCell::ID
Identifier ID() const
get ID (from cached data member) non-virtual and inline for fast access
Definition: CaloCell.h:279
LArNonLinearity::m_emID
const LArEM_ID * m_emID
Definition: LArNonLinearity.h:56
DeMoScan.index
string index
Definition: DeMoScan.py:362
DiTauMassTools::MaxHistStrategyV2::e
e
Definition: PhysicsAnalysis/TauID/DiTauMassTools/DiTauMassTools/HelperFunctions.h:26
CaloCell
Data object for each calorimeter readout cell.
Definition: CaloCell.h:57
LArEM_Base_ID::is_em_barrel
bool is_em_barrel(const Identifier id) const
test if the id belongs to the EM barrel
CaloCellCorrection::setenergy
static void setenergy(CaloCell *lar_cell, float energy)
Definition: CaloCellCorrection.cxx:89
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
CaloIdManager.h
LArNonLinearity::m_p1
static const double m_p1[6][2]
Definition: LArNonLinearity.h:51
LArNonLinearity::m_hecID
const LArHEC_ID * m_hecID
Definition: LArNonLinearity.h:57
LArNonLinearity::m_etrans
static const double m_etrans[6]
Definition: LArNonLinearity.h:48
LArNonLinearity::m_etatrans
static const double m_etatrans
Definition: LArNonLinearity.h:47
GeV
#define GeV
Definition: CaloTransverseBalanceVecMon.cxx:30
AtlasDetectorID::is_lar_em
bool is_lar_em(Identifier id) const
Definition: AtlasDetectorID.h:818
LArNonLinearity::LArNonLinearity
LArNonLinearity(const std::string &type, const std::string &name, const IInterface *parent)
Definition: LArNonLinearity.cxx:74
CaloCell::eta
virtual double eta() const override final
get eta (through CaloDetDescrElement)
Definition: CaloCell.h:366