CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_3/src/SimCalorimetry/EcalZeroSuppressionProducers/src/EcalZeroSuppressionProducer.cc

Go to the documentation of this file.
00001 
00002 #include "SimCalorimetry/EcalZeroSuppressionProducers/interface/EcalZeroSuppressionProducer.h"
00003 
00004 EcalZeroSuppressionProducer::EcalZeroSuppressionProducer(const edm::ParameterSet& params) 
00005 {
00006   digiProducer_   = params.getParameter<std::string>("digiProducer");
00007   EBdigiCollection_ = params.getParameter<std::string>("EBdigiCollection");
00008   EEdigiCollection_ = params.getParameter<std::string>("EEdigiCollection");
00009   EBZSdigiCollection_ = params.getParameter<std::string>("EBZSdigiCollection");
00010   EEZSdigiCollection_ = params.getParameter<std::string>("EEZSdigiCollection");
00011 
00012   // initialize the default values for the thresholds in number of noise sigmas
00013 
00014   glbBarrelThreshold_ = params.getUntrackedParameter<double>("glbBarrelThreshold",0.2);
00015   glbEndcapThreshold_ = params.getUntrackedParameter<double>("glbEndcapThreshold",0.4);
00016 
00017   produces<EBDigiCollection>(EBZSdigiCollection_);
00018   produces<EEDigiCollection>(EEZSdigiCollection_);
00019 
00020 }
00021 
00022 
00023 EcalZeroSuppressionProducer::~EcalZeroSuppressionProducer() 
00024 { }
00025 
00026 
00027 void EcalZeroSuppressionProducer::produce(edm::Event& event, const edm::EventSetup& eventSetup) 
00028 {
00029   
00030   // Get Inputs
00031 
00032   initCalibrations(eventSetup);
00033   
00034   edm::Handle< EBDigiCollection > pEBDigis;
00035   edm::Handle< EEDigiCollection > pEEDigis;
00036   
00037   const EBDigiCollection* fullBarrelDigis =0;
00038   const EEDigiCollection* fullEndcapDigis =0;
00039   
00040   event.getByLabel( digiProducer_, pEBDigis);
00041   if (pEBDigis.isValid()){ 
00042     fullBarrelDigis = pEBDigis.product(); // get a ptr to the produc
00043     edm::LogInfo("ZeroSuppressionInfo") << "total # fullBarrelDigis: " << fullBarrelDigis->size() ;
00044   } else {
00045     edm::LogError("ZeroSuppressionError") << "Error! can't get the product " << EBdigiCollection_.c_str() ;
00046   }
00047   
00048   event.getByLabel( digiProducer_, pEEDigis);
00049   if (pEEDigis.isValid()){ 
00050     fullEndcapDigis = pEEDigis.product(); // get a ptr to the product
00051     edm::LogInfo("ZeroSuppressionInfo") << "total # fullEndcapDigis: " << fullEndcapDigis->size() ;
00052   } else {
00053     edm::LogError("ZeroSuppressionError") << "Error! can't get the product " << EEdigiCollection_.c_str() ;
00054   }
00055 
00056   // collection of zero suppressed digis to put in the event
00057   
00058   std::auto_ptr< EBDigiCollection > gzsBarrelDigis(new EBDigiCollection());
00059   std::auto_ptr< EEDigiCollection > gzsEndcapDigis(new EEDigiCollection());
00060 
00061   CaloDigiCollectionSorter sorter(5);
00062 
00063   // Barrel zero suppression
00064 
00065   if (fullBarrelDigis) {
00066 
00067     for(EBDigiCollection::const_iterator digiItr = (*fullBarrelDigis).begin();
00068         digiItr != (*fullBarrelDigis).end(); ++digiItr)
00069       {
00070         
00071         bool isAccepted = theBarrelZeroSuppressor_.accept(*digiItr, glbBarrelThreshold_);
00072         if (isAccepted) {
00073           (*gzsBarrelDigis).push_back(digiItr->id(), digiItr->begin());
00074         }
00075         
00076       }
00077     edm::LogInfo("ZeroSuppressionInfo") << "EB Digis: " << gzsBarrelDigis->size();
00078 
00079 
00080     //std::vector<EBDataFrame> sortedDigisEB = sorter.sortedVector(*gzsBarrelDigis);
00081     //LogDebug("ZeroSuppressionDump") << "Top 10 EB digis";
00082     //for(int i = 0; i < std::min(10,(int) sortedDigisEB.size()); ++i) 
00083     //  {
00084     //    LogDebug("ZeroSuppressionDump") << sortedDigisEB[i];
00085     //  }
00086   }
00087   
00088   // Endcap zero suppression
00089 
00090   if (fullEndcapDigis) {
00091 
00092     for(EEDigiCollection::const_iterator digiItr = (*fullEndcapDigis).begin();
00093         digiItr != (*fullEndcapDigis).end(); ++digiItr)
00094       {
00095         
00096         bool isAccepted = theEndcapZeroSuppressor_.accept(*digiItr, glbEndcapThreshold_);
00097         if (isAccepted) {
00098           (*gzsEndcapDigis).push_back(digiItr->id(), digiItr->begin());
00099         }
00100         
00101       }
00102     edm::LogInfo("ZeroSuppressionInfo") << "EB Digis: " << gzsBarrelDigis->size();
00103     
00104     //    std::vector<EEDataFrame> sortedDigisEE = sorter.sortedVector(*gzsEndcapDigis);
00105     //LogDebug("ZeroSuppressionDump")  << "Top 10 EE digis";
00106     //for(int i = 0; i < std::min(10,(int) sortedDigisEE.size()); ++i) 
00107     //  {
00108     //    LogDebug("ZeroSuppressionDump") << sortedDigisEE[i];
00109     //  }
00110   
00111   }
00112   // Step D: Put outputs into event
00113   event.put(gzsBarrelDigis, EBZSdigiCollection_);
00114   event.put(gzsEndcapDigis, EEZSdigiCollection_);
00115 
00116 }
00117 
00118 
00119 void EcalZeroSuppressionProducer::initCalibrations(const edm::EventSetup & eventSetup) {
00120 
00121   // Pedestals from event setup
00122                                                                                                                                                              
00123   edm::ESHandle<EcalPedestals> dbPed;
00124   eventSetup.get<EcalPedestalsRcd>().get( dbPed );
00125   const EcalPedestals * thePedestals=dbPed.product();
00126 
00127   theBarrelZeroSuppressor_.setPedestals( thePedestals );
00128   theEndcapZeroSuppressor_.setPedestals( thePedestals );
00129                                                                                                                                                              
00130 }