Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:09:11

0001 #include "DPGAnalysis/SiStripTools/interface/MultiplicityCorrelatorHistogramMaker.h"
0002 #include "FWCore/Framework/interface/Event.h"
0003 #include "FWCore/Framework/interface/Run.h"
0004 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0005 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0006 #include "FWCore/ServiceRegistry/interface/Service.h"
0007 #include "CommonTools/UtilAlgos/interface/TFileService.h"
0008 #include "TH2F.h"
0009 #include "TH1F.h"
0010 #include <cmath>
0011 
0012 MultiplicityCorrelatorHistogramMaker::MultiplicityCorrelatorHistogramMaker(edm::ConsumesCollector&& iC)
0013     : m_rhm(iC, false),
0014       m_fhm(iC, true),
0015       m_runHisto(false),
0016       m_runHistoBXProfile(false),
0017       m_runHistoBX(false),
0018       m_runHisto2D(false),
0019       m_runHistoProfileBX(false),
0020       m_scfact(1.),
0021       m_yvsxmult(nullptr),
0022       m_atanyoverx(nullptr),
0023       m_atanyoverxrun(nullptr),
0024       m_atanyoverxvsbxrun(nullptr),
0025       m_atanyoverxvsbxrun2D(nullptr),
0026       m_yvsxmultrun(nullptr),
0027       m_yvsxmultprofvsbxrun(nullptr),
0028       m_xvsymultprofvsbxrun(nullptr) {}
0029 
0030 MultiplicityCorrelatorHistogramMaker::MultiplicityCorrelatorHistogramMaker(const edm::ParameterSet& iConfig,
0031                                                                            edm::ConsumesCollector&& iC)
0032     : m_rhm(iC, false),
0033       m_fhm(iC, true),
0034       m_runHisto(iConfig.getParameter<bool>("runHisto")),
0035       m_runHistoBXProfile(iConfig.getParameter<bool>("runHistoBXProfile")),
0036       m_runHistoBX(iConfig.getParameter<bool>("runHistoBX")),
0037       m_runHisto2D(iConfig.getParameter<bool>("runHisto2D")),
0038       m_runHistoProfileBX(iConfig.getUntrackedParameter<bool>("runHistoProfileBX", false)),
0039       m_scfact(iConfig.getUntrackedParameter<double>("scaleFactor", 1.)),
0040       m_atanyoverxrun(nullptr),
0041       m_atanyoverxvsbxrun(nullptr),
0042       m_atanyoverxvsbxrun2D(nullptr),
0043       m_yvsxmultrun(nullptr),
0044       m_yvsxmultprofvsbxrun(nullptr),
0045       m_xvsymultprofvsbxrun(nullptr) {
0046   edm::Service<TFileService> tfserv;
0047 
0048   char hname[300];
0049   sprintf(hname,
0050           "%sVs%s",
0051           iConfig.getParameter<std::string>("yDetLabel").c_str(),
0052           iConfig.getParameter<std::string>("xDetLabel").c_str());
0053   char htitle[300];
0054   sprintf(htitle,
0055           "%s Vs %s multiplicity",
0056           iConfig.getParameter<std::string>("yDetLabel").c_str(),
0057           iConfig.getParameter<std::string>("xDetLabel").c_str());
0058 
0059   m_yvsxmult = tfserv->make<TH2F>(hname,
0060                                   htitle,
0061                                   iConfig.getParameter<unsigned int>("xBins"),
0062                                   0.,
0063                                   iConfig.getParameter<double>("xMax"),
0064                                   iConfig.getParameter<unsigned int>("yBins"),
0065                                   0.,
0066                                   iConfig.getParameter<double>("yMax"));
0067 
0068   if (m_runHisto && m_runHisto2D) {
0069     m_yvsxmultrun = m_rhm.makeTH2F(hname,
0070                                    htitle,
0071                                    iConfig.getParameter<unsigned int>("xBins"),
0072                                    0.,
0073                                    iConfig.getParameter<double>("xMax"),
0074                                    iConfig.getParameter<unsigned int>("yBins"),
0075                                    0.,
0076                                    iConfig.getParameter<double>("yMax"));
0077   }
0078 
0079   if (m_runHisto && m_runHistoProfileBX) {
0080     sprintf(hname,
0081             "%sVs%sprofvsbx",
0082             iConfig.getParameter<std::string>("yDetLabel").c_str(),
0083             iConfig.getParameter<std::string>("xDetLabel").c_str());
0084     sprintf(htitle,
0085             "%s Vs %s multiplicity vs BX",
0086             iConfig.getParameter<std::string>("yDetLabel").c_str(),
0087             iConfig.getParameter<std::string>("xDetLabel").c_str());
0088     m_yvsxmultprofvsbxrun = m_fhm.makeTProfile2D(hname,
0089                                                  htitle,
0090                                                  3564,
0091                                                  -0.5,
0092                                                  3564 - 0.5,
0093                                                  iConfig.getParameter<unsigned int>("xBins"),
0094                                                  0.,
0095                                                  iConfig.getParameter<double>("xMax"));
0096     sprintf(hname,
0097             "%sVs%sprofvsbx",
0098             iConfig.getParameter<std::string>("xDetLabel").c_str(),
0099             iConfig.getParameter<std::string>("yDetLabel").c_str());
0100     sprintf(htitle,
0101             "%s Vs %s multiplicity vs BX",
0102             iConfig.getParameter<std::string>("xDetLabel").c_str(),
0103             iConfig.getParameter<std::string>("yDetLabel").c_str());
0104     m_xvsymultprofvsbxrun = m_fhm.makeTProfile2D(hname,
0105                                                  htitle,
0106                                                  3564,
0107                                                  -0.5,
0108                                                  3564 - 0.5,
0109                                                  iConfig.getParameter<unsigned int>("yBins"),
0110                                                  0.,
0111                                                  iConfig.getParameter<double>("yMax"));
0112   }
0113 
0114   sprintf(hname,
0115           "%sOver%s",
0116           iConfig.getParameter<std::string>("yDetLabel").c_str(),
0117           iConfig.getParameter<std::string>("xDetLabel").c_str());
0118   sprintf(htitle,
0119           "atan (%4.2f*%s / %s multiplicity ratio)",
0120           m_scfact,
0121           iConfig.getParameter<std::string>("yDetLabel").c_str(),
0122           iConfig.getParameter<std::string>("xDetLabel").c_str());
0123 
0124   m_atanyoverx = tfserv->make<TH1F>(hname, htitle, iConfig.getParameter<unsigned int>("rBins"), 0., 1.6);
0125 
0126   if (m_runHisto) {
0127     sprintf(hname,
0128             "%sOver%srun",
0129             iConfig.getParameter<std::string>("yDetLabel").c_str(),
0130             iConfig.getParameter<std::string>("xDetLabel").c_str());
0131     m_atanyoverxrun = m_rhm.makeTH1F(hname, htitle, iConfig.getParameter<unsigned int>("rBins"), 0., 1.6);
0132     if (m_runHistoBX) {
0133       sprintf(hname,
0134               "%sOver%svsbx2D",
0135               iConfig.getParameter<std::string>("yDetLabel").c_str(),
0136               iConfig.getParameter<std::string>("xDetLabel").c_str());
0137       sprintf(htitle,
0138               "atan (%4.2f*%s / %s multiplicity ratio)",
0139               m_scfact,
0140               iConfig.getParameter<std::string>("yDetLabel").c_str(),
0141               iConfig.getParameter<std::string>("xDetLabel").c_str());
0142       m_atanyoverxvsbxrun2D =
0143           m_fhm.makeTH2F(hname, htitle, 3564, -0.5, 3564 - 0.5, iConfig.getParameter<unsigned int>("rBins"), 0., 1.6);
0144     }
0145     if (m_runHistoBXProfile) {
0146       sprintf(hname,
0147               "%sOver%svsbx",
0148               iConfig.getParameter<std::string>("yDetLabel").c_str(),
0149               iConfig.getParameter<std::string>("xDetLabel").c_str());
0150       sprintf(htitle,
0151               "atan (%4.2f*%s / %s multiplicity ratio)",
0152               m_scfact,
0153               iConfig.getParameter<std::string>("yDetLabel").c_str(),
0154               iConfig.getParameter<std::string>("xDetLabel").c_str());
0155       m_atanyoverxvsbxrun = m_fhm.makeTProfile(hname, htitle, 3564, -0.5, 3564 - 0.5);
0156     }
0157   }
0158 }
0159 
0160 MultiplicityCorrelatorHistogramMaker::~MultiplicityCorrelatorHistogramMaker() {}
0161 
0162 void MultiplicityCorrelatorHistogramMaker::beginRun(const edm::Run& iRun) {
0163   m_rhm.beginRun(iRun);
0164   m_fhm.beginRun(iRun);
0165 }
0166 
0167 void MultiplicityCorrelatorHistogramMaker::fill(const edm::Event& iEvent, const int xmult, const int ymult) {
0168   const int bx = iEvent.bunchCrossing();
0169 
0170   if (m_yvsxmult)
0171     m_yvsxmult->Fill(xmult, ymult);
0172   if (m_atanyoverx)
0173     m_atanyoverx->Fill(atan2(ymult * m_scfact, xmult));
0174 
0175   if (m_yvsxmultrun && *m_yvsxmultrun)
0176     (*m_yvsxmultrun)->Fill(xmult, ymult);
0177   if (m_atanyoverxrun && *m_atanyoverxrun)
0178     (*m_atanyoverxrun)->Fill(atan2(ymult * m_scfact, xmult));
0179   if (m_atanyoverxvsbxrun && *m_atanyoverxvsbxrun)
0180     (*m_atanyoverxvsbxrun)->Fill(bx % 3564, atan2(ymult * m_scfact, xmult));
0181   if (m_atanyoverxvsbxrun2D && *m_atanyoverxvsbxrun2D)
0182     (*m_atanyoverxvsbxrun2D)->Fill(bx % 3564, atan2(ymult * m_scfact, xmult));
0183 
0184   if (m_yvsxmultprofvsbxrun && *m_yvsxmultprofvsbxrun)
0185     (*m_yvsxmultprofvsbxrun)->Fill(bx % 3564, xmult, ymult);
0186   if (m_xvsymultprofvsbxrun && *m_xvsymultprofvsbxrun)
0187     (*m_xvsymultprofvsbxrun)->Fill(bx % 3564, ymult, xmult);
0188 }