CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_5_3_13_patch3/src/DQM/RPCMonitorClient/src/RPCLinkSynchroHistoMaker.cc

Go to the documentation of this file.
00001 #include "DQM/RPCMonitorClient/interface/RPCLinkSynchroHistoMaker.h"
00002 #include "DataFormats/RPCDigi/interface/RPCRawSynchro.h"
00003 #include "CondFormats/RPCObjects/interface/RPCReadOutMapping.h"
00004 
00005 #include <sstream>
00006 #include "TH1F.h"
00007 #include "TH2F.h"
00008 #include <algorithm>
00009 #include <iostream>
00010 
00011 
00012 struct OrderLbSpread { bool operator() (const std::pair<double,unsigned int> & lb1, const std::pair<double,unsigned int> & lb2) { return lb1.first > lb2.first; } };
00013 struct OrderLbOccup  { bool operator() (const std::pair<unsigned int,unsigned int> & lb1, const std::pair<unsigned int,unsigned int> & lb2) { return lb1.first > lb2.first; } };
00014 
00015 void RPCLinkSynchroHistoMaker::fill(TH1F* hDelay, TH2F* hDelaySpread, TH2F* hTopOccup, TH2F* hTopSpread) const
00016 {
00017   hDelay->Reset();
00018   hDelaySpread->Reset();
00019   hTopOccup->Reset();
00020   hTopSpread->Reset();
00021 
00022   typedef std::vector< std::pair<unsigned int, unsigned int> > TopOccup;
00023   typedef std::vector< std::pair<double, unsigned int> > TopSpread;
00024   TopOccup topOccup(10,std::make_pair(0,0));  
00025   TopSpread topSpread(10,std::make_pair(0.,0));
00026 
00027   for (unsigned int idx=0; idx < theLinkStat.theLinkStatMap.size(); ++idx) {
00028     const RPCLinkSynchroStat::BoardAndCounts & bc = theLinkStat.theLinkStatMap[idx]; 
00029 
00030     int sum = bc.second.sum();
00031     double rms =  bc.second.rms();
00032 
00033     hDelaySpread->Fill(bc.second.mean()-3.,bc.second.rms());
00034 
00035     if (sum==0) continue; 
00036     for (int i=0; i<=7; ++i) hDelay->Fill(i-3,bc.second.counts()[i]);
00037 
00038     std::pair<unsigned int, unsigned int> canOccup =  std::make_pair(sum, idx);
00039     std::pair<double, unsigned int>      canSpread =  std::make_pair(rms, idx);
00040     TopOccup::iterator io = upper_bound(topOccup.begin(), topOccup.end(), canOccup, OrderLbOccup()); 
00041     TopSpread::iterator is = upper_bound(topSpread.begin(), topSpread.end(), canSpread, OrderLbSpread()); 
00042     if (io != topOccup.end()) { 
00043       topOccup.insert(io,canOccup);
00044       topOccup.erase(topOccup.end()-1);
00045     }
00046     if (is != topSpread.end()) {
00047       topSpread.insert(is,canSpread);
00048       topSpread.erase(topSpread.end()-1);
00049     }
00050   }
00051 
00052   for (int itop=0; itop<10; itop++) {
00053     const RPCLinkSynchroStat::BoardAndCounts & occup  = theLinkStat.theLinkStatMap[topOccup[itop].second];
00054     const RPCLinkSynchroStat::BoardAndCounts & spread = theLinkStat.theLinkStatMap[topSpread[itop].second];
00055     hTopOccup->GetYaxis()->SetBinLabel(itop+1,occup.first.name().c_str());
00056     hTopSpread->GetYaxis()->SetBinLabel(itop+1,spread.first.name().c_str());
00057     for (unsigned int icount=0; icount<occup.second.counts().size(); icount++) {
00058       hTopOccup->SetBinContent(icount+1, itop+1, float(occup.second.counts()[icount]));
00059       hTopSpread->SetBinContent(icount+1, itop+1, float(spread.second.counts()[icount]));
00060     }
00061   }
00062 //  for (int j=0; j<10; j++) { cout <<"topSpread["<<j<<"] = "<<topSpread[j].first<<endl; }
00063 //  for (int j=0; j<10; j++) { cout <<"topOccup["<<j<<"] = "<<topOccup[j].first<<endl; }
00064 
00065 }
00066