1 #ifndef Calibration_HcalCalibALgos_CommonUsefulStuff_h
2 #define Calibration_HcalCalibALgos_CommonUsefulStuff_h
37 const GlobalVector caloIntersectVector(caloPoint.
x(), caloPoint.
y(), caloPoint.
z());
41 const GlobalVector rechitVector(rechitPoint.
x(), rechitPoint.
y(), rechitPoint.
z());
44 double dotprod = caloIntersectUnitVector.
dot(rechitUnitVector);
45 double rechitdist = caloIntersectVector.mag() / dotprod;
47 const GlobalVector effectiveRechitVector = rechitdist * rechitUnitVector;
49 effectiveRechitVector.
x(), effectiveRechitVector.
y(), effectiveRechitVector.
z());
51 GlobalVector distance_vector = effectiveRechitPoint - caloPoint;
54 return distance_vector.
mag();
66 const GlobalVector caloIntersectVector(caloPoint.
x(), caloPoint.
y(),
70 const GlobalVector rechitVector(rechitPoint.
x(), rechitPoint.
y(), rechitPoint.
z());
72 double dotprod_denominator = caloUnitVector.
dot(rechitUnitVector);
73 double dotprod_numerator = caloUnitVector.dot(caloIntersectVector);
74 double rechitdist = dotprod_numerator / dotprod_denominator;
75 const GlobalVector effectiveRechitVector = rechitdist * rechitUnitVector;
77 effectiveRechitVector.
x(), effectiveRechitVector.
y(), effectiveRechitVector.
z());
78 GlobalVector distance_vector = effectiveRechitPoint - caloPoint;
79 if (dotprod_denominator > 0. && dotprod_numerator > 0.) {
80 return distance_vector.
mag();
110 const GlobalVector heightVector = trackDirection * coneHeight;
114 const GlobalVector caloIntersectVector(caloPoint.
x(), caloPoint.
y(), caloPoint.
z());
117 const GlobalVector coneBaseVector = heightVector + caloIntersectVector;
120 const GlobalPoint coneBasePoint(coneBaseVector.x(), coneBaseVector.y(), coneBaseVector.z());
123 const GlobalVector rechitVector(rechitPoint.
x(), rechitPoint.
y(), rechitPoint.
z());
142 double rechitdist = trackDirection.
dot(coneBaseVector) / trackDirection.
dot(rechitDirection);
147 const GlobalVector effectiveRechitVector = rechitdist * rechitDirection;
149 effectiveRechitVector.
x(), effectiveRechitVector.
y(), effectiveRechitVector.
z());
151 GlobalVector distance_vector = effectiveRechitPoint - coneBasePoint;
152 return distance_vector.
mag();
160 double eECALcone = 0;
161 std::vector<int> usedHitsEcal;
162 usedHitsEcal.clear();
164 for (std::vector<EcalRecHit>::const_iterator ehit = ecalCol.
begin(); ehit != ecalCol.
end(); ehit++) {
166 bool hitIsUsed =
false;
167 int hitHashedIndex = -10000;
176 for (uint32_t
i = 0;
i < usedHitsEcal.size();
i++) {
177 if (usedHitsEcal[
i] == hitHashedIndex)
182 usedHitsEcal.push_back(hitHashedIndex);
188 eECALcone += ehit->energy();
200 double eECALcone = 0;
201 std::vector<int> usedHitsEcal;
202 usedHitsEcal.clear();
203 for (std::vector<EcalRecHit>::const_iterator ehit = ecalCol.
begin(); ehit != ecalCol.
end(); ehit++) {
205 bool hitIsUsed =
false;
206 int hitHashedIndex = -10000;
215 for (uint32_t
i = 0;
i < usedHitsEcal.size();
i++) {
216 if (usedHitsEcal[
i] == hitHashedIndex)
221 usedHitsEcal.push_back(hitHashedIndex);
227 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)
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