New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
New HeavyIon ClusterCompatibility object and producer for beam scraping removal #8996
Merged
cmsbuild
merged 9 commits into
cms-sw:CMSSW_7_5_X
from
appeltel:HI2015_ClusterCompatibility_75X
May 14, 2015
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
26b8839
first checkin of ClusterCompatibility object and ClusterCompatibility…
appeltel 18c2ffc
fix minor bugs, wrong input collection by default for HI
appeltel 16e9d4a
dont try to find the best z position for the producer, just leave tha…
appeltel bde8076
fix git renaming error
appeltel a32f936
Reimplement ClusterCompatibility to include number of pixel clusters …
appeltel e971909
Merged HI2015_ClusterCompatibility from repository appeltel
appeltel bedfcd0
add to event content, remove unused parameter
appeltel 10dcd67
fix incorrect python syntax for EventContent
appeltel 94eda2a
Comment DataFormat variables for Doxygen, update ClusterCompatibility…
appeltel File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this looks really excessive. |
||
) |
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_*_*') | ||
) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please add some comments to the code to describe the meaning of the variables; use /// or //! for doxygen parsing