CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_6_2_5/src/EventFilter/EcalRawToDigi/plugins/EcalRawToRecHitByproductProducer.cc

Go to the documentation of this file.
00001 #include "EventFilter/EcalRawToDigi/plugins/EcalRawToRecHitByproductProducer.h"
00002 #include "EventFilter/EcalRawToDigi/interface/EcalUnpackerWorkerRecord.h"
00003 #include "EventFilter/EcalRawToDigi/interface/EcalUnpackerWorker.h"
00004 #include "DataFormats/Common/interface/Handle.h"
00005 #include "DataFormats/Common/interface/LazyGetter.h"
00006 #include "DataFormats/EcalRecHit/interface/EcalRecHit.h"
00007 #include "DataFormats/EcalRecHit/interface/EcalRecHitComparison.h"
00008 #include "FWCore/Framework/interface/Event.h"
00009 
00010 
00011 EcalRawToRecHitByproductProducer::EcalRawToRecHitByproductProducer(const edm::ParameterSet& iConfig)
00012 {
00013   workerName_ = iConfig.getParameter<std::string>("workerName");
00014 
00015   produces<EBDigiCollection>("ebDigis"); 
00016   produces<EEDigiCollection>("eeDigis");
00017 
00018   produces<EBSrFlagCollection>();
00019   produces<EESrFlagCollection>();
00020   produces<EcalRawDataCollection>();
00021   produces<EcalPnDiodeDigiCollection>();
00022   produces<EcalTrigPrimDigiCollection>("EcalTriggerPrimitives");
00023   produces<EcalPSInputDigiCollection>("EcalPseudoStripInputs");
00024   
00025   // Integrity for xtal data
00026   produces<EBDetIdCollection>("EcalIntegrityGainErrors");
00027   produces<EBDetIdCollection>("EcalIntegrityGainSwitchErrors");
00028   produces<EBDetIdCollection>("EcalIntegrityChIdErrors");
00029 
00030   // Integrity for xtal data - EE specific (to be rivisited towards EB+EE common collection)
00031   produces<EEDetIdCollection>("EcalIntegrityGainErrors");
00032   produces<EEDetIdCollection>("EcalIntegrityGainSwitchErrors");
00033   produces<EEDetIdCollection>("EcalIntegrityChIdErrors");
00034 
00035   // Integrity Errors
00036   produces<EcalElectronicsIdCollection>("EcalIntegrityTTIdErrors");
00037   produces<EcalElectronicsIdCollection>("EcalIntegrityZSXtalIdErrors");
00038   produces<EcalElectronicsIdCollection>("EcalIntegrityBlockSizeErrors");
00039  
00040   // Mem channels' integrity
00041   produces<EcalElectronicsIdCollection>("EcalIntegrityMemTtIdErrors");
00042   produces<EcalElectronicsIdCollection>("EcalIntegrityMemBlockSizeErrors");
00043   produces<EcalElectronicsIdCollection>("EcalIntegrityMemChIdErrors");
00044   produces<EcalElectronicsIdCollection>("EcalIntegrityMemGainErrors");
00045 }
00046 
00047 
00048 // ------------ method called to produce the data  ------------
00049 void
00050 EcalRawToRecHitByproductProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup)
00051 {
00052   // The next two lines are a temporary fix so that this
00053   // module will run without a fatal exception in unscheduled
00054   // mode. In scheduled mode, these two lines should have no
00055   // effect, but in unscheduled mode this will ensure the module
00056   // that creates the objects this module puts into the Event
00057   // is executed before this module.  This does NOT ensure the
00058   // objects are properly filled.  The plan is that this part
00059   // of the code will be completely rewritten in the near future.
00060   // In this rewrite the EcalUnpackerWorker will no longer be
00061   // written to either the Event or EventSetup and this problem
00062   // will be resolved in a permanent manner. 
00063   edm::Handle<edm::LazyGetter<EcalRecHit> > lgetter;
00064   iEvent.getByLabel("hltEcalRawToRecHitFacility", lgetter);
00065 
00066   //retrieve the unpacker worker
00067   edm::ESHandle<EcalUnpackerWorkerBase> workerESH;
00068   iSetup.get<EcalUnpackerWorkerRecord>().get(workerName_, workerESH);
00069   const EcalUnpackerWorker * worker =  dynamic_cast<const EcalUnpackerWorker *>(&*workerESH);
00070   if (!worker) 
00071     edm::LogError("IncorrectConfiguration")<<"worker "<< workerName_ <<" could not be cast in EcalUnpackerWorker type."
00072                                                <<" this must be a configuration mistake. Expect a segfault right now.";
00073 
00074   LogDebug("EcalRawToRecHit|Byproducts")<<"worker retrieved.";
00075 
00076   //prepare output collections
00077   std::auto_ptr<EBDigiCollection> productDigisEB(worker->productDigisEB);
00078   
00079   // create the collection of Ecal Digis
00080   std::auto_ptr<EEDigiCollection> productDigisEE(worker->productDigisEE);
00081 
00082   // create the collection for headers
00083   std::auto_ptr<EcalRawDataCollection> productDccHeaders(worker->productDccHeaders);
00084 
00085   // create the collection for invalid gains
00086   std::auto_ptr< EBDetIdCollection> productInvalidGains(worker->productInvalidGains);
00087 
00088   // create the collection for invalid gain Switch
00089   std::auto_ptr< EBDetIdCollection> productInvalidGainsSwitch(worker->productInvalidGainsSwitch);
00090   
00091   // create the collection for invalid chids
00092   std::auto_ptr< EBDetIdCollection> productInvalidChIds(worker->productInvalidChIds);
00093   
00095     
00096   // create the collection for invalid gains
00097   std::auto_ptr<EEDetIdCollection> productInvalidEEGains(worker->productInvalidEEGains);
00098     
00099   // create the collection for invalid gain Switch
00100   std::auto_ptr<EEDetIdCollection> productInvalidEEGainsSwitch(worker->productInvalidEEGainsSwitch);
00101     
00102   // create the collection for invalid chids
00103   std::auto_ptr<EEDetIdCollection> productInvalidEEChIds(worker->productInvalidEEChIds);
00104   
00106     
00107   // create the collection for EB srflags       
00108   std::auto_ptr<EBSrFlagCollection> productEBSrFlags(worker->productEBSrFlags);
00109   
00110   // create the collection for EB srflags       
00111   std::auto_ptr<EESrFlagCollection> productEESrFlags(worker->productEESrFlags);
00112   
00113   // create the collection for ecal trigger primitives
00114   std::auto_ptr<EcalTrigPrimDigiCollection> productEcalTps(worker->productTps);
00115 
00116   // create the collection for ecal trigger primitives
00117   std::auto_ptr<EcalPSInputDigiCollection> productEcalPSs(worker->productPSs);
00118 
00120 
00121   // create the collection for invalid TTIds
00122   std::auto_ptr<EcalElectronicsIdCollection> productInvalidTTIds(worker->productInvalidTTIds);
00123  
00124   // create the collection for invalid XtalIds
00125   std::auto_ptr<EcalElectronicsIdCollection> productInvalidZSXtalIds(worker->productInvalidZSXtalIds);
00126  
00127   // create the collection for invalid BlockLengths
00128   std::auto_ptr<EcalElectronicsIdCollection> productInvalidBlockLengths(worker->productInvalidBlockLengths);
00129   
00130   // MEMs Collections
00131   // create the collection for the Pn Diode Digis
00132   std::auto_ptr<EcalPnDiodeDigiCollection> productPnDiodeDigis(worker->productPnDiodeDigis);
00133   
00134   // create the collection for invalid Mem Tt id 
00135   std::auto_ptr<EcalElectronicsIdCollection> productInvalidMemTtIds(worker->productInvalidMemTtIds);
00136   
00137   // create the collection for invalid Mem Block Size 
00138   std::auto_ptr<EcalElectronicsIdCollection> productInvalidMemBlockSizes(worker->productInvalidMemBlockSizes);
00139   
00140   // create the collection for invalid Mem Block Size 
00141   std::auto_ptr<EcalElectronicsIdCollection> productInvalidMemChIds(worker->productInvalidMemChIds);
00142   
00143   // create the collection for invalid Mem Gain Errors 
00144   std::auto_ptr<EcalElectronicsIdCollection> productInvalidMemGains(worker->productInvalidMemGains);
00145   
00146 
00147   //---------------------------   
00148   //write outputs to the event
00149   //---------------------------   
00150 
00151   iEvent.put(productDigisEB,"ebDigis");
00152   iEvent.put(productDigisEE,"eeDigis");
00153   iEvent.put(productDccHeaders); 
00154   iEvent.put(productInvalidGains,"EcalIntegrityGainErrors");
00155   iEvent.put(productInvalidGainsSwitch, "EcalIntegrityGainSwitchErrors");
00156   iEvent.put(productInvalidChIds, "EcalIntegrityChIdErrors");
00157   // EE (leaving for now the same names as in EB)
00158   iEvent.put(productInvalidEEGains,"EcalIntegrityGainErrors");
00159   iEvent.put(productInvalidEEGainsSwitch, "EcalIntegrityGainSwitchErrors");
00160   iEvent.put(productInvalidEEChIds, "EcalIntegrityChIdErrors");
00161   // EE
00162   iEvent.put(productInvalidTTIds,"EcalIntegrityTTIdErrors");
00163   iEvent.put(productInvalidZSXtalIds,"EcalIntegrityZSXtalIdErrors");
00164   iEvent.put(productInvalidBlockLengths,"EcalIntegrityBlockSizeErrors");
00165   iEvent.put(productPnDiodeDigis);
00166   // errors  
00167   iEvent.put(productInvalidMemTtIds,"EcalIntegrityMemTtIdErrors");
00168   iEvent.put(productInvalidMemBlockSizes,"EcalIntegrityMemBlockSizeErrors");
00169   iEvent.put(productInvalidMemChIds,"EcalIntegrityMemChIdErrors");
00170   iEvent.put(productInvalidMemGains,"EcalIntegrityMemGainErrors");
00171 
00172   // flags
00173   iEvent.put(productEBSrFlags);
00174   iEvent.put(productEESrFlags);
00175 
00176   // trigger primitives 
00177   iEvent.put(productEcalTps,"EcalTriggerPrimitives");
00178   iEvent.put(productEcalPSs,"EcalPseudoStripInputs");
00179 
00180   //make new collections.
00181   worker->update(iEvent);
00182 }