CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
PatVertexAnalyzer Class Reference
Inheritance diagram for PatVertexAnalyzer:
edm::EDAnalyzer edm::EDConsumerBase

Public Member Functions

void analyze (const edm::Event &event, const edm::EventSetup &es) override
 
void beginJob () override
 
 PatVertexAnalyzer (const edm::ParameterSet &params)
 constructor and destructor More...
 
 ~PatVertexAnalyzer () override
 
- Public Member Functions inherited from edm::EDAnalyzer
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzer ()
 
SerialTaskQueueglobalLuminosityBlocksQueue ()
 
SerialTaskQueueglobalRunsQueue ()
 
ModuleDescription const & moduleDescription () const
 
std::string workerType () const
 
 ~EDAnalyzer () override
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase &&)=default
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
ESProxyIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
std::vector< ESProxyIndex > const & esGetTokenIndicesVector (edm::Transition iTrans) const
 
std::vector< ESRecordIndex > const & esGetTokenRecordIndicesVector (edm::Transition iTrans) const
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProxyIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

Private Attributes

edm::EDGetTokenT< reco::GenParticleCollectiongenParticlesToken_
 
TH1 * nTracks_
 
TH1 * nVertices_
 
edm::EDGetTokenT< reco::VertexCollectionsrcToken_
 
TH1 * x_
 
TH1 * xDelta_
 
TH1 * xErr_
 
TH1 * xPull_
 
TH1 * y_
 
TH1 * yDelta_
 
TH1 * yErr_
 
TH1 * yPull_
 
TH1 * z_
 
TH1 * zDelta_
 
TH1 * zErr_
 
TH1 * zPull_
 

Additional Inherited Members

- Public Types inherited from edm::EDAnalyzer
typedef EDAnalyzer ModuleType
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from edm::EDAnalyzer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &)
 
static bool wantsGlobalLuminosityBlocks ()
 
static bool wantsGlobalRuns ()
 
static bool wantsInputProcessBlocks ()
 
static bool wantsProcessBlocks ()
 
static bool wantsStreamLuminosityBlocks ()
 
static bool wantsStreamRuns ()
 
- Protected Member Functions inherited from edm::EDConsumerBase
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
template<BranchType B = InEvent>
EDConsumerBaseAdaptor< B > consumes (edm::InputTag tag) noexcept
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<Transition Tr = Transition::Event>
constexpr auto esConsumes () noexcept
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
template<Transition Tr = Transition::Event>
auto esConsumes (ESInputTag tag) noexcept
 
template<Transition Tr = Transition::Event>
ESGetTokenGeneric esConsumes (eventsetup::EventSetupRecordKey const &iRecord, eventsetup::DataKey const &iKey)
 Used with EventSetupRecord::doGet. More...
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 

Detailed Description

Definition at line 26 of file PatVertexAnalyzer.cc.

Constructor & Destructor Documentation

◆ PatVertexAnalyzer()

PatVertexAnalyzer::PatVertexAnalyzer ( const edm::ParameterSet params)

constructor and destructor

Definition at line 48 of file PatVertexAnalyzer.cc.

49  : srcToken_(consumes<reco::VertexCollection>(params.getParameter<edm::InputTag>("src"))),
50  genParticlesToken_(consumes<reco::GenParticleCollection>(params.getParameter<edm::InputTag>("mc"))) {}

◆ ~PatVertexAnalyzer()

PatVertexAnalyzer::~PatVertexAnalyzer ( )
override

Definition at line 52 of file PatVertexAnalyzer.cc.

52 {}

Member Function Documentation

◆ analyze()

void PatVertexAnalyzer::analyze ( const edm::Event event,
const edm::EventSetup es 
)
overridevirtual

Implements edm::EDAnalyzer.

Definition at line 75 of file PatVertexAnalyzer.cc.

