26 const double R_M = 2.2;
36 theMagneticField = theMagneticFieldHandle.
product();
42 thePropagator = thePropagatorHandle.
product();
50 ev.
getByLabel(
"ecalRecHit",
"EcalRecHitsEB", recHitsBarrel);
51 ev.
getByLabel(
"ecalRecHit",
"EcalRecHitsEE", recHitsEndcap);
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);
91 std::vector<TrajectoryStateOnSurface> tsosEnds;
94 theCaloGeometry->getSubdetectorGeometry(
DetId::Ecal,subDet);
99 if(!geom->
present(detId))
return tsosEnds;
106 for(
int i = 0; i < 2; i++)
115 tsos = thePropagator->propagate(ftsAtLastPoint,*thePlane);
117 if(!tsos.
isValid())
return tsosEnds;
121 if(!geom->
present(detId))
return tsosEnds;
124 while(cell != oldcell && step++ < 5);
127 tsosEnds.push_back(tsos);
135 (
const std::vector<TrajectoryStateOnSurface> & tsosEnds,
142 p = tsosEnds[0].surface().toLocal(tsosEnds[0].globalPosition());
145 p = tsosEnds[0].surface().toLocal(tsosEnds[1].globalPosition());
151 for(
int i = 0; i < 4; i++)
159 double dm =
min(d1,d2);
163 if(lambda > 0 && lambda < 1)
165 double dp = (
c -
p1 - lambda * (
p2 -
p1)).mag2();
169 dmin =
min(dm, dmin);
177 (
const std::vector<TrajectoryStateOnSurface> & tsosEnds,
int subDet,
int & ntime)
180 theCaloGeometry->getSubdetectorGeometry(
DetId::Ecal,subDet);
182 std::vector<DetId> detIds;
183 detIds.push_back(geom->
getClosestCell(tsosEnds[0].globalPosition()));
184 detIds.push_back(geom->
getClosestCell(tsosEnds[1].globalPosition()));
194 double ieta = (frontId.
ieta() + backId.
ieta())/2.;
195 double weta = fabs(frontId.
ieta() - backId.
ieta())/2.;
197 double iphi = (frontId.
iphi() + backId.
iphi())/2.;
198 double wphi = fabs(frontId.
iphi() - backId.
iphi())/2.;
201 recHit!= recHitsBarrel->end();
207 if(fabs(detId.ieta() - ieta) < weta + 4 &&
208 fabs(detId.iphi() - iphi) < wphi + 4)
209 if(getDistance(tsosEnds, cell) <
R_M)
211 energy += recHit->energy();
212 time += recHit->energy() * recHit->time();
222 double ix = (frontId.
ix() + backId.
ix())/2.;
223 double wx = fabs(frontId.
ix() - backId.
ix())/2.;
225 double iy = (frontId.
iy() + backId.
iy())/2.;
226 double wy = fabs(frontId.
iy() - backId.
iy())/2.;
229 recHit!= recHitsEndcap->end();
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)
241 energy += recHit->energy();
242 time += recHit->energy() * recHit->time();
250 return std::pair<double,double> (
energy,
time);
266 std::vector<int> subDets;
270 std::pair<double,double>
result(0,0);
273 for(std::vector<int>::const_iterator subDet = subDets.begin();
274 subDet!= subDets.end(); subDet++)
281 Cylinder::CylinderPointer theBarrel =
Cylinder::build(radius, pos, rot);
282 tsosBeforeEcal = thePropagator->propagate(ftsAtLastPoint, *theBarrel);
284 if(!tsosBeforeEcal.
isValid())
continue;
291 tsosBeforeEcal = thePropagator->propagate(ftsAtLastPoint, *theEndcap);
293 if(!tsosBeforeEcal.
isValid())
continue;
297 std::vector<TrajectoryStateOnSurface> tsosEnds =
298 getEndpoints(ftsAtLastPoint, tsosBeforeEcal, *subDet);
300 if(tsosEnds.size() == 2)
301 result = processEcalRecHits(tsosEnds, *subDet, ntime);
double outerPy() const
y coordinate of momentum vector at the outermost hit position
Global3DPoint GlobalPoint
std::vector< EcalRecHit >::const_iterator const_iterator
FreeTrajectoryState getTrajectoryAtOuterPoint(const reco::Track &track)
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.
double outerZ() const
z coordinate of the outermost hit position
int iphi() const
get the crystal iphi
virtual bool present(const DetId &id) const
is this detid present in the geometry?
double getDistance(const std::vector< TrajectoryStateOnSurface > &tsosEnds, const CaloCellGeometry *cell)
std::pair< double, double > processEcalRecHits(const std::vector< TrajectoryStateOnSurface > &tsosEnds, int subDet, int &ntime)
CovarianceMatrix outerStateCovariance() const
outermost trajectory state curvilinear errors
static PlanePointer build(Args &&...args)
T mag2() const
The vector magnitude squared. Equivalent to vec.dot(vec)
double outerX() const
x coordinate of the outermost hit position
int ieta() const
get the crystal ieta
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
double outerPz() const
z coordinate of momentum vector at the outermost hit position
virtual DetId getClosestCell(const GlobalPoint &r) const
GlobalPoint position() const
T const * product() const
EcalShowerProperties(const edm::Event &ev, const edm::EventSetup &es)
double outerY() const
y coordinate of the outermost hit position
std::vector< TrajectoryStateOnSurface > getEndpoints(const FreeTrajectoryState &ftsAtLastPoint, const TrajectoryStateOnSurface &tsosBeforeEcal, int subDet)
int charge() const
track electric charge
std::pair< double, double > processTrack(const reco::Track &track, int &ntime)
double outerPx() const
x coordinate of momentum vector at the outermost hit position
virtual const CornersVec & getCorners() const =0
Returns the corner points of this cell's volume.