CMS 3D CMS Logo

Public Member Functions | Private Attributes | Friends

EcalUnpackerWorker Class Reference

#include <EcalUnpackerWorker.h>

Inheritance diagram for EcalUnpackerWorker:
EcalUnpackerWorkerBase

List of all members.

Public Member Functions

 EcalUnpackerWorker (const edm::ParameterSet &conf)
unsigned int maxElementIndex () const
void set (const edm::EventSetup &es) const
void setHandles (const EcalUnpackerWorkerRecord &iRecord)
void update (const edm::Event &e) const
template<class DID >
void work (EcalDigiCollection::const_iterator &beginDigi, EcalDigiCollection::const_iterator &endDigi, std::auto_ptr< EcalUncalibratedRecHitCollection > &uncalibRecHits, std::auto_ptr< EcalRecHitCollection > &calibRechits) const
std::auto_ptr
< EcalRecHitCollection
work (const uint32_t &i, const FEDRawDataCollection &) const
void write (edm::Event &e) const
 ~EcalUnpackerWorker ()

Private Attributes

edm::ESHandle< EcalRegionCablingcabling
EcalRecHitWorkerBaseClassCalibWorker_
const edm::Eventevt
EcalElectronicsMappermyMap_
std::auto_ptr
< EcalRawDataCollection
productDccHeaders
std::auto_ptr< EBDigiCollectionproductDigisEB
std::auto_ptr< EEDigiCollectionproductDigisEE
std::auto_ptr< EBSrFlagCollectionproductEBSrFlags
std::auto_ptr< EESrFlagCollectionproductEESrFlags
std::auto_ptr
< EcalElectronicsIdCollection
productInvalidBlockLengths
std::auto_ptr< EBDetIdCollectionproductInvalidChIds
std::auto_ptr< EEDetIdCollectionproductInvalidEEChIds
std::auto_ptr< EEDetIdCollectionproductInvalidEEGains
std::auto_ptr< EEDetIdCollectionproductInvalidEEGainsSwitch
std::auto_ptr< EBDetIdCollectionproductInvalidGains
std::auto_ptr< EBDetIdCollectionproductInvalidGainsSwitch
std::auto_ptr
< EcalElectronicsIdCollection
productInvalidMemBlockSizes
std::auto_ptr
< EcalElectronicsIdCollection
productInvalidMemChIds
std::auto_ptr
< EcalElectronicsIdCollection
productInvalidMemGains
std::auto_ptr
< EcalElectronicsIdCollection
productInvalidMemTtIds
std::auto_ptr
< EcalElectronicsIdCollection
productInvalidTTIds
std::auto_ptr
< EcalElectronicsIdCollection
productInvalidZSXtalIds
std::auto_ptr
< EcalPnDiodeDigiCollection
productPnDiodeDigis
std::auto_ptr
< EcalPSInputDigiCollection
productPSs
std::auto_ptr
< EcalTrigPrimDigiCollection
productTps
EcalUncalibRecHitWorkerBaseClassUncalibWorker_
DCCDataUnpackerunpacker_

Friends

class EcalRawToRecHitByproductProducer

Detailed Description

Definition at line 29 of file EcalUnpackerWorker.h.


Constructor & Destructor Documentation

EcalUnpackerWorker::EcalUnpackerWorker ( const edm::ParameterSet conf)

DCCDataUnpacker

Definition at line 18 of file EcalUnpackerWorker.cc.

