CMS 3D CMS Logo

List of all members | Classes | Public Types | Public Member Functions | Static Public Attributes | Protected Attributes
BlockFormatter Class Reference

#include <BlockFormatter.h>

Inheritance diagram for BlockFormatter:
SRBlockFormatter TCCBlockFormatter TowerBlockFormatter

Classes

struct  Config
 
struct  Params
 

Public Types

typedef uint16_t Word16
 
typedef uint64_t Word64
 

Public Member Functions

 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)
 

Static Public Attributes

static const int kCardsPerTower = 5
 

Protected Attributes

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 BlockFormatter.h.

Member Typedef Documentation

◆ Word16

typedef uint16_t BlockFormatter::Word16

Definition at line 16 of file BlockFormatter.h.

◆ Word64

typedef uint64_t BlockFormatter::Word64

Definition at line 15 of file BlockFormatter.h.

Constructor & Destructor Documentation

◆ BlockFormatter()

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

Definition at line 11 of file BlockFormatter.cc.

12  : plistDCCId_{iC.plistDCCId_},
13  counter_{iP.counter_},
14  orbit_number_{iP.orbit_number_},
15  bx_{iP.bx_},
16  lv1_{iP.lv1_},
17  runnumber_{iP.runnumber_},
18  debug_{iC.debug_},
19  doBarrel_{iC.doBarrel_},
20  doEndCap_{iC.doEndCap_},
21  doTCC_{iC.doTCC_},
22  doSR_{iC.doSR_},
23  doTower_{iC.doTower_} {}

References BlockFormatter::Config::plistDCCId_.

Member Function Documentation

◆ CleanUp()

void BlockFormatter::CleanUp ( FEDRawDataCollection productRawData,
std::map< int, std::map< int, int > > *  FEDorder 
)

Definition at line 104 of file BlockFormatter.cc.

104  {
105  for (int id = 0; id < 36 + 18; id++) {
106  if ((!doBarrel_) && (id >= 9 && id <= 44))
107  continue;
108  if ((!doEndCap_) && (id <= 8 || id >= 45))
109  continue;
110 
111  int FEDid = FEDNumbering::MINECALFEDID + id + 1;
112  FEDRawData& rawdata = productRawData->FEDData(FEDid);
113 
114  // ---- if raw need not be made for a given fed, set its size to empty and return
115  if (find((*plistDCCId_).begin(), (*plistDCCId_).end(), (id + 1)) == (*plistDCCId_).end()) {
116  rawdata.resize(0);
117  continue;
118  }
119 
120  // ---- Add the trailer word
121  int lastline = rawdata.size();
122  rawdata.resize(lastline + 8);
123  unsigned char* pData = rawdata.data();
124  int event_length = (lastline + 8) / 8; // in 64 bits words
125 
126  pData[lastline + 7] = 0xa0;
127  // pData[lastline+4] = event_length & 0xFFFFFF;
128  pData[lastline + 4] = event_length & 0xFF;
129  pData[lastline + 5] = (event_length >> 8) & 0xFF;
130  pData[lastline + 6] = (event_length >> 16) & 0xFF;
131  int event_status = 0;
132  pData[lastline + 1] = event_status & 0x0F;
133  int tts = 0 << 4;
134  pData[lastline] = tts & 0xF0;
135 
136  // ---- Write the event length in the DCC header
137  // pData[8] = event_length & 0xFFFFFF;
138  pData[8] = event_length & 0xFF;
139  pData[9] = (event_length >> 8) & 0xFF;
140  pData[10] = (event_length >> 16) & 0xFF;
141 
142  // cout << " in BlockFormatter::CleanUp. FEDid = " << FEDid << " event_length*8 " << dec << event_length*8 << endl;
143 
144  map<int, map<int, int> >::iterator fen = FEDorder->find(FEDid);
145 
146  bool FED_has_data = true;
147  if (fen == FEDorder->end())
148  FED_has_data = false;
149  if (debug_ && (!FED_has_data))
150  cout << " FEDid is not in FEDorder ! " << endl;
151  if (!FED_has_data) {
152  int ch_status = 7;
153  for (int iFE = 1; iFE <= 68; iFE++) {
154  int irow = (iFE - 1) / 14;
155  int kval = ((iFE - 1) % 14) / 2;
156  if (iFE % 2 == 1)
157  pData[32 + 8 * irow + kval] |= ch_status & 0xFF;
158  else
159  pData[32 + 8 * irow + kval] |= ((ch_status << 4) & 0xFF);
160  }
161  }
162 
163  if (FED_has_data) {
164  map<int, int>& FEorder = (*fen).second;
165 
166  for (int iFE = 1; iFE <= 68; iFE++) {
167  map<int, int>::iterator fe = FEorder.find(iFE);
168  int ch_status = 0;
169  if (fe == FEorder.end()) // FE not present due to SRP, update CH_status
170  ch_status = 7; // CH_SUPPRESS
171  int irow = (iFE - 1) / 14;
172  int kval = ((iFE - 1) % 14) / 2;
173  if (iFE % 2 == 1)
174  pData[32 + 8 * irow + kval] |= ch_status & 0xFF;
175  else
176  pData[32 + 8 * irow + kval] |= ((ch_status << 4) & 0xFF);
177  }
178  }
179  }
180 }

