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

typedef uint16_t BlockFormatter::Word16

Definition at line 16 of file BlockFormatter.h.

typedef uint64_t BlockFormatter::Word64

Definition at line 15 of file BlockFormatter.h.

Constructor & Destructor Documentation

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

Definition at line 11 of file BlockFormatter.cc.

References bx_, counter_, debug_, doBarrel_, doEndCap_, doSR_, doTCC_, doTower_, lv1_, orbit_number_, BlockFormatter::Config::plistDCCId_, and runnumber_.

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_} {}
const std::vector< int32_t > * plistDCCId_
const bool doBarrel_
const bool doTower_
const bool debug_
const bool doSR_
const bool doEndCap_
const bool doTCC_

Member Function Documentation

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

Definition at line 104 of file BlockFormatter.cc.

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

Referenced by EcalDigiToRaw::produce().

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 }
const bool doBarrel_
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
size_t size() const
Lenght of the data buffer in bytes.
Definition: FEDRawData.h:45
const FEDRawData & FEDData(int fedid) const
retrieve data for fed
void resize(size_t newsize)
Definition: FEDRawData.cc:28
const bool debug_
const bool doEndCap_
const unsigned char * data() const
Return a const pointer to the beginning of the data buffer.
Definition: FEDRawData.cc:24
void BlockFormatter::DigiToRaw ( FEDRawDataCollection productRawData)

Definition at line 25 of file BlockFormatter.cc.

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().

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 }
const bool doBarrel_
size_t size() const
Lenght of the data buffer in bytes.
Definition: FEDRawData.h:45
uint64_t word
const FEDRawData & FEDData(int fedid) const
retrieve data for fed
void resize(size_t newsize)
Definition: FEDRawData.cc:28
static const int MAX_DCCID_EBP
static const int MIN_DCCID_EBM
const bool debug_
const bool doEndCap_
uint64_t Word64
const unsigned char * data() const
Return a const pointer to the beginning of the data buffer.
Definition: FEDRawData.cc:24
static const int MIN_DCCID_EEP
void BlockFormatter::print ( FEDRawData rawdata)

Definition at line 89 of file BlockFormatter.cc.

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().

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 }
size
Write out results.
size_t size() const
Lenght of the data buffer in bytes.
Definition: FEDRawData.h:45
const unsigned char * data() const
Return a const pointer to the beginning of the data buffer.
Definition: FEDRawData.cc:24
void BlockFormatter::PrintSizes ( FEDRawDataCollection productRawData)

Definition at line 182 of file BlockFormatter.cc.

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

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 }
size_t size() const
Lenght of the data buffer in bytes.
Definition: FEDRawData.h:45
const FEDRawData & FEDData(int fedid) const
retrieve data for fed

Member Data Documentation

int BlockFormatter::bx_
protected
int BlockFormatter::counter_
protected

Definition at line 47 of file BlockFormatter.h.

Referenced by BlockFormatter().

const bool BlockFormatter::debug_
protected
const bool BlockFormatter::doBarrel_
protected

Definition at line 55 of file BlockFormatter.h.

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

const bool BlockFormatter::doEndCap_
protected

Definition at line 56 of file BlockFormatter.h.

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

const bool BlockFormatter::doSR_
protected

Definition at line 58 of file BlockFormatter.h.

Referenced by BlockFormatter().

const bool BlockFormatter::doTCC_
protected

Definition at line 57 of file BlockFormatter.h.

Referenced by BlockFormatter().

const bool BlockFormatter::doTower_
protected

Definition at line 59 of file BlockFormatter.h.

Referenced by BlockFormatter().

const int BlockFormatter::kCardsPerTower = 5
static

Definition at line 37 of file BlockFormatter.h.

int BlockFormatter::lv1_
protected
int BlockFormatter::orbit_number_
protected

Definition at line 48 of file BlockFormatter.h.

Referenced by BlockFormatter(), and DigiToRaw().

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

Definition at line 45 of file BlockFormatter.h.

int BlockFormatter::runnumber_
protected

Definition at line 51 of file BlockFormatter.h.

Referenced by BlockFormatter(), and DigiToRaw().