CMS 3D CMS Logo

Public Types | Public Member Functions | Static Public Attributes | Private Attributes

ESDigiToRaw Class Reference

#include <ESDigiToRaw.h>

Inheritance diagram for ESDigiToRaw:
edm::EDProducer edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

List of all members.

Public Types

typedef uint32_t Word32
typedef uint64_t Word64

Public Member Functions

void beginJob ()
void endJob ()
 ESDigiToRaw (const edm::ParameterSet &ps)
int * GetBX ()
int * GetCounter ()
int * GetLV1 ()
int * GetOrbit ()
int * GetRunNumber ()
void produce (edm::Event &e, const edm::EventSetup &es)
virtual ~ESDigiToRaw ()

Static Public Attributes

static const int BXMAX = 2808
static const int KCHIP_BC_RANGE = 4096
static const int KCHIP_EC_RANGE = 256
static const int LHC_BX_RANGE = 3564

Private Attributes

int bx_
int counter_
bool debug_
ESDataFormatterESDataFormatter_
int fedId_ [2][2][40][40]
int formatMajor_
int formatMinor_
std::string instanceName_
int kchip_bc_
int kchip_ec_
std::string label_
edm::FileInPath lookup_
int lv1_
int orbit_number_
int run_number_

Detailed Description

Definition at line 19 of file ESDigiToRaw.h.


Member Typedef Documentation

typedef uint32_t ESDigiToRaw::Word32

Definition at line 30 of file ESDigiToRaw.h.

typedef uint64_t ESDigiToRaw::Word64

Definition at line 31 of file ESDigiToRaw.h.


Constructor & Destructor Documentation

ESDigiToRaw::ESDigiToRaw ( const edm::ParameterSet ps)

Definition at line 15 of file ESDigiToRaw.cc.

References counter_, gather_cfg::cout, debug_, ESDataFormatter_, fedId_, mergeVDriftHistosByStation::file, formatMajor_, formatMinor_, edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), i, instanceName_, j, gen::k, kchip_bc_, kchip_ec_, label_, lookup_, m, and submitDQMOfflineCAF::nLines.

                                                  : ESDataFormatter_(0)
{
  
  label_ = ps.getParameter<string>("Label");
  instanceName_ = ps.getParameter<string>("InstanceES");
  debug_ = ps.getUntrackedParameter<bool>("debugMode", false);
  formatMajor_ = ps.getUntrackedParameter<int>("formatMajor", 4);
  formatMinor_ = ps.getUntrackedParameter<int>("formatMinor", 1);
  lookup_ = ps.getUntrackedParameter<FileInPath>("LookupTable");

  counter_ = 0;
  kchip_ec_ = 0; 
  kchip_bc_ = 0; 

  produces<FEDRawDataCollection>();
  
  if (formatMajor_ == 4) 
    ESDataFormatter_ = new ESDataFormatterV4(ps);
  else 
    ESDataFormatter_ = new ESDataFormatterV1_1(ps);

  // initialize look-up table
  for (int i=0; i<2; ++i)
    for (int j=0; j<2; ++j)
      for (int k=0 ;k<40; ++k)
        for (int m=0; m<40; m++)
          fedId_[i][j][k][m] = -1;

  // read in look-up table
  int nLines, iz, ip, ix, iy, fed, kchip, pace, bundle, fiber, optorx;
  ifstream file;
  file.open(lookup_.fullPath().c_str());
  if( file.is_open() ) {
    
    file >> nLines;
    for (int i=0; i<nLines; ++i) {
      file >> iz >> ip >> ix >> iy >> fed >> kchip >> pace >> bundle >> fiber >> optorx ;
      fedId_[(3-iz)/2-1][ip-1][ix-1][iy-1] = fed;
    }
  } else {
    cout<<"[ESDigiToRaw] Look up table file can not be found in "<<lookup_.fullPath().c_str() <<endl;
  }

  file.close();
}
ESDigiToRaw::~ESDigiToRaw ( ) [virtual]

Definition at line 61 of file ESDigiToRaw.cc.

References ESDataFormatter_.


Member Function Documentation

void ESDigiToRaw::beginJob ( void  ) [virtual]

Reimplemented from edm::EDProducer.

Definition at line 65 of file ESDigiToRaw.cc.

                           {
}
void ESDigiToRaw::endJob ( void  ) [virtual]

Reimplemented from edm::EDProducer.

Definition at line 121 of file ESDigiToRaw.cc.

                         {
}
int* ESDigiToRaw::GetBX ( ) [inline]

Definition at line 35 of file ESDigiToRaw.h.

References bx_.

{return &bx_ ;}
int* ESDigiToRaw::GetCounter ( ) [inline]

Definition at line 33 of file ESDigiToRaw.h.

References counter_.

{return &counter_ ;}
int* ESDigiToRaw::GetLV1 ( ) [inline]

Definition at line 36 of file ESDigiToRaw.h.

References lv1_.

{return &lv1_ ;}
int* ESDigiToRaw::GetOrbit ( ) [inline]

Definition at line 34 of file ESDigiToRaw.h.

References orbit_number_.

{return &orbit_number_ ;}
int* ESDigiToRaw::GetRunNumber ( ) [inline]

Definition at line 37 of file ESDigiToRaw.h.

References run_number_.

{return &run_number_ ;}
void ESDigiToRaw::produce ( edm::Event e,
const edm::EventSetup es 
) [virtual]

Implements edm::EDProducer.

Definition at line 68 of file ESDigiToRaw.cc.