References gather_cfg::cout, FEDRawData::data(), debug_, doBarrel_, doEndCap_, FEDRawDataCollection::FEDData(), spr::find(), FEDNumbering::MINECALFEDID, FEDRawData::resize(), and FEDRawData::size().

Referenced by EcalDigiToRaw::produce().

◆ DigiToRaw()

void BlockFormatter::DigiToRaw ( FEDRawDataCollection productRawData)

Definition at line 25 of file BlockFormatter.cc.

25  {
26  int run_number = runnumber_;
27  int bx = bx_;
28  int lv1 = lv1_;
29 
30  if (debug_)
31  cout << "in BlockFormatter::DigiToRaw run_number orbit_number bx lv1 " << dec << run_number << " " << orbit_number_
32  << " " << bx << " " << lv1 << endl;
33 
34  for (int idcc = 1; idcc <= 54; idcc++) {
36  continue;
37  if ((!doEndCap_) && (idcc <= EcalElectronicsId::MAX_DCCID_EEM || idcc >= EcalElectronicsId::MIN_DCCID_EEP))
38  continue;
39 
40  int FEDid = FEDNumbering::MINECALFEDID + idcc;
41  FEDRawData& rawdata = productRawData->FEDData(FEDid);
42  unsigned char* pData;
43  short int DCC_ERRORS = 0;
44 
45  if (rawdata.size() == 0) {
46  rawdata.resize(8);
47  pData = rawdata.data();
48 
49  Word64 word = 0x18 + ((FEDid & 0xFFF) << 8) + ((Word64)((Word64)bx & 0xFFF) << 20) +
50  ((Word64)((Word64)lv1 & 0xFFFFFF) << 32) + (Word64)((Word64)0x51 << 56);
51  Word64* pw = reinterpret_cast<Word64*>(const_cast<unsigned char*>(pData));
52  *pw = word; // DAQ header
53 
54  rawdata.resize(rawdata.size() + 8 * 8); // DCC header
55  pData = rawdata.data();
56  pData[11] = DCC_ERRORS & 0xFF;
57  pData[12] = run_number & 0xFF;
58  pData[13] = (run_number >> 8) & 0xFF;
59  pData[14] = (run_number >> 16) & 0xFF;
60  pData[15] = 0x01;
61 
62  for (int i = 16; i <= 22; i++) {
63  pData[i] = 0; // to be filled for local data taking or calibration
64  }
65  pData[23] = 0x02;
66  pData[24] = orbit_number_ & 0xFF;
67  pData[25] = (orbit_number_ >> 8) & 0xFF;
68  pData[26] = (orbit_number_ >> 16) & 0xFF;
69  pData[27] = (orbit_number_ >> 24) & 0xFF;
70  int SRenable_ = 1;
71  int SR = SRenable_;
72  int ZS = 0;
73  int TZS = 0;
74  // int SR_CHSTATUS = 0;
75  pData[28] = (SR & 0x1) + ((ZS & 0x1) << 1) + ((TZS & 0x1) << 2);
76  pData[31] = 0x03;
77 
78  for (int i = 0; i <= 4; i++) {
79  for (int j = 0; j < 7; j++) {
80  pData[32 + 8 * i + j] = 0;
81  }
82  pData[32 + 8 * i + 7] = 0x04;
83  }
84 
85  } // endif rawdatasize == 0
86  } // loop on id
87 }

