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 15 of file BlockFormatter.h.

Member Typedef Documentation

typedef uint16_t BlockFormatter::Word16

Definition at line 18 of file BlockFormatter.h.

typedef uint64_t BlockFormatter::Word64

Definition at line 17 of file BlockFormatter.h.

Constructor & Destructor Documentation

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

Definition at line 13 of file BlockFormatter.cc.

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

13  :
14  plistDCCId_{iC.plistDCCId_},
15  counter_{iP.counter_},
16  orbit_number_{iP.orbit_number_},
17  bx_{iP.bx_},
18  lv1_{iP.lv1_},
19  runnumber_{iP.runnumber_},
20  debug_{iC.debug_},
21  doBarrel_{iC.doBarrel_},
22  doEndCap_{iC.doEndCap_},
23  doTCC_{iC.doTCC_},
24  doSR_{iC.doSR_},
25  doTower_{iC.doTower_}
26 {
27 }
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 114 of file BlockFormatter.cc.

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

Referenced by EcalDigiToRaw::produce().

115  {
116 
117 
118  for (int id=0; id < 36 + 18; id++) {
119  if ( (! doBarrel_) && (id >= 9 && id <= 44)) continue;
120  if ( (! doEndCap_) && (id <= 8 || id >= 45)) continue;
121 
122  int FEDid = FEDNumbering::MINECALFEDID + id +1;
123  FEDRawData& rawdata = productRawData -> FEDData(FEDid);
124 
125  // ---- if raw need not be made for a given fed, set its size to empty and return
126  if ( find( (*plistDCCId_).begin(), (*plistDCCId_).end(), (id+1) ) == (*plistDCCId_).end() )
127  {
128  rawdata.resize( 0 );
129  continue;
130  }
131 
132  // ---- Add the trailer word
133  int lastline = rawdata.size();
134  rawdata.resize( lastline + 8);
135  unsigned char * pData = rawdata.data();
136  int event_length = (lastline + 8) / 8; // in 64 bits words
137 
138  pData[lastline+7] = 0xa0;
139  // pData[lastline+4] = event_length & 0xFFFFFF;
140  pData[lastline+4] = event_length & 0xFF;
141  pData[lastline+5] = (event_length >> 8) & 0xFF;
142  pData[lastline+6] = (event_length >> 16) & 0xFF;
143  int event_status = 0;
144  pData[lastline+1] = event_status & 0x0F;
145  int tts = 0 <<4;
146  pData[lastline] = tts & 0xF0;
147 
148  // ---- Write the event length in the DCC header
149  // pData[8] = event_length & 0xFFFFFF;
150  pData[8] = event_length & 0xFF;
151  pData[9] = (event_length >> 8) & 0xFF;
152  pData[10] = (event_length >> 16) & 0xFF;
153 
154  // cout << " in BlockFormatter::CleanUp. FEDid = " << FEDid << " event_length*8 " << dec << event_length*8 << endl;
155 
156  map<int, map<int,int> >::iterator fen = FEDorder -> find(FEDid);
157 
158  bool FED_has_data = true;
159  if (fen == FEDorder->end()) FED_has_data = false;
160  if (debug_ && (! FED_has_data)) cout << " FEDid is not in FEDorder ! " << endl;
161  if ( ! FED_has_data) {
162  int ch_status = 7;
163  for (int iFE=1; iFE <= 68; iFE++) {
164  int irow = (iFE-1) / 14;
165  int kval = ( (iFE-1) % 14) / 2;
166  if (iFE % 2 ==1) pData[32 + 8*irow + kval] |= ch_status & 0xFF;
167  else pData[32 + 8*irow + kval] |= ((ch_status <<4) & 0xFF);
168  }
169  }
170 
171  if (FED_has_data) {
172  map<int, int>& FEorder = (*fen).second;
173 
174  for (int iFE=1; iFE <= 68; iFE++) {
175  map<int,int>::iterator fe = FEorder.find(iFE);
176  int ch_status = 0;
177  if (fe == FEorder.end()) // FE not present due to SRP, update CH_status
178  ch_status = 7; // CH_SUPPRESS
179  int irow = (iFE-1) / 14;
180  int kval = ( (iFE-1) % 14) / 2;
181  if (iFE % 2 ==1) pData[32 + 8*irow + kval] |= ch_status & 0xFF;
182  else pData[32 + 8*irow + kval] |= ((ch_status <<4) & 0xFF);
183 
184  }
185  }
186 
187  }
188 }
const bool doBarrel_
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:20
size_t size() const
Lenght of the data buffer in bytes.
Definition: FEDRawData.h:47
void resize(size_t newsize)
Definition: FEDRawData.cc:32
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:28
void BlockFormatter::DigiToRaw ( FEDRawDataCollection productRawData)

