106 for (
int i=0;
i<2; ++
i)
107 for (
int j=0; j<2; ++j)
108 for (
int k=0 ;
k<40; ++
k)
109 for (
int m=0;
m<40;
m++) {
118 for(
int i=0;
i<56;++
i) {
122 for(
int i=0;
i<56;++
i) {
124 for(
int k=0;
k<12;
k++)
129 int nLines, iz, ip, ix, iy, fed, kchip, pace, bundle, fiber, optorx;
132 if( file.is_open() ) {
136 for (
int i=0;
i<nLines; ++
i) {
138 file >> iz >> ip >> ix >> iy >> fed >> kchip >> pace >> bundle >> fiber >> optorx;
140 fedId =
fedId_[(3-iz)/2-1][ip-1][ix-1][iy-1] = fed;
141 kchipId_[(3-iz)/2-1][ip-1][ix-1][iy-1] = kchip;
142 paceId_[(3-iz)/2-1][ip-1][ix-1][iy-1] = pace - 1;
143 bundleId_[(3-iz)/2-1][ip-1][ix-1][iy-1] = bundle;
144 fiberId_[(3-iz)/2-1][ip-1][ix-1][iy-1] = fiber;
145 optoId_[(3-iz)/2-1][ip-1][ix-1][iy-1] = optorx;
148 if (
debug_)
cout <<
"ESDataFormatterV4::ESDataFormatterV4 : fedId value : " << fedId
149 <<
" out of ES range, at lookup table line : " <<
i << endl;
150 }
else if (optorx < 1 || optorx > 3) {
151 if (
debug_)
cout <<
"ESDataFormatterV4::ESDataFormatterV4 : optorx value : " << optorx
152 <<
" out of ES range, at lookup table line : " <<
i << endl;
156 if (fiber>0 && fiber<13) {
159 if (
debug_)
cout <<
"ESDataFormatterV4::ESDataFormatterV4 : fiber value : " << fiber
160 <<
" out of ES range, at lookup table line : " <<
i << endl;
167 if (
debug_)
cout<<
"ESDataFormatterV4::ESDataFormatterV4 : Look up table file can not be found in "<<
lookup_.
fullPath().c_str()<<endl;
181 return (s1.second < s2.second);
194 return (val1 < val2);
201 int ts[3] = {0, 0, 0};
206 int optorx_ch_counts[3][12];
208 int kchip, pace, optorx, fiber ;
209 map<int, vector<Word64> > map_data;
210 vector<Word64> words;
212 vector<Word32> testVector ;
214 set<pair<int,int>,
ltfiber> set_of_kchip_fiber_in_optorx[3];
220 for(
int j=0;j<12;++j)
221 optorx_ch_counts[
i][j] = 0 ;
226 cout <<
"ESDataFormatterV4::DigiToRaw : FEDID : " << fedId <<
" size of detDigis : " 227 << detDigis.size() << endl ;
230 for (DetDigis::const_iterator it = detDigis.begin(); it != detDigis.end(); ++it) {
235 for (
int is=0; is<dataframe.
size(); ++is) ts[is] = dataframe.
sample(is).
adc();
241 <<
" "<<detId.
strip()<<
" ("<<kchip<<
","<<pace<<
") "<<ts[0]<<
" "<<ts[1]<<
" "<<ts[2]<<endl;
244 int siz = detId.
zside();
245 int sip = detId.
plane();
246 int six = detId.
six();
247 int siy = detId.
siy();
249 if (siz == 1 && sip == 1 && siy <= 20) sistrip = 33 - sistrip;
250 if (siz == 1 && sip == 2 && six > 20) sistrip = 33 - sistrip;
251 if (siz == -1 && sip == 1 && siy > 20) sistrip = 33 - sistrip;
252 if (siz == -1 && sip == 2 && six <= 20) sistrip = 33 - sistrip;
258 map_data[kchip].push_back(word);
263 optorx_ch_counts[optorx-1][fiber-1]++;
265 set<pair<int,int>,
ltfiber> & theSet = set_of_kchip_fiber_in_optorx[optorx-1];
266 theSet.insert(pair<int,int>(kchip,fiber));
272 for(
int iopto=0; iopto<3; ++iopto) {
280 words.push_back(word);
282 set<pair<int,int>,
ltfiber> & theSet = set_of_kchip_fiber_in_optorx[iopto];
285 cout <<
"ESDataFormatterV4::DigiToRaw : FEDID : " << fedId <<
" size of set_of_kchip_fiber_in_optorx[" 287 << theSet.size() << endl ;
290 set<pair<int,int>,
ltfiber>::const_iterator kit = theSet.begin();
294 while (kit != theSet.end()) {
296 const pair<int,int>& kchip_fiber = (*kit);
298 if (
debug_)
cout<<
"KCHIP : "<<kchip_fiber.first <<
" FIBER: " << kchip_fiber.second << endl;
303 word1 = (0 <<
sKFLAG1) | (0xf <<
sKFLAG2) | (((kchip_fiber.first<<2) | 0x02) <<
sKID);
309 words.push_back(word);
311 vector<Word64> &
data = map_data[kchip_fiber.first];
316 for (
unsigned int id=0;
id<data.size(); ++
id) {
318 words.push_back(data[
id]);
328 int dataSize = (words.size() + 8) *
sizeof(
Word64);
330 vector<Word64> DCCwords;
333 word1 = (numberOfStrips <<
sDEL) | (0xff <<
sDERR) ;
335 DCCwords.push_back(word);
340 DCCwords.push_back(word);
345 DCCwords.push_back(word);
347 for(
int iopto=0; iopto < 3; ++iopto ) {
353 for(ich=0;ich<4;++ich) {
354 int chStatus = (optorx_ch_counts[iopto][ich+8]>0) ? 0xe : 0xd ;
356 word2 |= (chStatus << (ich*4));
359 for(ich=0;ich<8;++ich) {
360 int chStatus = (optorx_ch_counts[iopto][ich]>0) ? 0xe : 0xd ;
362 word1 |= (chStatus << (ich*4));
368 DCCwords.push_back(word);
374 fedRawData.
resize(dataSize);
383 for (
unsigned int i=0;
i<DCCwords.size(); ++
i) {
390 for (
unsigned int i=0;
i<words.size(); ++
i) {
T getUntrackedParameter(std::string const &, T const &) const
const ESDetId & id() const
static void set(unsigned char *trailer, uint32_t lenght, uint16_t crc, uint8_t evt_stat, uint8_t tts, bool moreTrailers=false)
Set all fields in the trailer.
void resize(size_t newsize)
unsigned short compute_crc(unsigned char *buffer, unsigned int bufSize)
const ESSample & sample(int i) const
bool operator()(const pair< int, int > s1, const pair< int, int > s2) const
char data[epos_bytes_allocation]
const unsigned char * data() const
Return a const pointer to the beginning of the data buffer.
std::string fullPath() const
int adc() const
get the ADC sample (singed 16 bits)