CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_6_2_5/src/EventFilter/HcalRawToDigi/plugins/HcalHistogramRawToDigi.cc

Go to the documentation of this file.
00001 using namespace std;
00002 #include "EventFilter/HcalRawToDigi/plugins/HcalHistogramRawToDigi.h"
00003 #include "DataFormats/FEDRawData/interface/FEDNumbering.h"
00004 #include "DataFormats/FEDRawData/interface/FEDRawDataCollection.h"
00005 #include "DataFormats/HcalDigi/interface/HcalDigiCollections.h"
00006 #include "FWCore/Framework/interface/ESHandle.h"
00007 #include "CalibFormats/HcalObjects/interface/HcalDbService.h"
00008 #include "CalibFormats/HcalObjects/interface/HcalDbRecord.h"
00009 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00010 #include <iostream>
00011 
00012 
00013 HcalHistogramRawToDigi::HcalHistogramRawToDigi(edm::ParameterSet const& conf):
00014   dataTag_(conf.getParameter<edm::InputTag>("InputLabel")),
00015   unpacker_(conf.getUntrackedParameter<int>("HcalFirstFED",FEDNumbering::MINHCALFEDID)),
00016   fedUnpackList_(conf.getUntrackedParameter<std::vector<int> >("FEDs")),
00017   firstFED_(conf.getUntrackedParameter<int>("HcalFirstFED",FEDNumbering::MINHCALFEDID))
00018 {
00019   std::ostringstream ss;
00020   for (unsigned int i=0; i<fedUnpackList_.size(); i++) 
00021     ss << fedUnpackList_[i] << " ";
00022   edm::LogInfo("HCAL") << "HcalHistogramRawToDigi will unpack FEDs ( " << ss.str() << ")";
00023     
00024   // products produced...
00025   produces<HcalHistogramDigiCollection>();
00026 }
00027 
00028 // Virtual destructor needed.
00029 HcalHistogramRawToDigi::~HcalHistogramRawToDigi() { }  
00030 
00031 // Functions that gets called by framework every event
00032 void HcalHistogramRawToDigi::produce(edm::Event& e, const edm::EventSetup& es)
00033 {
00034   // Step A: Get Inputs 
00035   edm::Handle<FEDRawDataCollection> rawraw;  
00036   e.getByLabel(dataTag_,rawraw);
00037   // get the mapping
00038   edm::ESHandle<HcalDbService> pSetup;
00039   es.get<HcalDbRecord>().get( pSetup );
00040   const HcalElectronicsMap* readoutMap=pSetup->getHcalMapping();
00041 
00042   // Step B: Create empty output
00043   std::auto_ptr<HcalHistogramDigiCollection> prod(new HcalHistogramDigiCollection());
00044   std::vector<HcalHistogramDigi> digis;
00045 
00046   // Step C: unpack all requested FEDs
00047   for (std::vector<int>::const_iterator i=fedUnpackList_.begin(); i!=fedUnpackList_.end(); i++) {
00048     const FEDRawData& fed = rawraw->FEDData(*i);
00049 
00050     unpacker_.unpack(fed,*readoutMap,digis);
00051   }
00052 
00053   // Step B2: encapsulate vectors in actual collections
00054   prod->swap_contents(digis);
00055 
00056   // Step D: Put outputs into event
00057   prod->sort();
00058   e.put(prod);
00059 }
00060 
00061