Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:10:39

0001 /*
0002  * \file L1TFED.cc
0003  *
0004  * \author J. Berryhill
0005  *
0006  */
0007 
0008 #include "DQM/L1TMonitor/interface/L1TFED.h"
0009 
0010 using namespace std;
0011 using namespace edm;
0012 
0013 L1TFED::L1TFED(const ParameterSet& ps) {
0014   // verbosity switch
0015   verbose_ = ps.getUntrackedParameter<bool>("verbose", false);
0016   l1feds_ = ps.getParameter<std::vector<int> >("L1FEDS");
0017   directory_ = ps.getUntrackedParameter<std::string>("FEDDirName", "L1T/FEDIntegrity");
0018   stableROConfig_ = ps.getUntrackedParameter<bool>("stableROConfig", true);
0019   rawl_ = consumes<FEDRawDataCollection>(ps.getParameter<InputTag>("rawTag"));
0020 
0021   if (verbose_)
0022     cout << "L1TFED: constructor...." << endl;
0023   nev_ = 0;
0024 }
0025 
0026 L1TFED::~L1TFED() {}
0027 
0028 void L1TFED::bookHistograms(DQMStore::IBooker& ibooker, edm::Run const& iRun, edm::EventSetup const& iSetup) {
0029   ibooker.setCurrentFolder(directory_);
0030 
0031   fedentries = ibooker.book1D("FEDEntries", "Fed ID occupancy", l1feds_.size(), 0., l1feds_.size());
0032   fedfatal = ibooker.book1D("FEDFatal", "Fed ID non present ", l1feds_.size(), 0., l1feds_.size());
0033   fednonfatal = ibooker.book1D("FEDNonFatal", "Fed corrupted data ", l1feds_.size(), 0., l1feds_.size());
0034   hfedprof = ibooker.bookProfile("fedprofile", "FED Size by ID", l1feds_.size(), 0., l1feds_.size(), 0, 0., 10000.);
0035   for (unsigned int i = 0; i < l1feds_.size(); i++) {
0036     ostringstream sfed;
0037     sfed << l1feds_[i];
0038     fedentries->setBinLabel(i + 1, "FED " + sfed.str());
0039     fedfatal->setBinLabel(i + 1, "FED " + sfed.str());
0040     fednonfatal->setBinLabel(i + 1, "FED " + sfed.str());
0041     hfedprof->setBinLabel(i + 1, "FED " + sfed.str());
0042   }
0043 
0044   hfedsize = ibooker.book1D("fedsize", "FED Size Distribution", 100, 0., 10000.);
0045 }
0046 
0047 void L1TFED::analyze(const Event& e, const EventSetup& c) {
0048   nev_++;
0049   if (verbose_)
0050     cout << "L1T FED Integrity: analyze...." << endl;
0051 
0052   edm::Handle<FEDRawDataCollection> rawdata;
0053   bool t = e.getByToken(rawl_, rawdata);
0054 
0055   if (!t) {
0056     if (verbose_)
0057       cout << "can't find FEDRawDataCollection " << endl;
0058   }
0059 
0060   else {
0061     if (verbose_)
0062       cout << "fedlist size = " << l1feds_.size() << endl;
0063 
0064     for (unsigned int i = 0; i < l1feds_.size(); i++) {
0065       int fedId = l1feds_[i];
0066       if (verbose_)
0067         cout << "fedId = " << fedId << endl;
0068 
0069       const FEDRawData& data = rawdata->FEDData(fedId);
0070 
0071       if (size_t size = data.size()) {
0072         fedentries->Fill(i);
0073         hfedsize->Fill(float(size));
0074         hfedprof->Fill(float(i), float(size));
0075         if (verbose_)
0076           cout << "header check = " << FEDHeader(data.data()).check() << endl;
0077         if (verbose_)
0078           cout << "trailer check = " << FEDTrailer(data.data()).check() << endl;
0079 
0080         if (!FEDHeader(data.data()).check())
0081           fedfatal->Fill(i);
0082 
0083       } else {
0084         if (verbose_)
0085           cout << "empty fed " << i << endl;
0086         if (stableROConfig_)
0087           fedfatal->Fill(i);
0088       }
0089     }
0090   }
0091 }