CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_10_patch1/src/Validation/RecoVertex/interface/PrimaryVertexAnalyzer.h

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 //
00003 // Package:    PrimaryVertexAnalyzer
00004 // Class:      PrimaryVertexAnalyzer
00005 // 
00013 //
00014 // Original Author:  Wolfram Erdmann
00015 //         Created:  Fri Jun  2 10:54:05 CEST 2006
00016 // $Id: PrimaryVertexAnalyzer.h,v 1.15 2009/03/06 15:08:42 werdmann Exp $
00017 //
00018 //
00019 
00020 
00021 // system include files
00022 #include <memory>
00023 #include <string>
00024 #include <vector>
00025  
00026 // user include files
00027 #include "FWCore/Framework/interface/Frameworkfwd.h"
00028 #include "FWCore/Framework/interface/EDAnalyzer.h"
00029 #include "FWCore/Framework/interface/Event.h"
00030 #include "FWCore/Framework/interface/MakerMacros.h"
00031 
00032 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00033 #include "DataFormats/TrackReco/interface/Track.h"
00034 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00035 
00036 //generator level
00037 #include "SimDataFormats/GeneratorProducts/interface/HepMCProduct.h"
00038 #include "HepMC/GenEvent.h"
00039 #include "HepMC/GenVertex.h"
00040 #include "HepMC/GenParticle.h"
00041  
00042 // vertex stuff
00043 #include <DataFormats/VertexReco/interface/VertexFwd.h>
00044 #include "RecoVertex/VertexPrimitives/interface/TransientVertex.h"
00045 
00046 // simulated vertices,..., add <use name=SimDataFormats/Vertex> and <../Track>
00047 #include <SimDataFormats/Vertex/interface/SimVertex.h>
00048 #include <SimDataFormats/Vertex/interface/SimVertexContainer.h>
00049 #include <SimDataFormats/Track/interface/SimTrack.h>
00050 #include <SimDataFormats/Track/interface/SimTrackContainer.h>
00051 #include "SimGeneral/HepPDTRecord/interface/ParticleDataTable.h"
00052 
00053 // Root
00054 #include <TH1.h>
00055 #include <TFile.h>
00056 #include <TDirectory.h>
00057 
00058 
00059 
00060 // class declaration
00061 class PrimaryVertexAnalyzer : public edm::EDAnalyzer {
00062 
00063 
00064 // auxiliary class holding simulated primary vertices
00065 class simPrimaryVertex {
00066 public:
00067   simPrimaryVertex(double x1,double y1,double z1):x(x1),y(y1),z(z1),ptsq(0),nGenTrk(0){};
00068   double x,y,z;
00069    HepMC::FourVector ptot;
00070   //HepLorentzVector ptot;
00071   double ptsq;
00072   int nGenTrk;
00073   std::vector<int> finalstateParticles;
00074   std::vector<int> simTrackIndex;
00075   std::vector<int> genVertex;
00076   const reco::Vertex *recVtx;
00077 };
00078 
00079 
00080 
00081 public:
00082   explicit PrimaryVertexAnalyzer(const edm::ParameterSet&);
00083   ~PrimaryVertexAnalyzer();
00084   
00085   virtual void analyze(const edm::Event&, const edm::EventSetup&);
00086   virtual void beginJob();
00087   virtual void endJob();
00088 
00089 private:
00090 
00091   bool matchVertex(const simPrimaryVertex  &vsim, 
00092                    const reco::Vertex       &vrec);
00093   bool isResonance(const HepMC::GenParticle * p);
00094   bool isFinalstateParticle(const HepMC::GenParticle * p);
00095   bool isCharged(const HepMC::GenParticle * p);
00096  
00097   void printRecVtxs(const edm::Handle<reco::VertexCollection> recVtxs);
00098   void printSimVtxs(const edm::Handle<edm::SimVertexContainer> simVtxs);
00099   void printSimTrks(const edm::Handle<edm::SimTrackContainer> simVtrks);
00100   std::vector<simPrimaryVertex> getSimPVs(const edm::Handle<edm::HepMCProduct> evtMC, std::string suffix);
00101   std::vector<simPrimaryVertex> getSimPVs(const edm::Handle<edm::HepMCProduct> evt, 
00102                                           const edm::Handle<edm::SimVertexContainer> simVtxs, 
00103                                           const edm::Handle<edm::SimTrackContainer> simTrks);
00104   // ----------member data ---------------------------
00105   std::string recoTrackProducer_;
00106   std::string outputFile_;       // output file
00107   std::vector<std::string> vtxSample_;        // which vertices to analyze
00108   std::vector<std::string> suffixSample_;
00109   TFile*  rootFile_;             
00110   bool verbose_;
00111   edm::InputTag simG4_;
00112   double simUnit_;     
00113   edm::ESHandle < ParticleDataTable > pdt;
00114      
00115 
00116         std::map<std::string, TH1*> h;
00117         std::map<std::string, TDirectory*> hdir;
00118         
00119 };
00120