test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
RPCLinkSynchroHistoMaker.cc
Go to the documentation of this file.
4 
5 #include <sstream>
6 #include "TH1F.h"
7 #include "TH2F.h"
8 #include <algorithm>
9 #include <iostream>
10 
11 
12 struct OrderLbSpread { bool operator() (const std::pair<double,unsigned int> & lb1, const std::pair<double,unsigned int> & lb2) { return lb1.first > lb2.first; } };
13 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; } };
14 
15 void RPCLinkSynchroHistoMaker::fill(TH1F* hDelay, TH2F* hDelaySpread, TH2F* hTopOccup, TH2F* hTopSpread) const
16 {
17  hDelay->Reset();
18  hDelaySpread->Reset();
19  hTopOccup->Reset();
20  hTopSpread->Reset();
21 
22  typedef std::vector< std::pair<unsigned int, unsigned int> > TopOccup;
23  typedef std::vector< std::pair<double, unsigned int> > TopSpread;
24  TopOccup topOccup(10,std::make_pair(0,0));
25  TopSpread topSpread(10,std::make_pair(0.,0));
26 
27  for (unsigned int idx=0; idx < theLinkStat.theLinkStatMap.size(); ++idx) {
29 
30  int sum = bc.second.sum();
31  double rms = bc.second.rms();
32 
33  hDelaySpread->Fill(bc.second.mean()-3.,bc.second.rms());
34 
35  if (sum==0) continue;
36  for (int i=0; i<=7; ++i) hDelay->Fill(i-3,bc.second.counts()[i]);
37 
38  std::pair<unsigned int, unsigned int> canOccup = std::make_pair(sum, idx);
39  std::pair<double, unsigned int> canSpread = std::make_pair(rms, idx);
40  TopOccup::iterator io = upper_bound(topOccup.begin(), topOccup.end(), canOccup, OrderLbOccup());
41  TopSpread::iterator is = upper_bound(topSpread.begin(), topSpread.end(), canSpread, OrderLbSpread());
42  if (io != topOccup.end()) {
43  topOccup.insert(io,canOccup);
44  topOccup.erase(topOccup.end()-1);
45  }
46  if (is != topSpread.end()) {
47  topSpread.insert(is,canSpread);
48  topSpread.erase(topSpread.end()-1);
49  }
50  }
51 
52  for (int itop=0; itop<10; itop++) {
53  const RPCLinkSynchroStat::BoardAndCounts & occup = theLinkStat.theLinkStatMap[topOccup[itop].second];
54  const RPCLinkSynchroStat::BoardAndCounts & spread = theLinkStat.theLinkStatMap[topSpread[itop].second];
55  hTopOccup->GetYaxis()->SetBinLabel(itop+1,occup.first.name().c_str());
56  hTopSpread->GetYaxis()->SetBinLabel(itop+1,spread.first.name().c_str());
57  for (unsigned int icount=0; icount<occup.second.counts().size(); icount++) {
58  hTopOccup->SetBinContent(icount+1, itop+1, float(occup.second.counts()[icount]));
59  hTopSpread->SetBinContent(icount+1, itop+1, float(spread.second.counts()[icount]));
60  }
61  }
62 // for (int j=0; j<10; j++) { cout <<"topSpread["<<j<<"] = "<<topSpread[j].first<<endl; }
63 // for (int j=0; j<10; j++) { cout <<"topOccup["<<j<<"] = "<<topOccup[j].first<<endl; }
64 
65 }
66 
bool operator()(const std::pair< unsigned int, unsigned int > &lb1, const std::pair< unsigned int, unsigned int > &lb2)
int i
Definition: DBlmapReader.cc:9
const RPCLinkSynchroStat & theLinkStat
std::pair< LinkBoard, SynchroCounts > BoardAndCounts
bool operator()(const std::pair< double, unsigned int > &lb1, const std::pair< double, unsigned int > &lb2)
tuple idx
DEBUGGING if hasattr(process,&quot;trackMonIterativeTracking2012&quot;): print &quot;trackMonIterativeTracking2012 D...
void fill(TH1F *hDelay, TH2F *hDelaySpread, TH2F *hTopOccup, TH2F *hTopSpread) const
std::vector< BoardAndCounts > theLinkStatMap