CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_6_1_2_SLHC2/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.";
00093 //<<watcher.lap();
00094 
00095     EcalDigiCollection::const_iterator itdg = beginDigi;
00096     /*R*/ LogDebug("EcalRawToRecHit|Worker")<<"iterator check." ;
00097 
00098     for(; itdg != endDigi; ++itdg) 
00099       {
00100 
00101         //get the uncalibrated rechit
00102         /*R*/ LogDebug("EcalRawToRecHit|Worker")<<"ready to make Uncalib rechit." ;
00103 //<<watcher.lap();
00104         if (!UncalibWorker_->run(*evt, itdg, *uncalibRecHits)) continue;
00105         EcalUncalibratedRecHit & EURH=uncalibRecHits->back();
00106 
00107         /*R*/ LogDebug("EcalRawToRecHit|Worker")<<"creating a rechit." ;
00108 //<<watcher.lap();
00109         if (!CalibWorker_->run(*evt, EURH, *calibRechits)) continue;
00110         /*R*/ LogDebug("EcalRawToRecHit|Worker")<<"created." ;
00111 //<<watcher.lap();
00112 
00113       }//loop over digis
00114   }
00115 
00116 };
00117 
00118 
00119 #endif