CMS 3D CMS Logo

RPCEventSummary.cc
Go to the documentation of this file.
1 /* \author Anna Cimmino*/
2 #include <sstream>
3 
5 //CondFormats
8 // Framework
10 //#include "FWCore/Framework/interface/LuminosityBlock.h"
11 //#include "FWCore/Framework/interface/Event.h"
14 
15 
17  edm::LogVerbatim ("rpceventsummary") << "[RPCEventSummary]: Constructor";
18 
19  enableReportSummary_ = ps.getUntrackedParameter<bool>("EnableSummaryReport",true);
20  prescaleFactor_ = ps.getUntrackedParameter<int>("PrescaleFactor", 1);
21  eventInfoPath_ = ps.getUntrackedParameter<std::string>("EventInfoPath", "RPC/EventInfo");
22 
23 
24  std::string subsystemFolder = ps.getUntrackedParameter<std::string>("RPCFolder", "RPC");
25  std::string recHitTypeFolder = ps.getUntrackedParameter<std::string>("RecHitTypeFolder", "AllHits");
26  std::string summaryFolder = ps.getUntrackedParameter<std::string>("SummaryFolder", "SummaryHistograms");
27 
28  globalFolder_ = subsystemFolder +"/"+ recHitTypeFolder +"/"+ summaryFolder ;
29  prefixFolder_ = subsystemFolder +"/"+ recHitTypeFolder ;
30 
31  minimumEvents_= ps.getUntrackedParameter<int>("MinimumRPCEvents", 10000);
32  numberDisk_ = ps.getUntrackedParameter<int>("NumberOfEndcapDisks", 4);
33  doEndcapCertification_ = ps.getUntrackedParameter<bool>("EnableEndcapSummary", false);
34 
35  FEDRange_.first = ps.getUntrackedParameter<unsigned int>("MinimumRPCFEDId", 790);
36  FEDRange_.second = ps.getUntrackedParameter<unsigned int>("MaximumRPCFEDId", 792);
37 
38  NumberOfFeds_ =FEDRange_.second - FEDRange_.first +1;
39 
40  offlineDQM_ = ps.getUntrackedParameter<bool> ("OfflineDQM",true);
41 
42 
43 }
44 
46  edm::LogVerbatim ("rpceventsummary") << "[RPCEventSummary]: Destructor ";
47 }
48 
50  edm::LogVerbatim ("rpceventsummary") << "[RPCEventSummary]: Begin job ";
51  init_ = false;
52 }
53 
55 
56  edm::LogVerbatim ("rpceventsummary") << "[RPCEventSummary]: Begin run";
57 
58 
59  if(!init_){
61 
63 
64  int defaultValue = 1;
65  isIn_ = true;
66 
67  if(auto runInfoRec = setup.tryToGet<RunInfoRcd>()) {
68  defaultValue = -1;
69  //get fed summary information
71  runInfoRec->get(sumFED);
72  std::vector<int> FedsInIds= sumFED->m_fed_in;
73  unsigned int f = 0;
74  isIn_ = false;
75  while(!isIn_ && f < FedsInIds.size()) {
76  int fedID=FedsInIds[f];
77  //make sure fed id is in allowed range
78  if(fedID>=FEDRange_.first && fedID<=FEDRange_.second) {
79  defaultValue = 1;
80  isIn_ = true;
81  }
82  f++;
83  }
84  }
85 
86  MonitorElement* me;
88 
89  //a global summary float [0,1] providing a global summary of the status
90  //and showing the goodness of the data taken by the the sub-system
91  std::string histoName="reportSummary";
92  me=nullptr;
93  me = ibooker.bookFloat(histoName);
94  me->Fill(defaultValue);
95 
96  //TH2F ME providing a mapof values[0-1] to show if problems are localized or distributed
97  me=nullptr;
98  me = ibooker.book2D("reportSummaryMap", "RPC Report Summary Map", 15, -7.5, 7.5, 12, 0.5 ,12.5);
99 
100  //customize the 2d histo
101  std::stringstream BinLabel;
102  for (int i= 1 ; i<=15; i++){
103  BinLabel.str("");
104  if(i<13){
105  BinLabel<<"Sec"<<i;
106  me->setBinLabel(i,BinLabel.str(),2);
107  }
108 
109  BinLabel.str("");
110  if(i<5)
111  BinLabel<<"Disk"<<i-5;
112  else if(i>11)
113  BinLabel<<"Disk"<<i-11;
114  else if(i==11 || i==5)
115  BinLabel.str("");
116  else
117  BinLabel<<"Wheel"<<i-8;
118 
119  me->setBinLabel(i,BinLabel.str(),1);
120  }
121 
122  //fill the histo with "1" --- just for the moment
123  for(int i=1; i<=15; i++){
124  for (int j=1; j<=12; j++ ){
125  if(i==5 || i==11 || (j>6 && (i<6 || i>10)))
126  me->setBinContent(i,j,-1);//bins that not correspond to subdetector parts
127  else
128  me->setBinContent(i,j,defaultValue);
129  }
130  }
131 
132  if(numberDisk_ < 4)
133  for (int j=1; j<=12; j++ ){
134  me->setBinContent(1,j,-1);//bins that not correspond to subdetector parts
135  me->setBinContent(15,j,-1);
136  }
137 
138  //the reportSummaryContents folder containins a collection of ME floats [0-1] (order of 5-10)
139  // which describe the behavior of the respective subsystem sub-components.
140  ibooker.setCurrentFolder(eventInfoPath_+ "/reportSummaryContents");
141 
142  std::stringstream segName;
143  std::vector<std::string> segmentNames;
144  for(int i=-2; i<=2; i++){
145  segName.str("");
146  segName<<"RPC_Wheel"<<i;
147  segmentNames.push_back(segName.str());
148  }
149 
150  for(int i=-numberDisk_; i<=numberDisk_; i++){
151  if(i==0) continue;
152  segName.str("");
153  segName<<"RPC_Disk"<<i;
154  segmentNames.push_back(segName.str());
155  }
156 
157 
158  for(unsigned int i=0; i<segmentNames.size(); i++){
159  me =nullptr;
160  me = ibooker.bookFloat(segmentNames[i]);
161  me->Fill(defaultValue);
162  }
163 
165  init_ = true;
166  }
167 
168 
169 
171  this->clientOperation(igetter);
172  }
173 
174  lumiCounter_++;
175 
176 }
177 
178 
179 
181 
182  if(isIn_) { this->clientOperation(igetter);}
183 }
184 
186 
187  float rpcevents = minimumEvents_;
188  MonitorElement * RPCEvents ;
189  RPCEvents = igetter.get( prefixFolder_ +"/RPCEvents");
190 
191  if(RPCEvents) {
192  rpcevents = RPCEvents ->getBinContent(1);
193  }
194 
195 
196  if(rpcevents < minimumEvents_) return;
197  std::stringstream meName;
198  MonitorElement * myMe;
199 
200  meName.str("");
201  meName<<eventInfoPath_ + "/reportSummaryMap";
202  MonitorElement * reportMe = igetter.get(meName.str());
203 
204  MonitorElement * globalMe;
205 
206  //BARREL
207  float barrelFactor = 0;
208 
209  for(int w = -2 ; w<3; w++){
210 
211  meName.str("");
212  meName<<globalFolder_<<"/RPCChamberQuality_Roll_vs_Sector_Wheel"<<w;
213  myMe = igetter.get(meName.str());
214 
215  if(myMe){
216  float wheelFactor = 0;
217 
218  for(int s = 1; s<=myMe->getNbinsX() ; s++){
219  float sectorFactor = 0;
220  int rollInSector = 0;
221 
222 
223  for(int r = 1;r<=myMe->getNbinsY(); r++){
224  if((s!=4 && r > 17 ) || ((s ==9 ||s ==10) && r >15 ) ) continue;
225  rollInSector++;
226 
227 
228  if(myMe->getBinContent(s,r) == PARTIALLY_DEAD) sectorFactor+=0.8;
229  else if(myMe->getBinContent(s,r) == DEAD )sectorFactor+=0;
230  else sectorFactor+=1;
231 
232  }
233  if(rollInSector!=0)
234  sectorFactor = sectorFactor/rollInSector;
235 
236  if(reportMe) reportMe->setBinContent(w+8, s, sectorFactor);
237  wheelFactor += sectorFactor;
238 
239  }//end loop on sectors
240 
241  wheelFactor = wheelFactor/myMe->getNbinsX();
242 
243  meName.str("");
244  meName<<eventInfoPath_ + "/reportSummaryContents/RPC_Wheel"<<w;
245  globalMe=igetter.get(meName.str());
246  if(globalMe) globalMe->Fill(wheelFactor);
247 
248  barrelFactor += wheelFactor;
249  }//
250  }//end loop on wheel
251 
252  barrelFactor = barrelFactor/5;
253 
254 
255  float endcapFactor = 0;
256 
258 
259  //Endcap
260  for(int d = -numberDisk_ ; d<= numberDisk_; d++){
261  if (d==0) continue;
262 
263  meName.str("");
264  meName<<globalFolder_<<"/RPCChamberQuality_Ring_vs_Segment_Disk"<<d;
265  myMe = igetter.get(meName.str());
266 
267  if(myMe){
268  float diskFactor = 0;
269 
270  float sectorFactor[6]= {0,0,0,0,0,0};
271 
272  for (int i = 0 ;i <6;i++){
273  int firstSeg = (i *6 )+1;
274  int lastSeg = firstSeg +6;
275  int rollInSector = 0;
276  for(int seg = firstSeg; seg< lastSeg ; seg++){
277 
278  for(int y = 1;y<=myMe->getNbinsY(); y++){
279  rollInSector++;
280  if(myMe->getBinContent(seg,y) == PARTIALLY_DEAD) sectorFactor[i]+=0.8;
281  else if(myMe->getBinContent(seg,y) == DEAD )sectorFactor[i]+=0;
282  else sectorFactor[i]+=1;
283 
284  }
285  }
286  sectorFactor[i] = sectorFactor[i]/rollInSector;
287  }//end loop on Sectors
288 
289 
290  for (int sec = 0 ; sec<6; sec++){
291  diskFactor += sectorFactor[sec];
292  if(reportMe) {
293  if (d<0) reportMe->setBinContent(d+5, sec+1 , sectorFactor[sec]);
294  else reportMe->setBinContent(d+11, sec+1 , sectorFactor[sec]);
295  }
296  }
297 
298  diskFactor = diskFactor/6;
299 
300  meName.str("");
301  meName<<eventInfoPath_ + "/reportSummaryContents/RPC_Disk"<<d;
302  globalMe=igetter.get(meName.str());
303  if(globalMe) globalMe->Fill(diskFactor);
304 
305  endcapFactor += diskFactor;
306  }//end loop on disks
307 
308  }
309 
310  endcapFactor=endcapFactor/ (numberDisk_ * 2);
311 
312  }
313 
314  //Fill repor summary
315  float rpcFactor = barrelFactor;
316  if(doEndcapCertification_){ rpcFactor = ( barrelFactor + endcapFactor)/2; }
317 
318  globalMe = igetter.get(eventInfoPath_ +"/reportSummary");
319  if(globalMe) globalMe->Fill(rpcFactor);
320 
321 
322 }
std::string eventInfoPath_
T getUntrackedParameter(std::string const &, T const &) const
std::optional< T > tryToGet() const
Definition: EventSetup.h:87
void setBinContent(int binx, double content)
set content of bin (1-D)
const double w
Definition: UKUtility.cc:23
~RPCEventSummary() override
Destructor.
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)
def setup(process, global_tag, zero_tesla=False)
Definition: GeneralSetup.py:2
static HCTypeTag findType(char const *iTypeName)
find a type based on the types name, if not found will return default HCTypeTag
void dqmEndLuminosityBlock(DQMStore::IBooker &, DQMStore::IGetter &, edm::LuminosityBlock const &, edm::EventSetup const &) override
void beginJob() override
void Fill(long long x)
std::string globalFolder_
void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:268
std::vector< int > m_fed_in
Definition: RunInfo.h:26
double f[11][100]
void clientOperation(DQMStore::IGetter &igetter)
MonitorElement * get(std::string const &path)
Definition: DQMStore.cc:303
MonitorElement * book2D(Args &&...args)
Definition: DQMStore.h:109
void dqmEndJob(DQMStore::IBooker &, DQMStore::IGetter &) override
RPCEventSummary(const edm::ParameterSet &ps)
Constructor.
int getNbinsY() const
get # of bins in Y-axis
std::pair< int, int > FEDRange_
double getBinContent(int binx) const
get content of bin (1-D)
std::string prefixFolder_
int getNbinsX() const
get # of bins in X-axis
MonitorElement * bookFloat(Args &&...args)
Definition: DQMStore.h:105