CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
RPCMonitorRaw.cc
Go to the documentation of this file.
2 
3 
8 
12 
17 
18 #include "TH1F.h"
19 #include "TH2F.h"
20 #include "TFile.h"
21 
22 #include <fstream>
23 #include <iostream>
24 #include <iomanip>
25 #include <bitset>
26 
27 typedef std::map< std::pair<int,int>, int>::const_iterator IT;
28 
30  : theConfig(cfg),
31  rpcRawDataCountsTag_(cfg.getParameter<edm::InputTag>("rpcRawDataCountsTag"))
32 {
33  for (unsigned int i=0; i<10;i++) theWatchedErrorHistoPos[i]=0;
34  std::vector<int> algos = cfg.getUntrackedParameter<std::vector<int> >("watchedErrors");
35  for (std::vector<int>::const_iterator it=algos.begin();it!= algos.end(); ++it) {
36  unsigned int ialgo = *it;
37  if (ialgo < 10) theWatchedErrorHistoPos[ialgo]=1; // real position initialisain is in begin job. here mark just switched on.
38  }
39 }
40 
41 RPCMonitorRaw::~RPCMonitorRaw() { LogTrace("") << "RPCMonitorRaw destructor"; }
42 
44 {
45 
46 // Get DQM interface
47  DQMStore* theDMBE = edm::Service<DQMStore>().operator->();
48 
49  theDMBE->setCurrentFolder("RPC/LinkMonitor");
50 
51  me_t[0]=theDMBE->book1D("recordType_790",RPCRawDataCountsHistoMaker::emptyRecordTypeHisto(790));
52  me_t[1]=theDMBE->book1D("recordType_791",RPCRawDataCountsHistoMaker::emptyRecordTypeHisto(791));
53  me_t[2]=theDMBE->book1D("recordType_792",RPCRawDataCountsHistoMaker::emptyRecordTypeHisto(792));
54  for (int i=0;i<3;++i)me_t[i]->getTH1F()->SetStats(0);
55 
56  me_e[0]=theDMBE->book1D("readoutErrors_790",RPCRawDataCountsHistoMaker::emptyReadoutErrorHisto(790));
57  me_e[1]=theDMBE->book1D("readoutErrors_791",RPCRawDataCountsHistoMaker::emptyReadoutErrorHisto(791));
58  me_e[2]=theDMBE->book1D("readoutErrors_792",RPCRawDataCountsHistoMaker::emptyReadoutErrorHisto(792));
59  for (int i=0;i<3;++i)me_e[i]->getTH1F()->SetStats(0);
60 
61  me_mapGoodEvents=theDMBE->book2D("mapGoodRecords","mapGoodRecords",36,-0.5,35.5, 3, 789.5,792.5);
62  me_mapGoodEvents->getTH2F()->SetNdivisions(3,"y");
63  me_mapGoodEvents->getTH2F()->SetXTitle("rmb");
64  me_mapGoodEvents->getTH2F()->SetYTitle("fed");
65  me_mapGoodEvents->getTH2F()->SetStats(0);
66  me_mapBadEvents =theDMBE->book2D("mapErrorRecords", "mapErrorRecords", 36,-0.5,35.5, 3, 789.5,792.5);
67  me_mapBadEvents->getTH2F()->SetXTitle("fed");
68  me_mapBadEvents->getTH2F()->SetYTitle("rmb");
69  me_mapBadEvents->getTH2F()->SetNdivisions(3,"y");
70  me_mapBadEvents->getTH2F()->SetStats(0);
71 
72  for (unsigned int i=0; i<=9; ++i) {
74  for (unsigned int fed=790; fed <=792; ++fed) {
76  MonitorElement* watched = theDMBE->book2D(histo->GetName(),histo);
77  theWatchedErrorHistos[fed-790].push_back(watched);
79  }
80  }
81  }
82 
83 }
85 {
86 bool writeHistos = theConfig.getUntrackedParameter<bool>("writeHistograms", false);
87  if (writeHistos) {
89  TFile f(histoFile.c_str(),"RECREATE");
90  for (int i=0; i<3; ++i) {
91  me_t[i]->getTH1F()->Write();
92  me_e[i]->getTH1F()->Write();
93  std::vector<MonitorElement* > & wh = theWatchedErrorHistos[i];
94  for (std::vector<MonitorElement* >::const_iterator it=wh.begin(); it != wh.end(); ++it)(*it)->getTH2F()->Write();
95  }
96  me_mapGoodEvents->getTH2F()->Write();
97  me_mapBadEvents->getTH2F()->Write();
98  edm::LogInfo(" END JOB, histos saved!");
99  f.Close();
100  }
101 }
102 
103 
105 {
106 
108  ev.getByLabel(rpcRawDataCountsTag_, rawCounts);
109  const RPCRawDataCounts & counts = *rawCounts.product();
110 
111  //
112  // record type
113  //
114  for (IT it=counts.theRecordTypes.begin(); it != counts.theRecordTypes.end(); ++it)
115  me_t[it->first.first-790]->Fill(it->first.second,it->second);
116 
117  //
118  // good events topology
119  //
120  for (IT it = counts.theGoodEvents.begin(); it != counts.theGoodEvents.end(); ++it)
121  me_mapGoodEvents->Fill(it->first.second, it->first.first, it->second);
122 
123  //
124  // bad events topology
125  //
126  for (IT it = counts.theBadEvents.begin(); it != counts.theBadEvents.end(); ++it)
127  me_mapBadEvents->Fill(it->first.second, it->first.first, it->second);
128 
129 
130  //
131  // readout errors
132  //
133  for (IT it=counts.theReadoutErrors.begin(); it != counts.theReadoutErrors.end(); ++it) {
134  rpcrawtodigi::ReadoutError error(it->first.second);
135  LinkBoardElectronicIndex ele = error.where();
137 
138  int fed = it->first.first;
139  me_e[fed-790]->Fill(type, it->second);
140 
141  //
142  // in addition fill location map for selected errors
143  //
145  if ( idx >= 0) {
146  std::vector<MonitorElement* > & wh = theWatchedErrorHistos[fed-790];
147  MonitorElement* me = wh[idx];
148  me->Fill(ele.dccInputChannelNum, ele.tbLinkInputNum, it->second);
149  }
150  }
151 
152 
153 // for (int i=0; i<3; ++i) {
154 // me_t[i]->update();
155 // me_e[i]->update();
156 // std::vector<MonitorElement* > & wh = theWatchedErrorHistos[i];
157 // for (std::vector<MonitorElement* >::iterator it=wh.begin(); it != wh.end(); ++it) (*it)->update();
158 // }
159 // me_mapGoodEvents->update();
160 // me_mapBadEvents->update();
161 
162 
163 
164 }
std::map< std::pair< int, int >, int > theReadoutErrors
LinkBoardElectronicIndex where() const
Definition: ReadoutError.cc:20
type
Definition: HCALResponse.h:21
TFile * histoFile
Definition: hcalCalib.cc:45
T getUntrackedParameter(std::string const &, T const &) const
int i
Definition: DBlmapReader.cc:9
MonitorElement * book1D(const char *name, const char *title, int nchX, double lowX, double highX)
Book 1D histogram.
Definition: DQMStore.cc:722
MonitorElement * me_mapBadEvents
Definition: RPCMonitorRaw.h:36
std::vector< MonitorElement * > theWatchedErrorHistos[3]
Definition: RPCMonitorRaw.h:39
static TH1F * emptyReadoutErrorHisto(int fedId)
ReadoutErrorType type() const
Definition: ReadoutError.cc:14
void Fill(long long x)
MonitorElement * me_mapGoodEvents
Definition: RPCMonitorRaw.h:35
MonitorElement * me_t[3]
Definition: RPCMonitorRaw.h:33
virtual void endJob()
static TH2F * emptyReadoutErrorMapHisto(int fedId, int type)
virtual ~RPCMonitorRaw()
edm::ParameterSet theConfig
Definition: RPCMonitorRaw.h:38
virtual void beginJob()
RPCMonitorRaw(const edm::ParameterSet &cfg)
double f[11][100]
TH1F * getTH1F(std::string name, std::string process, std::string rootfolder, DQMStore *dbe_, bool verb, bool clone)
std::map< std::pair< int, int >, int > theGoodEvents
std::vector< LinkConnSpec >::const_iterator IT
unsigned int theWatchedErrorHistoPos[10]
Definition: RPCMonitorRaw.h:42
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:361
#define LogTrace(id)
std::map< std::pair< int, int >, int > theRecordTypes
virtual void analyze(const edm::Event &, const edm::EventSetup &)
get data, convert to digis attach againe to Event
tuple idx
DEBUGGING if hasattr(process,&quot;trackMonIterativeTracking2012&quot;): print &quot;trackMonIterativeTracking2012 D...
TH1F * getTH1F(void) const
T const * product() const
Definition: Handle.h:74
static TH1F * emptyRecordTypeHisto(int fedId)
edm::InputTag rpcRawDataCountsTag_
Definition: RPCMonitorRaw.h:47
std::map< std::pair< int, int >, int > theBadEvents
TH2F * getTH2F(void) 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:850
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:434
MonitorElement * me_e[3]
Definition: RPCMonitorRaw.h:34