1 #ifndef CommonUsefulStuff_h
2 #define CommonUsefulStuff_h
77 double dotprod = caloIntersectUnitVector.
dot(rechitUnitVector);
78 double rechitdist = caloIntersectVector.mag()/dotprod;
81 const GlobalVector effectiveRechitVector = rechitdist*rechitUnitVector;
82 const GlobalPoint effectiveRechitPoint(effectiveRechitVector.
x(),
83 effectiveRechitVector.
y(),
84 effectiveRechitVector.
z());
87 GlobalVector distance_vector = effectiveRechitPoint-caloPoint;
91 return distance_vector.
mag();
118 double dotprod_denominator = caloUnitVector.
dot(rechitUnitVector);
119 double dotprod_numerator = caloUnitVector.dot(caloIntersectVector);
120 double rechitdist = dotprod_numerator/dotprod_denominator;
121 const GlobalVector effectiveRechitVector = rechitdist*rechitUnitVector;
122 const GlobalPoint effectiveRechitPoint(effectiveRechitVector.
x(),
123 effectiveRechitVector.
y(),
124 effectiveRechitVector.
z());
125 GlobalVector distance_vector = effectiveRechitPoint-caloPoint;
126 if (dotprod_denominator > 0. && dotprod_numerator > 0.)
129 return distance_vector.
mag();
166 const GlobalVector heightVector = trackDirection*coneHeight;
175 const GlobalVector coneBaseVector = heightVector+caloIntersectVector;
178 const GlobalPoint coneBasePoint(coneBaseVector.x(),
204 double rechitdist = trackDirection.
dot(coneBaseVector)/trackDirection.
dot(rechitDirection);
209 const GlobalVector effectiveRechitVector = rechitdist*rechitDirection;
210 const GlobalPoint effectiveRechitPoint(effectiveRechitVector.
x(),
211 effectiveRechitVector.
y(),
212 effectiveRechitVector.
z());
215 GlobalVector distance_vector = effectiveRechitPoint-coneBasePoint;
216 return distance_vector.
mag();
223 double eECALcone = 0;
224 std::vector<int> usedHitsEcal;
225 usedHitsEcal.clear();
227 for (std::vector<EcalRecHit>::const_iterator ehit=ecalCol.
begin(); ehit!=ecalCol.
end(); ehit++)
230 bool hitIsUsed=
false;
231 int hitHashedIndex=-10000;
242 for (uint32_t
i=0;
i<usedHitsEcal.size();
i++)
244 if (usedHitsEcal[
i]==hitHashedIndex) hitIsUsed=
true;
246 if (hitIsUsed)
continue;
247 usedHitsEcal.push_back(hitHashedIndex);
254 eECALcone += ehit->energy();
264 double eECALcone = 0;
265 std::vector<int> usedHitsEcal;
266 usedHitsEcal.clear();
267 for (std::vector<EcalRecHit>::const_iterator ehit=ecalCol.
begin(); ehit!=ecalCol.
end(); ehit++)
270 bool hitIsUsed=
false;
271 int hitHashedIndex=-10000;
282 for (uint32_t
i=0;
i<usedHitsEcal.size();
i++)
284 if (usedHitsEcal[
i]==hitHashedIndex) hitIsUsed=
true;
286 if (hitIsUsed)
continue;
287 usedHitsEcal.push_back(hitHashedIndex);
294 eECALcone += ehit->energy();
int hashedIndex() const
get a compact index for arrays
double ecalEnergyInCone(const GlobalPoint center, double radius, const EcalRecHitCollection ecalCol, const CaloGeometry *geo)
double getDistInPlaneTrackDir(const GlobalPoint caloPoint, const GlobalVector caloVector, const GlobalPoint rechitPoint)
PreciseFloatType< T, U >::Type dot(const Vector3DBase< U, FrameTag > &v) const
double getDistInPlane(const GlobalVector trackDirection, const GlobalPoint caloPoint, const GlobalPoint rechitPoint, double coneHeight)
const GlobalPoint & getPosition(const DetId &id) const
Get the position of a given detector id.
const_iterator end() const
Vector3DBase unit() const
double getDistInPlaneSimple(const GlobalPoint caloPoint, const GlobalPoint rechitPoint)
const_iterator begin() const