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() ) {
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);
186 struct ltstrip :
public binary_function<ESDataFormatterV4::Word64&, ESDataFormatterV4::Word64&,bool> {
195 return (val1 < val2);
203 int ts[3] = {0, 0, 0};
206 int numberOfStrips = 0 ;
208 int optorx_ch_counts[3][12];
210 int kchip, pace, optorx, fiber ;
211 map<int, vector<Word64> > map_data;
212 vector<Word64> words;
214 vector<Word32> testVector ;
216 set<pair<int,int>,
ltfiber> set_of_kchip_fiber_in_optorx[3];
222 for(
int j=0;
j<12;++
j)
223 optorx_ch_counts[
i][
j] = 0 ;
228 cout <<
"ESDataFormatterV4::DigiToRaw : FEDID : " << fedId <<
" size of detDigis : "
229 << detDigis.size() << endl ;
232 for (DetDigis::const_iterator it = detDigis.begin(); it != detDigis.end(); ++it) {
237 for (
int is=0; is<dataframe.
size(); ++is) ts[is] = dataframe.
sample(is).
adc();
243 <<
" "<<detId.
strip()<<
" ("<<kchip<<
","<<pace<<
") "<<ts[0]<<
" "<<ts[1]<<
" "<<ts[2]<<endl;
246 int siz = detId.
zside();
247 int sip = detId.
plane();
248 int six = detId.
six();
249 int siy = detId.
siy();
250 int sistrip = detId.
strip();
251 if (siz == 1 && sip == 1 && siy <= 20) sistrip = 33 - sistrip;
252 if (siz == 1 && sip == 2 && six > 20) sistrip = 33 - sistrip;
253 if (siz == -1 && sip == 1 && siy > 20) sistrip = 33 - sistrip;
254 if (siz == -1 && sip == 2 && six <= 20) sistrip = 33 - sistrip;
260 map_data[kchip].push_back(word);
265 optorx_ch_counts[optorx-1][fiber-1]++;
267 set<pair<int,int>,
ltfiber> & theSet = set_of_kchip_fiber_in_optorx[optorx-1];
268 theSet.insert(pair<int,int>(kchip,fiber));
274 for(
int iopto=0; iopto<3; ++iopto) {
282 words.push_back(word);
284 set<pair<int,int>,
ltfiber> & theSet = set_of_kchip_fiber_in_optorx[iopto];
287 cout <<
"ESDataFormatterV4::DigiToRaw : FEDID : " << fedId <<
" size of set_of_kchip_fiber_in_optorx["
289 << theSet.size() << endl ;
292 set<pair<int,int>,
ltfiber>::const_iterator kit = theSet.begin();
296 while (kit != theSet.end()) {
298 const pair<int,int>& kchip_fiber = (*kit);
300 if (
debug_)
cout<<
"KCHIP : "<<kchip_fiber.first <<
" FIBER: " << kchip_fiber.second << endl;
305 word1 = (0 <<
sKFLAG1) | (0xf <<
sKFLAG2) | (((kchip_fiber.first<<2) | 0x02) <<
sKID);
311 words.push_back(word);
313 vector<Word64> &
data = map_data[kchip_fiber.first];
318 for (
unsigned int id=0;
id<data.size(); ++id) {
320 words.push_back(data[
id]);
330 int dataSize = (words.size() + 8) *
sizeof(
Word64);
332 vector<Word64> DCCwords;
335 word1 = (numberOfStrips <<
sDEL) | (0xff <<
sDERR) ;
337 DCCwords.push_back(word);
342 DCCwords.push_back(word);
347 DCCwords.push_back(word);
349 for(
int iopto=0; iopto < 3; ++iopto ) {
355 for(ich=0;ich<4;++ich) {
356 int chStatus = (optorx_ch_counts[iopto][ich+8]>0) ? 0xe : 0xd ;
358 word2 |= (chStatus << (ich*4));
361 for(ich=0;ich<8;++ich) {
362 int chStatus = (optorx_ch_counts[iopto][ich]>0) ? 0xe : 0xd ;
364 word1 |= (chStatus << (ich*4));
370 DCCwords.push_back(word);
376 fedRawData.
resize(dataSize);
385 for (
unsigned int i=0;
i<DCCwords.size(); ++
i) {
392 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, int evt_lgth, int crc, int evt_stat, int tts, bool T=false)
Set all fields in the trailer.
void resize(size_t newsize)
unsigned short compute_crc(unsigned char *buffer, unsigned int bufSize)
bool operator()(const ESDataFormatterV4::Word64 &s1, const ESDataFormatterV4::Word64 &s2)
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.
int adc() const
get the ADC sample (singed 16 bits)
std::string fullPath() const