CMS 3D CMS Logo

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>
12 
14 
15  globalFolder_ = ps.getUntrackedParameter<std::string>("GlobalFolder", "RPC/RPCEfficiency/");
16  numberOfDisks_ = ps.getUntrackedParameter<int>("NumberOfEndcapDisks", 4);
17  innermostRings_ = ps.getUntrackedParameter<int>("NumberOfInnermostEndcapRings", 2);
18 
19 }
20 
21 
23 
25 
27 
29 
30 
32  EfficiencyPerRing = ibooker.book1D("EfficiencyPerRing","Efficiency per Ring",12,0.5,12.5);
33  EfficiencyPerLayer = ibooker.book1D("EfficiencyPerLayer","Efficiency per Layer",6,0.5,6.5);
34 
35 
36 
37  std::stringstream meName1;
38  MonitorElement * myMe1;
39 
40  std::stringstream meName2;
41  MonitorElement * myMe2;
42 
43  std::stringstream binName;
44  binName.str("");
45 
46  meName1.str("");
47  meName1<<globalFolder_;
48 
49  meName2.str("");
50  meName2<<globalFolder_;
51 
52  int k = 0;
53 
54  //EfficiencyPerRing
55 
56  for(int i=(-1*numberOfDisks_ ); i<=numberOfDisks_ ; i++){
57  if(i == 0) continue;
58  for(int j=innermostRings_; j<=3; j++){
59  meName1.str("");
60  meName2.str("");
61  if(i < 0){
62  meName1<<globalFolder_<<"Azimutal/ExGregDistroDm"<<abs(i)<<"R"<<j;
63  meName2<<globalFolder_<<"Azimutal/OcGregDistroDm"<<abs(i)<<"R"<<j;
64  //std::cout<<meName1.str()<<std::endl;
65  //std::cout<<meName2.str()<<std::endl;
66  binName.str("");
67  binName<<"RE-"<<i<<"/"<<j;
68  k++;}
69  else if(i >0){
70  meName1<<globalFolder_<<"Azimutal/ExGregDistroD"<<abs(i)<<"R"<<j;
71  meName2<<globalFolder_<<"Azimutal/OcGregDistroD"<<abs(i)<<"R"<<j;
72  //std::cout<<meName1.str()<<std::endl;
73  //std::cout<<meName2.str()<<std::endl;
74  binName.str("");
75  binName<<"RE+"<<abs(i)<<"/"<<j;
76  k++;}
77 
78  myMe1 = nullptr; myMe1 = nullptr;
79  myMe1 = igetter.get(meName1.str());
80  myMe2 = igetter.get(meName2.str());
81 
82  if(myMe1 && myMe2){
83  TH1 * histo1 = myMe1->getTH1();
84  TH1 * histo2 = myMe2->getTH1();
85 
86  int exg = histo1->Integral();
87  int obg = histo2->Integral();
88  double eff = 0;
89  double err = 0;
90  if(exg != 0){
91  eff = (double)obg/(double)exg;
92  err = sqrt(eff*(1-eff)/(double)exg);}
93 
94  if(k%2 != 0 && k < 7){
96  EfficiencyPerRing->setBinError(k+1, err);
97  EfficiencyPerRing->setBinLabel(k+1, binName.str());}
98  else if(k%2 == 0 && k < 7){
100  EfficiencyPerRing->setBinError(k-1, err);
101  EfficiencyPerRing->setBinLabel(k-1, binName.str());}
102  else if(k >= 7){
105  EfficiencyPerRing->setBinLabel(k, binName.str());}
106  }
107  }
108  }
109 
110  //EfficiencyPerLayer
111 
112  for(int i=1; i<=6; i++){
113 
114  int Exp = 0;
115  int Obs = 0;
116  double eff = 0;
117  double err = 0;
118 
119  for(int j=-2; j<=2; j++){
120  meName1.str("");
121  meName2.str("");
122  if(j < 0){
123  meName1<<globalFolder_<<"BarrelPerLayer/ExpLayerWm"<<abs(j);
124  meName2<<globalFolder_<<"BarrelPerLayer/ObsLayerWm"<<abs(j);}
125  else{
126  meName1<<globalFolder_<<"BarrelPerLayer/ExpLayerW"<<j;
127  meName2<<globalFolder_<<"BarrelPerLayer/ObsLayerW"<<j;}
128  myMe1 = nullptr; myMe1 = nullptr;
129  myMe1 = igetter.get(meName1.str());
130  myMe2 = igetter.get(meName2.str());
131  if(myMe1 && myMe2){
132  Exp += myMe1->getBinContent(i);
133  Obs += myMe2->getBinContent(i);
134  }
135  }
136 
137  if(Exp != 0){
138  eff = (double)Obs/(double)Exp;
139  err = sqrt(eff*(1-eff)/(double)Exp);}
142  binName.str("");
143  binName<<"Layer "<<i;
144  EfficiencyPerLayer->setBinLabel(i, binName.str());
145 
146  }
147 
148 }
149 
T getUntrackedParameter(std::string const &, T const &) const
void setBinContent(int binx, double content)
set content of bin (1-D)
MonitorElement * get(const std::string &path)
Definition: DQMStore.cc:302
void dqmEndLuminosityBlock(DQMStore::IBooker &, DQMStore::IGetter &, edm::LuminosityBlock const &, edm::EventSetup const &) override
TH1 * getTH1() const
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)
~RPCEfficiencyPerRingLayer() override
Destructor.
T sqrt(T t)
Definition: SSEVec.h:18
MonitorElement * book1D(Args &&...args)
Definition: DQMStore.h:118
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
void setBinError(int binx, double error)
set uncertainty on content of bin (1-D)
int k[5][pyjets_maxn]
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:274
RPCEfficiencyPerRingLayer(const edm::ParameterSet &iConfig)
Constructor.
double getBinContent(int binx) const
get content of bin (1-D)
void dqmEndJob(DQMStore::IBooker &, DQMStore::IGetter &) override