00001 #include "Calibration/IsolatedParticles/interface/MatrixECALDetIds.h"
00002 #include "Calibration/IsolatedParticles/interface/MatrixHCALDetIds.h"
00003 #include "Calibration/IsolatedParticles/interface/ChargeIsolation.h"
00004 #include "Calibration/IsolatedParticles/interface/GenSimInfo.h"
00005
00006 #include<iostream>
00007
00008 namespace spr{
00009
00010 void eGenSimInfo(const DetId& coreDet, HepMC::GenEvent::particle_const_iterator trkItr, std::vector<spr::propagatedGenTrackID>& trackIds, const CaloGeometry* geo, const CaloTopology* caloTopology, int ieta, int iphi, genSimInfo & info, bool debug) {
00011
00012 if (debug) std::cout << "eGenSimInfo:: For track " << (*trkItr)->momentum().rho() << "/" << (*trkItr)->momentum().eta() << "/" << (*trkItr)->momentum().phi() << " with ieta:iphi " << ieta << ":" << iphi << std::endl;
00013
00014 std::vector<DetId> vdets = spr::matrixECALIds(coreDet, ieta, iphi, geo, caloTopology, debug);
00015 spr::cGenSimInfo(vdets, trkItr, trackIds, true, info, debug);
00016 }
00017
00018 void eGenSimInfo(const DetId& coreDet, HepMC::GenEvent::particle_const_iterator trkItr, std::vector<spr::propagatedGenTrackID>& trackIds, const CaloGeometry* geo, const CaloTopology* caloTopology, double dR, const GlobalVector& trackMom, spr::genSimInfo & info, bool debug) {
00019
00020 if (debug) std::cout << "eGenSimInfo:: For track " << (*trkItr)->momentum().rho() << "/" << (*trkItr)->momentum().eta() << "/" << (*trkItr)->momentum().phi() << " with dR,tMom " << dR << " " << trackMom << std::endl;
00021
00022 std::vector<DetId> vdets = spr::matrixECALIds(coreDet, dR, trackMom, geo, caloTopology, debug);
00023 spr::cGenSimInfo(vdets, trkItr, trackIds, true, info, debug);
00024 }
00025
00026 void eGenSimInfo(const DetId& coreDet, reco::GenParticleCollection::const_iterator trkItr, std::vector<spr::propagatedGenParticleID>& trackIds, const CaloGeometry* geo, const CaloTopology* caloTopology, int ieta, int iphi, genSimInfo & info, bool debug) {
00027
00028 if (debug) std::cout << "eGenSimInfo:: For track " << trkItr->momentum().R() << "/" << trkItr->momentum().eta() << "/" << trkItr->momentum().phi() << " with ieta:iphi " << ieta << ":" << iphi << std::endl;
00029
00030 std::vector<DetId> vdets = spr::matrixECALIds(coreDet, ieta, iphi, geo, caloTopology, debug);
00031 spr::cGenSimInfo(vdets, trkItr, trackIds, true, info, debug);
00032 }
00033
00034 void eGenSimInfo(const DetId& coreDet, reco::GenParticleCollection::const_iterator trkItr, std::vector<spr::propagatedGenParticleID>& trackIds, const CaloGeometry* geo, const CaloTopology* caloTopology, double dR, const GlobalVector& trackMom, spr::genSimInfo & info, bool debug) {
00035
00036 if (debug) std::cout << "eGenSimInfo:: For track " << trkItr->momentum().R() << "/" << trkItr->momentum().eta() << "/" << trkItr->momentum().phi() << " with dR,tMom " << dR << " " << trackMom << std::endl;
00037
00038 std::vector<DetId> vdets = spr::matrixECALIds(coreDet, dR, trackMom, geo, caloTopology, debug);
00039 spr::cGenSimInfo(vdets, trkItr, trackIds, true, info, debug);
00040 }
00041
00042 void hGenSimInfo(const DetId& coreDet, HepMC::GenEvent::particle_const_iterator trkItr, std::vector<spr::propagatedGenTrackID>& trackIds, const HcalTopology* topology, int ieta, int iphi, genSimInfo & info, bool includeHO, bool debug) {
00043
00044 if (debug) std::cout << "hGenSimInfo:: For track " << (*trkItr)->momentum().rho() << "/" << (*trkItr)->momentum().eta() << "/" << (*trkItr)->momentum().phi() << " with ieta:iphi " << ieta << ":" << iphi << std::endl;
00045
00046 std::vector<DetId> dets;
00047 dets.push_back(coreDet);
00048 std::vector<DetId> vdets = spr::matrixHCALIds(dets, topology, ieta, iphi, includeHO, debug);
00049 spr::cGenSimInfo(vdets, trkItr, trackIds, false, info, debug);
00050 }
00051
00052 void hGenSimInfo(const DetId& coreDet, HepMC::GenEvent::particle_const_iterator trkItr, std::vector<spr::propagatedGenTrackID>& trackIds, const CaloGeometry* geo, const HcalTopology* topology, double dR, const GlobalVector& trackMom, spr::genSimInfo & info, bool includeHO, bool debug) {
00053
00054 if (debug) std::cout << "hGenSimInfo:: For track " << (*trkItr)->momentum().rho() << "/" << (*trkItr)->momentum().eta() << "/" << (*trkItr)->momentum().phi() << " with dR,tMom " << dR << " " << trackMom << std::endl;
00055
00056 std::vector<DetId> vdets = spr::matrixHCALIds(coreDet, geo, topology, dR, trackMom, includeHO, debug);
00057 spr::cGenSimInfo(vdets, trkItr, trackIds, false, info, debug);
00058 }
00059
00060 void hGenSimInfo(const DetId& coreDet, reco::GenParticleCollection::const_iterator trkItr, std::vector<spr::propagatedGenParticleID>& trackIds, const HcalTopology* topology, int ieta, int iphi, genSimInfo & info, bool includeHO, bool debug) {
00061
00062 if (debug) std::cout << "hGenSimInfo:: For track " << trkItr->momentum().R() << "/" << trkItr->momentum().eta() << "/" << trkItr->momentum().phi() << " with ieta:iphi " << ieta << ":" << iphi << std::endl;
00063
00064 std::vector<DetId> dets;
00065 dets.push_back(coreDet);
00066 std::vector<DetId> vdets = spr::matrixHCALIds(dets, topology, ieta, iphi, includeHO, debug);
00067 spr::cGenSimInfo(vdets, trkItr, trackIds, false, info, debug);
00068 }
00069
00070 void hGenSimInfo(const DetId& coreDet, reco::GenParticleCollection::const_iterator trkItr, std::vector<spr::propagatedGenParticleID>& trackIds, const CaloGeometry* geo, const HcalTopology* topology, double dR, const GlobalVector& trackMom, spr::genSimInfo & info, bool includeHO, bool debug) {
00071
00072 if (debug) std::cout << "hGenSimInfo:: For track " << trkItr->momentum().R() << "/" << trkItr->momentum().eta() << "/" << trkItr->momentum().phi() << " with dR,tMom " << dR << " " << trackMom << std::endl;
00073
00074 std::vector<DetId> vdets = spr::matrixHCALIds(coreDet, geo, topology, dR, trackMom, includeHO, debug);
00075 spr::cGenSimInfo(vdets, trkItr, trackIds, false, info, debug);
00076 }
00077
00078 void cGenSimInfo(std::vector<DetId>& vdets, HepMC::GenEvent::particle_const_iterator trkItr, std::vector<spr::propagatedGenTrackID>& trackIds, bool ifECAL, spr::genSimInfo & info, bool debug) {
00079
00080 for (unsigned int i=0; i<trackIds.size(); ++i) {
00081 HepMC::GenEvent::particle_const_iterator trkItr2 = trackIds[i].trkItr;
00082
00083 if ( (trkItr2 != trkItr) && trackIds[i].ok) {
00084 int charge = trackIds[i].charge;
00085 int pdgid = trackIds[i].pdgId;
00086 double p = (*trkItr2)->momentum().rho();
00087 bool isolat= false;
00088 if (ifECAL) {
00089 const DetId anyCell = trackIds[i].detIdECAL;
00090 isolat = spr::chargeIsolation(anyCell,vdets);
00091 } else {
00092 const DetId anyCell = trackIds[i].detIdHCAL;
00093 isolat = spr::chargeIsolation(anyCell,vdets);
00094 }
00095 if (!isolat) spr::cGenSimInfo(charge, pdgid, p, info, debug);
00096 }
00097 }
00098 if (debug) {
00099 std::cout << "Isolation variables: isChargedIso :" << info.isChargedIso
00100 << " maxNearP " << info.maxNearP << " Energy e/mu/g/ch/nh "
00101 << info.eleEne << "," << info.muEne << "," << info.photonEne
00102 << "," << info.cHadronEne << "," << info.nHadronEne
00103 << " charge " << info.cHadronEne_[0] << ","
00104 << info.cHadronEne_[1] << "," << info.cHadronEne_[2]
00105 << std::endl;
00106 }
00107 }
00108
00109 void cGenSimInfo(std::vector<DetId>& vdets, reco::GenParticleCollection::const_iterator trkItr, std::vector<spr::propagatedGenParticleID>& trackIds, bool ifECAL, spr::genSimInfo & info, bool debug) {
00110
00111 for (unsigned int i=0; i<trackIds.size(); ++i) {
00112 reco::GenParticleCollection::const_iterator trkItr2 = trackIds[i].trkItr;
00113
00114 if ( (trkItr2 != trkItr) && trackIds[i].ok) {
00115 int charge = trackIds[i].charge;
00116 int pdgid = trackIds[i].pdgId;
00117 double p = trkItr2->momentum().R();
00118 bool isolat= false;
00119 if (ifECAL) {
00120 const DetId anyCell = trackIds[i].detIdECAL;
00121 isolat = spr::chargeIsolation(anyCell,vdets);
00122 } else {
00123 const DetId anyCell = trackIds[i].detIdHCAL;
00124 isolat = spr::chargeIsolation(anyCell,vdets);
00125 }
00126 if (!isolat) spr::cGenSimInfo(charge, pdgid, p, info, debug);
00127 }
00128 }
00129
00130 if (debug) {
00131 std::cout << "Isolation variables: isChargedIso :" << info.isChargedIso
00132 << " maxNearP " << info.maxNearP << " Energy e/mu/g/ch/nh "
00133 << info.eleEne << "," << info.muEne << "," << info.photonEne
00134 << "," << info.cHadronEne << "," << info.nHadronEne
00135 << " charge " << info.cHadronEne_[0] << ","
00136 << info.cHadronEne_[1] << "," << info.cHadronEne_[2]
00137 << std::endl;
00138 }
00139 }
00140
00141 void cGenSimInfo(int charge, int pdgid, double p, spr::genSimInfo & info, bool debug) {
00142
00143 if (pdgid==22 ) info.photonEne += p;
00144 else if (pdgid==11) info.eleEne += p;
00145 else if (pdgid==13) info.muEne += p;
00146 else if (std::abs(charge)>0) {
00147 info.isChargedIso = false;
00148 info.cHadronEne += p;
00149 if (p>1.0) info.cHadronEne_[0] += p;
00150 if (p>2.0) info.cHadronEne_[1] += p;
00151 if (p>3.0) info.cHadronEne_[2] += p;
00152 if (info.maxNearP<p) info.maxNearP=p;
00153 } else if (std::abs(charge)==0) {
00154 info.nHadronEne += p;
00155 }
00156 }
00157 }