75  {
76  // handle to the primary vertex collection
78  event.getByToken(srcToken_, pvHandle);
79 
80  // handle to the generator particles (i.e. the MC truth)
82  event.getByToken(genParticlesToken_, genParticlesHandle);
83 
84  // extract the position of the simulated vertex
85  math::XYZPoint simPV = (*genParticlesHandle)[2].vertex();
86 
87  // the number of reconstructed primary vertices
88  nVertices_->Fill(pvHandle->size());
89 
90  // if we have at least one, use the first (highest pt^2 sum)
91  if (!pvHandle->empty()) {
92  const reco::Vertex &pv = (*pvHandle)[0];
93 
94  nTracks_->Fill(pv.tracksSize());
95 
96  x_->Fill(pv.x());
97  y_->Fill(pv.y());
98  z_->Fill(pv.z());
99 
100  xErr_->Fill(pv.xError());
101  yErr_->Fill(pv.yError());
102  zErr_->Fill(pv.zError());
103 
104  xDelta_->Fill(pv.x() - simPV.X());
105  yDelta_->Fill(pv.y() - simPV.Y());
106  zDelta_->Fill(pv.z() - simPV.Z());
107 
108  xPull_->Fill((pv.x() - simPV.X()) / pv.xError());
109  yPull_->Fill((pv.y() - simPV.Y()) / pv.yError());
110  zPull_->Fill((pv.z() - simPV.Z()) / pv.zError());
111 
112  // we could access the tracks using the
113  // pv.tracks_begin() ... pv.tracks_end() iterators
114  }
115 }

References genParticlesToken_, nTracks_, nVertices_, MetAnalyzer::pv(), srcToken_, x_, xDelta_, xErr_, xPull_, y_, yDelta_, yErr_, yPull_, z_, zDelta_, zErr_, and zPull_.

◆ beginJob()

void PatVertexAnalyzer::beginJob ( void  )
overridevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 54 of file PatVertexAnalyzer.cc.

54  {
55  // retrieve handle to auxiliary service
56  // used for storing histograms into ROOT file
58 
59  nVertices_ = fs->make<TH1F>("nVertices", "number of reconstructed primary vertices", 50, 0, 50);
60  nTracks_ = fs->make<TH1F>("nTracks", "number of tracks at primary vertex", 100, 0, 300);
61  x_ = fs->make<TH1F>("pvX", "primary vertex x", 100, -0.1, 0.1);
62  y_ = fs->make<TH1F>("pvY", "primary vertex y", 100, -0.1, 0.1);
63  z_ = fs->make<TH1F>("pvZ", "primary vertex z", 100, -30, 30);
64  xErr_ = fs->make<TH1F>("pvErrorX", "primary vertex x error", 100, 0, 0.005);
65  yErr_ = fs->make<TH1F>("pvErrorY", "primary vertex y error", 100, 0, 0.005);
66  zErr_ = fs->make<TH1F>("pvErrorZ", "primary vertex z error", 100, 0, 0.01);
67  xDelta_ = fs->make<TH1F>("pvDeltaX", "x shift wrt simulated vertex", 100, -0.01, 0.01);
68  yDelta_ = fs->make<TH1F>("pvDeltaY", "y shift wrt simulated vertex", 100, -0.01, 0.01);
69  zDelta_ = fs->make<TH1F>("pvDeltaZ", "z shift wrt simulated vertex", 100, -0.02, 0.02);
70  xPull_ = fs->make<TH1F>("pvPullX", "primary vertex x pull", 100, -5, 5);
71  yPull_ = fs->make<TH1F>("pvPullY", "primary vertex y pull", 100, -5, 5);
72  zPull_ = fs->make<TH1F>("pvPullZ", "primary vertex z pull", 100, -5, 5);
73 }

References TFileService::make(), nTracks_, nVertices_, x_, xDelta_, xErr_, xPull_, y_, yDelta_, yErr_, yPull_, z_, zDelta_, zErr_, and zPull_.

Member Data Documentation

◆ genParticlesToken_

edm::EDGetTokenT<reco::GenParticleCollection> PatVertexAnalyzer::genParticlesToken_
private

Definition at line 39 of file PatVertexAnalyzer.cc.

Referenced by analyze().

◆ nTracks_

TH1 * PatVertexAnalyzer::nTracks_
private

Definition at line 41 of file PatVertexAnalyzer.cc.

Referenced by analyze(), and beginJob().

◆ nVertices_

TH1* PatVertexAnalyzer::nVertices_
private

Definition at line 41 of file PatVertexAnalyzer.cc.

Referenced by analyze(), and beginJob().

◆ srcToken_

edm::EDGetTokenT<reco::VertexCollection> PatVertexAnalyzer::srcToken_
private

Definition at line 38 of file PatVertexAnalyzer.cc.

Referenced by analyze().

◆ x_

TH1* PatVertexAnalyzer::x_
private

Definition at line 42 of file PatVertexAnalyzer.cc.

Referenced by analyze(), and beginJob().

◆ xDelta_

TH1* PatVertexAnalyzer::xDelta_
private

Definition at line 44 of file PatVertexAnalyzer.cc.