Definition at line 29 of file BlockFormatter.cc.

References bx_, gather_cfg::cout, FEDRawData::data(), debug_, TauDecayModes::dec, doBarrel_, doEndCap_, mps_fire::i, lv1_, EcalElectronicsId::MAX_DCCID_EBP, EcalElectronicsId::MIN_DCCID_EBM, EcalElectronicsId::MIN_DCCID_EEP, FEDNumbering::MINECALFEDID, orbit_number_, matplotRender::rawdata, FEDRawData::resize(), runnumber_, FEDRawData::size(), globals_cff::x1, and CaloTPGTranscoder_cfi::ZS.

Referenced by EcalDigiToRaw::produce().

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

Definition at line 98 of file BlockFormatter.cc.

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

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

98  {
99  int size = rawdata.size();
100  cout << "Print RawData size " << dec << size << endl;
101  unsigned char* pData = rawdata.data();
102 
103  int n = size/8;
104  for (int i=0; i < n; i++) {
105  for (int j=7; j>=0; j--) {
106  if (8*i+j <= size) cout << hex << (int)pData[8*i+j] << " ";
107  }
108  cout << endl;
109  }
110 }
size
Write out results.
size_t size() const
Lenght of the data buffer in bytes.
Definition: FEDRawData.h:47
const unsigned char * data() const
Return a const pointer to the beginning of the data buffer.
Definition: FEDRawData.cc:28
void BlockFormatter::PrintSizes ( FEDRawDataCollection productRawData)

Definition at line 191 of file BlockFormatter.cc.

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

191  {
192 
193 
194  for (int id=0; id < 36 + 18; id++) {
195 
196  // if ( (! doBarrel_) && (id >= 9 && id <= 44)) continue;
197  // if ( (! doEndCap_) && (id <= 8 || id >= 45)) continue;
198 
199 
200  int FEDid = FEDNumbering::MINECALFEDID + id;
201  FEDRawData& rawdata = productRawData -> FEDData(FEDid);
202  if (rawdata.size() > 0)
203  cout << "Size of FED id " << dec << FEDid << " is : " << dec << rawdata.size() << endl;
204 
205  }
206 }
size_t size() const
Lenght of the data buffer in bytes.
Definition: FEDRawData.h:47

Member Data Documentation

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

Definition at line 51 of file BlockFormatter.h.

Referenced by BlockFormatter().

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

Definition at line 59 of file BlockFormatter.h.

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

const bool BlockFormatter::doEndCap_
protected

Definition at line 60 of file BlockFormatter.h.

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

const bool BlockFormatter::doSR_
protected

Definition at line 62 of file BlockFormatter.h.

Referenced by BlockFormatter().

const bool BlockFormatter::doTCC_
protected

Definition at line 61 of file BlockFormatter.h.

Referenced by BlockFormatter().

const bool BlockFormatter::doTower_
protected

Definition at line 63 of file BlockFormatter.h.

Referenced by BlockFormatter().

const int BlockFormatter::kCardsPerTower = 5
static

Definition at line 39 of file BlockFormatter.h.

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

Definition at line 52 of file BlockFormatter.h.

Referenced by BlockFormatter(), and DigiToRaw().

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

Definition at line 49 of file BlockFormatter.h.

int BlockFormatter::runnumber_
protected

Definition at line 55 of file BlockFormatter.h.

Referenced by BlockFormatter(), and DigiToRaw().