CMS 3D CMS Logo

Public Types | Public Member Functions | Protected Attributes | Static Protected Attributes

ESDataFormatterV1_1 Class Reference

#include <ESDataFormatterV1_1.h>

Inheritance diagram for ESDataFormatterV1_1:
ESDataFormatter

List of all members.

Public Types

typedef ESDataFormatter::DetDigis DetDigis
typedef ESDataFormatter::Digis Digis
typedef ESDataFormatter::Word16 Word16
typedef ESDataFormatter::Word32 Word32
typedef ESDataFormatter::Word64 Word64
typedef ESDataFormatter::Word8 Word8

Public Member Functions

void DigiToRaw (int fedId, Digis &digis, FEDRawData &fedRawData)
 ESDataFormatterV1_1 (const edm::ParameterSet &ps)
 ~ESDataFormatterV1_1 ()

Protected Attributes

static const int bADC0 = 16
static const int bADC1 = 16
static const int bADC2 = 16
static const int bDCH = 4
static const int bDCOMFLAG = 8
static const int bDEL = 24
static const int bDERR = 8
static const int bDH = 6
static const int bDOPTO = 8
static const int bDORBIT = 32
static const int bDRUN = 24
static const int bDRUNTYPE = 32
static const int bDTRGTYPE = 16
static const int bDVMAJOR = 8
static const int bE0 = 1
static const int bE1 = 1
static const int bFIBER = 6
static const int bKBC = 12
static const int bKCE = 1
static const int bKCRC = 1
static const int bKET = 1
static const int bKFLAG1 = 4
static const int bKFLAG2 = 8
static const int bKHEAD1 = 2
static const int bKHEAD2 = 2
static const int bKID = 11
static const int bPACE = 2
static const int bSTRIP = 5
static const int sADC0 = 0
static const int sADC1 = bADC0 + sADC0
static const int sADC2 = 0
static const int sDCH = 0
static const int sDCOMFLAG = bDTRGTYPE + sDTRGTYPE
static const int sDEL = 0
static const int sDERR = bDEL + sDEL
static const int sDH = 24
static const int sDOPTO = 16
static const int sDORBIT = 0
static const int sDRUN = 0
static const int sDRUNTYPE = 0
static const int sDTRGTYPE = 0
static const int sDVMAJOR = bDVMINOR + sDVMINOR
static const int sE0 = bSTRIP + sSTRIP + 1
static const int sE1 = bE0 + sE0
static const int sFIBER = bKID + sKID + 1
static const int sKBC = bKFLAG2 + sKFLAG2
static const int sKCE = bKCRC + sKCRC
static const int sKCRC = bKET + sKET
static const int sKET = 0
static const int sKFLAG1 = bKBC + sKBC
static const int sKFLAG2 = bKEC + sKEC
static const int sKHEAD1 = bFIBER + sFIBER + 2
static const int sKHEAD2 = bKHEAD1 + sKHEAD1
static const int sKID = bKCE + sKCE + 5
static const int sPACE = bADC2 + sADC2
static const int sSTRIP = bPACE + sPACE

Static Protected Attributes

static const int bDHEAD = 2
static const int bDVMINOR = 8
static const int bHEAD = 2
static const int bKEC = 8
static const int sDHEAD = 26
static const int sDVMINOR = 8
static const int sHEAD = bE1 + sE1 + 4
static const int sKEC = 0

Detailed Description

Definition at line 20 of file ESDataFormatterV1_1.h.


Member Typedef Documentation

Reimplemented from ESDataFormatter.

Definition at line 24 of file ESDataFormatterV1_1.h.

Reimplemented from ESDataFormatter.

Definition at line 25 of file ESDataFormatterV1_1.h.

Reimplemented from ESDataFormatter.

Definition at line 28 of file ESDataFormatterV1_1.h.

Reimplemented from ESDataFormatter.

Definition at line 29 of file ESDataFormatterV1_1.h.

Reimplemented from ESDataFormatter.

Definition at line 30 of file ESDataFormatterV1_1.h.

Reimplemented from ESDataFormatter.

Definition at line 27 of file ESDataFormatterV1_1.h.


Constructor & Destructor Documentation

ESDataFormatterV1_1::ESDataFormatterV1_1 ( const edm::ParameterSet ps)

Definition at line 84 of file ESDataFormatterV1_1.cc.

  : ESDataFormatter(ps) {
}
ESDataFormatterV1_1::~ESDataFormatterV1_1 ( )

