CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Member Functions | Private Attributes
EcalShowerProperties Class Reference

#include <EcalShowerProperties.h>

Public Member Functions

 EcalShowerProperties (const edm::Event &ev, const edm::EventSetup &es)
 
std::pair< double, double > processTrack (const reco::Track &track, int &ntime)
 

Private Member Functions

double getDistance (const std::vector< TrajectoryStateOnSurface > &tsosEnds, const CaloCellGeometry *cell)
 
std::vector
< TrajectoryStateOnSurface
getEndpoints (const FreeTrajectoryState &ftsAtLastPoint, const TrajectoryStateOnSurface &tsosBeforeEcal, int subDet)
 
Plane::PlanePointer getSurface (const CaloCellGeometry *cell, int i)
 
FreeTrajectoryState getTrajectoryAtOuterPoint (const reco::Track &track)
 
std::pair< double, double > processEcalRecHits (const std::vector< TrajectoryStateOnSurface > &tsosEnds, int subDet, int &ntime)
 

Private Attributes

edm::Handle< EBRecHitCollectionrecHitsBarrel
 
edm::Handle< EERecHitCollectionrecHitsEndcap
 
const CaloGeometrytheCaloGeometry
 
const MagneticFieldtheMagneticField
 
const PropagatorthePropagator
 

Detailed Description

Definition at line 18 of file EcalShowerProperties.h.

Constructor & Destructor Documentation

EcalShowerProperties::EcalShowerProperties ( const edm::Event ev,
const edm::EventSetup es 
)

Definition at line 31 of file EcalShowerProperties.cc.

References edm::EventSetup::get(), edm::Event::getByLabel(), and edm::ESHandle< class >::product().

32 {
33  // Get magnetic field
34  edm::ESHandle<MagneticField> theMagneticFieldHandle;
35  es.get<IdealMagneticFieldRecord>().get(theMagneticFieldHandle);
36  theMagneticField = theMagneticFieldHandle.product();
37 
38  // Get propagator
39  edm::ESHandle<Propagator> thePropagatorHandle;
40  es.get<TrackingComponentsRecord>().get("PropagatorWithMaterial",
41  thePropagatorHandle);
42  thePropagator = thePropagatorHandle.product();
43 
44  // Get calorimetry
45  edm::ESHandle<CaloGeometry> theCaloGeometryHandle;
46  es.get<IdealGeometryRecord>().get(theCaloGeometryHandle);
47  theCaloGeometry = (const CaloGeometry*)theCaloGeometryHandle.product();
48 
49  // Get ecal rechits
50  ev.getByLabel("ecalRecHit", "EcalRecHitsEB", recHitsBarrel);
51  ev.getByLabel("ecalRecHit", "EcalRecHitsEE", recHitsEndcap);
52 }
edm::Handle< EBRecHitCollection > recHitsBarrel
const CaloGeometry * theCaloGeometry
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:361
edm::Handle< EERecHitCollection > recHitsEndcap
const T & get() const
Definition: EventSetup.h:55
T const * product() const
Definition: ESHandle.h:62
const Propagator * thePropagator
const MagneticField * theMagneticField

Member Function Documentation

double EcalShowerProperties::getDistance ( const std::vector< TrajectoryStateOnSurface > &  tsosEnds,
const CaloCellGeometry cell 
)
private

Definition at line 135 of file EcalShowerProperties.cc.

References trackerHits::c, dmin, reco::dp, alignCSCRings::e, CaloCellGeometry::getCorners(), mag2(), min, AlCaHLTBitMon_ParallelJobs::p, p1, p2, mathSSE::sqrt(), x, PV3DBase< T, PVType, FrameType >::x(), detailsBasic3DVector::y, PV3DBase< T, PVType, FrameType >::y(), and detailsBasic3DVector::z.

