Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2023-03-17 10:54:08

0001 /*
0002  *  See header file for a description of this class.
0003  *
0004  *  \author G. Cerminara - INFN Torino
0005  *
0006  *  threadsafe version (//-) oct/nov 2014 - WATWanAbdullah ncpp-um-my
0007  *
0008  */
0009 
0010 #include "DQM/DTMonitorClient/src/DTDAQInfo.h"
0011 #include "DataFormats/FEDRawData/interface/FEDNumbering.h"
0012 
0013 #include "FWCore/ServiceRegistry/interface/Service.h"
0014 #include "FWCore/Framework/interface/ESHandle.h"
0015 #include "FWCore/Framework/interface/EventSetup.h"
0016 
0017 #include "DQMServices/Core/interface/DQMStore.h"
0018 
0019 #include "CondFormats/RunInfo/interface/RunInfo.h"
0020 #include "CondFormats/RunInfo/interface/RunSummary.h"
0021 
0022 #include "CondFormats/DTObjects/interface/DTReadOutMapping.h"
0023 
0024 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0025 
0026 using namespace std;
0027 using namespace edm;
0028 
0029 DTDAQInfo::DTDAQInfo(const ParameterSet& pset)
0030     : mappingToken_(esConsumes<edm::Transition::EndLuminosityBlock>()),
0031       runInfoToken_(esConsumes<edm::Transition::EndLuminosityBlock>()) {
0032   bookingdone = false;
0033   checkUros = pset.getUntrackedParameter<bool>("checkUros", true);
0034 }
0035 
0036 DTDAQInfo::~DTDAQInfo() {}
0037 
0038 void DTDAQInfo::dqmEndLuminosityBlock(DQMStore::IBooker& ibooker,
0039                                       DQMStore::IGetter& igetter,
0040                                       edm::LuminosityBlock const& lumiSeg,
0041                                       edm::EventSetup const& setup) {
0042   if (!bookingdone) {
0043     // retrieve the mapping
0044     mapping = &setup.getData(mappingToken_);
0045 
0046     // book the ME
0047     // global fraction
0048 
0049     ibooker.setCurrentFolder("DT/EventInfo");
0050 
0051     totalDAQFraction = ibooker.bookFloat("DAQSummary");
0052     totalDAQFraction->Fill(-1);
0053 
0054     // map
0055     daqMap = ibooker.book2D("DAQSummaryMap", "DT Certification Summary Map", 12, 1, 13, 5, -2, 3);
0056     daqMap->setAxisTitle("sector", 1);
0057     daqMap->setAxisTitle("wheel", 2);
0058 
0059     // Wheel "fractions" -> will be 0 or 1
0060 
0061     ibooker.setCurrentFolder("DT/EventInfo/DAQContents");
0062     for (int wheel = -2; wheel != 3; ++wheel) {
0063       stringstream streams;
0064       streams << "DT_Wheel" << wheel;
0065 
0066       daqFractions[wheel] = ibooker.bookFloat(streams.str());
0067       daqFractions[wheel]->Fill(-1);
0068     }
0069     bookingdone = true;
0070   }  //booking done
0071 
0072   if (auto runInfoRec = setup.tryToGet<RunInfoRcd>()) {
0073     // reset to 0
0074     totalDAQFraction->Fill(0.);
0075     daqFractions[-2]->Fill(0.);
0076     daqFractions[-1]->Fill(0.);
0077     daqFractions[-0]->Fill(0.);
0078     daqFractions[1]->Fill(0.);
0079     daqFractions[2]->Fill(0.);
0080 
0081     daqMap->Reset();
0082     //get fed summary information
0083     auto sumFED = runInfoRec->get(runInfoToken_);
0084     const vector<int> fedInIDs = sumFED.m_fed_in;
0085 
0086     // the range of DT feds
0087     static const int FEDIDmin = FEDNumbering::MINDTFEDID;
0088     static const int FEDIDMax = FEDNumbering::MAXDTFEDID;
0089 
0090     //FIXME for uROS FEDIDs once mapping has been defined
0091     if (checkUros) {
0092       LogTrace("DQM|DTMonitorClient|DTDAQInfo") << "Checking uROS FEDs as Legacy FEDs" << endl;
0093     }
0094 
0095     // loop on all active feds
0096     for (vector<int>::const_iterator fed = fedInIDs.begin(); fed != fedInIDs.end(); ++fed) {
0097       // check if the fed is in the DT range
0098       if (!(*fed >= FEDIDmin && *fed <= FEDIDMax))
0099         continue;
0100 
0101       // check if the 12 channels are connected to any sector and fill the wheel percentage accordignly
0102       int wheel = -99;
0103       int sector = -99;
0104       int dummy = -99;
0105       for (int ros = 1; ros != 13; ++ros) {
0106         if (!mapping->readOutToGeometry(*fed, ros, 2, 2, 2, wheel, dummy, sector, dummy, dummy, dummy)) {
0107           LogTrace("DQM|DTMonitorClient|DTDAQInfo")
0108               << "FED: " << *fed << " Ch: " << ros << " wheel: " << wheel << " Sect: " << sector << endl;
0109           daqFractions[wheel]->Fill(daqFractions[wheel]->getFloatValue() + 1. / 12.);
0110           totalDAQFraction->Fill(totalDAQFraction->getFloatValue() + 1. / 60.);
0111           daqMap->Fill(sector, wheel);
0112         }
0113       }
0114     }
0115   } else {
0116     LogWarning("DQM|DTMonitorClient|DTDAQInfo") << "*** Warning: record key not found for RunInfoRcd" << endl;
0117     totalDAQFraction->Fill(-1);
0118     for (int wheel = -2; wheel != 3; ++wheel) {
0119       daqFractions[wheel]->Fill(-1);
0120     }
0121     return;
0122   }
0123 }
0124 
0125 void DTDAQInfo::dqmEndJob(DQMStore::IBooker& ibooker, DQMStore::IGetter& igetter) {}