CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
DigiPileupCorrHistogramMaker Class Reference

#include <DigiPileupCorrHistogramMaker.h>

Public Member Functions

void beginRun (const unsigned int nrun)
 
void book (const std::string dirname, const std::map< unsigned int, std::string > &labels)
 
void book (const std::string dirname)
 
 DigiPileupCorrHistogramMaker (edm::ConsumesCollector &&iC)
 
 DigiPileupCorrHistogramMaker (const edm::ParameterSet &iConfig, edm::ConsumesCollector &&iC)
 
void fill (const edm::Event &iEvent, const std::map< unsigned int, int > &ndigi)
 
 ~DigiPileupCorrHistogramMaker ()
 

Private Attributes

const bool m_2dhisto
 
std::map< unsigned int, int > m_binmax
 
std::string m_hitname
 
std::map< unsigned int, std::string > m_labels
 
const int m_nbins
 
std::map< unsigned int, TH2F * > m_nmultvsmclumi
 
std::map< unsigned int, TProfile * > m_nmultvsmclumiprof
 
std::map< unsigned int, TH2F * > m_nmultvsmcnvtx
 
std::map< unsigned int, TProfile * > m_nmultvsmcnvtxprof
 
std::map< unsigned int, TProfile2D * > m_nmultvsmcnvtxprof2d
 
const int m_ootBX
 
edm::EDGetTokenT< std::vector< PileupSummaryInfo > > m_pileupcollectionToken
 
const int m_scalefact
 
std::map< unsigned int, TFileDirectory * > m_subdirs
 
bool m_useVisibleVertices
 

Detailed Description

Definition at line 19 of file DigiPileupCorrHistogramMaker.h.

Constructor & Destructor Documentation

DigiPileupCorrHistogramMaker::DigiPileupCorrHistogramMaker ( edm::ConsumesCollector &&  iC)

Definition at line 15 of file DigiPileupCorrHistogramMaker.cc.

16  : m_pileupcollectionToken(iC.consumes<std::vector<PileupSummaryInfo> >(edm::InputTag("addPileupInfo"))),
17  m_useVisibleVertices(false),
18  m_hitname(),
19  m_nbins(500),
20  m_scalefact(),
21  m_binmax(),
22  m_labels(),
28  m_subdirs(),
29  m_2dhisto(),
30  m_ootBX(-1) {}
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
std::map< unsigned int, std::string > m_labels
std::map< unsigned int, TProfile * > m_nmultvsmcnvtxprof
std::map< unsigned int, TFileDirectory * > m_subdirs
std::map< unsigned int, TH2F * > m_nmultvsmclumi
std::map< unsigned int, int > m_binmax
edm::EDGetTokenT< std::vector< PileupSummaryInfo > > m_pileupcollectionToken
std::map< unsigned int, TProfile2D * > m_nmultvsmcnvtxprof2d
std::map< unsigned int, TH2F * > m_nmultvsmcnvtx
std::map< unsigned int, TProfile * > m_nmultvsmclumiprof
DigiPileupCorrHistogramMaker::DigiPileupCorrHistogramMaker ( const edm::ParameterSet iConfig,
edm::ConsumesCollector &&  iC 
)

Definition at line 32 of file DigiPileupCorrHistogramMaker.cc.

References edm::ParameterSet::getUntrackedParameter(), m_binmax, m_labels, and AlCaHLTBitMon_QueryRunRegistry::string.

