Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-05-31 22:35:53

0001 #include "DQM/RPCMonitorDigi/interface/RPCLinkSynchroHistoMaker.h"
0002 #include "DataFormats/RPCDigi/interface/RPCRawSynchro.h"
0003 
0004 #include <algorithm>
0005 #include <utility>
0006 
0007 struct OrderLbSpread {
0008   bool operator()(const std::pair<double, unsigned int>& lb1, const std::pair<double, unsigned int>& lb2) {
0009     return lb1.first > lb2.first;
0010   }
0011 };
0012 struct OrderLbOccup {
0013   bool operator()(const std::pair<unsigned int, unsigned int>& lb1, const std::pair<unsigned int, unsigned int>& lb2) {
0014     return lb1.first > lb2.first;
0015   }
0016 };
0017 
0018 void RPCLinkSynchroHistoMaker::fill(TH1F* hDelay, TH2F* hDelaySpread, TH2F* hTopOccup, TH2F* hTopSpread) const {
0019   hDelay->Reset();
0020   hDelaySpread->Reset();
0021   hTopOccup->Reset();
0022   hTopSpread->Reset();
0023 
0024   typedef std::vector<std::pair<unsigned int, unsigned int> > TopOccup;
0025   typedef std::vector<std::pair<double, unsigned int> > TopSpread;
0026   TopOccup topOccup(10, std::make_pair(0, 0));
0027   TopSpread topSpread(10, std::make_pair(0., 0));
0028 
0029   for (unsigned int idx = 0; idx < theLinkStat.theLinkStatMap.size(); ++idx) {
0030     const RPCLinkSynchroStat::BoardAndCounts& bc = theLinkStat.theLinkStatMap[idx];
0031 
0032     int sum = bc.second.sum();
0033     double rms = bc.second.rms();
0034 
0035     hDelaySpread->Fill(bc.second.mean() - 3., bc.second.rms());
0036 
0037     if (sum == 0)
0038       continue;
0039     for (int i = 0; i <= 7; ++i)
0040       hDelay->Fill(i - 3, bc.second.counts()[i]);
0041 
0042     std::pair<unsigned int, unsigned int> canOccup = std::make_pair(sum, idx);
0043     std::pair<double, unsigned int> canSpread = std::make_pair(rms, idx);
0044     TopOccup::iterator io = upper_bound(topOccup.begin(), topOccup.end(), canOccup, OrderLbOccup());
0045     TopSpread::iterator is = upper_bound(topSpread.begin(), topSpread.end(), canSpread, OrderLbSpread());
0046     if (io != topOccup.end()) {
0047       topOccup.insert(io, canOccup);
0048       topOccup.erase(topOccup.end() - 1);
0049     }
0050     if (is != topSpread.end()) {
0051       topSpread.insert(is, canSpread);
0052       topSpread.erase(topSpread.end() - 1);
0053     }
0054   }
0055 
0056   for (int itop = 0; itop < 10; itop++) {
0057     const RPCLinkSynchroStat::BoardAndCounts& occup = theLinkStat.theLinkStatMap[topOccup[itop].second];
0058     const RPCLinkSynchroStat::BoardAndCounts& spread = theLinkStat.theLinkStatMap[topSpread[itop].second];
0059     hTopOccup->GetYaxis()->SetBinLabel(itop + 1, occup.first.name().c_str());
0060     hTopSpread->GetYaxis()->SetBinLabel(itop + 1, spread.first.name().c_str());
0061     for (unsigned int icount = 0; icount < occup.second.counts().size(); icount++) {
0062       hTopOccup->SetBinContent(icount + 1, itop + 1, float(occup.second.counts()[icount]));
0063       hTopSpread->SetBinContent(icount + 1, itop + 1, float(spread.second.counts()[icount]));
0064     }
0065   }
0066 }