Definition at line 88 of file ESDataFormatterV1_1.cc.

                                          {
}

Member Function Documentation

void ESDataFormatterV1_1::DigiToRaw ( int  fedId,
Digis digis,
FEDRawData fedRawData 
) [virtual]

Implements ESDataFormatter.

Definition at line 128 of file ESDataFormatterV1_1.cc.

References ESSample::adc(), ESDataFormatter::bx_, evf::compute_crc(), gather_cfg::cout, FEDRawData::data(), runTheMatrix::data, ESDataFormatter::debug_, i, ESDataFrame::id(), ESDataFormatter::lv1_, ESDataFormatter::orbit_number_, ESDetId::plane(), ESDataFormatter::print(), FEDRawData::resize(), ESDataFormatter::run_number_, sADC0, sADC1, sADC2, ESDataFrame::sample(), sDEL, sDH, sDHEAD, sDORBIT, sDRUN, sDVMAJOR, sDVMINOR, sE0, sE1, FEDTrailer::set(), FEDHeader::set(), sFIBER, sHEAD, ESDetId::six(), ESDetId::siy(), ESDataFrame::size(), sKBC, sKCE, sKCRC, sKEC, sKET, sKFLAG1, sKFLAG2, sKHEAD1, sKHEAD2, sKID, sPACE, sSTRIP, ESDetId::strip(), ESDataFormatter::trgtype_, and ESDetId::zside().

                                                                                   {

  map<int, vector<Word64> > map_data;
  map_data.clear();  

  int ts[3] = {0, 0, 0};
  Word32 word1, word2;
  Word64 word;
  vector<Word64> words;


    const DetDigis& detDigis = digis[fedId];

//     if (detDigis==digis.end()) { 
//       cout << "ESDataFormatterV1_1::DigiToRaw : could not find digi vector in digis map for fedID: " 
//         << fedId << endl ; 
//       return 0; 
//     } 

    for (DetDigis::const_iterator it = detDigis.begin(); it != detDigis.end(); ++it) {
      
      const ESDataFrame& dataframe = (*it);            
      const ESDetId& detId = dataframe.id();     
      
      for (int is=0; is<dataframe.size(); ++is) ts[is] = dataframe.sample(is).adc();            
      
      //  calculate fake kchip and pace id 
      int kchip = -1;
      int pace = -1;
      int ix = -1;
      int iy = -1;
      
      ix = detId.six() % 2;
      iy = detId.siy() % 2;
      if (ix == 1 && iy == 1)
        pace = 0;
      else if (ix == 0 && iy == 1)
        pace = 1;
      else if (ix == 1 && iy == 0) 
        pace = 2;
      else if (ix == 0 && iy == 0)
        pace = 3;
      
      ix = (1 + detId.six()) / 2;
      iy = (1 + detId.siy()) / 2;  
      if (detId.zside() == 1 && detId.plane() == 1) 
        kchip = ix + (iy-1)*20 - 1;
      else if (detId.zside() == 1 && detId.plane() == 2) 
        kchip = ix + (iy-1)*20 + 399;
      else if (detId.zside() == -1 && detId.plane() == 1) 
        kchip = ix + (iy-1)*20 + 799;
      else if (detId.zside() == -1 && detId.plane() == 2) 
        kchip = ix + (iy-1)*20 + 1199;
      
      if (debug_) cout<<"Si : "<<detId.zside()<<" "<<detId.plane()<<" "<<detId.six()<<" "<<detId.siy()<<" "<<detId.strip()<<" ("<<kchip<<","<<pace<<") "<<ts[2]<<" "<<ts[1]<<" "<<ts[0]<<endl;

      word1 = (ts[1] << sADC1) | (ts[0] << sADC0);
      word2 = (2 << sHEAD) | (0 << sE1) | (0 << sE0) | ((detId.strip()-1) << sSTRIP) | (pace << sPACE) | (ts[2] << sADC2);
      word  = (Word64(word2) << 32 ) | Word64(word1);
      
      map_data[kchip].push_back(word);
    }


  map<int, vector<Word64> >::const_iterator kit;
  for (kit=map_data.begin(); kit!=map_data.end(); ++kit) {

    if (debug_) cout<<"KCHIP : "<<kit->first<<endl;

    word1 = (0 << sKFLAG1) | (0 << sKBC) | (0 << sKFLAG2) | (0 << sKEC);                                                       
    word2 = (1 << sKHEAD2) | (0 << sKHEAD1) | (0 << sFIBER) | (kit->first << sKID) | (0 << sKCE) | (0 << sKCRC) | (0 << sKET);
    word  = (Word64(word2) << 32 ) | Word64(word1);                                                                            

    if (debug_) cout<<"KCHIP : "<<print(word)<<endl; 
    words.push_back(word);           

    const vector<Word64> & data = kit->second; 
    for (unsigned int id=0; id<data.size(); ++id) {
      if (debug_) cout<<"Data  : "<<print(data[id])<<endl;
      words.push_back(data[id]);
    }

  } 

  int dataSize = (words.size() + 8) * sizeof(Word64);
  
  // DCC words
  vector<Word64> DCCwords;
  word2 = (0 << sDHEAD) | (1 <<sDH) | (run_number_ << sDRUN);
  word1 = (dataSize << sDEL);
  word  = (Word64(word2) << 32 ) | Word64(word1);
  DCCwords.push_back(word);
  word2 = (0 << sDHEAD) | (2 <<sDH);
  word1 = 0;
  word  = (Word64(word2) << 32 ) | Word64(word1);
  DCCwords.push_back(word);
  word2 = (0 << sDHEAD) | (3 <<sDH) | (1 << sDVMAJOR) | (1 << sDVMINOR); 
  word1 = (orbit_number_ << sDORBIT);
  word  = (Word64(word2) << 32 ) | Word64(word1);
  DCCwords.push_back(word);
  word2 = (0 << sDHEAD) | (4 <<sDH);
  word1 = 0;
  word  = (Word64(word2) << 32 ) | Word64(word1);
  DCCwords.push_back(word);
  word2 = (0 << sDHEAD) | (5 <<sDH);
  word1 = 0;
  word  = (Word64(word2) << 32 ) | Word64(word1);
  DCCwords.push_back(word);
  word2 = (0 << sDHEAD) | (6 <<sDH);
  word1 = 0;
  word  = (Word64(word2) << 32 ) | Word64(word1);
  DCCwords.push_back(word);
  
  // Output (data size in Bytes)
  fedRawData.resize(dataSize);

  Word64 * w = reinterpret_cast<Word64* >(fedRawData.data());
  
  // header
  FEDHeader::set( reinterpret_cast<unsigned char*>(w), trgtype_, lv1_, bx_, fedId); 
  w++;

  // ES-DCC 
  for (unsigned int i=0; i<DCCwords.size(); ++i) {
    if (debug_) cout<<"DCC  : "<<print(DCCwords[i])<<endl;
    *w = DCCwords[i];
    w++;
  }

  // event data
  for (unsigned int i=0; i<words.size(); ++i) {
    *w = words[i];
    w++;  
  }

  // trailer
  FEDTrailer::set( reinterpret_cast<unsigned char*>(w), dataSize/sizeof(Word64), 
                   evf::compute_crc(fedRawData.data(), dataSize),
                   0, 0);
  w++;
 

}