35  iC.consumes<std::vector<PileupSummaryInfo> >(iConfig.getParameter<edm::InputTag>("pileupSummaryCollection"))),
36  m_useVisibleVertices(iConfig.getParameter<bool>("useVisibleVertices")),
37  m_hitname(iConfig.getUntrackedParameter<std::string>("hitName", "digi")),
38  m_nbins(iConfig.getUntrackedParameter<int>("numberOfBins", 500)),
39  m_scalefact(iConfig.getUntrackedParameter<int>("scaleFactor", 5)),
40  m_labels(),
46  m_subdirs(),
47  m_2dhisto(iConfig.getUntrackedParameter<bool>("wanted2DHisto", false)),
48  m_ootBX(iConfig.getUntrackedParameter<int>("ootBX", -1)) {
49  std::vector<edm::ParameterSet> wantedsubds(iConfig.getUntrackedParameter<std::vector<edm::ParameterSet> >(
50  "wantedSubDets", std::vector<edm::ParameterSet>()));
51 
52  for (std::vector<edm::ParameterSet>::iterator ps = wantedsubds.begin(); ps != wantedsubds.end(); ++ps) {
53  m_labels[ps->getParameter<unsigned int>("detSelection")] = ps->getParameter<std::string>("detLabel");
54  m_binmax[ps->getParameter<unsigned int>("detSelection")] = ps->getParameter<int>("binMax");
55  }
56 }
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
T getParameter(std::string const &) const
std::map< unsigned int, std::string > m_labels
T getUntrackedParameter(std::string const &, T const &) const
std::map< unsigned int, TProfile * > m_nmultvsmcnvtxprof
std::map< unsigned int, TFileDirectory * > m_subdirs
std::map< unsigned int, TH2F * > m_nmultvsmclumi
std::map< unsigned int, int > m_binmax
edm::EDGetTokenT< std::vector< PileupSummaryInfo > > m_pileupcollectionToken
std::map< unsigned int, TProfile2D * > m_nmultvsmcnvtxprof2d
std::map< unsigned int, TH2F * > m_nmultvsmcnvtx
std::map< unsigned int, TProfile * > m_nmultvsmclumiprof
DigiPileupCorrHistogramMaker::~DigiPileupCorrHistogramMaker ( )

Definition at line 58 of file DigiPileupCorrHistogramMaker.cc.

References mps_fire::i, m_labels, m_subdirs, and AlCaHLTBitMon_QueryRunRegistry::string.

58  {
59  for (std::map<unsigned int, std::string>::const_iterator lab = m_labels.begin(); lab != m_labels.end(); lab++) {
60  const unsigned int i = lab->first;
61  const std::string slab = lab->second;
62 
63  delete m_subdirs[i];
64  }
65 }
std::map< unsigned int, std::string > m_labels
std::map< unsigned int, TFileDirectory * > m_subdirs

Member Function Documentation

void DigiPileupCorrHistogramMaker::beginRun ( const unsigned int  nrun)

Definition at line 137 of file DigiPileupCorrHistogramMaker.cc.

137 {}
void DigiPileupCorrHistogramMaker::book ( const std::string  dirname,
const std::map< unsigned int, std::string > &  labels 
)

Definition at line 67 of file DigiPileupCorrHistogramMaker.cc.

References SummaryClient_cfi::labels, and m_labels.

Referenced by MultiplicityInvestigator::MultiplicityInvestigator().

67  {
68  m_labels = labels;
69  book(dirname);
70 }
std::map< unsigned int, std::string > m_labels
void book(const std::string dirname, const std::map< unsigned int, std::string > &labels)
void DigiPileupCorrHistogramMaker::book ( const std::string  dirname)

Definition at line 72 of file DigiPileupCorrHistogramMaker.cc.

References mps_fire::i, m_2dhisto, m_binmax, m_hitname, m_labels, m_nbins, m_nmultvsmclumi, m_nmultvsmclumiprof, m_nmultvsmcnvtx, m_nmultvsmcnvtxprof, m_nmultvsmcnvtxprof2d, m_scalefact, m_subdirs, TFileDirectory::mkdir(), TFileService::mkdir(), Skims_PA_cff::name, SiStripTKNumbers::nstrips(), AlCaHLTBitMon_QueryRunRegistry::string, and overlapproblemtsosanalyzer_cfi::title.

