CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
EcalBasicClusterLocalContCorrection Class Reference
Inheritance diagram for EcalBasicClusterLocalContCorrection:
EcalClusterFunctionBaseClass

Public Member Functions

void checkInit () const
 
 EcalBasicClusterLocalContCorrection (const edm::ParameterSet &)
 
const EcalClusterLocalContCorrParametersgetParameters () const
 
float getValue (const reco::BasicCluster &, const EcalRecHitCollection &) const override
 
float getValue (const reco::SuperCluster &, const int mode) const override
 
void init (const edm::EventSetup &es) override
 
- Public Member Functions inherited from EcalClusterFunctionBaseClass
virtual float getValue (const reco::CaloCluster &) const
 
virtual ~EcalClusterFunctionBaseClass ()
 

Private Member Functions

int getEcalModule (DetId id) const
 

Private Attributes

const edm::EventSetupes_
 
edm::ESHandle< EcalClusterLocalContCorrParametersesParams_
 
const EcalClusterLocalContCorrParametersparams_
 

Detailed Description

Function to correct em object energy for energy not contained in a 5x5 crystal area in the calorimeter

$Id: EcalBasicClusterLocalContCorrection.h $Date: $Revision:

Author
Federico Ferri, CEA Saclay, November 2008

Definition at line 22 of file EcalBasicClusterLocalContCorrection.cc.

Constructor & Destructor Documentation

◆ EcalBasicClusterLocalContCorrection()

EcalBasicClusterLocalContCorrection::EcalBasicClusterLocalContCorrection ( const edm::ParameterSet )
inline

Definition at line 24 of file EcalBasicClusterLocalContCorrection.cc.

24 {};

Member Function Documentation

◆ checkInit()

void EcalBasicClusterLocalContCorrection::checkInit ( ) const

Definition at line 52 of file EcalBasicClusterLocalContCorrection.cc.

52  {
53  if (!params_) {
54  // non-initialized function parameters: throw exception
55  throw cms::Exception("EcalBasicClusterLocalContCorrection::checkInit()")
56  << "Trying to access an uninitialized crack correction function.\n"
57  "Please call `init( edm::EventSetup &)' before any use of the function.\n";
58  }
59 }

References Exception, and params_.

◆ getEcalModule()

int EcalBasicClusterLocalContCorrection::getEcalModule ( DetId  id) const
private

Definition at line 199 of file EcalBasicClusterLocalContCorrection.cc.

199  {
200  int mod = 0;
201  int ieta = (EBDetId(id)).ieta();
202 
203  if (fabs(ieta) <= 25)
204  mod = 0;
205  if (fabs(ieta) > 25 && fabs(ieta) <= 45)
206  mod = 1;
207  if (fabs(ieta) > 45 && fabs(ieta) <= 65)
208  mod = 2;
209  if (fabs(ieta) > 65 && fabs(ieta) <= 85)
210  mod = 3;
211 
212  return (mod);
213 }

References LEDCalibrationChannels::ieta, and mod().

◆ getParameters()

const EcalClusterLocalContCorrParameters* EcalBasicClusterLocalContCorrection::getParameters ( ) const
inline

Definition at line 27 of file EcalBasicClusterLocalContCorrection.cc.

27 { return params_; }

References params_.

◆ getValue() [1/2]

float EcalBasicClusterLocalContCorrection::getValue ( const reco::BasicCluster basicCluster,
const EcalRecHitCollection recHit 
) const
overridevirtual

Implements EcalClusterFunctionBaseClass.

Definition at line 69 of file EcalBasicClusterLocalContCorrection.cc.

