Line Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188
#include "DPGAnalysis/SiStripTools/interface/MultiplicityCorrelatorHistogramMaker.h"
#include "FWCore/Framework/interface/Event.h"
#include "FWCore/Framework/interface/Run.h"
#include "FWCore/MessageLogger/interface/MessageLogger.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "FWCore/ServiceRegistry/interface/Service.h"
#include "CommonTools/UtilAlgos/interface/TFileService.h"
#include "TH2F.h"
#include "TH1F.h"
#include <cmath>

MultiplicityCorrelatorHistogramMaker::MultiplicityCorrelatorHistogramMaker(edm::ConsumesCollector&& iC)
    : m_rhm(iC, false),
      m_fhm(iC, true),
      m_runHisto(false),
      m_runHistoBXProfile(false),
      m_runHistoBX(false),
      m_runHisto2D(false),
      m_runHistoProfileBX(false),
      m_scfact(1.),
      m_yvsxmult(nullptr),
      m_atanyoverx(nullptr),
      m_atanyoverxrun(nullptr),
      m_atanyoverxvsbxrun(nullptr),
      m_atanyoverxvsbxrun2D(nullptr),
      m_yvsxmultrun(nullptr),
      m_yvsxmultprofvsbxrun(nullptr),
      m_xvsymultprofvsbxrun(nullptr) {}

MultiplicityCorrelatorHistogramMaker::MultiplicityCorrelatorHistogramMaker(const edm::ParameterSet& iConfig,
                                                                           edm::ConsumesCollector&& iC)
    : m_rhm(iC, false),
      m_fhm(iC, true),
      m_runHisto(iConfig.getParameter<bool>("runHisto")),
      m_runHistoBXProfile(iConfig.getParameter<bool>("runHistoBXProfile")),
      m_runHistoBX(iConfig.getParameter<bool>("runHistoBX")),
      m_runHisto2D(iConfig.getParameter<bool>("runHisto2D")),
      m_runHistoProfileBX(iConfig.getUntrackedParameter<bool>("runHistoProfileBX", false)),
      m_scfact(iConfig.getUntrackedParameter<double>("scaleFactor", 1.)),
      m_atanyoverxrun(nullptr),
      m_atanyoverxvsbxrun(nullptr),
      m_atanyoverxvsbxrun2D(nullptr),
      m_yvsxmultrun(nullptr),
      m_yvsxmultprofvsbxrun(nullptr),
      m_xvsymultprofvsbxrun(nullptr) {
  edm::Service<TFileService> tfserv;

  char hname[300];
  sprintf(hname,
          "%sVs%s",
          iConfig.getParameter<std::string>("yDetLabel").c_str(),
          iConfig.getParameter<std::string>("xDetLabel").c_str());
  char htitle[300];
  sprintf(htitle,
          "%s Vs %s multiplicity",
          iConfig.getParameter<std::string>("yDetLabel").c_str(),
          iConfig.getParameter<std::string>("xDetLabel").c_str());

  m_yvsxmult = tfserv->make<TH2F>(hname,
                                  htitle,
                                  iConfig.getParameter<unsigned int>("xBins"),
                                  0.,
                                  iConfig.getParameter<double>("xMax"),
                                  iConfig.getParameter<unsigned int>("yBins"),
                                  0.,
                                  iConfig.getParameter<double>("yMax"));

  if (m_runHisto && m_runHisto2D) {
    m_yvsxmultrun = m_rhm.makeTH2F(hname,
                                   htitle,
                                   iConfig.getParameter<unsigned int>("xBins"),
                                   0.,
                                   iConfig.getParameter<double>("xMax"),
                                   iConfig.getParameter<unsigned int>("yBins"),
                                   0.,
                                   iConfig.getParameter<double>("yMax"));
  }

  if (m_runHisto && m_runHistoProfileBX) {
    sprintf(hname,
            "%sVs%sprofvsbx",
            iConfig.getParameter<std::string>("yDetLabel").c_str(),
            iConfig.getParameter<std::string>("xDetLabel").c_str());
    sprintf(htitle,
            "%s Vs %s multiplicity vs BX",
            iConfig.getParameter<std::string>("yDetLabel").c_str(),
            iConfig.getParameter<std::string>("xDetLabel").c_str());
    m_yvsxmultprofvsbxrun = m_fhm.makeTProfile2D(hname,
                                                 htitle,
                                                 3564,
                                                 -0.5,
                                                 3564 - 0.5,
                                                 iConfig.getParameter<unsigned int>("xBins"),
                                                 0.,
                                                 iConfig.getParameter<double>("xMax"));
    sprintf(hname,
            "%sVs%sprofvsbx",
            iConfig.getParameter<std::string>("xDetLabel").c_str(),
            iConfig.getParameter<std::string>("yDetLabel").c_str());
    sprintf(htitle,
            "%s Vs %s multiplicity vs BX",
            iConfig.getParameter<std::string>("xDetLabel").c_str(),
            iConfig.getParameter<std::string>("yDetLabel").c_str());
    m_xvsymultprofvsbxrun = m_fhm.makeTProfile2D(hname,
                                                 htitle,
                                                 3564,
                                                 -0.5,
                                                 3564 - 0.5,
                                                 iConfig.getParameter<unsigned int>("yBins"),
                                                 0.,
                                                 iConfig.getParameter<double>("yMax"));
  }

  sprintf(hname,
          "%sOver%s",
          iConfig.getParameter<std::string>("yDetLabel").c_str(),
          iConfig.getParameter<std::string>("xDetLabel").c_str());
  sprintf(htitle,
          "atan (%4.2f*%s / %s multiplicity ratio)",
          m_scfact,
          iConfig.getParameter<std::string>("yDetLabel").c_str(),
          iConfig.getParameter<std::string>("xDetLabel").c_str());

  m_atanyoverx = tfserv->make<TH1F>(hname, htitle, iConfig.getParameter<unsigned int>("rBins"), 0., 1.6);

  if (m_runHisto) {
    sprintf(hname,
            "%sOver%srun",
            iConfig.getParameter<std::string>("yDetLabel").c_str(),
            iConfig.getParameter<std::string>("xDetLabel").c_str());
    m_atanyoverxrun = m_rhm.makeTH1F(hname, htitle, iConfig.getParameter<unsigned int>("rBins"), 0., 1.6);
    if (m_runHistoBX) {
      sprintf(hname,
              "%sOver%svsbx2D",
              iConfig.getParameter<std::string>("yDetLabel").c_str(),
              iConfig.getParameter<std::string>("xDetLabel").c_str());
      sprintf(htitle,
              "atan (%4.2f*%s / %s multiplicity ratio)",
              m_scfact,
              iConfig.getParameter<std::string>("yDetLabel").c_str(),
              iConfig.getParameter<std::string>("xDetLabel").c_str());
      m_atanyoverxvsbxrun2D =
          m_fhm.makeTH2F(hname, htitle, 3564, -0.5, 3564 - 0.5, iConfig.getParameter<unsigned int>("rBins"), 0., 1.6);
    }
    if (m_runHistoBXProfile) {
      sprintf(hname,
              "%sOver%svsbx",
              iConfig.getParameter<std::string>("yDetLabel").c_str(),
              iConfig.getParameter<std::string>("xDetLabel").c_str());
      sprintf(htitle,
              "atan (%4.2f*%s / %s multiplicity ratio)",
              m_scfact,
              iConfig.getParameter<std::string>("yDetLabel").c_str(),
              iConfig.getParameter<std::string>("xDetLabel").c_str());
      m_atanyoverxvsbxrun = m_fhm.makeTProfile(hname, htitle, 3564, -0.5, 3564 - 0.5);
    }
  }
}