72  {
74  TFileDirectory subev = tfserv->mkdir(dirname);
75 
76  SiStripTKNumbers trnumb;
77 
78  edm::LogInfo("NumberOfBins") << "Number of Bins: " << m_nbins;
79  edm::LogInfo("ScaleFactors") << "y-axis range scale factor: " << m_scalefact;
80  edm::LogInfo("BinMaxValue") << "Setting bin max values";
81 
82  for (std::map<unsigned int, std::string>::const_iterator lab = m_labels.begin(); lab != m_labels.end(); lab++) {
83  const unsigned int i = lab->first;
84  const std::string slab = lab->second;
85 
86  if (m_binmax.find(i) == m_binmax.end()) {
87  edm::LogVerbatim("NotConfiguredBinMax")
88  << "Bin max for " << lab->second << " not configured: " << trnumb.nstrips(i) << " used";
89  m_binmax[i] = trnumb.nstrips(i);
90  }
91 
92  edm::LogVerbatim("BinMaxValue") << "Bin max for " << lab->second << " is " << m_binmax[i];
93  }
94 
95  for (std::map<unsigned int, std::string>::const_iterator lab = m_labels.begin(); lab != m_labels.end(); ++lab) {
96  const int i = lab->first;
97  const std::string slab = lab->second;
98 
99  char name[200];
100  char title[500];
101 
102  m_subdirs[i] = new TFileDirectory(subev.mkdir(slab));
103 
104  if (m_subdirs[i]) {
105  sprintf(name, "n%sdigivsmclumi", slab.c_str());
106  sprintf(title, "%s %s multiplicity ave pileup interactions", slab.c_str(), m_hitname.c_str());
107  m_nmultvsmclumi[i] = m_subdirs[i]->make<TH2F>(
108  name, title, 200, 0., 50., m_nbins, 0., m_binmax[i] / (m_scalefact * m_nbins) * m_nbins);
109  m_nmultvsmclumi[i]->GetXaxis()->SetTitle("Average Pileup Interactions");
110  m_nmultvsmclumi[i]->GetYaxis()->SetTitle("Number of Hits");
111  sprintf(name, "n%sdigivsmclumiprof", slab.c_str());
112  m_nmultvsmclumiprof[i] = m_subdirs[i]->make<TProfile>(name, title, 200, 0., 50.);
113  m_nmultvsmclumiprof[i]->GetXaxis()->SetTitle("Average Pileup Interactions");
114  m_nmultvsmclumiprof[i]->GetYaxis()->SetTitle("Number of Hits");
115 
116  sprintf(name, "n%sdigivsmcnvtx", slab.c_str());
117  sprintf(title, "%s %s multiplicity vs pileup interactions", slab.c_str(), m_hitname.c_str());
118  m_nmultvsmcnvtx[i] = m_subdirs[i]->make<TH2F>(
119  name, title, 60, -0.5, 59.5, m_nbins, 0., m_binmax[i] / (m_scalefact * m_nbins) * m_nbins);
120  m_nmultvsmcnvtx[i]->GetXaxis()->SetTitle("Pileup Interactions");
121  m_nmultvsmcnvtx[i]->GetYaxis()->SetTitle("Number of Hits");
122  sprintf(name, "n%sdigivsmcnvtxprof", slab.c_str());
123  m_nmultvsmcnvtxprof[i] = m_subdirs[i]->make<TProfile>(name, title, 60, -0.5, 59.5);
124  m_nmultvsmcnvtxprof[i]->GetXaxis()->SetTitle("Pileup Interactions");
125  m_nmultvsmcnvtxprof[i]->GetYaxis()->SetTitle("Number of Hits");
126  if (m_2dhisto) {
127  sprintf(name, "n%sdigivsmcnvtxprof2d", slab.c_str());
128  m_nmultvsmcnvtxprof2d[i] = m_subdirs[i]->make<TProfile2D>(name, title, 60, -0.5, 59.5, 60, -0.5, 59.5);
129  m_nmultvsmcnvtxprof2d[i]->GetXaxis()->SetTitle("Pileup Interactions");
130  m_nmultvsmcnvtxprof2d[i]->GetYaxis()->SetTitle("Pileup Interactions OOT");
131  m_nmultvsmcnvtxprof2d[i]->GetZaxis()->SetTitle("Number of Hits");
132  }
133  }
134  }
135 }
std::map< unsigned int, std::string > m_labels
std::map< unsigned int, TProfile * > m_nmultvsmcnvtxprof
int nstrips(const DetId &detid) const
std::map< unsigned int, TFileDirectory * > m_subdirs
std::map< unsigned int, TH2F * > m_nmultvsmclumi
std::map< unsigned int, int > m_binmax
TFileDirectory mkdir(const std::string &dir, const std::string &descr="")
create a new subdirectory
Definition: TFileService.h:69
TFileDirectory mkdir(const std::string &dir, const std::string &descr="")
create a new subdirectory
std::map< unsigned int, TProfile2D * > m_nmultvsmcnvtxprof2d
std::map< unsigned int, TH2F * > m_nmultvsmcnvtx
std::map< unsigned int, TProfile * > m_nmultvsmclumiprof
void DigiPileupCorrHistogramMaker::fill ( const edm::Event iEvent,
const std::map< unsigned int, int > &  ndigi 
)