References CalibWorker_, reco::get(), edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), EcalElectronicsMapper::makeMapFromVectors(), myMap_, productDccHeaders, productDigisEB, productDigisEE, productEBSrFlags, productEESrFlags, productInvalidBlockLengths, productInvalidChIds, productInvalidEEChIds, productInvalidEEGains, productInvalidEEGainsSwitch, productInvalidGains, productInvalidGainsSwitch, productInvalidMemBlockSizes, productInvalidMemChIds, productInvalidMemGains, productInvalidMemTtIds, productInvalidTTIds, productInvalidZSXtalIds, productPnDiodeDigis, productPSs, productTps, DCCDataUnpacker::setDccHeadersCollection(), DCCDataUnpacker::setEBDigisCollection(), DCCDataUnpacker::setEBSrFlagsCollection(), DCCDataUnpacker::setEcalPSsCollection(), DCCDataUnpacker::setEcalTpsCollection(), DCCDataUnpacker::setEEDigisCollection(), DCCDataUnpacker::setEESrFlagsCollection(), DCCDataUnpacker::setInvalidBlockLengthsCollection(), DCCDataUnpacker::setInvalidChIdsCollection(), DCCDataUnpacker::setInvalidEEChIdsCollection(), DCCDataUnpacker::setInvalidEEGainsCollection(), DCCDataUnpacker::setInvalidEEGainsSwitchCollection(), DCCDataUnpacker::setInvalidGainsCollection(), DCCDataUnpacker::setInvalidGainsSwitchCollection(), DCCDataUnpacker::setInvalidMemBlockSizesCollection(), DCCDataUnpacker::setInvalidMemChIdsCollection(), DCCDataUnpacker::setInvalidMemGainsCollection(), DCCDataUnpacker::setInvalidMemTtIdsCollection(), DCCDataUnpacker::setInvalidTTIdsCollection(), DCCDataUnpacker::setInvalidZSXtalIdsCollection(), DCCDataUnpacker::setPnDiodeDigisCollection(), DCCDataUnpacker::silentMode_, UncalibWorker_, and unpacker_.

                                                                  {
  edm::ParameterSet DCCpset = conf.getParameter<edm::ParameterSet>("DCCDataUnpacker");
  edm::ParameterSet EEMpset = conf.getParameter<edm::ParameterSet>("ElectronicsMapper");

  unsigned int numbXtalTSamples_ = EEMpset.getParameter<unsigned int>("numbXtalTSamples");
  unsigned int numbTriggerTSamples_ = EEMpset.getParameter<unsigned int>("numbTriggerTSamples");
  
  if( numbXtalTSamples_ <6 || numbXtalTSamples_>64 || (numbXtalTSamples_-2)%4 ){
    edm::LogError("IncorrectConfiguration")<<"Unsuported number of xtal time samples : "<<numbXtalTSamples_
                                           <<"\n Valid Number of xtal time samples are : 6,10,14,18,...,62"; 
  }
  
  if( numbTriggerTSamples_ !=1 && numbTriggerTSamples_ !=4 && numbTriggerTSamples_ !=8  ){
    edm::LogError("IncorrectConfiguration")<<"Unsuported number of trigger time samples : "<<numbTriggerTSamples_
                                           <<"\n Valid number of trigger time samples are :  1, 4 or 8"; 
  }
  
  myMap_ = new EcalElectronicsMapper(numbXtalTSamples_, numbTriggerTSamples_);
  std::vector<int> oFl = DCCpset.getParameter<std::vector<int> >("orderedFedList");
  std::vector<int> oDl = DCCpset.getParameter<std::vector<int> >("orderedDCCIdList");
  bool readResult = myMap_->makeMapFromVectors(oFl,oDl);
  
  if(!readResult){
    edm::LogError("IncorrectConfiguration")<<"\n unable to configure EcalElectronicsMapper from vectors.";
  }
    
  unpacker_ = new DCCDataUnpacker(myMap_,
                                  DCCpset.getParameter<bool>("headerUnpacking"),
                                  DCCpset.getParameter<bool>("srpUnpacking"),
                                  DCCpset.getParameter<bool>("tccUnpacking"),
                                  DCCpset.getParameter<bool>("feUnpacking"),
                                  DCCpset.getParameter<bool>("memUnpacking"),
                                  DCCpset.getParameter<bool>("syncCheck"),
                                  DCCpset.getParameter<bool>("feIdCheck"),
                                  DCCpset.getParameter<bool>("forceKeepFRData") 
                                  );
  edm::LogInfo("EcalRawToRecHit")
    <<"\n ECAL RawToDigi within RawToRecHit configuration:"
    <<"\n Header  unpacking is "<<DCCpset.getParameter<bool>("headerUnpacking")
    <<"\n SRP Bl. unpacking is "<<DCCpset.getParameter<bool>("srpUnpacking")
    <<"\n TCC Bl. unpacking is "<<DCCpset.getParameter<bool>("tccUnpacking")
    <<"\n FE  Bl. unpacking is "<<DCCpset.getParameter<bool>("feUnpacking")
    <<"\n MEM Bl. unpacking is "<<DCCpset.getParameter<bool>("memUnpacking")
    <<"\n sync check is "<<DCCpset.getParameter<bool>("syncCheck")
    <<"\n feID check is "<<DCCpset.getParameter<bool>("feIdCheck")
    <<"\n force keep FR data is "<<DCCpset.getParameter<bool>("forceKeepFRData")
    <<"\n";
  
  unpacker_->setEBDigisCollection(&productDigisEB);
  unpacker_->setEEDigisCollection(&productDigisEE);
  unpacker_->setDccHeadersCollection(&productDccHeaders); 
  unpacker_->setInvalidGainsCollection(&productInvalidGains); 
  unpacker_->setInvalidGainsSwitchCollection(&productInvalidGainsSwitch);
  unpacker_->setInvalidChIdsCollection(&productInvalidChIds);
  unpacker_->setInvalidEEGainsCollection(&productInvalidEEGains);
  unpacker_->setInvalidEEGainsSwitchCollection(&productInvalidEEGainsSwitch);
  unpacker_->setInvalidEEChIdsCollection(&productInvalidEEChIds);
  unpacker_->setEBSrFlagsCollection(&productEBSrFlags);
  unpacker_->setEESrFlagsCollection(&productEESrFlags);
  unpacker_->setEcalTpsCollection(&productTps);
  unpacker_->setEcalPSsCollection(&productPSs);
  unpacker_->setInvalidTTIdsCollection(&productInvalidTTIds);  
  unpacker_->setInvalidZSXtalIdsCollection(&productInvalidZSXtalIds);
  unpacker_->setInvalidBlockLengthsCollection(&productInvalidBlockLengths);
  unpacker_->setPnDiodeDigisCollection(&productPnDiodeDigis);
  unpacker_->setInvalidMemTtIdsCollection(& productInvalidMemTtIds);
  unpacker_->setInvalidMemBlockSizesCollection(& productInvalidMemBlockSizes);
  unpacker_->setInvalidMemChIdsCollection(& productInvalidMemChIds);
  unpacker_->setInvalidMemGainsCollection(& productInvalidMemGains);

  DCCDataUnpacker::silentMode_ = conf.getUntrackedParameter<bool> ("silentMode",true);

  edm::ParameterSet UncalibPSet = conf.getParameter<edm::ParameterSet>("UncalibRHAlgo");
  std::string UncaliComponentName = UncalibPSet.getParameter<std::string>("Type");
  UncalibWorker_ = EcalUncalibRecHitWorkerFactory::get()->create(UncaliComponentName, UncalibPSet);

  edm::ParameterSet CalibPSet = conf.getParameter<edm::ParameterSet>("CalibRHAlgo");
  std::string CaliComponentName = CalibPSet.getParameter<std::string>("Type");
  CalibWorker_ = EcalRecHitWorkerFactory::get()->create(CaliComponentName, CalibPSet);

}
EcalUnpackerWorker::~EcalUnpackerWorker ( )

