ATLAS Offline Software
H1WeightToolCSC12Generic.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 /***********************************************************************
6 Filename : H1WeightToolCSC12Generic.cxx
7 Author : Walter Lampl
8 Created : Feb 2007
9 
10 ***********************************************************************/
11 
13 #include "CaloEvent/CaloCell.h"
14 //#include "CaloEvent/CaloSampling.h"
15 
16 #include "CLHEP/Units/SystemOfUnits.h"
17 //#include "GaudiKernel/Service.h"
18 //#include "GaudiKernel/MsgStream.h"
19 
20 #include <cmath>
21 #include <string>
22 
23 using CLHEP::millimeter;
24 using CLHEP::GeV;
25 
28  return StatusCode::SUCCESS;
29 }
30 
31 
32 double H1WeightToolCSC12Generic::etCell(const CaloCell* thisCell, double weight)
33 {
34 
35  double etcell = weight * thisCell->et() * wtCell(thisCell);
36  return etcell;
37 
38 }
39 
40 
41 double H1WeightToolCSC12Generic::wtCell(const CaloCell* thisCell) const
42 {
43  Context myctx = context (Gaudi::Hive::currentContext());
44 
45  const double mm3 = millimeter*millimeter*millimeter;
46  const double log2 = 0.69314718056;
47  const double inv_log2 = 1. / log2;
48 
49  int dim=m_wtEMB1(myctx).size(); //FIXME: Assume same size for all m_wtXXXXX
50 
51  // Process cell
52 
53  double ecell = thisCell->e();
54  double etaa = fabs( thisCell->eta() );
55  double vol = thisCell->caloDDE()->volume();
56  const CaloSampling::CaloSample s = thisCell->caloDDE()->getSampling();//CaloSampling::getSampling( *thisCell );
57 
58  int iET=0;
59  if( fabs(ecell) > 0 && vol > 0 ) {
60  iET=static_cast<int>(log(fabs(ecell)/fabs(vol)*(mm3/GeV))*inv_log2+26);
61  if(iET<0) iET=0;
62  if(iET >= dim) iET = dim-1;
63  } else {
64  iET=-1;
65  }
66 
67  double wt = 0;
68 
69  switch ( s ) {
70 
71  // Presampler
73  wt = m_wtEMB0(myctx)[0];
74  break;
75 
77  wt = m_wtEME0(myctx)[0];
78  break;
79 
80  // First EM layer
81 
82  case CaloSampling::EMB1:
83  wt = m_wtEMB0(myctx)[1];
84  break;
85 
86  case CaloSampling::EME1:
87  wt = m_wtEME0(myctx)[1];
88  break;
89 
90 
91  // EM Barrel
92  case CaloSampling::EMB2:
93  case CaloSampling::EMB3:
94  if(iET >= 0 && etaa < 0.8) wt = m_wtEMB1(myctx)[iET];
95  if(iET >= 0 && etaa >= 0.8) wt = m_wtEMB2(myctx)[iET];
96  break;
97 
98  // EM Endcap
99  case CaloSampling::EME2:
100  case CaloSampling::EME3:
101  if(iET >= 0 && etaa < 2.5) wt = m_wtEME1(myctx)[iET];
102  if(iET >= 0 && etaa >= 2.5) wt = m_wtEME2(myctx)[iET];
103  break;
104 
105  // Tile
109  if(iET >= 0) wt = m_wtTile1(myctx)[iET];
110  break;
111 
115  if(iET >= 0) wt = m_wtTile2(myctx)[iET];
116  break;
117 
118  // Had endcap
119  case CaloSampling::HEC0:
120  case CaloSampling::HEC1:
121  case CaloSampling::HEC2:
122  case CaloSampling::HEC3:
123  if(iET>=0 && etaa<2.5) wt = m_wtHec1(myctx)[iET];
124  if(iET>=0 && etaa>=2.5) wt = m_wtHec2(myctx)[iET];
125  break;
126 
127  // FCal
128  case CaloSampling::FCAL0:
129  if(iET >= 0) wt = m_wtFCal1(myctx)[iET];
130  break;
131 
132  case CaloSampling::FCAL1:
133  case CaloSampling::FCAL2:
134  if(iET >= 0) wt = m_wtFCal2(myctx)[iET];
135  break;
136 
137  // Gap calorimeter
139  wt = m_wtGap(myctx);
140  break;
141 
142  // Gap scintillators
145  wt = m_wtScint(myctx);
146  break;
147 
148  case CaloSampling::MINIFCAL0:
149  case CaloSampling::MINIFCAL1:
150  case CaloSampling::MINIFCAL2:
151  case CaloSampling::MINIFCAL3:
153  break;
154 
155  } // end switch
156 
157  return wt;
158 
159 }
160 
161 
162 double H1WeightToolCSC12Generic::etCryo(double etAccb3, double etTile1)
163 {
164 
165  if( etAccb3*etTile1 > 0 ) {
166  return wtCryo() * sqrt( etAccb3*etTile1 );
167  } else {
168  return 0;
169  }
170 
171 }
172 
174 {
175  Context myctx = context (Gaudi::Hive::currentContext());
176  return m_wtCryo(myctx);
177 }
178 
179 // Jet Energy scale
180 
181 double H1WeightToolCSC12Generic::jetScale(double e, double eta)
182 {
183  Context myctx = context (Gaudi::Hive::currentContext());
184  const CxxUtils::Array<2> etaFit = m_etaFit(myctx);
185 
186  int nEtaBins=etaFit.size();
187  if (nEtaBins==0)
188  return 1.0;
189 
190  int ieta = static_cast<int>(fabs(eta)*(1./0.10));
191  if (ieta>=nEtaBins) ieta=nEtaBins-1;
192  //if(ieta > 49) ieta = 49;
193  double ptlog = log(fabs(e)/(cosh(eta)*GeV));
194  if(ptlog < 2.3) ptlog = 2.3;
195  if(ptlog > etaFit[ieta][4]) ptlog = etaFit[ieta][4];
196  double func = etaFit[ieta][0] + etaFit[ieta][1]/ptlog
197  + etaFit[ieta][2]/(ptlog*ptlog)
198  + etaFit[ieta][3]/(ptlog*ptlog*ptlog);
199 
200  return 1./func;
201 
202 }
AllowedVariables::e
e
Definition: AsgElectronSelectorTool.cxx:37
GetLCDefs::Unknown
@ Unknown
Definition: GetLCDefs.h:21
H1WeightToolCSC12Generic::m_wtGap
Constant< float > m_wtGap
Definition: H1WeightToolCSC12Generic.h:55
GeV
#define GeV
Definition: PhysicsAnalysis/TauID/TauAnalysisTools/Root/HelperFunctions.cxx:17
H1WeightToolCSC12Generic::wtCell
virtual double wtCell(const CaloCell *thisCell) const override
Definition: H1WeightToolCSC12Generic.cxx:41
python.SystemOfUnits.s
int s
Definition: SystemOfUnits.py:131
CaloCell_ID_FCS::TileExt2
@ TileExt2
Definition: FastCaloSim_CaloCell_ID.h:39
yodamerge_tmp.dim
dim
Definition: yodamerge_tmp.py:239
constants.EMB1
int EMB1
Definition: Calorimeter/CaloClusterCorrection/python/constants.py:53
TCS::KFMET::nEtaBins
constexpr unsigned nEtaBins
Definition: KalmanMETCorrectionConstants.h:18
eta
Scalar eta() const
pseudorapidity method
Definition: AmgMatrixBasePlugin.h:83
CaloCell_ID_FCS::TileExt0
@ TileExt0
Definition: FastCaloSim_CaloCell_ID.h:37
CaloCell_ID_FCS::TileBar1
@ TileBar1
Definition: FastCaloSim_CaloCell_ID.h:32
initialize
void initialize()
Definition: run_EoverP.cxx:894
H1WeightToolCSC12Generic::m_wtCryo
Constant< float > m_wtCryo
Definition: H1WeightToolCSC12Generic.h:57
CxxUtils::Array::size
unsigned int size(unsigned int dim=0) const
Return the size of the array along one dimension.
H1WeightToolCSC12Generic::m_etaFit
Constant< CxxUtils::Array< 2 > > m_etaFit
Definition: H1WeightToolCSC12Generic.h:58
H1WeightToolCSC12Generic::etCell
virtual double etCell(const CaloCell *thisCell, double weight) override
Definition: H1WeightToolCSC12Generic.cxx:32
H1WeightToolCSC12Generic::m_wtTile1
Constant< CxxUtils::Array< 1 > > m_wtTile1
Definition: H1WeightToolCSC12Generic.h:49
CaloCell_ID_FCS::FCAL1
@ FCAL1
Definition: FastCaloSim_CaloCell_ID.h:41
CaloCell.h
CaloCell::e
virtual double e() const override final
get energy (data member) (synonym to method energy()
Definition: CaloCell.h:317
H1WeightToolCSC12Generic::jetScale
virtual double jetScale(double e, double eta) override
Definition: H1WeightToolCSC12Generic.cxx:181
CaloCell_ID_FCS::HEC2
@ HEC2
Definition: FastCaloSim_CaloCell_ID.h:29
H1WeightToolCSC12Generic::m_wtEME1
Constant< CxxUtils::Array< 1 > > m_wtEME1
Definition: H1WeightToolCSC12Generic.h:47
CaloCell_ID_FCS::TileGap3
@ TileGap3
Definition: FastCaloSim_CaloCell_ID.h:36
H1WeightToolCSC12Generic::m_wtHec2
Constant< CxxUtils::Array< 1 > > m_wtHec2
Definition: H1WeightToolCSC12Generic.h:52
H1WeightToolCSC12Generic::m_wtEMB1
Constant< CxxUtils::Array< 1 > > m_wtEMB1
Definition: H1WeightToolCSC12Generic.h:45
python.SystemOfUnits.mm3
int mm3
Definition: SystemOfUnits.py:85
H1WeightToolCSC12Generic::m_wtEME2
Constant< CxxUtils::Array< 1 > > m_wtEME2
Definition: H1WeightToolCSC12Generic.h:48
dqt_zlumi_pandas.weight
int weight
Definition: dqt_zlumi_pandas.py:189
H1WeightToolCSC12Generic::initialize
virtual StatusCode initialize() override
Definition: H1WeightToolCSC12Generic.cxx:26
python.SystemOfUnits.millimeter
int millimeter
Definition: SystemOfUnits.py:53
CaloCell_ID_FCS::HEC1
@ HEC1
Definition: FastCaloSim_CaloCell_ID.h:28
constants.EMB2
int EMB2
Definition: Calorimeter/CaloClusterCorrection/python/constants.py:54
H1WeightToolCSC12Generic::wtCryo
virtual double wtCryo() override
Definition: H1WeightToolCSC12Generic.cxx:173
H1WeightToolCSC12Generic::m_wtEMB0
Constant< CxxUtils::Array< 1 > > m_wtEMB0
Definition: H1WeightToolCSC12Generic.h:43
CaloSampling::CaloSample
CaloSample
Definition: Calorimeter/CaloGeoHelpers/CaloGeoHelpers/CaloSampling.h:22
CaloCell_ID_FCS::TileBar0
@ TileBar0
Definition: FastCaloSim_CaloCell_ID.h:31
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
CaloCell_ID_FCS::TileGap2
@ TileGap2
Definition: FastCaloSim_CaloCell_ID.h:35
CaloCell::caloDDE
const CaloDetDescrElement * caloDDE() const
get pointer to CaloDetDescrElement (data member)
Definition: CaloCell.h:305
CxxUtils::Array< 2 >
CaloCell::et
virtual double et() const override final
get et
Definition: CaloCell.h:407
constants.EME1
int EME1
Definition: Calorimeter/CaloClusterCorrection/python/constants.py:55
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
H1WeightToolCSC12Generic::m_wtEMB2
Constant< CxxUtils::Array< 1 > > m_wtEMB2
Definition: H1WeightToolCSC12Generic.h:46
H1WeightToolCSC12Generic.h
CaloCell_ID_FCS::TileGap1
@ TileGap1
Definition: FastCaloSim_CaloCell_ID.h:34
H1WeightToolCSC12Generic::m_wtFCal1
Constant< CxxUtils::Array< 1 > > m_wtFCal1
Definition: H1WeightToolCSC12Generic.h:53
CaloDetDescrElement::volume
float volume() const
cell volume
Definition: Calorimeter/CaloDetDescr/CaloDetDescr/CaloDetDescrElement.h:381
CaloCell_ID_FCS::TileExt1
@ TileExt1
Definition: FastCaloSim_CaloCell_ID.h:38
CaloCell_ID_FCS::EME3
@ EME3
Definition: FastCaloSim_CaloCell_ID.h:26
H1WeightToolCSC12Generic::m_wtTile2
Constant< CxxUtils::Array< 1 > > m_wtTile2
Definition: H1WeightToolCSC12Generic.h:50
CaloCell_ID_FCS::HEC0
@ HEC0
Definition: FastCaloSim_CaloCell_ID.h:27
CaloCell
Data object for each calorimeter readout cell.
Definition: CaloCell.h:57
CaloDetDescrElement::getSampling
CaloCell_ID::CaloSample getSampling() const
cell sampling
Definition: Calorimeter/CaloDetDescr/CaloDetDescr/CaloDetDescrElement.h:395
CaloCell_ID_FCS::PreSamplerE
@ PreSamplerE
Definition: FastCaloSim_CaloCell_ID.h:23
H1WeightToolCSC12Generic::etCryo
virtual double etCryo(double etAccb3, double etTile1) override
Definition: H1WeightToolCSC12Generic.cxx:162
CaloCell_ID_FCS::PreSamplerB
@ PreSamplerB
Definition: FastCaloSim_CaloCell_ID.h:19
python.CaloCondTools.log
log
Definition: CaloCondTools.py:20
CaloCell_ID_FCS::FCAL2
@ FCAL2
Definition: FastCaloSim_CaloCell_ID.h:42
H1WeightToolCSC12Generic::m_wtHec1
Constant< CxxUtils::Array< 1 > > m_wtHec1
Definition: H1WeightToolCSC12Generic.h:51
CaloCell_ID_FCS::HEC3
@ HEC3
Definition: FastCaloSim_CaloCell_ID.h:30
H1WeightToolCSC12Generic::m_wtEME0
Constant< CxxUtils::Array< 1 > > m_wtEME0
Definition: H1WeightToolCSC12Generic.h:44
CaloCell_ID_FCS::FCAL0
@ FCAL0
Definition: FastCaloSim_CaloCell_ID.h:40
CaloCell_ID_FCS::EMB3
@ EMB3
Definition: FastCaloSim_CaloCell_ID.h:22
CaloCell_ID_FCS::TileBar2
@ TileBar2
Definition: FastCaloSim_CaloCell_ID.h:33
constants.EME2
int EME2
Definition: Calorimeter/CaloClusterCorrection/python/constants.py:56
CaloCell::eta
virtual double eta() const override final
get eta (through CaloDetDescrElement)
Definition: CaloCell.h:366
H1WeightToolCSC12Generic::m_wtScint
Constant< float > m_wtScint
Definition: H1WeightToolCSC12Generic.h:56
H1WeightToolCSC12Generic::m_wtFCal2
Constant< CxxUtils::Array< 1 > > m_wtFCal2
Definition: H1WeightToolCSC12Generic.h:54