CMS 3D CMS Logo

Public Member Functions | Private Member Functions | Private Attributes

HcalCalibFEDSelector Class Reference

Inheritance diagram for HcalCalibFEDSelector:
edm::EDProducer edm::ProducerBase edm::ProductRegistryHelper

List of all members.

Public Member Functions

 HcalCalibFEDSelector (const edm::ParameterSet &)
 ~HcalCalibFEDSelector ()

Private Member Functions

virtual void beginJob ()
virtual void endJob ()
virtual void produce (edm::Event &, const edm::EventSetup &)

Private Attributes

std::vector< int > extraFEDs_
edm::InputTag rawInLabel_

Detailed Description

Definition at line 17 of file HcalCalibFEDSelector.cc.


Constructor & Destructor Documentation

HcalCalibFEDSelector::HcalCalibFEDSelector ( const edm::ParameterSet iConfig)

Definition at line 37 of file HcalCalibFEDSelector.cc.

References extraFEDs_, edm::ParameterSet::getParameter(), and rawInLabel_.

{
  rawInLabel_ = iConfig.getParameter<edm::InputTag>("rawInputLabel");
  extraFEDs_  = iConfig.getParameter< std::vector<int> >("extraFEDsToKeep") ; 
  produces<FEDRawDataCollection>();  
}
HcalCalibFEDSelector::~HcalCalibFEDSelector ( )

Definition at line 44 of file HcalCalibFEDSelector.cc.

{
}

Member Function Documentation

void HcalCalibFEDSelector::beginJob ( void  ) [private, virtual]

Reimplemented from edm::EDProducer.

Definition at line 126 of file HcalCalibFEDSelector.cc.

{
}
void HcalCalibFEDSelector::endJob ( void  ) [private, virtual]

Reimplemented from edm::EDProducer.

Definition at line 131 of file HcalCalibFEDSelector.cc.

                                  {
}
void HcalCalibFEDSelector::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
) [private, virtual]

Implements edm::EDProducer.

Definition at line 49 of file HcalCalibFEDSelector.cc.

References diJetCalib::calibType, FEDRawData::data(), runTheMatrix::data, extraFEDs_, funct::false, FEDRawDataCollection::FEDData(), edm::Event::getByLabel(), HcalFEDList::getListOfFEDs(), i, j, gen::k, FEDNumbering::lastFEDId(), FEDNumbering::MAXHCALFEDID, FEDNumbering::MINHCALFEDID, edm::Handle< T >::product(), edm::Event::put(), rawInLabel_, FEDRawData::resize(), findQualityFiles::size, FEDRawData::size(), funct::true, and relativeConstraints::value.

{

  std::auto_ptr<FEDRawDataCollection> producedData(new FEDRawDataCollection);

  edm::Handle<FEDRawDataCollection> rawIn;
  iEvent.getByLabel(rawInLabel_,rawIn);
 
  std::vector<int> selFEDs;

  //--- Get the list of FEDs to be kept ---//
  int calibType = -1 ; 
  for (int i=FEDNumbering::MINHCALFEDID;
       i<=FEDNumbering::MAXHCALFEDID; i++) {
    const FEDRawData& fedData = rawIn->FEDData(i) ; 
    if ( fedData.size() < 24 ) continue ; // FED is empty
    int value = ((const HcalDCCHeader*)(fedData.data()))->getCalibType() ; 
    if ( calibType < 0 ) {
      calibType = value ; 
    } else { 
      if ( calibType != value ) 
        edm::LogWarning("HcalCalibFEDSelector") << "Conflicting calibration types found: " 
                                                << calibType << " vs. " << value
                                                << ".  Staying with " << calibType ; 
    }
  }

  HcalFEDList calibFeds(calibType) ; 
  selFEDs = calibFeds.getListOfFEDs() ; 
  for (unsigned int i=0; i<extraFEDs_.size(); i++) {
    bool duplicate = false ; 
    for (unsigned int j=0; j<selFEDs.size(); j++) { 
      if (extraFEDs_.at(i) == selFEDs.at(j)) {
        duplicate = true ; 
        break ; 
      }
    }
    if ( !duplicate ) selFEDs.push_back( extraFEDs_.at(i) ) ; 
  }

  // Copying:
  const FEDRawDataCollection *rdc=rawIn.product();
  
  for ( int j=0; j< FEDNumbering::lastFEDId(); ++j ) 
    {
      bool rightFED=false;
      for (uint32_t k=0; k<selFEDs.size(); k++)
        {
          if (j==selFEDs[k])
           {
             rightFED=true;
           }
       }
     if (!rightFED) continue;
     const FEDRawData & fedData = rdc->FEDData(j);
     size_t size=fedData.size();
     
     if ( size > 0 ) 
       {
       // this fed has data -- lets copy it
         FEDRawData & fedDataProd = producedData->FEDData(j);
         if ( fedDataProd.size() != 0 ) {
           continue;
         }
         fedDataProd.resize(size);
         unsigned char *dataProd=fedDataProd.data();
         const unsigned char *data=fedData.data();
         // memcpy is at-least-as-fast as assignment and can be much faster
         memcpy(dataProd, data, size);
       }
   }

 iEvent.put(producedData);
}

Member Data Documentation

std::vector<int> HcalCalibFEDSelector::extraFEDs_ [private]

Definition at line 30 of file HcalCalibFEDSelector.cc.

Referenced by HcalCalibFEDSelector(), and produce().

Definition at line 29 of file HcalCalibFEDSelector.cc.

Referenced by HcalCalibFEDSelector(), and produce().