CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
DigiLumiCorrHistogramMaker.cc
Go to the documentation of this file.
9 #include "TH2F.h"
10 #include "TProfile.h"
11 
14 
15 
17  m_lumiProducer("lumiProducer"), m_fhm(), m_runHisto(false),
18  m_hitname(), m_nbins(500), m_scalefact(), m_binmax(), m_labels(), m_nmultvslumi(), m_nmultvslumiprof(), m_subdirs() { }
19 
21  m_lumiProducer(iConfig.getParameter<edm::InputTag>("lumiProducer")),
22  m_fhm(),
23  m_runHisto(iConfig.getUntrackedParameter<bool>("runHisto",false)),
24  m_hitname(iConfig.getUntrackedParameter<std::string>("hitName","digi")),
25  m_nbins(iConfig.getUntrackedParameter<int>("numberOfBins",500)),
26  m_scalefact(iConfig.getUntrackedParameter<int>("scaleFactor",5)),
27  m_labels(), m_nmultvslumi(), m_nmultvslumiprof(), m_subdirs()
28 {
29 
30  std::vector<edm::ParameterSet>
31  wantedsubds(iConfig.getUntrackedParameter<std::vector<edm::ParameterSet> >("wantedSubDets",std::vector<edm::ParameterSet>()));
32 
33  for(std::vector<edm::ParameterSet>::iterator ps=wantedsubds.begin();ps!=wantedsubds.end();++ps) {
34  m_labels[ps->getParameter<unsigned int>("detSelection")] = ps->getParameter<std::string>("detLabel");
35  m_binmax[ps->getParameter<unsigned int>("detSelection")] = ps->getParameter<int>("binMax");
36  }
37 
38 
39 }
40 
41 
43 
44  for(std::map<unsigned int,std::string>::const_iterator lab=m_labels.begin();lab!=m_labels.end();lab++) {
45 
46  const unsigned int i = lab->first; const std::string slab = lab->second;
47 
48  delete m_subdirs[i];
49  delete m_fhm[i];
50  }
51 
52 }
53 
54 
55 
56 void DigiLumiCorrHistogramMaker::book(const std::string dirname, const std::map<unsigned int, std::string>& labels) {
57 
58  m_labels = labels;
59  book(dirname);
60 
61 }
62 
63 void DigiLumiCorrHistogramMaker::book(const std::string dirname) {
64 
66  TFileDirectory subev = tfserv->mkdir(dirname);
67 
68  SiStripTKNumbers trnumb;
69 
70  edm::LogInfo("NumberOfBins") << "Number of Bins: " << m_nbins;
71  edm::LogInfo("ScaleFactors") << "y-axis range scale factor: " << m_scalefact;
72  edm::LogInfo("BinMaxValue") << "Setting bin max values";
73 
74  for(std::map<unsigned int,std::string>::const_iterator lab=m_labels.begin();lab!=m_labels.end();lab++) {
75 
76  const unsigned int i = lab->first; const std::string slab = lab->second;
77 
78  if(m_binmax.find(i)==m_binmax.end()) {
79  edm::LogVerbatim("NotConfiguredBinMax") << "Bin max for " << lab->second
80  << " not configured: " << trnumb.nstrips(i) << " used";
81  m_binmax[i] = trnumb.nstrips(i);
82  }
83 
84  edm::LogVerbatim("BinMaxValue") << "Bin max for " << lab->second << " is " << m_binmax[i];
85 
86  }
87 
88  for(std::map<unsigned int,std::string>::const_iterator lab=m_labels.begin();lab!=m_labels.end();++lab) {
89 
90  const int i = lab->first; const std::string slab = lab->second;
91 
92  char name[200];
93  char title[500];
94 
95  m_subdirs[i] = new TFileDirectory(subev.mkdir(slab.c_str()));
96  m_fhm[i] = new RunHistogramManager(true);
97 
98  if(m_subdirs[i]) {
99  sprintf(name,"n%sdigivslumi",slab.c_str());
100  sprintf(title,"%s %s multiplicity vs BX lumi",slab.c_str(),m_hitname.c_str());
101  m_nmultvslumi[i] = m_subdirs[i]->make<TH2F>(name,title,250,0.,10.,m_nbins,0.,m_binmax[i]/(m_scalefact*m_nbins)*m_nbins);
102  m_nmultvslumi[i]->GetXaxis()->SetTitle("BX lumi [10^{30}cm^{-2}s^{-1}]"); m_nmultvslumi[i]->GetYaxis()->SetTitle("Number of Hits");
103  sprintf(name,"n%sdigivslumiprof",slab.c_str());
104  m_nmultvslumiprof[i] = m_subdirs[i]->make<TProfile>(name,title,250,0.,10.);
105  m_nmultvslumiprof[i]->GetXaxis()->SetTitle("BX lumi [10^{30}cm^{-2}s^{-1}]"); m_nmultvslumiprof[i]->GetYaxis()->SetTitle("Number of Hits");
106 
107  if(m_runHisto) {
108  edm::LogInfo("RunHistos") << "Pseudo-booking run histos " << slab.c_str();
109  sprintf(name,"n%sdigivslumivsbxprofrun",slab.c_str());
110  sprintf(title,"%s %s multiplicity vs BX lumi vs BX",slab.c_str(),m_hitname.c_str());
111  m_nmultvslumivsbxprofrun[i] = m_fhm[i]->makeTProfile2D(name,title,3564,0.5,3563.5,250,0.,10.);
112  }
113  }
114 
115  }
116 
117 
118 }
119 
121 
123 
124 
125  for(std::map<unsigned int,std::string>::const_iterator lab=m_labels.begin();lab!=m_labels.end();++lab) {
126  const int i = lab->first; const std::string slab = lab->second;
127  m_fhm[i]->beginRun(iRun,*m_subdirs[i]);
128  if(m_runHisto) {
129  (*m_nmultvslumivsbxprofrun[i])->GetXaxis()->SetTitle("BX");
130  (*m_nmultvslumivsbxprofrun[i])->GetYaxis()->SetTitle("BX lumi [10^{30}cm^{-2}s^{-1}]");
131  }
132  }
133 
134 
135 }
136 
137 void DigiLumiCorrHistogramMaker::fill(const edm::Event& iEvent, const std::map<unsigned int,int>& ndigi) {
138 
141 
142  if(ld.isValid()) {
143  if(ld->isValid()) {
144  float bxlumi = ld->lumiValue(LumiDetails::kOCC1,iEvent.bunchCrossing())*6.37;
145 
146  for(std::map<unsigned int,int>::const_iterator digi=ndigi.begin();digi!=ndigi.end();digi++) {
147  if(m_labels.find(digi->first) != m_labels.end()) {
148  const unsigned int i=digi->first;
149  m_nmultvslumi[i]->Fill(bxlumi,digi->second);
150  m_nmultvslumiprof[i]->Fill(bxlumi,digi->second);
151 
152  if(m_nmultvslumivsbxprofrun[i] && *m_nmultvslumivsbxprofrun[i]) (*m_nmultvslumivsbxprofrun[i])->Fill(iEvent.bunchCrossing(),bxlumi,digi->second);
153 
154  }
155  }
156  }
157  }
158 }
159 
T getUntrackedParameter(std::string const &, T const &) const
int i
Definition: DBlmapReader.cc:9
std::map< unsigned int, TFileDirectory * > m_subdirs
std::map< unsigned int, RunHistogramManager * > m_fhm
std::map< unsigned int, int > m_binmax
std::map< unsigned int, std::string > m_labels
int bunchCrossing() const
Definition: EventBase.h:62
bool getByLabel(std::string const &label, Handle< PROD > &result) const
int nstrips(const SiStripDetId &detid) const
int iEvent
Definition: GenABIO.cc:243
void Fill(HcalDetId &id, double val, std::vector< TH2F > &depth)
std::map< unsigned int, TProfile2D ** > m_nmultvslumivsbxprofrun
std::map< unsigned int, TProfile * > m_nmultvslumiprof
void fill(const edm::Event &iEvent, const std::map< unsigned int, int > &ndigi)
LuminosityBlock const & getLuminosityBlock() const
Definition: Event.h:59
bool isValid() const
Definition: HandleBase.h:76
void book(const std::string dirname, const std::map< unsigned int, std::string > &labels)
std::map< unsigned int, TH2F * > m_nmultvslumi
TFileDirectory mkdir(const std::string &dir, const std::string &descr="")
create a new subdirectory
Definition: Run.h:33
void beginRun(const edm::Run &iRun)