CMS 3D CMS Logo

FindDistCone.cc
Go to the documentation of this file.
5 
6 namespace spr {
7 
8  // Cone clustering core
9  double getDistInPlaneTrackDir(const GlobalPoint& caloPoint,
10  const GlobalVector& caloVector,
11  const GlobalPoint& rechitPoint,
12  bool debug) {
13  const GlobalVector caloIntersectVector(caloPoint.x(), caloPoint.y(),
14  caloPoint.z()); //p
15 
16  const GlobalVector caloUnitVector = caloVector.unit();
17  const GlobalVector rechitVector(rechitPoint.x(), rechitPoint.y(), rechitPoint.z());
18  const GlobalVector rechitUnitVector = rechitVector.unit();
19  double dotprod_denominator = caloUnitVector.dot(rechitUnitVector);
20  double dotprod_numerator = caloUnitVector.dot(caloIntersectVector);
21  double rechitdist = dotprod_numerator / dotprod_denominator;
22  const GlobalVector effectiveRechitVector = rechitdist * rechitUnitVector;
23  const GlobalPoint effectiveRechitPoint(
24  effectiveRechitVector.x(), effectiveRechitVector.y(), effectiveRechitVector.z());
25  GlobalVector distance_vector = effectiveRechitPoint - caloPoint;
26  if (debug) {
27  edm::LogVerbatim("IsoTrack") << "getDistInPlaneTrackDir: point " << caloPoint << " dirn " << caloVector
28  << " numerator " << dotprod_numerator << " denominator " << dotprod_denominator
29  << " distance " << distance_vector.mag();
30  }
31  if (dotprod_denominator > 0. && dotprod_numerator > 0.) {
32  return distance_vector.mag();
33  } else {
34  return 999999.;
35  }
36  }
37 
38  // Not used, but here for reference
39  double getDistInCMatEcal(double eta1, double phi1, double eta2, double phi2, bool debug) {
40  double dR, Rec;
41  if (fabs(eta1) < spr::etaBEEcal)
42  Rec = spr::rFrontEB;
43  else
44  Rec = spr::zFrontEE;
45  double ce1 = cosh(eta1);
46  double ce2 = cosh(eta2);
47  double te1 = tanh(eta1);
48  double te2 = tanh(eta2);
49 
50  double z = cos(phi1 - phi2) / ce1 / ce2 + te1 * te2;
51  if (z != 0)
52  dR = fabs(Rec * ce1 * sqrt(1. / z / z - 1.));
53  else
54  dR = 999999.;
55  if (debug)
56  edm::LogVerbatim("IsoTrack") << "getDistInCMatEcal: between (" << eta1 << ", " << phi1 << ") and (" << eta2
57  << ", " << phi2 << " is " << dR;
58  return dR;
59  }
60 
61  // Not used, but here for reference
62  double getDistInCMatHcal(double eta1, double phi1, double eta2, double phi2, bool debug) {
63  // Radii and eta from Geometry/HcalCommonData/data/hcalendcapalgo.xml
64  // and Geometry/HcalCommonData/data/hcalbarrelalgo.xml
65 
66  double dR, Rec;
67  if (fabs(eta1) < spr::etaBEHcal)
68  Rec = spr::rFrontHB;
69  else
70  Rec = spr::zFrontHE;
71  double ce1 = cosh(eta1);
72  double ce2 = cosh(eta2);
73  double te1 = tanh(eta1);
74  double te2 = tanh(eta2);
75 
76  double z = cos(phi1 - phi2) / ce1 / ce2 + te1 * te2;
77  if (z != 0)
78  dR = fabs(Rec * ce1 * sqrt(1. / z / z - 1.));
79  else
80  dR = 999999.;
81  if (debug)
82  edm::LogVerbatim("IsoTrack") << "getDistInCMatHcal: between (" << eta1 << ", " << phi1 << ") and (" << eta2
83  << ", " << phi2 << " is " << dR;
84  return dR;
85  }
86 
88  std::vector<int>& RH_ieta,
89  std::vector<int>& RH_iphi,
90  std::vector<double>& RH_ene,
91  bool) {
92  RH_ieta.push_back(hit->id().ieta());
93  RH_iphi.push_back(hit->id().iphi());
94  RH_ene.push_back(hit->energy());
95  }
96 
97  void getEtaPhi(edm::PCaloHitContainer::const_iterator hit,
98  std::vector<int>& RH_ieta,
99  std::vector<int>& RH_iphi,
100  std::vector<double>& RH_ene,
101  bool) {
102  // SimHit function not yet implemented.
103  RH_ieta.push_back(-9);
104  RH_iphi.push_back(-9);
105  RH_ene.push_back(-9.);
106  }
107 
109  std::vector<int>& RH_ieta,
110  std::vector<int>& RH_iphi,
111  std::vector<double>& RH_ene,
112  bool) {
113  // Ecal function not yet implemented.
114  RH_ieta.push_back(-9);
115  RH_iphi.push_back(-9);
116  RH_ene.push_back(-9.);
117  }
118 
120  ieta = hit->id().ieta();
121  iphi = hit->id().iphi();
122  }
123 
124  void getEtaPhi(edm::PCaloHitContainer::const_iterator hit, int& ieta, int& iphi, bool) {
125  DetId id = DetId(hit->id());
126  if (id.det() == DetId::Hcal) {
127  ieta = ((HcalDetId)(hit->id())).ieta();
128  iphi = ((HcalDetId)(hit->id())).iphi();
129  } else if (id.det() == DetId::Ecal && id.subdetId() == EcalBarrel) {
130  ieta = ((EBDetId)(id)).ieta();
131  iphi = ((EBDetId)(id)).iphi();
132  } else {
133  ieta = 999;
134  iphi = 999;
135  }
136  }
137 
139  DetId id = hit->id();
140  if (id.subdetId() == EcalBarrel) {
141  ieta = ((EBDetId)(id)).ieta();
142  iphi = ((EBDetId)(id)).iphi();
143  } else {
144  ieta = 999;
145  iphi = 999;
146  }
147  }
148 
150  double energy = ((useRaw == 1) ? hit->eraw() : ((useRaw == 2) ? hit->eaux() : hit->energy()));
151  return energy;
152  }
153 
154  double getEnergy(EcalRecHitCollection::const_iterator hit, int, bool) { return hit->energy(); }
155 
156  double getEnergy(edm::PCaloHitContainer::const_iterator hit, int, bool) {
157  // This will not yet handle Ecal CaloHits!!
158  double samplingWeight = 1.;
159  // Hard coded sampling weights from JFH analysis of iso tracks
160  // Sept 2009.
161  DetId id = hit->id();
162  if (id.det() == DetId::Hcal) {
163  HcalDetId detId(id);
164  if (detId.subdet() == HcalBarrel)
165  samplingWeight = 114.1;
166  else if (detId.subdet() == HcalEndcap)
167  samplingWeight = 167.3;
168  else {
169  // ONLY protection against summing HO, HF simhits
170  return 0.;
171  }
172  }
173 
174  return samplingWeight * hit->energy();
175  }
176 
178  DetId detId(hit->id());
179  return (static_cast<const HcalGeometry*>(geo->getSubdetectorGeometry(detId)))->getPosition(detId);
180  }
181 
182  GlobalPoint getGpos(const CaloGeometry* geo, edm::PCaloHitContainer::const_iterator hit, bool) {
183  DetId detId(hit->id());
184  GlobalPoint point = (detId.det() == DetId::Hcal)
185  ? (static_cast<const HcalGeometry*>(geo->getSubdetectorGeometry(detId)))->getPosition(detId)
186  : geo->getPosition(detId);
187  return point;
188  }
189 
191  // Not tested for EcalRecHits!!
192  if (hit->id().subdetId() == EcalEndcap) {
193  EEDetId EEid = EEDetId(hit->id());
194  return geo->getPosition(EEid);
195  } else { // (hit->id().subdetId() == EcalBarrel)
196  EBDetId EBid = EBDetId(hit->id());
197  return geo->getPosition(EBid);
198  }
199  }
200 
202  double energy = ((useRaw == 1) ? hit->eraw() : ((useRaw == 2) ? hit->eaux() : hit->energy()));
203  return energy;
204  }
205 
206  double getRawEnergy(EcalRecHitCollection::const_iterator hit, int) { return hit->energy(); }
207 
208  double getRawEnergy(edm::PCaloHitContainer::const_iterator hit, int) { return hit->energy(); }
209 } // namespace spr
Log< level::Info, true > LogVerbatim
static const double etaBEEcal
Definition: CaloConstants.h:12
double getDistInCMatHcal(double eta1, double phi1, double eta2, double phi2, bool debug=false)
Definition: FindDistCone.cc:62
double getDistInPlaneTrackDir(const GlobalPoint &caloPoint, const GlobalVector &caloVector, const GlobalPoint &rechitPoint, bool debug=false)
Definition: FindDistCone.cc:9
void tanh(data_T data[CONFIG_T::n_in], res_T res[CONFIG_T::n_in])
static const double etaBEHcal
Definition: CaloConstants.h:15
T z() const
Definition: PV3DBase.h:61
double getEnergy(HBHERecHitCollection::const_iterator hit, int useRaw=0, bool debug=false)
PreciseFloatType< T, U >::Type dot(const Vector3DBase< U, FrameTag > &v) const
Definition: Vector3DBase.h:99
static const double zFrontHE
Definition: CaloConstants.h:13
std::vector< T >::const_iterator const_iterator
static const double rFrontHB
Definition: CaloConstants.h:14
T x() const
Definition: PV3DBase.h:59
T y() const
Definition: PV3DBase.h:60
static const double zFrontEE
Definition: CaloConstants.h:9
double getDistInCMatEcal(double eta1, double phi1, double eta2, double phi2, bool debug=false)
Definition: FindDistCone.cc:39
GlobalPoint getPosition(const DetId &id) const
Get the position of a given detector id.
Definition: CaloGeometry.cc:50
T sqrt(T t)
Definition: SSEVec.h:19
static const double rFrontEB
Definition: CaloConstants.h:10
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
T mag() const
Definition: PV3DBase.h:64
unsigned int id
double getRawEnergy(HBHERecHitCollection::const_iterator hit, int useRaw=0)
Definition: DetId.h:17
#define debug
Definition: HDRShower.cc:19
void getEtaPhi(HBHERecHitCollection::const_iterator hit, std::vector< int > &RH_ieta, std::vector< int > &RH_iphi, std::vector< double > &RH_ene, bool debug=false)
Definition: FindDistCone.cc:87
GlobalPoint getGpos(const CaloGeometry *geo, HBHERecHitCollection::const_iterator hit, bool debug=false)
Vector3DBase unit() const
Definition: Vector3DBase.h:54
const CaloSubdetectorGeometry * getSubdetectorGeometry(const DetId &id) const
access the subdetector geometry for the given subdetector directly
Definition: CaloGeometry.cc:34
*vegas h *****************************************************used in the default bin number in original ***version of VEGAS is ***a higher bin number might help to derive a more precise ***grade subtle point
Definition: invegas.h:5