CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
RPCOccupancyTest.cc
Go to the documentation of this file.
1 /* \author Anna Cimmino*/
2 //#include <cmath>
3 #include <sstream>
6 
7 // Framework
9 //Geometry
11 
13  edm::LogVerbatim ("rpceventsummary") << "[RPCOccupancyTest]: Constructor";
14 
15  prescaleFactor_ = ps.getUntrackedParameter<int>("DiagnosticPrescale", 1);
16  numberOfDisks_ = ps.getUntrackedParameter<int>("NumberOfEndcapDisks", 4);
17  numberOfRings_ = ps.getUntrackedParameter<int>("NumberOfEndcapRings", 2);
18  testMode_ = ps.getUntrackedParameter<bool>("testMode", false);
19  useRollInfo_ = ps.getUntrackedParameter<bool>("useRollInfo_", false);
20 
21  std::string subsystemFolder = ps.getUntrackedParameter<std::string>("RPCFolder", "RPC");
22  std::string recHitTypeFolder= ps.getUntrackedParameter<std::string>("RecHitTypeFolder", "AllHits");
23 
24  prefixDir_ = subsystemFolder+ "/"+ recHitTypeFolder;
25 
26 }
27 
29 
31  edm::LogVerbatim ("rpceventsummary") << "[RPCOccupancyTest]: Begin job ";
32  globalFolder_ = workingFolder;
33 }
34 
35 
36 void RPCOccupancyTest::getMonitorElements(std::vector<MonitorElement *> & meVector, std::vector<RPCDetId> & detIdVector, std::string & clientHistoName){
37  //Get NumberOfDigi ME for each roll
38  for(unsigned int i = 0 ; i<meVector.size(); i++){
39 
40  std::string meName = meVector[i]->getName();
41 
42  if(meName.find(clientHistoName) != std::string::npos){
43  myOccupancyMe_.push_back(meVector[i]);
44  myDetIds_.push_back(detIdVector[i]);
45  }
46  }
47 }
48 
50 
51  edm::LogVerbatim ("rpceventsummary") <<"[RPCOccupancyTest]: Client Operation";
52 
53  //Loop on MEs
54  for (unsigned int i = 0 ; i<myOccupancyMe_.size();i++){
56  }//End loop on MEs
57 }
58 
59 
61 
63 
64  std::stringstream histoName;
65  rpcdqm::utils rpcUtils;
66 
67  histoName.str("");
68  histoName<<"Barrel_OccupancyByStations_Normalized";
69 
70  Barrel_OccBySt = ibooker.book1D(histoName.str().c_str(), histoName.str().c_str(), 4, 0.5, 4.5);
71  Barrel_OccBySt -> setBinLabel(1, "St1", 1);
72  Barrel_OccBySt -> setBinLabel(2, "St2", 1);
73  Barrel_OccBySt -> setBinLabel(3, "St3", 1);
74  Barrel_OccBySt -> setBinLabel(4, "St4", 1);
75 
76 
77  histoName.str("");
78  histoName<<"EndCap_OccupancyByRings_Normalized";
79  EndCap_OccByRng = ibooker.book1D(histoName.str().c_str(), histoName.str().c_str(), 4, 0.5, 4.5);
80  EndCap_OccByRng -> setBinLabel(1, "E+/R3", 1);
81  EndCap_OccByRng -> setBinLabel(2, "E+/R2", 1);
82  EndCap_OccByRng -> setBinLabel(3, "E-/R2", 1);
83  EndCap_OccByRng -> setBinLabel(4, "E-/R3", 1);
84 
85  for (int w = -2; w<=2; w++ ){//loop on wheels
86 
87  histoName.str("");
88  histoName<<"AsymmetryLeftRight_Roll_vs_Sector_Wheel"<<w;
89 
90  AsyMeWheel[w+2] = ibooker.book2D(histoName.str().c_str(), histoName.str().c_str(), 12, 0.5, 12.5, 21, 0.5, 21.5);
91 
92  rpcUtils.labelXAxisSector(AsyMeWheel[w+2]);
93  rpcUtils.labelYAxisRoll(AsyMeWheel[w+2], 0, w, useRollInfo_);
94 
95 
96  if(testMode_){
97 
98  histoName.str("");
99  histoName<<"OccupancyNormByEvents_Wheel"<<w;
100  NormOccupWheel[w+2] = ibooker.book2D(histoName.str().c_str(), histoName.str().c_str(), 12, 0.5, 12.5, 21, 0.5, 21.5);
101 
102  rpcUtils.labelXAxisSector( NormOccupWheel[w+2]);
103  rpcUtils.labelYAxisRoll( NormOccupWheel[w+2], 0, w, useRollInfo_);
104 
105 
106  histoName.str("");
107  histoName<<"AsymmetryLeftRight_Distribution_Wheel"<<w;
108  AsyMeDWheel[w+2] = ibooker.book1D(histoName.str().c_str(), histoName.str().c_str(), 20, -0.1, 1.1);
109 
110  histoName.str("");
111  histoName<<"OccupancyNormByEvents_Distribution_Wheel"<<w;
112 
113  NormOccupDWheel[w+2] = ibooker.book1D(histoName.str().c_str(), histoName.str().c_str(), 100, 0.0, 0.205);
114  }
115  }//end Barrel
116 
117  for(int d = -numberOfDisks_; d<=numberOfDisks_; d++ ){
118 
119  if (d == 0)continue;
120 
121  int offset = numberOfDisks_;
122  if (d>0) offset --; //used to skip case equale to zero
123 
124  histoName.str("");
125  histoName<<"AsymmetryLeftRight_Ring_vs_Segment_Disk"<<d;
126  AsyMeDisk[d+offset] = ibooker.book2D(histoName.str().c_str(), histoName.str().c_str(), 36, 0.5, 36.5, 3*numberOfRings_, 0.5,3*numberOfRings_+ 0.5);
127 
128  rpcUtils.labelXAxisSegment(AsyMeDisk[d+offset]);
129  rpcUtils.labelYAxisRing(AsyMeDisk[d+offset], numberOfRings_, useRollInfo_);
130 
131 
132 
133  if(testMode_){
134 
135  histoName.str("");
136  histoName<<"OccupancyNormByEvents_Disk"<<d;
137  NormOccupDisk[d+offset] = ibooker.book2D(histoName.str().c_str(), histoName.str().c_str(), 36, 0.5, 36.5, 3*numberOfRings_, 0.5,3*numberOfRings_+ 0.5);
138 
139  rpcUtils.labelXAxisSegment(NormOccupDisk[d+offset]);
141 
142  histoName.str("");
143  histoName<<"AsymmetryLeftRight_Distribution_Disk"<<d;
144  AsyMeDDisk[d+offset] = ibooker.book1D(histoName.str().c_str(), histoName.str().c_str(), 20, -0.1, 1.1);
145 
146  histoName.str("");
147  histoName<<"OccupancyNormByEvents_Distribution_Disk"<<d;
148  NormOccupDDisk[d+offset] = ibooker.book1D(histoName.str().c_str(), histoName.str().c_str(), 100, 0.0, 0.205);
149  }
150  }//End loop on Endcap
151 }
152 
153 
155 
156 
157 if (!myMe) return;
158 
159  MonitorElement * AsyMe=NULL; //Left Right Asymetry
160  MonitorElement * AsyMeD=NULL;
161  MonitorElement * NormOccup=NULL;
162  MonitorElement * NormOccupD=NULL;
163 
164  if(detId.region() ==0){
165  AsyMe= AsyMeWheel[detId.ring()+2];
166  if(testMode_){
167  NormOccup=NormOccupWheel[detId.ring()+2];
168  AsyMeD= AsyMeDWheel[detId.ring()+2];
169  NormOccupD=NormOccupDWheel[detId.ring()+2];
170  }
171 
172  }else{
173 
174  if( -detId.station() + numberOfDisks_ >= 0 ){
175 
176  if(detId.region()<0){
177  AsyMe= AsyMeDisk[-detId.station() + numberOfDisks_];
178  if(testMode_){
179  NormOccup=NormOccupDisk[-detId.station() + numberOfDisks_];
180  AsyMeD= AsyMeDDisk[-detId.station() + numberOfDisks_];
181  NormOccupD=NormOccupDDisk[-detId.station() + numberOfDisks_];
182  }
183  }else{
184  AsyMe= AsyMeDisk[detId.station() + numberOfDisks_-1];
185  if(testMode_){
186  NormOccup=NormOccupDisk[detId.station() + numberOfDisks_-1];
187  AsyMeD= AsyMeDDisk[detId.station() + numberOfDisks_-1];
188  NormOccupD=NormOccupDDisk[detId.station() + numberOfDisks_-1];
189  }
190  }
191  }
192  }
193 
194 
195  int xBin,yBin;
196  if(detId.region()==0){//Barrel
197  xBin= detId.sector();
198  rpcdqm::utils rollNumber;
199  yBin = rollNumber.detId2RollNr(detId);
200  }else{//Endcap
201  //get segment number
202  RPCGeomServ RPCServ(detId);
203  xBin = RPCServ.segment();
204  (numberOfRings_ == 3 ? yBin= detId.ring()*3-detId.roll()+1 : yBin= (detId.ring()-1)*3-detId.roll()+1);
205  }
206 
207 
208  int stripInRoll=myMe->getNbinsX();
209  float FOccupancy=0;
210  float BOccupancy=0;
211 
212  float totEnt = myMe->getEntries();
213  for(int strip = 1 ; strip<=stripInRoll; strip++){
214  if(strip<=stripInRoll/2) FOccupancy+=myMe->getBinContent(strip);
215  else BOccupancy+=myMe->getBinContent(strip);
216  }
217 
218 
219  float asym = 0;
220  if(totEnt != 0 ) asym = fabs((FOccupancy - BOccupancy )/totEnt);
221 
222  if(AsyMe) AsyMe->setBinContent(xBin,yBin,asym);
223 
224 
225 
226  float normoccup = 1;
227  if(rpcevents_ != 0) normoccup = (totEnt/rpcevents_);
228 
229  if(testMode_){
230  if(NormOccup) NormOccup->setBinContent(xBin,yBin, normoccup);
231  if(AsyMeD) AsyMeD->Fill(asym);
232  if(NormOccupD) NormOccupD->Fill(normoccup);
233  }
234 
235 
236  if(detId.region()==0) {
237  if(Barrel_OccBySt)Barrel_OccBySt -> Fill(detId.station(), normoccup);
238  }else if(detId.region()==1) {
239  if(detId.ring()==3) {
240  EndCap_OccByRng -> Fill(1, normoccup);
241  } else {
242  EndCap_OccByRng -> Fill(2, normoccup);
243  }
244  } else {
245  if(detId.ring()==3) {
246  EndCap_OccByRng -> Fill(4, normoccup);
247  }else {
248  EndCap_OccByRng -> Fill(3, normoccup);
249  }
250  }
251 
252 }
253 
254 
255 
256 
257 
T getUntrackedParameter(std::string const &, T const &) const
int i
Definition: DBlmapReader.cc:9
void myBooker(DQMStore::IBooker &)
void setBinContent(int binx, double content)
set content of bin (1-D)
MonitorElement * AsyMeWheel[5]
const double w
Definition: UKUtility.cc:23
tuple yBin
Definition: cuy.py:891
MonitorElement * NormOccupDDisk[10]
void labelXAxisSegment(MonitorElement *myMe)
Definition: utils.h:250
MonitorElement * EndCap_OccByRng
void labelYAxisRoll(MonitorElement *myMe, int region, int ring, bool useRollInfo)
Definition: utils.h:268
#define NULL
Definition: scimark2.h:8
double getEntries(void) const
get # of entries
std::vector< RPCDetId > myDetIds_
void Fill(long long x)
void beginJob(std::string &)
MonitorElement * NormOccupDWheel[5]
MonitorElement * Barrel_OccBySt
virtual ~RPCOccupancyTest()
void labelYAxisRing(MonitorElement *myMe, int numberOfRings, bool useRollInfo)
Definition: utils.h:295
int roll() const
Definition: RPCDetId.h:120
MonitorElement * NormOccupWheel[5]
void Fill(HcalDetId &id, double val, std::vector< TH2F > &depth)
int ring() const
Definition: RPCDetId.h:72
MonitorElement * book1D(Args &&...args)
Definition: DQMStore.h:115
MonitorElement * AsyMeDisk[10]
std::string globalFolder_
unsigned int offset(bool)
void labelXAxisSector(MonitorElement *myMe)
Definition: utils.h:236
void fillGlobalME(RPCDetId &, MonitorElement *)
virtual int segment()
Definition: RPCGeomServ.cc:467
int detId2RollNr(const RPCDetId &_id)
Definition: utils.h:18
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:274
MonitorElement * book2D(Args &&...args)
Definition: DQMStore.h:133
MonitorElement * AsyMeDDisk[10]
int sector() const
Sector id: the group of chambers at same phi (and increasing r)
Definition: RPCDetId.h:102
std::string prefixDir_
RPCOccupancyTest(const edm::ParameterSet &ps)
double getBinContent(int binx) const
get content of bin (1-D)
void getMonitorElements(std::vector< MonitorElement * > &, std::vector< RPCDetId > &, std::string &)
int getNbinsX(void) const
get # of bins in X-axis
std::vector< MonitorElement * > myOccupancyMe_
MonitorElement * NormOccupDisk[10]
MonitorElement * AsyMeDWheel[5]
int region() const
Region id: 0 for Barrel, +/-1 For +/- Endcap.
Definition: RPCDetId.h:63
int station() const
Definition: RPCDetId.h:96