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>
12 
14 
15  globalFolder_ = ps.getUntrackedParameter<std::string>("GlobalFolder", "RPC/RPCEfficiency/");
16  SaveFile = ps.getUntrackedParameter<bool>("SaveFile", false);
17  NameFile = ps.getUntrackedParameter<std::string>("NameFile","RPCEfficiency.root");
18 
19  numberOfDisks_ = ps.getUntrackedParameter<int>("NumberOfEndcapDisks", 4);
20  innermostRings_ = ps.getUntrackedParameter<int>("NumberOfInnermostEndcapRings", 2);
21 
22 }
23 
24 
26 
28 
30 
32 }
33 
35 
36  if(dbe_ == 0) return;
37 
39  EfficiencyPerRing = dbe_->book1D("EfficiencyPerRing","Efficiency per Ring",12,0.5,12.5);
40  EfficiencyPerLayer = dbe_->book1D("EfficiencyPerLayer","Efficiency per Layer",6,0.5,6.5);
41 
42 
43 }
44 
46 
47  std::stringstream meName1;
48  MonitorElement * myMe1;
49 
50  std::stringstream meName2;
51  MonitorElement * myMe2;
52 
53  std::stringstream binName;
54  binName.str("");
55 
56  meName1.str("");
57  meName1<<globalFolder_;
58 
59  meName2.str("");
60  meName2<<globalFolder_;
61 
62  int k = 0;
63 
64  //EfficiencyPerRing
65 
66  for(int i=(-1*numberOfDisks_ ); i<=numberOfDisks_ ; i++){
67  if(i == 0) continue;
68  for(int j=innermostRings_; j<=3; j++){
69  meName1.str("");
70  meName2.str("");
71  if(i < 0){
72  meName1<<globalFolder_<<"Azimutal/ExGregDistroDm"<<abs(i)<<"R"<<j;
73  meName2<<globalFolder_<<"Azimutal/OcGregDistroDm"<<abs(i)<<"R"<<j;
74  //std::cout<<meName1.str()<<std::endl;
75  //std::cout<<meName2.str()<<std::endl;
76  binName.str("");
77  binName<<"RE-"<<i<<"/"<<j;
78  k++;}
79  else if(i >0){
80  meName1<<globalFolder_<<"Azimutal/ExGregDistroD"<<abs(i)<<"R"<<j;
81  meName2<<globalFolder_<<"Azimutal/OcGregDistroD"<<abs(i)<<"R"<<j;
82  //std::cout<<meName1.str()<<std::endl;
83  //std::cout<<meName2.str()<<std::endl;
84  binName.str("");
85  binName<<"RE+"<<abs(i)<<"/"<<j;
86  k++;}
87 
88  myMe1 = NULL; myMe1 = NULL;
89  myMe1 = dbe_->get(meName1.str());
90  myMe2 = dbe_->get(meName2.str());
91 
92  if(myMe1 && myMe2){
93  TH1 * histo1 = myMe1->getTH1();
94  TH1 * histo2 = myMe2->getTH1();
95 
96  int exg = histo1->Integral();
97  int obg = histo2->Integral();
98  double eff = 0;
99  double err = 0;
100  if(exg != 0){
101  eff = (double)obg/(double)exg;
102  err = sqrt(eff*(1-eff)/(double)exg);}
103 
104  if(k%2 != 0 && k < 7){
105  EfficiencyPerRing->setBinContent(k+1, eff);
106  EfficiencyPerRing->setBinError(k+1, err);
107  EfficiencyPerRing->setBinLabel(k+1, binName.str());}
108  else if(k%2 == 0 && k < 7){
109  EfficiencyPerRing->setBinContent(k-1, eff);
110  EfficiencyPerRing->setBinError(k-1, err);
111  EfficiencyPerRing->setBinLabel(k-1, binName.str());}
112  else if(k >= 7){
115  EfficiencyPerRing->setBinLabel(k, binName.str());}
116  }
117  }
118  }
119 
120  //EfficiencyPerLayer
121 
122  for(int i=1; i<=6; i++){
123 
124  int Exp = 0;
125  int Obs = 0;
126  double eff = 0;
127  double err = 0;
128 
129  for(int j=-2; j<=2; j++){
130  meName1.str("");
131  meName2.str("");
132  if(j < 0){
133  meName1<<globalFolder_<<"BarrelPerLayer/ExpLayerWm"<<abs(j);
134  meName2<<globalFolder_<<"BarrelPerLayer/ObsLayerWm"<<abs(j);}
135  else{
136  meName1<<globalFolder_<<"BarrelPerLayer/ExpLayerW"<<j;
137  meName2<<globalFolder_<<"BarrelPerLayer/ObsLayerW"<<j;}
138  myMe1 = NULL; myMe1 = NULL;
139  myMe1 = dbe_->get(meName1.str());
140  myMe2 = dbe_->get(meName2.str());
141  if(myMe1 && myMe2){
142  Exp += myMe1->getBinContent(i);
143  Obs += myMe2->getBinContent(i);
144  }
145  }
146 
147  if(Exp != 0){
148  eff = (double)Obs/(double)Exp;
149  err = sqrt(eff*(1-eff)/(double)Exp);}
152  binName.str("");
153  binName<<"Layer "<<i;
154  EfficiencyPerLayer->setBinLabel(i, binName.str());
155 
156  }
157 
158  if(SaveFile) dbe_->save(NameFile);
159 
160 }
161 
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:942
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 NULL
Definition: scimark2.h:8
int iEvent
Definition: GenABIO.cc:230
T sqrt(T t)
Definition: SSEVec.h:48
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
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:1696
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)
void save(const std::string &filename, const std::string &path="", const std::string &pattern="", const std::string &rewrite="", const uint32_t run=0, const uint32_t lumi=0, SaveReferenceTag ref=SaveWithReference, int minStatus=dqm::qstatus::STATUS_OK, const std::string &fileupdate="RECREATE", const bool resetMEsAfterWriting=false)
Definition: DQMStore.cc:2490
virtual ~RPCEfficiencyPerRingLayer()
Destructor.
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:655
Definition: Run.h:41