137 {
138  double dmin = 1e+9;
139  LocalPoint p;
140 
141  // Project to entry surface, 'p1p2' segment
142  p = tsosEnds[0].surface().toLocal(tsosEnds[0].globalPosition());
143  LocalPoint p1(p.x(), p.y(), 0);
144 
145  p = tsosEnds[0].surface().toLocal(tsosEnds[1].globalPosition());
146  LocalPoint p2(p.x(), p.y(), 0);
147 
148  const CaloCellGeometry::CornersVec & c(cell->getCorners());
149 
150  // Project to entry surface, 'c' corners
151  for(int i = 0; i < 4; i++)
152  {
153  p = tsosEnds[0].surface().toLocal(GlobalPoint(c[i].x(),c[i].y(),c[i].z()));
154  LocalPoint c(p.x(), p.y(), 0);
155 
156  // Calculate distance of 'c' from endpoints 'p1' and 'p2'
157  double d1 = (p1 - c).mag2(); // distance from end
158  double d2 = (p2 - c).mag2(); // distance from end
159  double dm = min(d1,d2);
160 
161  // distance from segment
162  double lambda = (c - p1) * (p2 - p1) / (p2 - p1).mag2();
163  if(lambda > 0 && lambda < 1)
164  {
165  double dp = (c - p1 - lambda * (p2 - p1)).mag2();
166  dm = min (dm,dp);
167  }
168 
169  dmin = min(dm, dmin);
170  }
171 
172  return(sqrt(dmin));
173 }
int i
Definition: DBlmapReader.cc:9
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
T y() const
Definition: PV3DBase.h:63
#define min(a, b)
Definition: mlp_lapack.h:161
float float float z
T sqrt(T t)
Definition: SSEVec.h:48
T mag2() const
The vector magnitude squared. Equivalent to vec.dot(vec)
#define dmin(a, b)
Definition: mlp_lapack.h:163
double p2[4]
Definition: TauolaWrapper.h:90
auto dp
Definition: deltaR.h:24
double p1[4]
Definition: TauolaWrapper.h:89
Definition: DDAxes.h:10
T x() const
Definition: PV3DBase.h:62
virtual const CornersVec & getCorners() const =0
Returns the corner points of this cell&#39;s volume.
vector< TrajectoryStateOnSurface > EcalShowerProperties::getEndpoints ( const FreeTrajectoryState ftsAtLastPoint,
const TrajectoryStateOnSurface tsosBeforeEcal,
int  subDet 
)
private

Definition at line 88 of file EcalShowerProperties.cc.

References DetId::Ecal, relativeConstraints::geom, CaloSubdetectorGeometry::getClosestCell(), CaloSubdetectorGeometry::getGeometry(), TrajectoryStateOnSurface::globalPosition(), TrajectoryStateOnSurface::isValid(), FreeTrajectoryState::position(), CaloSubdetectorGeometry::present(), and relval_parameters_module::step.

90 {
91  std::vector<TrajectoryStateOnSurface> tsosEnds;
92 
95 
96  // Get closest cell
97  DetId detId(geom->getClosestCell(ftsAtLastPoint.position()));
98 
99  if(!geom->present(detId)) return tsosEnds;
100 
101  const CaloCellGeometry* cell = geom->getGeometry(detId);
102  const CaloCellGeometry* oldcell;
104 
105  // Front and back
106  for(int i = 0; i < 2; i++)
107  {
108  int step = 0;
109 
110  do
111  {
112  oldcell = cell;
113 
114  Plane::PlanePointer thePlane = getSurface(oldcell, i);
115  tsos = thePropagator->propagate(ftsAtLastPoint,*thePlane);
116 
117  if(!tsos.isValid()) return tsosEnds;
118 
119  detId = geom->getClosestCell(tsos.globalPosition());
120 
121  if(!geom->present(detId)) return tsosEnds;
122  cell = geom->getGeometry(detId);
123  }
124  while(cell != oldcell && step++ < 5);
125 
126  if(step++ < 5)
127  tsosEnds.push_back(tsos);
128  }
129 
130  return tsosEnds;
131 }
const CaloSubdetectorGeometry * getSubdetectorGeometry(const DetId &id) const
access the subdetector geometry for the given subdetector directly
Definition: CaloGeometry.cc:43
int i
Definition: DBlmapReader.cc:9
GlobalPoint globalPosition() const
Plane::PlanePointer getSurface(const CaloCellGeometry *cell, int i)
virtual const CaloCellGeometry * getGeometry(const DetId &id) const
Get the cell geometry of a given detector id. Should return false if not found.
virtual bool present(const DetId &id) const
is this detid present in the geometry?
const CaloGeometry * theCaloGeometry
virtual TrajectoryStateOnSurface propagate(const FreeTrajectoryState &, const Surface &) const
Definition: Propagator.cc:12
virtual DetId getClosestCell(const GlobalPoint &r) const
Definition: DetId.h:20
GlobalPoint position() const
const Propagator * thePropagator
Plane::PlanePointer EcalShowerProperties::getSurface ( const CaloCellGeometry cell,
int  i 
)
private

