CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
RPCChamberQuality.cc
Go to the documentation of this file.
1 #include <sstream>
5 // Framework
7 //DataFormats
9 
10 const std::string RPCChamberQuality::xLabels_[7] = {"Good", "OFF", "Nois.St","Nois.Ch","Part.Dead","Dead","Bad.Shape"};
11 const std::string RPCChamberQuality::regions_[3] = {"EndcapNegative","Barrel","EndcapPositive"};
12 
14  edm::LogVerbatim ("rpceventsummary") << "[RPCChamberQuality]: Constructor";
15 
16  prescaleFactor_ = ps.getUntrackedParameter<int>("PrescaleFactor", 5);
17 
18  std::string subsystemFolder = ps.getUntrackedParameter<std::string>("RPCFolder", "RPC");
19  std::string recHitTypeFolder = ps.getUntrackedParameter<std::string>("RecHitTypeFolder", "AllHits");
20  std::string summaryFolder = ps.getUntrackedParameter<std::string>("SummaryFolder", "SummaryHistograms");
21 
22  summaryDir_ = subsystemFolder +"/"+ recHitTypeFolder +"/"+ summaryFolder ;
23  prefixDir_ = subsystemFolder +"/"+ recHitTypeFolder ;
24 
25  enableDQMClients_ = ps.getUntrackedParameter<bool> ("EnableRPCDqmClient",true);
26 
27  minEvents = ps.getUntrackedParameter<int>("MinimumRPCEvents", 10000);
28  numberOfDisks_ = ps.getUntrackedParameter<int>("NumberOfEndcapDisks", 4);
29  useRollInfo_ = ps.getUntrackedParameter<bool> ("UseRollInfo",false);
30  offlineDQM_ = ps.getUntrackedParameter<bool> ("OfflineDQM",true);
31 }
32 
34  edm::LogVerbatim ("rpceventsummary") << "[RPCChamberQuality]: Destructor ";
35  if(! enableDQMClients_ ) return;
36  dbe_=0;
37 }
38 
40  edm::LogVerbatim ("rpceventsummary") << "[RPCChamberQuality]: Begin job ";
41  if(! enableDQMClients_ ) return;
43 }
44 
46  edm::LogVerbatim ("rpceventsummary") << "[RPCChamberQuality]: Begin run";
47  if(! enableDQMClients_ ) return;
48 
49  init_ = false;
51 
52  MonitorElement* me;
54 
55  std::stringstream histoName;
56 
57  rpcdqm::utils rpcUtils;
58 
59  for (int r = 0 ; r < 3; r++){
60 
61  histoName.str("");
62  histoName<<"RPCChamberQuality_"<<regions_[r];
63  me = dbe_->get(summaryDir_+"/"+ histoName.str());
64  if (0!=me) dbe_->removeElement(me->getName());
65  me = dbe_->book1D(histoName.str().c_str(), histoName.str().c_str(), 7, 0.5, 7.5);
66 
67  for (int x = 1; x <8 ; x++) me->setBinLabel(x, xLabels_[x-1]);
68  }
69 
70 
71  histoName.str("");
72  histoName<<"RPC_System_Quality_Overview";
73  me = dbe_->get(summaryDir_+"/"+ histoName.str());
74  if (0!=me) dbe_->removeElement(me->getName());
75  me = dbe_->book2D(histoName.str().c_str(), histoName.str().c_str(), 7, 0.5, 7.5, 3, 0.5, 3.5);
76  me->setBinLabel(1, "E+", 2);
77  me->setBinLabel(2, "B", 2);
78  me->setBinLabel(3, "E-", 2);
79 
80  for (int x = 1; x <8 ; x++) me->setBinLabel(x, xLabels_[x-1]);
81 
82  for(int w=-2; w<3;w++){//Loop on wheels
83 
84  histoName.str("");
85  histoName<<"RPCChamberQuality_Roll_vs_Sector_Wheel"<<w;
86  me = dbe_->get(summaryDir_+"/"+ histoName.str());
87  if (0!=me) dbe_->removeElement(me->getName());
88  me = dbe_->book2D(histoName.str().c_str(), histoName.str().c_str(), 12, 0.5, 12.5, 21, 0.5, 21.5);
89 
90  rpcUtils.labelXAxisSector( me);
91  rpcUtils.labelYAxisRoll(me, 0, w, useRollInfo_ );
92 
93  histoName.str("");
94  histoName<<"RPCChamberQuality_Distribution_Wheel"<<w;
95  me=0;
96  me = dbe_->get(summaryDir_+"/"+ histoName.str());
97  if (0!=me ) dbe_->removeElement(me->getName());
98  me = dbe_->book1D(histoName.str().c_str(), histoName.str().c_str(), 7, 0.5, 7.5);
99 
100  for (int x = 1; x <8; x++) me->setBinLabel(x, xLabels_[x-1]);
101  }//end loop on wheels
102 
103  for(int d= -numberOfDisks_; d<= numberOfDisks_ ; d++) { // Loop on disk
104  if(d==0) continue;
105  histoName.str("");
106  histoName<<"RPCChamberQuality_Ring_vs_Segment_Disk"<<d; // 2D histo for RPC Qtest
107  me = 0;
108  me = dbe_->get(summaryDir_+"/"+ histoName.str());
109  if (0!=me) {
110  dbe_->removeElement(me->getName());
111  }
112  me = dbe_->book2D(histoName.str().c_str(), histoName.str().c_str(), 36, 0.5, 36.5, 6, 0.5, 6.5);
113  rpcUtils.labelXAxisSegment(me);
114  rpcUtils.labelYAxisRing(me, 2, useRollInfo_ );
115 
116  histoName.str("");
117  histoName<<"RPCChamberQuality_Distribution_Disk"<<d;
118  me=0;
119  me = dbe_->get(summaryDir_+"/"+ histoName.str());
120  if (0!=me ) dbe_->removeElement(me->getName());
121  me = dbe_->book1D(histoName.str().c_str(), histoName.str().c_str(), 7, 0.5, 7.5);
122 
123  for (int x = 1; x <8 ; x++) me->setBinLabel(x, xLabels_[x-1]);
124  }
125 }
126 
128 
130 
132  edm::LogVerbatim ("rpceventsummary") <<"[RPCChamberQuality]: End Job, performing DQM client operation";
133  if(! enableDQMClients_ ) return;
134  this->fillMonitorElements();
135 
136 }
137 
139 
140  std::stringstream meName;
141 
142  meName.str("");
143  meName<<prefixDir_<<"/RPCEvents";
144  int rpcEvents=minEvents;
145  RpcEvents = dbe_->get(meName.str());
146 
147  if(RpcEvents) rpcEvents= (int)RpcEvents->getBinContent(1);
148 
149  if(rpcEvents >= minEvents){
150 
151  init_ = true;
152 
153  MonitorElement * summary[3];
154 
155  for(int r = 0 ; r < 3 ; r++) {
156  meName.str("");
157  meName<<summaryDir_<<"/RPCChamberQuality_"<<RPCChamberQuality::regions_[r];
158  summary[r] = dbe_ -> get(meName.str());
159 
160  if( summary[r] != 0 ) summary[r]->Reset();
161  }
162 
163  //Barrel
164  for (int wheel=-2; wheel<3; wheel++) { // loop by Wheels
165  meName.str("");
166  meName<<"Roll_vs_Sector_Wheel"<<wheel;
167 
168  this->performeClientOperation(meName.str(), 0 , summary[1]);
169  } // loop by Wheels
170 
171 
172  // Endcap
173  for(int i=-numberOfDisks_; i<=numberOfDisks_; i++) {//loop on Disks
174  if(i==0) continue;
175 
176  meName.str("");
177  meName<<"Ring_vs_Segment_Disk"<<i;
178 
179  if(i<0) this->performeClientOperation(meName.str(), -1 , summary[0]);
180  else this->performeClientOperation(meName.str(), 1 , summary[2]);
181  }//loop on Disks
182 
183  MonitorElement * RpcOverview = NULL;
184  meName.str("");
185  meName<<summaryDir_<<"/RPC_System_Quality_Overview";
186  RpcOverview = dbe_ -> get(meName.str());
187  RpcOverview->Reset();
188 
189  if(RpcOverview) {//Fill Overview ME
190  for(int r = 0 ; r< 3; r++) {
191  if (summary[r] == 0 ) continue;
192  double entries = summary[r]->getEntries();
193  if(entries == 0) continue;
194  for (int x = 1; x <= 7; x++) {
195  RpcOverview->setBinContent(x,r+1,(summary[r]->getBinContent(x)/entries));
196  }
197  }
198  } //loop by LimiBloks
199  }
200 }
201 
203 
204  if(!enableDQMClients_ ) return;
205 
206  if(offlineDQM_) return;
207 
208  if(!init_ ) {
209  this->fillMonitorElements();
210  return;
211  }
212 
213  lumiCounter_++;
214 
215  if (lumiCounter_%prescaleFactor_ != 0) return;
216 
217  this->fillMonitorElements();
218 
219 
220 }
221 
222 
224 
225 
226  MonitorElement * RCQ=NULL;
227  MonitorElement * RCQD=NULL;
228 
229  MonitorElement * DEAD=NULL;
230  MonitorElement * CLS=NULL;
231  MonitorElement * MULT=NULL;
232  MonitorElement * NoisySt=NULL;
233  MonitorElement * Chip=NULL;
234  MonitorElement * HV=NULL;
236  std::stringstream meName;
237 
238  meName.str("");
239  meName<<summaryDir_<<"/RPCChamberQuality_"<<MESufix;
240  RCQ = dbe_ -> get(meName.str());
241  // if (RCQ) RCQ->Reset();
242 
243 
244  int pos = MESufix.find_last_of("_");
245  meName.str("");
246  meName<<summaryDir_<<"/RPCChamberQuality_Distribution"<<MESufix.substr(pos);
247  RCQD = dbe_ -> get(meName.str());
248  if (RCQD) RCQD->Reset();
249 
250  //get HV Histo
251  meName.str("");
252  meName<<summaryDir_<<"/HVStatus_"<<MESufix;
253  HV = dbe_ -> get(meName.str());
254  //get LV Histo
255  meName.str("");
256  meName<<summaryDir_<<"/LVStatus_"<<MESufix;
257  LV = dbe_ -> get(meName.str());
258  //Dead
259  meName.str("");
260  meName << summaryDir_<<"/DeadChannelFraction_"<<MESufix;
261  DEAD = dbe_->get(meName.str());
262  //ClusterSize
263  meName.str("");
264  meName<<summaryDir_<<"/ClusterSizeIn1Bin_"<<MESufix;
265  CLS = dbe_ -> get(meName.str());
266  //NoisyStrips
267  meName.str("");
268  meName<<summaryDir_<<"/RPCNoisyStrips_"<<MESufix;
269  NoisySt = dbe_ -> get(meName.str());
270  //Multiplicity
271  meName.str("");
272  meName<<summaryDir_<<"/NumberOfDigi_Mean_"<<MESufix;
273  MULT = dbe_ -> get(meName.str());
274  //Asymetry
275  meName.str("");
276  meName<<summaryDir_<<"/AsymmetryLeftRight_"<<MESufix;
277  Chip = dbe_ -> get(meName.str());
278 
279  int xBinMax, yBinMax;
280 
281  if (region != 0) xBinMax = 37;
282  else xBinMax = 13;
283 
284  for(int x=1; x<xBinMax; x++) {
285  if (region != 0 ) {
286  yBinMax = 7;
287  }else {
288  if(x==4) yBinMax=22;
289  else if(x==9 || x==11) yBinMax=16;
290  else yBinMax=18;
291  }
292  for(int y=1; y<yBinMax; y++) {
293  int hv=1;
294  int lv=1;
295  float dead =0;
296  float firstbin= 0;
297  float noisystrips = 0;
298  float mult = 0;
299  float asy = 0;
300  chamberQualityState chamberState = GoodState;
301 
302  if(HV) hv = (int)HV ->getBinContent(x,y);
303  if(LV) lv = (int)LV ->getBinContent(x,y);
304 
305  if( hv!=1 || lv!=1) {
306  chamberState = OffState;
307  }else {
308  if(DEAD) dead= DEAD -> getBinContent(x,y);
309  if(dead>=0.80 ) {
310  chamberState = DeadState;
311  }else if (0.33<=dead && dead<0.80 ){
312  chamberState = PartiallyDeadState;
313  }else {
314  if(CLS ) firstbin = CLS -> getBinContent(x,y);
315  if(firstbin >= 0.88) {
316  chamberState = NoisyStripState;
317  } else {
318  if(NoisySt) noisystrips = NoisySt -> getBinContent(x,y);
319  if (noisystrips > 0){
320  chamberState = NoisyStripState;
321  }else {
322  if(MULT) mult = MULT -> getBinContent(x,y);
323  if(mult>=6) {
324  chamberState = NoisyRollState;
325  }else {
326  if (Chip) asy = Chip->getBinContent(x,y);
327  if(asy>0.35) {
328  chamberState = BadShapeState;
329  }else {
330  chamberState = GoodState;
331  }
332  }
333  }
334  }
335  }
336  }
337  if (RCQ) RCQ -> setBinContent(x,y, chamberState);
338  if (RCQD) RCQD -> Fill(chamberState);
339  if (quality) quality->Fill(chamberState);
340  }
341  }
342  return;
343 }
344 
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)
MonitorElement * book1D(const char *name, const char *title, int nchX, double lowX, double highX)
Book 1D histogram.
Definition: DQMStore.cc:964
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)
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
susybsm::HSCParticleRefVector hv
Definition: classes.h:28
void analyze(const edm::Event &iEvent, const edm::EventSetup &c)
static const std::string xLabels_[7]
double getEntries(void) const
get # of entries
void beginRun(const edm::Run &r, const edm::EventSetup &c)
std::string summaryDir_
virtual ~RPCChamberQuality()
void Fill(long long x)
math::XYZTLorentzVectorD LV
int iEvent
Definition: GenABIO.cc:230
void labelYAxisRing(MonitorElement *myMe, int numberOfRings, bool useRollInfo)
Definition: utils.h:295
void performeClientOperation(std::string, int, MonitorElement *)
RPCChamberQuality(const edm::ParameterSet &ps)
void Fill(HcalDetId &id, double val, std::vector< TH2F > &depth)
void removeElement(const std::string &name)
Definition: DQMStore.cc:3159
MonitorElement * get(const std::string &path) const
get ME from full pathname (e.g. &quot;my/long/dir/my_histo&quot;)
Definition: DQMStore.cc:1718
void labelXAxisSector(MonitorElement *myMe)
Definition: utils.h:236
MonitorElement * RpcEvents
static const std::string regions_[3]
std::string prefixDir_
double getBinContent(int binx) const
get content of bin (1-D)
void beginLuminosityBlock(edm::LuminosityBlock const &lumiSeg, edm::EventSetup const &context)
T w() const
Definition: DDAxes.h: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:1092
void endLuminosityBlock(edm::LuminosityBlock const &lumiSeg, edm::EventSetup const &c)
void Reset(void)
reset ME (ie. contents, errors, etc)
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:677
Definition: Run.h:41
void endRun(const edm::Run &r, const edm::EventSetup &c)