References l1GtPatternGenerator_cfi::bx, bx_, gather_cfg::cout, FEDRawData::data(), debug_, TauDecayModes::dec, doBarrel_, doEndCap_, FEDRawDataCollection::FEDData(), mps_fire::i, dqmiolumiharvest::j, lv1_, EcalElectronicsId::MAX_DCCID_EBP, EcalElectronicsId::MIN_DCCID_EBM, EcalElectronicsId::MIN_DCCID_EEP, FEDNumbering::MINECALFEDID, orbit_number_, FEDRawData::resize(), contentValuesCheck::run_number, runnumber_, FEDRawData::size(), testProducerWithPsetDescEmpty_cfi::x1, and CaloTPGTranscoder_cfi::ZS.

Referenced by EcalDigiToRaw::produce().

◆ print()

void BlockFormatter::print ( FEDRawData rawdata)

Definition at line 89 of file BlockFormatter.cc.

89  {
90  int size = rawdata.size();
91  cout << "Print RawData size " << dec << size << endl;
92  unsigned char* pData = rawdata.data();
93 
94  int n = size / 8;
95  for (int i = 0; i < n; i++) {
96  for (int j = 7; j >= 0; j--) {
97  if (8 * i + j <= size)
98  cout << hex << (int)pData[8 * i + j] << " ";
99  }
100  cout << endl;
101  }
102 }

References gather_cfg::cout, FEDRawData::data(), TauDecayModes::dec, mps_fire::i, createfilelist::int, dqmiolumiharvest::j, dqmiodumpmetadata::n, FEDRawData::size(), and findQualityFiles::size.

Referenced by SRBlockFormatter::DigiToRaw(), TowerBlockFormatter::DigiToRaw(), TCCBlockFormatter::DigiToRaw(), and EcalDigiToRaw::produce().

◆ PrintSizes()

void BlockFormatter::PrintSizes ( FEDRawDataCollection productRawData)

Definition at line 182 of file BlockFormatter.cc.

182  {
183  for (int id = 0; id < 36 + 18; id++) {
184  // if ( (! doBarrel_) && (id >= 9 && id <= 44)) continue;
185  // if ( (! doEndCap_) && (id <= 8 || id >= 45)) continue;
186 
187  int FEDid = FEDNumbering::MINECALFEDID + id;
188  FEDRawData& rawdata = productRawData->FEDData(FEDid);
189  if (rawdata.size() > 0)
190  cout << "Size of FED id " << dec << FEDid << " is : " << dec << rawdata.size() << endl;
191  }
192 }

References gather_cfg::cout, TauDecayModes::dec, FEDRawDataCollection::FEDData(), triggerObjects_cff::id, FEDNumbering::MINECALFEDID, and FEDRawData::size().

Member Data Documentation

◆ bx_

int BlockFormatter::bx_
protected

◆ counter_

int BlockFormatter::counter_
protected

Definition at line 47 of file BlockFormatter.h.

◆ debug_

const bool BlockFormatter::debug_
protected

◆ doBarrel_

const bool BlockFormatter::doBarrel_
protected

Definition at line 55 of file BlockFormatter.h.

Referenced by CleanUp(), TCCBlockFormatter::DigiToRaw(), and DigiToRaw().

◆ doEndCap_

const bool BlockFormatter::doEndCap_
protected

Definition at line 56 of file BlockFormatter.h.

Referenced by CleanUp(), TCCBlockFormatter::DigiToRaw(), and DigiToRaw().

◆ doSR_

const bool BlockFormatter::doSR_
protected

Definition at line 58 of file BlockFormatter.h.

◆ doTCC_

const bool BlockFormatter::doTCC_
protected

Definition at line 57 of file BlockFormatter.h.

◆ doTower_

const bool BlockFormatter::doTower_
protected

Definition at line 59 of file BlockFormatter.h.