Definition at line 101 of file EcalUnpackerWorker.cc.

References CalibWorker_, myMap_, UncalibWorker_, and unpacker_.

                                       {
  //delete everything that is own by the EcalUnpackerWorker
  delete myMap_;
  delete unpacker_;
  delete UncalibWorker_;
  delete CalibWorker_;

}

Member Function Documentation

unsigned int EcalUnpackerWorker::maxElementIndex ( ) const [inline, virtual]

Reimplemented from EcalUnpackerWorkerBase.

Definition at line 47 of file EcalUnpackerWorker.h.

void EcalUnpackerWorker::set ( const edm::EventSetup es) const [virtual]
void EcalUnpackerWorker::setHandles ( const EcalUnpackerWorkerRecord iRecord) [virtual]
void EcalUnpackerWorker::update ( const edm::Event e) const [virtual]

keep the event

DCCDataUnpacker

Reimplemented from EcalUnpackerWorkerBase.

Definition at line 125 of file EcalUnpackerWorker.cc.

References alignCSCRings::e, evt, productDccHeaders, productDigisEB, productDigisEE, productEBSrFlags, productEESrFlags, productInvalidBlockLengths, productInvalidChIds, productInvalidEEChIds, productInvalidEEGains, productInvalidEEGainsSwitch, productInvalidGains, productInvalidGainsSwitch, productInvalidMemBlockSizes, productInvalidMemChIds, productInvalidMemGains, productInvalidMemTtIds, productInvalidTTIds, productInvalidZSXtalIds, productPnDiodeDigis, productPSs, and productTps.

Referenced by EcalRawToRecHitByproductProducer::produce().

std::auto_ptr< EcalRecHitCollection > EcalUnpackerWorker::work ( const uint32_t &  i,
const FEDRawDataCollection rawdata 
) const [virtual]

Reimplemented from EcalUnpackerWorkerBase.

Definition at line 162 of file EcalUnpackerWorker.cc.