70  {
71  checkInit();
72 
73  // number of parameters needed by this parametrization
74  size_t nparams = 24;
75 
76  //correction factor to be returned, and to be calculated in this present function:
77  double correction_factor = 1.;
78  double fetacor = 1.; //eta dependent part of the correction factor
79  double fphicor = 1.; //phi dependent part of the correction factor
80 
81  //--------------if barrel calculate local position wrt xtal center -------------------
82  edm::ESHandle<CaloGeometry> caloGeometry;
83  es_->get<CaloGeometryRecord>().get(caloGeometry);
84  const CaloSubdetectorGeometry *geom = caloGeometry->getSubdetectorGeometry(DetId::Ecal, EcalBarrel); //EcalBarrel = 1
85 
86  const math::XYZPoint &position_ = basicCluster.position();
87  double Theta = -position_.theta() + 0.5 * M_PI;
88  double Eta = position_.eta();
89  double Phi = TVector2::Phi_mpi_pi(position_.phi());
90 
91  //Calculate expected depth of the maximum shower from energy (like in PositionCalc::Calculate_Location()):
92  // The parameters X0 and T0 are hardcoded here because these values were used to calculate the corrections:
93  const float X0 = 0.89;
94  const float T0 = 7.4;
95  double depth = X0 * (T0 + log(basicCluster.energy()));
96 
97  //search which crystal is closest to the cluster position and call it crystalseed:
98  //std::vector<DetId> crystals_vector = *scRef.getHitsByDetId(); //deprecated
99  std::vector<std::pair<DetId, float> > crystals_vector = basicCluster.hitsAndFractions();
100  float dphimin = 999.;
101  float detamin = 999.;
102  int ietaclosest = 0;
103  int iphiclosest = 0;
104 
105  for (unsigned int icry = 0; icry != crystals_vector.size(); ++icry) {
106  EBDetId crystal(crystals_vector[icry].first);
107  auto cell = geom->getGeometry(crystal); // problema qui
108  GlobalPoint center_pos = cell->getPosition(depth);
109  double EtaCentr = center_pos.eta();
110  double PhiCentr = TVector2::Phi_mpi_pi(center_pos.phi());
111  if (std::abs(EtaCentr - Eta) < detamin) {
112  detamin = std::abs(EtaCentr - Eta);
113  ietaclosest = crystal.ieta();
114  }
115  if (std::abs(TVector2::Phi_mpi_pi(PhiCentr - Phi)) < dphimin) {
116  dphimin = std::abs(TVector2::Phi_mpi_pi(PhiCentr - Phi));
117  iphiclosest = crystal.iphi();
118  }
119  }
120 
121  EBDetId crystalseed(ietaclosest, iphiclosest);
122 
123  // Get center cell position from shower depth
124  auto cell = geom->getGeometry(crystalseed);
125  GlobalPoint center_pos = cell->getPosition(depth);
126 
127  //PHI
128  double PhiCentr = TVector2::Phi_mpi_pi(center_pos.phi());
129  double PhiWidth = (M_PI / 180.);
130  double PhiCry = (TVector2::Phi_mpi_pi(Phi - PhiCentr)) / PhiWidth;
131  if (PhiCry > 0.5)
132  PhiCry = 0.5;
133  if (PhiCry < -0.5)
134  PhiCry = -0.5;
135  //flip to take into account ECAL barrel symmetries:
136  if (ietaclosest < 0)
137  PhiCry *= -1.;
138 
139  //ETA
140  double ThetaCentr = -center_pos.theta() + 0.5 * M_PI;
141  double ThetaWidth = (M_PI / 180.) * std::cos(ThetaCentr);
142  double EtaCry = (Theta - ThetaCentr) / ThetaWidth;
143  if (EtaCry > 0.5)
144  EtaCry = 0.5;
145  if (EtaCry < -0.5)
146  EtaCry = -0.5;
147  //flip to take into account ECAL barrel symmetries:
148  if (ietaclosest < 0)
149  EtaCry *= -1.;
150 
151  //-------------- end calculate local position -------------
152 
153  size_t payloadsize = params_->params().size();
154 
155  if (payloadsize < nparams)
156  edm::LogError("Invalid Payload") << "Parametrization requires " << nparams << " parameters but only " << payloadsize
157  << " are found in DB. Perhaps incompatible Global Tag" << std::endl;
158 
159  if (payloadsize > nparams)
160  edm::LogWarning("Size mismatch ") << "Parametrization requires " << nparams << " parameters but " << payloadsize
161  << " are found in DB. Perhaps incompatible Global Tag" << std::endl;
162 
163  std::pair<double, double> localPosition(EtaCry, PhiCry);
164 
165  //--- local cluster coordinates
166  float localEta = localPosition.first;
167  float localPhi = localPosition.second;
168 
169  //--- ecal module
170  int imod = getEcalModule(basicCluster.seed());
171 
172  //-- corrections parameters
173  float pe[3], pp[3];
174  pe[0] = (params_->params())[0 + imod * 3];
175  pe[1] = (params_->params())[1 + imod * 3];
176  pe[2] = (params_->params())[2 + imod * 3];
177  pp[0] = (params_->params())[12 + imod * 3];
178  pp[1] = (params_->params())[13 + imod * 3];
179  pp[2] = (params_->params())[14 + imod * 3];
180 
181  //--- correction vs local eta
182  fetacor = pe[0] + pe[1] * localEta + pe[2] * localEta * localEta;
183 
184  //--- correction vs local phi
185  fphicor = pp[0] + pp[1] * localPhi + pp[2] * localPhi * localPhi;
186 
187  //if the seed crystal is neighbourgh of a supermodule border, don't apply the phi dependent containment corrections, but use the larger crack corrections instead.
188  int iphimod20 = std::abs(iphiclosest % 20);
189  if (iphimod20 <= 1)
190  fphicor = 1.;
191 
192  correction_factor = (1. / fetacor) * (1. / fphicor);
193 
194  //return the correction factor. Use it to multiply the cluster energy.
195  return correction_factor;
196 }

