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
tracking DQM improvements #17074
tracking DQM improvements #17074
Changes from 3 commits
39b5960
20514ff
dc8e2c9
3f47885
0c6ca39
cd216e7
c667877
ea56389
e20977a
728e8c5
73b0317
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import FWCore.ParameterSet.Config as cms | ||
|
||
from CommonTools.RecoAlgos.VertexCompositeCandidateCollectionSelector_cfi import VertexCompositeCandidateCollectionSelector as vertexCompositeCandidateCollectionSelector | ||
|
||
|
||
vertexCompositeCandidateCollectionSelector.v0 = cms.InputTag('generalV0Candidates:Kshort') # generalV0Candidates:Lambda | ||
vertexCompositeCandidateCollectionSelector.beamSpot = cms.InputTag('offlineBeamSpot') | ||
vertexCompositeCandidateCollectionSelector.primaryVertex = cms.InputTag('offlinePrimaryVertices') | ||
vertexCompositeCandidateCollectionSelector.pvNDOF = cms.int32(4) | ||
vertexCompositeCandidateCollectionSelector.lxyCUT = cms.double( 16.) # cm (2016 pixel layer3:10.2 cm ; 2017 pixel layer4: 16.0 cm) | ||
vertexCompositeCandidateCollectionSelector.lxyWRTbsCUT = cms.double( 0.) # cm | ||
#vertexCompositeCandidateCollectionSelector.debug = cms.untracked.bool(False) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,170 @@ | ||
// system include files | ||
#include <memory> | ||
|
||
// user include files | ||
#include "FWCore/Framework/interface/Frameworkfwd.h" | ||
#include "FWCore/Framework/interface/stream/EDProducer.h" | ||
|
||
#include "FWCore/Framework/interface/Event.h" | ||
#include "FWCore/Framework/interface/MakerMacros.h" | ||
|
||
#include "FWCore/ParameterSet/interface/ParameterSet.h" | ||
|
||
//#include "DataFormats/Candidate/interface/Candidate.h" | ||
#include "DataFormats/Candidate/interface/VertexCompositeCandidate.h" | ||
#include "DataFormats/RecoCandidate/interface/RecoChargedCandidate.h" | ||
|
||
#include "DataFormats/VertexReco/interface/Vertex.h" | ||
#include "DataFormats/VertexReco/interface/VertexFwd.h" | ||
|
||
// | ||
// class declaration | ||
// | ||
|
||
class VertexCompositeCandidateCollectionSelector : public edm::stream::EDProducer<> { | ||
public: | ||
explicit VertexCompositeCandidateCollectionSelector(const edm::ParameterSet&); | ||
|
||
static void fillDescriptions(edm::ConfigurationDescriptions& descriptions); | ||
|
||
private: | ||
virtual void produce(edm::Event&, const edm::EventSetup&) override; | ||
|
||
// ----------member data --------------------------- | ||
|
||
edm::EDGetTokenT<reco::VertexCompositeCandidateCollection> v0Token_; | ||
edm::EDGetTokenT<reco::BeamSpot> bsToken_; | ||
edm::EDGetTokenT<reco::VertexCollection> pvToken_; | ||
|
||
int pvNDOF_; | ||
|
||
std::string label_; | ||
|
||
// list of variables for the selection | ||
float lxyCUT_; | ||
float lxyWRTbsCUT_; | ||
bool debug_; | ||
}; | ||
|
||
// | ||
// constants, enums and typedefs | ||
// | ||
|
||
|
||
// | ||
// static data member definitions | ||
// | ||
|
||
// | ||
// constructors and destructor | ||
// | ||
VertexCompositeCandidateCollectionSelector::VertexCompositeCandidateCollectionSelector(const edm::ParameterSet& iConfig) | ||
: v0Token_ ( consumes<reco::VertexCompositeCandidateCollection>(iConfig.getParameter<edm::InputTag>("v0") ) ) | ||
, bsToken_ ( consumes<reco::BeamSpot> (iConfig.getParameter<edm::InputTag>("beamSpot") ) ) | ||
, pvToken_ ( consumes<reco::VertexCollection> (iConfig.getParameter<edm::InputTag>("primaryVertex") ) ) | ||
, pvNDOF_ ( iConfig.getParameter<int> ("pvNDOF") ) | ||
, label_ ( iConfig.getParameter<edm::InputTag>("v0").instance() ) | ||
, lxyCUT_ ( iConfig.getParameter<double>("lxyCUT") ) | ||
, lxyWRTbsCUT_ ( iConfig.getParameter<double>("lxyWRTbsCUT") ) | ||
, debug_ ( iConfig.getUntrackedParameter<bool>("debug") ) | ||
{ | ||
if (debug_) std::cout << "VertexCompositeCandidateCollectionSelector::VertexCompositeCandidateCollectionSelector" << std::endl; | ||
// product | ||
produces<reco::VertexCompositeCandidateCollection>(); | ||
|
||
//now do what ever other initialization is needed | ||
|
||
} | ||
|
||
|
||
// | ||
// member functions | ||
// | ||
|
||
// ------------ method called to produce the data ------------ | ||
void | ||
VertexCompositeCandidateCollectionSelector::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) | ||
{ | ||
using namespace edm; | ||
|
||
if (debug_) std::cout << "VertexCompositeCandidateCollectionSelector::produce" << std::endl; | ||
|
||
// Create auto_ptr for each collection to be stored in the Event | ||
auto result = std::make_unique<reco::VertexCompositeCandidateCollection>(); | ||
|
||
edm::Handle<reco::BeamSpot> beamspotHandle; | ||
iEvent.getByToken(bsToken_,beamspotHandle); | ||
reco::BeamSpot const * bs = nullptr; | ||
if (beamspotHandle.isValid()) | ||
bs = &(*beamspotHandle); | ||
|
||
|
||
edm::Handle< reco::VertexCollection > pvHandle; | ||
iEvent.getByToken(pvToken_, pvHandle ); | ||
reco::Vertex const * pv = nullptr; | ||
if (pvHandle.isValid()) { | ||
pv = &pvHandle->front(); | ||
//--- pv fake (the pv collection should have size==1 and the pv==beam spot) | ||
if ( pv->isFake() || pv->tracksSize()==0 | ||
// definition of goodOfflinePrimaryVertex | ||
|| pv->ndof() < pvNDOF_ || pv->z() > 24.) pv = nullptr; | ||
} | ||
|
||
edm::Handle<reco::VertexCompositeCandidateCollection> v0Handle; | ||
iEvent.getByToken(v0Token_, v0Handle); | ||
int n = ( v0Handle.isValid() ? v0Handle->size() : -1 ); | ||
if (debug_) std::cout << "n: " << n << std::endl; | ||
if (n>0) { | ||
|
||
reco::VertexCompositeCandidateCollection v0s = *v0Handle.product(); | ||
for ( auto v0 : v0s ) { | ||
// float mass = v0.mass(); | ||
// float pt = v0.pt(); | ||
// float p = v0.p(); | ||
// float eta = v0.eta(); | ||
// float phi = v0.phi(); | ||
// int pdgID = v0.pdgId(); | ||
// float chi2oNDF = v0.vertexNormalizedChi2(); | ||
GlobalPoint displacementFromPV = ( pv==nullptr ? GlobalPoint(-9.,-9.,0) : GlobalPoint( (pv->x() - v0.vx()), | ||
(pv->y() - v0.vy()), | ||
0. ) ); | ||
GlobalPoint displacementFromBS = ( bs==nullptr ? GlobalPoint(-9.-9.,0.) : GlobalPoint( -1*((bs->position().x() - v0.vx()) + (v0.vz() - bs->position().z()) * bs->dxdz()), | ||
-1*((bs->position().y() - v0.vy()) + (v0.vz() - bs->position().z()) * bs->dydz()), | ||
0 ) ); | ||
float lxy = ( pv==nullptr ? -9. : displacementFromPV.perp() ); | ||
float lxyWRTbs = ( bs==nullptr ? -9. : displacementFromBS.perp() ); | ||
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. Please don't use magic numbers. Use a constant for the -9 value. Also, in lines128 and 131, it would be good to set a constant null GlobalPoint and use that. |
||
|
||
if (debug_) std::cout << "lxy: " << lxy << " w.r.t. " << lxyCUT_ << " ==> " << ( lxy >= lxyCUT_ ? "OK" : "KO" ) << std::endl; | ||
if (debug_) std::cout << "lxyWRTbs: " << lxyWRTbs << " w.r.t. " << lxyWRTbsCUT_ << " ==> " << ( lxyWRTbs >= lxyWRTbsCUT_ ? "OK" : "KO" ) << std::endl; | ||
if (lxy < lxyCUT_) continue; | ||
if (lxyWRTbs < lxyWRTbsCUT_) continue; | ||
result->push_back(v0); | ||
} | ||
} | ||
|
||
if (debug_) std::cout << "result: " << result->size() << std::endl; | ||
// put into the Event | ||
// Write the collections to the Event | ||
// result->shrink_to_fit(); iEvent.put(std::move(result), std::string(label_) ); | ||
result->shrink_to_fit(); iEvent.put(std::move(result) ); | ||
|
||
} | ||
|
||
// ------------ method fills 'descriptions' with the allowed parameters for the module ------------ | ||
void | ||
VertexCompositeCandidateCollectionSelector::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { | ||
//The following says we do not know what parameters are allowed so do no validation | ||
// Please change this to state exactly what you do use, even if it is no parameters | ||
edm::ParameterSetDescription desc; | ||
desc.add<edm::InputTag>("v0"); | ||
desc.add<edm::InputTag>("beamSpot"); | ||
desc.add<edm::InputTag>("primaryVertex"); | ||
desc.add<int>("pvNDOF"); | ||
desc.add<double>("lxyCUT", 16.); // cm (2016 pixel layer3:10.2 cm ; 2017 pixel layer4: 16.0 cm) | ||
desc.add<double>("lxyWRTbsCUT", 0.); // cm | ||
desc.addUntracked<bool>("debug",false); | ||
descriptions.add("VertexCompositeCandidateCollectionSelector",desc); | ||
} | ||
|
||
//define this as a plug-in | ||
DEFINE_FWK_MODULE(VertexCompositeCandidateCollectionSelector); |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -180,13 +180,84 @@ | |
doEffFromHitPatternVsBX ['highPurityPt1'] = cms.bool(True) | ||
doStopSource ['highPurityPt1'] = cms.bool(True) | ||
|
||
###### all tracks (no pt cut) associated to the PV | ||
###### association is dz<1mm | ||
from CommonTools.RecoAlgos.TrackWithVertexSelector_cfi import * | ||
|
||
trackAssociated2pvSelector = trackWithVertexSelector.clone() | ||
trackAssociated2pvSelector.trackWithVertexSelectorParams = cms.PSet( | ||
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.
What happens in |
||
# the track collection | ||
src = cms.InputTag('generalTracks'), | ||
# kinematic cuts (pT in GeV) | ||
etaMin = cms.double(0.0), | ||
etaMax = cms.double(5.0), | ||
ptMin = cms.double(0.0), | ||
ptMax = cms.double(100000.0), | ||
# impact parameter cut (in cm) | ||
d0Max = cms.double(999.), | ||
dzMax = cms.double(999.), | ||
# quality cuts (valid hits, normalized chi2) | ||
normalizedChi2 = cms.double(999999.), | ||
numberOfValidHits = cms.uint32(0), | ||
numberOfLostHits = cms.uint32(999), ## at most 999 lost hits | ||
numberOfValidPixelHits = cms.uint32(0), ## at least <n> hits in the pixels | ||
ptErrorCut = cms.double(9999999.), ## [pTError/pT]*max(1,normChi2) <= ptErrorCut | ||
quality = cms.string("highPurity"), # quality cut as defined in reco::TrackBase | ||
# compatibility with a vertex ? | ||
useVtx = cms.bool(True), | ||
vertexTag = cms.InputTag('trackingDQMgoodOfflinePrimaryVertices'), | ||
timesTag = cms.InputTag(''), | ||
timeResosTag = cms.InputTag(''), | ||
nVertices = cms.uint32(0), ## how many vertices to look at before dropping the track | ||
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.
|
||
vtxFallback = cms.bool(True), ## falback to beam spot if there are no vertices | ||
# uses vtx=(0,0,0) with deltaZeta=15.9, deltaRho = 0.2 | ||
zetaVtx = cms.double(0.1), | ||
# rhoVtx = cms.double(0.2), ## tags used by b-tagging folks | ||
rhoVtx = cms.double(999.), ## tags used by b-tagging folks | ||
nSigmaDtVertex = cms.double(0), | ||
# should _not_ be used for the TrackWithVertexRefSelector | ||
copyExtras = cms.untracked.bool(False), ## copies also extras and rechits on RECO | ||
copyTrajectories = cms.untracked.bool(False), # don't set this to true on AOD! | ||
) | ||
|
||
highPurityPV0p1 = trackAssociated2pvSelector.clone() | ||
highPurityPV0p1.trackWithVertexSelectorParams.zetaVtx = cms.double(0.1) | ||
|
||
sequenceName ['highPurityPV0p1'] = highPurityPV0p1 | ||
mainfolderName ['highPurityPV0p1'] = 'Tracking/TrackParameters/highPurityTracks/dzPV0p1' | ||
vertexfolderName['highPurityPV0p1'] = 'Tracking/PrimaryVertices/highPurityTracks/dzPV0p1' | ||
trackPtN ['highPurityPV0p1'] = cms.int32(100) | ||
trackPtMin ['highPurityPV0p1'] = cms.double(0.) | ||
trackPtMax ['highPurityPV0p1'] = cms.double(100.) | ||
doPlotsPCA ['highPurityPV0p1'] = cms.bool(True) | ||
numCutString ['highPurityPV0p1'] = cms.string("") # default: " pt >= 1 & quality('highPurity') " | ||
denCutString ['highPurityPV0p1'] = cms.string(" pt >= 1 ") # it is as in the default config (just be sure) | ||
doGoodTracksPlots ['highPurityPV0p1'] = cms.bool(True) | ||
doTrackerSpecific ['highPurityPV0p1'] = cms.bool(True) | ||
doHitPropertiesPlots ['highPurityPV0p1'] = cms.bool(True) | ||
doGeneralPropertiesPlots ['highPurityPV0p1'] = cms.bool(True) | ||
doBeamSpotPlots ['highPurityPV0p1'] = cms.bool(True) | ||
doSeedParameterHistos ['highPurityPV0p1'] = cms.bool(False) | ||
doRecHitVsPhiVsEtaPerTrack ['highPurityPV0p1'] = cms.bool(True) | ||
doRecHitVsPtVsEtaPerTrack ['highPurityPV0p1'] = cms.bool(True) | ||
doGoodTrackRecHitVsPhiVsEtaPerTrack ['highPurityPV0p1'] = cms.bool(True) | ||
doLayersVsPhiVsEtaPerTrack ['highPurityPV0p1'] = cms.bool(True) | ||
doGoodTrackLayersVsPhiVsEtaPerTrack ['highPurityPV0p1'] = cms.bool(True) | ||
doPUmonitoring ['highPurityPV0p1'] = cms.bool(False) | ||
doPlotsVsBXlumi ['highPurityPV0p1'] = cms.bool(False) | ||
doPlotsVsGoodPVtx ['highPurityPV0p1'] = cms.bool(True) | ||
doEffFromHitPatternVsPU ['highPurityPV0p1'] = cms.bool(True) | ||
doEffFromHitPatternVsBX ['highPurityPV0p1'] = cms.bool(True) | ||
doStopSource ['highPurityPV0p1'] = cms.bool(True) | ||
|
||
selectedTracks.extend( ['generalTracks'] ) | ||
#selectedTracks.extend( ['highPurityPtRange0to1'] ) | ||
#selectedTracks.extend( ['highPurityPtRange1to10'] ) | ||
#selectedTracks.extend( ['highPurityPt10'] ) | ||
|
||
selectedTracks.extend( ['highPurityPt1'] ) | ||
selectedTracks.extend( ['highPurityPtRange0to1'] ) | ||
selectedTracks.extend( ['highPurityPV0p1'] ) | ||
|
||
#selectedTracks2runSequence=cms.Sequence() | ||
#for tracks in selectedTracks : | ||
|
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.
shouldn't you clone VertexCompositeCandidateCollectionSelector instead of modifying it?
What if someone needs to load VertexCompositeCandidateCollectionSelector_cfi in a different place