CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
RPCEfficiencyPerRingLayer.cc
Go to the documentation of this file.
1 //
2 // Original Author: Cesare Calabria,161 R-006,
3 // Created: Fri May 13 12:58:43 CEST 2011
4 
5 
6 // user include files
8 #include <sstream>
9 
10 //CondFormats
11 //#include "CondFormats/RunInfo/interface/RunInfo.h"
12 //#include "CondFormats/DataRecord/interface/RunSummaryRcd.h"
13 // Framework
14 //#include "FWCore/MessageLogger/interface/MessageLogger.h"
15 //#include "FWCore/Framework/interface/LuminosityBlock.h"
19 //DQM Services
20 
21 
23 
24  globalFolder_ = ps.getUntrackedParameter<std::string>("GlobalFolder", "RPC/RPCEfficiency/");
25  SaveFile = ps.getUntrackedParameter<bool>("SaveFile", false);
26  NameFile = ps.getUntrackedParameter<std::string>("NameFile","RPCEfficiency.root");
27 }
28 
29 
31 
33 
35 
37 }
38 
40 
41  if(dbe_ == 0) return;
42 
44  EfficiencyPerRing = dbe_->book1D("EfficiencyPerRing","Efficiency per Ring",12,0.5,12.5);
45  EfficiencyPerLayer = dbe_->book1D("EfficiencyPerLayer","Efficiency per Layer",6,0.5,6.5);
46 
47 }
48 
50 
51  std::stringstream meName1;
52  MonitorElement * myMe1;
53 
54  std::stringstream meName2;
55  MonitorElement * myMe2;
56 
57  std::stringstream binName;
58  binName.str("");
59 
60  meName1.str("");
61  meName1<<globalFolder_;
62 
63  meName2.str("");
64  meName2<<globalFolder_;
65 
66  int k = 0;
67 
68  //EfficiencyPerRing
69 
70  for(int i=-3; i<=3; i++){
71  if(i == 0) continue;
72  for(int j=2; j<=3; j++){
73  meName1.str("");
74  meName2.str("");
75  if(i < 0){
76  meName1<<globalFolder_<<"Azimutal/ExGregDistroDm"<<abs(i)<<"R"<<j;
77  meName2<<globalFolder_<<"Azimutal/OcGregDistroDm"<<abs(i)<<"R"<<j;
78  //std::cout<<meName1.str()<<std::endl;
79  //std::cout<<meName2.str()<<std::endl;
80  binName.str("");
81  binName<<"RE-"<<i<<"/"<<j;
82  k++;}
83  else if(i >0){
84  meName1<<globalFolder_<<"Azimutal/ExGregDistroD"<<abs(i)<<"R"<<j;
85  meName2<<globalFolder_<<"Azimutal/OcGregDistroD"<<abs(i)<<"R"<<j;
86  //std::cout<<meName1.str()<<std::endl;
87  //std::cout<<meName2.str()<<std::endl;
88  binName.str("");
89  binName<<"RE+"<<abs(i)<<"/"<<j;
90  k++;}
91 
92  myMe1 = dbe_->get(meName1.str());
93  myMe2 = dbe_->get(meName2.str());
94  TH1 * histo1 = myMe1->getTH1();
95  TH1 * histo2 = myMe2->getTH1();
96  if(myMe1 && myMe2){
97 
98  int exg = histo1->Integral();
99  int obg = histo2->Integral();
100  double eff = 0;
101  double err = 0;
102  if(exg != 0){
103  eff = (double)obg/(double)exg;
104  err = sqrt(eff*(1-eff)/(double)exg);}
105  //std::cout<<exg<<" "<<obg<<" "<<eff<<" "<<err<<" "<<k<<std::endl;
106  if(k%2 != 0 && k < 7){
107  EfficiencyPerRing->setBinContent(k+1, eff);
108  EfficiencyPerRing->setBinError(k+1, err);
109  EfficiencyPerRing->setBinLabel(k+1, binName.str());}
110  else if(k%2 == 0 && k < 7){
111  EfficiencyPerRing->setBinContent(k-1, eff);
112  EfficiencyPerRing->setBinError(k-1, err);
113  EfficiencyPerRing->setBinLabel(k-1, binName.str());}
114  else if(k >= 7){
117  EfficiencyPerRing->setBinLabel(k, binName.str());}
118  }
119  }
120  }
121 
122  //EfficiencyPerLayer
123 
124  for(int i=1; i<=6; i++){
125 
126  int Exp = 0;
127  int Obs = 0;
128  double eff = 0;
129  double err = 0;
130 
131  for(int j=-2; j<=2; j++){
132  meName1.str("");
133  meName2.str("");
134  if(j < 0){
135  meName1<<globalFolder_<<"BarrelPerLayer/ExpLayerWm"<<abs(j);
136  meName2<<globalFolder_<<"BarrelPerLayer/ObsLayerWm"<<abs(j);}
137  else{
138  meName1<<globalFolder_<<"BarrelPerLayer/ExpLayerW"<<j;
139  meName2<<globalFolder_<<"BarrelPerLayer/ObsLayerW"<<j;}
140  //std::cout<<meName1.str()<<std::endl;
141  //std::cout<<meName2.str()<<std::endl;
142  myMe1 = dbe_->get(meName1.str());
143  myMe2 = dbe_->get(meName2.str());
144  if(myMe1 && myMe2){
145  Exp += myMe1->getBinContent(i);
146  Obs += myMe2->getBinContent(i);
147  }
148  }
149 
150  if(Exp != 0){
151  eff = (double)Obs/(double)Exp;
152  err = sqrt(eff*(1-eff)/(double)Exp);}
155  binName.str("");
156  binName<<"Layer "<<i;
157  EfficiencyPerLayer->setBinLabel(i, binName.str());
158  //std::cout<<Exp<<" "<<Obs<<" "<<eff<<" "<<err<<std::endl;
159  }
160 
161  if(SaveFile) dbe_->save(NameFile);
162 
163 }
164 
T getUntrackedParameter(std::string const &, T const &) const
int i
Definition: DBlmapReader.cc:9
void setBinContent(int binx, double content)
set content of bin (1-D)
MonitorElement * book1D(const char *name, const char *title, int nchX, double lowX, double highX)
Book 1D histogram.
Definition: DQMStore.cc:722
void save(const std::string &filename, const std::string &path="", const std::string &pattern="", const std::string &rewrite="", SaveReferenceTag ref=SaveWithReference, int minStatus=dqm::qstatus::STATUS_OK, const std::string &fileupdate="RECREATE")
Definition: DQMStore.cc:2118
void setBinLabel(int bin, const std::string &label, int axis=1)
set bin label for x, y or z axis (axis=1, 2, 3 respectively)
#define abs(x)
Definition: mlp_lapack.h:159
int iEvent
Definition: GenABIO.cc:243
T sqrt(T t)
Definition: SSEVec.h:48
int j
Definition: DBlmapReader.cc:9
TH1 * getTH1(void) const
void setBinError(int binx, double error)
set uncertainty on content of bin (1-D)
void analyze(const edm::Event &iEvent, const edm::EventSetup &iSetup)
Analyze.
void beginRun(const edm::Run &r, const edm::EventSetup &c)
MonitorElement * get(const std::string &path) const
get ME from full pathname (e.g. &quot;my/long/dir/my_histo&quot;)
Definition: DQMStore.cc:1473
int k[5][pyjets_maxn]
void endRun(const edm::Run &r, const edm::EventSetup &c)
RPCEfficiencyPerRingLayer(const edm::ParameterSet &iConfig)
Constructor.
double getBinContent(int binx) const
get content of bin (1-D)
virtual ~RPCEfficiencyPerRingLayer()
Destructor.
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:434
Definition: Run.h:36