Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2022-02-25 23:40:02

0001 // -*- C++ -*-
0002 //
0003 // Package:    SiStripMonitorRawData
0004 // Class:      SiStripMonitorRawData
0005 //
0006 /**\class SiStripMonitorDigi SiStripMonitorDigi.cc
0007  DQM/SiStripMonitorDigi/src/SiStripMonitorDigi.cc
0008 
0009  Description: <one line class summary>
0010 
0011  Implementation:
0012      <Notes on implementation>
0013 */
0014 //
0015 // Original Author:  Suchandra Dutta
0016 //         Created:  Fri June  1 17:00:00 CET 2007
0017 //
0018 //
0019 
0020 #include "CalibFormats/SiStripObjects/interface/SiStripDetCabling.h"
0021 #include "CalibTracker/Records/interface/SiStripDetCablingRcd.h"
0022 #include "DQM/SiStripMonitorPedestals/interface/SiStripMonitorRawData.h"
0023 #include "DQMServices/Core/interface/DQMStore.h"
0024 #include "DataFormats/Common/interface/DetSetVector.h"
0025 #include "DataFormats/Common/interface/Handle.h"
0026 #include "DataFormats/SiStripDigi/interface/SiStripRawDigi.h"
0027 #include "FWCore/Framework/interface/EventSetup.h"
0028 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0029 #include "FWCore/ServiceRegistry/interface/Service.h"
0030 
0031 // std
0032 #include <algorithm>
0033 #include <cmath>
0034 #include <cstdlib>
0035 #include <numeric>
0036 
0037 SiStripMonitorRawData::SiStripMonitorRawData(edm::ParameterSet const &iConfig)
0038     : BadFedNumber(nullptr),
0039       dqmStore_(edm::Service<DQMStore>().operator->()),
0040       conf_(iConfig),
0041       detCablingToken_(esConsumes<edm::Transition::BeginRun>())
0042 
0043 {
0044   // retrieve producer name of input StripDigiCollection
0045   std::string digiProducer = conf_.getParameter<std::string>("DigiProducer");
0046   std::string digiType = "VirginRaw";
0047   digiToken_ = consumes<edm::DetSetVector<SiStripRawDigi>>(edm::InputTag(digiProducer, digiType));
0048 
0049   edm::LogInfo("SiStripMonitorRawData") << "SiStripMonitorRawData  "
0050                                         << " Constructing....... ";
0051 }
0052 
0053 SiStripMonitorRawData::~SiStripMonitorRawData() {
0054   edm::LogInfo("SiStripMonitorRawData") << "SiStripMonitorRawData  "
0055                                         << " Destructing....... ";
0056 }
0057 //
0058 // -- BeginRun
0059 //
0060 
0061 void SiStripMonitorRawData::bookHistograms(DQMStore::IBooker &ibooker,
0062                                            const edm::Run &run,
0063                                            const edm::EventSetup &eSetup) {
0064   if (BadFedNumber)
0065     BadFedNumber->Reset();
0066 
0067   if (detCablingWatcher_.check(eSetup)) {
0068     SelectedDetIds.clear();
0069     const auto &detcabling = eSetup.getData(detCablingToken_);
0070     detcabling.addActiveDetectorsRawIds(SelectedDetIds);
0071 
0072     edm::LogInfo("SiStripMonitorRawData") << "SiStripMonitorRawData::bookHistograms: "
0073                                           << " Creating MEs for new Cabling ";
0074     ibooker.setCurrentFolder("Track/GlobalParameter");
0075     if (!BadFedNumber) {
0076       BadFedNumber =
0077           ibooker.book1D("FaultyFedNumberAndChannel", "Faulty Fed Id and Channel and Numbers", 60000, 0.5, 600.5);
0078       BadFedNumber->setAxisTitle("Fed Id and Channel numbers", 1);
0079     }
0080   }
0081 }
0082 
0083 // ------------ method called to produce the data  ------------
0084 void SiStripMonitorRawData::analyze(edm::Event const &iEvent, edm::EventSetup const &iSetup) {
0085   edm::LogInfo("SiStripMonitorRawData") << "SiStripMonitorRawData::analyze: Run " << iEvent.id().run() << " Event "
0086                                         << iEvent.id().event();
0087 
0088   const auto &detcabling = iSetup.getData(detCablingToken_);
0089 
0090   // get DigiCollection object from Event
0091   edm::Handle<edm::DetSetVector<SiStripRawDigi>> digi_collection;
0092   iEvent.getByToken(digiToken_, digi_collection);
0093 
0094   for (std::vector<uint32_t>::const_iterator idetid = SelectedDetIds.begin(), iEnd = SelectedDetIds.end();
0095        idetid != iEnd;
0096        ++idetid) {
0097     std::vector<edm::DetSet<SiStripRawDigi>>::const_iterator digis = digi_collection->find((*idetid));
0098     if (digis == digi_collection->end() || digis->data.empty() || digis->data.size() > 768) {
0099       std::vector<const FedChannelConnection *> fed_conns = detcabling.getConnections((*idetid));
0100       for (unsigned int k = 0; k < fed_conns.size(); k++) {
0101         if (fed_conns[k] && fed_conns[k]->isConnected()) {
0102           float fed_id = fed_conns[k]->fedId() + 0.01 * fed_conns[k]->fedCh();
0103           BadFedNumber->Fill(fed_id);
0104         }
0105       }
0106       continue;
0107     }
0108   }
0109 }
0110 //
0111 // -- End Run
0112 //
0113 void SiStripMonitorRawData::dqmEndRun(edm::Run const &run, edm::EventSetup const &eSetup) {
0114   bool outputMEsInRootFile = conf_.getParameter<bool>("OutputMEsInRootFile");
0115   std::string outputFileName = conf_.getParameter<std::string>("OutputFileName");
0116   if (outputMEsInRootFile) {
0117     dqmStore_->save(outputFileName);
0118   }
0119 }
0120 //
0121 // -- End Job
0122 //
0123 void SiStripMonitorRawData::endJob(void) {
0124   edm::LogInfo("SiStripMonitorRawData") << "SiStripMonitorRawData::EndJob: "
0125                                         << " Finishing!! ";
0126 }
0127 DEFINE_FWK_MODULE(SiStripMonitorRawData);