Go to the documentation of this file.00001 #include "EventFilter/EcalRawToDigi/interface/EcalUnpackerWorker.h"
00002
00003 #include "RecoLocalCalo/EcalRecAlgos/interface/EcalRecHitSimpleAlgo.h"
00004
00005
00006 #include "CondFormats/DataRecord/interface/EcalPedestalsRcd.h"
00007 #include "CondFormats/DataRecord/interface/EcalGainRatiosRcd.h"
00008 #include "CondFormats/DataRecord/interface/EcalWeightXtalGroupsRcd.h"
00009 #include "CondFormats/DataRecord/interface/EcalTBWeightsRcd.h"
00010
00011 #include "CondFormats/DataRecord/interface/EcalIntercalibConstantsRcd.h"
00012 #include "CondFormats/DataRecord/interface/EcalADCToGeVConstantRcd.h"
00013 #include "CalibCalorimetry/EcalLaserCorrection/interface/EcalLaserDbRecord.h"
00014
00015 #include "RecoLocalCalo/EcalRecProducers/interface/EcalUncalibRecHitWorkerFactory.h"
00016 #include "RecoLocalCalo/EcalRecProducers/interface/EcalRecHitWorkerFactory.h"
00017
00018 EcalUnpackerWorker::EcalUnpackerWorker(const edm::ParameterSet & conf){
00020 edm::ParameterSet DCCpset = conf.getParameter<edm::ParameterSet>("DCCDataUnpacker");
00021 edm::ParameterSet EEMpset = conf.getParameter<edm::ParameterSet>("ElectronicsMapper");
00022
00023 unsigned int numbXtalTSamples_ = EEMpset.getParameter<unsigned int>("numbXtalTSamples");
00024 unsigned int numbTriggerTSamples_ = EEMpset.getParameter<unsigned int>("numbTriggerTSamples");
00025
00026 if( numbXtalTSamples_ <6 || numbXtalTSamples_>64 || (numbXtalTSamples_-2)%4 ){
00027 edm::LogError("IncorrectConfiguration")<<"Unsuported number of xtal time samples : "<<numbXtalTSamples_
00028 <<"\n Valid Number of xtal time samples are : 6,10,14,18,...,62";
00029 }
00030
00031 if( numbTriggerTSamples_ !=1 && numbTriggerTSamples_ !=4 && numbTriggerTSamples_ !=8 ){
00032 edm::LogError("IncorrectConfiguration")<<"Unsuported number of trigger time samples : "<<numbTriggerTSamples_
00033 <<"\n Valid number of trigger time samples are : 1, 4 or 8";
00034 }
00035
00036 myMap_ = new EcalElectronicsMapper(numbXtalTSamples_, numbTriggerTSamples_);
00037 std::vector<int> oFl = DCCpset.getParameter<std::vector<int> >("orderedFedList");
00038 std::vector<int> oDl = DCCpset.getParameter<std::vector<int> >("orderedDCCIdList");
00039 bool readResult = myMap_->makeMapFromVectors(oFl,oDl);
00040
00041 if(!readResult){
00042 edm::LogError("IncorrectConfiguration")<<"\n unable to configure EcalElectronicsMapper from vectors.";
00043 }
00044
00045 unpacker_ = new DCCDataUnpacker(myMap_,
00046 DCCpset.getParameter<bool>("headerUnpacking"),
00047 DCCpset.getParameter<bool>("srpUnpacking"),
00048 DCCpset.getParameter<bool>("tccUnpacking"),
00049 DCCpset.getParameter<bool>("feUnpacking"),
00050 DCCpset.getParameter<bool>("memUnpacking"),
00051 DCCpset.getParameter<bool>("syncCheck"),
00052 DCCpset.getParameter<bool>("feIdCheck"),
00053 DCCpset.getParameter<bool>("forceKeepFRData")
00054 );
00055
00056 unpacker_->setEBDigisCollection(&productDigisEB);
00057 unpacker_->setEEDigisCollection(&productDigisEE);
00058 unpacker_->setDccHeadersCollection(&productDccHeaders);
00059 unpacker_->setInvalidGainsCollection(&productInvalidGains);
00060 unpacker_->setInvalidGainsSwitchCollection(&productInvalidGainsSwitch);
00061 unpacker_->setInvalidChIdsCollection(&productInvalidChIds);
00062 unpacker_->setInvalidEEGainsCollection(&productInvalidEEGains);
00063 unpacker_->setInvalidEEGainsSwitchCollection(&productInvalidEEGainsSwitch);
00064 unpacker_->setInvalidEEChIdsCollection(&productInvalidEEChIds);
00065 unpacker_->setEBSrFlagsCollection(&productEBSrFlags);
00066 unpacker_->setEESrFlagsCollection(&productEESrFlags);
00067 unpacker_->setEcalTpsCollection(&productTps);
00068 unpacker_->setEcalPSsCollection(&productPSs);
00069 unpacker_->setInvalidTTIdsCollection(&productInvalidTTIds);
00070 unpacker_->setInvalidZSXtalIdsCollection(&productInvalidZSXtalIds);
00071 unpacker_->setInvalidBlockLengthsCollection(&productInvalidBlockLengths);
00072 unpacker_->setPnDiodeDigisCollection(&productPnDiodeDigis);
00073 unpacker_->setInvalidMemTtIdsCollection(& productInvalidMemTtIds);
00074 unpacker_->setInvalidMemBlockSizesCollection(& productInvalidMemBlockSizes);
00075 unpacker_->setInvalidMemChIdsCollection(& productInvalidMemChIds);
00076 unpacker_->setInvalidMemGainsCollection(& productInvalidMemGains);
00077
00078 DCCDataUnpacker::silentMode_ = conf.getUntrackedParameter<bool> ("silentMode",true);
00079
00080 edm::ParameterSet UncalibPSet = conf.getParameter<edm::ParameterSet>("UncalibRHAlgo");
00081 std::string UncaliComponentName = UncalibPSet.getParameter<std::string>("Type");
00082 UncalibWorker_ = EcalUncalibRecHitWorkerFactory::get()->create(UncaliComponentName, UncalibPSet);
00083
00084 edm::ParameterSet CalibPSet = conf.getParameter<edm::ParameterSet>("CalibRHAlgo");
00085 std::string CaliComponentName = CalibPSet.getParameter<std::string>("Type");
00086 CalibWorker_ = EcalRecHitWorkerFactory::get()->create(CaliComponentName, CalibPSet);
00087
00088 }
00089
00090 EcalUnpackerWorker::~EcalUnpackerWorker(){
00091
00092 delete myMap_;
00093 delete unpacker_;
00094 delete UncalibWorker_;
00095 delete CalibWorker_;
00096
00097 }
00098
00099 void EcalUnpackerWorker::setHandles(const EcalUnpackerWorkerRecord & iRecord) {
00100 iRecord.getRecord<EcalRegionCablingRecord>().get(cabling);
00101
00102 myMap_->setEcalElectronicsMapping(cabling->mapping());
00103 }
00104
00105 void EcalUnpackerWorker::set(const edm::EventSetup & es) const {
00106 UncalibWorker_->set(es);
00107 CalibWorker_->set(es);
00108 }
00109
00110 void EcalUnpackerWorker::write(edm::Event & e) const{
00111
00112 }
00113
00114 void EcalUnpackerWorker::update(const edm::Event & e)const{
00116 evt=&e;
00117
00118 const bool reserveMem =false;
00119
00121 productDigisEB.reset(new EBDigiCollection);
00122 productDigisEE.reset(new EEDigiCollection);
00123 productDccHeaders.reset(new EcalRawDataCollection);
00124 productInvalidGains.reset(new EBDetIdCollection);
00125 productInvalidGainsSwitch.reset(new EBDetIdCollection);
00126 productInvalidChIds.reset(new EBDetIdCollection);
00127 productInvalidEEGains.reset(new EEDetIdCollection);
00128 productInvalidEEGainsSwitch.reset(new EEDetIdCollection);
00129 productInvalidEEChIds.reset(new EEDetIdCollection);
00130 productEBSrFlags.reset(new EBSrFlagCollection);
00131 productEESrFlags.reset(new EESrFlagCollection);
00132 productTps.reset(new EcalTrigPrimDigiCollection);
00133 productPSs.reset(new EcalPSInputDigiCollection);
00134 productInvalidTTIds.reset(new EcalElectronicsIdCollection);
00135 productInvalidZSXtalIds.reset(new EcalElectronicsIdCollection);
00136 productInvalidBlockLengths.reset(new EcalElectronicsIdCollection);
00137 productPnDiodeDigis.reset(new EcalPnDiodeDigiCollection);
00138 productInvalidMemTtIds.reset(new EcalElectronicsIdCollection);
00139 productInvalidMemBlockSizes.reset(new EcalElectronicsIdCollection);
00140 productInvalidMemChIds.reset(new EcalElectronicsIdCollection);
00141 productInvalidMemGains.reset(new EcalElectronicsIdCollection);
00142
00143 if (reserveMem){
00144 productDigisEB->reserve(1700);
00145 productDigisEE->reserve(1700);
00146 }
00147
00148 }
00149
00150
00151 std::auto_ptr< EcalRecHitCollection > EcalUnpackerWorker::work(const uint32_t & index, const FEDRawDataCollection & rawdata)const{
00152 MyWatcher watcher("Worker");
00153 LogDebug("EcalRawToRecHit|Worker")<<"is going to work on index: "<<index
00154 <<"for fed Id: "<<EcalRegionCabling::fedIndex(index)<<watcher.lap();
00155
00156 int fedIndex = EcalRegionCabling::fedIndex(index);
00157
00158 const FEDRawData & fedData = rawdata.FEDData(fedIndex);
00159
00160
00161 LogDebug("EcalRawToRecHit|Worker")
00162 <<"size of digi collections before unpacking: "
00163 <<(*unpacker_->ebDigisCollection())->size()
00164 <<" "<<(*unpacker_->eeDigisCollection())->size()
00165 <<watcher.lap();
00166
00167 EcalDigiCollection::const_iterator beginDigiEB = (*unpacker_->ebDigisCollection())->end();
00168 EcalDigiCollection::const_iterator beginDigiEE = (*unpacker_->eeDigisCollection())->end();
00169
00170
00171
00172 int smId =0;
00173 int length = fedData.size();
00174 if ( length >= EMPTYEVENTSIZE ){
00175 if(myMap_->setActiveDCC(fedIndex)){
00176 smId = myMap_->getActiveSM();
00177 uint64_t * pData = (uint64_t *)(fedData.data());
00178 LogDebug("EcalRawToRecHit|Worker")<<"calling the unpacker: "<<length<<" "<<smId<<" "<<fedIndex
00179 <<watcher.lap();
00180 unpacker_->unpack( pData, static_cast<unsigned int>(length),smId,fedIndex);
00181 LogDebug("EcalRawToRecHit|Worker")<<"unpacking done."
00182 <<watcher.lap();
00183 }
00184 else{
00185 edm::LogInfo("EcalUnpackerWorker")<<"cannot set: "<<fedIndex<<" to be an active DCC.";
00186 LogDebug("EcalRawToRecHit|Worker")<<"cannot set: "<<fedIndex<<" to be an active DCC.";
00187 return std::auto_ptr< EcalRecHitCollection >(new EcalRecHitCollection);
00188 }
00189 }
00190 else {
00191 edm::LogInfo("EcalUnpackerWorker")<<"empty event on this FED: "<<fedIndex<<" length: "<<length;
00192 LogDebug("EcalRawToRecHit|Worker")<<"empty event on this FED: "<<fedIndex<<" length: "<<length;
00193 return std::auto_ptr< EcalRecHitCollection >(new EcalRecHitCollection);
00194 }
00195
00196 LogDebug("EcalRawToRecHit|Worker")
00197 <<"size of digi collections after unpacking: "
00198 <<(*unpacker_->ebDigisCollection())->size()
00199 <<" "<<(*unpacker_->eeDigisCollection())->size()
00200 <<watcher.lap();
00201 EcalDigiCollection::const_iterator endDigiEB = (*unpacker_->ebDigisCollection())->end();
00202 EcalDigiCollection::const_iterator endDigiEE = (*unpacker_->eeDigisCollection())->end();
00203
00204
00205 std::auto_ptr< EcalRecHitCollection > ecalrechits( new EcalRecHitCollection );
00206 std::auto_ptr< EcalUncalibratedRecHitCollection > uncalibRecHits( new EcalUncalibratedRecHitCollection );
00207
00208 LogDebug("EcalRawToRecHit|Worker")<<"going to work on EE rechits from: "<<endDigiEE-beginDigiEE<<" digis."
00209 <<"\ngoing to work on EB rechits from: "<<endDigiEB-beginDigiEB<<" digis."
00210 <<watcher.lap();
00211
00212
00213 if (beginDigiEB!=endDigiEB){
00214 work<EBDetId>(beginDigiEB, endDigiEB, uncalibRecHits, ecalrechits);
00215 }
00216 LogDebug("EcalRawToRecHit|Worker")<<uncalibRecHits->size()<<" uncalibrated rechit created so far\n"
00217 <<ecalrechits->size()<<" rechit created so far."
00218 <<watcher.lap();
00219
00220
00221 if (beginDigiEE!=endDigiEE){
00222 work<EEDetId>(beginDigiEE, endDigiEE, uncalibRecHits, ecalrechits);
00223 }
00224 LogDebug("EcalRawToRecHit|Worker")<<uncalibRecHits->size()<<" uncalibrated rechit created eventually\n"
00225 <<ecalrechits->size()<<" rechit created eventually"
00226 <<watcher.lap();
00227
00228 return ecalrechits;
00229 }