CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
DigiInvestigatorHistogramMaker.cc
Go to the documentation of this file.
6 #include "TProfile.h"
7 #include "TH1F.h"
8 
10 
11 
13  _hitname(), _nbins(500), m_maxLS(100), m_LSfrac(4), _scalefact(), _runHisto(true), _binmax(), _labels(), _nmultvsorbrun(), _nmult() { }
14 
16  _hitname(iConfig.getUntrackedParameter<std::string>("hitName","digi")),
17  _nbins(iConfig.getUntrackedParameter<int>("numberOfBins",500)),
18  m_maxLS(iConfig.getUntrackedParameter<unsigned int>("maxLSBeforeRebin",100)),
19  m_LSfrac(iConfig.getUntrackedParameter<unsigned int>("startingLSFraction",4)),
20  _scalefact(iConfig.getUntrackedParameter<int>("scaleFactor",5)),
21  _runHisto(iConfig.getUntrackedParameter<bool>("runHisto",true)),
22  _labels(), _rhm(), _nmultvsorbrun(), _nmult(), _subdirs()
23 {
24 
25  std::vector<edm::ParameterSet>
26  wantedsubds(iConfig.getUntrackedParameter<std::vector<edm::ParameterSet> >("wantedSubDets",std::vector<edm::ParameterSet>()));
27 
28  for(std::vector<edm::ParameterSet>::iterator ps=wantedsubds.begin();ps!=wantedsubds.end();++ps) {
29  _labels[ps->getParameter<unsigned int>("detSelection")] = ps->getParameter<std::string>("detLabel");
30  _binmax[ps->getParameter<unsigned int>("detSelection")] = ps->getParameter<int>("binMax");
31  }
32 
33 
34 }
35 
36 
38 
39  for(std::map<unsigned int,std::string>::const_iterator lab=_labels.begin();lab!=_labels.end();lab++) {
40 
41  const unsigned int i = lab->first; const std::string slab = lab->second;
42 
43  delete _subdirs[i];
44  }
45 
46 }
47 
48 
49 
50 void DigiInvestigatorHistogramMaker::book(const std::string dirname, const std::map<unsigned int, std::string>& labels) {
51 
52  _labels = labels;
53  book(dirname);
54 
55 }
56 
58 
60  TFileDirectory subev = tfserv->mkdir(dirname);
61 
62  SiStripTKNumbers trnumb;
63 
64  edm::LogInfo("NumberOfBins") << "Number of Bins: " << _nbins;
65  edm::LogInfo("NumberOfMaxLS") << "Max number of LS before rebinning: " << m_maxLS;
66  edm::LogInfo("StartingLSFrac") << "Fraction of LS in one bin before rebinning: " << m_LSfrac;
67  edm::LogInfo("ScaleFactors") << "x-axis range scale factor: " << _scalefact;
68  edm::LogInfo("BinMaxValue") << "Setting bin max values";
69 
70  for(std::map<unsigned int,std::string>::const_iterator lab=_labels.begin();lab!=_labels.end();lab++) {
71 
72  const unsigned int i = lab->first; const std::string slab = lab->second;
73 
74  if(_binmax.find(i)==_binmax.end()) {
75  edm::LogVerbatim("NotConfiguredBinMax") << "Bin max for " << lab->second
76  << " not configured: " << trnumb.nstrips(i) << " used";
77  _binmax[i] = trnumb.nstrips(i);
78  }
79 
80  edm::LogVerbatim("BinMaxValue") << "Bin max for " << lab->second << " is " << _binmax[i];
81 
82  }
83 
84  for(std::map<unsigned int,std::string>::const_iterator lab=_labels.begin();lab!=_labels.end();++lab) {
85 
86  const int i = lab->first; const std::string slab = lab->second;
87 
88  char name[200];
89  char title[500];
90 
91  _subdirs[i] = new TFileDirectory(subev.mkdir(slab.c_str()));
92 
93  if(_subdirs[i]) {
94  sprintf(name,"n%sdigi",slab.c_str());
95  sprintf(title,"%s %s multiplicity",slab.c_str(),_hitname.c_str());
96  _nmult[i] = _subdirs[i]->make<TH1F>(name,title,_nbins,0.,(1+_binmax[i]/(_scalefact*_nbins))*_nbins);
97  _nmult[i]->GetXaxis()->SetTitle("Number of Hits"); _nmult[i]->GetYaxis()->SetTitle("Events");
98 
99  if(_runHisto) {
100  sprintf(name,"n%sdigivsorbrun",slab.c_str());
101  sprintf(title,"%s %s mean multiplicity vs orbit",slab.c_str(),_hitname.c_str());
102  _nmultvsorbrun[i] = _rhm.makeTProfile(name,title,m_LSfrac*m_maxLS,0,m_maxLS*262144);
103  }
104 
105  }
106 
107  }
108 
109 
110 }
111 
112 void DigiInvestigatorHistogramMaker::beginRun(const unsigned int nrun) {
113 
114  // char runname[100];
115  // sprintf(runname,"run_%d",nrun);
116 
118 
119  // currdir = &(*tfserv);
120  // _rhm.beginRun(nrun,*currdir);
121 
122  _rhm.beginRun(nrun,*tfserv);
123 
124 
125  for(std::map<unsigned int,std::string>::const_iterator lab=_labels.begin();lab!=_labels.end();++lab) {
126 
127  const int i = lab->first; const std::string slab = lab->second;
128 
129  // char name[200];
130  // char title[500];
131 
132  // TFileDirectory subd =_subdirs[i]->mkdir(runname);
133 
134  // sprintf(name,"n%sdigivsorbrun",slab.c_str());
135  // sprintf(title,"%s %s mean multiplicity vs orbit",slab.c_str(),_hitname.c_str());
136  // _nmultvsorbrun[i] = subd.make<TProfile>(name,title,_norbbin,0.5,11223*_norbbin+0.5);
137  if(_runHisto) {
138  (*_nmultvsorbrun[i])->GetXaxis()->SetTitle("time [orbit#]"); (*_nmultvsorbrun[i])->GetYaxis()->SetTitle("Hits");
139  (*_nmultvsorbrun[i])->SetBit(TH1::kCanRebin);
140  }
141  }
142 
143 
144 }
145 
146 void DigiInvestigatorHistogramMaker::fill(const unsigned int orbit, const std::map<unsigned int,int>& ndigi) {
147 
148  for(std::map<unsigned int,int>::const_iterator digi=ndigi.begin();digi!=ndigi.end();digi++) {
149 
150  if(_labels.find(digi->first) != _labels.end()) {
151 
152  const unsigned int i=digi->first;
153 
154  _nmult[i]->Fill(digi->second);
155  if(_runHisto) {
156  if(_nmultvsorbrun[i] && *_nmultvsorbrun[i]) (*_nmultvsorbrun[i])->Fill(orbit,digi->second);
157  }
158  }
159 
160  }
161 }
162 
T getUntrackedParameter(std::string const &, T const &) const
int i
Definition: DBlmapReader.cc:9
std::map< unsigned int, TH1F * > _nmult
void book(const std::string dirname, const std::map< unsigned int, std::string > &labels)
std::map< unsigned int, std::string > _labels
int nstrips(const SiStripDetId &detid) const
void Fill(HcalDetId &id, double val, std::vector< TH2F > &depth)
TProfile ** makeTProfile(const char *name, const char *title, const unsigned int nbinx, const double xmin, const double xmax)
void fill(const unsigned int orbit, const std::map< unsigned int, int > &ndigi)
TFileDirectory mkdir(const std::string &dir, const std::string &descr="")
create a new subdirectory
void beginRun(const edm::Run &iRun)
std::map< unsigned int, TFileDirectory * > _subdirs
std::map< unsigned int, TProfile ** > _nmultvsorbrun