MultiplicityCorrelatorHistogramMaker::~MultiplicityCorrelatorHistogramMaker() {}

void MultiplicityCorrelatorHistogramMaker::beginRun(const edm::Run& iRun) {
  m_rhm.beginRun(iRun);
  m_fhm.beginRun(iRun);
}

void MultiplicityCorrelatorHistogramMaker::fill(const edm::Event& iEvent, const int xmult, const int ymult) {
  const int bx = iEvent.bunchCrossing();

  if (m_yvsxmult)
    m_yvsxmult->Fill(xmult, ymult);
  if (m_atanyoverx)
    m_atanyoverx->Fill(atan2(ymult * m_scfact, xmult));

  if (m_yvsxmultrun && *m_yvsxmultrun)
    (*m_yvsxmultrun)->Fill(xmult, ymult);
  if (m_atanyoverxrun && *m_atanyoverxrun)
    (*m_atanyoverxrun)->Fill(atan2(ymult * m_scfact, xmult));
  if (m_atanyoverxvsbxrun && *m_atanyoverxvsbxrun)
    (*m_atanyoverxvsbxrun)->Fill(bx % 3564, atan2(ymult * m_scfact, xmult));
  if (m_atanyoverxvsbxrun2D && *m_atanyoverxvsbxrun2D)
    (*m_atanyoverxvsbxrun2D)->Fill(bx % 3564, atan2(ymult * m_scfact, xmult));

  if (m_yvsxmultprofvsbxrun && *m_yvsxmultprofvsbxrun)
    (*m_yvsxmultprofvsbxrun)->Fill(bx % 3564, xmult, ymult);
  if (m_xvsymultprofvsbxrun && *m_xvsymultprofvsbxrun)
    (*m_xvsymultprofvsbxrun)->Fill(bx % 3564, ymult, xmult);
}