References FEDRawData::data(), DCCDataUnpacker::ebDigisCollection(), DCCDataUnpacker::eeDigisCollection(), EMPTYEVENTSIZE, end, FEDRawDataCollection::FEDData(), EcalRegionCabling::fedIndex(), EcalElectronicsMapper::getActiveSM(), LogDebug, myMap_, EcalElectronicsMapper::setActiveDCC(), findQualityFiles::size, FEDRawData::size(), DCCDataUnpacker::unpack(), and unpacker_.

                                                                                                                             {
//  MyWatcher watcher("Worker");
  LogDebug("EcalRawToRecHit|Worker")<<"is going to work on index: "<<index
                                    <<"for fed Id: "<<EcalRegionCabling::fedIndex(index);
//<<watcher.lap();
//std::cout<<watcher.lap() <<std::endl;
  int fedIndex = EcalRegionCabling::fedIndex(index);

  const FEDRawData & fedData = rawdata.FEDData(fedIndex);

  //remember where the iterators were before unpacking
   LogDebug("EcalRawToRecHit|Worker")
    <<"size of digi collections before unpacking: "
    <<(*unpacker_->ebDigisCollection())->size()
    <<" "<<(*unpacker_->eeDigisCollection())->size();
  //  <<watcher.lap();

  EcalDigiCollection::const_iterator beginDigiEB =  (*unpacker_->ebDigisCollection())->end();
  EcalDigiCollection::const_iterator beginDigiEE =  (*unpacker_->eeDigisCollection())->end();
  
  //###### get the digi #######
  // unpack first
  int smId =0;
  int length = fedData.size();
  if ( length >= EMPTYEVENTSIZE ){
    if(myMap_->setActiveDCC(fedIndex)){
      smId = myMap_->getActiveSM();
      uint64_t * pData = (uint64_t *)(fedData.data());
       LogDebug("EcalRawToRecHit|Worker")<<"calling the unpacker: "<<length<<" "<<smId<<" "<<fedIndex ;
//                                            <<watcher.lap();
      unpacker_->unpack( pData, static_cast<unsigned int>(length),smId,fedIndex);
       LogDebug("EcalRawToRecHit|Worker")<<"unpacking done." ;
//                                            <<watcher.lap();
    }
    else{
      edm::LogInfo("EcalUnpackerWorker")<<"cannot set: "<<fedIndex<<" to be an active DCC.";
       LogDebug("EcalRawToRecHit|Worker")<<"cannot set: "<<fedIndex<<" to be an active DCC.";
      return std::auto_ptr< EcalRecHitCollection >(new EcalRecHitCollection);
    }
  }
  else {
    edm::LogInfo("EcalUnpackerWorker")<<"empty event on this FED: "<<fedIndex<<" length: "<<length;
     LogDebug("EcalRawToRecHit|Worker")<<"empty event on this FED: "<<fedIndex<<" length: "<<length;
    return std::auto_ptr< EcalRecHitCollection >(new EcalRecHitCollection);
  }

   LogDebug("EcalRawToRecHit|Worker")
    <<"size of digi collections after unpacking: "
    <<(*unpacker_->ebDigisCollection())->size()
    <<" "<<(*unpacker_->eeDigisCollection())->size() ;
//    <<watcher.lap();
  EcalDigiCollection::const_iterator endDigiEB = (*unpacker_->ebDigisCollection())->end();
  EcalDigiCollection::const_iterator endDigiEE = (*unpacker_->eeDigisCollection())->end();

  //collection for the rechits: uncalib and final
  std::auto_ptr< EcalRecHitCollection > ecalrechits( new EcalRecHitCollection );
  std::auto_ptr< EcalUncalibratedRecHitCollection > uncalibRecHits( new EcalUncalibratedRecHitCollection );
  
   LogDebug("EcalRawToRecHit|Worker")<<"going to work on EE rechits from: "<<endDigiEE-beginDigiEE<<" digis."
                                            <<"\ngoing to work on EB rechits from: "<<endDigiEB-beginDigiEB<<" digis." ;
//                                        <<watcher.lap();
  // EB
  //make the uncalibrated rechits on the fly
  if (beginDigiEB!=endDigiEB){
    work<EBDetId>(beginDigiEB, endDigiEB, uncalibRecHits, ecalrechits);
  }
   LogDebug("EcalRawToRecHit|Worker")<<uncalibRecHits->size()<<" uncalibrated rechit created so far\n"
                                          <<ecalrechits->size()<<" rechit created so far." ;
//                                        <<watcher.lap();
  
  // EE
  if (beginDigiEE!=endDigiEE){
    work<EEDetId>(beginDigiEE, endDigiEE, uncalibRecHits, ecalrechits);
  } 
   LogDebug("EcalRawToRecHit|Worker")<<uncalibRecHits->size()<<" uncalibrated rechit created eventually\n"
                                          <<ecalrechits->size()<<" rechit created eventually" ;
//                                        <<watcher.lap();

  return ecalrechits;
}
template<class DID >
void EcalUnpackerWorker::work ( EcalDigiCollection::const_iterator beginDigi,
EcalDigiCollection::const_iterator endDigi,
std::auto_ptr< EcalUncalibratedRecHitCollection > &  uncalibRecHits,
std::auto_ptr< EcalRecHitCollection > &  calibRechits 
) const [inline]