Definition at line 68 of file EcalShowerProperties.cc.

References Plane::build(), trackerHits::c, CaloCellGeometry::getCorners(), j, pos, makeMuonMisalignmentScenario::rot, x, detailsBasic3DVector::y, and detailsBasic3DVector::z.

69 {
70  int j = i * 4;
71 
72  // Get corners
73  const CaloCellGeometry::CornersVec & c(cell->getCorners());
74 
75  // Get center
76  GlobalPoint center( (c[j].x() + c[j+1].x() + c[j+2].x() + c[j+3].x()) / 4,
77  (c[j].y() + c[j+1].y() + c[j+2].y() + c[j+3].y()) / 4,
78  (c[j].z() + c[j+1].z() + c[j+2].z() + c[j+3].z()) / 4);
79 
80  // Get plane
81  Surface::PositionType pos(center);
82  Surface::RotationType rot(c[j+1]-c[j], c[j+3]-c[j]);
83  return Plane::build(pos, rot);
84 }
int i
Definition: DBlmapReader.cc:9
float float float z
static PlanePointer build(Args &&...args)
Definition: Plane.h:36
int j
Definition: DBlmapReader.cc:9
Definition: DDAxes.h:10
virtual const CornersVec & getCorners() const =0
Returns the corner points of this cell&#39;s volume.
FreeTrajectoryState EcalShowerProperties::getTrajectoryAtOuterPoint ( const reco::Track track)
private

Definition at line 56 of file EcalShowerProperties.cc.

References reco::TrackBase::charge(), reco::Track::outerPx(), reco::Track::outerPy(), reco::Track::outerPz(), reco::Track::outerStateCovariance(), reco::Track::outerX(), reco::Track::outerY(), reco::Track::outerZ(), and pos.

57 {
58  GlobalPoint pos(track.outerX() , track.outerY() , track.outerZ() );
59  GlobalVector mom(track.outerPx(), track.outerPy(), track.outerPz());
60 
62 
63  return FreeTrajectoryState(gtp, track.outerStateCovariance());
64 }
double outerPy() const
y coordinate of momentum vector at the outermost hit position
Definition: Track.h:73
double outerZ() const
z coordinate of the outermost hit position
Definition: Track.h:81
CovarianceMatrix outerStateCovariance() const
outermost trajectory state curvilinear errors
Definition: Track.h:51
double outerX() const
x coordinate of the outermost hit position
Definition: Track.h:77
double outerPz() const
z coordinate of momentum vector at the outermost hit position
Definition: Track.h:75
double outerY() const
y coordinate of the outermost hit position
Definition: Track.h:79
int charge() const
track electric charge
Definition: TrackBase.h:113
double outerPx() const
x coordinate of momentum vector at the outermost hit position
Definition: Track.h:71
const MagneticField * theMagneticField
pair< double, double > EcalShowerProperties::processEcalRecHits ( const std::vector< TrajectoryStateOnSurface > &  tsosEnds,
int  subDet,
int &  ntime 
)
private

