Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 14:34:23

0001 #include "Validation/RecoVertex/interface/VertexHistogramMaker.h"
0002 #include "FWCore/Framework/interface/ConsumesCollector.h"
0003 #include "FWCore/Framework/interface/Event.h"
0004 #include "FWCore/Framework/interface/LuminosityBlock.h"
0005 #include "FWCore/Framework/interface/Run.h"
0006 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0007 #include "FWCore/ServiceRegistry/interface/Service.h"
0008 #include "CommonTools/UtilAlgos/interface/TFileService.h"
0009 #include "DataFormats/Luminosity/interface/LumiDetails.h"
0010 #include "DataFormats/VertexReco/interface/Vertex.h"
0011 #include "TH2F.h"
0012 #include "TH1F.h"
0013 #include "TProfile.h"
0014 
0015 VertexHistogramMaker::VertexHistogramMaker(edm::ConsumesCollector&& iC)
0016     : m_currdir(nullptr),
0017       m_maxLS(100),
0018       m_weightThreshold(0.5),
0019       m_trueOnly(true),
0020       m_runHisto(true),
0021       m_runHistoProfile(true),
0022       m_runHistoBXProfile(true),
0023       m_runHistoBXProfile2D(false),
0024       m_runHisto2D(false),
0025       m_bsConstrained(false),
0026       m_histoParameters(),
0027       m_rhm(iC),
0028       m_fhm(iC) {}
0029 
0030 VertexHistogramMaker::VertexHistogramMaker(const edm::ParameterSet& iConfig, edm::ConsumesCollector&& iC)
0031     : m_currdir(nullptr),
0032       m_maxLS(iConfig.getParameter<unsigned int>("maxLSBeforeRebin")),
0033       m_weightThreshold(iConfig.getUntrackedParameter<double>("weightThreshold", 0.5)),
0034       m_trueOnly(iConfig.getUntrackedParameter<bool>("trueOnly", true)),
0035       m_runHisto(iConfig.getUntrackedParameter<bool>("runHisto", true)),
0036       m_runHistoProfile(iConfig.getUntrackedParameter<bool>("runHistoProfile", true)),
0037       m_runHistoBXProfile(iConfig.getUntrackedParameter<bool>("runHistoBXProfile", true)),
0038       m_runHistoBXProfile2D(iConfig.getUntrackedParameter<bool>("runHistoBXProfile2D", false)),
0039       m_runHisto2D(iConfig.getUntrackedParameter<bool>("runHisto2D", false)),
0040       m_bsConstrained(iConfig.getParameter<bool>("bsConstrained")),
0041       m_histoParameters(iConfig.getUntrackedParameter<edm::ParameterSet>("histoParameters", edm::ParameterSet())),
0042       m_lumiDetailsToken(iC.consumes<LumiDetails, edm::InLumi>(edm::InputTag(std::string("lumiProducer")))),
0043       m_rhm(iC, false),
0044       m_fhm(iC, true) {}
0045 
0046 VertexHistogramMaker::~VertexHistogramMaker() { delete m_currdir; }
0047 
0048 void VertexHistogramMaker::book(const std::string dirname) {
0049   edm::Service<TFileService> tfserv;
0050   TFileDirectory* currdir = &(tfserv->tFileDirectory());
0051 
0052   if (!dirname.empty()) {
0053     currdir = new TFileDirectory(tfserv->mkdir(dirname));
0054     m_currdir = currdir;
0055   }
0056 
0057   edm::LogInfo("HistogramBooking") << "Vertex histogram booking in directory " << dirname;
0058 
0059   m_hnvtx = currdir->make<TH1F>("nvtx", "Number of Vertices", 60, -0.5, 59.5);
0060   m_hnvtx->GetXaxis()->SetTitle("vertices");
0061   m_hnvtx->GetYaxis()->SetTitle("Events");
0062 
0063   m_hntruevtx = currdir->make<TH1F>("ntruevtx", "Number of True Vertices", 60, -0.5, 59.5);
0064   m_hntruevtx->GetXaxis()->SetTitle("vertices");
0065   m_hntruevtx->GetYaxis()->SetTitle("Events");
0066 
0067   m_hntruevtxvslumi = currdir->make<TProfile>("ntruevtxvslumi", "Number of True Vertices vs BX lumi", 250, 0., 10.);
0068   m_hntruevtxvslumi->GetXaxis()->SetTitle("BX lumi [10^{30}cm^{-2}s^{-1}]");
0069   m_hntruevtxvslumi->GetYaxis()->SetTitle("Vertices");
0070 
0071   m_hntruevtxvslumi2D =
0072       currdir->make<TH2D>("ntruevtxvslumi2D", "Number of True Vertices vs BX lumi", 250, 0., 10., 100, -0.5, 99.5);
0073   m_hntruevtxvslumi2D->GetXaxis()->SetTitle("BX lumi [10^{30}cm^{-2}s^{-1}]");
0074   m_hntruevtxvslumi2D->GetYaxis()->SetTitle("Vertices");
0075 
0076   m_hntracks = currdir->make<TH1F>("ntracks", "Number of Tracks", 300, -0.5, 299.5);
0077   m_hntracks->GetXaxis()->SetTitle("tracks");
0078   m_hntracks->GetYaxis()->SetTitle("Vertices");
0079 
0080   m_hsqsumptsq = currdir->make<TH1F>("sqsumptsq", "sqrt(sum pt**2)", 1000, 0., 1000.);
0081   m_hsqsumptsq->GetXaxis()->SetTitle("sqrt(#Sigma pt^{2}) (GeV)");
0082   m_hsqsumptsq->GetYaxis()->SetTitle("Vertices");
0083 
0084   char htitle[300];
0085   sprintf(htitle, "sqrt(sum pt**2) of Tracks weight > %f", m_weightThreshold);
0086   m_hsqsumptsqheavy = currdir->make<TH1F>("sqsumptsqheavy", htitle, 1000, 0., 1000.);
0087   m_hsqsumptsqheavy->GetXaxis()->SetTitle("sqrt(#Sigma pt^{2}) (GeV)");
0088   m_hsqsumptsqheavy->GetYaxis()->SetTitle("Vertices");
0089 
0090   sprintf(htitle, "Number of Tracks weight > %f", m_weightThreshold);
0091   m_hnheavytracks = currdir->make<TH1F>("nheavytracks", htitle, 200, -0.5, 199.5);
0092   m_hnheavytracks->GetXaxis()->SetTitle("tracks");
0093   m_hnheavytracks->GetYaxis()->SetTitle("Vertices");
0094 
0095   m_hndof = currdir->make<TH1F>("ndof", "Number of degree of freedom", 250, -0.5, 499.5);
0096   m_hndof->GetXaxis()->SetTitle("ndof");
0097   m_hndof->GetYaxis()->SetTitle("Vertices");
0098 
0099   m_hndofvstracks = currdir->make<TH2F>("ndofvstracks", "Ndof vs Ntracks", 300, -0.5, 299.5, 250, -0.5, 499.5);
0100   m_hndofvstracks->GetXaxis()->SetTitle("tracks");
0101   m_hndofvstracks->GetYaxis()->SetTitle("ndof");
0102 
0103   m_hndofvsvtxz = currdir->make<TProfile>("ndofvsvtxz",
0104                                           "Ndof vs Vertex Z position",
0105                                           200,
0106                                           m_histoParameters.getUntrackedParameter<double>("zMin", -20.),
0107                                           m_histoParameters.getUntrackedParameter<double>("zMax", 20.));
0108   m_hndofvsvtxz->GetXaxis()->SetTitle("Z [cm]");
0109   m_hndofvsvtxz->GetYaxis()->SetTitle("ndof");
0110 
0111   m_hntracksvsvtxz = currdir->make<TProfile>("ntracksvsvtxz",
0112                                              "Ntracks vs Vertex Z position",
0113                                              200,
0114                                              m_histoParameters.getUntrackedParameter<double>("zMin", -20.),
0115                                              m_histoParameters.getUntrackedParameter<double>("zMax", 20.));
0116   m_hntracksvsvtxz->GetXaxis()->SetTitle("Z [cm]");
0117   m_hntracksvsvtxz->GetYaxis()->SetTitle("tracks");
0118 
0119   m_haveweightvsvtxz = currdir->make<TProfile>("aveweightvsvtxz",
0120                                                "Average weight vs Vertex Z position",
0121                                                200,
0122                                                m_histoParameters.getUntrackedParameter<double>("zMin", -20.),
0123                                                m_histoParameters.getUntrackedParameter<double>("zMax", 20.));
0124   m_haveweightvsvtxz->GetXaxis()->SetTitle("Z [cm]");
0125   m_haveweightvsvtxz->GetYaxis()->SetTitle("Average weight");
0126 
0127   m_haveweightvsvtxzchk = currdir->make<TProfile>("aveweightvsvtxzchk",
0128                                                   "Average weight vs Vertex Z position (check)",
0129                                                   200,
0130                                                   m_histoParameters.getUntrackedParameter<double>("zMin", -20.),
0131                                                   m_histoParameters.getUntrackedParameter<double>("zMax", 20.));
0132   m_haveweightvsvtxzchk->GetXaxis()->SetTitle("Z [cm]");
0133   m_haveweightvsvtxzchk->GetYaxis()->SetTitle("Average weight");
0134 
0135   m_hweights = currdir->make<TH1F>("weights", "Tracks weights", 51, 0., 1.02);
0136   m_hweights->GetXaxis()->SetTitle("weights");
0137   m_hweights->GetYaxis()->SetTitle("Tracks");
0138 
0139   m_haveweight = currdir->make<TH1F>("aveweight", "Tracks average weights sum", 51, 0., 1.02);
0140   m_haveweight->GetXaxis()->SetTitle("Average weight");
0141   m_haveweight->GetYaxis()->SetTitle("Vertices");
0142 
0143   m_hvtxx = currdir->make<TH1F>("vtxx",
0144                                 "Vertex X position",
0145                                 m_histoParameters.getUntrackedParameter<unsigned int>("nBinX", 200),
0146                                 m_histoParameters.getUntrackedParameter<double>("xMin", -1.),
0147                                 m_histoParameters.getUntrackedParameter<double>("xMax", 1.));
0148   m_hvtxx->GetXaxis()->SetTitle("X [cm]");
0149   m_hvtxx->GetYaxis()->SetTitle("Vertices");
0150 
0151   m_hvtxy = currdir->make<TH1F>("vtxy",
0152                                 "Vertex Y position",
0153                                 m_histoParameters.getUntrackedParameter<unsigned int>("nBinY", 200),
0154                                 m_histoParameters.getUntrackedParameter<double>("yMin", -1.),
0155                                 m_histoParameters.getUntrackedParameter<double>("yMax", 1.));
0156   m_hvtxy->GetXaxis()->SetTitle("Y [cm]");
0157   m_hvtxy->GetYaxis()->SetTitle("Vertices");
0158 
0159   m_hvtxz = currdir->make<TH1F>("vtxz",
0160                                 "Vertex Z position",
0161                                 m_histoParameters.getUntrackedParameter<unsigned int>("nBinZ", 200),
0162                                 m_histoParameters.getUntrackedParameter<double>("zMin", -20.),
0163                                 m_histoParameters.getUntrackedParameter<double>("zMax", 20.));
0164   m_hvtxz->GetXaxis()->SetTitle("Z [cm]");
0165   m_hvtxz->GetYaxis()->SetTitle("Vertices");
0166 
0167   if (m_runHisto) {
0168     m_hvtxxrun = m_rhm.makeTH1F("vtxxrun",
0169                                 "Vertex X position",
0170                                 m_histoParameters.getUntrackedParameter<unsigned int>("nBinX", 200),
0171                                 m_histoParameters.getUntrackedParameter<double>("xMin", -1.),
0172                                 m_histoParameters.getUntrackedParameter<double>("xMax", 1.));
0173 
0174     m_hvtxyrun = m_rhm.makeTH1F("vtxyrun",
0175                                 "Vertex Y position",
0176                                 m_histoParameters.getUntrackedParameter<unsigned int>("nBinY", 200),
0177                                 m_histoParameters.getUntrackedParameter<double>("yMin", -1.),
0178                                 m_histoParameters.getUntrackedParameter<double>("yMax", 1.));
0179 
0180     m_hvtxzrun = m_rhm.makeTH1F("vtxzrun",
0181                                 "Vertex Z position",
0182                                 m_histoParameters.getUntrackedParameter<unsigned int>("nBinZ", 200),
0183                                 m_histoParameters.getUntrackedParameter<double>("zMin", -20.),
0184                                 m_histoParameters.getUntrackedParameter<double>("zMax", 20.));
0185 
0186     if (m_runHistoProfile) {
0187       m_hvtxxvsorbrun = m_rhm.makeTProfile(
0188           "vtxxvsorbrun", "Vertex X position vs orbit number", 4 * m_maxLS, 0.5, m_maxLS * 262144 + 0.5);
0189       m_hvtxyvsorbrun = m_rhm.makeTProfile(
0190           "vtxyvsorbrun", "Vertex Y position vs orbit number", 4 * m_maxLS, 0.5, m_maxLS * 262144 + 0.5);
0191       m_hvtxzvsorbrun = m_rhm.makeTProfile(
0192           "vtxzvsorbrun", "Vertex Z position vs orbit number", 4 * m_maxLS, 0.5, m_maxLS * 262144 + 0.5);
0193       m_hnvtxvsorbrun = m_rhm.makeTProfile(
0194           "nvtxvsorbrun", "Number of true vertices vs orbit number", m_maxLS, 0.5, m_maxLS * 262144 + 0.5);
0195     }
0196 
0197     if (m_runHisto2D) {
0198       m_hnvtxvsbxvsorbrun = m_rhm.makeTProfile2D("nvtxvsbxvsorbrun",
0199                                                  "Number of true vertices vs BX vs orbit number",
0200                                                  3564,
0201                                                  -0.5,
0202                                                  3563.5,
0203                                                  m_maxLS,
0204                                                  0.5,
0205                                                  m_maxLS * 262144 + 0.5);
0206       m_hnvtxvsorbrun2D = m_rhm.makeTH2F("nvtxvsorbrun2D",
0207                                          "Number of true vertices vs orbit number",
0208                                          m_maxLS,
0209                                          0.5,
0210                                          m_maxLS * 262144 + 0.5,
0211                                          60,
0212                                          -0.5,
0213                                          59.5);
0214     }
0215 
0216     if (m_runHistoBXProfile) {
0217       m_hvtxxvsbxrun = m_fhm.makeTProfile("vtxxvsbxrun", "Vertex X position vs BX number", 3564, -0.5, 3563.5);
0218       m_hvtxyvsbxrun = m_fhm.makeTProfile("vtxyvsbxrun", "Vertex Y position vs BX number", 3564, -0.5, 3563.5);
0219       m_hvtxzvsbxrun = m_fhm.makeTProfile("vtxzvsbxrun", "Vertex Z position vs BX number", 3564, -0.5, 3563.5);
0220 
0221       m_hnvtxvsbxrun = m_rhm.makeTProfile("nvtxvsbxrun", "Number of true vertices vs BX number", 3564, -0.5, 3563.5);
0222 
0223       if (m_runHistoBXProfile2D) {
0224         m_hnvtxvsbxvslumirun = m_fhm.makeTProfile2D(
0225             "nvtxvsbxvslumirun", "Number of vertices vs BX and BX lumi", 3564, -0.5, 3563.5, 250, 0., 10.);
0226       }
0227       if (m_runHisto2D) {
0228         m_hvtxxvsbx2drun = m_fhm.makeTH2F("vtxxvsbx2drun",
0229                                           "Vertex X position vs BX number",
0230                                           3564,
0231                                           -0.5,
0232                                           3563.5,
0233                                           m_histoParameters.getUntrackedParameter<unsigned int>("nBinX", 200),
0234                                           m_histoParameters.getUntrackedParameter<double>("xMin", -1.),
0235                                           m_histoParameters.getUntrackedParameter<double>("xMax", 1.));
0236         m_hvtxyvsbx2drun = m_fhm.makeTH2F("vtxyvsbx2drun",
0237                                           "Vertex Y position vs BX number",
0238                                           3564,
0239                                           -0.5,
0240                                           3563.5,
0241                                           m_histoParameters.getUntrackedParameter<unsigned int>("nBinY", 200),
0242                                           m_histoParameters.getUntrackedParameter<double>("yMin", -1.),
0243                                           m_histoParameters.getUntrackedParameter<double>("yMax", 1.));
0244         m_hvtxzvsbx2drun = m_fhm.makeTH2F("vtxzvsbx2drun",
0245                                           "Vertex Z position vs BX number",
0246                                           3564,
0247                                           -0.5,
0248                                           3563.5,
0249                                           m_histoParameters.getUntrackedParameter<unsigned int>("nBinZ", 200),
0250                                           m_histoParameters.getUntrackedParameter<double>("zMin", -20.),
0251                                           m_histoParameters.getUntrackedParameter<double>("zMax", 20.));
0252       }
0253     }
0254   }
0255 }
0256 
0257 void VertexHistogramMaker::beginRun(const edm::Run& iRun) {
0258   TFileDirectory* currdir = m_currdir;
0259   if (currdir == nullptr) {
0260     edm::Service<TFileService> tfserv;
0261     currdir = &(tfserv->tFileDirectory());
0262   }
0263 
0264   m_rhm.beginRun(iRun, *currdir);
0265   m_fhm.beginRun(iRun, *currdir);
0266 
0267   if (m_runHisto) {
0268     (*m_hvtxxrun)->GetXaxis()->SetTitle("X [cm]");
0269     (*m_hvtxxrun)->GetYaxis()->SetTitle("Vertices");
0270     (*m_hvtxyrun)->GetXaxis()->SetTitle("Y [cm]");
0271     (*m_hvtxyrun)->GetYaxis()->SetTitle("Vertices");
0272     (*m_hvtxzrun)->GetXaxis()->SetTitle("Z [cm]");
0273     (*m_hvtxzrun)->GetYaxis()->SetTitle("Vertices");
0274 
0275     if (m_runHistoProfile) {
0276       (*m_hvtxxvsorbrun)->GetXaxis()->SetTitle("time [orbit#]");
0277       (*m_hvtxxvsorbrun)->GetYaxis()->SetTitle("X [cm]");
0278       (*m_hvtxxvsorbrun)->SetCanExtend(TH1::kAllAxes);
0279       (*m_hvtxyvsorbrun)->GetXaxis()->SetTitle("time [orbit#]");
0280       (*m_hvtxyvsorbrun)->GetYaxis()->SetTitle("Y [cm]");
0281       (*m_hvtxyvsorbrun)->SetCanExtend(TH1::kAllAxes);
0282       (*m_hvtxzvsorbrun)->GetXaxis()->SetTitle("time [orbit#]");
0283       (*m_hvtxzvsorbrun)->GetYaxis()->SetTitle("Z [cm]");
0284       (*m_hvtxzvsorbrun)->SetCanExtend(TH1::kAllAxes);
0285       (*m_hnvtxvsorbrun)->GetXaxis()->SetTitle("time [orbit#]");
0286       (*m_hnvtxvsorbrun)->GetYaxis()->SetTitle("Nvertices");
0287       (*m_hnvtxvsorbrun)->SetCanExtend(TH1::kAllAxes);
0288     }
0289 
0290     if (m_runHistoBXProfile) {
0291       (*m_hvtxxvsbxrun)->GetXaxis()->SetTitle("BX");
0292       (*m_hvtxxvsbxrun)->GetYaxis()->SetTitle("X [cm]");
0293       (*m_hvtxyvsbxrun)->GetXaxis()->SetTitle("BX");
0294       (*m_hvtxyvsbxrun)->GetYaxis()->SetTitle("Y [cm]");
0295       (*m_hvtxzvsbxrun)->GetXaxis()->SetTitle("BX");
0296       (*m_hvtxzvsbxrun)->GetYaxis()->SetTitle("Z [cm]");
0297       (*m_hnvtxvsbxrun)->GetXaxis()->SetTitle("BX");
0298       (*m_hnvtxvsbxrun)->GetYaxis()->SetTitle("Nvertices");
0299       if (m_runHistoBXProfile2D) {
0300         (*m_hnvtxvsbxvslumirun)->GetXaxis()->SetTitle("BX");
0301         (*m_hnvtxvsbxvslumirun)->GetYaxis()->SetTitle("BX lumi [10^{30}cm^{-2}s^{-1}]");
0302       }
0303       if (m_runHisto2D) {
0304         (*m_hvtxxvsbx2drun)->GetXaxis()->SetTitle("BX");
0305         (*m_hvtxxvsbx2drun)->GetYaxis()->SetTitle("X [cm]");
0306         (*m_hvtxyvsbx2drun)->GetXaxis()->SetTitle("BX");
0307         (*m_hvtxyvsbx2drun)->GetYaxis()->SetTitle("Y [cm]");
0308         (*m_hvtxzvsbx2drun)->GetXaxis()->SetTitle("BX");
0309         (*m_hvtxzvsbx2drun)->GetYaxis()->SetTitle("Z [cm]");
0310       }
0311     }
0312 
0313     if (m_runHisto2D) {
0314       (*m_hnvtxvsbxvsorbrun)->GetXaxis()->SetTitle("BX#");
0315       (*m_hnvtxvsbxvsorbrun)->GetYaxis()->SetTitle("time [orbit#]");
0316       (*m_hnvtxvsbxvsorbrun)->SetCanExtend(TH1::kAllAxes);
0317       (*m_hnvtxvsorbrun2D)->GetXaxis()->SetTitle("time [orbit#]");
0318       (*m_hnvtxvsorbrun2D)->GetYaxis()->SetTitle("Nvertices");
0319       (*m_hnvtxvsorbrun2D)->SetCanExtend(TH1::kAllAxes);
0320     }
0321   }
0322 }
0323 
0324 void VertexHistogramMaker::fill(const unsigned int orbit,
0325                                 const int bx,
0326                                 const float bxlumi,
0327                                 const reco::VertexCollection& vertices,
0328                                 const double weight) {
0329   m_hnvtx->Fill(vertices.size(), weight);
0330 
0331   int ntruevtx = 0;
0332   for (reco::VertexCollection::const_iterator vtx = vertices.begin(); vtx != vertices.end(); ++vtx) {
0333     if (!vtx->isFake())
0334       ntruevtx++;
0335 
0336     if (!(m_trueOnly && vtx->isFake())) {
0337       double aveweight =
0338           m_bsConstrained ? vtx->ndof() / (2. * vtx->tracksSize()) : (vtx->ndof() + 3) / (2. * vtx->tracksSize());
0339 
0340       m_hntracks->Fill(vtx->tracksSize(), weight);
0341       m_hndof->Fill(vtx->ndof(), weight);
0342       m_haveweight->Fill(aveweight, weight);
0343       m_hndofvstracks->Fill(vtx->tracksSize(), vtx->ndof(), weight);
0344       m_hndofvsvtxz->Fill(vtx->z(), vtx->ndof(), weight);
0345       m_hntracksvsvtxz->Fill(vtx->z(), vtx->tracksSize(), weight);
0346       m_haveweightvsvtxz->Fill(vtx->z(), aveweight, weight);
0347 
0348       m_hvtxx->Fill(vtx->x(), weight);
0349       m_hvtxy->Fill(vtx->y(), weight);
0350       m_hvtxz->Fill(vtx->z(), weight);
0351 
0352       if (m_runHisto) {
0353         if (m_hvtxxrun && *m_hvtxxrun)
0354           (*m_hvtxxrun)->Fill(vtx->x(), weight);
0355         if (m_hvtxyrun && *m_hvtxyrun)
0356           (*m_hvtxyrun)->Fill(vtx->y(), weight);
0357         if (m_hvtxzrun && *m_hvtxzrun)
0358           (*m_hvtxzrun)->Fill(vtx->z(), weight);
0359         if (m_runHistoProfile) {
0360           if (m_hvtxxvsorbrun && *m_hvtxxvsorbrun)
0361             (*m_hvtxxvsorbrun)->Fill(orbit, vtx->x(), weight);
0362           if (m_hvtxyvsorbrun && *m_hvtxyvsorbrun)
0363             (*m_hvtxyvsorbrun)->Fill(orbit, vtx->y(), weight);
0364           if (m_hvtxzvsorbrun && *m_hvtxzvsorbrun)
0365             (*m_hvtxzvsorbrun)->Fill(orbit, vtx->z(), weight);
0366         }
0367         if (m_runHistoBXProfile) {
0368           if (m_hvtxxvsbxrun && *m_hvtxxvsbxrun)
0369             (*m_hvtxxvsbxrun)->Fill(bx % 3564, vtx->x(), weight);
0370           if (m_hvtxyvsbxrun && *m_hvtxyvsbxrun)
0371             (*m_hvtxyvsbxrun)->Fill(bx % 3564, vtx->y(), weight);
0372           if (m_hvtxzvsbxrun && *m_hvtxzvsbxrun)
0373             (*m_hvtxzvsbxrun)->Fill(bx % 3564, vtx->z(), weight);
0374           if (m_runHisto2D) {
0375             if (m_hvtxxvsbx2drun && *m_hvtxxvsbx2drun)
0376               (*m_hvtxxvsbx2drun)->Fill(bx % 3564, vtx->x(), weight);
0377             if (m_hvtxyvsbx2drun && *m_hvtxyvsbx2drun)
0378               (*m_hvtxyvsbx2drun)->Fill(bx % 3564, vtx->y(), weight);
0379             if (m_hvtxzvsbx2drun && *m_hvtxzvsbx2drun)
0380               (*m_hvtxzvsbx2drun)->Fill(bx % 3564, vtx->z(), weight);
0381           }
0382         }
0383       }
0384 
0385       int nheavytracks = 0;
0386       double sumpt2 = 0.;
0387       double sumpt2heavy = 0.;
0388 
0389       for (reco::Vertex::trackRef_iterator trk = vtx->tracks_begin(); trk != vtx->tracks_end(); ++trk) {
0390         sumpt2 += (*trk)->pt() * (*trk)->pt();
0391 
0392         if (vtx->trackWeight(*trk) > m_weightThreshold) {
0393           nheavytracks++;
0394           sumpt2heavy += (*trk)->pt() * (*trk)->pt();
0395         }
0396 
0397         m_hweights->Fill(vtx->trackWeight(*trk), weight);
0398         m_haveweightvsvtxzchk->Fill(vtx->z(), vtx->trackWeight(*trk), weight);
0399       }
0400 
0401       m_hnheavytracks->Fill(nheavytracks, weight);
0402       m_hsqsumptsq->Fill(sqrt(sumpt2), weight);
0403       m_hsqsumptsqheavy->Fill(sqrt(sumpt2heavy), weight);
0404     }
0405   }
0406 
0407   m_hntruevtx->Fill(ntruevtx, weight);
0408 
0409   if (bxlumi >= 0.) {
0410     m_hntruevtxvslumi->Fill(bxlumi, ntruevtx, weight);
0411     m_hntruevtxvslumi2D->Fill(bxlumi, ntruevtx, weight);
0412   }
0413 
0414   if (m_runHisto) {
0415     if (m_runHistoProfile) {
0416       if (m_hnvtxvsorbrun && *m_hnvtxvsorbrun)
0417         (*m_hnvtxvsorbrun)->Fill(orbit, ntruevtx, weight);
0418     }
0419     if (m_runHistoBXProfile) {
0420       if (m_hnvtxvsbxrun && *m_hnvtxvsbxrun)
0421         (*m_hnvtxvsbxrun)->Fill(bx % 3564, ntruevtx, weight);
0422       if (m_runHistoBXProfile2D) {
0423         if (m_hnvtxvsbxvslumirun && *m_hnvtxvsbxvslumirun && bxlumi >= 0.)
0424           (*m_hnvtxvsbxvslumirun)->Fill(bx % 3564, bxlumi, ntruevtx, weight);
0425       }
0426     }
0427     if (m_runHisto2D) {
0428       if (m_hnvtxvsbxvsorbrun && *m_hnvtxvsbxvsorbrun)
0429         (*m_hnvtxvsbxvsorbrun)->Fill(bx % 3564, orbit, ntruevtx, weight);
0430       if (m_hnvtxvsorbrun2D && *m_hnvtxvsorbrun2D) {
0431         if (ntruevtx < (*m_hnvtxvsorbrun2D)->GetYaxis()->GetXmax() &&
0432             ntruevtx > (*m_hnvtxvsorbrun2D)->GetYaxis()->GetXmin()) {
0433           (*m_hnvtxvsorbrun2D)->Fill(orbit, ntruevtx, weight);
0434         }
0435       }
0436     }
0437   }
0438 }
0439 
0440 void VertexHistogramMaker::fill(const edm::Event& iEvent, const reco::VertexCollection& vertices, const double weight) {
0441   // get luminosity
0442 
0443   edm::Handle<LumiDetails> ld;
0444   iEvent.getLuminosityBlock().getByToken(m_lumiDetailsToken, ld);
0445 
0446   float bxlumi = -1.;
0447 
0448   if (ld.isValid()) {
0449     if (ld->isValid()) {
0450       bxlumi = ld->lumiValue(LumiDetails::kOCC1, iEvent.bunchCrossing()) * 6.37;
0451     }
0452   }
0453 
0454   fill(iEvent.orbitNumber(), iEvent.bunchCrossing(), bxlumi, vertices, weight);
0455 }