19 : EBRecHitCollectionToken_(
21 EERecHitCollectionToken_(
23 ecalDetIdAssociatorToken_(iC.esConsumes(
edm::
ESInputTag(
"",
"EcalDetIdAssociator"))),
24 bFieldToken_(iC.esConsumes()),
25 theCaloGeometryToken_(iC.esConsumes()),
26 caloTopologyToken_(iC.esConsumes()) {
63 for (reco::TrackCollection::const_iterator ndTrack =
tracks->begin(); ndTrack !=
tracks->end(); ++ndTrack) {
65 sqrt(
pow((
track.outerEta() - ndTrack->outerEta()), 2) +
pow((
track.outerPhi() - ndTrack->outerPhi()), 2));
75 std::map<int, GlobalPoint> trackExitPositionMap;
76 std::map<int, float> trackCrossedXtalCurvedMap;
80 std::vector<SteppingHelixStateInfo> neckLace;
83 double totalLengthCurved = 0.;
86 if (neckLace.size() > 1) {
88 trackCrossedXtalCurvedMap,
98 float sumWeightedTime = 0;
99 float sumTimeErrorSqr = 0;
101 float sumTrackLength = 0;
102 std::vector<EcalRecHit> crossedRecHits;
105 std::map<int, GlobalPoint>::const_iterator trackExitMapIt = trackExitPositionMap.begin();
106 for (std::map<int, float>::const_iterator mapIt = trackCrossedXtalCurvedMap.begin();
107 mapIt != trackCrossedXtalCurvedMap.end();
111 thisHit = ebRecHits->
find(ebDetId);
112 if (thisHit == ebRecHits->
end()) {
118 if (!
hit.isTimeValid())
120 uint32_t rhFlag =
hit.recoFlag();
124 float errorOnThis =
hit.timeError();
125 sumTrackLength += mapIt->second;
126 sumEnergy +=
hit.energy();
127 crossedRecHits.push_back(
hit);
130 result.ecalTrackLengths.push_back(mapIt->second);
131 result.ecalTrackExitPositions.push_back(trackExitMapIt->second);
132 result.ecalEnergies.push_back(
hit.energy());
134 result.ecalTimeErrors.push_back(
hit.timeError());
135 result.ecalOutOfTimeEnergies.push_back(0.);
136 result.ecalOutOfTimeChi2s.push_back(0.);
138 result.ecalDetIds.push_back(ebDetId);
143 if (
hit.isTimeErrorValid())
145 sumWeightedTime +=
hit.time() / (errorOnThis * errorOnThis);
146 sumTimeErrorSqr += 1 / (errorOnThis * errorOnThis);
152 if (!crossedRecHits.empty()) {
154 sort(crossedRecHits.begin(), crossedRecHits.end(), [](
auto&
x,
auto&
y) {
return (
x.energy() >
y.energy()); });
155 result.ecalCrossedEnergy = sumEnergy;
156 result.ecalCrysCrossed = crossedRecHits.size();
157 result.ecalDeDx = sumEnergy / sumTrackLength;
162 if (sumTimeErrorSqr > 0) {
163 result.ecalTime = sumWeightedTime / sumTimeErrorSqr;
164 result.ecalTimeError =
sqrt(1 / sumTimeErrorSqr);
165 DetId maxEnergyId = crossedRecHits.begin()->id();
167 if (maxEnergyId !=
DetId())
173 double muonShowerMax = frontFaceR + 11.5;
174 double gammaShowerMax = frontFaceR + 6.23;
189 if (!
info.crossedHcalRecHits.empty()) {
215 prop->setMaterialMode(
false);
216 prop->applyRadX0Correction(
true);
222 std::map<int, float>& trackCrossedXtalMap,
223 double& totalLengthCurved,
228 const std::vector<SteppingHelixStateInfo>& neckLace) {
230 internalPointCurved = origin;
231 externalPointCurved = origin;
233 bool firstPoint =
false;
234 trackCrossedXtalMap.clear();
239 for (std::vector<SteppingHelixStateInfo>::const_iterator
itr = (neckLace.begin() + 1);
itr != neckLace.end(); ++
itr) {
241 std::vector<DetId> surroundingMatrix;
249 ->inside(probe_gp))) {
250 double step = ((*itr).position() - (*(
itr - 1)).position()).
mag();
253 trackExitPositionMap, trackCrossedXtalMap, closestEndcapDetIdToProbe,
step,
point, theEndcapSubdetGeometry);
254 totalLengthCurved +=
step;
256 if (firstPoint ==
false) {
257 internalPointCurved = probe_gp;
261 externalPointCurved = probe_gp;
266 ->inside(probe_gp))) {
267 double step = ((*itr).position() - (*(
itr - 1)).position()).
mag();
270 trackExitPositionMap, trackCrossedXtalMap, closestBarrelDetIdToProbe,
step,
point, theBarrelSubdetGeometry);
271 totalLengthCurved +=
step;
273 if (firstPoint ==
false) {
274 internalPointCurved = probe_gp;
278 externalPointCurved = probe_gp;
284 for (
unsigned int k = 0;
k < surroundingMatrix.size(); ++
k) {
287 ->inside(probe_gp)) {
288 double step = ((*itr).position() - (*(
itr - 1)).position()).
mag();
292 surroundingMatrix[
k],
296 totalLengthCurved +=
step;
298 if (firstPoint ==
false) {
299 internalPointCurved = probe_gp;
303 externalPointCurved = probe_gp;
308 surroundingMatrix.clear();
316 std::map<int, float>& trackCrossedXtalMap,
321 auto cell_p = theSubdetGeometry->
getGeometry(aDetId);
325 std::map<int, GlobalPoint>::iterator xtal = trackExitPositionMap.find(aDetId.
rawId());
326 if (xtal != trackExitPositionMap.end())
327 ((*xtal).second) =
diff;
329 trackExitPositionMap.insert(std::pair<int, GlobalPoint>(aDetId.
rawId(),
diff));
331 std::map<int, float>::iterator xtal2 = trackCrossedXtalMap.find(aDetId.
rawId());
332 if (xtal2 != trackCrossedXtalMap.end())
333 ((*xtal2).second) +=
step;
335 trackCrossedXtalMap.insert(std::pair<int, float>(aDetId.
rawId(),
step));