CMS 3D CMS Logo

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 ("rpcchamberquality") << "[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  init_ = false;
33  lumiCounter_ = 0;
34 }
35 
37  edm::LogVerbatim ("rpcchamberquality") << "[RPCChamberQuality]: Destructor ";
38 }
39 
41  edm::LogVerbatim ("rpcchamberquality") << "[RPCChamberQuality]: Begin job ";
42 }
43 
44 
45 
47 
48  edm::LogVerbatim ("rpcchamberquality") <<"[RPCChamberQuality]: End Lumi Block";
49 
50  if( enableDQMClients_ && !offlineDQM_ ) {
51 
52  edm::LogVerbatim ("rpcchamberquality") <<"[RPCChamberQuality]: Performing DQM client operation";
53 
54  if (lumiCounter_==0){ //book histograms during at firt LB end
55  this->myBooker(ibooker);
57  }
58 
59  if (lumiCounter_%prescaleFactor_ == 0){//Fill histograms every N=prescaleFactor_ LBs
60  this->fillMonitorElements(igetter);
61  }
62  }
63  lumiCounter_++;
64 }
65 
66 
67 
69 
70  edm::LogVerbatim ("rpcchamberquality") <<"[RPCChamberQuality]: End Job";
71 
72  if( enableDQMClients_ ) {
73  edm::LogVerbatim ("rpcchamberquality") <<"[RPCChamberQuality]: Performing DQM client operation";
74  if( offlineDQM_ && !init_ ) {this->myBooker(ibooker);}
75  if(init_){this->fillMonitorElements(igetter);}
76  }
77 }
78 
79 
80 
82 
83  init_ = true;
84 
86 
87  MonitorElement* me;
88  std::stringstream histoName;
89 
90  rpcdqm::utils rpcUtils;
91 
92  for (int r = 0 ; r < 3; r++){
93 
94  histoName.str("");
95  histoName<<"RPCChamberQuality_"<<regions_[r];
96  me = ibooker.book1D(histoName.str().c_str(), histoName.str().c_str(), 7, 0.5, 7.5);
97 
98  for (int x = 1; x <8 ; x++) {me->setBinLabel(x, xLabels_[x-1]);}
99  }
100 
101 
102  histoName.str("");
103  histoName<<"RPC_System_Quality_Overview";
104  me = ibooker.book2D(histoName.str().c_str(), histoName.str().c_str(), 7, 0.5, 7.5, 3, 0.5, 3.5);
105  me->setBinLabel(1, "E-", 2);
106  me->setBinLabel(2, "B", 2);
107  me->setBinLabel(3, "E+", 2);
108 
109  for (int x = 1; x <8 ; x++) {me->setBinLabel(x, xLabels_[x-1]);}
110 
111  for(int w=-2; w<3;w++){//Loop on wheels
112 
113  histoName.str("");
114  histoName<<"RPCChamberQuality_Roll_vs_Sector_Wheel"<<w;
115  me = ibooker.book2D(histoName.str().c_str(), histoName.str().c_str(), 12, 0.5, 12.5, 21, 0.5, 21.5);
116 
117  rpcUtils.labelXAxisSector( me);
118  rpcUtils.labelYAxisRoll(me, 0, w, useRollInfo_ );
119 
120  histoName.str("");
121  histoName<<"RPCChamberQuality_Distribution_Wheel"<<w;
122  me = ibooker.book1D(histoName.str().c_str(), histoName.str().c_str(), 7, 0.5, 7.5);
123 
124  for (int x = 1; x <8; x++) {me->setBinLabel(x, xLabels_[x-1]);}
125  }//end loop on wheels
126 
127  for(int d= -numberOfDisks_; d<= numberOfDisks_ ; d++) { // Loop on disk
128  if(d==0) continue;
129  histoName.str("");
130  histoName<<"RPCChamberQuality_Ring_vs_Segment_Disk"<<d; // 2D histo for RPC Qtest
131  me = ibooker.book2D(histoName.str().c_str(), histoName.str().c_str(), 36, 0.5, 36.5, 6, 0.5, 6.5);
132  rpcUtils.labelXAxisSegment(me);
133  rpcUtils.labelYAxisRing(me, 2, useRollInfo_ );
134 
135  histoName.str("");
136  histoName<<"RPCChamberQuality_Distribution_Disk"<<d;
137  me = ibooker.book1D(histoName.str().c_str(), histoName.str().c_str(), 7, 0.5, 7.5);
138 
139  for (int x = 1; x <8 ; x++) {me->setBinLabel(x, xLabels_[x-1]);}
140  }
141 }
142 
143 
144 
146 
147  std::stringstream meName;
148 
149  meName.str("");
150  meName<<prefixDir_<<"/RPCEvents";
151  int rpcEvents=minEvents;
152  RpcEvents = igetter.get(meName.str());
153 
154  if(RpcEvents) rpcEvents= (int)RpcEvents->getBinContent(1);
155 
156  if(rpcEvents >= minEvents){
157 
158  init_ = true;
159 
160  MonitorElement * summary[3];
161 
162  for(int r = 0 ; r < 3 ; r++) {
163  meName.str("");
164  meName<<summaryDir_<<"/RPCChamberQuality_"<<RPCChamberQuality::regions_[r];
165  summary[r] = igetter.get(meName.str());
166 
167  if( summary[r] != 0 ) summary[r]->Reset();
168  }
169 
170  //Barrel
171  for (int wheel=-2; wheel<3; wheel++) { // loop by Wheels
172  meName.str("");
173  meName<<"Roll_vs_Sector_Wheel"<<wheel;
174 
175  this->performeClientOperation(meName.str(), 0 , summary[1],igetter);
176  } // loop by Wheels
177 
178 
179  // Endcap
180  for(int i=-numberOfDisks_; i<=numberOfDisks_; i++) {//loop on Disks
181  if(i==0) continue;
182 
183  meName.str("");
184  meName<<"Ring_vs_Segment_Disk"<<i;
185 
186  if(i<0) this->performeClientOperation(meName.str(), -1 , summary[0],igetter);
187  else this->performeClientOperation(meName.str(), 1 , summary[2],igetter);
188  }//loop on Disks
189 
190  MonitorElement * RpcOverview = NULL;
191  meName.str("");
192  meName<<summaryDir_<<"/RPC_System_Quality_Overview";
193  RpcOverview = igetter.get(meName.str());
194  RpcOverview->Reset();
195 
196  if(RpcOverview) {//Fill Overview ME
197  for(int r = 0 ; r< 3; r++) {
198  if (summary[r] == 0 ) continue;
199  double entries = summary[r]->getEntries();
200  if(entries == 0) continue;
201  for (int x = 1; x <= 7; x++) {
202  RpcOverview->setBinContent(x,r+1,(summary[r]->getBinContent(x)/entries));
203  }
204  }
205  } //loop by LimiBloks
206  }
207 }
208 
209 
210 
211 
212 
213 
215 
216 
217  MonitorElement * RCQ=NULL;
218  MonitorElement * RCQD=NULL;
219 
220  MonitorElement * DEAD=NULL;
221  MonitorElement * CLS=NULL;
222  MonitorElement * MULT=NULL;
223  MonitorElement * NoisySt=NULL;
224  MonitorElement * Chip=NULL;
225  MonitorElement * HV=NULL;
227  std::stringstream meName;
228 
229  meName.str("");
230  meName<<summaryDir_<<"/RPCChamberQuality_"<<MESufix;
231  RCQ = igetter.get(meName.str());
232  // if (RCQ) RCQ->Reset();
233 
234 
235  int pos = MESufix.find_last_of("_");
236  meName.str("");
237  meName<<summaryDir_<<"/RPCChamberQuality_Distribution"<<MESufix.substr(pos);
238  RCQD = igetter.get(meName.str());
239  if (RCQD) RCQD->Reset();
240 
241  //get HV Histo
242  meName.str("");
243  meName<<summaryDir_<<"/HVStatus_"<<MESufix;
244  HV = igetter.get(meName.str());
245  //get LV Histo
246  meName.str("");
247  meName<<summaryDir_<<"/LVStatus_"<<MESufix;
248  LV = igetter.get(meName.str());
249  //Dead
250  meName.str("");
251  meName << summaryDir_<<"/DeadChannelFraction_"<<MESufix;
252  DEAD = igetter.get(meName.str());
253  //ClusterSize
254  meName.str("");
255  meName<<summaryDir_<<"/ClusterSizeIn1Bin_"<<MESufix;
256  CLS = igetter.get(meName.str());
257  //NoisyStrips
258  meName.str("");
259  meName<<summaryDir_<<"/RPCNoisyStrips_"<<MESufix;
260  NoisySt = igetter.get(meName.str());
261  //Multiplicity
262  meName.str("");
263  meName<<summaryDir_<<"/NumberOfDigi_Mean_"<<MESufix;
264  MULT = igetter.get(meName.str());
265  //Asymetry
266  meName.str("");
267  meName<<summaryDir_<<"/AsymmetryLeftRight_"<<MESufix;
268  Chip = igetter.get(meName.str());
269 
270  int xBinMax, yBinMax;
271 
272  if (region != 0) xBinMax = 37;
273  else xBinMax = 13;
274 
275  for(int x=1; x<xBinMax; x++) {
276  if (region != 0 ) {
277  yBinMax = 7;
278  }else {
279  if(x==4) yBinMax=22;
280  else if(x==9 || x==11) yBinMax=16;
281  else yBinMax=18;
282  }
283  for(int y=1; y<yBinMax; y++) {
284  int hv=1;
285  int lv=1;
286  float dead =0;
287  float firstbin= 0;
288  float noisystrips = 0;
289  float mult = 0;
290  float asy = 0;
291  chamberQualityState chamberState = GoodState;
292 
293  if(HV) hv = (int)HV ->getBinContent(x,y);
294  if(LV) lv = (int)LV ->getBinContent(x,y);
295 
296  if( hv!=1 || lv!=1) {
297  chamberState = OffState;
298  }else {
299  if(DEAD) dead= DEAD -> getBinContent(x,y);
300  if(dead>=0.80 ) {
301  chamberState = DeadState;
302  }else if (0.33<=dead && dead<0.80 ){
303  chamberState = PartiallyDeadState;
304  }else {
305  if(CLS ) firstbin = CLS -> getBinContent(x,y);
306  if(firstbin >= 0.88) {
307  chamberState = NoisyStripState;
308  } else {
309  if(NoisySt) noisystrips = NoisySt -> getBinContent(x,y);
310  if (noisystrips > 0){
311  chamberState = NoisyStripState;
312  }else {
313  if(MULT) mult = MULT -> getBinContent(x,y);
314  if(mult>=6) {
315  chamberState = NoisyRollState;
316  }else {
317  if (Chip) asy = Chip->getBinContent(x,y);
318  if(asy>0.35) {
319  chamberState = BadShapeState;
320  }else {
321  chamberState = GoodState;
322  }
323  }
324  }
325  }
326  }
327  }
328  if (RCQ) RCQ -> setBinContent(x,y, chamberState);
329  if (RCQD) RCQD -> Fill(chamberState);
330  if (quality) quality->Fill(chamberState);
331  }
332  }
333  return;
334 }
335 
T getUntrackedParameter(std::string const &, T const &) const
void beginJob() override
const double w
Definition: UKUtility.cc:23
MonitorElement * get(const std::string &path)
Definition: DQMStore.cc:305
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
static const std::string xLabels_[7]
double getEntries(void) const
get # of entries
std::string summaryDir_
void fillMonitorElements(DQMStore::IGetter &)
virtual ~RPCChamberQuality()
void Fill(long long x)
math::XYZTLorentzVectorD LV
void labelYAxisRing(MonitorElement *myMe, int numberOfRings, bool useRollInfo)
Definition: utils.h:295
void dqmEndLuminosityBlock(DQMStore::IBooker &, DQMStore::IGetter &, edm::LuminosityBlock const &, edm::EventSetup const &) override
RPCChamberQuality(const edm::ParameterSet &ps)
void Fill(HcalDetId &id, double val, std::vector< TH2F > &depth)
MonitorElement * book1D(Args &&...args)
Definition: DQMStore.h:115
void labelXAxisSector(MonitorElement *myMe)
Definition: utils.h:236
void performeClientOperation(std::string, int, MonitorElement *, DQMStore::IGetter &)
void dqmEndJob(DQMStore::IBooker &, DQMStore::IGetter &) override
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:277
MonitorElement * book2D(Args &&...args)
Definition: DQMStore.h:133
MonitorElement * RpcEvents
static const std::string regions_[3]
std::string prefixDir_
double getBinContent(int binx) const
get content of bin (1-D)
void Reset(void)
reset ME (ie. contents, errors, etc)
void myBooker(DQMStore::IBooker &)