CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
SRBlockFormatter Class Reference

#include <SRBlockFormatter.h>

Inheritance diagram for SRBlockFormatter:
BlockFormatter

Public Member Functions

void DigiToRaw (int dccid, int dcc_channel, int flag, FEDRawData &rawdata)
 
 SRBlockFormatter (BlockFormatter::Config const &, BlockFormatter::Params const &)
 
- Public Member Functions inherited from BlockFormatter
 BlockFormatter (Config const &iC, Params const &iP)
 
void CleanUp (FEDRawDataCollection *productRawData, std::map< int, std::map< int, int > > *FEDorder)
 
void DigiToRaw (FEDRawDataCollection *productRawData)
 
void print (FEDRawData &rawdata)
 
void PrintSizes (FEDRawDataCollection *productRawData)
 

Private Attributes

std::map< int, int > header_
 

Additional Inherited Members

- Public Types inherited from BlockFormatter
typedef uint16_t Word16
 
typedef uint64_t Word64
 
- Static Public Attributes inherited from BlockFormatter
static const int kCardsPerTower = 5
 
- Protected Attributes inherited from BlockFormatter
int bx_
 
int counter_
 
const bool debug_
 
const bool doBarrel_
 
const bool doEndCap_
 
const bool doSR_
 
const bool doTCC_
 
const bool doTower_
 
int lv1_
 
int orbit_number_
 
const std::vector< int32_t > * plistDCCId_
 
int runnumber_
 

Detailed Description

Definition at line 14 of file SRBlockFormatter.h.

Constructor & Destructor Documentation

SRBlockFormatter::SRBlockFormatter ( BlockFormatter::Config const &  iC,
BlockFormatter::Params const &  iP 
)

Definition at line 9 of file SRBlockFormatter.cc.

9  : BlockFormatter(iC,iP) {
10 
11 }
BlockFormatter(Config const &iC, Params const &iP)

Member Function Documentation

void SRBlockFormatter::DigiToRaw ( int  dccid,
int  dcc_channel,
int  flag,
FEDRawData rawdata 
)

Definition at line 13 of file SRBlockFormatter.cc.

References BlockFormatter::bx_, gather_cfg::cout, FEDRawData::data(), BlockFormatter::debug_, TauDecayModes::dec, header_, ntuplemaker::iline, BlockFormatter::lv1_, BlockFormatter::print(), FEDRawData::resize(), and FEDRawData::size().

Referenced by EcalDigiToRaw::produce().

14 {
15 
16  if (debug_) cout << "enter in SRBlockFormatter::DigiToRaw " << endl;
17  if (debug_) print(rawdata);
18 
19  int bx = bx_;
20  int lv1 = lv1_;
21 
22  int Nrows_SRP = 5; // Both for Barrel and EndCap (without the header row)
23  int SRid = (dccid -1) / 3 +1;
24 
25 
26  // int Number_SRP_Flags = 68;
27 
28  int SRP_index;
29  int icode = 1000 * dccid + SRid;
30  if (debug_) cout << "size of header_ map is " << header_.size() << endl;
31 
32  std::map<int, int>::const_iterator it_header = header_.find(icode);
33 
34  if ( it_header != header_.end() ) {
35  SRP_index = rawdata.size() / 8 - Nrows_SRP;
36  if (debug_) cout << "This SRid is already there." << endl;
37  }
38  else {
39  if (debug_) cout << "New SR Block added on Raw data " << endl;
40  header_[icode] = 1;
41  SRP_index = rawdata.size() / 8;
42  rawdata.resize (rawdata.size() + 8 + 8*Nrows_SRP); // 1 line for SRP header, 5 lines of data
43  unsigned char* ppData = rawdata.data();
44  ppData[8*SRP_index] = SRid & 0xFF;
45  ppData[8*SRP_index+2] = bx & 0xFF;
46  ppData[8*SRP_index+3] = (bx & 0xF00)>>8;
47  ppData[8*SRP_index+3] |= 0x80;
48  ppData[8*SRP_index+4] = lv1 & 0xFF;
49  ppData[8*SRP_index+5] = (lv1 & 0xF00)>>8;
50  // ppData[8*SRP_index+6] = Number_SRP_Flags;
51  ppData[8*SRP_index+6] = 0;
52  ppData[8*SRP_index+7] = 0x80;
53  SRP_index ++;
54  if (debug_) cout << "Added headers and empty lines : " << endl;
55  if (debug_) print(rawdata);
56 
57  // -- put the B011 and B100 already, since for Endcap there can be empty
58  // -- lines in the TCC and the SRP blocks
59  unsigned char* Data = rawdata.data();
60  for (int iline=SRP_index; iline < SRP_index+Nrows_SRP; iline++) {
61  Data[8*iline + 7] |= 0x80;
62  Data[8*iline + 3] |= 0x80;
63  }
64  }
65 
66  unsigned char* pData = rawdata.data();
67 
68  // -- Now the TCC Block :
69 
70  int nflags = pData[8*(SRP_index-1) +6] & 0x7F;
71  nflags ++;
72  pData[8*(SRP_index-1) + 6] = nflags & 0x7F;
73 
74  int jTT = (dcc_channel-1);
75  int irow = jTT/16 ;
76  int ival = jTT % 4;
77  int kval = (jTT % 16) / 4;
78  SRP_index += irow;
79 
80  if (debug_) cout << "Now add SC to SRBlock " << dec << dcc_channel << " irow ival " << dec << irow << " " << dec << ival << endl;
81  if (debug_) cout << "new data will be added at line " << dec << SRP_index << endl;
82 
83 
84  unsigned char* buff = &pData[8*SRP_index];
85  Word64* pw = reinterpret_cast<Word64*>(const_cast<unsigned char*>(buff));
86  int nbits = kval*16 + 3*ival;
87  Word64 wflag = (Word64)((short int)flag & 0x7) << nbits;
88  *pw |= wflag;
89  Word64 b1 = (Word64)((Word64)0x80 <<56);
90  *pw |= b1 ;
91  Word64 b2 = (Word64)((Word64)0x80 <<24);
92  *pw |= b2 ;
93 
94  if (debug_) print(rawdata);
95 
96 
97 }
size_t size() const
Lenght of the data buffer in bytes.
Definition: FEDRawData.h:47
void print(FEDRawData &rawdata)
void resize(size_t newsize)
Definition: FEDRawData.cc:32
const bool debug_
uint64_t Word64
std::map< int, int > header_
const unsigned char * data() const
Return a const pointer to the beginning of the data buffer.
Definition: FEDRawData.cc:28

Member Data Documentation

std::map<int, int> SRBlockFormatter::header_
private

Definition at line 22 of file SRBlockFormatter.h.

Referenced by DigiToRaw().