Skip to content

Commit

Permalink
Merge pull request #20680 from davidcarbonis/phase1pixelValidation_94…
Browse files Browse the repository at this point in the history
…X_clusterFix_v1

Phase1 pixel validation cluster loop fix
  • Loading branch information
cmsbuild committed Oct 3, 2017
2 parents 32e60e2 + cea84d3 commit 575a47c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 49 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
SiPixelPhase1TrackClustersCharge = DefaultHisto.clone(
name = "charge",
title = "Corrected Cluster Charge",
range_min = 0, range_max = 100, range_nbins = 200,
xlabel = "Charge size (in ke)",
range_min = 0, range_max = 200e3, range_nbins = 200,
xlabel = "Charge size",
topFolderName = "PixelPhase1V/Clusters",
specs = VPSet(
Specification().groupBy("PXBarrel/PXLayer").save(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,62 +44,17 @@ void SiPixelPhase1TrackClustersV::analyze(const edm::Event& iEvent, const edm::E
// get clusters
edm::Handle< edmNew::DetSetVector<SiPixelCluster> > clusterColl;
iEvent.getByToken( clustersToken_, clusterColl );

// we need to store some per-cluster data. Instead of a map, we use a vector,
// exploiting the fact that all custers live in the DetSetVector and we can
// use the same indices to refer to them.
// corr_charge is not strictly needed but cleaner to have it.
std::vector<bool> ontrack (clusterColl->data().size(), false);
std::vector<float> corr_charge(clusterColl->data().size(), -1.0f);

for (auto const & track : *tracks) {

auto const & trajParams = track.extra()->trajParams();
assert(trajParams.size()==track.recHitsSize());
auto hb = track.recHitsBegin();
for(unsigned int h=0;h<track.recHitsSize();h++){
auto hit = *(hb+h);
if (!hit->isValid()) continue;
DetId id = hit->geographicalId();

// check that we are in the pixel
uint32_t subdetid = (id.subdetId());
if (subdetid != PixelSubdetector::PixelBarrel && subdetid != PixelSubdetector::PixelEndcap) continue;
auto pixhit = dynamic_cast<const SiPixelRecHit*>(hit->hit());
if (!pixhit) continue;

// get the cluster
auto clust = pixhit->cluster();
if (clust.isNull()) continue;
ontrack[clust.key()] = true; // mark cluster as ontrack


// correct charge for track impact angle
auto const & ltp = trajParams[h];
LocalVector localDir = ltp.momentum()/ltp.momentum().mag();

float clust_alpha = atan2(localDir.z(), localDir.x());
float clust_beta = atan2(localDir.z(), localDir.y());
double corrCharge = clust->charge()/1000. * sqrt( 1.0 / ( 1.0/pow( tan(clust_alpha), 2 ) +
1.0/pow( tan(clust_beta ), 2 ) +
1.0 ));
corr_charge[clust.key()] = (float) corrCharge;
}

edmNew::DetSetVector<SiPixelCluster>::const_iterator it;
for (it = clusterColl->begin(); it != clusterColl->end(); ++it) {
auto id = DetId(it->detId());

for(auto subit = it->begin(); subit != it->end(); ++subit) {
// we could do subit-...->data().front() as well, but this seems cleaner.
auto key = edmNew::makeRefTo(clusterColl, subit).key();
float corrected_charge = corr_charge[key];
SiPixelCluster const& cluster = *subit;

histo[CHARGE].fill(double(corrected_charge), id, &iEvent);
histo[CHARGE].fill(double(cluster.charge() ), id, &iEvent);
histo[SIZE_X].fill(double(cluster.sizeX() ), id, &iEvent);
histo[SIZE_Y].fill(double(cluster.sizeY() ), id, &iEvent);
}
}
}

Expand Down

0 comments on commit 575a47c

Please sign in to comment.