Definition at line 87 of file EcalUnpackerWorker.h.

References CalibWorker_, evt, LogDebug, EcalRecHitWorkerBaseClass::run(), EcalUncalibRecHitWorkerBaseClass::run(), and UncalibWorker_.

                                                                                         {
//    MyWatcher watcher("<Worker>");
    LogDebug("EcalRawToRecHit|Worker")<<"ready to work on digis.";
//<<watcher.lap();

    EcalDigiCollection::const_iterator itdg = beginDigi;
    /*R*/ LogDebug("EcalRawToRecHit|Worker")<<"iterator check." ;

    for(; itdg != endDigi; ++itdg) 
      {

        //get the uncalibrated rechit
        /*R*/ LogDebug("EcalRawToRecHit|Worker")<<"ready to make Uncalib rechit." ;
//<<watcher.lap();
        if (!UncalibWorker_->run(*evt, itdg, *uncalibRecHits)) continue;
        EcalUncalibratedRecHit & EURH=uncalibRecHits->back();

        /*R*/ LogDebug("EcalRawToRecHit|Worker")<<"creating a rechit." ;
//<<watcher.lap();
        if (!CalibWorker_->run(*evt, EURH, *calibRechits)) continue;
        /*R*/ LogDebug("EcalRawToRecHit|Worker")<<"created." ;
//<<watcher.lap();

      }//loop over digis
  }
void EcalUnpackerWorker::write ( edm::Event e) const [virtual]

Reimplemented from EcalUnpackerWorkerBase.

Definition at line 121 of file EcalUnpackerWorker.cc.

                                                {
  //write the collection in the event as requested.
}

Friends And Related Function Documentation

friend class EcalRawToRecHitByproductProducer [friend]

Definition at line 59 of file EcalUnpackerWorker.h.


Member Data Documentation

Definition at line 80 of file EcalUnpackerWorker.h.

Referenced by setHandles().

Definition at line 83 of file EcalUnpackerWorker.h.

Referenced by EcalUnpackerWorker(), set(), work(), and ~EcalUnpackerWorker().

const edm::Event* EcalUnpackerWorker::evt [mutable, private]

Reimplemented from EcalUnpackerWorkerBase.

Definition at line 51 of file EcalUnpackerWorker.h.

Referenced by update(), and work().

Definition at line 55 of file EcalUnpackerWorker.h.

Referenced by EcalUnpackerWorker(), setHandles(), work(), and ~EcalUnpackerWorker().

std::auto_ptr<EBDigiCollection> EcalUnpackerWorker::productDigisEB [mutable, private]
std::auto_ptr<EEDigiCollection> EcalUnpackerWorker::productDigisEE [mutable, private]
std::auto_ptr<EBSrFlagCollection> EcalUnpackerWorker::productEBSrFlags [mutable, private]
std::auto_ptr<EESrFlagCollection> EcalUnpackerWorker::productEESrFlags [mutable, private]
std::auto_ptr< EBDetIdCollection> EcalUnpackerWorker::productInvalidChIds [mutable, private]
std::auto_ptr< EBDetIdCollection> EcalUnpackerWorker::productInvalidGains [mutable, private]
std::auto_ptr<EcalPSInputDigiCollection> EcalUnpackerWorker::productPSs [mutable, private]

Definition at line 82 of file EcalUnpackerWorker.h.

Referenced by EcalUnpackerWorker(), set(), work(), and ~EcalUnpackerWorker().

Definition at line 53 of file EcalUnpackerWorker.h.

Referenced by EcalUnpackerWorker(), work(), and ~EcalUnpackerWorker().