CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_1_8_patch12/src/EventFilter/EcalRawToDigi/interface/EcalUnpackerWorker.h

Go to the documentation of this file.
00001 #ifndef EcalUnpackerWorker_H
00002 #define EcalUnpackerWorker_H
00003 
00004 #include "FWCore/Framework/interface/ESHandle.h"
00005 #include "DataFormats/FEDRawData/interface/FEDRawData.h"
00006 #include "DataFormats/EcalRecHit/interface/EcalRecHitCollections.h"
00007 #include "FWCore/Framework/interface/Event.h"
00008 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00009 #include "EventFilter/EcalRawToDigi/interface/DCCDataUnpacker.h"
00010 #include "EventFilter/EcalRawToDigi/interface/EcalElectronicsMapper.h"
00011 #include "DataFormats/EcalDigi/interface/EcalDigiCollections.h"
00012 #include "DataFormats/EcalRawData/interface/EcalRawDataCollections.h"
00013 
00014 #include "EventFilter/EcalRawToDigi/interface/EcalUnpackerWorkerRecord.h"
00015 #include "EventFilter/EcalRawToDigi/interface/EcalRegionCabling.h"
00016 
00017 #include "RecoLocalCalo/EcalRecProducers/interface/EcalUncalibRecHitWorkerBaseClass.h"
00018 #include "RecoLocalCalo/EcalRecProducers/interface/EcalRecHitWorkerBaseClass.h"
00019 
00020 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00021 
00022 #include "EventFilter/EcalRawToDigi/interface/MyWatcher.h"
00023 
00024 #include "EventFilter/EcalRawToDigi/interface/EcalUnpackerWorkerBase.h"
00025 
00026 //forward declaration. just to be friend
00027 class EcalRawToRecHitByproductProducer;
00028 
00029 class EcalUnpackerWorker : public EcalUnpackerWorkerBase {
00030  public:
00031 
00032   EcalUnpackerWorker(const edm::ParameterSet & conf);
00033   
00034   ~EcalUnpackerWorker();
00035   
00036   // the method that does it all
00037   std::auto_ptr<EcalRecHitCollection> work(const uint32_t & i, const FEDRawDataCollection&) const;
00038   
00039   // method to set things up once per event
00040   void update(const edm::Event & e) const;
00041   
00042   void write(edm::Event &e) const;
00043 
00044   void setHandles(const EcalUnpackerWorkerRecord & iRecord);
00045   void set(const edm::EventSetup & es) const;
00046 
00047   unsigned int maxElementIndex() const { return EcalRegionCabling::maxElementIndex();}
00048   
00049  private:
00050 
00051   mutable const edm::Event * evt;
00052 
00053   DCCDataUnpacker * unpacker_;
00054 
00055   EcalElectronicsMapper * myMap_;
00056   mutable std::auto_ptr<EBDigiCollection> productDigisEB;
00057   mutable std::auto_ptr<EEDigiCollection> productDigisEE;
00058 
00059   friend class EcalRawToRecHitByproductProducer;
00060   mutable std::auto_ptr<EcalRawDataCollection> productDccHeaders;
00061   mutable std::auto_ptr< EBDetIdCollection> productInvalidGains;
00062   mutable std::auto_ptr< EBDetIdCollection> productInvalidGainsSwitch;
00063   mutable std::auto_ptr< EBDetIdCollection> productInvalidChIds;
00064   mutable std::auto_ptr< EEDetIdCollection> productInvalidEEGains;
00065   mutable std::auto_ptr<EEDetIdCollection> productInvalidEEGainsSwitch;
00066   mutable std::auto_ptr<EEDetIdCollection> productInvalidEEChIds;
00067   mutable std::auto_ptr<EBSrFlagCollection> productEBSrFlags;
00068   mutable std::auto_ptr<EESrFlagCollection> productEESrFlags;
00069   mutable std::auto_ptr<EcalTrigPrimDigiCollection> productTps;
00070   mutable std::auto_ptr<EcalPSInputDigiCollection> productPSs;
00071   mutable std::auto_ptr<EcalElectronicsIdCollection> productInvalidTTIds;
00072   mutable std::auto_ptr<EcalElectronicsIdCollection> productInvalidZSXtalIds;
00073   mutable std::auto_ptr<EcalElectronicsIdCollection> productInvalidBlockLengths;
00074   mutable std::auto_ptr<EcalPnDiodeDigiCollection> productPnDiodeDigis;
00075   mutable std::auto_ptr<EcalElectronicsIdCollection> productInvalidMemTtIds;
00076   mutable std::auto_ptr<EcalElectronicsIdCollection> productInvalidMemBlockSizes;
00077   mutable std::auto_ptr<EcalElectronicsIdCollection> productInvalidMemChIds;
00078   mutable std::auto_ptr<EcalElectronicsIdCollection> productInvalidMemGains;
00079 
00080   mutable edm::ESHandle<EcalRegionCabling> cabling;
00081 
00082   EcalUncalibRecHitWorkerBaseClass * UncalibWorker_;
00083   EcalRecHitWorkerBaseClass * CalibWorker_;
00084 
00085  public:
00086 
00087   template <class DID> void work(EcalDigiCollection::const_iterator & beginDigi,
00088                                  EcalDigiCollection::const_iterator & endDigi,
00089                                  std::auto_ptr<EcalUncalibratedRecHitCollection> & uncalibRecHits,
00090                                  std::auto_ptr< EcalRecHitCollection > & calibRechits)const{
00091     MyWatcher watcher("<Worker>");
00092     LogDebug("EcalRawToRecHit|Worker")<<"ready to work on digis."<<watcher.lap();
00093 
00094     EcalDigiCollection::const_iterator itdg = beginDigi;
00095     /*R*/ LogDebug("EcalRawToRecHit|Worker")<<"iterator check." ;
00096 
00097     for(; itdg != endDigi; ++itdg) 
00098       {
00099 
00100         //get the uncalibrated rechit
00101         /*R*/ LogDebug("EcalRawToRecHit|Worker")<<"ready to make Uncalib rechit."<<watcher.lap();
00102         if (!UncalibWorker_->run(*evt, itdg, *uncalibRecHits)) continue;
00103         EcalUncalibratedRecHit & EURH=uncalibRecHits->back();
00104 
00105         /*R*/ LogDebug("EcalRawToRecHit|Worker")<<"creating a rechit."<<watcher.lap();
00106         if (!CalibWorker_->run(*evt, EURH, *calibRechits)) continue;
00107         /*R*/ LogDebug("EcalRawToRecHit|Worker")<<"created."<<watcher.lap();
00108 
00109       }//loop over digis
00110   }
00111 
00112 };
00113 
00114 
00115 #endif