File indexing completed on 2024-04-06 12:29:30
0001
0002 #include "SimCalorimetry/EcalZeroSuppressionProducers/interface/EcalZeroSuppressionProducer.h"
0003
0004 EcalZeroSuppressionProducer::EcalZeroSuppressionProducer(const edm::ParameterSet ¶ms)
0005 : glbBarrelThreshold_(params.getUntrackedParameter<double>("glbBarrelThreshold", 0.2)),
0006 glbEndcapThreshold_(params.getUntrackedParameter<double>("glbEndcapThreshold", 0.4)),
0007 digiProducer_(params.getParameter<std::string>("digiProducer")),
0008 ebDigiCollection_(params.getParameter<std::string>("EBdigiCollection")),
0009 eeDigiCollection_(params.getParameter<std::string>("EEdigiCollection")),
0010 ebZSdigiCollection_(params.getParameter<std::string>("EBZSdigiCollection")),
0011 eeZSdigiCollection_(params.getParameter<std::string>("EEZSdigiCollection")),
0012 ebToken_(consumes<EBDigiCollection>(edm::InputTag(digiProducer_))),
0013 eeToken_(consumes<EEDigiCollection>(edm::InputTag(digiProducer_))),
0014 pedestalToken_(esConsumes()) {
0015 produces<EBDigiCollection>(ebZSdigiCollection_);
0016 produces<EEDigiCollection>(eeZSdigiCollection_);
0017 }
0018
0019 EcalZeroSuppressionProducer::~EcalZeroSuppressionProducer() {}
0020
0021 void EcalZeroSuppressionProducer::produce(edm::Event &event, const edm::EventSetup &eventSetup) {
0022
0023
0024 initCalibrations(eventSetup);
0025
0026 edm::Handle<EBDigiCollection> pEBDigis;
0027 edm::Handle<EEDigiCollection> pEEDigis;
0028
0029 const EBDigiCollection *fullBarrelDigis = nullptr;
0030 const EEDigiCollection *fullEndcapDigis = nullptr;
0031
0032 event.getByToken(ebToken_, pEBDigis);
0033 if (pEBDigis.isValid()) {
0034 fullBarrelDigis = pEBDigis.product();
0035 edm::LogInfo("ZeroSuppressionInfo") << "total # fullBarrelDigis: " << fullBarrelDigis->size();
0036 } else {
0037 edm::LogError("ZeroSuppressionError") << "Error! can't get the product " << ebDigiCollection_.c_str();
0038 }
0039
0040 event.getByToken(eeToken_, pEEDigis);
0041 if (pEEDigis.isValid()) {
0042 fullEndcapDigis = pEEDigis.product();
0043 edm::LogInfo("ZeroSuppressionInfo") << "total # fullEndcapDigis: " << fullEndcapDigis->size();
0044 } else {
0045 edm::LogError("ZeroSuppressionError") << "Error! can't get the product " << eeDigiCollection_.c_str();
0046 }
0047
0048
0049
0050 auto gzsBarrelDigis = std::make_unique<EBDigiCollection>();
0051 auto gzsEndcapDigis = std::make_unique<EEDigiCollection>();
0052
0053 CaloDigiCollectionSorter sorter(5);
0054
0055
0056
0057 if (fullBarrelDigis) {
0058 for (EBDigiCollection::const_iterator digiItr = (*fullBarrelDigis).begin(); digiItr != (*fullBarrelDigis).end();
0059 ++digiItr) {
0060 bool isAccepted = theBarrelZeroSuppressor_.accept(*digiItr, glbBarrelThreshold_);
0061 if (isAccepted) {
0062 (*gzsBarrelDigis).push_back(digiItr->id(), digiItr->begin());
0063 }
0064 }
0065 edm::LogInfo("ZeroSuppressionInfo") << "EB Digis: " << gzsBarrelDigis->size();
0066
0067
0068
0069
0070
0071
0072
0073
0074 }
0075
0076
0077
0078 if (fullEndcapDigis) {
0079 for (EEDigiCollection::const_iterator digiItr = (*fullEndcapDigis).begin(); digiItr != (*fullEndcapDigis).end();
0080 ++digiItr) {
0081 bool isAccepted = theEndcapZeroSuppressor_.accept(*digiItr, glbEndcapThreshold_);
0082 if (isAccepted) {
0083 (*gzsEndcapDigis).push_back(digiItr->id(), digiItr->begin());
0084 }
0085 }
0086 edm::LogInfo("ZeroSuppressionInfo") << "EB Digis: " << gzsBarrelDigis->size();
0087
0088
0089
0090
0091
0092
0093
0094
0095 }
0096
0097 event.put(std::move(gzsBarrelDigis), ebZSdigiCollection_);
0098 event.put(std::move(gzsEndcapDigis), eeZSdigiCollection_);
0099 }
0100
0101 void EcalZeroSuppressionProducer::initCalibrations(const edm::EventSetup &eventSetup) {
0102
0103 const auto &thePedestals = eventSetup.getData(pedestalToken_);
0104
0105 theBarrelZeroSuppressor_.setPedestals(&thePedestals);
0106 theEndcapZeroSuppressor_.setPedestals(&thePedestals);
0107 }