diff --git a/SimCalorimetry/HcalSimProducers/plugins/HcalDigiAnalyzer.cc b/SimCalorimetry/HcalSimProducers/plugins/HcalDigiAnalyzer.cc new file mode 100644 index 0000000000000..271950d8eb0f7 --- /dev/null +++ b/SimCalorimetry/HcalSimProducers/plugins/HcalDigiAnalyzer.cc @@ -0,0 +1,151 @@ +/** Studies Hcal digis + + \Author Rick Wilkinson, Caltech +*/ + +#include "CalibFormats/CaloObjects/interface/CaloSamples.h" +#include "DataFormats/HcalDigi/interface/HcalDigiCollections.h" +#include "FWCore/Framework/interface/Event.h" +#include "FWCore/Framework/interface/EventSetup.h" +#include "FWCore/Framework/interface/one/EDAnalyzer.h" +#include "FWCore/MessageLogger/interface/MessageLogger.h" +#include "FWCore/ParameterSet/interface/ParameterSet.h" +#include "FWCore/Utilities/interface/InputTag.h" +#include "SimCalorimetry/CaloSimAlgos/interface/CaloHitAnalyzer.h" +#include "SimCalorimetry/CaloSimAlgos/interface/CaloValidationStatistics.h" +#include "SimCalorimetry/HcalSimAlgos/interface/HcalHitFilter.h" +#include "SimCalorimetry/HcalSimAlgos/interface/HcalSimParameterMap.h" +#include "SimCalorimetry/HcalSimAlgos/interface/ZDCHitFilter.h" + +#include +#include + +class HcalDigiStatistics { +public: + HcalDigiStatistics(std::string name, + int maxBin, + float amplitudeThreshold, + float expectedPedestal, + float binPrevToBinMax, + float binNextToBinMax, + CaloHitAnalyzer &litudeAnalyzer) + : maxBin_(maxBin), + amplitudeThreshold_(amplitudeThreshold), + pedestal_(name + " pedestal", expectedPedestal, 0.), + binPrevToBinMax_(name + " binPrevToBinMax", binPrevToBinMax, 0.), + binNextToBinMax_(name + " binNextToBinMax", binNextToBinMax, 0.), + amplitudeAnalyzer_(amplitudeAnalyzer) {} + + template + void analyze(const Digi &digi); + +private: + int maxBin_; + float amplitudeThreshold_; + CaloValidationStatistics pedestal_; + CaloValidationStatistics binPrevToBinMax_; + CaloValidationStatistics binNextToBinMax_; + CaloHitAnalyzer &litudeAnalyzer_; +}; + +template +void HcalDigiStatistics::analyze(const Digi &digi) { + pedestal_.addEntry(digi[0].adc()); + pedestal_.addEntry(digi[1].adc()); + + double pedestal_fC = 0.5 * (digi[0].nominal_fC() + digi[1].nominal_fC()); + + double maxAmplitude = digi[maxBin_].nominal_fC() - pedestal_fC; + + if (maxAmplitude > amplitudeThreshold_) { + double binPrevToBinMax = (digi[maxBin_ - 1].nominal_fC() - pedestal_fC) / maxAmplitude; + binPrevToBinMax_.addEntry(binPrevToBinMax); + + double binNextToBinMax = (digi[maxBin_ + 1].nominal_fC() - pedestal_fC) / maxAmplitude; + binNextToBinMax_.addEntry(binNextToBinMax); + + double amplitude = digi[maxBin_].nominal_fC() + digi[maxBin_ + 1].nominal_fC() - 2 * pedestal_fC; + + amplitudeAnalyzer_.analyze(digi.id().rawId(), amplitude); + } +} + +class HcalDigiAnalyzer : public edm::one::EDAnalyzer<> { +public: + explicit HcalDigiAnalyzer(edm::ParameterSet const &conf); + void analyze(edm::Event const &e, edm::EventSetup const &c) override; + +private: + std::string hitReadoutName_; + HcalSimParameterMap simParameterMap_; + HBHEHitFilter hbheFilter_; + HOHitFilter hoFilter_; + HFHitFilter hfFilter_; + ZDCHitFilter zdcFilter_; + CaloHitAnalyzer hbheHitAnalyzer_; + CaloHitAnalyzer hoHitAnalyzer_; + CaloHitAnalyzer hfHitAnalyzer_; + CaloHitAnalyzer zdcHitAnalyzer_; + HcalDigiStatistics hbheDigiStatistics_; + HcalDigiStatistics hoDigiStatistics_; + HcalDigiStatistics hfDigiStatistics_; + HcalDigiStatistics zdcDigiStatistics_; + + edm::InputTag hbheDigiCollectionTag_; + edm::InputTag hoDigiCollectionTag_; + edm::InputTag hfDigiCollectionTag_; +}; + +HcalDigiAnalyzer::HcalDigiAnalyzer(edm::ParameterSet const &conf) + : hitReadoutName_("HcalHits"), + simParameterMap_(), + hbheFilter_(), + hoFilter_(), + hfFilter_(), + hbheHitAnalyzer_("HBHEDigi", 1., &simParameterMap_, &hbheFilter_), + hoHitAnalyzer_("HODigi", 1., &simParameterMap_, &hoFilter_), + hfHitAnalyzer_("HFDigi", 1., &simParameterMap_, &hfFilter_), + zdcHitAnalyzer_("ZDCDigi", 1., &simParameterMap_, &zdcFilter_), + hbheDigiStatistics_("HBHEDigi", 4, 10., 6., 0.1, 0.5, hbheHitAnalyzer_), + hoDigiStatistics_("HODigi", 4, 10., 6., 0.1, 0.5, hoHitAnalyzer_), + hfDigiStatistics_("HFDigi", 3, 10., 6., 0.1, 0.5, hfHitAnalyzer_), + zdcDigiStatistics_("ZDCDigi", 3, 10., 6., 0.1, 0.5, zdcHitAnalyzer_), + hbheDigiCollectionTag_(conf.getParameter("hbheDigiCollectionTag")), + hoDigiCollectionTag_(conf.getParameter("hoDigiCollectionTag")), + hfDigiCollectionTag_(conf.getParameter("hfDigiCollectionTag")) {} + +namespace HcalDigiAnalyzerImpl { + template + void analyze(edm::Event const &e, HcalDigiStatistics &statistics, edm::InputTag &tag) { + edm::Handle digis; + e.getByLabel(tag, digis); + for (unsigned i = 0; i < digis->size(); ++i) { + std::cout << (*digis)[i] << std::endl; + statistics.analyze((*digis)[i]); + } + } +} // namespace HcalDigiAnalyzerImpl + +void HcalDigiAnalyzer::analyze(edm::Event const &e, edm::EventSetup const &c) { + // Step A: Get Inputs + edm::Handle> cf, zdccf; + e.getByLabel("mix", "HcalHits", cf); + // e.getByLabel("mix", "ZDCHits", zdccf); + + // test access to SimHits for HcalHits and ZDC hits + std::unique_ptr> hits(new MixCollection(cf.product())); + // std::unique_ptr > zdcHits(new + // MixCollection(zdccf.product())); + hbheHitAnalyzer_.fillHits(*hits); + hoHitAnalyzer_.fillHits(*hits); + hfHitAnalyzer_.fillHits(*hits); + // zdcHitAnalyzer_.fillHits(*zdcHits); + HcalDigiAnalyzerImpl::analyze(e, hbheDigiStatistics_, hbheDigiCollectionTag_); + HcalDigiAnalyzerImpl::analyze(e, hoDigiStatistics_, hoDigiCollectionTag_); + HcalDigiAnalyzerImpl::analyze(e, hfDigiStatistics_, hfDigiCollectionTag_); + // HcalDigiAnalyzerImpl::analyze(e, zdcDigiStatistics_); +} + +#include "FWCore/Framework/interface/MakerMacros.h" + +DEFINE_FWK_MODULE(HcalDigiAnalyzer); diff --git a/SimCalorimetry/HcalSimProducers/src/HcalDigiProducer.cc b/SimCalorimetry/HcalSimProducers/plugins/HcalDigiProducer.cc similarity index 94% rename from SimCalorimetry/HcalSimProducers/src/HcalDigiProducer.cc rename to SimCalorimetry/HcalSimProducers/plugins/HcalDigiProducer.cc index 727d50d9c839d..94f1404e559f3 100644 --- a/SimCalorimetry/HcalSimProducers/src/HcalDigiProducer.cc +++ b/SimCalorimetry/HcalSimProducers/plugins/HcalDigiProducer.cc @@ -73,3 +73,8 @@ void HcalDigiProducer::setQIE10NoiseSignalGenerator(HcalBaseSignalGenerator *noi void HcalDigiProducer::setQIE11NoiseSignalGenerator(HcalBaseSignalGenerator *noiseGenerator) { theDigitizer_.setQIE11NoiseSignalGenerator(noiseGenerator); } + +#include "FWCore/Framework/interface/MakerMacros.h" +#include "SimGeneral/MixingModule/interface/DigiAccumulatorMixModFactory.h" + +DEFINE_DIGI_ACCUMULATOR(HcalDigiProducer); diff --git a/SimCalorimetry/HcalSimProducers/src/HcalHitAnalyzer.cc b/SimCalorimetry/HcalSimProducers/plugins/HcalHitAnalyzer.cc similarity index 62% rename from SimCalorimetry/HcalSimProducers/src/HcalHitAnalyzer.cc rename to SimCalorimetry/HcalSimProducers/plugins/HcalHitAnalyzer.cc index 94ba175495659..f632dc8ff3f9a 100644 --- a/SimCalorimetry/HcalSimProducers/src/HcalHitAnalyzer.cc +++ b/SimCalorimetry/HcalSimProducers/plugins/HcalHitAnalyzer.cc @@ -1,7 +1,43 @@ +/** Compares HCAL RecHits to SimHit + + \Author Rick Wilkinson, Caltech +*/ + #include "DataFormats/HcalRecHit/interface/HcalRecHitCollections.h" +#include "FWCore/Framework/interface/Event.h" +#include "FWCore/Framework/interface/EventSetup.h" +#include "FWCore/Framework/interface/one/EDAnalyzer.h" #include "FWCore/MessageLogger/interface/MessageLogger.h" -#include "SimCalorimetry/HcalSimProducers/src/HcalHitAnalyzer.h" +#include "FWCore/ParameterSet/interface/ParameterSet.h" +#include "FWCore/Utilities/interface/InputTag.h" +#include "SimCalorimetry/CaloSimAlgos/interface/CaloHitAnalyzer.h" +#include "SimCalorimetry/HcalSimAlgos/interface/HcalHitFilter.h" +#include "SimCalorimetry/HcalSimAlgos/interface/HcalSimParameterMap.h" +#include "SimCalorimetry/HcalSimAlgos/interface/ZDCHitFilter.h" + #include +#include + +class HcalHitAnalyzer : public edm::one::EDAnalyzer<> { +public: + explicit HcalHitAnalyzer(edm::ParameterSet const &conf); + void analyze(edm::Event const &e, edm::EventSetup const &c) override; + +private: + HcalSimParameterMap simParameterMap_; + HBHEHitFilter hbheFilter_; + HOHitFilter hoFilter_; + HFHitFilter hfFilter_; + ZDCHitFilter zdcFilter_; + CaloHitAnalyzer hbheAnalyzer_; + CaloHitAnalyzer hoAnalyzer_; + CaloHitAnalyzer hfAnalyzer_; + CaloHitAnalyzer zdcAnalyzer_; + + edm::InputTag hbheRecHitCollectionTag_; + edm::InputTag hoRecHitCollectionTag_; + edm::InputTag hfRecHitCollectionTag_; +}; HcalHitAnalyzer::HcalHitAnalyzer(edm::ParameterSet const &conf) : simParameterMap_(conf), @@ -47,3 +83,7 @@ void HcalHitAnalyzer::analyze(edm::Event const &e, edm::EventSetup const &c) { HcalHitAnalyzerImpl::analyze(e, hfAnalyzer_, hfRecHitCollectionTag_); // HcalHitAnalyzerImpl::analyze(e, zdcAnalyzer_); } + +#include "FWCore/Framework/interface/MakerMacros.h" + +DEFINE_FWK_MODULE(HcalHitAnalyzer); diff --git a/SimCalorimetry/HcalSimProducers/plugins/SealModule.cc b/SimCalorimetry/HcalSimProducers/plugins/SealModule.cc deleted file mode 100644 index 011759fa42e9c..0000000000000 --- a/SimCalorimetry/HcalSimProducers/plugins/SealModule.cc +++ /dev/null @@ -1,9 +0,0 @@ -#include "FWCore/Framework/interface/MakerMacros.h" -#include "SimCalorimetry/HcalSimProducers/interface/HcalDigiProducer.h" -#include "SimCalorimetry/HcalSimProducers/src/HcalDigiAnalyzer.h" -#include "SimCalorimetry/HcalSimProducers/src/HcalHitAnalyzer.h" -#include "SimGeneral/MixingModule/interface/DigiAccumulatorMixModFactory.h" - -DEFINE_FWK_MODULE(HcalHitAnalyzer); -DEFINE_FWK_MODULE(HcalDigiAnalyzer); -DEFINE_DIGI_ACCUMULATOR(HcalDigiProducer); diff --git a/SimCalorimetry/HcalSimProducers/src/HcalDigiAnalyzer.cc b/SimCalorimetry/HcalSimProducers/src/HcalDigiAnalyzer.cc deleted file mode 100644 index 97ba9eff7c788..0000000000000 --- a/SimCalorimetry/HcalSimProducers/src/HcalDigiAnalyzer.cc +++ /dev/null @@ -1,54 +0,0 @@ -#include "DataFormats/HcalDigi/interface/HcalDigiCollections.h" -#include "FWCore/MessageLogger/interface/MessageLogger.h" -#include "SimCalorimetry/HcalSimProducers/src/HcalDigiAnalyzer.h" -#include - -HcalDigiAnalyzer::HcalDigiAnalyzer(edm::ParameterSet const &conf) - : hitReadoutName_("HcalHits"), - simParameterMap_(), - hbheFilter_(), - hoFilter_(), - hfFilter_(), - hbheHitAnalyzer_("HBHEDigi", 1., &simParameterMap_, &hbheFilter_), - hoHitAnalyzer_("HODigi", 1., &simParameterMap_, &hoFilter_), - hfHitAnalyzer_("HFDigi", 1., &simParameterMap_, &hfFilter_), - zdcHitAnalyzer_("ZDCDigi", 1., &simParameterMap_, &zdcFilter_), - hbheDigiStatistics_("HBHEDigi", 4, 10., 6., 0.1, 0.5, hbheHitAnalyzer_), - hoDigiStatistics_("HODigi", 4, 10., 6., 0.1, 0.5, hoHitAnalyzer_), - hfDigiStatistics_("HFDigi", 3, 10., 6., 0.1, 0.5, hfHitAnalyzer_), - zdcDigiStatistics_("ZDCDigi", 3, 10., 6., 0.1, 0.5, zdcHitAnalyzer_), - hbheDigiCollectionTag_(conf.getParameter("hbheDigiCollectionTag")), - hoDigiCollectionTag_(conf.getParameter("hoDigiCollectionTag")), - hfDigiCollectionTag_(conf.getParameter("hfDigiCollectionTag")) {} - -namespace HcalDigiAnalyzerImpl { - template - void analyze(edm::Event const &e, HcalDigiStatistics &statistics, edm::InputTag &tag) { - edm::Handle digis; - e.getByLabel(tag, digis); - for (unsigned i = 0; i < digis->size(); ++i) { - std::cout << (*digis)[i] << std::endl; - statistics.analyze((*digis)[i]); - } - } -} // namespace HcalDigiAnalyzerImpl - -void HcalDigiAnalyzer::analyze(edm::Event const &e, edm::EventSetup const &c) { - // Step A: Get Inputs - edm::Handle> cf, zdccf; - e.getByLabel("mix", "HcalHits", cf); - // e.getByLabel("mix", "ZDCHits", zdccf); - - // test access to SimHits for HcalHits and ZDC hits - std::unique_ptr> hits(new MixCollection(cf.product())); - // std::unique_ptr > zdcHits(new - // MixCollection(zdccf.product())); - hbheHitAnalyzer_.fillHits(*hits); - hoHitAnalyzer_.fillHits(*hits); - hfHitAnalyzer_.fillHits(*hits); - // zdcHitAnalyzer_.fillHits(*zdcHits); - HcalDigiAnalyzerImpl::analyze(e, hbheDigiStatistics_, hbheDigiCollectionTag_); - HcalDigiAnalyzerImpl::analyze(e, hoDigiStatistics_, hoDigiCollectionTag_); - HcalDigiAnalyzerImpl::analyze(e, hfDigiStatistics_, hfDigiCollectionTag_); - // HcalDigiAnalyzerImpl::analyze(e, zdcDigiStatistics_); -} diff --git a/SimCalorimetry/HcalSimProducers/src/HcalDigiAnalyzer.h b/SimCalorimetry/HcalSimProducers/src/HcalDigiAnalyzer.h deleted file mode 100644 index 21362e42457a3..0000000000000 --- a/SimCalorimetry/HcalSimProducers/src/HcalDigiAnalyzer.h +++ /dev/null @@ -1,48 +0,0 @@ -#ifndef HcalSimProducers_HcalDigiAnalyzer_h -#define HcalSimProducers_HcalDigiAnalyzer_h - -#include "DataFormats/HcalDigi/interface/HcalDigiCollections.h" -#include "FWCore/Framework/interface/Event.h" -#include "FWCore/Framework/interface/EventSetup.h" -#include "FWCore/Framework/interface/one/EDAnalyzer.h" -#include "FWCore/ParameterSet/interface/ParameterSet.h" -#include "FWCore/Utilities/interface/InputTag.h" -#include "SimCalorimetry/CaloSimAlgos/interface/CaloHitAnalyzer.h" -#include "SimCalorimetry/HcalSimAlgos/interface/HcalHitFilter.h" -#include "SimCalorimetry/HcalSimAlgos/interface/HcalSimParameterMap.h" -#include "SimCalorimetry/HcalSimAlgos/interface/ZDCHitFilter.h" -#include "SimCalorimetry/HcalSimProducers/src/HcalDigiStatistics.h" -#include - -/** Studies Hcal digis - - \Author Rick Wilkinson, Caltech -*/ - -class HcalDigiAnalyzer : public edm::one::EDAnalyzer<> { -public: - explicit HcalDigiAnalyzer(edm::ParameterSet const &conf); - void analyze(edm::Event const &e, edm::EventSetup const &c) override; - -private: - std::string hitReadoutName_; - HcalSimParameterMap simParameterMap_; - HBHEHitFilter hbheFilter_; - HOHitFilter hoFilter_; - HFHitFilter hfFilter_; - ZDCHitFilter zdcFilter_; - CaloHitAnalyzer hbheHitAnalyzer_; - CaloHitAnalyzer hoHitAnalyzer_; - CaloHitAnalyzer hfHitAnalyzer_; - CaloHitAnalyzer zdcHitAnalyzer_; - HcalDigiStatistics hbheDigiStatistics_; - HcalDigiStatistics hoDigiStatistics_; - HcalDigiStatistics hfDigiStatistics_; - HcalDigiStatistics zdcDigiStatistics_; - - edm::InputTag hbheDigiCollectionTag_; - edm::InputTag hoDigiCollectionTag_; - edm::InputTag hfDigiCollectionTag_; -}; - -#endif diff --git a/SimCalorimetry/HcalSimProducers/src/HcalDigiStatistics.h b/SimCalorimetry/HcalSimProducers/src/HcalDigiStatistics.h deleted file mode 100644 index f652db769c8fe..0000000000000 --- a/SimCalorimetry/HcalSimProducers/src/HcalDigiStatistics.h +++ /dev/null @@ -1,59 +0,0 @@ -#ifndef HcalSimProducers_HcalDigiStatistics_h -#define HcalSimProducers_HcalDigiStatistics_h - -#include "CalibFormats/CaloObjects/interface/CaloSamples.h" -#include "SimCalorimetry/CaloSimAlgos/interface/CaloHitAnalyzer.h" -#include "SimCalorimetry/CaloSimAlgos/interface/CaloValidationStatistics.h" -#include - -class HcalDigiStatistics { -public: - HcalDigiStatistics(std::string name, - int maxBin, - float amplitudeThreshold, - float expectedPedestal, - float binPrevToBinMax, - float binNextToBinMax, - CaloHitAnalyzer &litudeAnalyzer) - : maxBin_(maxBin), - amplitudeThreshold_(amplitudeThreshold), - pedestal_(name + " pedestal", expectedPedestal, 0.), - binPrevToBinMax_(name + " binPrevToBinMax", binPrevToBinMax, 0.), - binNextToBinMax_(name + " binNextToBinMax", binNextToBinMax, 0.), - amplitudeAnalyzer_(amplitudeAnalyzer) {} - - template - void analyze(const Digi &digi); - -private: - int maxBin_; - float amplitudeThreshold_; - CaloValidationStatistics pedestal_; - CaloValidationStatistics binPrevToBinMax_; - CaloValidationStatistics binNextToBinMax_; - CaloHitAnalyzer &litudeAnalyzer_; -}; - -template -void HcalDigiStatistics::analyze(const Digi &digi) { - pedestal_.addEntry(digi[0].adc()); - pedestal_.addEntry(digi[1].adc()); - - double pedestal_fC = 0.5 * (digi[0].nominal_fC() + digi[1].nominal_fC()); - - double maxAmplitude = digi[maxBin_].nominal_fC() - pedestal_fC; - - if (maxAmplitude > amplitudeThreshold_) { - double binPrevToBinMax = (digi[maxBin_ - 1].nominal_fC() - pedestal_fC) / maxAmplitude; - binPrevToBinMax_.addEntry(binPrevToBinMax); - - double binNextToBinMax = (digi[maxBin_ + 1].nominal_fC() - pedestal_fC) / maxAmplitude; - binNextToBinMax_.addEntry(binNextToBinMax); - - double amplitude = digi[maxBin_].nominal_fC() + digi[maxBin_ + 1].nominal_fC() - 2 * pedestal_fC; - - amplitudeAnalyzer_.analyze(digi.id().rawId(), amplitude); - } -} - -#endif diff --git a/SimCalorimetry/HcalSimProducers/src/HcalHitAnalyzer.h b/SimCalorimetry/HcalSimProducers/src/HcalHitAnalyzer.h deleted file mode 100644 index 5c37f61732b5b..0000000000000 --- a/SimCalorimetry/HcalSimProducers/src/HcalHitAnalyzer.h +++ /dev/null @@ -1,41 +0,0 @@ -#ifndef HcalSimProducers_HcalHitAnalyzer_h -#define HcalSimProducers_HcalHitAnalyzer_h - -#include "FWCore/Framework/interface/Event.h" -#include "FWCore/Framework/interface/EventSetup.h" -#include "FWCore/Framework/interface/one/EDAnalyzer.h" -#include "FWCore/ParameterSet/interface/ParameterSet.h" -#include "FWCore/Utilities/interface/InputTag.h" -#include "SimCalorimetry/CaloSimAlgos/interface/CaloHitAnalyzer.h" -#include "SimCalorimetry/HcalSimAlgos/interface/HcalHitFilter.h" -#include "SimCalorimetry/HcalSimAlgos/interface/HcalSimParameterMap.h" -#include "SimCalorimetry/HcalSimAlgos/interface/ZDCHitFilter.h" -#include - -/** Compares HCAL RecHits to SimHit - - \Author Rick Wilkinson, Caltech -*/ - -class HcalHitAnalyzer : public edm::one::EDAnalyzer<> { -public: - explicit HcalHitAnalyzer(edm::ParameterSet const &conf); - void analyze(edm::Event const &e, edm::EventSetup const &c) override; - -private: - HcalSimParameterMap simParameterMap_; - HBHEHitFilter hbheFilter_; - HOHitFilter hoFilter_; - HFHitFilter hfFilter_; - ZDCHitFilter zdcFilter_; - CaloHitAnalyzer hbheAnalyzer_; - CaloHitAnalyzer hoAnalyzer_; - CaloHitAnalyzer hfAnalyzer_; - CaloHitAnalyzer zdcAnalyzer_; - - edm::InputTag hbheRecHitCollectionTag_; - edm::InputTag hoRecHitCollectionTag_; - edm::InputTag hfRecHitCollectionTag_; -}; - -#endif