Definition at line 177 of file EcalShowerProperties.cc.

References DetId::Ecal, EcalBarrel, relval_parameters_module::energy, relativeConstraints::geom, CaloSubdetectorGeometry::getClosestCell(), CaloSubdetectorGeometry::getGeometry(), EBDetId::ieta(), EBDetId::iphi(), EEDetId::ix(), EEDetId::iy(), R_M, cond::rpcobgas::time, and EEDetId::zside().

178 {
181 
182  std::vector<DetId> detIds;
183  detIds.push_back(geom->getClosestCell(tsosEnds[0].globalPosition()));
184  detIds.push_back(geom->getClosestCell(tsosEnds[1].globalPosition()));
185 
186  double energy = 0, time = 0;
187  ntime = 0;
188 
189  if(subDet == EcalBarrel)
190  {
191  EBDetId frontId(detIds[0]);
192  EBDetId backId(detIds[1]);
193 
194  double ieta = (frontId.ieta() + backId.ieta())/2.;
195  double weta = fabs(frontId.ieta() - backId.ieta())/2.;
196 
197  double iphi = (frontId.iphi() + backId.iphi())/2.;
198  double wphi = fabs(frontId.iphi() - backId.iphi())/2.;
199 
201  recHit!= recHitsBarrel->end();
202  recHit++)
203  {
204  EBDetId detId(recHit->id());
205  const CaloCellGeometry* cell = geom->getGeometry(detId);
206 
207  if(fabs(detId.ieta() - ieta) < weta + 4 &&
208  fabs(detId.iphi() - iphi) < wphi + 4)
209  if(getDistance(tsosEnds, cell) < R_M)
210  {
211  energy += recHit->energy();
212  time += recHit->energy() * recHit->time();
213  ntime++;
214  }
215  }
216  }
217  else
218  {
219  EEDetId frontId(detIds[0]);
220  EEDetId backId(detIds[1]);
221 
222  double ix = (frontId.ix() + backId.ix())/2.;
223  double wx = fabs(frontId.ix() - backId.ix())/2.;
224 
225  double iy = (frontId.iy() + backId.iy())/2.;
226  double wy = fabs(frontId.iy() - backId.iy())/2.;
227 
229  recHit!= recHitsEndcap->end();
230  recHit++)
231  {
232  EEDetId detId(recHit->id());
233  const CaloCellGeometry* cell = geom->getGeometry(detId);
234 
235  if(detId.zside() == frontId.zside() &&
236  detId.zside() == backId.zside())
237  if( fabs(detId.ix() - ix) < wx + 4 &&
238  fabs(detId.iy() - iy) < wy + 4)
239  if(getDistance(tsosEnds, cell) < R_M)
240  {
241  energy += recHit->energy();
242  time += recHit->energy() * recHit->time();
243  ntime++;
244  }
245  }
246  }
247 
248  if(energy > 0) time /= energy;
249 
250  return std::pair<double,double> (energy,time);
251 }
const CaloSubdetectorGeometry * getSubdetectorGeometry(const DetId &id) const
access the subdetector geometry for the given subdetector directly
Definition: CaloGeometry.cc:43
std::vector< EcalRecHit >::const_iterator const_iterator
const double R_M
edm::Handle< EBRecHitCollection > recHitsBarrel
virtual const CaloCellGeometry * getGeometry(const DetId &id) const
Get the cell geometry of a given detector id. Should return false if not found.
double getDistance(const std::vector< TrajectoryStateOnSurface > &tsosEnds, const CaloCellGeometry *cell)
const CaloGeometry * theCaloGeometry
virtual DetId getClosestCell(const GlobalPoint &r) const
edm::Handle< EERecHitCollection > recHitsEndcap
pair< double, double > EcalShowerProperties::processTrack ( const reco::Track track,
int &  ntime 
)

Definition at line 255 of file EcalShowerProperties.cc.

