Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:15:03

0001 #include "EventFilter/HcalRawToDigi/plugins/HcalHistogramRawToDigi.h"
0002 #include "DataFormats/FEDRawData/interface/FEDNumbering.h"
0003 #include "DataFormats/HcalDigi/interface/HcalDigiCollections.h"
0004 #include "FWCore/Framework/interface/ESHandle.h"
0005 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0006 #include <iostream>
0007 
0008 HcalHistogramRawToDigi::HcalHistogramRawToDigi(edm::ParameterSet const& conf)
0009     : unpacker_(conf.getUntrackedParameter<int>("HcalFirstFED", FEDNumbering::MINHCALFEDID)),
0010       fedUnpackList_(conf.getUntrackedParameter<std::vector<int> >("FEDs")),
0011       firstFED_(conf.getUntrackedParameter<int>("HcalFirstFED", FEDNumbering::MINHCALFEDID)) {
0012   std::ostringstream ss;
0013   for (unsigned int i = 0; i < fedUnpackList_.size(); i++)
0014     ss << fedUnpackList_[i] << " ";
0015   edm::LogInfo("HCAL") << "HcalHistogramRawToDigi will unpack FEDs ( " << ss.str() << ")";
0016 
0017   tok_data_ = consumes<FEDRawDataCollection>(conf.getParameter<edm::InputTag>("InputLabel"));
0018   tok_dbService_ = esConsumes<HcalDbService, HcalDbRecord>();
0019 
0020   // products produced...
0021   produces<HcalHistogramDigiCollection>();
0022 }
0023 
0024 // Virtual destructor needed.
0025 HcalHistogramRawToDigi::~HcalHistogramRawToDigi() {}
0026 
0027 // Functions that gets called by framework every event
0028 void HcalHistogramRawToDigi::produce(edm::Event& e, const edm::EventSetup& es) {
0029   // Step A: Get Inputs
0030   edm::Handle<FEDRawDataCollection> rawraw;
0031   e.getByToken(tok_data_, rawraw);
0032   // get the mapping
0033   edm::ESHandle<HcalDbService> pSetup = es.getHandle(tok_dbService_);
0034   const HcalElectronicsMap* readoutMap = pSetup->getHcalMapping();
0035 
0036   // Step B: Create empty output
0037   auto prod = std::make_unique<HcalHistogramDigiCollection>();
0038   std::vector<HcalHistogramDigi> digis;
0039 
0040   // Step C: unpack all requested FEDs
0041   for (std::vector<int>::const_iterator i = fedUnpackList_.begin(); i != fedUnpackList_.end(); i++) {
0042     const FEDRawData& fed = rawraw->FEDData(*i);
0043 
0044     unpacker_.unpack(fed, *readoutMap, digis);
0045   }
0046 
0047   // Step B2: encapsulate vectors in actual collections
0048   prod->swap_contents(digis);
0049 
0050   // Step D: Put outputs into event
0051   prod->sort();
0052   e.put(std::move(prod));
0053 }