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

Vertex validation slhc16p1 #4871

Merged
merged 13 commits into from Aug 7, 2014
Merged
Show file tree
Hide file tree
Changes from all 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 Validation/Configuration/python/postValidation_cff.py
Expand Up @@ -14,12 +14,14 @@
from Validation.RPCRecHits.postValidation_cfi import *
from Validation.RecoTau.DQMMCValidation_cfi import *
from Validation.RecoEgamma.photonFastSimPostProcessor_cff import *
from Validation.RecoVertex.PrimaryVertexAnalyzer4PUSlimmed_Client_cfi import *
from DQMOffline.RecoB.dqmCollector_cff import *


postValidation = cms.Sequence(
recoMuonPostProcessors
+ postProcessorTrack
+ postProcessorVertex
+ MuIsoValPostProcessor
+ calotowersPostProcessor
+ hcalSimHitsPostProcessor
Expand Down
162 changes: 162 additions & 0 deletions Validation/RecoVertex/interface/PrimaryVertexAnalyzer4PUSlimmed.h
@@ -0,0 +1,162 @@
#ifndef VALIDATION_RECOVERTEX_INTERFACE_PRIMARYVERTEXANALYZER4PUSLIMMED_H_
#define VALIDATION_RECOVERTEX_INTERFACE_PRIMARYVERTEXANALYZER4PUSLIMMED_H_

// -*- C++ -*-
//
// Package: PrimaryVertexAnalyzer4PUSlimmed
// Class: PrimaryVertexAnalyzer4PUSlimmed
//
/**\class PrimaryVertexAnalyzer4PUSlimmed PrimaryVertexAnalyzer4PUSlimmed.cc Validation/RecoVertex/src/PrimaryVertexAnalyzer4PUSlimmed.cc

Description: primary vertex analyzer for events with pile-up

Implementation:
<Notes on implementation>
*/
//
// Original Author: Marco Rovere (code adapted from old code by
// Wolfram Erdmann)


// system include files
#include <memory>
#include <string>
#include <vector>
#include <map>
#include <algorithm>

// user include files
#include "FWCore/Framework/interface/Frameworkfwd.h"
#include "FWCore/Framework/interface/EDAnalyzer.h"
#include "FWCore/Framework/interface/ESHandle.h"

// math
#include "DataFormats/Math/interface/LorentzVector.h"
#include "DataFormats/Math/interface/Point3D.h"

// reco track
#include "DataFormats/TrackReco/interface/Track.h"
#include "DataFormats/TrackReco/interface/TrackFwd.h"

// reco vertex
#include "DataFormats/VertexReco/interface/VertexFwd.h"

// simulated track
#include "SimDataFormats/TrackingAnalysis/interface/TrackingParticle.h"
#include "SimTracker/TrackAssociation/interface/TrackAssociatorBase.h"

// pile-up
#include "SimDataFormats/PileupSummaryInfo/interface/PileupSummaryInfo.h"

// vertexing
#include "RecoVertex/PrimaryVertexProducer/interface/TrackFilterForPVFinding.h"

class MonitorElement;

// class declaration
class PrimaryVertexAnalyzer4PUSlimmed : public edm::EDAnalyzer {
typedef math::XYZTLorentzVector LorentzVector;

// auxiliary class holding simulated vertices
struct simPrimaryVertex {
simPrimaryVertex(double x1, double y1, double z1)
:x(x1), y(y1), z(z1),
ptsq(0), closest_vertex_distance_z(-1.),
nGenTrk(0),
num_matched_reco_tracks(0),
average_match_quality(0.0),
sim_vertex(nullptr) {
ptot.setPx(0);
ptot.setPy(0);
ptot.setPz(0);
ptot.setE(0);
p4 = LorentzVector(0, 0, 0, 0);
r = sqrt(x*x + y*y);
};
double x, y, z, r;
HepMC::FourVector ptot;
LorentzVector p4;
double ptsq;
double closest_vertex_distance_z;
int nGenTrk;
int num_matched_reco_tracks;
float average_match_quality;
EncodedEventId eventId;
const TrackingVertex * sim_vertex;
std::vector<const reco::Vertex *> rec_vertices;
};

// auxiliary class holding reconstructed vertices
struct recoPrimaryVertex {
recoPrimaryVertex(double x1, double y1, double z1)
:x(x1), y(y1), z(z1),
ptsq(0), closest_vertex_distance_z(-1.),
nRecoTrk(0),
recVtx(nullptr) {
r = sqrt(x*x + y*y);
};
double x, y, z, r;
double ptsq;
double closest_vertex_distance_z;
int nRecoTrk;
std::vector<const TrackingVertex *> sim_vertices;
std::vector<const simPrimaryVertex *> sim_vertices_internal;
const reco::Vertex *recVtx;
};

public:
explicit PrimaryVertexAnalyzer4PUSlimmed(const edm::ParameterSet&);
~PrimaryVertexAnalyzer4PUSlimmed();

virtual void analyze(const edm::Event&, const edm::EventSetup&);
virtual void bookHistograms(edm::Run const&,
edm::EventSetup const&);
virtual void beginRun(edm::Run const&iRun, edm::EventSetup const &iSetup) {
bookHistograms(iRun, iSetup);
}

private:
void resetSimPVAssociation(std::vector<simPrimaryVertex>&);
void matchSim2RecoVertices(std::vector<simPrimaryVertex>&,
const reco::VertexCollection &);
void matchReco2SimVertices(std::vector<recoPrimaryVertex>&,
const TrackingVertexCollection &,
const std::vector<simPrimaryVertex>&);
void fillGenericGenVertexHistograms(const simPrimaryVertex &v);
// void fillGenericRecoVertexHistograms(const std::string &,
// const simPrimaryVertex &v);
void fillRecoAssociatedGenVertexHistograms(const std::string &,
const simPrimaryVertex &v);
void fillGenAssociatedRecoVertexHistograms(const std::string &,
const recoPrimaryVertex &v);

std::vector<PrimaryVertexAnalyzer4PUSlimmed::simPrimaryVertex> getSimPVs(
const edm::Handle<TrackingVertexCollection>);

std::vector<PrimaryVertexAnalyzer4PUSlimmed::recoPrimaryVertex> getRecoPVs(
const edm::Handle<reco::VertexCollection>);

// ----------member data ---------------------------
bool verbose_;
bool use_TP_associator_;
double sigma_z_match_;
std::string root_folder_;

std::map<std::string, std::map<std::string, MonitorElement*> > mes_;
reco::RecoToSimCollection r2s_;
reco::SimToRecoCollection s2r_;

// TODO(rovere) possibly reuse an object from the event and do not
// re-run the associator(s)
const TrackAssociatorBase * associatorByHits_;

edm::EDGetTokenT< std::vector<PileupSummaryInfo> > vecPileupSummaryInfoToken_;
std::vector<edm::EDGetTokenT<reco::VertexCollection> > reco_vertex_collection_tokens_;
std::vector<edm::InputTag > reco_vertex_collections_;
edm::EDGetTokenT<reco::TrackCollection> recoTrackCollectionToken_;
edm::EDGetTokenT< edm::View<reco::Track> > edmView_recoTrack_Token_;
edm::EDGetTokenT<TrackingParticleCollection> trackingParticleCollectionToken_;
edm::EDGetTokenT<TrackingVertexCollection> trackingVertexCollectionToken_;
};

#endif // VALIDATION_RECOVERTEX_INTERFACE_PRIMARYVERTEXANALYZER4PUSLIMMED_H_
@@ -0,0 +1,45 @@
import FWCore.ParameterSet.Config as cms

postProcessorVertex = cms.EDAnalyzer("DQMGenericClient",
subDirs = cms.untracked.vstring("Vertexing/PrimaryVertexV/*"),
efficiency = cms.vstring(
"effic_vs_NumVertices 'Efficiency vs NumVertices' GenAllAssoc2RecoMatched_NumVertices GenAllAssoc2Reco_NumVertices",
"effic_vs_Z 'Efficiency vs Z' GenAllAssoc2RecoMatched_Z GenAllAssoc2Reco_Z",
"effic_vs_R 'Efficiency vs R' GenAllAssoc2RecoMatched_R GenAllAssoc2Reco_R",
"effic_vs_Pt2 'Efficiency vs Sum p_{T}^{2}' GenAllAssoc2RecoMatched_Pt2 GenAllAssoc2Reco_Pt2",
"effic_vs_NumTracks 'Efficiency vs NumTracks' GenAllAssoc2RecoMatched_NumTracks GenAllAssoc2Reco_NumTracks",
"effic_vs_ClosestVertexInZ 'Efficiency vs ClosestVtx in Z' GenAllAssoc2RecoMatched_ClosestDistanceZ GenAllAssoc2Reco_ClosestDistanceZ",
"gen_duplicate_vs_ClosestVertexInZ 'Gen_Duplicate vs ClosestVtx in Z' GenAllAssoc2RecoMultiMatched_ClosestDistanceZ GenAllAssoc2Reco_ClosestDistanceZ",
"gen_duplicate_vs_NumVertices 'Gen_Duplicate vs NumVertices' GenAllAssoc2RecoMultiMatched_NumVertices GenAllAssoc2Reco_NumVertices",
"gen_duplicate_vs_Z 'Gen_Duplicate vs Z' GenAllAssoc2RecoMultiMatched_Z GenAllAssoc2Reco_Z",
"gen_duplicate_vs_R 'Gen_Duplicate vs R' GenAllAssoc2RecoMultiMatched_R GenAllAssoc2Reco_R",
"gen_duplicate_vs_Pt2 'Gen_Duplicate vs Sum p_{T}^{2}' GenAllAssoc2RecoMultiMatched_Pt2 GenAllAssoc2Reco_Pt2",
"gen_duplicate_vs_NumTracks 'Gen_Duplicate vs NumTracks' GenAllAssoc2RecoMultiMatched_NumTracks GenAllAssoc2Reco_NumTracks",
"gen_duplicate_vs_ClosestVertexInZ 'Gen_Duplicate vs ClosestVtx in Z' GenAllAssoc2RecoMultiMatched_ClosestDistanceZ GenAllAssoc2Reco_ClosestDistanceZ",
"merged_vs_NumVertices 'Merged vs NumVertices' RecoAllAssoc2GenMultiMatched_NumVertices RecoAllAssoc2Gen_NumVertices",
"merged_vs_Z 'Merged vs Z' RecoAllAssoc2GenMultiMatched_Z RecoAllAssoc2Gen_Z",
"merged_vs_R 'Merged vs R' RecoAllAssoc2GenMultiMatched_R RecoAllAssoc2Gen_R",
"merged_vs_Pt2 'Merged vs Sum p_{T}^{2}' RecoAllAssoc2GenMultiMatched_Pt2 RecoAllAssoc2Gen_Pt2",
"merged_vs_NumTracks 'Merged vs NumTracks' RecoAllAssoc2GenMultiMatched_NumTracks RecoAllAssoc2Gen_NumTracks",
"merged_vs_ClosestVertexInZ 'Merged vs ClosestVtx in Z' RecoAllAssoc2GenMultiMatched_ClosestDistanceZ RecoAllAssoc2GenSimForMerge_ClosestDistanceZ",
"fakerate_vs_NumVertices 'Fakerate vs NumVertices' RecoAllAssoc2GenMatched_NumVertices RecoAllAssoc2Gen_NumVertices fake",
"fakerate_vs_Z 'Fakerate vs Z' RecoAllAssoc2GenMatched_Z RecoAllAssoc2Gen_Z fake",
"fakerate_vs_R 'Fakerate vs R' RecoAllAssoc2GenMatched_R RecoAllAssoc2Gen_R fake",
"fakerate_vs_Pt2 'Fakerate vs Sum p_{T}^{2}' RecoAllAssoc2GenMatched_Pt2 RecoAllAssoc2Gen_Pt2 fake",
"fakerate_vs_Ndof 'Fakerate vs Ndof' RecoAllAssoc2GenMatched_Ndof RecoAllAssoc2Gen_Ndof fake",
"fakerate_vs_NumTracks 'Fakerate vs NumTracks' RecoAllAssoc2GenMatched_NumTracks RecoAllAssoc2Gen_NumTracks fake",
"fakerate_vs_ClosestVertexInZ 'Fakerate vs ClosestVtx in Z' RecoAllAssoc2GenMatched_ClosestDistanceZ RecoAllAssoc2Gen_ClosestDistanceZ fake",
"duplicate_vs_NumVertices 'Duplicate vs NumVertices' RecoAllAssoc2MultiMatchedGen_NumVertices RecoAllAssoc2Gen_NumVertices",
"duplicate_vs_Z 'Duplicate vs Z' RecoAllAssoc2MultiMatchedGen_Z RecoAllAssoc2Gen_Z",
"duplicate_vs_R 'Duplicate vs R' RecoAllAssoc2MultiMatchedGen_R RecoAllAssoc2Gen_R",
"duplicate_vs_Pt2 'Duplicate vs Sum p_{T}^{2}' RecoAllAssoc2MultiMatchedGen_Pt2 RecoAllAssoc2Gen_Pt2",
"duplicate_vs_NumTracks 'Duplicate vs NumTracks' RecoAllAssoc2MultiMatchedGen_NumTracks RecoAllAssoc2Gen_NumTracks",
"duplicate_vs_ClosestVertexInZ 'Duplicate vs ClosestsVtx In Z' RecoAllAssoc2MultiMatchedGen_ClosestDistanceZ RecoAllAssoc2Gen_ClosestDistanceZ"
),
resolution = cms.vstring(),
profile= cms.vstring(),
outputFileName = cms.untracked.string(""),
verbose = cms.untracked.uint32(5)
)

postProcessorVertexStandAlone = cms.Sequence(postProcessorVertex)
@@ -0,0 +1,34 @@
import FWCore.ParameterSet.Config as cms

selectedOfflinePrimaryVertices = cms.EDFilter("VertexSelector",
src = cms.InputTag('offlinePrimaryVertices'),
cut = cms.string("isValid & ndof > 4 & tracksSize > 0 & abs(z) <= 24 & abs(position.Rho) <= 2."),
filter = cms.bool(False)
)

selectedOfflinePrimaryVerticesWithBS = selectedOfflinePrimaryVertices.clone()
selectedOfflinePrimaryVerticesWithBS.src = cms.InputTag('offlinePrimaryVerticesWithBS')

selectedPixelVertices = selectedOfflinePrimaryVertices.clone()
selectedPixelVertices.src = cms.InputTag('pixelVertices')

vertexAnalysis = cms.EDAnalyzer("PrimaryVertexAnalyzer4PUSlimmed",
simG4 = cms.InputTag("g4SimHits"),
use_TP_associator = cms.untracked.bool(False),
verbose = cms.untracked.bool(False),
sigma_z_match = cms.untracked.double(3.0),
root_folder = cms.untracked.string("Vertexing/PrimaryVertexV"),
recoTrackProducer = cms.untracked.string("generalTracks"),
vertexRecoCollections = cms.VInputTag("offlinePrimaryVertices",
"offlinePrimaryVerticesWithBS",
"pixelVertices",
"selectedOfflinePrimaryVertices",
"selectedOfflinePrimaryVerticesWithBS",
"selectedPixelVertices"),
)

vertexAnalysisSequence = cms.Sequence(cms.ignore(selectedOfflinePrimaryVertices)
* cms.ignore(selectedOfflinePrimaryVerticesWithBS)
* cms.ignore(selectedPixelVertices)
* vertexAnalysis
)
5 changes: 4 additions & 1 deletion Validation/RecoVertex/python/VertexValidation_cff.py
Expand Up @@ -2,5 +2,8 @@

from SimTracker.TrackAssociation.trackingParticleRecoTrackAsssociation_cfi import *
from Validation.RecoVertex.v0validator_cfi import *
from Validation.RecoVertex.PrimaryVertexAnalyzer4PUSlimmed_cfi import *

vertexValidation = cms.Sequence(trackingParticleRecoTrackAsssociation * v0Validator)
vertexValidation = cms.Sequence(trackingParticleRecoTrackAsssociation
* v0Validator
* vertexAnalysisSequence)