CMS 3D CMS Logo

BlockFormatter.cc
Go to the documentation of this file.
1 #include <memory>
2 
3 // user include files
4 
8 
9 using namespace std;
10 
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_} {}
24 
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 }
88 
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 }
103 
104 void BlockFormatter::CleanUp(FEDRawDataCollection* productRawData, map<int, map<int, int> >* FEDorder) {
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 }
181 
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 }
FEDNumbering.h
EcalElectronicsId.h
FEDNumbering::MINECALFEDID
Definition: FEDNumbering.h:43
BlockFormatter::Word64
uint64_t Word64
Definition: BlockFormatter.h:15
mps_fire.i
i
Definition: mps_fire.py:428
BlockFormatter::PrintSizes
void PrintSizes(FEDRawDataCollection *productRawData)
Definition: BlockFormatter.cc:182
dqmiodumpmetadata.n
n
Definition: dqmiodumpmetadata.py:28
FEDRawDataCollection
Definition: FEDRawDataCollection.h:18
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
BlockFormatter::Params
Definition: BlockFormatter.h:28
spr::find
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
BlockFormatter::print
void print(FEDRawData &rawdata)
Definition: BlockFormatter.cc:89
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
BlockFormatter::Config::plistDCCId_
const std::vector< int32_t > * plistDCCId_
Definition: BlockFormatter.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
BlockFormatter::bx_
int bx_
Definition: BlockFormatter.h:49
BlockFormatter::BlockFormatter
BlockFormatter(Config const &iC, Params const &iP)
Definition: BlockFormatter.cc:11
BlockFormatter::doBarrel_
const bool doBarrel_
Definition: BlockFormatter.h:55
BlockFormatter::debug_
const bool debug_
Definition: BlockFormatter.h:53
BlockFormatter::DigiToRaw
void DigiToRaw(FEDRawDataCollection *productRawData)
Definition: BlockFormatter.cc:25
FEDRawDataCollection::FEDData
const FEDRawData & FEDData(int fedid) const
retrieve data for fed
Definition: FEDRawDataCollection.cc:19
BlockFormatter::doEndCap_
const bool doEndCap_
Definition: BlockFormatter.h:56
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
BlockFormatter::CleanUp
void CleanUp(FEDRawDataCollection *productRawData, std::map< int, std::map< int, int > > *FEDorder)
Definition: BlockFormatter.cc:104
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
std
Definition: JetResolutionObject.h:76
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
BlockFormatter.h
genParticles_cff.map
map
Definition: genParticles_cff.py:11
Config
Definition: Config.py:1
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
findQualityFiles.size
size
Write out results.
Definition: findQualityFiles.py:443