Referenced by analyze(), and beginJob().

◆ xErr_

TH1* PatVertexAnalyzer::xErr_
private

Definition at line 43 of file PatVertexAnalyzer.cc.

Referenced by analyze(), and beginJob().

◆ xPull_

TH1* PatVertexAnalyzer::xPull_
private

Definition at line 45 of file PatVertexAnalyzer.cc.

Referenced by analyze(), and beginJob().

◆ y_

TH1 * PatVertexAnalyzer::y_
private

Definition at line 42 of file PatVertexAnalyzer.cc.

Referenced by analyze(), and beginJob().

◆ yDelta_

TH1 * PatVertexAnalyzer::yDelta_
private

Definition at line 44 of file PatVertexAnalyzer.cc.

Referenced by analyze(), and beginJob().

◆ yErr_

TH1 * PatVertexAnalyzer::yErr_
private

Definition at line 43 of file PatVertexAnalyzer.cc.

Referenced by analyze(), and beginJob().

◆ yPull_

TH1 * PatVertexAnalyzer::yPull_
private

Definition at line 45 of file PatVertexAnalyzer.cc.

Referenced by analyze(), and beginJob().

◆ z_

TH1 * PatVertexAnalyzer::z_
private

Definition at line 42 of file PatVertexAnalyzer.cc.

Referenced by analyze(), and beginJob().

◆ zDelta_

TH1 * PatVertexAnalyzer::zDelta_
private

Definition at line 44 of file PatVertexAnalyzer.cc.

Referenced by analyze(), and beginJob().

◆ zErr_

TH1 * PatVertexAnalyzer::zErr_
private

Definition at line 43 of file PatVertexAnalyzer.cc.

Referenced by analyze(), and beginJob().

◆ zPull_

TH1 * PatVertexAnalyzer::zPull_
private

Definition at line 45 of file PatVertexAnalyzer.cc.

Referenced by analyze(), and beginJob().

PatVertexAnalyzer::xDelta_
TH1 * xDelta_
Definition: PatVertexAnalyzer.cc:44
PatVertexAnalyzer::y_
TH1 * y_
Definition: PatVertexAnalyzer.cc:42
CalibrationSummaryClient_cfi.params
params
Definition: CalibrationSummaryClient_cfi.py:14
PatVertexAnalyzer::genParticlesToken_
edm::EDGetTokenT< reco::GenParticleCollection > genParticlesToken_
Definition: PatVertexAnalyzer.cc:39
PatVertexAnalyzer::z_
TH1 * z_
Definition: PatVertexAnalyzer.cc:42
PatVertexAnalyzer::yPull_
TH1 * yPull_
Definition: PatVertexAnalyzer.cc:45
PatVertexAnalyzer::zErr_
TH1 * zErr_
Definition: PatVertexAnalyzer.cc:43
edm::Handle< reco::VertexCollection >
PatVertexAnalyzer::srcToken_
edm::EDGetTokenT< reco::VertexCollection > srcToken_
Definition: PatVertexAnalyzer.cc:38
PatVertexAnalyzer::zDelta_
TH1 * zDelta_
Definition: PatVertexAnalyzer.cc:44
PatVertexAnalyzer::xErr_
TH1 * xErr_
Definition: PatVertexAnalyzer.cc:43
math::XYZPoint
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
PatVertexAnalyzer::x_
TH1 * x_
Definition: PatVertexAnalyzer.cc:42
PatVertexAnalyzer::nTracks_
TH1 * nTracks_
Definition: PatVertexAnalyzer.cc:41
edm::Service< TFileService >
MetAnalyzer.pv
def pv(vc)
Definition: MetAnalyzer.py:7
PatVertexAnalyzer::xPull_
TH1 * xPull_
Definition: PatVertexAnalyzer.cc:45
PatVertexAnalyzer::yDelta_
TH1 * yDelta_
Definition: PatVertexAnalyzer.cc:44
PatVertexAnalyzer::zPull_
TH1 * zPull_
Definition: PatVertexAnalyzer.cc:45
PatVertexAnalyzer::yErr_
TH1 * yErr_
Definition: PatVertexAnalyzer.cc:43
edm::InputTag
Definition: InputTag.h:15
reco::Vertex
Definition: Vertex.h:35
PatVertexAnalyzer::nVertices_
TH1 * nVertices_
Definition: PatVertexAnalyzer.cc:41
TFileService::make
T * make(const Args &... args) const
make new ROOT object
Definition: TFileService.h:64