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 13 of file SRBlockFormatter.h.

Constructor & Destructor Documentation

◆ SRBlockFormatter()

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

Definition at line 7 of file SRBlockFormatter.cc.

7 : BlockFormatter(iC, iP) {}
BlockFormatter(Config const &iC, Params const &iP)

Member Function Documentation

◆ DigiToRaw()

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

Definition at line 9 of file SRBlockFormatter.cc.

References b1, b2, nano_mu_digi_cff::bx, BlockFormatter::bx_, gather_cfg::cout, FEDRawData::data(), BlockFormatter::debug_, TauDecayModes::dec, RemoveAddSevLevel::flag, header_, ntuplemaker::iline, BlockFormatter::lv1_, BlockFormatter::print(), FEDRawData::resize(), and FEDRawData::size().

Referenced by EcalDigiToRaw::produce().

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

Member Data Documentation

◆ header_

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

Definition at line 20 of file SRBlockFormatter.h.

Referenced by DigiToRaw().