◆ kCardsPerTower

const int BlockFormatter::kCardsPerTower = 5
static

Definition at line 37 of file BlockFormatter.h.

◆ lv1_

int BlockFormatter::lv1_
protected

◆ orbit_number_

int BlockFormatter::orbit_number_
protected

Definition at line 48 of file BlockFormatter.h.

Referenced by DigiToRaw().

◆ plistDCCId_

const std::vector<int32_t>* BlockFormatter::plistDCCId_
protected

Definition at line 45 of file BlockFormatter.h.

◆ runnumber_

int BlockFormatter::runnumber_
protected

Definition at line 51 of file BlockFormatter.h.

Referenced by DigiToRaw().

FEDNumbering::MINECALFEDID
Definition: FEDNumbering.h:43
BlockFormatter::Word64
uint64_t Word64
Definition: BlockFormatter.h:15
mps_fire.i
i
Definition: mps_fire.py:355
dqmiodumpmetadata.n
n
Definition: dqmiodumpmetadata.py:28
gather_cfg.cout
cout
Definition: gather_cfg.py:144
l1GtPatternGenerator_cfi.bx
bx
Definition: l1GtPatternGenerator_cfi.py:18
contentValuesCheck.run_number
run_number
Definition: contentValuesCheck.py:38
spr::find
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
FEDRawData::data
const unsigned char * data() const
Return a const pointer to the beginning of the data buffer.
Definition: FEDRawData.cc:24
FEDRawData
Definition: FEDRawData.h:19
word
uint64_t word
Definition: CTPPSTotemDataFormatter.cc:29
EcalElectronicsId::MIN_DCCID_EBM
static const int MIN_DCCID_EBM
Definition: EcalElectronicsId.h:64
testProducerWithPsetDescEmpty_cfi.x1
x1
Definition: testProducerWithPsetDescEmpty_cfi.py:33
CaloTPGTranscoder_cfi.ZS
ZS
Definition: CaloTPGTranscoder_cfi.py:22
BlockFormatter::bx_
int bx_
Definition: BlockFormatter.h:49
BlockFormatter::doBarrel_
const bool doBarrel_
Definition: BlockFormatter.h:55
BlockFormatter::debug_
const bool debug_
Definition: BlockFormatter.h:53
FEDRawDataCollection::FEDData
const FEDRawData & FEDData(int fedid) const
retrieve data for fed
Definition: FEDRawDataCollection.cc:19
BlockFormatter::doTower_
const bool doTower_
Definition: BlockFormatter.h:59
BlockFormatter::plistDCCId_
const std::vector< int32_t > * plistDCCId_
Definition: BlockFormatter.h:45
BlockFormatter::doSR_
const bool doSR_
Definition: BlockFormatter.h:58
BlockFormatter::doEndCap_
const bool doEndCap_
Definition: BlockFormatter.h:56
Word64
uint64_t Word64
Definition: RPCUnpackingModule.cc:38
createfilelist.int
int
Definition: createfilelist.py:10
EcalElectronicsId::MAX_DCCID_EBP
static const int MAX_DCCID_EBP
Definition: EcalElectronicsId.h:67
BlockFormatter::lv1_
int lv1_
Definition: BlockFormatter.h:50
FEDRawData::size
size_t size() const
Lenght of the data buffer in bytes.
Definition: FEDRawData.h:45
BlockFormatter::orbit_number_
int orbit_number_
Definition: BlockFormatter.h:48
BlockFormatter::runnumber_
int runnumber_
Definition: BlockFormatter.h:51
triggerObjects_cff.id
id
Definition: triggerObjects_cff.py:31
FEDRawData::resize
void resize(size_t newsize)
Definition: FEDRawData.cc:28
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
EcalElectronicsId::MIN_DCCID_EEP
static const int MIN_DCCID_EEP
Definition: EcalElectronicsId.h:68
TauDecayModes.dec
dec
Definition: TauDecayModes.py:143
BlockFormatter::doTCC_
const bool doTCC_
Definition: BlockFormatter.h:57
findQualityFiles.size
size
Write out results.
Definition: findQualityFiles.py:443
BlockFormatter::counter_
int counter_
Definition: BlockFormatter.h:47