CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_5_3_14/src/SimCalorimetry/EcalZeroSuppressionProducers/src/ESZeroSuppressionProducer.cc

Go to the documentation of this file.
00001 #include "SimCalorimetry/EcalZeroSuppressionProducers/interface/ESZeroSuppressionProducer.h"
00002 #include "Geometry/Records/interface/IdealGeometryRecord.h"
00003 #include "DataFormats/EcalDigi/interface/ESDataFrame.h"
00004 
00005 ESZeroSuppressionProducer::ESZeroSuppressionProducer(const edm::ParameterSet& ps) {
00006 
00007   digiProducer_   = ps.getParameter<std::string>("digiProducer");
00008   ESdigiCollection_ = ps.getParameter<std::string>("ESdigiCollection");
00009   ESZSdigiCollection_ = ps.getParameter<std::string>("ESZSdigiCollection");
00010  
00011   produces<ESDigiCollection>(ESZSdigiCollection_);
00012 }
00013 
00014 ESZeroSuppressionProducer::~ESZeroSuppressionProducer() { 
00015 
00016 }
00017 
00018 void ESZeroSuppressionProducer::produce(edm::Event& event, const edm::EventSetup& eventSetup) {
00019 
00020   eventSetup.get<ESThresholdsRcd>().get(esthresholds_);
00021   const ESThresholds *thresholds = esthresholds_.product();
00022 
00023   eventSetup.get<ESPedestalsRcd>().get(espeds_);
00024   const ESPedestals *pedestals = espeds_.product();
00025 
00026   float ts2Threshold = thresholds->getTS2Threshold();
00027 
00028   edm::Handle<ESDigiCollection> ESDigis;
00029 
00030   bool fullESDigis = true;
00031   event.getByLabel(digiProducer_, ESDigis);
00032   if (!ESDigis.isValid()) {
00033     edm::LogError("ZeroSuppressionError") << "Error! can't get the product " << ESdigiCollection_.c_str() ;
00034     fullESDigis = false;
00035   }  
00036 
00037   std::auto_ptr<ESDigiCollection> ESZSDigis(new ESDigiCollection());
00038   
00039   if (fullESDigis) {
00040     for (ESDigiCollection::const_iterator i (ESDigis->begin()); 
00041          i!=ESDigis->end(); ++i) {            
00042 
00043       ESDataFrame dataframe = (*i);
00044 
00045       ESPedestals::const_iterator it_ped = pedestals->find(dataframe.id());
00046 
00047       if (dataframe.sample(1).adc() > (ts2Threshold+it_ped->getMean())) {
00048         //std::cout<<dataframe.sample(1).adc()<<" "<<ts2Threshold+it_ped->getMean()<<std::endl;
00049         (*ESZSDigis).push_back(*i);
00050       }
00051     }
00052   }     
00053   
00054   event.put(ESZSDigis, ESZSdigiCollection_);  
00055 }
00056