-
Notifications
You must be signed in to change notification settings - Fork 4.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8996 from appeltel/HI2015_ClusterCompatibility_75X
New HeavyIon ClusterCompatibility object and producer for beam scraping removal
- Loading branch information
Showing
8 changed files
with
265 additions
and
3 deletions.
There are no files selected for viewing
45 changes: 45 additions & 0 deletions
45
DataFormats/HeavyIonEvent/interface/ClusterCompatibility.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
#ifndef DataFormats_ClusterCompatibility_h | ||
#define DataFormats_ClusterCompatibility_h | ||
|
||
#include <vector> | ||
|
||
namespace reco { class ClusterCompatibility { | ||
public: | ||
|
||
ClusterCompatibility(); | ||
virtual ~ClusterCompatibility(); | ||
|
||
/// Number of valid pixel clusters | ||
int nValidPixelHits() const { return nValidPixelHits_; } | ||
|
||
/// Number of vertex-position hypotheses tested | ||
int size() const { return z0_.size(); } | ||
|
||
/// Vertex z position for the i-th vertex-position hypothesis | ||
float z0(int i) const { return z0_[i]; } | ||
|
||
/// Number of compatible non-edge pixel-barrel clusters | ||
/// for the i-th vertex-position hypothesis | ||
int nHit(int i) const { return nHit_[i]; } | ||
|
||
/// Sum of the difference between the expected and actual | ||
/// width of all compatible non-edge pixel-barrel clusters | ||
/// for the i-th vertex-position hypothesis | ||
float chi(int i) const { return chi_[i]; } | ||
|
||
void append(float, int, float); | ||
void setNValidPixelHits(int nPxl) { nValidPixelHits_ = nPxl; } | ||
|
||
protected: | ||
|
||
|
||
int nValidPixelHits_; | ||
|
||
std::vector<float> z0_; | ||
std::vector<int> nHit_; | ||
std::vector<float> chi_; | ||
|
||
}; | ||
|
||
} | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#include "DataFormats/HeavyIonEvent/interface/ClusterCompatibility.h" | ||
using namespace reco; | ||
|
||
ClusterCompatibility::ClusterCompatibility(): | ||
nValidPixelHits_(0), | ||
z0_(), | ||
nHit_(), | ||
chi_() | ||
{} | ||
|
||
ClusterCompatibility::~ClusterCompatibility() {} | ||
|
||
void | ||
ClusterCompatibility::append(float z0, int nHit, float chi) { | ||
z0_.push_back(z0); | ||
nHit_.push_back(nHit); | ||
chi_.push_back(chi); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
179 changes: 179 additions & 0 deletions
179
RecoHI/HiCentralityAlgos/plugins/ClusterCompatibilityProducer.cc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,179 @@ | ||
// | ||
// Derived from HLTrigger/special/src/HLTPixelClusterShapeFilter.cc | ||
// at version 7_5_0_pre3 | ||
// | ||
// Original Author (of Derivative Producer): Eric Appelt | ||
// Created: Mon Apr 27, 2015 | ||
|
||
#include <iostream> | ||
|
||
#include "FWCore/Framework/interface/Frameworkfwd.h" | ||
#include "FWCore/Framework/interface/stream/EDProducer.h" | ||
#include "FWCore/Framework/interface/Event.h" | ||
#include "FWCore/Framework/interface/EventSetup.h" | ||
#include "FWCore/Framework/interface/ESHandle.h" | ||
#include "FWCore/Framework/interface/MakerMacros.h" | ||
#include "FWCore/ParameterSet/interface/ParameterSet.h" | ||
#include "FWCore/MessageLogger/interface/MessageLogger.h" | ||
|
||
#include "DataFormats/Common/interface/Handle.h" | ||
#include "DataFormats/GeometryVector/interface/LocalPoint.h" | ||
#include "DataFormats/GeometryVector/interface/GlobalPoint.h" | ||
#include "DataFormats/SiPixelDetId/interface/PixelSubdetector.h" | ||
#include "DataFormats/TrackerRecHit2D/interface/SiPixelRecHitCollection.h" | ||
#include "DataFormats/HeavyIonEvent/interface/ClusterCompatibility.h" | ||
|
||
#include "Geometry/TrackerGeometryBuilder/interface/TrackerGeometry.h" | ||
#include "Geometry/TrackerGeometryBuilder/interface/PixelGeomDetUnit.h" | ||
#include "Geometry/CommonTopologies/interface/PixelTopology.h" | ||
#include "Geometry/Records/interface/TrackerDigiGeometryRecord.h" | ||
#include "Geometry/CommonDetUnit/interface/GeomDet.h" | ||
|
||
|
||
// | ||
// class declaration | ||
// | ||
|
||
class ClusterCompatibilityProducer : public edm::stream::EDProducer<> { | ||
|
||
public: | ||
explicit ClusterCompatibilityProducer(const edm::ParameterSet&); | ||
~ClusterCompatibilityProducer(); | ||
|
||
virtual void produce(edm::Event&, const edm::EventSetup&) override; | ||
|
||
private: | ||
|
||
edm::EDGetTokenT<SiPixelRecHitCollection> inputToken_; | ||
edm::InputTag inputTag_; // input tag identifying product containing pixel clusters | ||
double minZ_; // beginning z-vertex position | ||
double maxZ_; // end z-vertex position | ||
double zStep_; // size of steps in z-vertex test | ||
|
||
struct VertexHit | ||
{ | ||
float z; | ||
float r; | ||
float w; | ||
}; | ||
|
||
struct ContainedHits | ||
{ | ||
float z0; | ||
int nHit; | ||
float chi; | ||
}; | ||
|
||
ContainedHits getContainedHits(const std::vector<VertexHit> &hits, double z0) const; | ||
|
||
}; | ||
|
||
ClusterCompatibilityProducer::ClusterCompatibilityProducer(const edm::ParameterSet& config): | ||
inputTag_ (config.getParameter<edm::InputTag>("inputTag")), | ||
minZ_ (config.getParameter<double>("minZ")), | ||
maxZ_ (config.getParameter<double>("maxZ")), | ||
zStep_ (config.getParameter<double>("zStep")) | ||
{ | ||
inputToken_ = consumes<SiPixelRecHitCollection>(inputTag_); | ||
LogDebug("") << "Using the " << inputTag_ << " input collection"; | ||
produces<reco::ClusterCompatibility>(); | ||
} | ||
|
||
ClusterCompatibilityProducer::~ClusterCompatibilityProducer() {} | ||
|
||
void | ||
ClusterCompatibilityProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) | ||
{ | ||
std::auto_ptr<reco::ClusterCompatibility> creco(new reco::ClusterCompatibility()); | ||
|
||
// get hold of products from Event | ||
edm::Handle<SiPixelRecHitCollection> hRecHits; | ||
iEvent.getByToken(inputToken_, hRecHits); | ||
|
||
// get tracker geometry | ||
if (hRecHits.isValid()) { | ||
edm::ESHandle<TrackerGeometry> trackerHandle; | ||
iSetup.get<TrackerDigiGeometryRecord>().get(trackerHandle); | ||
const TrackerGeometry *tgeo = trackerHandle.product(); | ||
const SiPixelRecHitCollection *hits = hRecHits.product(); | ||
|
||
// loop over pixel rechits | ||
int nPxlHits=0; | ||
std::vector<VertexHit> vhits; | ||
for(SiPixelRecHitCollection::DataContainer::const_iterator hit = hits->data().begin(), | ||
end = hits->data().end(); hit != end; ++hit) { | ||
if (!hit->isValid()) | ||
continue; | ||
++nPxlHits; | ||
DetId id(hit->geographicalId()); | ||
if(id.subdetId() != int(PixelSubdetector::PixelBarrel)) | ||
continue; | ||
const PixelGeomDetUnit *pgdu = static_cast<const PixelGeomDetUnit*>(tgeo->idToDet(id)); | ||
const PixelTopology *pixTopo = &(pgdu->specificTopology()); | ||
std::vector<SiPixelCluster::Pixel> pixels(hit->cluster()->pixels()); | ||
bool pixelOnEdge = false; | ||
for(std::vector<SiPixelCluster::Pixel>::const_iterator pixel = pixels.begin(); | ||
pixel != pixels.end(); ++pixel) { | ||
int pixelX = pixel->x; | ||
int pixelY = pixel->y; | ||
if(pixTopo->isItEdgePixelInX(pixelX) || pixTopo->isItEdgePixelInY(pixelY)) { | ||
pixelOnEdge = true; | ||
break; | ||
} | ||
} | ||
if (pixelOnEdge) | ||
continue; | ||
|
||
LocalPoint lpos = LocalPoint(hit->localPosition().x(), | ||
hit->localPosition().y(), | ||
hit->localPosition().z()); | ||
GlobalPoint gpos = pgdu->toGlobal(lpos); | ||
VertexHit vh; | ||
vh.z = gpos.z(); | ||
vh.r = gpos.perp(); | ||
vh.w = hit->cluster()->sizeY(); | ||
vhits.push_back(vh); | ||
} | ||
|
||
creco->setNValidPixelHits(nPxlHits); | ||
|
||
// append cluster compatibility for each z-position | ||
for(double z0 = minZ_; z0 <= maxZ_; z0 += zStep_) | ||
{ | ||
ContainedHits c = getContainedHits(vhits, z0); | ||
creco->append(c.z0, c.nHit, c.chi); | ||
} | ||
|
||
} | ||
iEvent.put(creco); | ||
|
||
} | ||
|
||
|
||
ClusterCompatibilityProducer::ContainedHits ClusterCompatibilityProducer::getContainedHits(const std::vector<VertexHit> &hits, double z0) const | ||
{ | ||
|
||
// Calculate number of hits contained in v-shaped window in cluster y-width vs. z-position. | ||
int n = 0; | ||
double chi = 0.; | ||
|
||
for(std::vector<VertexHit>::const_iterator hit = hits.begin(); hit!= hits.end(); hit++) { | ||
// the calculation of the predicted cluster width p was | ||
// marked 'FIXME' in the HLTPixelClusterShapeFilter. It should | ||
// be revisited but is retained as it was for compatibility with the | ||
// older filter. | ||
double p = 2 * fabs(hit->z - z0)/hit->r + 0.5; | ||
if(fabs(p - hit->w) <= 1.) { | ||
chi += fabs(p - hit->w); | ||
n++; | ||
} | ||
} | ||
ClusterCompatibilityProducer::ContainedHits output; | ||
output.z0 = z0; | ||
output.nHit = n; | ||
output.chi = chi; | ||
return output; | ||
} | ||
|
||
//define this as a plug-in | ||
DEFINE_FWK_MODULE(ClusterCompatibilityProducer); |
8 changes: 8 additions & 0 deletions
8
RecoHI/HiCentralityAlgos/python/HiClusterCompatibility_cfi.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import FWCore.ParameterSet.Config as cms | ||
|
||
hiClusterCompatibility = cms.EDProducer("ClusterCompatibilityProducer", | ||
inputTag = cms.InputTag( "siPixelRecHits" ), | ||
minZ = cms.double(-40.0), | ||
maxZ = cms.double(40.05), | ||
zStep = cms.double(0.2) | ||
) |
9 changes: 6 additions & 3 deletions
9
RecoHI/HiCentralityAlgos/python/RecoHiCentrality_EventContent_cff.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,16 @@ | ||
import FWCore.ParameterSet.Config as cms | ||
|
||
RecoHiCentralityFEVT = cms.PSet( | ||
outputCommands = cms.untracked.vstring('keep recoCentrality*_hiCentrality_*_*') | ||
outputCommands = cms.untracked.vstring('keep recoCentrality*_hiCentrality_*_*', | ||
'keep recoClusterCompatibility*_hiClusterCompatibility_*_*') | ||
) | ||
|
||
RecoHiCentralityRECO = cms.PSet( | ||
outputCommands = cms.untracked.vstring('keep recoCentrality*_hiCentrality_*_*') | ||
outputCommands = cms.untracked.vstring('keep recoCentrality*_hiCentrality_*_*', | ||
'keep recoClusterCompatibility*_hiClusterCompatibility_*_*') | ||
) | ||
|
||
RecoHiCentralityAOD = cms.PSet( | ||
outputCommands = cms.untracked.vstring('keep recoCentrality*_hiCentrality_*_*') | ||
outputCommands = cms.untracked.vstring('keep recoCentrality*_hiCentrality_*_*', | ||
'keep recoClusterCompatibility*_hiClusterCompatibility_*_*') | ||
) |