Skip to content

Commit

Permalink
Improve code readability
Browse files Browse the repository at this point in the history
  • Loading branch information
tsusa authored and mmusich committed May 9, 2022
1 parent 4bcf704 commit dc0140e
Showing 1 changed file with 40 additions and 63 deletions.
103 changes: 40 additions & 63 deletions DQM/SiPixelPhase1Track/plugins/SiPixelPhase1TrackEfficiency.cc
Original file line number Diff line number Diff line change
Expand Up @@ -160,34 +160,22 @@ namespace {
//////////////////////////////////////////////////////////////////////////////////////////

// Hp cut
int TRACK_QUALITY_HIGH_PURITY_BIT = 2;
int TRACK_QUALITY_HIGH_PURITY_MASK = 1 << TRACK_QUALITY_HIGH_PURITY_BIT;
static constexpr int TRACK_QUALITY_HIGH_PURITY_BIT = 2;
static constexpr int TRACK_QUALITY_HIGH_PURITY_MASK = 1 << TRACK_QUALITY_HIGH_PURITY_BIT;

// Pt cut
float TRACK_PT_CUT_VAL = 1.0f;
static constexpr float TRACK_PT_CUT_VAL = 1.0f;

// Nstrip cut
int TRACK_NSTRIP_CUT_VAL = 10;
static constexpr int TRACK_NSTRIP_CUT_VAL = 10;

//D0
std::array<float, 4> TRACK_D0_CUT_BARREL_VAL = {{0.01f, 0.02f, 0.02f, 0.02f}};
float TRACK_D0_CUT_FORWARD_VAL = 0.05f;
static constexpr std::array<float, 4> TRACK_D0_CUT_BARREL_VAL = {{0.01f, 0.02f, 0.02f, 0.02f}};
static constexpr float TRACK_D0_CUT_FORWARD_VAL = 0.05f;

//Dz
float TRACK_DZ_CUT_BARREL_VAL = 0.01f;
float TRACK_DZ_CUT_FORWARD_VAL = 0.5f;

bool isBpixtrack = false, isFpixtrack = false;
int nStripHits = 0;
int nBpixL1Hits = 0;
int nBpixL2Hits = 0;
int nBpixL3Hits = 0;
int nBpixL4Hits = 0;
int nFpixD1Hits = 0;
int nFpixD2Hits = 0;
int nFpixD3Hits = 0;
bool passcuts = true;
bool passcuts_hit = true;
static constexpr float TRACK_DZ_CUT_BARREL_VAL = 0.01f;
static constexpr float TRACK_DZ_CUT_FORWARD_VAL = 0.5f;

TrajectoryStateOnSurface tsosPXB2;
bool valid_layerFrom = false;
Expand All @@ -210,16 +198,17 @@ namespace {
(track->pt() < 0.75 || std::abs(track->dxy(vertices->at(0).position())) > 5 * track->dxyError()))
continue;

isBpixtrack = false, isFpixtrack = false;
nStripHits = 0;
nBpixL1Hits = 0;
nBpixL2Hits = 0;
nBpixL3Hits = 0;
nBpixL4Hits = 0;
nFpixD1Hits = 0;
nFpixD2Hits = 0;
nFpixD3Hits = 0;
passcuts = true;
bool isBpixtrack = false;
bool isFpixtrack = false;
int nStripHits = 0;
int nBpixL1Hits = 0;
int nBpixL2Hits = 0;
int nBpixL3Hits = 0;
int nBpixL4Hits = 0;
int nFpixD1Hits = 0;
int nFpixD2Hits = 0;
int nFpixD3Hits = 0;
bool passcuts = true;

// first, look at the full track to see whether it is good
// auto const & trajParams = track.extra()->trajParams();
Expand All @@ -238,36 +227,26 @@ namespace {
isBpixtrack = true;
if (trackerTopology_->pxbLayer(id) == 1)
nBpixL1Hits++;
if (trackerTopology_->pxbLayer(id) == 2)
else if (trackerTopology_->pxbLayer(id) == 2)
nBpixL2Hits++;
if (trackerTopology_->pxbLayer(id) == 3)
else if (trackerTopology_->pxbLayer(id) == 3)
nBpixL3Hits++;
if (trackerTopology_->pxbLayer(id) == 4)
else if (trackerTopology_->pxbLayer(id) == 4)
nBpixL4Hits++;
}
if (subdetid == PixelSubdetector::PixelEndcap && hit->isValid()) {
} else if (subdetid == PixelSubdetector::PixelEndcap && hit->isValid()) {
isFpixtrack = true;
if (trackerTopology_->pxfDisk(id) == 1)
nFpixD1Hits++;
if (trackerTopology_->pxfDisk(id) == 2)
else if (trackerTopology_->pxfDisk(id) == 2)
nFpixD2Hits++;
if (trackerTopology_->pxfDisk(id) == 3)
else if (trackerTopology_->pxfDisk(id) == 3)
nFpixD3Hits++;
}

// count strip hits
if (subdetid == StripSubdetector::TIB)
nStripHits++;
if (subdetid == StripSubdetector::TOB)
nStripHits++;
if (subdetid == StripSubdetector::TID)
if (subdetid == StripSubdetector::TIB || subdetid == StripSubdetector::TOB ||
subdetid == StripSubdetector::TID || subdetid == StripSubdetector::TEC)
nStripHits++;
if (subdetid == StripSubdetector::TEC)
nStripHits++;

// check that we are in the pixel
// if (subdetid == PixelSubdetector::PixelBarrel) isBpixtrack = true;
// if (subdetid == PixelSubdetector::PixelEndcap) isFpixtrack = true;
}

