CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 ()
 
void StartEvent ()
 
 ~SRBlockFormatter ()
 
- Public Member Functions inherited from BlockFormatter
 BlockFormatter ()
 
void CleanUp (FEDRawDataCollection *productRawData, std::map< int, std::map< int, int > > *FEDorder)
 
void DigiToRaw (FEDRawDataCollection *productRawData)
 
void print (FEDRawData &rawdata)
 
void PrintSizes (FEDRawDataCollection *productRawData)
 
void SetParam (EcalDigiToRaw *base)
 
 ~BlockFormatter ()
 

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
bool debug_
 
bool doBarrel_
 
bool doEndCap_
 
bool doSR_
 
bool doTCC_
 
bool doTower_
 
int * pbx_
 
int * pcounter_
 
std::vector< int32_t > * plistDCCId_
 
int * plv1_
 
int * porbit_number_
 
int * prunnumber_
 

Detailed Description

Definition at line 16 of file SRBlockFormatter.h.

Constructor & Destructor Documentation

SRBlockFormatter::SRBlockFormatter ( )

Definition at line 9 of file SRBlockFormatter.cc.

9  {
10 
11 }
SRBlockFormatter::~SRBlockFormatter ( )

Definition at line 13 of file SRBlockFormatter.cc.

13  {
14 
15 }

Member Function Documentation

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

Definition at line 25 of file SRBlockFormatter.cc.

References gather_cfg::cout, FEDRawData::data(), ntuplemaker::iline, reco::print(), FEDRawData::resize(), FEDRawData::size(), and run_regression::wflag.

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

Definition at line 18 of file SRBlockFormatter.cc.

References gather_cfg::cout.

18  {
19  if (debug_) cout << "enter in StartEvent. header_ size is " << header_.size() << endl;
20  header_ .clear() ;
21  if (debug_) cout << "after empty : header_ size is " << header_.size() << endl;
22  return;
23 }
std::map< int, int > header_
tuple cout
Definition: gather_cfg.py:121

Member Data Documentation

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

Definition at line 26 of file SRBlockFormatter.h.