Skip to content

Commit

Permalink
Code check
Browse files Browse the repository at this point in the history
  • Loading branch information
Sunanda committed Aug 9, 2021
1 parent f7b5347 commit 28991f0
Show file tree
Hide file tree
Showing 9 changed files with 140 additions and 97 deletions.
16 changes: 7 additions & 9 deletions Calibration/IsolatedParticles/src/DetIdFromEtaPhi.cc
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ namespace spr {
}
const CaloSubdetectorGeometry* gECAL = geo->getSubdetectorGeometry(DetId::Ecal, subdet);
if (debug)
edm::LogVerbatim("IsoTrack") << "findDetIdECAL: eta " << eta << " theta " << theta << " phi " << phi << " radius " << radius << " subdet " << subdet;
edm::LogVerbatim("IsoTrack") << "findDetIdECAL: eta " << eta << " theta " << theta << " phi " << phi << " radius "
<< radius << " subdet " << subdet;
return spr::findDetIdCalo(gECAL, theta, phi, radius, debug);
}

Expand All @@ -38,16 +39,12 @@ namespace spr {
radius = spr::rFrontHB / std::sin(theta);
const CaloSubdetectorGeometry* gHCAL = geo->getSubdetectorGeometry(DetId::Hcal, HcalBarrel);
if (debug)
edm::LogVerbatim("IsoTrack") << "findDetIdHCAL: eta " << eta << " theta " << theta << " phi " << phi << " radius " << radius;
edm::LogVerbatim("IsoTrack") << "findDetIdHCAL: eta " << eta << " theta " << theta << " phi " << phi << " radius "
<< radius;
return spr::findDetIdCalo(gHCAL, theta, phi, radius, debug);
}

