Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:29:30

0001 #include "DataFormats/EcalDigi/interface/ESDataFrame.h"
0002 #include "Geometry/Records/interface/IdealGeometryRecord.h"
0003 #include "SimCalorimetry/EcalZeroSuppressionProducers/interface/ESZeroSuppressionProducer.h"
0004 
0005 ESZeroSuppressionProducer::ESZeroSuppressionProducer(const edm::ParameterSet &ps)
0006     : digiProducer_(ps.getParameter<std::string>("digiProducer")),
0007       ESdigiCollection_(ps.getParameter<std::string>("ESdigiCollection")),
0008       ESZSdigiCollection_(ps.getParameter<std::string>("ESZSdigiCollection")),
0009       ES_token(consumes<ESDigiCollection>(edm::InputTag(digiProducer_))),
0010       esthresholdsToken_(esConsumes()),
0011       espedsToken_(esConsumes()) {
0012   produces<ESDigiCollection>(ESZSdigiCollection_);
0013 }
0014 
0015 ESZeroSuppressionProducer::~ESZeroSuppressionProducer() {}
0016 
0017 void ESZeroSuppressionProducer::produce(edm::Event &event, const edm::EventSetup &eventSetup) {
0018   const ESThresholds &thresholds = eventSetup.getData(esthresholdsToken_);
0019   const ESPedestals &pedestals = eventSetup.getData(espedsToken_);
0020 
0021   float ts2Threshold = thresholds.getTS2Threshold();
0022 
0023   edm::Handle<ESDigiCollection> ESDigis;
0024 
0025   bool fullESDigis = true;
0026   event.getByToken(ES_token, ESDigis);
0027   if (!ESDigis.isValid()) {
0028     edm::LogError("ZeroSuppressionError") << "Error! can't get the product " << ESdigiCollection_.c_str();
0029     fullESDigis = false;
0030   }
0031 
0032   std::unique_ptr<ESDigiCollection> ESZSDigis(new ESDigiCollection());
0033 
0034   if (fullESDigis) {
0035     for (ESDigiCollection::const_iterator i(ESDigis->begin()); i != ESDigis->end(); ++i) {
0036       ESDataFrame dataframe = (*i);
0037 
0038       ESPedestals::const_iterator it_ped = pedestals.find(dataframe.id());
0039 
0040       if (dataframe.sample(1).adc() > (ts2Threshold + it_ped->getMean())) {
0041         // std::cout<<dataframe.sample(1).adc()<<"
0042         // "<<ts2Threshold+it_ped->getMean()<<std::endl;
0043         (*ESZSDigis).push_back(*i);
0044       }
0045     }
0046   }
0047 
0048   event.put(std::move(ESZSDigis), ESZSdigiCollection_);
0049 }