CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
RPCNoisyStripTest.cc
Go to the documentation of this file.
3 
4 //DQM Services
5 //#include "DQMServices/Core/interface/DQMStore.h"
6 
7 // Framework
9 //#include <FWCore/Framework/interface/ESHandle.h>
10 
11 //Geometry
13 
14 
16  edm::LogVerbatim ("rpcnoisetest") << "[RPCNoisyStripTest]: Constructor";
17 
18  prescaleFactor_ = ps.getUntrackedParameter<int>("DiagnosticPrescale", 1);
19  numberOfDisks_ = ps.getUntrackedParameter<int>("NumberOfEndcapDisks", 4);
20  numberOfRings_ = ps.getUntrackedParameter<int>("NumberOfEndcapRings", 2);
21  useRollInfo_ = ps.getUntrackedParameter<bool>("UseRollInfo", false);
22  testMode_ = ps.getUntrackedParameter<bool>("testMode", false);
23 
24 }
25 
27 
29  edm::LogVerbatim ("rpcnoisetest") << "[RPCNoisyStripTest]: Begin job ";
30  dbe_ = dbe;
31 
32  globalFolder_ = workingFolder;
33 }
34 
36  edm::LogVerbatim ("rpcnoisetest") << "[RPCNoisyStripTest]: End run";
37 }
38 
39 
41 
43 
45 
47 
48  edm::LogVerbatim ("rpcnoisetest") <<"[RPCNoisyStripTest]: Client Operation";
49 
50  //Loop on MEs
51  for (unsigned int i = 0 ; i<myOccupancyMe_.size();i++){
52  this->fillGlobalME(myDetIds_[i],myOccupancyMe_[i], iSetup);
53  }//End loop on MEs
54 
55 }
56 
58 
59 
60  MonitorElement* me;
62 
63  std::stringstream histoName;
64 
65  rpcdqm::utils rpcUtils;
66 
67  for (int w = -2; w<= 2;w++ ){//loop on wheels and disks
68 
69  if(testMode_){
70  histoName.str("");
71  histoName<<"RPCNoisyStrips_Distribution_Wheel"<<w;
72  me =0;
73  me = dbe_->get( globalFolder_ +"/"+ histoName.str());
74  if ( 0!=me ) {
75  dbe_->removeElement(me->getName());
76  }
77  NOISEDWheel[w+2] = dbe_->book1D(histoName.str().c_str(), histoName.str().c_str(), 6, -0.5, 5.5);
78 
79 
80  histoName.str("");
81  histoName<<"RPCStripsDeviation_Distribution_Wheel"<<w;
82  me =0;
83  me = dbe_->get( globalFolder_ +"/"+ histoName.str());
84  if ( 0!=me ) {
85  dbe_->removeElement(me->getName());
86  }
87  DEVDWheel[w+2] = dbe_->book1D(histoName.str().c_str(), histoName.str().c_str(), 101, -0.01, 10.01);
88  }
89 
90  histoName.str("");
91  histoName<<"RPCNoisyStrips_Roll_vs_Sector_Wheel"<<w;
92  me =0;
93  me = dbe_->get( globalFolder_ +"/"+ histoName.str());
94  if ( 0!=me ) {
95  dbe_->removeElement(me->getName());
96  }
97 
98  NOISEWheel[w+2] = dbe_->book2D(histoName.str().c_str(), histoName.str().c_str() , 12, 0.5, 12.5, 21, 0.5, 21.5);
99  rpcUtils.labelXAxisSector(NOISEWheel[w+2]);
100  rpcUtils.labelYAxisRoll(NOISEWheel[w+2], 0, w, useRollInfo_);
101  }
102 
103 
104 
105  for(int d = -numberOfDisks_; d<=numberOfDisks_; d++ ){//ENDCAP
106 
107  if (d == 0) continue;
108 
109  int offset = numberOfDisks_;
110  if (d>0) offset --;
111 
112  if (testMode_){
113  histoName.str("");
114  histoName<<"RPCNoisyStrips_Distribution_Disk"<<d;
115  me =0;
116  me = dbe_->get( globalFolder_ +"/"+ histoName.str());
117  if ( 0!=me ) {
118  dbe_->removeElement(me->getName());
119  }
120  NOISEDDisk[d+offset] = dbe_->book1D(histoName.str().c_str(), histoName.str().c_str(), 6, -0.5, 5.5);
121 
122 
123  histoName.str("");
124  histoName<<"RPCStripsDeviation_Distribution_Disk"<<d;
125  me =0;
126  me = dbe_->get( globalFolder_ +"/"+ histoName.str());
127  if ( 0!=me ) {
128  dbe_->removeElement(me->getName());
129  }
130  DEVDDisk[d+offset] = dbe_->book1D(histoName.str().c_str(), histoName.str().c_str(), 101, -0.01, 10.01);
131  }
132 
133  histoName.str("");
134  histoName<<"RPCNoisyStrips_Ring_vs_Segment_Disk"<<d;
135  me =0;
136  me = dbe_->get( globalFolder_ +"/"+ histoName.str());
137  if ( 0!=me ) {
138  dbe_->removeElement(me->getName());
139  }
140 
141  NOISEDisk[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);
142  rpcUtils.labelXAxisSegment(NOISEDisk[d+offset]);
143  rpcUtils.labelYAxisRing(NOISEDisk[d+offset], numberOfRings_, useRollInfo_);
144 
145  }
146 
147 }
148 
149 
150 void RPCNoisyStripTest::getMonitorElements(std::vector<MonitorElement *> & meVector, std::vector<RPCDetId> & detIdVector){
151 
152  //Get NumberOfDigi ME for each roll
153  for (unsigned int i = 0 ; i<meVector.size(); i++){
154 
155  bool flag= false;
156 
157  DQMNet::TagList tagList;
158  tagList = meVector[i]->getTags();
159  DQMNet::TagList::iterator tagItr = tagList.begin();
160 
161  while (tagItr != tagList.end() && !flag ) {
162  if((*tagItr) == rpcdqm::OCCUPANCY)
163  flag= true;
164 
165  tagItr++;
166  }
167 
168  if(flag){
169  myOccupancyMe_.push_back(meVector[i]);
170  myDetIds_.push_back(detIdVector[i]);
171  }
172  }
173 
174 }
175 
177 
179 
180  // ESHandle<RPCGeometry> rpcgeo;
181 // iSetup.get<MuonGeometryRecord>().get(rpcgeo);
182 
183  std::stringstream meName;
184 
186  MonitorElement * DEVD=NULL;
187  MonitorElement * NOISED=NULL;
188 
189  if (detId.region()==0) { //BARREL
190  NOISE = NOISEWheel[detId.ring()+2];
191  if(testMode_) {
192  DEVD = DEVDWheel[detId.ring()+2];
193  NOISED= NOISEDWheel[detId.ring()+2];
194  }
195  }else if(detId.region()<0 && (-detId.station() + numberOfDisks_) >= 0 ){//ENDCAP-
196  NOISE = NOISEDisk[ -detId.station() + numberOfDisks_];
197  if(testMode_) {
198  DEVD = DEVDDisk[ -detId.station() + numberOfDisks_];
199  NOISED= NOISEDDisk[-detId.station() + numberOfDisks_];
200  }
201  }else if((-detId.station() + numberOfDisks_)>= 0 ){//ENDCAP +
202  NOISE = NOISEDisk[detId.station() + numberOfDisks_-1];
203  if(testMode_) {
204  DEVD = DEVDDisk[detId.station() + numberOfDisks_-1];
205  NOISED= NOISEDDisk[detId.station() + numberOfDisks_-1];
206  }
207  }
208 
209 
210  int entries = (int) myMe -> getEntries();
211  int bins = (int) myMe ->getNbinsX();
212 
213  std::vector<float> myvector;
214 
215  // count alive strips and alive strip values put in the vector
216  for(int xbin =1 ; xbin <= bins ; xbin++) {
217  float binContent = myMe->getBinContent(xbin);
218  if (binContent > 0) myvector.push_back(binContent);
219  }
220 
221 
222  int noisyStrips=0;
223  // calculate mean on YAxis and check diff between bins and mean
224  if (myvector.size()>0) {
225  float ymean = entries/myvector.size(); //mean on Yaxis
226  for(unsigned int i=0; i<myvector.size(); i++) {
227  float deviation = myvector[i]/ymean;
228  if(deviation > 3.5) noisyStrips++;
229  if(deviation > 5) deviation = 5; //overflow
230  if(DEVD) DEVD-> Fill(deviation);
231  }
232 
233 
234  int xBin,yBin;
235  if(detId.region()==0){//Barrel
236  xBin= detId.sector();
237  rpcdqm::utils rollNumber;
238  yBin = rollNumber.detId2RollNr(detId);
239  }else{//Endcap
240  //get segment number
241  RPCGeomServ RPCServ(detId);
242  xBin = RPCServ.segment();
243  (numberOfRings_ == 3 ? yBin= detId.ring()*3-detId.roll()+1 : yBin= (detId.ring()-1)*3-detId.roll()+1);
244  }
245 
246  if(NOISE) NOISE->setBinContent(xBin,yBin,noisyStrips);
247  if(NOISED) NOISED ->Fill(noisyStrips);
248 
249  }
250 
251 }
252 
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)
void fillGlobalME(RPCDetId &, MonitorElement *, edm::EventSetup const &)
const double w
Definition: UKUtility.cc:23
MonitorElement * book1D(const char *name, const char *title, int nchX, double lowX, double highX)
Book 1D histogram.
Definition: DQMStore.cc:954
tuple yBin
Definition: cuy.py:891
void beginRun(const edm::Run &, const edm::EventSetup &)
void labelXAxisSegment(MonitorElement *myMe)
Definition: utils.h:250
void labelYAxisRoll(MonitorElement *myMe, int region, int ring, bool useRollInfo)
Definition: utils.h:268
#define NULL
Definition: scimark2.h:8
MonitorElement * NOISEDDisk[10]
std::string globalFolder_
void Fill(long long x)
std::vector< RPCDetId > myDetIds_
RPCNoisyStripTest(const edm::ParameterSet &ps)
void clientOperation(edm::EventSetup const &c)
void analyze(const edm::Event &iEvent, const edm::EventSetup &c)
int iEvent
Definition: GenABIO.cc:230
void labelYAxisRing(MonitorElement *myMe, int numberOfRings, bool useRollInfo)
Definition: utils.h:295
int roll() const
Definition: RPCDetId.h:120
std::vector< MonitorElement * > myOccupancyMe_
MonitorElement * NOISEDWheel[5]
void Fill(HcalDetId &id, double val, std::vector< TH2F > &depth)
int ring() const
Definition: RPCDetId.h:72
void removeElement(const std::string &name)
Definition: DQMStore.cc:3143
void getMonitorElements(std::vector< MonitorElement * > &, std::vector< RPCDetId > &)
unsigned int offset(bool)
MonitorElement * get(const std::string &path) const
get ME from full pathname (e.g. &quot;my/long/dir/my_histo&quot;)
Definition: DQMStore.cc:1708
void labelXAxisSector(MonitorElement *myMe)
Definition: utils.h:236
void endRun(const edm::Run &, const edm::EventSetup &)
virtual ~RPCNoisyStripTest()
void beginJob(DQMStore *, std::string)
MonitorElement * DEVDWheel[5]
virtual int segment()
Definition: RPCGeomServ.cc:467
int detId2RollNr(const RPCDetId &_id)
Definition: utils.h:18
std::vector< uint32_t > TagList
Definition: DQMNet.h:84
MonitorElement * NOISEDisk[10]
int sector() const
Sector id: the group of chambers at same phi (and increasing r)
Definition: RPCDetId.h:102
double getBinContent(int binx) const
get content of bin (1-D)
void beginLuminosityBlock(edm::LuminosityBlock const &lumiSeg, edm::EventSetup const &context)
void endLuminosityBlock(edm::LuminosityBlock const &lumiSeg, edm::EventSetup const &c)
MonitorElement * DEVDDisk[10]
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:1082
MonitorElement * NOISEWheel[5]
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:667
Definition: Run.h:41
int region() const
Region id: 0 for Barrel, +/-1 For +/- Endcap.
Definition: RPCDetId.h:63
int station() const
Definition: RPCDetId.h:96