CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions
EcalBasicClusterLocalContCorrection Class Reference

#include <EcalBasicClusterLocalContCorrection.h>

Inheritance diagram for EcalBasicClusterLocalContCorrection:
EcalClusterLocalContCorrectionBaseClass EcalClusterFunctionBaseClass

Public Member Functions

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

Private Member Functions

int getEcalModule (DetId id) const
 

Additional Inherited Members

- Protected Attributes inherited from EcalClusterLocalContCorrectionBaseClass
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 15 of file EcalBasicClusterLocalContCorrection.h.

Constructor & Destructor Documentation

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

Member Function Documentation

int EcalBasicClusterLocalContCorrection::getEcalModule ( DetId  id) const
private

Definition at line 176 of file EcalBasicClusterLocalContCorrection.cc.

References DEFINE_EDM_PLUGIN, and mod().

Referenced by EcalBasicClusterLocalContCorrection().

177 {
178  int mod = 0;
179  int ieta = (EBDetId(id)).ieta();
180 
181  if (fabs(ieta) <=25 ) mod = 0;
182  if (fabs(ieta) > 25 && fabs(ieta) <=45 ) mod = 1;
183  if (fabs(ieta) > 45 && fabs(ieta) <=65 ) mod = 2;
184  if (fabs(ieta) > 65 && fabs(ieta) <=85 ) mod = 3;
185 
186  return (mod);
187 
188 }
T mod(const T &a, const T &b)
Definition: ecalDccMap.h:4
float EcalBasicClusterLocalContCorrection::getValue ( const reco::BasicCluster basicCluster,
const EcalRecHitCollection recHit 
) const
overridevirtual

Implements EcalClusterLocalContCorrectionBaseClass.

Definition at line 35 of file EcalBasicClusterLocalContCorrection.cc.

References Abs(), egammaForCoreTracking_cff::depth, DetId::Ecal, EcalBarrel, reco::tau::disc::Eta(), PV3DBase< T, PVType, FrameType >::eta(), plotBeamSpotDB::first, relativeConstraints::geom, CaloSubdetectorGeometry::getGeometry(), CaloGeometry::getSubdetectorGeometry(), EBDetId::ieta(), EBDetId::iphi(), cmsBatch::log, colinearityKinematic::Phi, PV3DBase< T, PVType, FrameType >::phi(), Pi, createTree::pp, PV3DBase< T, PVType, FrameType >::theta(), and X0.

Referenced by EcalBasicClusterLocalContCorrection().

