CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
MTVHistoProducerAlgo.cc
Go to the documentation of this file.
2 
4  if (th2->GetNbinsX()==me->getNbinsX()){
5  TProfile * p1 = (TProfile*) th2->ProfileX();
6  p1->Copy(*me->getTProfile());
7  delete p1;
8  } else {
9  throw cms::Exception("MultiTrackValidator") << "Different number of bins!";
10  }
11 }
12 
14  for (unsigned int j=0; j<vec.size(); j++){
15  h->setBinContent(j+1, vec[j]);
16  }
17 }
18 
20  std::vector<int>& numerator,
21  std::vector<int>& denominator,
23  double value,err;
24  for (unsigned int j=0; j<numerator.size(); j++){
25  if (denominator[j]!=0){
26  if (type=="effic"){
27  value = ((double) numerator[j])*1./((double) denominator[j]);
28  err = sqrt( value*(1-value)/(double) denominator[j] );
29  } else if (type=="fakerate"){
30  value = 1-((double) numerator[j])*1./((double) denominator[j]);
31  err = sqrt( value*(1-value)/(double) denominator[j] );
32  } else if (type=="pileup"){
33  value = ((double) numerator[j])*1./((double) denominator[j]);
34  err = sqrt( value*(1+value)/(double) denominator[j] );
35  } else return;
36  h->setBinContent(j+1, value);
37  h->setBinError(j+1, err);
38  }
39  else {
40  h->setBinContent(j+1, 0.);
41  h->setBinError(j+1, 0.);
42  }
43  }
44 }
45 
47  TH1* numerator,
48  TH1* denominator,
50  assert(h->getNbinsX()==numerator->GetNbinsX());
51  assert(h->getNbinsX()==denominator->GetNbinsX());
52  double value,err;
53  for (int bin=1;bin<=h->getNbinsX();++bin) {
54  if (denominator->GetBinContent(bin)!=0) {
55  if (type=="effic"){
56  value = ((double) numerator->GetBinContent(bin))/((double) denominator->GetBinContent(bin));
57  err = sqrt( value*(1.-value)/((double) denominator->GetBinContent(bin)) );
58  } else if (type=="fakerate"){
59  value = 1.-((double) numerator->GetBinContent(bin))/((double) denominator->GetBinContent(bin));
60  err = sqrt( value*(1.-value)/(double)denominator->GetBinContent(bin) );
61  } else if (type=="pileup"){
62  value = ((double) numerator->GetBinContent(bin))/((double) denominator->GetBinContent(bin));
63  err = sqrt( value*(1.+value)/(double) denominator->GetBinContent(bin) );
64  } else return;
65  h->setBinContent(bin,value);
66  h->setBinError(bin,err);
67  }
68  }
69 }
70 
72  TAxis *axis = h->GetXaxis();
73  int bins = axis->GetNbins();
74 
75  float from = axis->GetXmin();
76  float to = axis->GetXmax();
77  float width = (to - from) / bins;
78  float *new_bins = new float[bins + 1];
79 
80  for (int i = 0; i <= bins; i++) {
81  new_bins[i] = TMath::Power(10, from + i * width);
82 
83  }
84  axis->Set(bins, new_bins);
85  delete[] new_bins;
86 }
87 
88 
89 //void MTVHistoProducerAlgo::
90 //void MTVHistoProducerAlgo::
91 
type
Definition: HCALResponse.h:21
int i
Definition: DBlmapReader.cc:9
void setBinContent(int binx, double content)
set content of bin (1-D)
void fillPlotFromVectors(MonitorElement *h, std::vector< int > &numerator, std::vector< int > &denominator, std::string type)
list numerator
Definition: cuy.py:483
void doProfileX(TH2 *th2, MonitorElement *me)
void fillPlotFromVector(MonitorElement *h, std::vector< int > &vec)
list denominator
Definition: cuy.py:484
T sqrt(T t)
Definition: SSEVec.h:48
int j
Definition: DBlmapReader.cc:9
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
Definition: Activities.doc:4
void setBinError(int binx, double error)
set uncertainty on content of bin (1-D)
void fillPlotFromPlots(MonitorElement *h, TH1 *numerator, TH1 *denominator, std::string type)
double p1[4]
Definition: TauolaWrapper.h:89
TProfile * getTProfile(void) const
int getNbinsX(void) const
get # of bins in X-axis