Skip to content
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

Merged
merged 11 commits into from Jan 17, 2017
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions CommonTools/RecoAlgos/BuildFile.xml
Expand Up @@ -9,6 +9,8 @@
<use name="DataFormats/SiPixelCluster"/>
<use name="DataFormats/TrackerRecHit2D"/>
<use name="DataFormats/METReco"/>
<use name="DataFormats/RecoCandidate"/>
<use name="DataFormats/Candidate"/>
<use name="TrackingTools/Records"/>
<use name="TrackingTools/IPTools"/>
<use name="TrackingTools/TransientTrack"/>
Expand Down
Expand Up @@ -2,6 +2,6 @@

from CommonTools.RecoAlgos.TrackWithVertexSelectorParams_cff import *

trackWithVertexSelector = cms.EDFilter("TrackWithVertexSelector",
trackWithVertexSelector = cms.EDProducer("TrackWithVertexSelector",
trackWithVertexSelectorParams
)
@@ -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
Copy link
Contributor

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

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)
@@ -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() );
Copy link
Contributor

Choose a reason for hiding this comment

The 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);
88 changes: 87 additions & 1 deletion DQM/TrackingMonitor/python/V0Monitor_cff.py
Expand Up @@ -25,7 +25,6 @@
+ LambdaMonitoring
)


from DQM.TrackingMonitorSource.pset4GenericTriggerEventFlag_cfi import *

# tracker ON
Expand Down Expand Up @@ -107,3 +106,90 @@
+ LambdaMonitoringZBHIPOOT
)



from CommonTools.RecoAlgos.vertexCompositeCandidateCollectionSelector_cfi import *
KshortWlxy16 = vertexCompositeCandidateCollectionSelector.clone()
KshortWlxy16.v0 = cms.InputTag('generalV0Candidates:Kshort')

LambdaWlxy16 = vertexCompositeCandidateCollectionSelector.clone()
LambdaWlxy16.v0 = cms.InputTag('generalV0Candidates:Lambda')

KshortWlxy16Monitoring = KshortMonitoring.clone()
KshortWlxy16Monitoring.v0 = cms.InputTag('KshortWlxy16')
KshortWlxy16Monitoring.FolderName = cms.string("Tracking/V0Monitoring/Ks/Lxy16")

LambdaWlxy16Monitoring = LambdaMonitoring.clone()
LambdaWlxy16Monitoring.v0 = cms.InputTag('LambdaWlxy16')
LambdaWlxy16Monitoring.FolderName = cms.string("Tracking/V0Monitoring/Lambda/Lxy16")

voWcutMonitoringSequence = cms.Sequence(
KshortWlxy16*KshortWlxy16Monitoring
+ LambdaWlxy16*LambdaWlxy16Monitoring
)

KshortWlxy16MonitoringCommon = KshortMonitoringCommon.clone()
KshortWlxy16MonitoringCommon.v0 = cms.InputTag('KshortWlxy16')
KshortWlxy16MonitoringCommon.FolderName = cms.string("Tracking/V0Monitoring/Ks/Lxy16")

LambdaWlxy16MonitoringCommon = LambdaMonitoringCommon.clone()
LambdaWlxy16MonitoringCommon.v0 = cms.InputTag('LambdaWlxy16')
LambdaWlxy16MonitoringCommon.FolderName = cms.string("Tracking/V0Monitoring/Lambda/Lxy16")

voWcutMonitoringCommonSequence = cms.Sequence(
KshortWlxy16*KshortWlxy16MonitoringCommon
+LambdaWlxy16*LambdaWlxy16MonitoringCommon
)

KshortWlxy16MonitoringMB = KshortMonitoringMB.clone()
KshortWlxy16MonitoringMB.v0 = cms.InputTag('KshortWlxy16')
KshortWlxy16MonitoringMB.FolderName = cms.string("Tracking/V0Monitoring/HIP_OOTpu_INpu/Ks/Lxy16")

LambdaWlxy16MonitoringMB = LambdaMonitoringMB.clone()
LambdaWlxy16MonitoringMB.v0 = cms.InputTag('LambdaWlxy16')
LambdaWlxy16MonitoringMB.FolderName = cms.string("Tracking/V0Monitoring/HIP_OOTpu_INpu/Lambda/Lxy16")

voWcutMonitoringMBSequence = cms.Sequence(
KshortWlxy16*KshortWlxy16MonitoringMB
+LambdaWlxy16*LambdaWlxy16MonitoringMB
)

KshortWlxy16MonitoringZBnoHIPnoOOT = KshortMonitoringZBnoHIPnoOOT.clone()
KshortWlxy16MonitoringZBnoHIPnoOOT.v0 = cms.InputTag('KshortWlxy16')
KshortWlxy16MonitoringZBnoHIPnoOOT.FolderName = cms.string("Tracking/V0Monitoring/noHIP_noOOTpu_INpu/Ks/Lxy16")