Definition at line 139 of file DigiPileupCorrHistogramMaker.cc.

References edm::Event::getByToken(), mps_fire::i, m_2dhisto, m_labels, m_nmultvsmclumi, m_nmultvsmclumiprof, m_nmultvsmcnvtx, m_nmultvsmcnvtxprof, m_nmultvsmcnvtxprof2d, m_ootBX, m_pileupcollectionToken, and m_useVisibleVertices.

Referenced by MultiplicityInvestigator::analyze().

139  {
141  iEvent.getByToken(m_pileupcollectionToken, pileupinfos);
142 
143  // look for the intime PileupSummaryInfo
144 
145  std::vector<PileupSummaryInfo>::const_iterator pileupinfoInTime = pileupinfos->end();
146  std::vector<PileupSummaryInfo>::const_iterator pileupinfoMinusOne = pileupinfos->end();
147 
148  for (std::vector<PileupSummaryInfo>::const_iterator pileupinfo = pileupinfos->begin();
149  pileupinfo != pileupinfos->end();
150  ++pileupinfo) {
151  if (pileupinfo->getBunchCrossing() == 0)
152  pileupinfoInTime = pileupinfo;
153  if (pileupinfo->getBunchCrossing() == m_ootBX)
154  pileupinfoMinusOne = pileupinfo;
155  }
156 
157  if (pileupinfoInTime == pileupinfos->end()) {
158  edm::LogError("NoInTimePileUpInfo") << "Cannot find the in-time pileup info ";
159 
160  } else {
161  int npileup = pileupinfoInTime->getPU_NumInteractions();
162 
164  npileup = pileupinfoInTime->getPU_zpositions().size();
165 
166  for (std::map<unsigned int, int>::const_iterator digi = ndigi.begin(); digi != ndigi.end(); digi++) {
167  if (m_labels.find(digi->first) != m_labels.end()) {
168  const unsigned int i = digi->first;
169  m_nmultvsmcnvtx[i]->Fill(npileup, digi->second);
170  m_nmultvsmcnvtxprof[i]->Fill(npileup, digi->second);
171  m_nmultvsmclumi[i]->Fill(pileupinfoInTime->getTrueNumInteractions(), digi->second);
172  m_nmultvsmclumiprof[i]->Fill(pileupinfoInTime->getTrueNumInteractions(), digi->second);
173  if (m_2dhisto) {
174  if (pileupinfoMinusOne != pileupinfos->end()) {
175  int npileupminusone = pileupinfoMinusOne->getPU_NumInteractions();
177  npileupminusone = pileupinfoMinusOne->getPU_zpositions().size();
178  m_nmultvsmcnvtxprof2d[i]->Fill(npileup, npileupminusone, digi->second);
179  }
180  }
181  }
182  }
183  }
184 }
std::map< unsigned int, std::string > m_labels
std::map< unsigned int, TProfile * > m_nmultvsmcnvtxprof
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:525
std::map< unsigned int, TH2F * > m_nmultvsmclumi
edm::EDGetTokenT< std::vector< PileupSummaryInfo > > m_pileupcollectionToken
std::map< unsigned int, TProfile2D * > m_nmultvsmcnvtxprof2d
std::map< unsigned int, TH2F * > m_nmultvsmcnvtx
std::map< unsigned int, TProfile * > m_nmultvsmclumiprof

