CMS 3D CMS Logo

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

#include <DigiVtxPosCorrHistogramMaker.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)
 
 DigiVtxPosCorrHistogramMaker (edm::ConsumesCollector &&iC)
 
 DigiVtxPosCorrHistogramMaker (const edm::ParameterSet &iConfig, edm::ConsumesCollector &&iC)
 
void fill (const edm::Event &iEvent, const std::map< unsigned int, int > &ndigi)
 
 ~DigiVtxPosCorrHistogramMaker ()
 

Private Attributes

std::map< unsigned int, int > m_binmax
 
std::string m_hitname
 
std::map< unsigned int, std::string > m_labels
 
edm::EDGetTokenT< edm::HepMCProductm_mcvtxcollectionToken
 
const int m_nbins
 
std::map< unsigned int, TH2F * > m_nmultvsvtxpos
 
std::map< unsigned int, TProfile * > m_nmultvsvtxposprof
 
const int m_scalefact
 
std::map< unsigned int, TFileDirectory * > m_subdirs
 

Detailed Description

Definition at line 18 of file DigiVtxPosCorrHistogramMaker.h.

Constructor & Destructor Documentation

DigiVtxPosCorrHistogramMaker::DigiVtxPosCorrHistogramMaker ( edm::ConsumesCollector &&  iC)

Definition at line 15 of file DigiVtxPosCorrHistogramMaker.cc.

17  m_hitname(),
18  m_nbins(500),
19  m_scalefact(),
20  m_binmax(),
21  m_labels(),
24  m_subdirs() {}
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
edm::EDGetTokenT< edm::HepMCProduct > m_mcvtxcollectionToken
std::map< unsigned int, int > m_binmax
std::map< unsigned int, TProfile * > m_nmultvsvtxposprof
std::map< unsigned int, TH2F * > m_nmultvsvtxpos
std::map< unsigned int, std::string > m_labels
std::map< unsigned int, TFileDirectory * > m_subdirs
DigiVtxPosCorrHistogramMaker::DigiVtxPosCorrHistogramMaker ( const edm::ParameterSet iConfig,
edm::ConsumesCollector &&  iC 
)

Definition at line 26 of file DigiVtxPosCorrHistogramMaker.cc.

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

29  m_hitname(iConfig.getUntrackedParameter<std::string>("hitName", "digi")),
30  m_nbins(iConfig.getUntrackedParameter<int>("numberOfBins", 500)),
31  m_scalefact(iConfig.getUntrackedParameter<int>("scaleFactor", 5)),
32  m_labels(),
35  m_subdirs() {
36  std::vector<edm::ParameterSet> wantedsubds(iConfig.getUntrackedParameter<std::vector<edm::ParameterSet> >(
37  "wantedSubDets", std::vector<edm::ParameterSet>()));
38 
39  for (std::vector<edm::ParameterSet>::iterator ps = wantedsubds.begin(); ps != wantedsubds.end(); ++ps) {
40  m_labels[ps->getParameter<unsigned int>("detSelection")] = ps->getParameter<std::string>("detLabel");
41  m_binmax[ps->getParameter<unsigned int>("detSelection")] = ps->getParameter<int>("binMax");
42  }
43 }
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
edm::EDGetTokenT< edm::HepMCProduct > m_mcvtxcollectionToken
std::map< unsigned int, int > m_binmax
std::map< unsigned int, TProfile * > m_nmultvsvtxposprof
std::map< unsigned int, TH2F * > m_nmultvsvtxpos
std::map< unsigned int, std::string > m_labels
std::map< unsigned int, TFileDirectory * > m_subdirs
DigiVtxPosCorrHistogramMaker::~DigiVtxPosCorrHistogramMaker ( )

Definition at line 45 of file DigiVtxPosCorrHistogramMaker.cc.

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

