CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 
66  if(0 != setup.find( recordKey ) ) {
67  defaultValue = -1;
68  //get fed summary information
70  setup.get<RunInfoRcd>().get(sumFED);
71  std::vector<int> FedsInIds= sumFED->m_fed_in;
72  unsigned int f = 0;
73  bool flag = false;
74  while(!flag && f < FedsInIds.size()) {
75  int fedID=FedsInIds[f];
76  //make sure fed id is in allowed range
77  if(fedID>=FEDRange_.first && fedID<=FEDRange_.second) {
78  defaultValue = 1;
79  flag = true;
80  }
81  f++;
82  }
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=0;
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=0;
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 =0;
160  me = ibooker.bookFloat(segmentNames[i]);
161  me->Fill(defaultValue);
162  }
163 
165  init_ = true;
166  }
167 
168 
170  this->clientOperation(igetter);
171  }
172 
173  lumiCounter_++;
174 
175 }
176 
177 
178 
180 
181  this->clientOperation(igetter);
182 }
183 
185 
186  float rpcevents = minimumEvents_;
187  MonitorElement * RPCEvents ;
188  RPCEvents = igetter.get( prefixFolder_ +"/RPCEvents");
189 
190  if(RPCEvents) {
191  rpcevents = RPCEvents ->getBinContent(1);
192  }
193 
194 
195  if(rpcevents < minimumEvents_) return;
196  std::stringstream meName;
197  MonitorElement * myMe;
198 
199  meName.str("");
200  meName<<eventInfoPath_ + "/reportSummaryMap";
201  MonitorElement * reportMe = igetter.get(meName.str());
202 
203  MonitorElement * globalMe;
204 
205  //BARREL
206  float barrelFactor = 0;
207 
208  for(int w = -2 ; w<3; w++){
209 
210  meName.str("");
211  meName<<globalFolder_<<"/RPCChamberQuality_Roll_vs_Sector_Wheel"<<w;
212  myMe = igetter.get(meName.str());
213 
214  if(myMe){
215  float wheelFactor = 0;
216 
217  for(int s = 1; s<=myMe->getNbinsX() ; s++){
218  float sectorFactor = 0;
219  int rollInSector = 0;
220 
221 
222  for(int r = 1;r<=myMe->getNbinsY(); r++){
223  if((s!=4 && r > 17 ) || ((s ==9 ||s ==10) && r >15 ) ) continue;
224  rollInSector++;
225 
226 
227  if(myMe->getBinContent(s,r) == PARTIALLY_DEAD) sectorFactor+=0.8;
228  else if(myMe->getBinContent(s,r) == DEAD )sectorFactor+=0;
229  else sectorFactor+=1;
230 
231  }
232  if(rollInSector!=0)
233  sectorFactor = sectorFactor/rollInSector;
234 
235  if(reportMe) reportMe->setBinContent(w+8, s, sectorFactor);
236  wheelFactor += sectorFactor;
237 
238  }//end loop on sectors
239 
240  wheelFactor = wheelFactor/myMe->getNbinsX();
241 
242  meName.str("");
243  meName<<eventInfoPath_ + "/reportSummaryContents/RPC_Wheel"<<w;
244  globalMe=igetter.get(meName.str());
245  if(globalMe) globalMe->Fill(wheelFactor);
246 
247  barrelFactor += wheelFactor;
248  }//
249  }//end loop on wheel
250 
251  barrelFactor = barrelFactor/5;
252 
253 
254  float endcapFactor = 0;
255 
257 
258  //Endcap
259  for(int d = -numberDisk_ ; d<= numberDisk_; d++){
260  if (d==0) continue;
261 
262  meName.str("");
263  meName<<globalFolder_<<"/RPCChamberQuality_Ring_vs_Segment_Disk"<<d;
264  myMe = igetter.get(meName.str());
265 
266  if(myMe){
267  float diskFactor = 0;
268 
269  float sectorFactor[6]= {0,0,0,0,0,0};
270 
271  for (int i = 0 ;i <6;i++){
272  int firstSeg = (i *6 )+1;
273  int lastSeg = firstSeg +6;
274  int rollInSector = 0;
275  for(int seg = firstSeg; seg< lastSeg ; seg++){
276 
277  for(int y = 1;y<=myMe->getNbinsY(); y++){
278  rollInSector++;
279  if(myMe->getBinContent(seg,y) == PARTIALLY_DEAD) sectorFactor[i]+=0.8;
280  else if(myMe->getBinContent(seg,y) == DEAD )sectorFactor[i]+=0;
281  else sectorFactor[i]+=1;
282 
283  }
284  }
285  sectorFactor[i] = sectorFactor[i]/rollInSector;
286  }//end loop on Sectors
287 
288 
289  for (int sec = 0 ; sec<6; sec++){
290  diskFactor += sectorFactor[sec];
291  if(reportMe) {
292  if (d<0) reportMe->setBinContent(d+5, sec+1 , sectorFactor[sec]);
293  else reportMe->setBinContent(d+11, sec+1 , sectorFactor[sec]);
294  }
295  }
296 
297  diskFactor = diskFactor/6;
298 
299  meName.str("");
300  meName<<eventInfoPath_ + "/reportSummaryContents/RPC_Disk"<<d;
301  globalMe=igetter.get(meName.str());
302  if(globalMe) globalMe->Fill(diskFactor);
303 
304  endcapFactor += diskFactor;
305  }//end loop on disks
306 
307  }
308 
309  endcapFactor=endcapFactor/ (numberDisk_ * 2);
310 
311  }
312 
313  //Fill repor summary
314  float rpcFactor = barrelFactor;
315  if(doEndcapCertification_){ rpcFactor = ( barrelFactor + endcapFactor)/2; }
316 
317  globalMe = igetter.get(eventInfoPath_ +"/reportSummary");
318  if(globalMe) globalMe->Fill(rpcFactor);
319 
320 
321 }
std::string eventInfoPath_
T getUntrackedParameter(std::string const &, T const &) const
int i
Definition: DBlmapReader.cc:9
void setBinContent(int binx, double content)
set content of bin (1-D)
const double w
Definition: UKUtility.cc:23
MonitorElement * get(const std::string &path)
Definition: DQMStore.cc:298
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)
const eventsetup::EventSetupRecord * find(const eventsetup::EventSetupRecordKey &) const
Definition: EventSetup.cc:90
int getNbinsY(void) const
get # of bins in Y-axis
void Fill(long long x)
std::string globalFolder_
int j
Definition: DBlmapReader.cc:9
double f[11][100]
void clientOperation(DQMStore::IGetter &igetter)
virtual ~RPCEventSummary()
Destructor.
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:274
MonitorElement * book2D(Args &&...args)
Definition: DQMStore.h:133
void dqmEndJob(DQMStore::IBooker &, DQMStore::IGetter &) override
const T & get() const
Definition: EventSetup.h:55
RPCEventSummary(const edm::ParameterSet &ps)
Constructor.
std::pair< int, int > FEDRange_
void dqmEndLuminosityBlock(DQMStore::IBooker &, DQMStore::IGetter &, edm::LuminosityBlock const &, edm::EventSetup const &)
double getBinContent(int binx) const
get content of bin (1-D)
std::string prefixFolder_
int getNbinsX(void) const
get # of bins in X-axis
MonitorElement * bookFloat(Args &&...args)
Definition: DQMStore.h:109
void setup(std::vector< TH2F > &depth, std::string name, std::string units="")
static HCTypeTag findType(char const *iTypeName)
find a type based on the types name, if not found will return default HCTypeTag
Definition: HCTypeTag.cc:125