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", 3);
17  numberOfRings_ = ps.getUntrackedParameter<int>("NumberOfEndcapRings", 2);
18  testMode_ = ps.getUntrackedParameter<bool>("testMode", false);
19 
20  std::string subsystemFolder = ps.getUntrackedParameter<std::string>("RPCFolder", "RPC");
21  std::string recHitTypeFolder= ps.getUntrackedParameter<std::string>("RecHitTypeFolder", "Noise");
22 
23  prefixDir_ = subsystemFolder+ "/"+ recHitTypeFolder;
24 
25 }
26 
28  dbe_=0;
29 }
30 
31 void RPCOccupancyTest::beginJob(DQMStore * dbe, std::string workingFolder){
32  edm::LogVerbatim ("rpceventsummary") << "[RPCOccupancyTest]: Begin job ";
33  globalFolder_ = workingFolder;
34  dbe_=dbe;
35 }
36 
38  edm::LogVerbatim ("rpceventsummary") << "[RPCOccupancyTest]: End run";
39  }
40 
41 void RPCOccupancyTest::getMonitorElements(std::vector<MonitorElement *> & meVector, std::vector<RPCDetId> & detIdVector){
42 
43  //Get Occupancy ME for each roll
44  for (unsigned int i = 0 ; i<meVector.size(); i++){
45 
46  bool flag= false;
47 
48  DQMNet::TagList tagList;
49  tagList = meVector[i]->getTags();
50  DQMNet::TagList::iterator tagItr = tagList.begin();
51 
52  while (tagItr != tagList.end() && !flag ) {
53  if((*tagItr) == rpcdqm::OCCUPANCY)
54  flag= true;
55  tagItr++;
56  }
57 
58  if(flag){
59  myOccupancyMe_.push_back(meVector[i]);
60  myDetIds_.push_back(detIdVector[i]);
61  }
62  }
63 }
64 
66 
68 
70 
72 
73  edm::LogVerbatim ("rpceventsummary") <<"[RPCOccupancyTest]: Client Operation";
74 
75  MonitorElement * RPCEvents = dbe_->get(prefixDir_ +"/RPCEvents");
76  rpcevents_ = RPCEvents ->getBinContent(1);
77 
78 
79  //Loop on MEs
80  for (unsigned int i = 0 ; i<myOccupancyMe_.size();i++){
82  }//End loop on MEs
83 }
84 
87 
88  MonitorElement* me;
90 
91  std::stringstream histoName;
92  rpcdqm::utils rpcUtils;
93 
94  histoName.str("");
95  histoName<<"Barrel_OccupancyByStations_Normalized";
96  me = dbe_->get( globalFolder_+"/"+ histoName.str());
97  if ( 0!=me ) {
98  dbe_->removeElement(me->getName());
99  }
100  Barrel_OccBySt = dbe_->book1D(histoName.str().c_str(), histoName.str().c_str(), 4, 0.5, 4.5);
101  Barrel_OccBySt -> setBinLabel(1, "St1", 1);
102  Barrel_OccBySt -> setBinLabel(2, "St2", 1);
103  Barrel_OccBySt -> setBinLabel(3, "St3", 1);
104  Barrel_OccBySt -> setBinLabel(4, "St4", 1);
105 
106 
107  histoName.str("");
108  histoName<<"EndCap_OccupancyByRings_Normalized";
109  me = dbe_->get( globalFolder_+"/"+ histoName.str());
110  if ( 0!=me ) {
111  dbe_->removeElement(me->getName());
112  }
113  EndCap_OccByRng = dbe_->book1D(histoName.str().c_str(), histoName.str().c_str(), 4, 0.5, 4.5);
114  EndCap_OccByRng -> setBinLabel(1, "E+/R3", 1);
115  EndCap_OccByRng -> setBinLabel(2, "E+/R2", 1);
116  EndCap_OccByRng -> setBinLabel(3, "E-/R2", 1);
117  EndCap_OccByRng -> setBinLabel(4, "E-/R3", 1);
118 
119 // histoName.str("");
120 // histoName<<"EndCap_OccupancyByDisksAndRings_Normalized";
121 // me = dbe_->get( globalFolder_+"/"+ histoName.str());
122 // if ( 0!=me ) {
123 // dbe_->removeElement(me->getName());
124 // }
125 // EndCap_OccByDisk = dbe_->book1D(histoName.str().c_str(), histoName.str().c_str(), 12, 0, 12);
126 // EndCap_OccByDisk -> setBinLabel(1, "YE-3/R2", 1);
127 // EndCap_OccByDisk -> setBinLabel(2, "YE-2/R2", 1);
128 // EndCap_OccByDisk -> setBinLabel(3, "YE-1/R2", 1);
129 // EndCap_OccByDisk -> setBinLabel(4, "YE+1/R2", 1);
130 // EndCap_OccByDisk -> setBinLabel(5, "YE+2/R2", 1);
131 // EndCap_OccByDisk -> setBinLabel(6, "YE+3/R2", 1);
132 
133 // EndCap_OccByDisk -> setBinLabel(7, "YE-3/R3", 1);
134 // EndCap_OccByDisk -> setBinLabel(8, "YE-2/R3", 1);
135 // EndCap_OccByDisk -> setBinLabel(9, "YE-1/R3", 1);
136 // EndCap_OccByDisk -> setBinLabel(10, "YE+1/R3", 1);
137 // EndCap_OccByDisk -> setBinLabel(11, "YE+2/R3", 1);
138 // EndCap_OccByDisk -> setBinLabel(12, "YE+3/R3", 1);
139 
140  for (int w = -2; w<=2; w++ ){//loop on wheels
141 
142  histoName.str("");
143  histoName<<"AsymmetryLeftRight_Roll_vs_Sector_Wheel"<<w;
144  me = 0;
145  me = dbe_->get( globalFolder_+"/"+ histoName.str());
146  if ( 0!=me ) {
147  dbe_->removeElement(me->getName());
148  }
149 
150  AsyMeWheel[w+2] = dbe_->book2D(histoName.str().c_str(), histoName.str().c_str(), 12, 0.5, 12.5, 21, 0.5, 21.5);
151 
152  rpcUtils.labelXAxisSector(AsyMeWheel[w+2]);
153  rpcUtils.labelYAxisRoll(AsyMeWheel[w+2], 0, w);
154 
155 
156  if(testMode_){
157 
158  histoName.str("");
159  histoName<<"OccupancyNormByEvents_Wheel"<<w;
160  me = 0;
161  me = dbe_->get( globalFolder_+"/"+ histoName.str());
162  if ( 0!=me ) {
163  dbe_->removeElement(me->getName());
164  }
165 
166  NormOccupWheel[w+2] = dbe_->book2D(histoName.str().c_str(), histoName.str().c_str(), 12, 0.5, 12.5, 21, 0.5, 21.5);
167 
168  rpcUtils.labelXAxisSector( NormOccupWheel[w+2]);
169  rpcUtils.labelYAxisRoll( NormOccupWheel[w+2], 0, w);
170 
171 
172  histoName.str("");
173  histoName<<"AsymmetryLeftRight_Distribution_Wheel"<<w;
174  me = 0;
175  me = dbe_->get( globalFolder_+"/"+ histoName.str());
176  if ( 0!=me ) {
177  dbe_->removeElement(me->getName());
178  }
179  AsyMeDWheel[w+2] = dbe_->book1D(histoName.str().c_str(), histoName.str().c_str(), 20, -0.1, 1.1);
180 
181  histoName.str("");
182  histoName<<"OccupancyNormByEvents_Distribution_Wheel"<<w;
183  me = 0;
184  me = dbe_->get( globalFolder_+"/"+ histoName.str());
185  if ( 0!=me ) {
186  dbe_->removeElement(me->getName());
187  }
188  NormOccupDWheel[w+2] = dbe_->book1D(histoName.str().c_str(), histoName.str().c_str(), 100, 0.0, 0.205);
189  }
190  }//end Barrel
191 
192  for(int d = -numberOfDisks_; d<=numberOfDisks_; d++ ){
193 
194  if (d == 0)continue;
195 
196  int offset = numberOfDisks_;
197  if (d>0) offset --; //used to skip case equale to zero
198 
199  histoName.str("");
200  histoName<<"AsymmetryLeftRight_Ring_vs_Segment_Disk"<<d;
201  me = 0;
202  me = dbe_->get( globalFolder_+"/"+ histoName.str());
203  if ( 0!=me ) {
204  dbe_->removeElement(me->getName());
205  }
206 
207  AsyMeDisk[d+offset] = dbe_->book2D(histoName.str().c_str(), histoName.str().c_str(), 36, 0.5, 36.5, 3*numberOfRings_, 0.5,3*numberOfRings_+ 0.5);
208 
209  rpcUtils.labelXAxisSegment(AsyMeDisk[d+offset]);
210  rpcUtils.labelYAxisRing(AsyMeDisk[d+offset], numberOfRings_);
211 
212 
213 
214  if(testMode_){
215 
216  histoName.str("");
217  histoName<<"OccupancyNormByEvents_Disk"<<d;
218  me = 0;
219  me = dbe_->get( globalFolder_+"/"+ histoName.str());
220  if ( 0!=me ) {
221  dbe_->removeElement(me->getName());
222  }
223 
224  NormOccupDisk[d+offset] = dbe_->book2D(histoName.str().c_str(), histoName.str().c_str(), 36, 0.5, 36.5, 3*numberOfRings_, 0.5,3*numberOfRings_+ 0.5);
225 
226  rpcUtils.labelXAxisSegment(NormOccupDisk[d+offset]);
227  rpcUtils.labelYAxisRing( NormOccupDisk[d+offset],numberOfRings_);
228 
229  histoName.str("");
230  histoName<<"AsymmetryLeftRight_Distribution_Disk"<<d;
231  me = 0;
232  me = dbe_->get( globalFolder_+"/"+ histoName.str());
233  if ( 0!=me ) {
234  dbe_->removeElement(me->getName());
235  }
236  AsyMeDDisk[d+offset] = dbe_->book1D(histoName.str().c_str(), histoName.str().c_str(), 20, -0.1, 1.1);
237 
238 
239 
240  histoName.str("");
241  histoName<<"OccupancyNormByEvents_Distribution_Disk"<<d;
242  me = 0;
243  me = dbe_->get( globalFolder_+"/"+ histoName.str());
244  if ( 0!=me ) {
245  dbe_->removeElement(me->getName());
246  }
247  NormOccupDDisk[d+offset] = dbe_->book1D(histoName.str().c_str(), histoName.str().c_str(), 100, 0.0, 0.205);
248  }
249  }//End loop on Endcap
250 }
251 
252 
254 
255 
256 if (!myMe) return;
257 
258  MonitorElement * AsyMe=NULL; //Left Right Asymetry
259  MonitorElement * AsyMeD=NULL;
260  MonitorElement * NormOccup=NULL;
261  MonitorElement * NormOccupD=NULL;
262 
263  if(detId.region() ==0){
264  AsyMe= AsyMeWheel[detId.ring()+2];
265  if(testMode_){
266  NormOccup=NormOccupWheel[detId.ring()+2];
267  AsyMeD= AsyMeDWheel[detId.ring()+2];
268  NormOccupD=NormOccupDWheel[detId.ring()+2];
269  }
270 
271  }else{
272 
273  if( -detId.station() + numberOfDisks_ >= 0 ){
274 
275  if(detId.region()<0){
276  AsyMe= AsyMeDisk[-detId.station() + numberOfDisks_];
277  if(testMode_){
278  NormOccup=NormOccupDisk[-detId.station() + numberOfDisks_];
279  AsyMeD= AsyMeDDisk[-detId.station() + numberOfDisks_];
280  NormOccupD=NormOccupDDisk[-detId.station() + numberOfDisks_];
281  }
282  }else{
283  AsyMe= AsyMeDisk[detId.station() + numberOfDisks_-1];
284  if(testMode_){
285  NormOccup=NormOccupDisk[detId.station() + numberOfDisks_-1];
286  AsyMeD= AsyMeDDisk[detId.station() + numberOfDisks_-1];
287  NormOccupD=NormOccupDDisk[detId.station() + numberOfDisks_-1];
288  }
289  }
290  }
291  }
292 
293 
294  int xBin,yBin;
295  if(detId.region()==0){//Barrel
296  xBin= detId.sector();
297  rpcdqm::utils rollNumber;
298  yBin = rollNumber.detId2RollNr(detId);
299  }else{//Endcap
300  //get segment number
301  RPCGeomServ RPCServ(detId);
302  xBin = RPCServ.segment();
303  (numberOfRings_ == 3 ? yBin= detId.ring()*3-detId.roll()+1 : yBin= (detId.ring()-1)*3-detId.roll()+1);
304  }
305 
306 
307  int stripInRoll=myMe->getNbinsX();
308  float FOccupancy=0;
309  float BOccupancy=0;
310 
311  float totEnt = myMe->getEntries();
312  for(int strip = 1 ; strip<=stripInRoll; strip++){
313  if(strip<=stripInRoll/2) FOccupancy+=myMe->getBinContent(strip);
314  else BOccupancy+=myMe->getBinContent(strip);
315  }
316 
317 
318  float asym = 0;
319  if(totEnt != 0 ) asym = fabs((FOccupancy - BOccupancy )/totEnt);
320 
321  if(AsyMe) AsyMe->setBinContent(xBin,yBin,asym);
322 
323 
324 
325  float normoccup = 1;
326  if(rpcevents_ != 0) normoccup = (totEnt/rpcevents_);
327 
328  if(testMode_){
329  if(NormOccup) NormOccup->setBinContent(xBin,yBin, normoccup);
330  if(AsyMeD) AsyMeD->Fill(asym);
331  if(NormOccupD) NormOccupD->Fill(normoccup);
332  }
333 
334 
335  if(detId.region()==0) {
336  if(Barrel_OccBySt)Barrel_OccBySt -> Fill(detId.station(), normoccup);
337  }else if(detId.region()==1) {
338  if(detId.ring()==3) {
339  EndCap_OccByRng -> Fill(1, normoccup);
340  } else {
341  EndCap_OccByRng -> Fill(2, normoccup);
342  }
343  } else {
344  if(detId.ring()==3) {
345  EndCap_OccByRng -> Fill(4, normoccup);
346  }else {
347  EndCap_OccByRng -> Fill(3, normoccup);
348  }
349  }
350 
351 }
352 
353 
354 
355 
356 
T getUntrackedParameter(std::string const &, T const &) const
const std::string & getName(void) const
get name of ME
int i
Definition: DBlmapReader.cc:9
void setBinContent(int binx, double content)
set content of bin (1-D)
long int flag
Definition: mlp_lapack.h:47
MonitorElement * AsyMeWheel[5]
void strip(std::string &input, const std::string &blanks=" \n\t")
Definition: stringTools.cc:16
MonitorElement * book1D(const char *name, const char *title, int nchX, double lowX, double highX)
Book 1D histogram.
Definition: DQMStore.cc:514
MonitorElement * NormOccupDDisk[10]
void beginJob(DQMStore *, std::string)
void beginRun(const edm::Run &, const edm::EventSetup &)
void labelXAxisSegment(MonitorElement *myMe)
Definition: utils.h:221
MonitorElement * EndCap_OccByRng
void getMonitorElements(std::vector< MonitorElement * > &, std::vector< RPCDetId > &)
#define NULL
Definition: scimark2.h:8
double getEntries(void) const
get # of entries
void endRun(const edm::Run &, const edm::EventSetup &)
std::vector< RPCDetId > myDetIds_
void Fill(long long x)
void endLuminosityBlock(edm::LuminosityBlock const &lumiSeg, edm::EventSetup const &c)
MonitorElement * NormOccupDWheel[5]
MonitorElement * Barrel_OccBySt
virtual ~RPCOccupancyTest()
int iEvent
Definition: GenABIO.cc:243
void beginLuminosityBlock(edm::LuminosityBlock const &lumiSeg, edm::EventSetup const &context)
int roll() const
Definition: RPCDetId.h:122
MonitorElement * NormOccupWheel[5]
void Fill(HcalDetId &id, double val, std::vector< TH2F > &depth)
int ring() const
Definition: RPCDetId.h:74
void removeElement(const std::string &name)
Definition: DQMStore.cc:2353
MonitorElement * AsyMeDisk[10]
std::string globalFolder_
unsigned int offset(bool)
void clientOperation(edm::EventSetup const &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:1265
void labelXAxisSector(MonitorElement *myMe)
Definition: utils.h:206
void fillGlobalME(RPCDetId &, MonitorElement *)
virtual int segment()
Definition: RPCGeomServ.cc:467
int detId2RollNr(const RPCDetId &_id)
Definition: utils.h:18
std::vector< uint32_t > TagList
Definition: DQMNet.h:82
MonitorElement * AsyMeDDisk[10]
int sector() const
Sector id: the group of chambers at same phi (and increasing r)
Definition: RPCDetId.h:104
std::string prefixDir_
void labelYAxisRoll(MonitorElement *myMe, int region, int ring)
Definition: utils.h:239
RPCOccupancyTest(const edm::ParameterSet &ps)
double getBinContent(int binx) const
get content of bin (1-D)
void analyze(const edm::Event &iEvent, const edm::EventSetup &c)
int getNbinsX(void) const
get # of bins in X-axis
std::vector< MonitorElement * > myOccupancyMe_
MonitorElement * book2D(const char *name, const char *title, int nchX, double lowX, double highX, int nchY, double lowY, double highY)
Book 2D histogram.
Definition: DQMStore.cc:642
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:232
void labelYAxisRing(MonitorElement *myMe, int numberOfRings)
Definition: utils.h:266
Definition: Run.h:32
MonitorElement * NormOccupDisk[10]
MonitorElement * AsyMeDWheel[5]
int region() const
Region id: 0 for Barrel, +/-1 For +/- Endcap.
Definition: RPCDetId.h:65
int station() const
Definition: RPCDetId.h:98