LambdaWlxy16MonitoringZBnoHIPnoOOT = LambdaMonitoringZBnoHIPnoOOT.clone()
LambdaWlxy16MonitoringZBnoHIPnoOOT.v0 = cms.InputTag('LambdaWlxy16')
LambdaWlxy16MonitoringZBnoHIPnoOOT.FolderName = cms.string("Tracking/V0Monitoring/noHIP_noOOTpu_INpu/Lambda/Lxy16")


voWcutMonitoringZBnoHIPnoOOTSequence = cms.Sequence(
KshortWlxy16*KshortWlxy16MonitoringZBnoHIPnoOOT
+LambdaWlxy16*LambdaWlxy16MonitoringZBnoHIPnoOOT
)

KshortWlxy16MonitoringZBHIPnoOOT = KshortMonitoringZBHIPnoOOT.clone()
KshortWlxy16MonitoringZBHIPnoOOT.v0 = cms.InputTag('KshortWlxy16')
KshortWlxy16MonitoringZBHIPnoOOT.FolderName = cms.string("Tracking/V0Monitoring/HIP_noOOTpu_INpu/Ks/Lxy16")

LambdaWlxy16MonitoringZBHIPnoOOT = LambdaMonitoringZBHIPnoOOT.clone()
LambdaWlxy16MonitoringZBHIPnoOOT.v0 = cms.InputTag('LambdaWlxy16')
LambdaWlxy16MonitoringZBHIPnoOOT.FolderName = cms.string("Tracking/V0Monitoring/HIP_noOOTpu_INpu/Lambda/Lxy16")

voWcutMonitoringZBHIPnoOOTSequence = cms.Sequence(
KshortWlxy16*KshortWlxy16MonitoringZBHIPnoOOT
+LambdaWlxy16*LambdaWlxy16MonitoringZBHIPnoOOT
)

KshortWlxy16MonitoringZBHIPOOT = KshortMonitoringZBHIPOOT.clone()
KshortWlxy16MonitoringZBHIPOOT.v0 = cms.InputTag('KshortWlxy16')
KshortWlxy16MonitoringZBHIPOOT.FolderName = cms.string("Tracking/V0Monitoring/HIP_OOTpu_noINpu/Ks/Lxy16")

LambdaWlxy16MonitoringZBHIPOOT = LambdaMonitoringZBHIPOOT.clone()
LambdaWlxy16MonitoringZBHIPOOT.v0 = cms.InputTag('LambdaWlxy16')
LambdaWlxy16MonitoringZBHIPOOT.FolderName = cms.string("Tracking/V0Monitoring/HIP_OOTpu_noINpu/Lambda/Lxy16")

voWcutMonitoringZBHIPOOTSequence = cms.Sequence(
KshortWlxy16*KshortWlxy16MonitoringZBHIPOOT
+LambdaWlxy16*LambdaWlxy16MonitoringZBHIPOOT
)
@@ -1,8 +1,10 @@
import FWCore.ParameterSet.Config as cms

trackingEffFromHitPattern = cms.EDAnalyzer("DQMGenericClient",
subDirs = cms.untracked.vstring("Tracking/TrackParameters/generalTracks/HitEffFromHitPattern*",
"Tracking/TrackParameters/highPurityTracks/pt_1/HitEffFromHitPattern*"),
subDirs = cms.untracked.vstring(
"Tracking/TrackParameters/generalTracks/HitEffFromHitPattern*",
"Tracking/TrackParameters/highPurityTracks/dzPV0p1/HitEffFromHitPattern*",
),
efficiency = cms.vstring(
"effic_vs_PU_PXB1 'PXB Layer1 Efficiency vs GoodNumVertices' Hits_valid_PXB_Subdet1 Hits_total_PXB_Subdet1",
"effic_vs_PU_PXB2 'PXB Layer2 Efficiency vs GoodNumVertices' Hits_valid_PXB_Subdet2 Hits_total_PXB_Subdet2",
Expand Down
71 changes: 71 additions & 0 deletions DQM/TrackingMonitorSource/python/TrackCollections2monitor_cff.py
Expand Up @@ -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(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TrackWithVertexSelector does not have(/read) trackWithVertexSelectorParams PSet.

What happens in TrackWithVertexSelector_cfi.py is that the contents of trackWithVertexSelectorParams are copied to trackWithVertexSelector.

# 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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nVertices == 0 disables the vertex compatibility checks, i.e. only TrackWithVertexSelector::testTrack() gets called.

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 :
Expand Down