References funct::abs(), funct::cos(), LEDCalibrationChannels::depth, DetId::Ecal, EcalBarrel, reco::CaloCluster::energy(), PV3DBase< T, PVType, FrameType >::eta(), dqmdumpme::first, relativeConstraints::geom, get, CaloGeometry::getSubdetectorGeometry(), reco::CaloCluster::hitsAndFractions(), EBDetId::ieta(), EBDetId::iphi(), dqm-mbProfile::log, M_PI, PV3DBase< T, PVType, FrameType >::phi(), VtxSmearedParameters_cfi::Phi, reco::CaloCluster::position(), createTree::pp, reco::CaloCluster::seed(), PV3DBase< T, PVType, FrameType >::theta(), and MonitorAlCaEcalPi0_cfi::X0.

◆ getValue() [2/2]

float EcalBasicClusterLocalContCorrection::getValue ( const reco::SuperCluster superCluster,
const int  mode 
) const
overridevirtual

Implements EcalClusterFunctionBaseClass.

Definition at line 64 of file EcalBasicClusterLocalContCorrection.cc.

64  {
65  //checkInit();
66  return 1;
67 }

◆ init()

void EcalBasicClusterLocalContCorrection::init ( const edm::EventSetup es)
overridevirtual

Implements EcalClusterFunctionBaseClass.

Definition at line 46 of file EcalBasicClusterLocalContCorrection.cc.

46  {
48  params_ = esParams_.product();
49  es_ = &es; //needed to access the ECAL geometry
50 }

References es_, esParams_, edm::EventSetup::get(), get, and params_.

Member Data Documentation

◆ es_

const edm::EventSetup* EcalBasicClusterLocalContCorrection::es_
private

Definition at line 43 of file EcalBasicClusterLocalContCorrection.cc.

Referenced by init().

◆ esParams_

edm::ESHandle<EcalClusterLocalContCorrParameters> EcalBasicClusterLocalContCorrection::esParams_
private

Definition at line 41 of file EcalBasicClusterLocalContCorrection.cc.

Referenced by init().

◆ params_

const EcalClusterLocalContCorrParameters* EcalBasicClusterLocalContCorrection::params_
private

