CMS 3D CMS Logo

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

#include <BlockFormatter.h>

Inheritance diagram for BlockFormatter:
SRBlockFormatter TCCBlockFormatter TowerBlockFormatter

Public Types

typedef uint16_t Word16
 
typedef uint64_t Word64
 

Public Member Functions

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

Static Public Attributes

static const int kCardsPerTower = 5
 

Protected Attributes

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

Member Typedef Documentation

typedef uint16_t BlockFormatter::Word16

Definition at line 21 of file BlockFormatter.h.

typedef uint64_t BlockFormatter::Word64

Definition at line 20 of file BlockFormatter.h.

Constructor & Destructor Documentation

BlockFormatter::BlockFormatter ( )

Definition at line 14 of file BlockFormatter.cc.

14  {
15 }
BlockFormatter::~BlockFormatter ( )

Definition at line 17 of file BlockFormatter.cc.

17  {
18 }

Member Function Documentation

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

Definition at line 125 of file BlockFormatter.cc.

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

126  {
127 
128 
129  for (int id=0; id < 36 + 18; id++) {
130  if ( (! doBarrel_) && (id >= 9 && id <= 44)) continue;
131  if ( (! doEndCap_) && (id <= 8 || id >= 45)) continue;
132 
133  int FEDid = FEDNumbering::MINECALFEDID + id +1;
134  FEDRawData& rawdata = productRawData -> FEDData(FEDid);
135 
136  // ---- if raw need not be made for a given fed, set its size to empty and return
137  if ( find( (*plistDCCId_).begin(), (*plistDCCId_).end(), (id+1) ) == (*plistDCCId_).end() )
138  {
139  rawdata.resize( 0 );
140  continue;
141  }
142 
143  // ---- Add the trailer word
144  int lastline = rawdata.size();
145  rawdata.resize( lastline + 8);
146  unsigned char * pData = rawdata.data();
147  int event_length = (lastline + 8) / 8; // in 64 bits words
148 
149  pData[lastline+7] = 0xa0;
150  // pData[lastline+4] = event_length & 0xFFFFFF;
151  pData[lastline+4] = event_length & 0xFF;
152  pData[lastline+5] = (event_length >> 8) & 0xFF;
153  pData[lastline+6] = (event_length >> 16) & 0xFF;
154  int event_status = 0;
155  pData[lastline+1] = event_status & 0x0F;
156  int tts = 0 <<4;
157  pData[lastline] = tts & 0xF0;
158 
159  // ---- Write the event length in the DCC header
160  // pData[8] = event_length & 0xFFFFFF;
161  pData[8] = event_length & 0xFF;
162  pData[9] = (event_length >> 8) & 0xFF;
163  pData[10] = (event_length >> 16) & 0xFF;
164 
165  // cout << " in BlockFormatter::CleanUp. FEDid = " << FEDid << " event_length*8 " << dec << event_length*8 << endl;
166 
167  map<int, map<int,int> >::iterator fen = FEDorder -> find(FEDid);
168 
169  bool FED_has_data = true;
170  if (fen == FEDorder->end()) FED_has_data = false;
171  if (debug_ && (! FED_has_data)) cout << " FEDid is not in FEDorder ! " << endl;
172  if ( ! FED_has_data) {
173  int ch_status = 7;
174  for (int iFE=1; iFE <= 68; iFE++) {
175  int irow = (iFE-1) / 14;
176  int kval = ( (iFE-1) % 14) / 2;
177  if (iFE % 2 ==1) pData[32 + 8*irow + kval] |= ch_status & 0xFF;
178  else pData[32 + 8*irow + kval] |= ((ch_status <<4) & 0xFF);
179  }
180  }
181 
182  if (FED_has_data) {
183  map<int, int>& FEorder = (*fen).second;
184 
185  for (int iFE=1; iFE <= 68; iFE++) {
186  map<int,int>::iterator fe = FEorder.find(iFE);
187  int ch_status = 0;
188  if (fe == FEorder.end()) // FE not present due to SRP, update CH_status
189  ch_status = 7; // CH_SUPPRESS
190  int irow = (iFE-1) / 14;
191  int kval = ( (iFE-1) % 14) / 2;
192  if (iFE % 2 ==1) pData[32 + 8*irow + kval] |= ch_status & 0xFF;
193  else pData[32 + 8*irow + kval] |= ((ch_status <<4) & 0xFF);
194 
195  }
196  }
197 
198  }
199 }
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 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 39 of file BlockFormatter.cc.

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

