CMS 3D CMS Logo

Photon.cc
Go to the documentation of this file.
3 
4 using namespace reco;
5 
6 Photon::Photon(const LorentzVector& p4, const Point& caloPos, const PhotonCoreRef& core, const Point& vtx)
7  : RecoCandidate(0, p4, vtx, 22), caloPosition_(caloPos), photonCore_(core), pixelSeed_(false) {}
8 
9 Photon::Photon(const Photon& rhs)
10  : RecoCandidate(rhs),
11  caloPosition_(rhs.caloPosition_),
12  photonCore_(rhs.photonCore_),
13  pixelSeed_(rhs.pixelSeed_),
14  fiducialFlagBlock_(rhs.fiducialFlagBlock_),
15  isolationR04_(rhs.isolationR04_),
16  isolationR03_(rhs.isolationR03_),
17  showerShapeBlock_(rhs.showerShapeBlock_),
18  full5x5_showerShapeBlock_(rhs.full5x5_showerShapeBlock_),
19  saturationInfo_(rhs.saturationInfo_),
20  eCorrections_(rhs.eCorrections_),
21  mipVariableBlock_(rhs.mipVariableBlock_),
22  pfIsolation_(rhs.pfIsolation_) {}
23 
24 Photon::~Photon() {}
25 
26 Photon* Photon::clone() const { return new Photon(*this); }
27 
28 bool Photon::overlap(const Candidate& c) const {
29  const RecoCandidate* o = dynamic_cast<const RecoCandidate*>(&c);
30  return (o != nullptr && (checkOverlap(superCluster(), o->superCluster())));
31  return false;
32 }
33 
34 void Photon::setVertex(const Point& vertex) {
35  math::XYZVectorF direction = caloPosition() - vertex;
36  double energy = this->energy();
37  math::XYZVectorF momentum = direction.unit() * energy;
39  setP4(lv);
41 }
42 
43 reco::SuperClusterRef Photon::superCluster() const { return this->photonCore()->superCluster(); }
44 
46  const reco::ConversionRefVector& conv2leg = this->photonCore()->conversions();
47  const reco::ConversionRefVector& conv1leg = this->photonCore()->conversionsOneLeg();
48 
49  int origin = -1;
50  bool isEg = false, isPf = false;
51 
52  for (unsigned iConv = 0; iConv < conv2leg.size(); iConv++) {
53  std::vector<edm::RefToBase<reco::Track> > convtracks = conv2leg[iConv]->tracks();
54  for (unsigned itk = 0; itk < convtracks.size(); itk++) {
55  if (convTrack == convtracks[itk])
56  isEg = true;
57  }
58  }
59 
60  for (unsigned iConv = 0; iConv < conv1leg.size(); iConv++) {
61  std::vector<edm::RefToBase<reco::Track> > convtracks = conv1leg[iConv]->tracks();
62  for (unsigned itk = 0; itk < convtracks.size(); itk++) {
63  if (convTrack == convtracks[itk])
64  isPf = true;
65  }
66  }
67 
68  if (isEg)
69  origin = egamma;
70  if (isPf)
71  origin = pflow;
72  if (isEg && isPf)
73  origin = both;
74 
75  return origin;
76 }
77 
78 void Photon::setCorrectedEnergy(P4type type, float newEnergy, float delta_e, bool setToRecoCandidate) {
79  math::XYZTLorentzVectorD newP4 = p4();
80  newP4 *= newEnergy / newP4.e();
81  switch (type) {
82  case ecal_standard:
83  eCorrections_.scEcalEnergy = newEnergy;
85  break;
86  case ecal_photons:
87  eCorrections_.phoEcalEnergy = newEnergy;
89  break;
90  case regression1:
91  eCorrections_.regression1Energy = newEnergy;
93  [[fallthrough]];
94  case regression2:
95  eCorrections_.regression2Energy = newEnergy;
97  break;
98  default:
99  throw cms::Exception("reco::Photon") << "unexpected p4 type: " << type;
100  }
101  setP4(type, newP4, delta_e, setToRecoCandidate);
102 }
103 
104 float Photon::getCorrectedEnergy(P4type type) const {
105  switch (type) {
106  case ecal_standard:
108  break;
109  case ecal_photons:
111  break;
112  case regression1:
114  case regression2:
116  break;
117  default:
118  throw cms::Exception("reco::Photon") << "unexpected p4 type " << type << " cannot return the energy value: ";
119  }
120 }
121 
122 float Photon::getCorrectedEnergyError(P4type type) const {
123  switch (type) {
124  case ecal_standard:
126  break;
127  case ecal_photons:
129  break;
130  case regression1:
132  case regression2:
134  break;
135  default:
136  throw cms::Exception("reco::Photon")
137  << "unexpected p4 type " << type << " cannot return the uncertainty on the energy: ";
138  }
139 }
140 
141 void Photon::setP4(P4type type, const LorentzVector& p4, float error, bool setToRecoCandidate) {
142  switch (type) {
143  case ecal_standard:
146  break;
147  case ecal_photons:
150  break;
151  case regression1:
154  [[fallthrough]];
155  case regression2:
158  break;
159  default:
160  throw cms::Exception("reco::Photon") << "unexpected p4 type: " << type;
161  }
162  if (setToRecoCandidate) {
163  setP4(p4);
165  }
166 }
167 
168 const Candidate::LorentzVector& Photon::p4(P4type type) const {
169  switch (type) {
170  case ecal_standard:
171  return eCorrections_.scEcalP4;
172  case ecal_photons:
173  return eCorrections_.phoEcalP4;
174  case regression1:
176  case regression2:
178  default:
179  throw cms::Exception("reco::Photon") << "unexpected p4 type: " << type << " cannot return p4 ";
180  }
181 }
182 
184  auto& ss1 = showerShapeBlock_;
185  auto& ss2 = full5x5_showerShapeBlock_;
186  auto& iv1 = isolationR03_;
187  auto& iv2 = isolationR04_;
188 
189  for (uint id = 2u; id < ss1.hcalOverEcal.size(); ++id) {
190  ss1.hcalOverEcal[1] += ss1.hcalOverEcal[id];
191  ss1.hcalOverEcalBc[1] += ss1.hcalOverEcalBc[id];
192 
193  ss1.hcalOverEcal[id] = 0.f;
194  ss1.hcalOverEcalBc[id] = 0.f;
195 
196  ss2.hcalOverEcal[1] += ss2.hcalOverEcal[id];
197  ss2.hcalOverEcalBc[1] += ss2.hcalOverEcalBc[id];
198 
199  ss2.hcalOverEcal[id] = 0.f;
200  ss2.hcalOverEcalBc[id] = 0.f;
201 
202  iv1.hcalRecHitSumEt[1] += iv1.hcalRecHitSumEt[id];
203  iv1.hcalRecHitSumEtBc[1] += iv1.hcalRecHitSumEtBc[id];
204 
205  iv1.hcalRecHitSumEt[id] = 0.f;
206  iv1.hcalRecHitSumEtBc[id] = 0.f;
207 
208  iv2.hcalRecHitSumEt[1] += iv2.hcalRecHitSumEt[id];
209  iv2.hcalRecHitSumEtBc[1] += iv2.hcalRecHitSumEtBc[id];
210 
211  iv2.hcalRecHitSumEt[id] = 0.f;
212  iv2.hcalRecHitSumEtBc[id] = 0.f;
213  }
214 }
reco::LeafCandidate::momentum
Vector momentum() const final
spatial momentum vector
Definition: LeafCandidate.h:118
reco::Photon::EnergyCorrections::regression2Energy
float regression2Energy
Definition: Photon.h:326
reco::Photon::EnergyCorrections::scEcalEnergy
float scEcalEnergy
Definition: Photon.h:317
reco::Photon::superCluster
reco::SuperClusterRef superCluster() const override
Ref to SuperCluster.
funct::false
false
Definition: Factorize.h:29
reco::Photon::clone
Photon * clone() const override
returns a clone of the candidate
reco::RecoCandidate::checkOverlap
bool checkOverlap(const R &r1, const R &r2) const
check if two components overlap
Definition: RecoCandidate.h:67
math::XYZTLorentzVectorD
ROOT::Math::LorentzVector< ROOT::Math::PxPyPzE4D< double > > XYZTLorentzVectorD
Lorentz vector with cylindrical internal representation using pseudorapidity.
Definition: LorentzVector.h:14
reco::Photon::IsolationVariables::hcalRecHitSumEt
std::array< float, 7 > hcalRecHitSumEt
Definition: Photon.h:416
edm::RefVector< ConversionCollection >
reco
fixed size matrix
Definition: AlignmentAlgorithmBase.h:46
relativeConstraints.error
error
Definition: relativeConstraints.py:53
parallelization.uint
uint
Definition: parallelization.py:124
EcalTangentSkim_cfg.o
o
Definition: EcalTangentSkim_cfg.py:42
edm::Ref< PhotonCoreCollection >
reco::Photon::hcalToRun2EffDepth
void hcalToRun2EffDepth()
Photon.h
reco::Photon::ecal_photons
Definition: Photon.h:314
reco::Photon::egamma
Definition: Photon.h:62
reco::Photon::EnergyCorrections::regression1EnergyError
float regression1EnergyError
Definition: Photon.h:324
reco::Photon::EnergyCorrections::phoEcalEnergy
float phoEcalEnergy
Definition: Photon.h:320
reco::Photon::EnergyCorrections::regression1P4
LorentzVector regression1P4
Definition: Photon.h:325
reco::LeafCandidate::setVertex
void setVertex(const Point &vertex) override
set vertex
Definition: LeafCandidate.h:173
reco::Photon::caloPosition
math::XYZPointF caloPosition() const
position in ECAL: this is th SC position if r9<0.93. If r8>0.93 is position of seed BasicCluster taki...
Definition: Photon.h:85
reco::Photon::isolationR04_
IsolationVariables isolationR04_
Definition: Photon.h:595
Point
Structure Point Contains parameters of Gaussian fits to DMRs.
Definition: DMRtrends.cc:57
bphysicsOniaDQM_cfi.vertex
vertex
Definition: bphysicsOniaDQM_cfi.py:7
core
Definition: __init__.py:1
reco::Photon::photonCore
reco::PhotonCoreRef photonCore() const
returns a reference to the core photon object
Definition: Photon.h:47
reco::Photon::EnergyCorrections::candidateP4type
P4type candidateP4type
Definition: Photon.h:329
reco::Photon::getCorrectedEnergyError
float getCorrectedEnergyError(P4type type) const
type
type
Definition: SiPixelVCal_PayloadInspector.cc:39
reco::Photon::full5x5_showerShapeBlock_
ShowerShape full5x5_showerShapeBlock_
Definition: Photon.h:598
gainCalibHelper::gainCalibPI::type
type
Definition: SiPixelGainCalibHelper.h:40
reco::Photon::overlap
bool overlap(const Candidate &) const override
check overlap with another candidate
Photon
Definition: Photon.py:1
reco::Photon::EnergyCorrections::scEcalP4
LorentzVector scEcalP4
Definition: Photon.h:319
reco::LeafCandidate::p4
const LorentzVector & p4() const final
four-momentum Lorentz vector
Definition: LeafCandidate.h:114
p4
double p4[4]
Definition: TauolaWrapper.h:92
reco::Photon::Photon
Photon()
default constructor
Definition: Photon.h:32
reco::Photon::EnergyCorrections::scEcalEnergyError
float scEcalEnergyError
Definition: Photon.h:318
reco::RecoCandidate
Definition: RecoCandidate.h:20
reco::Photon::setCorrectedEnergy
void setCorrectedEnergy(P4type type, float E, float dE, bool toCand=true)
reco::Photon::both
Definition: Photon.h:62
reco::Photon::showerShapeBlock_
ShowerShape showerShapeBlock_
Definition: Photon.h:597
reco::LeafCandidate::vertex
const Point & vertex() const override
vertex position (overwritten by PF...)
Definition: LeafCandidate.h:165
reco::Candidate
Definition: Candidate.h:27
reco::Photon::eCorrections_
EnergyCorrections eCorrections_
Definition: Photon.h:600
reco::Photon::isolationR03_
IsolationVariables isolationR03_
Definition: Photon.h:596
reco::Photon::EnergyCorrections::regression1Energy
float regression1Energy
Definition: Photon.h:323
reco::Photon::pflow
Definition: Photon.h:62
reco::Photon::EnergyCorrections::regression2P4
LorentzVector regression2P4
Definition: Photon.h:328
SuperClusterFwd.h
extraflags_cff.vtx
vtx
Definition: extraflags_cff.py:19
reco::Photon::getCorrectedEnergy
float getCorrectedEnergy(P4type type) const
reco::Photon::EnergyCorrections::phoEcalP4
LorentzVector phoEcalP4
Definition: Photon.h:322
triggerObjects_cff.id
id
Definition: triggerObjects_cff.py:29
math::XYZTLorentzVector
XYZTLorentzVectorD XYZTLorentzVector
Lorentz vector with cylindrical internal representation using pseudorapidity.
Definition: LorentzVector.h:29
LorentzVector
math::XYZTLorentzVector LorentzVector
Definition: HLTMuonMatchAndPlot.h:49
Exception
Definition: hltDiff.cc:245
reco::Photon::EnergyCorrections::regression2EnergyError
float regression2EnergyError
Definition: Photon.h:327
math::XYZVectorF
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< float > > XYZVectorF
spatial vector with cartesian internal representation
Definition: Vector3D.h:16
reco::Photon::regression1
Definition: Photon.h:314
edm::RefToBase< reco::Track >
reco::Photon::conversionTrackProvenance
int conversionTrackProvenance(const edm::RefToBase< reco::Track > &convTrack) const
reco::Photon::EnergyCorrections::phoEcalEnergyError
float phoEcalEnergyError
Definition: Photon.h:321
reco::Photon::setVertex
void setVertex(const Point &vertex) override
set primary event vertex used to define photon direction
reco::LeafCandidate::energy
double energy() const final
energy
Definition: LeafCandidate.h:125
reco::Photon::regression2
Definition: Photon.h:314
reco::Candidate::LorentzVector
math::XYZTLorentzVector LorentzVector
Lorentz vector.
Definition: Candidate.h:36
c
auto & c
Definition: CAHitNtupletGeneratorKernelsImpl.h:56
reco::Photon::setP4
void setP4(P4type type, const LorentzVector &p4, float p4Error, bool setToRecoCandidate)
edm::RefVector::size
size_type size() const
Size of the RefVector.
Definition: RefVector.h:102
reco::Photon::~Photon
~Photon() override
destructor
reco::Photon::ecal_standard
Definition: Photon.h:314