const DetId findDetIdCalo(const CaloSubdetectorGeometry* geo,
double theta,
double phi,
double radius,
bool debug) {

const DetId findDetIdCalo(const CaloSubdetectorGeometry* geo, double theta, double phi, double radius, bool debug) {
double rcyl = radius * std::sin(theta);
double z = radius * std::cos(theta);
GlobalPoint point(rcyl * std::cos(phi), rcyl * std::sin(phi), z);
Expand All @@ -62,7 +59,8 @@ namespace spr {
} else {
st1 << (HcalDetId)(cell);
}
edm::LogVerbatim("IsoTrack") << "findDetIdCalo: rcyl " << rcyl << " z " << z << " Point " << point << " DetId " << st1.str();
edm::LogVerbatim("IsoTrack") << "findDetIdCalo: rcyl " << rcyl << " z " << z << " Point " << point << " DetId "
<< st1.str();
}
return cell;
}
Expand Down
25 changes: 9 additions & 16 deletions Calibration/IsolatedParticles/src/FindDistCone.cc
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ namespace spr {
const GlobalVector& caloVector,
const GlobalPoint& rechitPoint,
bool debug) {

const GlobalVector caloIntersectVector(caloPoint.x(), caloPoint.y(),
caloPoint.z()); //p

Expand All @@ -25,7 +24,9 @@ namespace spr {
effectiveRechitVector.x(), effectiveRechitVector.y(), effectiveRechitVector.z());
GlobalVector distance_vector = effectiveRechitPoint - caloPoint;
if (debug) {
edm::LogVerbatim("IsoTrack") << "getDistInPlaneTrackDir: point " << caloPoint << " dirn " << caloVector << " numerator " << dotprod_numerator << " denominator " << dotprod_denominator << " distance " << distance_vector.mag();
edm::LogVerbatim("IsoTrack") << "getDistInPlaneTrackDir: point " << caloPoint << " dirn " << caloVector
<< " numerator " << dotprod_numerator << " denominator " << dotprod_denominator
<< " distance " << distance_vector.mag();
}
if (dotprod_denominator > 0. && dotprod_numerator > 0.) {
return distance_vector.mag();
Expand All @@ -35,12 +36,7 @@ namespace spr {
}

// Not used, but here for reference
double getDistInCMatEcal(double eta1,
double phi1,
double eta2,
double phi2,
bool debug) {

double getDistInCMatEcal(double eta1, double phi1, double eta2, double phi2, bool debug) {
double dR, Rec;
if (fabs(eta1) < spr::etaBEEcal)
Rec = spr::rFrontEB;
Expand All @@ -57,17 +53,13 @@ namespace spr {
else
dR = 999999.;
if (debug)
edm::LogVerbatim("IsoTrack") << "getDistInCMatEcal: between (" << eta1 << ", " << phi1 << ") and (" << eta2 << ", " << phi2 << " is " << dR;
edm::LogVerbatim("IsoTrack") << "getDistInCMatEcal: between (" << eta1 << ", " << phi1 << ") and (" << eta2
<< ", " << phi2 << " is " << dR;
return dR;
}

// Not used, but here for reference
double getDistInCMatHcal(double eta1,
double phi1,
double eta2,
double phi2,
bool debug) {

double getDistInCMatHcal(double eta1, double phi1, double eta2, double phi2, bool debug) {
// Radii and eta from Geometry/HcalCommonData/data/hcalendcapalgo.xml
// and Geometry/HcalCommonData/data/hcalbarrelalgo.xml

Expand All @@ -88,7 +80,8 @@ namespace spr {
dR = 999999.;
return dR;
if (debug)
edm::LogVerbatim("IsoTrack") << "getDistInCMatHcal: between (" << eta1 << ", " << phi1 << ") and (" << eta2 << ", " << phi2 << " is " << dR;
edm::LogVerbatim("IsoTrack") << "getDistInCMatHcal: between (" << eta1 << ", " << phi1 << ") and (" << eta2
<< ", " << phi2 << " is " << dR;
}

void getEtaPhi(HBHERecHitCollection::const_iterator hit,
Expand Down
12 changes: 6 additions & 6 deletions Calibration/IsolatedParticles/src/FindEtaPhi.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,7 @@

namespace spr {

spr::EtaPhi getEtaPhi(int ieta,
int iphi,
bool debug) {

spr::EtaPhi getEtaPhi(int ieta, int iphi, bool debug) {
int ietal = (ieta - 1) / 2;
int ietar = ieta - ietal - 1;
int iphil = (iphi - 1) / 2;
Expand Down Expand Up @@ -41,9 +38,12 @@ namespace spr {
}

if (debug) {
edm::LogVerbatim("IsoTrack") << "getEtaPhi:: Has " << etaphi.ntrys << " possibilites for " << ieta << "X" << iphi << " matrix";
edm::LogVerbatim("IsoTrack") << "getEtaPhi:: Has " << etaphi.ntrys << " possibilites for " << ieta << "X" << iphi
<< " matrix";
for (int itry = 0; itry < etaphi.ntrys; itry++) {
edm::LogVerbatim("IsoTrack") << "Trial " << itry << " with etaE|etaW " << etaphi.ietaE[itry] << "|" << etaphi.ietaW[itry] << " and phiN|PhiS " << etaphi.iphiN[itry] << "|" << etaphi.iphiS[itry];
edm::LogVerbatim("IsoTrack") << "Trial " << itry << " with etaE|etaW " << etaphi.ietaE[itry] << "|"
<< etaphi.ietaW[itry] << " and phiN|PhiS " << etaphi.iphiN[itry] << "|"
<< etaphi.iphiS[itry];
}
}
return etaphi;
Expand Down
44 changes: 34 additions & 10 deletions Calibration/IsolatedParticles/src/GenSimInfo.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ namespace spr {
genSimInfo& info,
bool debug) {
if (debug)
edm::LogVerbatim("IsoTrack") << "eGenSimInfo:: For track " << (*trkItr)->momentum().rho() << "/" << (*trkItr)->momentum().eta() << "/" << (*trkItr)->momentum().phi() << " with ieta:iphi " << ieta << ":" << iphi;
edm::LogVerbatim("IsoTrack") << "eGenSimInfo:: For track " << (*trkItr)->momentum().rho() << "/"
<< (*trkItr)->momentum().eta() << "/" << (*trkItr)->momentum().phi()
<< " with ieta:iphi " << ieta << ":" << iphi;

std::vector<DetId> vdets = spr::matrixECALIds(coreDet, ieta, iphi, geo, caloTopology, false);
if (debug)
Expand All @@ -35,7 +37,9 @@ namespace spr {
spr::genSimInfo& info,
bool debug) {
if (debug)
edm::LogVerbatim("IsoTrack") << "eGenSimInfo:: For track " << (*trkItr)->momentum().rho() << "/" << (*trkItr)->momentum().eta() << "/" << (*trkItr)->momentum().phi() << " with dR,tMom " << dR << " " << trackMom;
edm::LogVerbatim("IsoTrack") << "eGenSimInfo:: For track " << (*trkItr)->momentum().rho() << "/"
<< (*trkItr)->momentum().eta() << "/" << (*trkItr)->momentum().phi()
<< " with dR,tMom " << dR << " " << trackMom;

std::vector<DetId> vdets = spr::matrixECALIds(coreDet, dR, trackMom, geo, caloTopology, false);
if (debug)
Expand All @@ -53,7 +57,9 @@ namespace spr {
genSimInfo& info,
bool debug) {
if (debug)
edm::LogVerbatim("IsoTrack") << "eGenSimInfo:: For track " << trkItr->momentum().R() << "/" << trkItr->momentum().eta() << "/" << trkItr->momentum().phi() << " with ieta:iphi " << ieta << ":" << iphi;
edm::LogVerbatim("IsoTrack") << "eGenSimInfo:: For track " << trkItr->momentum().R() << "/"
<< trkItr->momentum().eta() << "/" << trkItr->momentum().phi() << " with ieta:iphi "
<< ieta << ":" << iphi;

std::vector<DetId> vdets = spr::matrixECALIds(coreDet, ieta, iphi, geo, caloTopology, false);
if (debug)
Expand All @@ -71,7 +77,9 @@ namespace spr {
spr::genSimInfo& info,
bool debug) {
if (debug)
edm::LogVerbatim("IsoTrack") << "eGenSimInfo:: For track " << trkItr->momentum().R() << "/" << trkItr->momentum().eta() << "/" << trkItr->momentum().phi() << " with dR,tMom " << dR << " " << trackMom;
edm::LogVerbatim("IsoTrack") << "eGenSimInfo:: For track " << trkItr->momentum().R() << "/"
<< trkItr->momentum().eta() << "/" << trkItr->momentum().phi() << " with dR,tMom "
<< dR << " " << trackMom;

std::vector<DetId> vdets = spr::matrixECALIds(coreDet, dR, trackMom, geo, caloTopology, false);
if (debug)
Expand All @@ -89,7 +97,9 @@ namespace spr {
bool includeHO,
bool debug) {
if (debug)
edm::LogVerbatim("IsoTrack") << "hGenSimInfo:: For track " << (*trkItr)->momentum().rho() << "/" << (*trkItr)->momentum().eta() << "/" << (*trkItr)->momentum().phi() << " with ieta:iphi " << ieta << ":" << iphi;
edm::LogVerbatim("IsoTrack") << "hGenSimInfo:: For track " << (*trkItr)->momentum().rho() << "/"
<< (*trkItr)->momentum().eta() << "/" << (*trkItr)->momentum().phi()
<< " with ieta:iphi " << ieta << ":" << iphi;

std::vector<DetId> dets;
dets.push_back(coreDet);
Expand All @@ -110,7 +120,9 @@ namespace spr {
bool includeHO,
bool debug) {
if (debug)
edm::LogVerbatim("IsoTrack") << "hGenSimInfo:: For track " << (*trkItr)->momentum().rho() << "/" << (*trkItr)->momentum().eta() << "/" << (*trkItr)->momentum().phi() << " with dR,tMom " << dR << " " << trackMom;
edm::LogVerbatim("IsoTrack") << "hGenSimInfo:: For track " << (*trkItr)->momentum().rho() << "/"
<< (*trkItr)->momentum().eta() << "/" << (*trkItr)->momentum().phi()
<< " with dR,tMom " << dR << " " << trackMom;

std::vector<DetId> vdets = spr::matrixHCALIds(coreDet, geo, topology, dR, trackMom, includeHO, false);
if (debug)
Expand All @@ -128,7 +140,9 @@ namespace spr {
bool includeHO,
bool debug) {
if (debug)
edm::LogVerbatim("IsoTrack") << "hGenSimInfo:: For track " << trkItr->momentum().R() << "/" << trkItr->momentum().eta() << "/" << trkItr->momentum().phi() << " with ieta:iphi " << ieta << ":" << iphi;
edm::LogVerbatim("IsoTrack") << "hGenSimInfo:: For track " << trkItr->momentum().R() << "/"
<< trkItr->momentum().eta() << "/" << trkItr->momentum().phi() << " with ieta:iphi "
<< ieta << ":" << iphi;

std::vector<DetId> dets;
dets.push_back(coreDet);
Expand All @@ -149,7 +163,9 @@ namespace spr {
bool includeHO,
bool debug) {
if (debug)
edm::LogVerbatim("IsoTrack") << "hGenSimInfo:: For track " << trkItr->momentum().R() << "/" << trkItr->momentum().eta() << "/" << trkItr->momentum().phi() << " with dR,tMom " << dR << " " << trackMom;
edm::LogVerbatim("IsoTrack") << "hGenSimInfo:: For track " << trkItr->momentum().R() << "/"
<< trkItr->momentum().eta() << "/" << trkItr->momentum().phi() << " with dR,tMom "
<< dR << " " << trackMom;

std::vector<DetId> vdets = spr::matrixHCALIds(coreDet, geo, topology, dR, trackMom, includeHO, false);
if (debug)
Expand Down Expand Up @@ -189,7 +205,11 @@ namespace spr {
}

if (debug) {
edm::LogVerbatim("IsoTrack") << "Isolation variables: isChargedIso :" << info.isChargedIso << " maxNearP " << info.maxNearP << " Energy e/mu/g/ch/nh " << info.eleEne << "," << info.muEne << "," << info.photonEne << "," << info.cHadronEne << "," << info.nHadronEne << " charge " << info.cHadronEne_[0] << "," << info.cHadronEne_[1] << "," << info.cHadronEne_[2];
edm::LogVerbatim("IsoTrack") << "Isolation variables: isChargedIso :" << info.isChargedIso << " maxNearP "
<< info.maxNearP << " Energy e/mu/g/ch/nh " << info.eleEne << "," << info.muEne
<< "," << info.photonEne << "," << info.cHadronEne << "," << info.nHadronEne
<< " charge " << info.cHadronEne_[0] << "," << info.cHadronEne_[1] << ","
<< info.cHadronEne_[2];
}
}

Expand Down Expand Up @@ -225,7 +245,11 @@ namespace spr {
}

if (debug) {
edm::LogVerbatim("IsoTrack") << "Isolation variables: isChargedIso :" << info.isChargedIso << " maxNearP " << info.maxNearP << " Energy e/mu/g/ch/nh " << info.eleEne << "," << info.muEne << "," << info.photonEne << "," << info.cHadronEne << "," << info.nHadronEne << " charge " << info.cHadronEne_[0] << "," << info.cHadronEne_[1] << "," << info.cHadronEne_[2];
edm::LogVerbatim("IsoTrack") << "Isolation variables: isChargedIso :" << info.isChargedIso << " maxNearP "
<< info.maxNearP << " Energy e/mu/g/ch/nh " << info.eleEne << "," << info.muEne
<< "," << info.photonEne << "," << info.cHadronEne << "," << info.nHadronEne
<< " charge " << info.cHadronEne_[0] << "," << info.cHadronEne_[1] << ","
<< info.cHadronEne_[2];
}
}

Expand Down
16 changes: 10 additions & 6 deletions Calibration/IsolatedParticles/src/MatchingSimTrack.cc
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ namespace spr {
const reco::Track* pTrack,
TrackerHitAssociator& associate,
bool debug) {

edm::SimTrackContainer::const_iterator itr = SimTk->end();
;

Expand Down Expand Up @@ -62,7 +61,8 @@ namespace spr {
if (simTrkItr->trackId() == matchSimTrk) {
matchedId = simTrkItr->type();
if (debug)
edm::LogVerbatim("IsoTrack") << "matched trackId (maximum occurance) " << matchSimTrk << " type " << matchedId;
edm::LogVerbatim("IsoTrack") << "matched trackId (maximum occurance) " << matchSimTrk << " type "
<< matchedId;
itr = simTrkItr;
break;
}
Expand All @@ -87,7 +87,8 @@ namespace spr {
spr::matchedSimTrack(iEvent, SimTk, SimVtx, pTrack, associate, debug);
unsigned int matchSimTrk = trkInfo->trackId();
if (debug)
edm::LogVerbatim("IsoTrack") << "matchedSimTrackId finds the SimTrk ID of the current track to be " << matchSimTrk;
edm::LogVerbatim("IsoTrack") << "matchedSimTrackId finds the SimTrk ID of the current track to be "
<< matchSimTrk;
std::vector<int> matchTkid;
if (trkInfo->type() != 0) {
for (auto simTrkItr = SimTk->begin(); simTrkItr != SimTk->end(); simTrkItr++) {
Expand All @@ -113,7 +114,8 @@ namespace spr {
edm::SimTrackContainer::const_iterator parentItr = spr::parentSimTrack(simTrkItr, SimTk, SimVtx, debug);
if (debug) {
if (parentItr != SimTk->end())
edm::LogVerbatim("IsoTrack") << "original parent of " << simTrkItr->trackId() << " " << parentItr->trackId() << ", " << parentItr->type();
edm::LogVerbatim("IsoTrack") << "original parent of " << simTrkItr->trackId() << " "
<< parentItr->trackId() << ", " << parentItr->type();
else
edm::LogVerbatim("IsoTrack") << "original parent of " << simTrkItr->trackId() << " not found";
}
Expand All @@ -136,7 +138,8 @@ namespace spr {
edm::Handle<edm::SimVertexContainer>& SimVtx,
bool debug) {
if (debug)
edm::LogVerbatim("IsoTrack") << "Inside validSimTrack: trackId " << thisTrkItr->trackId() << " vtxIndex " << thisTrkItr->vertIndex() << " to be matched to " << simTkId;
edm::LogVerbatim("IsoTrack") << "Inside validSimTrack: trackId " << thisTrkItr->trackId() << " vtxIndex "
<< thisTrkItr->vertIndex() << " to be matched to " << simTkId;

//This track originates from simTkId
if (thisTrkItr->trackId() == simTkId)
Expand Down Expand Up @@ -187,7 +190,8 @@ namespace spr {

int vertIndex = thisTrkItr->vertIndex();
if (debug)
edm::LogVerbatim("IsoTrack") << "SimTrackParent " << thisTrkItr->trackId() << " Vertex " << vertIndex << " Type " << thisTrkItr->type() << " Charge " << static_cast<int>(thisTrkItr->charge());
edm::LogVerbatim("IsoTrack") << "SimTrackParent " << thisTrkItr->trackId() << " Vertex " << vertIndex << " Type "
<< thisTrkItr->type() << " Charge " << static_cast<int>(thisTrkItr->charge());
if (vertIndex == -1)
return thisTrkItr;
else if (vertIndex >= static_cast<int>(SimVtx->size()))
Expand Down

0 comments on commit 28991f0

Please sign in to comment.