References bx_, counter_, gather_cfg::cout, debug_, ESDataFormatter::DigiToRaw(), ESDataFormatter_, edm::EventID::event(), fedId_, edm::Event::getByLabel(), edm::EventBase::id(), instanceName_, kchip_bc_, KCHIP_BC_RANGE, kchip_ec_, KCHIP_EC_RANGE, label_, LHC_BX_RANGE, lv1_, orbit_number_, ESDetId::plane(), edm::Event::put(), edm::EventID::run(), run_number_, ESDataFormatter::setBX(), ESDataFormatter::setKchipBC(), ESDataFormatter::setKchipEC(), ESDataFormatter::setLV1(), ESDataFormatter::setOrbitNumber(), ESDataFormatter::setRunNumber(), ESDetId::six(), ESDetId::siy(), FEDRawData::size(), and ESDetId::zside().

                                                               {

  run_number_ = ev.id().run();
  orbit_number_ = counter_ / LHC_BX_RANGE;
  bx_ = (counter_ % LHC_BX_RANGE);
   
  lv1_ = ev.id().event();
  kchip_ec_ = (lv1_ % KCHIP_EC_RANGE); 
  kchip_bc_ = (counter_ % KCHIP_BC_RANGE);
  counter_++;

  ESDataFormatter_->setRunNumber(run_number_);
  ESDataFormatter_->setOrbitNumber(orbit_number_);
  ESDataFormatter_->setBX(bx_);
  ESDataFormatter_->setLV1(lv1_);
  ESDataFormatter_->setKchipBC(kchip_bc_);
  ESDataFormatter_->setKchipEC(kchip_ec_);

  edm::Handle<ESDigiCollection> digis;
  ev.getByLabel(label_, instanceName_, digis);

  int ifed;
  ESDataFormatter::Digis Digis;
  Digis.clear();

  for (ESDigiCollection::const_iterator it=digis->begin(); it!=digis->end(); ++it) {

    const ESDataFrame& df = *it;
    const ESDetId& detId = it->id();

    ifed = fedId_[(3-detId.zside())/2-1][detId.plane()-1][detId.six()-1][detId.siy()-1];
    if (ifed < 0) continue;

    Digis[ifed].push_back(df);
  }

  auto_ptr<FEDRawDataCollection> productRawData( new FEDRawDataCollection );

  ESDataFormatter::Digis::const_iterator itfed; 
  for (itfed = Digis.begin(); itfed != Digis.end(); ++itfed) {   
    int fId = (*itfed).first ; 

    FEDRawData& fedRawData = productRawData->FEDData(fId); 
    ESDataFormatter_->DigiToRaw(fId, Digis, fedRawData); 

    if (debug_) cout<<"FED : "<<fId<<" Data size : "<<fedRawData.size()<<" (Bytes)"<<endl;
  } 

  ev.put(productRawData);

  return;
}

Member Data Documentation

int ESDigiToRaw::bx_ [private]

Definition at line 49 of file ESDigiToRaw.h.

Referenced by GetBX(), and produce().

const int ESDigiToRaw::BXMAX = 2808 [static]

Definition at line 39 of file ESDigiToRaw.h.

int ESDigiToRaw::counter_ [private]

Definition at line 46 of file ESDigiToRaw.h.

Referenced by ESDigiToRaw(), GetCounter(), and produce().

bool ESDigiToRaw::debug_ [private]

Definition at line 58 of file ESDigiToRaw.h.

Referenced by ESDigiToRaw(), and produce().

Definition at line 62 of file ESDigiToRaw.h.

Referenced by ESDigiToRaw(), produce(), and ~ESDigiToRaw().

int ESDigiToRaw::fedId_[2][2][40][40] [private]

Definition at line 53 of file ESDigiToRaw.h.

Referenced by ESDigiToRaw(), and produce().

Definition at line 59 of file ESDigiToRaw.h.

Referenced by ESDigiToRaw().

Definition at line 60 of file ESDigiToRaw.h.

Referenced by ESDigiToRaw().

std::string ESDigiToRaw::instanceName_ [private]

Definition at line 56 of file ESDigiToRaw.h.

Referenced by ESDigiToRaw(), and produce().

int ESDigiToRaw::kchip_bc_ [private]

Definition at line 52 of file ESDigiToRaw.h.

Referenced by ESDigiToRaw(), and produce().

const int ESDigiToRaw::KCHIP_BC_RANGE = 4096 [static]

Definition at line 41 of file ESDigiToRaw.h.

Referenced by produce().

int ESDigiToRaw::kchip_ec_ [private]

Definition at line 51 of file ESDigiToRaw.h.

Referenced by ESDigiToRaw(), and produce().

const int ESDigiToRaw::KCHIP_EC_RANGE = 256 [static]

Definition at line 42 of file ESDigiToRaw.h.

Referenced by produce().

std::string ESDigiToRaw::label_ [private]

Definition at line 55 of file ESDigiToRaw.h.

Referenced by ESDigiToRaw(), and produce().

const int ESDigiToRaw::LHC_BX_RANGE = 3564 [static]

Definition at line 40 of file ESDigiToRaw.h.

Referenced by produce().

Definition at line 57 of file ESDigiToRaw.h.

Referenced by ESDigiToRaw().

int ESDigiToRaw::lv1_ [private]

Definition at line 50 of file ESDigiToRaw.h.

Referenced by GetLV1(), and produce().

Definition at line 47 of file ESDigiToRaw.h.

Referenced by GetOrbit(), and produce().

int ESDigiToRaw::run_number_ [private]

Definition at line 48 of file ESDigiToRaw.h.

Referenced by GetRunNumber(), and produce().