Member Data Documentation

const int ESDataFormatterV1_1::bADC0 = 16 [protected]

Definition at line 50 of file ESDataFormatterV1_1.h.

const int ESDataFormatterV1_1::bADC1 = 16 [protected]

Definition at line 50 of file ESDataFormatterV1_1.h.

const int ESDataFormatterV1_1::bADC2 = 16 [protected]

Definition at line 50 of file ESDataFormatterV1_1.h.

const int ESDataFormatterV1_1::bDCH = 4 [protected]

Definition at line 45 of file ESDataFormatterV1_1.h.

const int ESDataFormatterV1_1::bDCOMFLAG = 8 [protected]

Definition at line 44 of file ESDataFormatterV1_1.h.

const int ESDataFormatterV1_1::bDEL = 24 [protected]

Definition at line 44 of file ESDataFormatterV1_1.h.

const int ESDataFormatterV1_1::bDERR = 8 [protected]

Definition at line 44 of file ESDataFormatterV1_1.h.

const int ESDataFormatterV1_1::bDH = 6 [protected]

Definition at line 44 of file ESDataFormatterV1_1.h.

const int ESDataFormatterV1_1::bDHEAD = 2 [static, protected]

Definition at line 44 of file ESDataFormatterV1_1.h.

const int ESDataFormatterV1_1::bDOPTO = 8 [protected]

Definition at line 45 of file ESDataFormatterV1_1.h.