36 {
37  checkInit();
38 
39  // number of parameters needed by this parametrization
40  size_t nparams = 24;
41 
42  //correction factor to be returned, and to be calculated in this present function:
43  double correction_factor=1.;
44  double fetacor=1.; //eta dependent part of the correction factor
45  double fphicor=1.; //phi dependent part of the correction factor
46 
47 
48  //--------------if barrel calculate local position wrt xtal center -------------------
49  edm::ESHandle<CaloGeometry> caloGeometry;
50  es_->get<CaloGeometryRecord>().get(caloGeometry);
51  const CaloSubdetectorGeometry* geom = caloGeometry->getSubdetectorGeometry(DetId::Ecal,EcalBarrel);//EcalBarrel = 1
52 
53 
54  const math::XYZPoint& position_ = basicCluster.position();
55  double Theta = -position_.theta()+0.5*TMath::Pi();
56  double Eta = position_.eta();
57  double Phi = TVector2::Phi_mpi_pi(position_.phi());
58 
59 
60 
61  //Calculate expected depth of the maximum shower from energy (like in PositionCalc::Calculate_Location()):
62  // The parameters X0 and T0 are hardcoded here because these values were used to calculate the corrections:
63  const float X0 = 0.89; const float T0 = 7.4;
64  double depth = X0 * (T0 + log(basicCluster.energy()));
65 
66 
67  //search which crystal is closest to the cluster position and call it crystalseed:
68  //std::vector<DetId> crystals_vector = *scRef.getHitsByDetId(); //deprecated
69  std::vector< std::pair<DetId, float> > crystals_vector = basicCluster.hitsAndFractions();
70  float dphimin=999.;
71  float detamin=999.;
72  int ietaclosest = 0;
73  int iphiclosest = 0;
74 
75 
76  for (unsigned int icry=0; icry!=crystals_vector.size(); ++icry)
77  {
78 
79  EBDetId crystal(crystals_vector[icry].first);
80  auto cell=geom->getGeometry(crystal);// problema qui
81  GlobalPoint center_pos = cell->getPosition(depth);
82  double EtaCentr = center_pos.eta();
83  double PhiCentr = TVector2::Phi_mpi_pi(center_pos.phi());
84  if (TMath::Abs(EtaCentr-Eta) < detamin) {
85  detamin = TMath::Abs(EtaCentr-Eta);
86  ietaclosest = crystal.ieta();
87  }
88  if (TMath::Abs(TVector2::Phi_mpi_pi(PhiCentr-Phi)) < dphimin) {
89  dphimin = TMath::Abs(TVector2::Phi_mpi_pi(PhiCentr-Phi));
90  iphiclosest = crystal.iphi();
91  }
92 
93  }
94 
95 
96  EBDetId crystalseed(ietaclosest, iphiclosest);
97 
98 
99  // Get center cell position from shower depth
100  auto cell=geom->getGeometry(crystalseed);
101  GlobalPoint center_pos = cell->getPosition(depth);
102 
103  //PHI
104  double PhiCentr = TVector2::Phi_mpi_pi(center_pos.phi());
105  double PhiWidth = (TMath::Pi()/180.);
106  double PhiCry = (TVector2::Phi_mpi_pi(Phi-PhiCentr))/PhiWidth;
107  if (PhiCry>0.5) PhiCry=0.5;
108  if (PhiCry<-0.5) PhiCry=-0.5;
109  //flip to take into account ECAL barrel symmetries:
110  if (ietaclosest<0) PhiCry *= -1.;
111 
112 
113  //ETA
114  double ThetaCentr = -center_pos.theta()+0.5*TMath::Pi();
115  double ThetaWidth = (TMath::Pi()/180.)*TMath::Cos(ThetaCentr);
116  double EtaCry = (Theta-ThetaCentr)/ThetaWidth;
117  if (EtaCry>0.5) EtaCry=0.5;
118  if (EtaCry<-0.5) EtaCry=-0.5;
119  //flip to take into account ECAL barrel symmetries:
120  if (ietaclosest<0) EtaCry *= -1.;
121 
122 
123 
124  //-------------- end calculate local position -------------
125 
126 
127  size_t payloadsize = params_->params().size();
128 
129  if (payloadsize < nparams )
130  edm::LogError("Invalid Payload") << "Parametrization requires " << nparams << " parameters but only " << payloadsize << " are found in DB. Perhaps incompatible Global Tag" << std::endl;
131 
132 
133  if (payloadsize > nparams )
134  edm::LogWarning("Size mismatch ") << "Parametrization requires " << nparams << " parameters but " << payloadsize << " are found in DB. Perhaps incompatible Global Tag" << std::endl;
135 
136 
137 
138  std::pair<double,double> localPosition(EtaCry,PhiCry);
139 
140  //--- local cluster coordinates
141  float localEta = localPosition.first;
142  float localPhi = localPosition.second;
143 
144  //--- ecal module
145  int imod = getEcalModule(basicCluster.seed());
146 
147  //-- corrections parameters
148  float pe[3], pp[3];
149  pe[0]= (params_->params())[0+imod*3];
150  pe[1]= (params_->params())[1+imod*3];
151  pe[2]= (params_->params())[2+imod*3];
152  pp[0]= (params_->params())[12+imod*3];
153  pp[1]= (params_->params())[13+imod*3];
154  pp[2]= (params_->params())[14+imod*3];
155 
156 
157  //--- correction vs local eta
158  fetacor = pe[0]+pe[1]*localEta+pe[2]*localEta*localEta;
159 
160  //--- correction vs local phi
161  fphicor = pp[0]+pp[1]*localPhi+pp[2]*localPhi*localPhi;
162 
163 
164  //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.
165  int iphimod20 = TMath::Abs(iphiclosest%20);
166  if ( iphimod20 <=1 ) fphicor=1.;
167 
168  correction_factor = (1./fetacor)*(1./fphicor);
169 
170  //return the correction factor. Use it to multiply the cluster energy.
171  return correction_factor;
172 }
const double Pi
const CaloSubdetectorGeometry * getSubdetectorGeometry(const DetId &id) const
access the subdetector geometry for the given subdetector directly
Definition: CaloGeometry.cc:49
Geom::Phi< T > phi() const
Definition: PV3DBase.h:69
Geom::Theta< T > theta() const
Definition: PV3DBase.h:75
T Abs(T a)
Definition: MathUtil.h:49
EcalFunctionParameters & params()
virtual std::shared_ptr< const CaloCellGeometry > getGeometry(const DetId &id) const
Get the cell geometry of a given detector id. Should return false if not found.
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
T eta() const
Definition: PV3DBase.h:76
const EcalClusterLocalContCorrParameters * params_
T get() const
Definition: EventSetup.h:71
static const double X0
float EcalBasicClusterLocalContCorrection::getValue ( const reco::SuperCluster superCluster,
const int  mode 
) const
overridevirtual

Implements EcalClusterLocalContCorrectionBaseClass.

Definition at line 29 of file EcalBasicClusterLocalContCorrection.cc.

30 {
31  //checkInit();
32  return 1;
33 }