Definition at line 42 of file EcalBasicClusterLocalContCorrection.cc.

Referenced by checkInit(), getParameters(), and init().

CaloGeometryRecord
Definition: CaloGeometryRecord.h:30
EBDetId
Definition: EBDetId.h:17
PV3DBase::theta
Geom::Theta< T > theta() const
Definition: PV3DBase.h:72
mod
T mod(const T &a, const T &b)
Definition: ecalDccMap.h:4
EcalBasicClusterLocalContCorrection::getEcalModule
int getEcalModule(DetId id) const
Definition: EcalBasicClusterLocalContCorrection.cc:199
EcalBasicClusterLocalContCorrection::es_
const edm::EventSetup * es_
Definition: EcalBasicClusterLocalContCorrection.cc:43
CaloGeometry::getSubdetectorGeometry
const CaloSubdetectorGeometry * getSubdetectorGeometry(const DetId &id) const
access the subdetector geometry for the given subdetector directly
Definition: CaloGeometry.cc:34
dqmdumpme.first
first
Definition: dqmdumpme.py:55
edm::LogWarning
Log< level::Warning, false > LogWarning
Definition: MessageLogger.h:122
EcalBarrel
Definition: EcalSubdetector.h:10
funct::cos
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
edm::EventSetup::get
T get() const
Definition: EventSetup.h:80
edm::ESHandle< CaloGeometry >
relativeConstraints.geom
geom
Definition: relativeConstraints.py:72
EcalBasicClusterLocalContCorrection::checkInit
void checkInit() const
Definition: EcalBasicClusterLocalContCorrection.cc:52
VtxSmearedParameters_cfi.Phi
Phi
Definition: VtxSmearedParameters_cfi.py:112
Point3DBase< float, GlobalTag >
EcalBasicClusterLocalContCorrection::esParams_
edm::ESHandle< EcalClusterLocalContCorrParameters > esParams_
Definition: EcalBasicClusterLocalContCorrection.cc:41
LEDCalibrationChannels.depth
depth
Definition: LEDCalibrationChannels.py:65
LEDCalibrationChannels.ieta
ieta
Definition: LEDCalibrationChannels.py:63
math::XYZPoint
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
reco::CaloCluster::hitsAndFractions
const std::vector< std::pair< DetId, float > > & hitsAndFractions() const
Definition: CaloCluster.h:210
PV3DBase::eta
T eta() const
Definition: PV3DBase.h:73
M_PI
#define M_PI
Definition: BXVectorInputProducer.cc:49
MonitorAlCaEcalPi0_cfi.X0
X0
Definition: MonitorAlCaEcalPi0_cfi.py:77
edm::LogError
Log< level::Error, false > LogError
Definition: MessageLogger.h:123
DetId::Ecal
Definition: DetId.h:27
get
#define get
reco::CaloCluster::seed
DetId seed() const
return DetId of seed
Definition: CaloCluster.h:219
reco::CaloCluster::position
const math::XYZPoint & position() const
cluster centroid position
Definition: CaloCluster.h:154
EcalFunParams::params
EcalFunctionParameters & params()
Definition: EcalFunctionParameters.h:13
Exception
Definition: hltDiff.cc:246
CaloSubdetectorGeometry
Definition: CaloSubdetectorGeometry.h:22
dqm-mbProfile.log
log
Definition: dqm-mbProfile.py:17
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
createTree.pp
pp
Definition: createTree.py:17
EcalClusterLocalContCorrParametersRcd
Definition: EcalClusterLocalContCorrParametersRcd.h:5
reco::CaloCluster::energy
double energy() const
cluster energy
Definition: CaloCluster.h:149
PV3DBase::phi
Geom::Phi< T > phi() const
Definition: PV3DBase.h:66
EcalBasicClusterLocalContCorrection::params_
const EcalClusterLocalContCorrParameters * params_
Definition: EcalBasicClusterLocalContCorrection.cc:42