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