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 void setEvent(edm::Event const& e) const {evt = &e;} 00042 00043 void write(edm::Event &e) const; 00044 00045 void setHandles(const EcalUnpackerWorkerRecord & iRecord); 00046 void set(const edm::EventSetup & es) const; 00047 00048 unsigned int maxElementIndex() const { return EcalRegionCabling::maxElementIndex();} 00049 00050 private: 00051 00052 // This is bad design. EventSetup data types and Event product types 00053 // should not contain a pointer to the Event. The Event object has a 00054 // lifetime of one module and a pointer to it should not be saved in 00055 // these types. This is very fragile. This code needs to be redesigned 00056 // to remove this pointer entirely. 00057 mutable const edm::Event * evt; 00058 00059 DCCDataUnpacker * unpacker_; 00060 00061 EcalElectronicsMapper * myMap_; 00062 mutable std::auto_ptr<EBDigiCollection> productDigisEB; 00063 mutable std::auto_ptr<EEDigiCollection> productDigisEE; 00064 00065 friend class EcalRawToRecHitByproductProducer; 00066 mutable std::auto_ptr<EcalRawDataCollection> productDccHeaders; 00067 mutable std::auto_ptr< EBDetIdCollection> productInvalidGains; 00068 mutable std::auto_ptr< EBDetIdCollection> productInvalidGainsSwitch; 00069 mutable std::auto_ptr< EBDetIdCollection> productInvalidChIds; 00070 mutable std::auto_ptr< EEDetIdCollection> productInvalidEEGains; 00071 mutable std::auto_ptr<EEDetIdCollection> productInvalidEEGainsSwitch; 00072 mutable std::auto_ptr<EEDetIdCollection> productInvalidEEChIds; 00073 mutable std::auto_ptr<EBSrFlagCollection> productEBSrFlags; 00074 mutable std::auto_ptr<EESrFlagCollection> productEESrFlags; 00075 mutable std::auto_ptr<EcalTrigPrimDigiCollection> productTps; 00076 mutable std::auto_ptr<EcalPSInputDigiCollection> productPSs; 00077 mutable std::auto_ptr<EcalElectronicsIdCollection> productInvalidTTIds; 00078 mutable std::auto_ptr<EcalElectronicsIdCollection> productInvalidZSXtalIds; 00079 mutable std::auto_ptr<EcalElectronicsIdCollection> productInvalidBlockLengths; 00080 mutable std::auto_ptr<EcalPnDiodeDigiCollection> productPnDiodeDigis; 00081 mutable std::auto_ptr<EcalElectronicsIdCollection> productInvalidMemTtIds; 00082 mutable std::auto_ptr<EcalElectronicsIdCollection> productInvalidMemBlockSizes; 00083 mutable std::auto_ptr<EcalElectronicsIdCollection> productInvalidMemChIds; 00084 mutable std::auto_ptr<EcalElectronicsIdCollection> productInvalidMemGains; 00085 00086 mutable edm::ESHandle<EcalRegionCabling> cabling; 00087 00088 EcalUncalibRecHitWorkerBaseClass * UncalibWorker_; 00089 EcalRecHitWorkerBaseClass * CalibWorker_; 00090 00091 public: 00092 00093 template <class DID> void work(EcalDigiCollection::const_iterator & beginDigi, 00094 EcalDigiCollection::const_iterator & endDigi, 00095 std::auto_ptr<EcalUncalibratedRecHitCollection> & uncalibRecHits, 00096 std::auto_ptr< EcalRecHitCollection > & calibRechits)const{ 00097 // MyWatcher watcher("<Worker>"); 00098 LogDebug("EcalRawToRecHit|Worker")<<"ready to work on digis."; 00099 //<<watcher.lap(); 00100 00101 EcalDigiCollection::const_iterator itdg = beginDigi; 00102 /*R*/ LogDebug("EcalRawToRecHit|Worker")<<"iterator check." ; 00103 00104 for(; itdg != endDigi; ++itdg) 00105 { 00106 00107 //get the uncalibrated rechit 00108 /*R*/ LogDebug("EcalRawToRecHit|Worker")<<"ready to make Uncalib rechit." ; 00109 //<<watcher.lap(); 00110 if (!UncalibWorker_->run(*evt, itdg, *uncalibRecHits)) continue; 00111 EcalUncalibratedRecHit & EURH=uncalibRecHits->back(); 00112 00113 /*R*/ LogDebug("EcalRawToRecHit|Worker")<<"creating a rechit." ; 00114 //<<watcher.lap(); 00115 if (!CalibWorker_->run(*evt, EURH, *calibRechits)) continue; 00116 /*R*/ LogDebug("EcalRawToRecHit|Worker")<<"created." ; 00117 //<<watcher.lap(); 00118 00119 }//loop over digis 00120 } 00121 00122 }; 00123 00124 00125 #endif