CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
EcalUnpackerWorker.cc
Go to the documentation of this file.
2 
4 
5 
10 
14 
17 
20  edm::ParameterSet DCCpset = conf.getParameter<edm::ParameterSet>("DCCDataUnpacker");
21  edm::ParameterSet EEMpset = conf.getParameter<edm::ParameterSet>("ElectronicsMapper");
22 
23  unsigned int numbXtalTSamples_ = EEMpset.getParameter<unsigned int>("numbXtalTSamples");
24  unsigned int numbTriggerTSamples_ = EEMpset.getParameter<unsigned int>("numbTriggerTSamples");
25 
26  if( numbXtalTSamples_ <6 || numbXtalTSamples_>64 || (numbXtalTSamples_-2)%4 ){
27  edm::LogError("IncorrectConfiguration")<<"Unsuported number of xtal time samples : "<<numbXtalTSamples_
28  <<"\n Valid Number of xtal time samples are : 6,10,14,18,...,62";
29  }
30 
31  if( numbTriggerTSamples_ !=1 && numbTriggerTSamples_ !=4 && numbTriggerTSamples_ !=8 ){
32  edm::LogError("IncorrectConfiguration")<<"Unsuported number of trigger time samples : "<<numbTriggerTSamples_
33  <<"\n Valid number of trigger time samples are : 1, 4 or 8";
34  }
35 
36  myMap_ = new EcalElectronicsMapper(numbXtalTSamples_, numbTriggerTSamples_);
37  std::vector<int> oFl = DCCpset.getParameter<std::vector<int> >("orderedFedList");
38  std::vector<int> oDl = DCCpset.getParameter<std::vector<int> >("orderedDCCIdList");
39  bool readResult = myMap_->makeMapFromVectors(oFl,oDl);
40 
41  if(!readResult){
42  edm::LogError("IncorrectConfiguration")<<"\n unable to configure EcalElectronicsMapper from vectors.";
43  }
44 
46  DCCpset.getParameter<bool>("headerUnpacking"),
47  DCCpset.getParameter<bool>("srpUnpacking"),
48  DCCpset.getParameter<bool>("tccUnpacking"),
49  DCCpset.getParameter<bool>("feUnpacking"),
50  DCCpset.getParameter<bool>("memUnpacking"),
51  DCCpset.getParameter<bool>("syncCheck"),
52  DCCpset.getParameter<bool>("feIdCheck"),
53  DCCpset.getParameter<bool>("forceKeepFRData")
54  );
55  edm::LogInfo("EcalRawToRecHit")
56  <<"\n ECAL RawToDigi within RawToRecHit configuration:"
57  <<"\n Header unpacking is "<<DCCpset.getParameter<bool>("headerUnpacking")
58  <<"\n SRP Bl. unpacking is "<<DCCpset.getParameter<bool>("srpUnpacking")
59  <<"\n TCC Bl. unpacking is "<<DCCpset.getParameter<bool>("tccUnpacking")
60  <<"\n FE Bl. unpacking is "<<DCCpset.getParameter<bool>("feUnpacking")
61  <<"\n MEM Bl. unpacking is "<<DCCpset.getParameter<bool>("memUnpacking")
62  <<"\n sync check is "<<DCCpset.getParameter<bool>("syncCheck")
63  <<"\n feID check is "<<DCCpset.getParameter<bool>("feIdCheck")
64  <<"\n force keep FR data is "<<DCCpset.getParameter<bool>("forceKeepFRData")
65  <<"\n";
66 
88 
89  DCCDataUnpacker::silentMode_ = conf.getUntrackedParameter<bool> ("silentMode",true);
90 
91  edm::ParameterSet UncalibPSet = conf.getParameter<edm::ParameterSet>("UncalibRHAlgo");
92  std::string UncaliComponentName = UncalibPSet.getParameter<std::string>("Type");
93  UncalibWorker_ = EcalUncalibRecHitWorkerFactory::get()->create(UncaliComponentName, UncalibPSet);
94 
95  edm::ParameterSet CalibPSet = conf.getParameter<edm::ParameterSet>("CalibRHAlgo");
96  std::string CaliComponentName = CalibPSet.getParameter<std::string>("Type");
97  CalibWorker_ = EcalRecHitWorkerFactory::get()->create(CaliComponentName, CalibPSet);
98 
99 }
100 
102  //delete everything that is own by the EcalUnpackerWorker
103  delete myMap_;
104  delete unpacker_;
105  delete UncalibWorker_;
106  delete CalibWorker_;
107 
108 }
109 
111  iRecord.getRecord<EcalRegionCablingRecord>().get(cabling);
112  //the mapping is set as long as the mapping is valid.
114 }
115 
116 void EcalUnpackerWorker::set(const edm::EventSetup & es) const {
117  UncalibWorker_->set(es);
118  CalibWorker_->set(es);
119 }
120 
122  //write the collection in the event as requested.
123 }
124 
127  evt=&e;
128 
129  const bool reserveMem =true;
130 
132  productDigisEB.reset(new EBDigiCollection);
133  productDigisEE.reset(new EEDigiCollection);
153 
154  if (reserveMem){
155  productDigisEB->reserve(1700);
156  productDigisEE->reserve(1700);
157  }
158 
159  }
160 
161 
162 std::auto_ptr< EcalRecHitCollection > EcalUnpackerWorker::work(const uint32_t & index, const FEDRawDataCollection & rawdata)const{
163 // MyWatcher watcher("Worker");
164  LogDebug("EcalRawToRecHit|Worker")<<"is going to work on index: "<<index
165  <<"for fed Id: "<<EcalRegionCabling::fedIndex(index);
166 //<<watcher.lap();
167 //std::cout<<watcher.lap() <<std::endl;
168  int fedIndex = EcalRegionCabling::fedIndex(index);
169 
170  const FEDRawData & fedData = rawdata.FEDData(fedIndex);
171 
172  //remember where the iterators were before unpacking
173  LogDebug("EcalRawToRecHit|Worker")
174  <<"size of digi collections before unpacking: "
175  <<(*unpacker_->ebDigisCollection())->size()
176  <<" "<<(*unpacker_->eeDigisCollection())->size();
177  // <<watcher.lap();
178 
181 
182  //###### get the digi #######
183  // unpack first
184  int smId =0;
185  int length = fedData.size();
186  if ( length >= EMPTYEVENTSIZE ){
187  if(myMap_->setActiveDCC(fedIndex)){
188  smId = myMap_->getActiveSM();
189  uint64_t * pData = (uint64_t *)(fedData.data());
190  LogDebug("EcalRawToRecHit|Worker")<<"calling the unpacker: "<<length<<" "<<smId<<" "<<fedIndex ;
191 // <<watcher.lap();
192  unpacker_->unpack( pData, static_cast<unsigned int>(length),smId,fedIndex);
193  LogDebug("EcalRawToRecHit|Worker")<<"unpacking done." ;
194 // <<watcher.lap();
195  }
196  else{
197  edm::LogInfo("EcalUnpackerWorker")<<"cannot set: "<<fedIndex<<" to be an active DCC.";
198  LogDebug("EcalRawToRecHit|Worker")<<"cannot set: "<<fedIndex<<" to be an active DCC.";
199  return std::auto_ptr< EcalRecHitCollection >(new EcalRecHitCollection);
200  }
201  }
202  else {
203  edm::LogInfo("EcalUnpackerWorker")<<"empty event on this FED: "<<fedIndex<<" length: "<<length;
204  LogDebug("EcalRawToRecHit|Worker")<<"empty event on this FED: "<<fedIndex<<" length: "<<length;
205  return std::auto_ptr< EcalRecHitCollection >(new EcalRecHitCollection);
206  }
207 
208  LogDebug("EcalRawToRecHit|Worker")
209  <<"size of digi collections after unpacking: "
210  <<(*unpacker_->ebDigisCollection())->size()
211  <<" "<<(*unpacker_->eeDigisCollection())->size() ;
212 // <<watcher.lap();
215 
216  //collection for the rechits: uncalib and final
217  std::auto_ptr< EcalRecHitCollection > ecalrechits( new EcalRecHitCollection );
218  std::auto_ptr< EcalUncalibratedRecHitCollection > uncalibRecHits( new EcalUncalibratedRecHitCollection );
219 
220  LogDebug("EcalRawToRecHit|Worker")<<"going to work on EE rechits from: "<<endDigiEE-beginDigiEE<<" digis."
221  <<"\ngoing to work on EB rechits from: "<<endDigiEB-beginDigiEB<<" digis." ;
222 // <<watcher.lap();
223  // EB
224  //make the uncalibrated rechits on the fly
225  if (beginDigiEB!=endDigiEB){
226  work<EBDetId>(beginDigiEB, endDigiEB, uncalibRecHits, ecalrechits);
227  }
228  LogDebug("EcalRawToRecHit|Worker")<<uncalibRecHits->size()<<" uncalibrated rechit created so far\n"
229  <<ecalrechits->size()<<" rechit created so far." ;
230 // <<watcher.lap();
231 
232  // EE
233  if (beginDigiEE!=endDigiEE){
234  work<EEDetId>(beginDigiEE, endDigiEE, uncalibRecHits, ecalrechits);
235  }
236  LogDebug("EcalRawToRecHit|Worker")<<uncalibRecHits->size()<<" uncalibrated rechit created eventually\n"
237  <<ecalrechits->size()<<" rechit created eventually" ;
238 // <<watcher.lap();
239 
240  return ecalrechits;
241 }
#define LogDebug(id)
T getParameter(std::string const &) const
std::auto_ptr< EcalRecHitCollection > work(const uint32_t &i, const FEDRawDataCollection &) const
void setPnDiodeDigisCollection(std::auto_ptr< EcalPnDiodeDigiCollection > *x)
T getUntrackedParameter(std::string const &, T const &) const
std::auto_ptr< EEDetIdCollection > productInvalidEEGainsSwitch
EcalRecHitWorkerBaseClass * CalibWorker_
std::auto_ptr< EcalTrigPrimDigiCollection > productTps
std::auto_ptr< EcalPSInputDigiCollection > productPSs
std::auto_ptr< EcalElectronicsIdCollection > productInvalidBlockLengths
std::auto_ptr< EcalPnDiodeDigiCollection > productPnDiodeDigis
boost::transform_iterator< IterHelp, boost::counting_iterator< int > > const_iterator
virtual void set(const edm::EventSetup &es)=0
void unpack(const uint64_t *buffer, size_t bufferSize, unsigned int smId, unsigned int fedId)
void setInvalidZSXtalIdsCollection(std::auto_ptr< EcalElectronicsIdCollection > *x)
DCCDataUnpacker * unpacker_
void setInvalidMemBlockSizesCollection(std::auto_ptr< EcalElectronicsIdCollection > *x)
std::auto_ptr< EEDetIdCollection > productInvalidEEGains
EcalUncalibRecHitWorkerBaseClass * UncalibWorker_
void setDccHeadersCollection(std::auto_ptr< EcalRawDataCollection > *x)
void setEcalPSsCollection(std::auto_ptr< EcalPSInputDigiCollection > *x)
std::auto_ptr< EBSrFlagCollection > productEBSrFlags
void setInvalidEEGainsSwitchCollection(std::auto_ptr< EEDetIdCollection > *x)
void setEEDigisCollection(std::auto_ptr< EEDigiCollection > *x)
std::auto_ptr< EESrFlagCollection > productEESrFlags
void setEcalElectronicsMapping(const EcalElectronicsMapping *)
size_t size() const
Lenght of the data buffer in bytes.
Definition: FEDRawData.h:49
std::auto_ptr< EBDetIdCollection > productInvalidChIds
static bool silentMode_
std::auto_ptr< EEDigiCollection > productDigisEE
void setInvalidMemTtIdsCollection(std::auto_ptr< EcalElectronicsIdCollection > *x)
std::auto_ptr< EcalElectronicsIdCollection > productInvalidMemTtIds
static int fedIndex(const uint32_t index)
void setEBSrFlagsCollection(std::auto_ptr< EBSrFlagCollection > *x)
const FEDRawData & FEDData(int fedid) const
retrieve data for fed
bool setActiveDCC(unsigned int dccId)
void setEBDigisCollection(std::auto_ptr< EBDigiCollection > *x)
bool makeMapFromVectors(std::vector< int > &, std::vector< int > &)
void setInvalidMemGainsCollection(std::auto_ptr< EcalElectronicsIdCollection > *x)
void setInvalidGainsCollection(std::auto_ptr< EBDetIdCollection > *x)
#define end
Definition: vmac.h:38
void setInvalidEEChIdsCollection(std::auto_ptr< EEDetIdCollection > *x)
void update(const edm::Event &e) const
tuple conf
Definition: dbtoconf.py:185
void setInvalidTTIdsCollection(std::auto_ptr< EcalElectronicsIdCollection > *x)
std::auto_ptr< EBDetIdCollection > productInvalidGainsSwitch
std::auto_ptr< EBDigiCollection > productDigisEB
std::auto_ptr< EBDetIdCollection > productInvalidGains
void setInvalidGainsSwitchCollection(std::auto_ptr< EBDetIdCollection > *x)
void write(edm::Event &e) const
unsigned long long uint64_t
Definition: Time.h:15
void setEESrFlagsCollection(std::auto_ptr< EESrFlagCollection > *x)
void setHandles(const EcalUnpackerWorkerRecord &iRecord)
EcalElectronicsMapper * myMap_
EcalUnpackerWorker(const edm::ParameterSet &conf)
virtual void set(const edm::EventSetup &es)=0
std::auto_ptr< EcalElectronicsIdCollection > productInvalidMemBlockSizes
edm::ESHandle< EcalRegionCabling > cabling
std::auto_ptr< EEDetIdCollection > productInvalidEEChIds
std::auto_ptr< EcalElectronicsIdCollection > productInvalidMemGains
std::auto_ptr< EcalElectronicsIdCollection > productInvalidTTIds
const unsigned char * data() const
Return a const pointer to the beginning of the data buffer.
Definition: FEDRawData.cc:29
std::auto_ptr< EEDigiCollection > * eeDigisCollection()
const edm::Event * evt
std::auto_ptr< EcalElectronicsIdCollection > productInvalidMemChIds
void setEcalTpsCollection(std::auto_ptr< EcalTrigPrimDigiCollection > *x)
void setInvalidMemChIdsCollection(std::auto_ptr< EcalElectronicsIdCollection > *x)
void setInvalidBlockLengthsCollection(std::auto_ptr< EcalElectronicsIdCollection > *x)
dictionary rawdata
Definition: lumiPlot.py:393
void setInvalidEEGainsCollection(std::auto_ptr< EEDetIdCollection > *x)
std::auto_ptr< EBDigiCollection > * ebDigisCollection()
std::auto_ptr< EcalElectronicsIdCollection > productInvalidZSXtalIds
void set(const edm::EventSetup &es) const
tuple size
Write out results.
std::auto_ptr< EcalRawDataCollection > productDccHeaders
T get(const Candidate &c)
Definition: component.h:56
edm::SortedCollection< EcalRecHit > EcalRecHitCollection
void setInvalidChIdsCollection(std::auto_ptr< EBDetIdCollection > *x)