1 #ifndef CommonUsefulStuff_h
2 #define CommonUsefulStuff_h
76 double dotprod = caloIntersectUnitVector.
dot(rechitUnitVector);
77 double rechitdist = caloIntersectVector.mag()/dotprod;
80 const GlobalVector effectiveRechitVector = rechitdist*rechitUnitVector;
81 const GlobalPoint effectiveRechitPoint(effectiveRechitVector.
x(),
82 effectiveRechitVector.
y(),
83 effectiveRechitVector.
z());
86 GlobalVector distance_vector = effectiveRechitPoint-caloPoint;
90 return distance_vector.
mag();
117 double dotprod_denominator = caloUnitVector.
dot(rechitUnitVector);
118 double dotprod_numerator = caloUnitVector.dot(caloIntersectVector);
119 double rechitdist = dotprod_numerator/dotprod_denominator;
120 const GlobalVector effectiveRechitVector = rechitdist*rechitUnitVector;
121 const GlobalPoint effectiveRechitPoint(effectiveRechitVector.
x(),
122 effectiveRechitVector.
y(),
123 effectiveRechitVector.
z());
124 GlobalVector distance_vector = effectiveRechitPoint-caloPoint;
125 if (dotprod_denominator > 0. && dotprod_numerator > 0.)
128 return distance_vector.
mag();
165 const GlobalVector heightVector = trackDirection*coneHeight;
174 const GlobalVector coneBaseVector = heightVector+caloIntersectVector;
177 const GlobalPoint coneBasePoint(coneBaseVector.x(),
203 double rechitdist = trackDirection.
dot(coneBaseVector)/trackDirection.
dot(rechitDirection);
208 const GlobalVector effectiveRechitVector = rechitdist*rechitDirection;
209 const GlobalPoint effectiveRechitPoint(effectiveRechitVector.
x(),
210 effectiveRechitVector.
y(),
211 effectiveRechitVector.
z());
214 GlobalVector distance_vector = effectiveRechitPoint-coneBasePoint;
215 return distance_vector.
mag();
222 double eECALcone = 0;
223 std::vector<int> usedHitsEcal;
224 usedHitsEcal.clear();
226 for (std::vector<EcalRecHit>::const_iterator ehit=ecalCol.
begin(); ehit!=ecalCol.
end(); ehit++)
229 bool hitIsUsed=
false;
230 int hitHashedIndex=-10000;
241 for (uint32_t
i=0;
i<usedHitsEcal.size();
i++)
243 if (usedHitsEcal[
i]==hitHashedIndex) hitIsUsed=
true;
245 if (hitIsUsed)
continue;
246 usedHitsEcal.push_back(hitHashedIndex);
253 eECALcone += ehit->energy();
263 double eECALcone = 0;
264 std::vector<int> usedHitsEcal;
265 usedHitsEcal.clear();
266 for (std::vector<EcalRecHit>::const_iterator ehit=ecalCol.
begin(); ehit!=ecalCol.
end(); ehit++)
269 bool hitIsUsed=
false;
270 int hitHashedIndex=-10000;
281 for (uint32_t
i=0;
i<usedHitsEcal.size();
i++)
283 if (usedHitsEcal[
i]==hitHashedIndex) hitIsUsed=
true;
285 if (hitIsUsed)
continue;
286 usedHitsEcal.push_back(hitHashedIndex);
293 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