Go to the documentation of this file.00001 #include "SimCalorimetry/HcalTrigPrimProducers/src/HcalTrigPrimDigiProducer.h"
00002 #include "FWCore/Framework/interface/Event.h"
00003 #include "FWCore/Framework/interface/EventSetup.h"
00004 #include "DataFormats/Common/interface/Handle.h"
00005 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00006 #include "FWCore/Framework/interface/ESHandle.h"
00007 #include "DataFormats/HcalDigi/interface/HcalDigiCollections.h"
00008 #include "DataFormats/HcalDigi/interface/HBHEDataFrame.h"
00009 #include "DataFormats/HcalDigi/interface/HFDataFrame.h"
00010 #include "DataFormats/HcalDigi/interface/HcalTriggerPrimitiveDigi.h"
00011 #include "FWCore/Framework/interface/MakerMacros.h"
00012 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00013 #include "CalibFormats/HcalObjects/interface/HcalTPGRecord.h"
00014 #include "CalibFormats/HcalObjects/interface/HcalTPGCoder.h"
00015 #include "CalibFormats/CaloTPG/interface/HcalTPGCompressor.h"
00016 #include "CalibFormats/CaloTPG/interface/CaloTPGRecord.h"
00017 #include "CalibFormats/CaloTPG/interface/CaloTPGTranscoder.h"
00018 #include "CalibFormats/HcalObjects/interface/HcalDbService.h"
00019 #include "CalibFormats/HcalObjects/interface/HcalDbRecord.h"
00020 #include "DataFormats/FEDRawData/interface/FEDRawDataCollection.h"
00021 #include "CondFormats/HcalObjects/interface/HcalElectronicsMap.h"
00022 #include "CondFormats/HcalObjects/interface/HcalLutMetadata.h"
00023
00024 #include <algorithm>
00025
00026 HcalTrigPrimDigiProducer::HcalTrigPrimDigiProducer(const edm::ParameterSet& ps)
00027 :
00028 theAlgo_(ps.getParameter<bool>("peakFilter"),
00029 ps.getParameter<std::vector<double> >("weights"),
00030 ps.getParameter<int>("latency"),
00031 ps.getParameter<uint32_t>("FG_threshold"),
00032 ps.getParameter<uint32_t>("ZS_threshold"),
00033 ps.getParameter<int>("numberOfSamples"),
00034 ps.getParameter<int>("numberOfPresamples"),
00035 ps.getParameter<uint32_t>("MinSignalThreshold"),
00036 ps.getParameter<uint32_t>("PMTNoiseThreshold")
00037 ),
00038 inputLabel_(ps.getParameter<std::vector<edm::InputTag> >("inputLabel")),
00039 inputTagFEDRaw_(ps.getParameter<edm::InputTag> ("InputTagFEDRaw")),
00040 runZS_(ps.getParameter<bool>("RunZS")),
00041 runFrontEndFormatError_(ps.getParameter<bool>("FrontEndFormatError"))
00042 {
00043 produces<HcalTrigPrimDigiCollection>();
00044 theAlgo_.setPeakFinderAlgorithm(ps.getParameter<int>("PeakFinderAlgorithm"));
00045 }
00046
00047
00048 void HcalTrigPrimDigiProducer::produce(edm::Event& iEvent, const edm::EventSetup& eventSetup) {
00049
00050
00051 edm::ESHandle<HcalTPGCoder> inputCoder;
00052 eventSetup.get<HcalTPGRecord>().get(inputCoder);
00053
00054 edm::ESHandle<CaloTPGTranscoder> outTranscoder;
00055 eventSetup.get<CaloTPGRecord>().get(outTranscoder);
00056 outTranscoder->setup(eventSetup,CaloTPGTranscoder::HcalTPG);
00057
00058 edm::ESHandle<HcalLutMetadata> lutMetadata;
00059 eventSetup.get<HcalLutMetadataRcd>().get(lutMetadata);
00060 float rctlsb = lutMetadata->getRctLsb();
00061
00062
00063 std::auto_ptr<HcalTrigPrimDigiCollection> result(new HcalTrigPrimDigiCollection());
00064
00065 edm::Handle<HBHEDigiCollection> hbheDigis;
00066 edm::Handle<HFDigiCollection> hfDigis;
00067
00068 iEvent.getByLabel(inputLabel_[0],hbheDigis);
00069 iEvent.getByLabel(inputLabel_[1],hfDigis);
00070
00071
00072
00073
00074 if (!hbheDigis.isValid()) {
00075 edm::LogInfo("HcalTrigPrimDigiProducer")
00076 << "\nWarning: HBHEDigiCollection with input tag "
00077 << inputLabel_[0]
00078 << "\nrequested in configuration, but not found in the event."
00079 << "\nQuit returning empty product." << std::endl;
00080
00081
00082 iEvent.put(result);
00083
00084 outTranscoder->releaseSetup();
00085
00086 return;
00087 }
00088
00089 if (!hfDigis.isValid()) {
00090 edm::LogInfo("HcalTrigPrimDigiProducer")
00091 << "\nWarning: HFDigiCollection with input tag "
00092 << inputLabel_[1]
00093 << "\nrequested in configuration, but not found in the event."
00094 << "\nQuit returning empty product." << std::endl;
00095
00096
00097 iEvent.put(result);
00098
00099 outTranscoder->releaseSetup();
00100
00101 return;
00102 }
00103
00104
00105
00106 theAlgo_.run(inputCoder.product(),outTranscoder->getHcalCompressor().get(),
00107 *hbheDigis, *hfDigis, *result, rctlsb);
00108
00109
00110 if (runFrontEndFormatError_) {
00111
00112 edm::ESHandle < HcalDbService > pSetup;
00113 eventSetup.get<HcalDbRecord> ().get(pSetup);
00114 const HcalElectronicsMap *emap = pSetup->getHcalMapping();
00115
00116 edm::Handle < FEDRawDataCollection > fedHandle;
00117 iEvent.getByLabel(inputTagFEDRaw_, fedHandle);
00118
00119 if (fedHandle.isValid() && emap != 0) {
00120 theAlgo_.runFEFormatError(fedHandle.product(), emap, *result);
00121 } else {
00122 edm::LogInfo("HcalTrigPrimDigiProducer")
00123 << "\nWarning: FEDRawDataCollection with input tag "
00124 << inputTagFEDRaw_
00125 << "\nrequested in configuration, but not found in the event."
00126 << "\nQuit returning empty product." << std::endl;
00127
00128
00129 std::auto_ptr < HcalTrigPrimDigiCollection > emptyResult(
00130 new HcalTrigPrimDigiCollection());
00131
00132 iEvent.put(emptyResult);
00133
00134 outTranscoder->releaseSetup();
00135
00136 return;
00137 }
00138
00139 }
00140
00141 if (runZS_) theAlgo_.runZS(*result);
00142
00143
00144
00145
00146 iEvent.put(result);
00147
00148 outTranscoder->releaseSetup();
00149 }
00150
00151