45  {
46  for (std::map<unsigned int, std::string>::const_iterator lab = m_labels.begin(); lab != m_labels.end(); lab++) {
47  const unsigned int i = lab->first;
48  const std::string slab = lab->second;
49 
50  delete m_subdirs[i];
51  }
52 }
std::map< unsigned int, std::string > m_labels
std::map< unsigned int, TFileDirectory * > m_subdirs

Member Function Documentation

void DigiVtxPosCorrHistogramMaker::beginRun ( const unsigned int  nrun)

Definition at line 106 of file DigiVtxPosCorrHistogramMaker.cc.

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

Definition at line 54 of file DigiVtxPosCorrHistogramMaker.cc.

References SummaryClient_cfi::labels, and m_labels.

Referenced by MultiplicityInvestigator::MultiplicityInvestigator().

54  {
55  m_labels = labels;
56  book(dirname);
57 }
void book(const std::string dirname, const std::map< unsigned int, std::string > &labels)
std::map< unsigned int, std::string > m_labels
void DigiVtxPosCorrHistogramMaker::book ( const std::string  dirname)

Definition at line 59 of file DigiVtxPosCorrHistogramMaker.cc.

References mps_fire::i, m_binmax, m_hitname, m_labels, m_nbins, m_nmultvsvtxpos, m_nmultvsvtxposprof, m_scalefact, m_subdirs, TFileDirectory::mkdir(), TFileService::mkdir(), Skims_PA_cff::name, SiStripTKNumbers::nstrips(), AlCaHLTBitMon_QueryRunRegistry::string, and overlapproblemtsosanalyzer_cfi::title.

59  {
61  TFileDirectory subev = tfserv->mkdir(dirname);
62 
63  SiStripTKNumbers trnumb;
64 
65  edm::LogInfo("NumberOfBins") << "Number of Bins: " << m_nbins;
66  edm::LogInfo("ScaleFactors") << "y-axis range scale factor: " << m_scalefact;
67  edm::LogInfo("BinMaxValue") << "Setting bin max values";
68 
69  for (std::map<unsigned int, std::string>::const_iterator lab = m_labels.begin(); lab != m_labels.end(); lab++) {
70  const unsigned int i = lab->first;
71  const std::string slab = lab->second;
72 
73  if (m_binmax.find(i) == m_binmax.end()) {
74  edm::LogVerbatim("NotConfiguredBinMax")
75  << "Bin max for " << lab->second << " not configured: " << trnumb.nstrips(i) << " used";
76  m_binmax[i] = trnumb.nstrips(i);
77  }
78 
79  edm::LogVerbatim("BinMaxValue") << "Bin max for " << lab->second << " is " << m_binmax[i];
80  }
81 
82  for (std::map<unsigned int, std::string>::const_iterator lab = m_labels.begin(); lab != m_labels.end(); ++lab) {
83  const int i = lab->first;
84  const std::string slab = lab->second;
85 
86  char name[200];
87  char title[500];
88 
89  m_subdirs[i] = new TFileDirectory(subev.mkdir(slab));
90 
91  if (m_subdirs[i]) {
92  sprintf(name, "n%sdigivsvtxpos", slab.c_str());
93  sprintf(title, "%s %s multiplicity vx MC vertex z position", slab.c_str(), m_hitname.c_str());
94  m_nmultvsvtxpos[i] = m_subdirs[i]->make<TH2F>(
95  name, title, 200, -20., 20., m_nbins, 0., m_binmax[i] / (m_scalefact * m_nbins) * m_nbins);
96  m_nmultvsvtxpos[i]->GetXaxis()->SetTitle("MC vertex z position (cm)");
97  m_nmultvsvtxpos[i]->GetYaxis()->SetTitle("Number of Hits");
98  sprintf(name, "n%sdigivsvtxposprof", slab.c_str());
99  m_nmultvsvtxposprof[i] = m_subdirs[i]->make<TProfile>(name, title, 200, -20., 20.);
100  m_nmultvsvtxposprof[i]->GetXaxis()->SetTitle("MC vertex z position (cm)");
101  m_nmultvsvtxposprof[i]->GetYaxis()->SetTitle("Number of Hits");
102  }
103  }
104 }
std::map< unsigned int, int > m_binmax
int nstrips(const DetId &detid) const
std::map< unsigned int, TProfile * > m_nmultvsvtxposprof
std::map< unsigned int, TH2F * > m_nmultvsvtxpos
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, std::string > m_labels
std::map< unsigned int, TFileDirectory * > m_subdirs
void DigiVtxPosCorrHistogramMaker::fill ( const edm::Event iEvent,
const std::map< unsigned int, int > &  ndigi 
)