const int ESDataFormatterV1_1::bDORBIT = 32 [protected]

Definition at line 44 of file ESDataFormatterV1_1.h.

const int ESDataFormatterV1_1::bDRUN = 24 [protected]

Definition at line 44 of file ESDataFormatterV1_1.h.

const int ESDataFormatterV1_1::bDRUNTYPE = 32 [protected]

Definition at line 44 of file ESDataFormatterV1_1.h.

const int ESDataFormatterV1_1::bDTRGTYPE = 16 [protected]

Definition at line 44 of file ESDataFormatterV1_1.h.

const int ESDataFormatterV1_1::bDVMAJOR = 8 [protected]

Definition at line 45 of file ESDataFormatterV1_1.h.

const int ESDataFormatterV1_1::bDVMINOR = 8 [static, protected]

Definition at line 45 of file ESDataFormatterV1_1.h.

const int ESDataFormatterV1_1::bE0 = 1 [protected]

Definition at line 50 of file ESDataFormatterV1_1.h.

const int ESDataFormatterV1_1::bE1 = 1 [protected]

Definition at line 50 of file ESDataFormatterV1_1.h.

const int ESDataFormatterV1_1::bFIBER = 6 [protected]

Definition at line 48 of file ESDataFormatterV1_1.h.

const int ESDataFormatterV1_1::bHEAD = 2 [static, protected]

Definition at line 50 of file ESDataFormatterV1_1.h.

const int ESDataFormatterV1_1::bKBC = 12 [protected]

Definition at line 48 of file ESDataFormatterV1_1.h.

const int ESDataFormatterV1_1::bKCE = 1 [protected]

Definition at line 48 of file ESDataFormatterV1_1.h.

const int ESDataFormatterV1_1::bKCRC = 1 [protected]

Definition at line 48 of file ESDataFormatterV1_1.h.

const int ESDataFormatterV1_1::bKEC = 8 [static, protected]

Definition at line 48 of file ESDataFormatterV1_1.h.

const int ESDataFormatterV1_1::bKET = 1 [protected]

Definition at line 48 of file ESDataFormatterV1_1.h.

const int ESDataFormatterV1_1::bKFLAG1 = 4 [protected]

Definition at line 48 of file ESDataFormatterV1_1.h.

const int ESDataFormatterV1_1::bKFLAG2 = 8 [protected]

Definition at line 48 of file ESDataFormatterV1_1.h.

const int ESDataFormatterV1_1::bKHEAD1 = 2 [protected]

Definition at line 48 of file ESDataFormatterV1_1.h.

const int ESDataFormatterV1_1::bKHEAD2 = 2 [protected]

Definition at line 48 of file ESDataFormatterV1_1.h.

const int ESDataFormatterV1_1::bKID = 11 [protected]

Definition at line 48 of file ESDataFormatterV1_1.h.

const int ESDataFormatterV1_1::bPACE = 2 [protected]

Definition at line 50 of file ESDataFormatterV1_1.h.

const int ESDataFormatterV1_1::bSTRIP = 5 [protected]

Definition at line 50 of file ESDataFormatterV1_1.h.

const int ESDataFormatterV1_1::sADC0 = 0 [protected]

Definition at line 51 of file ESDataFormatterV1_1.h.

Referenced by DigiToRaw().

const int ESDataFormatterV1_1::sADC1 = bADC0 + sADC0 [protected]

Definition at line 51 of file ESDataFormatterV1_1.h.

Referenced by DigiToRaw().

const int ESDataFormatterV1_1::sADC2 = 0 [protected]

Definition at line 51 of file ESDataFormatterV1_1.h.

Referenced by DigiToRaw().

const int ESDataFormatterV1_1::sDCH = 0 [protected]

Definition at line 47 of file ESDataFormatterV1_1.h.

Definition at line 46 of file ESDataFormatterV1_1.h.

const int ESDataFormatterV1_1::sDEL = 0 [protected]

Definition at line 46 of file ESDataFormatterV1_1.h.

Referenced by DigiToRaw().

const int ESDataFormatterV1_1::sDERR = bDEL + sDEL [protected]

Definition at line 46 of file ESDataFormatterV1_1.h.

const int ESDataFormatterV1_1::sDH = 24 [protected]

Definition at line 46 of file ESDataFormatterV1_1.h.

Referenced by DigiToRaw().

const int ESDataFormatterV1_1::sDHEAD = 26 [static, protected]

