CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
L1TFED.cc
Go to the documentation of this file.
1 /*
2  * \file L1TFED.cc
3  *
4  * $Date: 2010/04/06 01:14:46 $
5  * $Revision: 1.15 $
6  * \author J. Berryhill
7  *
8  */
9 
15 
16 using namespace std;
17 using namespace edm;
18 
20 {
21 
22  // verbosity switch
23  verbose_ = ps.getUntrackedParameter<bool>("verbose", false);
24  rawl_ = ps.getParameter< InputTag >("rawTag");
25  if(verbose_) cout << "L1TFED: constructor...." << endl;
26 
27 
28  dbe = NULL;
29  if ( ps.getUntrackedParameter<bool>("DQMStore", false) )
30  {
31  dbe = Service<DQMStore>().operator->();
32  dbe->setVerbose(0);
33  }
34 
35  outputFile_ = ps.getUntrackedParameter<string>("outputFile", "");
36  if ( outputFile_.size() != 0 ) {
37  cout << "L1T Monitoring histograms will be saved to " << outputFile_.c_str() << endl;
38  }
39 
40  bool disable = ps.getUntrackedParameter<bool>("disableROOToutput", false);
41  if(disable){
42  outputFile_="";
43  }
44 
45  l1feds_ = ps.getParameter<std::vector<int> >("L1FEDS");
46 
47  directory_ = ps.getUntrackedParameter<std::string>("FEDDirName","L1T/FEDIntegrity");
48 
49 
50  if ( dbe !=NULL ) {
51  dbe->setCurrentFolder(directory_);
52  }
53 
54  stableROConfig_ = ps.getUntrackedParameter<bool>("stableROConfig", true);
55 }
56 
58 {
59 }
60 
61 void L1TFED::beginJob(void)
62 {
63 
64  nev_ = 0;
65 
66  // get hold of back-end interface
67  DQMStore* dbe = 0;
68  dbe = Service<DQMStore>().operator->();
69 
70  if ( dbe ) {
71  dbe->setCurrentFolder(directory_);
72  dbe->rmdir(directory_);
73  }
74 
75 
76  if ( dbe )
77  {
78  dbe->setCurrentFolder(directory_);
79 
80  fedentries = dbe->book1D("FEDEntries", "Fed ID occupancy", l1feds_.size(), 0.,l1feds_.size() );
81  fedfatal = dbe->book1D("FEDFatal", "Fed ID non present ", l1feds_.size(), 0., l1feds_.size());
82  fednonfatal = dbe->book1D("FEDNonFatal", "Fed corrupted data ", l1feds_.size(), 0.,l1feds_.size() );
83  hfedprof = dbe->bookProfile("fedprofile","FED Size by ID", l1feds_.size(), 0., l1feds_.size(),0,0.,5000.);
84  for(unsigned int i=0;i<l1feds_.size();i++){
85  ostringstream sfed;
86  sfed << l1feds_[i];
87  fedentries->setBinLabel(i+1,"FED "+ sfed.str());
88  fedfatal->setBinLabel(i+1,"FED "+ sfed.str());
89  fednonfatal->setBinLabel(i+1,"FED "+ sfed.str());
90 // hfedprof->getTProfile()->GetXaxis()->SetBinLabel(i+1,"FED "+ sfed.str());
91 
92  }
93 
94  hfedsize = dbe->book1D("fedsize","FED Size Distribution",100,0.,10000.);
95 
96  }
97 }
98 
99 
100 void L1TFED::endJob(void)
101 {
102 
103  if(verbose_) std::cout << "L1T FED Integrity: end job...." << std::endl;
104  LogInfo("EndJob") << "analyzed " << nev_ << " events";
105 
106  if ( outputFile_.size() != 0 && dbe ) dbe->save(outputFile_);
107 
108  return;
109 }
110 
111 void L1TFED::analyze(const Event& e, const EventSetup& c)
112 {
113  nev_++;
114  if(verbose_) cout << "L1T FED Integrity: analyze...." << endl;
115 
117  bool t = e.getByLabel(rawl_,rawdata);
118 
119  if ( ! t ) {
120  if(verbose_) cout << "can't find FEDRawDataCollection "<< endl;
121  }
122 
123  else {
124 
125  if(verbose_) cout << "fedlist size = " << l1feds_.size() << endl;
126 
127  for (unsigned int i = 0; i<l1feds_.size(); i++){
128  int fedId = l1feds_[i];
129  if(verbose_) cout << "fedId = " << fedId << endl;
130 
131  const FEDRawData & data = rawdata->FEDData(fedId);
132 
133  if(size_t size=data.size()){
134 
135  fedentries->Fill(i);
136  hfedsize->Fill(float(size));
137  hfedprof->Fill(float(i),float(size));
138  if(verbose_) cout << "header check = " << FEDHeader(data.data()).check() << endl;
139  if(verbose_) cout << "trailer check = " << FEDTrailer(data.data()).check() << endl;
140 
141  if(!FEDHeader(data.data()).check()) fedfatal->Fill(i);
142 
143 // if(!FEDHeader(data.data()).check() || !FEDTrailer(data.data()).check()) fedfatal->Fill(i);
144 // fedtrailer check seems to be always 0.
145 
146 // for fedId dedicated integrity checks.
147 /* switch(fedId){
148 
149  case 813:
150  std::cout << "do something for GT 813 data corruption..." << std::endl; continue;
151  fednonfatal->Fill(fedId);
152 
153  case 814:
154  std::cout << "do something for GT 814 data corruption..." << std::endl; continue;
155  fednonfatal->Fill(fedId);
156  }
157 */
158  } else {
159 
160  if(verbose_) cout << "empty fed " << i << endl;
161  if(stableROConfig_) fedfatal->Fill(i);
162 
163  }
164  }
165 
166  }
167 
168 }
169 
170 
void endJob(void)
Definition: L1TFED.cc:100
T getParameter(std::string const &) const
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:717
void rmdir(const std::string &fullpath)
Definition: DQMStore.cc:2530
void beginJob(void)
Definition: L1TFED.cc:61
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)
#define NULL
Definition: scimark2.h:8
void analyze(const edm::Event &e, const edm::EventSetup &c)
Definition: L1TFED.cc:111
size_t size() const
Lenght of the data buffer in bytes.
Definition: FEDRawData.h:49
bool check(const DataFrame &df, bool capcheck, bool dvercheck)
virtual ~L1TFED()
Definition: L1TFED.cc:57
MonitorElement * bookProfile(const char *name, const char *title, int nchX, double lowX, double highX, int nchY, double lowY, double highY, const char *option="s")
Definition: DQMStore.cc:1031
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:356
L1TFED(const edm::ParameterSet &ps)
Definition: L1TFED.cc:19
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
const unsigned char * data() const
Return a const pointer to the beginning of the data buffer.
Definition: FEDRawData.cc:29
tuple cout
Definition: gather_cfg.py:121
dictionary rawdata
Definition: lumiPlot.py:393
tuple size
Write out results.
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:429