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
13 //#include "FWCore/ParameterSet/interface/ParameterSet.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  dbe_=0;
48 }
49 
51  edm::LogVerbatim ("rpceventsummary") << "[RPCEventSummary]: Begin job ";
53 }
54 
56  edm::LogVerbatim ("rpceventsummary") << "[RPCEventSummary]: Begin run";
57 
58  init_ = false;
60 
62 
63  int defaultValue = 1;
64 
65  if(0 != setup.find( recordKey ) ) {
66  defaultValue = -1;
67  //get fed summary information
69  setup.get<RunInfoRcd>().get(sumFED);
70  std::vector<int> FedsInIds= sumFED->m_fed_in;
71  unsigned int f = 0;
72  bool flag = false;
73  while(!flag && f < FedsInIds.size()) {
74  int fedID=FedsInIds[f];
75  //make sure fed id is in allowed range
76  if(fedID>=FEDRange_.first && fedID<=FEDRange_.second) {
77  defaultValue = 1;
78  flag = true;
79  }
80  f++;
81  }
82  }
83 
84 
85  MonitorElement* me;
87 
88  //a global summary float [0,1] providing a global summary of the status
89  //and showing the goodness of the data taken by the the sub-system
90  std::string histoName="reportSummary";
91  me =0;
92  me = dbe_->get(eventInfoPath_ +"/"+ histoName);
93  if ( 0!=me) {
94  dbe_->removeElement(me->getName());
95  }
96 
97  me = dbe_->bookFloat(histoName);
98  me->Fill(defaultValue);
99 
100  //TH2F ME providing a mapof values[0-1] to show if problems are localized or distributed
101  me =0;
102  me = dbe_->get(eventInfoPath_ +"/reportSummaryMap");
103  if ( 0!=me) {
104  dbe_->removeElement(me->getName());
105  }
106 
107  me = dbe_->book2D("reportSummaryMap", "RPC Report Summary Map", 15, -7.5, 7.5, 12, 0.5 ,12.5);
108 
109  //customize the 2d histo
110  std::stringstream BinLabel;
111  for (int i= 1 ; i<=15; i++){
112  BinLabel.str("");
113  if(i<13){
114  BinLabel<<"Sec"<<i;
115  me->setBinLabel(i,BinLabel.str(),2);
116  }
117 
118  BinLabel.str("");
119  if(i<5)
120  BinLabel<<"Disk"<<i-5;
121  else if(i>11)
122  BinLabel<<"Disk"<<i-11;
123  else if(i==11 || i==5)
124  BinLabel.str("");
125  else
126  BinLabel<<"Wheel"<<i-8;
127 
128  me->setBinLabel(i,BinLabel.str(),1);
129  }
130 
131  //fill the histo with "1" --- just for the moment
132  for(int i=1; i<=15; i++){
133  for (int j=1; j<=12; j++ ){
134  if(i==5 || i==11 || (j>6 && (i<6 || i>10)))
135  me->setBinContent(i,j,-1);//bins that not correspond to subdetector parts
136  else
137  me->setBinContent(i,j,defaultValue);
138  }
139  }
140 
141  if(numberDisk_ < 4)
142  for (int j=1; j<=12; j++ ){
143  me->setBinContent(1,j,-1);//bins that not correspond to subdetector parts
144  me->setBinContent(15,j,-1);
145  }
146 
147  //the reportSummaryContents folder containins a collection of ME floats [0-1] (order of 5-10)
148  // which describe the behavior of the respective subsystem sub-components.
149  dbe_->setCurrentFolder(eventInfoPath_+ "/reportSummaryContents");
150 
151  std::stringstream segName;
152  std::vector<std::string> segmentNames;
153  for(int i=-4; i<=4; i++){
154  if(i>-3 && i<3) {
155  segName.str("");
156  segName<<"RPC_Wheel"<<i;
157  segmentNames.push_back(segName.str());
158  }
159  if(i==0) continue;
160  segName.str("");
161  segName<<"RPC_Disk"<<i;
162  segmentNames.push_back(segName.str());
163  }
164 
165 
166  for(unsigned int i=0; i<segmentNames.size(); i++){
167  me =0;
168  me = dbe_->get(eventInfoPath_ + "/reportSummaryContents/" +segmentNames[i]);
169  if ( 0!=me) {
170  dbe_->removeElement(me->getName());
171  }
172  me = dbe_->bookFloat(segmentNames[i]);
173  me->Fill(defaultValue);
174  }
175 
176  //excluded endcap parts
177  if(numberDisk_ < 4){
178  me=dbe_->get(eventInfoPath_ + "/reportSummaryContents/RPC_Disk4");
179  if(me) me->Fill(-1);
180  me=dbe_->get(eventInfoPath_ + "/reportSummaryContents/RPC_Disk-4");
181  if(me) me->Fill(-1);
182  }
183 }
184 
186 
188 
190  edm::LogVerbatim ("rpceventsummary") <<"[RPCEventSummary]: End of LS transition, performing DQM client operation";
191 
192  if(offlineDQM_) return;
193 
194  if(!init_){
195  this->clientOperation();
196  return;
197  }
198 
199  lumiCounter_++;
200  if(lumiCounter_%prescaleFactor_ != 0) return;
201 
202  this->clientOperation();
203 
204 }
205 
207 
208  this->clientOperation();
209 }
210 
212 
213  float rpcevents = minimumEvents_;
214  RPCEvents = dbe_->get( prefixFolder_ +"/RPCEvents");
215 
216  if(RPCEvents) {
217  rpcevents = RPCEvents ->getBinContent(1);
218  }
219 
220 
221  if(rpcevents < minimumEvents_) return;
222  init_ = true;
223  std::stringstream meName;
224  MonitorElement * myMe;
225 
226  meName.str("");
227  meName<<eventInfoPath_ + "/reportSummaryMap";
228  MonitorElement * reportMe = dbe_->get(meName.str());
229 
230  MonitorElement * globalMe;
231 
232  //BARREL
233  float barrelFactor = 0;
234 
235  for(int w = -2 ; w<3; w++){
236 
237  meName.str("");
238  meName<<globalFolder_<<"/RPCChamberQuality_Roll_vs_Sector_Wheel"<<w;
239  myMe = dbe_->get(meName.str());
240 
241  if(myMe){
242  float wheelFactor = 0;
243 
244  for(int s = 1; s<=myMe->getNbinsX() ; s++){
245  float sectorFactor = 0;
246  int rollInSector = 0;
247 
248 
249  for(int r = 1;r<=myMe->getNbinsY(); r++){
250  if((s!=4 && r > 17 ) || ((s ==9 ||s ==10) && r >15 ) ) continue;
251  rollInSector++;
252 
253 
254  if(myMe->getBinContent(s,r) == PARTIALLY_DEAD) sectorFactor+=0.8;
255  else if(myMe->getBinContent(s,r) == DEAD )sectorFactor+=0;
256  else sectorFactor+=1;
257 
258  }
259  if(rollInSector!=0)
260  sectorFactor = sectorFactor/rollInSector;
261 
262  if(reportMe) reportMe->setBinContent(w+8, s, sectorFactor);
263  wheelFactor += sectorFactor;
264 
265  }//end loop on sectors
266 
267  wheelFactor = wheelFactor/myMe->getNbinsX();
268 
269  meName.str("");
270  meName<<eventInfoPath_ + "/reportSummaryContents/RPC_Wheel"<<w;
271  globalMe=dbe_->get(meName.str());
272  if(globalMe) globalMe->Fill(wheelFactor);
273 
274  barrelFactor += wheelFactor;
275  }//
276  }//end loop on wheel
277 
278  barrelFactor = barrelFactor/5;
279 
280 
281  float endcapFactor = 0;
282 
284 
285  //Endcap
286  for(int d = -numberDisk_ ; d<= numberDisk_; d++){
287  if (d==0) continue;
288 
289  meName.str("");
290  meName<<globalFolder_<<"/RPCChamberQuality_Ring_vs_Segment_Disk"<<d;
291  myMe = dbe_->get(meName.str());
292 
293  if(myMe){
294  float diskFactor = 0;
295 
296  float sectorFactor[6]= {0,0,0,0,0,0};
297 
298  for (int i = 0 ;i <6;i++){
299  int firstSeg = (i *6 )+1;
300  int lastSeg = firstSeg +6;
301  int rollInSector = 0;
302  for(int seg = firstSeg; seg< lastSeg ; seg++){
303 
304  for(int y = 1;y<=myMe->getNbinsY(); y++){
305  rollInSector++;
306  if(myMe->getBinContent(seg,y) == PARTIALLY_DEAD) sectorFactor[i]+=0.8;
307  else if(myMe->getBinContent(seg,y) == DEAD )sectorFactor[i]+=0;
308  else sectorFactor[i]+=1;
309 
310  }
311  }
312  sectorFactor[i] = sectorFactor[i]/rollInSector;
313  }//end loop on Sectors
314 
315 
316  for (int sec = 0 ; sec<6; sec++){
317  diskFactor += sectorFactor[sec];
318  if(reportMe) {
319  if (d<0) reportMe->setBinContent(d+5, sec+1 , sectorFactor[sec]);
320  else reportMe->setBinContent(d+11, sec+1 , sectorFactor[sec]);
321  }
322  }
323 
324  diskFactor = diskFactor/6;
325 
326  meName.str("");
327  meName<<eventInfoPath_ + "/reportSummaryContents/RPC_Disk"<<d;
328  globalMe=dbe_->get(meName.str());
329  if(globalMe) globalMe->Fill(diskFactor);
330 
331  endcapFactor += diskFactor;
332  }//end loop on disks
333 
334  }
335 
336  endcapFactor=endcapFactor/ (numberDisk_ * 2);
337 
338  }
339 
340  //Fill repor summary
341  float rpcFactor = barrelFactor;
342  if(doEndcapCertification_){ rpcFactor = ( barrelFactor + endcapFactor)/2; }
343 
344  globalMe = dbe_->get(eventInfoPath_ +"/reportSummary");
345  if(globalMe) globalMe->Fill(rpcFactor);
346 
347 
348 }
std::string eventInfoPath_
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 endLuminosityBlock(edm::LuminosityBlock const &lumiSeg, edm::EventSetup const &c)
End Lumi Block.
void endRun(const edm::Run &r, const edm::EventSetup &c)
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)
MonitorElement * bookFloat(const char *name)
Book float.
Definition: DQMStore.cc:879
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)
void analyze(const edm::Event &iEvent, const edm::EventSetup &c)
Analyze.
std::string globalFolder_
int iEvent
Definition: GenABIO.cc:230
void removeElement(const std::string &name)
Definition: DQMStore.cc:3093
int j
Definition: DBlmapReader.cc:9
double f[11][100]
MonitorElement * get(const std::string &path) const
get ME from full pathname (e.g. &quot;my/long/dir/my_histo&quot;)
Definition: DQMStore.cc:1696
virtual ~RPCEventSummary()
Destructor.
void beginRun(const edm::Run &r, const edm::EventSetup &c)
const T & get() const
Definition: EventSetup.h:55
MonitorElement * RPCEvents
RPCEventSummary(const edm::ParameterSet &ps)
Constructor.
void beginLuminosityBlock(edm::LuminosityBlock const &lumiSeg, edm::EventSetup const &context)
Begin Lumi block.
std::pair< int, int > FEDRange_
double getBinContent(int binx) const
get content of bin (1-D)
std::string prefixFolder_
void beginJob()
BeginJob.
int getNbinsX(void) const
get # of bins in X-axis
T w() const
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:1070
void setup(std::vector< TH2F > &depth, std::string name, std::string units="")
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:655
Definition: Run.h:41
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