Definition at line 46 of file ESDataFormatterV1_1.h.

Referenced by DigiToRaw().

const int ESDataFormatterV1_1::sDOPTO = 16 [protected]

Definition at line 47 of file ESDataFormatterV1_1.h.

const int ESDataFormatterV1_1::sDORBIT = 0 [protected]

Definition at line 46 of file ESDataFormatterV1_1.h.

Referenced by DigiToRaw().

const int ESDataFormatterV1_1::sDRUN = 0 [protected]

Definition at line 46 of file ESDataFormatterV1_1.h.

Referenced by DigiToRaw().

const int ESDataFormatterV1_1::sDRUNTYPE = 0 [protected]

Definition at line 46 of file ESDataFormatterV1_1.h.

const int ESDataFormatterV1_1::sDTRGTYPE = 0 [protected]

Definition at line 46 of file ESDataFormatterV1_1.h.

const int ESDataFormatterV1_1::sDVMAJOR = bDVMINOR + sDVMINOR [protected]

Definition at line 47 of file ESDataFormatterV1_1.h.

Referenced by DigiToRaw().

const int ESDataFormatterV1_1::sDVMINOR = 8 [static, protected]

Definition at line 47 of file ESDataFormatterV1_1.h.

Referenced by DigiToRaw().

const int ESDataFormatterV1_1::sE0 = bSTRIP + sSTRIP + 1 [protected]

Definition at line 51 of file ESDataFormatterV1_1.h.

Referenced by DigiToRaw().

const int ESDataFormatterV1_1::sE1 = bE0 + sE0 [protected]

Definition at line 51 of file ESDataFormatterV1_1.h.

Referenced by DigiToRaw().

const int ESDataFormatterV1_1::sFIBER = bKID + sKID + 1 [protected]

Definition at line 49 of file ESDataFormatterV1_1.h.

Referenced by DigiToRaw().

const int ESDataFormatterV1_1::sHEAD = bE1 + sE1 + 4 [static, protected]

Definition at line 51 of file ESDataFormatterV1_1.h.

Referenced by DigiToRaw().

const int ESDataFormatterV1_1::sKBC = bKFLAG2 + sKFLAG2 [protected]

Definition at line 49 of file ESDataFormatterV1_1.h.

Referenced by DigiToRaw().

const int ESDataFormatterV1_1::sKCE = bKCRC + sKCRC [protected]

Definition at line 49 of file ESDataFormatterV1_1.h.

Referenced by DigiToRaw().

const int ESDataFormatterV1_1::sKCRC = bKET + sKET [protected]

Definition at line 49 of file ESDataFormatterV1_1.h.

Referenced by DigiToRaw().

const int ESDataFormatterV1_1::sKEC = 0 [static, protected]

Definition at line 49 of file ESDataFormatterV1_1.h.

Referenced by DigiToRaw().

const int ESDataFormatterV1_1::sKET = 0 [protected]

Definition at line 49 of file ESDataFormatterV1_1.h.

Referenced by DigiToRaw().

const int ESDataFormatterV1_1::sKFLAG1 = bKBC + sKBC [protected]

Definition at line 49 of file ESDataFormatterV1_1.h.

Referenced by DigiToRaw().

const int ESDataFormatterV1_1::sKFLAG2 = bKEC + sKEC [protected]

Definition at line 49 of file ESDataFormatterV1_1.h.

Referenced by DigiToRaw().

const int ESDataFormatterV1_1::sKHEAD1 = bFIBER + sFIBER + 2 [protected]

Definition at line 49 of file ESDataFormatterV1_1.h.

Referenced by DigiToRaw().

const int ESDataFormatterV1_1::sKHEAD2 = bKHEAD1 + sKHEAD1 [protected]

Definition at line 49 of file ESDataFormatterV1_1.h.

Referenced by DigiToRaw().

const int ESDataFormatterV1_1::sKID = bKCE + sKCE + 5 [protected]

Definition at line 49 of file ESDataFormatterV1_1.h.

Referenced by DigiToRaw().

const int ESDataFormatterV1_1::sPACE = bADC2 + sADC2 [protected]

Definition at line 51 of file ESDataFormatterV1_1.h.

Referenced by DigiToRaw().

const int ESDataFormatterV1_1::sSTRIP = bPACE + sPACE [protected]

Definition at line 51 of file ESDataFormatterV1_1.h.

Referenced by DigiToRaw().