Member Data Documentation

const bool DigiPileupCorrHistogramMaker::m_2dhisto
private

Definition at line 47 of file DigiPileupCorrHistogramMaker.h.

Referenced by book(), and fill().

std::map<unsigned int, int> DigiPileupCorrHistogramMaker::m_binmax
private

Definition at line 37 of file DigiPileupCorrHistogramMaker.h.

Referenced by book(), and DigiPileupCorrHistogramMaker().

std::string DigiPileupCorrHistogramMaker::m_hitname
private

Definition at line 34 of file DigiPileupCorrHistogramMaker.h.

Referenced by book().

std::map<unsigned int, std::string> DigiPileupCorrHistogramMaker::m_labels
private
const int DigiPileupCorrHistogramMaker::m_nbins
private

Definition at line 35 of file DigiPileupCorrHistogramMaker.h.

Referenced by book().

std::map<unsigned int, TH2F*> DigiPileupCorrHistogramMaker::m_nmultvsmclumi
private

Definition at line 40 of file DigiPileupCorrHistogramMaker.h.

Referenced by book(), and fill().

std::map<unsigned int, TProfile*> DigiPileupCorrHistogramMaker::m_nmultvsmclumiprof
private

Definition at line 41 of file DigiPileupCorrHistogramMaker.h.

Referenced by book(), and fill().

std::map<unsigned int, TH2F*> DigiPileupCorrHistogramMaker::m_nmultvsmcnvtx
private

Definition at line 42 of file DigiPileupCorrHistogramMaker.h.

Referenced by book(), and fill().

std::map<unsigned int, TProfile*> DigiPileupCorrHistogramMaker::m_nmultvsmcnvtxprof
private

Definition at line 43 of file DigiPileupCorrHistogramMaker.h.

Referenced by book(), and fill().

std::map<unsigned int, TProfile2D*> DigiPileupCorrHistogramMaker::m_nmultvsmcnvtxprof2d
private

Definition at line 44 of file DigiPileupCorrHistogramMaker.h.

Referenced by book(), and fill().

const int DigiPileupCorrHistogramMaker::m_ootBX
private

Definition at line 48 of file DigiPileupCorrHistogramMaker.h.

Referenced by fill().

edm::EDGetTokenT<std::vector<PileupSummaryInfo> > DigiPileupCorrHistogramMaker::m_pileupcollectionToken
private

Definition at line 32 of file DigiPileupCorrHistogramMaker.h.

Referenced by fill().

const int DigiPileupCorrHistogramMaker::m_scalefact
private

Definition at line 36 of file DigiPileupCorrHistogramMaker.h.

Referenced by book().

std::map<unsigned int, TFileDirectory*> DigiPileupCorrHistogramMaker::m_subdirs
private

Definition at line 45 of file DigiPileupCorrHistogramMaker.h.

Referenced by book(), and ~DigiPileupCorrHistogramMaker().

bool DigiPileupCorrHistogramMaker::m_useVisibleVertices
private

Definition at line 33 of file DigiPileupCorrHistogramMaker.h.

Referenced by fill().