Definition at line 108 of file DigiVtxPosCorrHistogramMaker.cc.

References edm::Event::getByToken(), edm::HepMCProduct::GetEvent(), mps_fire::i, edm::HandleBase::isValid(), m_labels, m_mcvtxcollectionToken, m_nmultvsvtxpos, and m_nmultvsvtxposprof.

Referenced by MultiplicityInvestigator::analyze().

108  {
109  // main interaction part
110 
112  iEvent.getByToken(m_mcvtxcollectionToken, EvtHandle);
113 
114  if (EvtHandle.isValid()) {
115  const HepMC::GenEvent* Evt = EvtHandle->GetEvent();
116 
117  // get the first vertex
118 
119  if (Evt->vertices_begin() != Evt->vertices_end()) {
120  double vtxz = (*Evt->vertices_begin())->point3d().z() / 10.;
121 
122  for (std::map<unsigned int, int>::const_iterator digi = ndigi.begin(); digi != ndigi.end(); digi++) {
123  if (m_labels.find(digi->first) != m_labels.end()) {
124  const unsigned int i = digi->first;
125  m_nmultvsvtxpos[i]->Fill(vtxz, digi->second);
126  m_nmultvsvtxposprof[i]->Fill(vtxz, digi->second);
127  }
128  }
129  }
130  }
131 }
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:525
edm::EDGetTokenT< edm::HepMCProduct > m_mcvtxcollectionToken
std::map< unsigned int, TProfile * > m_nmultvsvtxposprof
bool isValid() const
Definition: HandleBase.h:70
std::map< unsigned int, TH2F * > m_nmultvsvtxpos
const HepMC::GenEvent * GetEvent() const
Definition: HepMCProduct.h:34
std::map< unsigned int, std::string > m_labels

Member Data Documentation

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

Definition at line 35 of file DigiVtxPosCorrHistogramMaker.h.

Referenced by book(), and DigiVtxPosCorrHistogramMaker().

std::string DigiVtxPosCorrHistogramMaker::m_hitname
private

Definition at line 32 of file DigiVtxPosCorrHistogramMaker.h.

Referenced by book().

std::map<unsigned int, std::string> DigiVtxPosCorrHistogramMaker::m_labels
private
edm::EDGetTokenT<edm::HepMCProduct> DigiVtxPosCorrHistogramMaker::m_mcvtxcollectionToken
private

Definition at line 31 of file DigiVtxPosCorrHistogramMaker.h.

Referenced by fill().

const int DigiVtxPosCorrHistogramMaker::m_nbins
private

Definition at line 33 of file DigiVtxPosCorrHistogramMaker.h.

Referenced by book().

std::map<unsigned int, TH2F*> DigiVtxPosCorrHistogramMaker::m_nmultvsvtxpos
private

Definition at line 38 of file DigiVtxPosCorrHistogramMaker.h.

Referenced by book(), and fill().

std::map<unsigned int, TProfile*> DigiVtxPosCorrHistogramMaker::m_nmultvsvtxposprof
private

Definition at line 39 of file DigiVtxPosCorrHistogramMaker.h.

Referenced by book(), and fill().

const int DigiVtxPosCorrHistogramMaker::m_scalefact
private

Definition at line 34 of file DigiVtxPosCorrHistogramMaker.h.

Referenced by book().

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

Definition at line 40 of file DigiVtxPosCorrHistogramMaker.h.

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