Go to the documentation of this file.00001 #include "Calibration/IsolatedParticles/interface/FindDistCone.h"
00002
00003 #include <iostream>
00004
00005 namespace spr {
00006
00007
00008 double getDistInPlaneTrackDir(const GlobalPoint& caloPoint, const GlobalVector& caloVector, const GlobalPoint& rechitPoint) {
00009
00010 const GlobalVector caloIntersectVector(caloPoint.x(),
00011 caloPoint.y(),
00012 caloPoint.z());
00013
00014 const GlobalVector caloUnitVector = caloVector.unit();
00015 const GlobalVector rechitVector(rechitPoint.x(),
00016 rechitPoint.y(),
00017 rechitPoint.z());
00018 const GlobalVector rechitUnitVector = rechitVector.unit();
00019 double dotprod_denominator = caloUnitVector.dot(rechitUnitVector);
00020 double dotprod_numerator = caloUnitVector.dot(caloIntersectVector);
00021 double rechitdist = dotprod_numerator/dotprod_denominator;
00022 const GlobalVector effectiveRechitVector = rechitdist*rechitUnitVector;
00023 const GlobalPoint effectiveRechitPoint(effectiveRechitVector.x(),
00024 effectiveRechitVector.y(),
00025 effectiveRechitVector.z());
00026 GlobalVector distance_vector = effectiveRechitPoint-caloPoint;
00027 if (dotprod_denominator > 0. && dotprod_numerator > 0.) {
00028 return distance_vector.mag();
00029 } else {
00030 return 999999.;
00031 }
00032 }
00033
00034
00035 double getDistInCMatEcal(double eta1, double phi1, double eta2, double phi2){
00036
00037 double dR, Rec;
00038 if (fabs(eta1)<1.479) Rec=129;
00039 else Rec=317;
00040 double ce1=cosh(eta1);
00041 double ce2=cosh(eta2);
00042 double te1=tanh(eta1);
00043 double te2=tanh(eta2);
00044
00045 double z=cos(phi1-phi2)/ce1/ce2+te1*te2;
00046 if(z!=0) dR=fabs(Rec*ce1*sqrt(1./z/z-1.));
00047 else dR=999999.;
00048 return dR;
00049 }
00050
00051
00052
00053 double getDistInCMatHcal(double eta1, double phi1, double eta2, double phi2){
00054
00055
00056
00057
00058 double dR, Rec;
00059 if (fabs(eta1)<1.392) Rec=177.5;
00060 else Rec=391.95;
00061 double ce1=cosh(eta1);
00062 double ce2=cosh(eta2);
00063 double te1=tanh(eta1);
00064 double te2=tanh(eta2);
00065
00066 double z=cos(phi1-phi2)/ce1/ce2+te1*te2;
00067 if(z!=0) dR=fabs(Rec*ce1*sqrt(1./z/z-1.));
00068 else dR=999999.;
00069 return dR;
00070 }
00071
00072 void getEtaPhi(HBHERecHitCollection::const_iterator hit, std::vector<int>& RH_ieta, std::vector<int>& RH_iphi, std::vector<double>& RH_ene) {
00073
00074 RH_ieta.push_back(hit->id().ieta());
00075 RH_iphi.push_back(hit->id().iphi());
00076 RH_ene.push_back(hit->energy());
00077 }
00078
00079 void getEtaPhi(edm::PCaloHitContainer::const_iterator hit, std::vector<int>& RH_ieta, std::vector<int>& RH_iphi, std::vector<double>& RH_ene) {
00080
00081 RH_ieta.push_back(-9);
00082 RH_iphi.push_back(-9);
00083 RH_ene.push_back(-9.);
00084 }
00085
00086 void getEtaPhi(EcalRecHitCollection::const_iterator hit, std::vector<int>& RH_ieta, std::vector<int>& RH_iphi, std::vector<double>& RH_ene) {
00087
00088 RH_ieta.push_back(-9);
00089 RH_iphi.push_back(-9);
00090 RH_ene.push_back(-9.);
00091 }
00092
00093 void getEtaPhi(HBHERecHitCollection::const_iterator hit,int& ieta,int& iphi){
00094 ieta = hit->id().ieta();
00095 iphi = hit->id().iphi();
00096 }
00097
00098 void getEtaPhi(edm::PCaloHitContainer::const_iterator hit,int& ieta,int& iphi){
00099 DetId id = DetId(hit->id());
00100 if (id.det() == DetId::Hcal) {
00101 ieta = ((HcalDetId)(hit->id())).ieta();
00102 iphi = ((HcalDetId)(hit->id())).iphi();
00103 } else if (id.det() == DetId::Ecal && id.subdetId() == EcalBarrel) {
00104 ieta = ((EBDetId)(id)).ieta();
00105 iphi = ((EBDetId)(id)).iphi();
00106 } else {
00107 ieta = 999;
00108 iphi = 999;
00109 }
00110 }
00111
00112 void getEtaPhi(EcalRecHitCollection::const_iterator hit,int& ieta,int& iphi){
00113 DetId id = hit->id();
00114 if (id.subdetId() == EcalBarrel) {
00115 ieta = ((EBDetId)(id)).ieta();
00116 iphi = ((EBDetId)(id)).iphi();
00117 } else {
00118 ieta = 999;
00119 iphi = 999;
00120 }
00121 }
00122
00123 double getEnergy(HBHERecHitCollection::const_iterator hit) {
00124 return hit->energy();
00125 }
00126
00127 double getEnergy(EcalRecHitCollection::const_iterator hit) {
00128 return hit->energy();
00129 }
00130
00131 double getEnergy(edm::PCaloHitContainer::const_iterator hit) {
00132
00133 double samplingWeight = 1.;
00134
00135
00136 HcalDetId detId(hit->id());
00137 if (detId.subdet() == HcalBarrel)
00138 samplingWeight = 114.1;
00139 else if (detId.subdet() == HcalEndcap)
00140 samplingWeight = 167.3;
00141 else {
00142
00143 return 0.;
00144 }
00145
00146 return samplingWeight*hit->energy();
00147 }
00148
00149 GlobalPoint getGpos(const CaloGeometry* geo,HBHERecHitCollection::const_iterator hit) {
00150 DetId detId(hit->id());
00151 return geo->getPosition(detId);
00152 }
00153
00154 GlobalPoint getGpos(const CaloGeometry* geo,edm::PCaloHitContainer::const_iterator hit) {
00155 DetId detId(hit->id());
00156 return geo->getPosition(detId);
00157 }
00158
00159 GlobalPoint getGpos(const CaloGeometry* geo, EcalRecHitCollection::const_iterator hit) {
00160
00161 if (hit->id().subdetId() == EcalEndcap) {
00162 EEDetId EEid = EEDetId(hit->id());
00163 return geo->getPosition(EEid);
00164 } else {
00165 EBDetId EBid = EBDetId(hit->id());
00166 return geo->getPosition(EBid);
00167 }
00168 }
00169 }