if (!isBpixtrack && !isFpixtrack)
Expand All @@ -287,7 +266,7 @@ namespace {

// then, look at each hit
for (unsigned int h = 0; h < track->recHitsSize(); h++) {
passcuts_hit = true;
bool passcuts_hit = true;
auto hit = *(hb + h);

DetId id = hit->geographicalId();
Expand All @@ -304,8 +283,7 @@ namespace {
if (!((std::abs(track->dxy(vertices->at(0).position())) * -1.0) <
TRACK_D0_CUT_BARREL_VAL[trackerTopology_->pxbLayer(id) - 1]))
passcuts_hit = false;
}
if (subdetid == PixelSubdetector::PixelEndcap) {
} else if (subdetid == PixelSubdetector::PixelEndcap) {
if (!((std::abs(track->dxy(vertices->at(0).position())) * -1.0) < TRACK_D0_CUT_FORWARD_VAL))
passcuts_hit = false;
}
Expand All @@ -314,46 +292,45 @@ namespace {
if (subdetid == PixelSubdetector::PixelBarrel) {
if (!(std::abs(track->dz(vertices->at(0).position())) < TRACK_DZ_CUT_BARREL_VAL))
passcuts_hit = false;
}
if (subdetid == PixelSubdetector::PixelEndcap) {
} else if (subdetid == PixelSubdetector::PixelEndcap) {
if (!(std::abs(track->dz(vertices->at(0).position())) < TRACK_DZ_CUT_FORWARD_VAL))
passcuts_hit = false;
}

// Pixhit cut
if (subdetid == PixelSubdetector::PixelBarrel) {
if (trackerTopology_->pxbLayer(id) == 1)
if (trackerTopology_->pxbLayer(id) == 1) {
if (!((nBpixL2Hits > 0 && nBpixL3Hits > 0 && nBpixL4Hits > 0) ||
(nBpixL2Hits > 0 && nBpixL3Hits > 0 && nFpixD1Hits > 0) ||
(nBpixL2Hits > 0 && nFpixD1Hits > 0 && nFpixD2Hits > 0) ||
(nFpixD1Hits > 0 && nFpixD2Hits > 0 && nFpixD3Hits > 0)))
passcuts_hit = false;
if (trackerTopology_->pxbLayer(id) == 2)
} else if (trackerTopology_->pxbLayer(id) == 2) {
if (!((nBpixL1Hits > 0 && nBpixL3Hits > 0 && nBpixL4Hits > 0) ||
(nBpixL1Hits > 0 && nBpixL3Hits > 0 && nFpixD1Hits > 0) ||
(nBpixL1Hits > 0 && nFpixD1Hits > 0 && nFpixD2Hits > 0)))
passcuts_hit = false;
if (trackerTopology_->pxbLayer(id) == 3)
} else if (trackerTopology_->pxbLayer(id) == 3) {
if (!((nBpixL1Hits > 0 && nBpixL2Hits > 0 && nBpixL4Hits > 0) ||
(nBpixL1Hits > 0 && nBpixL2Hits > 0 && nFpixD1Hits > 0)))
passcuts_hit = false;
if (trackerTopology_->pxbLayer(id) == 4)
} else if (trackerTopology_->pxbLayer(id) == 4)
if (!((nBpixL1Hits > 0 && nBpixL2Hits > 0 && nBpixL3Hits > 0)))
passcuts_hit = false;
}
if (subdetid == PixelSubdetector::PixelEndcap) {
if (trackerTopology_->pxfDisk(id) == 1)
} else if (subdetid == PixelSubdetector::PixelEndcap) {
if (trackerTopology_->pxfDisk(id) == 1) {
if (!((nBpixL1Hits > 0 && nBpixL2Hits > 0 && nBpixL3Hits > 0) ||
(nBpixL1Hits > 0 && nBpixL2Hits > 0 && nFpixD2Hits > 0) ||
(nBpixL1Hits > 0 && nFpixD2Hits > 0 && nFpixD3Hits > 0)))
passcuts_hit = false;
if (trackerTopology_->pxfDisk(id) == 2)
} else if (trackerTopology_->pxfDisk(id) == 2) {
if (!((nBpixL1Hits > 0 && nBpixL2Hits > 0 && nFpixD1Hits > 0) ||
(nBpixL1Hits > 0 && nFpixD1Hits > 0 && nFpixD3Hits > 0)))
passcuts_hit = false;
if (trackerTopology_->pxfDisk(id) == 3)
} else if (trackerTopology_->pxfDisk(id) == 3) {
if (!((nBpixL1Hits > 0 && nFpixD1Hits > 0 && nFpixD2Hits > 0)))
passcuts_hit = false;
}
}
/*
//Fiducial Cut - will work on it later
Expand Down Expand Up @@ -439,7 +416,7 @@ namespace {
for (uint p = 0; p < expTrajMeasurements.size(); p++) {
bool valid = false;
bool missing = false;
passcuts_hit = true;
bool passcuts_hit = true;
TrajectoryMeasurement pxb1TM(expTrajMeasurements[p]);
const auto& pxb1Hit = pxb1TM.recHit();
bool inactive = (pxb1Hit->getType() == TrackingRecHit::inactive);
Expand Down

0 comments on commit dc0140e

Please sign in to comment.