References Plane::build(), newFWLiteAna::build, EcalBarrel, EcalEndcap, TrajectoryStateOnSurface::globalPosition(), TrajectoryStateOnSurface::isValid(), PV3DBase< T, PVType, FrameType >::perp(), pos, CosmicsPD_Skims::radius, query::result, makeMuonMisalignmentScenario::rot, detailsBasic3DVector::z, and PV3DBase< T, PVType, FrameType >::z().

256 {
257  // Get trajectory at outer point
258  FreeTrajectoryState ftsAtLastPoint = getTrajectoryAtOuterPoint(track);
259 
260  // Ecal cylinder
261  double radius = 129.0; // cm
262  double z = 320.9; // cm
264 
265  // Subdetector
266  std::vector<int> subDets;
267  subDets.push_back(EcalBarrel);
268  subDets.push_back(EcalEndcap);
269 
270  std::pair<double,double> result(0,0);
271 
272  // Take barrel and endcap
273  for(std::vector<int>::const_iterator subDet = subDets.begin();
274  subDet!= subDets.end(); subDet++)
275  {
276  TrajectoryStateOnSurface tsosBeforeEcal;
277 
278  if(*subDet == EcalBarrel)
279  {
280  Surface::PositionType pos(0,0,0);
281  Cylinder::CylinderPointer theBarrel = Cylinder::build(radius, pos, rot);
282  tsosBeforeEcal = thePropagator->propagate(ftsAtLastPoint, *theBarrel);
283 
284  if(!tsosBeforeEcal.isValid()) continue;
285  if(fabs(tsosBeforeEcal.globalPosition().z()) > z) continue;
286  }
287  else
288  {
289  Surface::PositionType pos(0,0,z);
290  Plane::PlanePointer theEndcap = Plane::build(pos, rot);
291  tsosBeforeEcal = thePropagator->propagate(ftsAtLastPoint, *theEndcap);
292 
293  if(!tsosBeforeEcal.isValid()) continue;
294  if(fabs(tsosBeforeEcal.globalPosition().perp()) > radius) continue;
295  }
296 
297  std::vector<TrajectoryStateOnSurface> tsosEnds =
298  getEndpoints(ftsAtLastPoint, tsosBeforeEcal, *subDet);
299 
300  if(tsosEnds.size() == 2)
301  result = processEcalRecHits(tsosEnds, *subDet, ntime);
302  }
303 
304  return result;
305 }
T perp() const
Definition: PV3DBase.h:72
FreeTrajectoryState getTrajectoryAtOuterPoint(const reco::Track &track)
GlobalPoint globalPosition() const
float float float z
std::pair< double, double > processEcalRecHits(const std::vector< TrajectoryStateOnSurface > &tsosEnds, int subDet, int &ntime)
static PlanePointer build(Args &&...args)
Definition: Plane.h:36
T z() const
Definition: PV3DBase.h:64
tuple result
Definition: query.py:137
virtual TrajectoryStateOnSurface propagate(const FreeTrajectoryState &, const Surface &) const
Definition: Propagator.cc:12
std::vector< TrajectoryStateOnSurface > getEndpoints(const FreeTrajectoryState &ftsAtLastPoint, const TrajectoryStateOnSurface &tsosBeforeEcal, int subDet)
const Propagator * thePropagator

Member Data Documentation

edm::Handle<EBRecHitCollection> EcalShowerProperties::recHitsBarrel
private

Definition at line 40 of file EcalShowerProperties.h.

edm::Handle<EERecHitCollection> EcalShowerProperties::recHitsEndcap
private

Definition at line 41 of file EcalShowerProperties.h.

const CaloGeometry* EcalShowerProperties::theCaloGeometry
private

Definition at line 38 of file EcalShowerProperties.h.

const MagneticField* EcalShowerProperties::theMagneticField
private

Definition at line 36 of file EcalShowerProperties.h.

const Propagator* EcalShowerProperties::thePropagator
private

Definition at line 37 of file EcalShowerProperties.h.