39  {
40 
41  int run_number = *prunnumber_;
42  int orbit_number_ = *porbit_number_;
43  int bx = *pbx_;
44  int lv1 = *plv1_;
45 
46  if (debug_) cout << "in BlockFormatter::DigiToRaw run_number orbit_number bx lv1 " << dec << run_number << " " <<
47  orbit_number_ << " " << bx << " " << lv1 << endl;
48 
49  for (int idcc=1; idcc <= 54; idcc++) {
50  if ( (! doBarrel_) &&
52  if ( (! doEndCap_) &&
53  (idcc <= EcalElectronicsId::MAX_DCCID_EEM || idcc >= EcalElectronicsId::MIN_DCCID_EEP)) continue;
54 
55  int FEDid = FEDNumbering::MINECALFEDID + idcc;
56  FEDRawData& rawdata = productRawData -> FEDData(FEDid);
57  unsigned char * pData;
58  short int DCC_ERRORS = 0;
59 
60  if (rawdata.size() == 0) {
61  rawdata.resize(8);
62  pData = rawdata.data();
63 
64  Word64 word = 0x18 + ((FEDid & 0xFFF)<<8)
65  + ((Word64)((Word64)bx & 0xFFF)<<20)
66  + ((Word64)((Word64)lv1 & 0xFFFFFF)<<32)
67  + (Word64)((Word64)0x51<<56);
68  Word64* pw = reinterpret_cast<Word64*>(const_cast<unsigned char*>(pData));
69  *pw = word; // DAQ header
70 
71  rawdata.resize(rawdata.size() + 8*8); // DCC header
72  pData = rawdata.data();
73  pData[11] = DCC_ERRORS & 0xFF;
74  pData[12] = run_number & 0xFF;
75  pData[13] = (run_number >>8) & 0xFF;
76  pData[14] = (run_number >> 16) & 0xFF;
77  pData[15] = 0x01;
78 
79  for (int i=16; i <= 22; i++) {
80  pData[i] = 0; // to be filled for local data taking or calibration
81  }
82  pData[23] = 0x02;
83  pData[24] = orbit_number_ & 0xFF;
84  pData[25] = (orbit_number_ >>8) & 0xFF;
85  pData[26] = (orbit_number_ >>16) & 0xFF;
86  pData[27] = (orbit_number_ >>24) & 0xFF;
87  int SRenable_ = 1;
88  int SR = SRenable_;
89  int ZS = 0;
90  int TZS = 0;
91  // int SR_CHSTATUS = 0;
92  pData[28] = (SR&0x1) + ((ZS&0x1)<<1) + ((TZS&0x1)<<2);
93  pData[31] = 0x03;
94 
95  for (int i=0; i<=4; i++) {
96  for (int j=0; j<7; j++) {
97  pData[32 +8*i + j] = 0;
98  }
99  pData[32 +8*i + 7] = 0x04;
100  }
101 
102  } // endif rawdatasize == 0
103  } // loop on id
104 
105 }
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
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 109 of file BlockFormatter.cc.

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

109  {
110  int size = rawdata.size();
111  cout << "Print RawData size " << dec << size << endl;
112  unsigned char* pData = rawdata.data();
113 
114  int n = size/8;
115  for (int i=0; i < n; i++) {
116  for (int j=7; j>=0; j--) {
117  if (8*i+j <= size) cout << hex << (int)pData[8*i+j] << " ";
118  }
119  cout << endl;
120  }
121 }
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 202 of file BlockFormatter.cc.

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

202  {
203 
204 
205  for (int id=0; id < 36 + 18; id++) {
206 
207  // if ( (! doBarrel_) && (id >= 9 && id <= 44)) continue;
208  // if ( (! doEndCap_) && (id <= 8 || id >= 45)) continue;
209 
210 
211  int FEDid = FEDNumbering::MINECALFEDID + id;
212  FEDRawData& rawdata = productRawData -> FEDData(FEDid);
213  if (rawdata.size() > 0)
214  cout << "Size of FED id " << dec << FEDid << " is : " << dec << rawdata.size() << endl;
215 
216  }
217 }
size_t size() const
Lenght of the data buffer in bytes.
Definition: FEDRawData.h:47
void BlockFormatter::SetParam ( EcalDigiToRaw base)

Definition at line 21 of file BlockFormatter.cc.

21  {
22 
23  pcounter_ = (base -> GetCounter());
24  debug_ = base -> GetDebug();
25  porbit_number_ = (base -> GetOrbit());
26  plv1_ = (base -> GetLV1());
27  pbx_ = (base -> GetBX());
28  prunnumber_ = (base -> GetRunNumber());
29  doBarrel_ = base -> GetDoBarrel();
30  doEndCap_ = base -> GetDoEndCap();
31  plistDCCId_ = base -> GetListDCCId();
32  doTCC_ = base -> GetDoTCC();
33  doSR_ = base -> GetDoSR();
34  doTower_ = base -> GetDoTower();
35 
36 }
std::vector< int32_t > * plistDCCId_

Member Data Documentation

bool BlockFormatter::debug_
protected

Definition at line 35 of file BlockFormatter.h.

bool BlockFormatter::doBarrel_
protected

Definition at line 37 of file BlockFormatter.h.

bool BlockFormatter::doEndCap_
protected

Definition at line 38 of file BlockFormatter.h.

bool BlockFormatter::doSR_
protected

Definition at line 40 of file BlockFormatter.h.

bool BlockFormatter::doTCC_
protected

Definition at line 39 of file BlockFormatter.h.

bool BlockFormatter::doTower_
protected

Definition at line 41 of file BlockFormatter.h.

const int BlockFormatter::kCardsPerTower = 5
static

Definition at line 26 of file BlockFormatter.h.

int* BlockFormatter::pbx_
protected

Definition at line 47 of file BlockFormatter.h.

int* BlockFormatter::pcounter_
protected

Definition at line 45 of file BlockFormatter.h.

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

Definition at line 43 of file BlockFormatter.h.

int* BlockFormatter::plv1_
protected

Definition at line 48 of file BlockFormatter.h.

int* BlockFormatter::porbit_number_
protected

Definition at line 46 of file BlockFormatter.h.

int* BlockFormatter::prunnumber_
protected

Definition at line 49 of file BlockFormatter.h.