CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Photon.cc
Go to the documentation of this file.
1 // $Id: Photon.cc,v 1.28 2011/11/07 21:16:15 nancy Exp $
4 
5 using namespace reco;
6 
8  Point caloPos,
9  const PhotonCoreRef & core,
10  const Point & vtx) :
11  RecoCandidate( 0, p4, vtx, 22 ),
12  caloPosition_( caloPos ),
13  photonCore_(core),
14  pixelSeed_(false)
15  {}
16 
17 
18 Photon::Photon( const Photon& rhs ) :
19  RecoCandidate(rhs),
20  caloPosition_(rhs.caloPosition_),
21  photonCore_ ( rhs.photonCore_),
22  pixelSeed_ ( rhs.pixelSeed_ ),
23  fiducialFlagBlock_ ( rhs.fiducialFlagBlock_ ),
24  isolationR04_ ( rhs.isolationR04_),
25  isolationR03_ ( rhs.isolationR03_),
26  showerShapeBlock_ ( rhs.showerShapeBlock_),
27  eCorrections_(rhs.eCorrections_),
28  mipVariableBlock_ (rhs.mipVariableBlock_),
29  pfIsolation_ ( rhs.pfIsolation_ )
30  {}
31 
32 
33 
34 
36 
37 Photon * Photon::clone() const {
38  return new Photon( * this );
39 }
40 
41 
42 bool Photon::overlap( const Candidate & c ) const {
43  const RecoCandidate * o = dynamic_cast<const RecoCandidate *>( & c );
44  return ( o != 0 &&
46  );
47  return false;
48 }
49 
50 void Photon::setVertex(const Point & vertex) {
51  math::XYZVectorF direction = caloPosition() - vertex;
52  double energy = this->energy();
53  math::XYZVectorF momentum = direction.unit() * energy;
54  math::XYZTLorentzVector lv(momentum.x(), momentum.y(), momentum.z(), energy );
55  setP4(lv);
56  vertex_ = vertex;
57 }
58 
60  return this->photonCore()->superCluster();
61 }
62 
64 
65  const reco::ConversionRefVector & conv2leg = this->photonCore()->conversions();
66  const reco::ConversionRefVector & conv1leg = this->photonCore()->conversionsOneLeg();
67 
68  int origin = -1;
69  bool isEg=false, isPf=false;
70 
71  for (unsigned iConv=0; iConv<conv2leg.size(); iConv++){
72  std::vector<edm::RefToBase<reco::Track> > convtracks = conv2leg[iConv]->tracks();
73  for (unsigned itk=0; itk<convtracks.size(); itk++){
74  if (convTrack==convtracks[itk]) isEg=true;
75  }
76  }
77 
78  for (unsigned iConv=0; iConv<conv1leg.size(); iConv++){
79  std::vector<edm::RefToBase<reco::Track> > convtracks = conv1leg[iConv]->tracks();
80  for (unsigned itk=0; itk<convtracks.size(); itk++){
81  if (convTrack==convtracks[itk]) isPf=true;
82  }
83  }
84 
85  if (isEg) origin=egamma;
86  if (isPf) origin=pflow;
87  if (isEg && isPf) origin=both;
88 
89  return origin;
90 }
91 
92 
93 void Photon::setCorrectedEnergy( P4type type, float newEnergy, float delta_e, bool setToRecoCandidate ) {
94 
95  math::XYZTLorentzVectorD newP4 = p4() ;
96  newP4 *= newEnergy/newP4.e() ;
97  switch(type)
98  {
99  case ecal_standard:
100  eCorrections_.scEcalEnergy = newEnergy;
102  break ;
103  case ecal_photons:
104  eCorrections_.phoEcalEnergy = newEnergy;
106  break ;
107  case regression1:
108  eCorrections_.regression1Energy = newEnergy ;
110  case regression2:
111  eCorrections_.regression2Energy = newEnergy ;
113  break ;
114  default:
115  throw cms::Exception("reco::Photon")<<"unexpected p4 type: "<< type ;
116  }
117  setP4(type, newP4, delta_e, setToRecoCandidate);
118 
119 }
120 
121 
122 
123 
125  switch(type)
126  {
127  case ecal_standard:
129  break ;
130  case ecal_photons:
132  break ;
133  case regression1:
135  case regression2:
137  break ;
138  default:
139  throw cms::Exception("reco::Photon")<<"unexpected p4 type " << type << " cannot return the energy value: " ;
140  }
141  }
142 
143 
145  switch(type)
146  {
147  case ecal_standard:
149  break ;
150  case ecal_photons:
152  break ;
153  case regression1:
155  case regression2:
157  break ;
158  default:
159  throw cms::Exception("reco::Photon")<<"unexpected p4 type " << type << " cannot return the uncertainty on the energy: " ;
160  }
161  }
162 
163 
164 
165 void Photon::setP4(P4type type, const LorentzVector & p4, float error, bool setToRecoCandidate ) {
166 
167 
168  switch(type)
169  {
170  case ecal_standard:
173  break ;
174  case ecal_photons:
177  break ;
178  case regression1:
181  case regression2:
184  break ;
185  default:
186  throw cms::Exception("reco::Photon")<<"unexpected p4 type: "<< type ;
187  }
188  if (setToRecoCandidate)
189  {
190  setP4(p4) ;
192  }
193 
194 
195 }
196 
198  {
199  switch(type)
200  {
201  case ecal_standard: return eCorrections_.scEcalP4 ;
202  case ecal_photons: return eCorrections_.phoEcalP4 ;
205  default: throw cms::Exception("reco::Photon")<<"unexpected p4 type: "<< type << " cannot return p4 ";
206  }
207  }
type
Definition: HCALResponse.h:22
bool checkOverlap(const R &r1, const R &r2) const
check if two components overlap
Definition: RecoCandidate.h:67
ROOT::Math::LorentzVector< ROOT::Math::PxPyPzE4D< double > > XYZTLorentzVectorD
Lorentz vector with cylindrical internal representation using pseudorapidity.
Definition: LorentzVector.h:15
virtual const Point & vertex() const
vertex position
virtual Photon * clone() const
returns a clone of the candidate
Definition: Photon.cc:37
virtual Vector momentum() const
spatial momentum vector
reco::SuperClusterRef superCluster() const
Ref to SuperCluster.
Definition: Photon.cc:59
Point vertex_
vertex position
Photon()
default constructor
Definition: Photon.h:32
float getCorrectedEnergy(P4type type) const
Definition: Photon.cc:124
XYZTLorentzVectorD XYZTLorentzVector
Lorentz vector with cylindrical internal representation using pseudorapidity.
Definition: LorentzVector.h:30
LorentzVector regression2P4
Definition: Photon.h:210
reco::PhotonCoreRef photonCore() const
returns a reference to the core photon object
Definition: Photon.h:50
virtual double energy() const
energy
virtual bool overlap(const Candidate &) const
check overlap with another candidate
Definition: Photon.cc:42
double p4[4]
Definition: TauolaWrapper.h:92
EnergyCorrections eCorrections_
Definition: Photon.h:454
void setCorrectedEnergy(P4type type, float E, float dE, bool toCand=true)
Definition: Photon.cc:93
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< float > > XYZVectorF
spatial vector with cartesian internal representation
Definition: Vector3D.h:18
float getCorrectedEnergyError(P4type type) const
Definition: Photon.cc:144
math::XYZPointF caloPosition() const
position in ECAL: this is th SC position if r9&lt;0.93. If r8&gt;0.93 is position of seed BasicCluster taki...
Definition: Photon.h:79
void setP4(P4type type, const LorentzVector &p4, float p4Error, bool setToRecoCandidate)
Definition: Photon.cc:165
LorentzVector regression1P4
Definition: Photon.h:207
math::XYZTLorentzVector LorentzVector
Lorentz vector.
Definition: Candidate.h:38
virtual ~Photon()
destructor
Definition: Photon.cc:35
size_type size() const
Size of the RefVector.
Definition: RefVector.h:89
math::XYZPoint Point
point in the space
Definition: Candidate.h:42
virtual const LorentzVector & p4() const
four-momentum Lorentz vector
virtual reco::SuperClusterRef superCluster() const
reference to a SuperCluster
void setVertex(const Point &vertex)
set primary event vertex used to define photon direction
Definition: Photon.cc:50
int conversionTrackProvenance(const edm::RefToBase< reco::Track > &convTrack) const
Definition: Photon.cc:63