EconSim.hh 15.3 KB
Newer Older
dauncey's avatar
dauncey committed
1 2 3 4 5 6 7
#ifndef EconSim_HH
#define EconSim_HH

#include <iostream>
#include <iomanip>
#include <cassert>

dauncey's avatar
dauncey committed
8 9
#include "Buffering/CircularBuffer.hh"
#include "Buffering/CircularBufferUR.hh"
dauncey's avatar
dauncey committed
10
#include "Buffering/HgcrocBoe.hh"
dauncey's avatar
dauncey committed
11 12
#include "Buffering/EconArch.hh"
#include "Buffering/EconFile.hh"
dauncey's avatar
dauncey committed
13 14 15

class EconSim {
  friend class EconAna;
dauncey's avatar
dauncey committed
16

dauncey's avatar
dauncey committed
17
public:
dauncey's avatar
dauncey committed
18 19 20 21 22 23 24 25 26 27 28
  enum {
    NumberOfParallelBuffers=2
  };
  
  enum DataRandomMethod {
    NotRandom,
    Binomial,
    Flat,
    Mixed
  };

dauncey's avatar
dauncey committed
29
  enum DataFormatMethod {
dauncey's avatar
dauncey committed
30
    FixedChannelBitmap,
dauncey's avatar
dauncey committed
31 32 33 34 35 36 37 38 39 40 41
    FixedChannelLabels,
    FixedMixture,
    VariableMixture
  };

  enum DataFlowMethod {
    FixedHgcrocMap,
    VariableHgcrocMap,
    EventBuild
  };

dauncey's avatar
dauncey committed
42 43 44 45 46 47
  //EconSim(unsigned e, unsigned h=18, unsigned m=0) : fEcon(e) {
  EconSim() {
    fSlink=0;

    if(fPrintLevel>0) {	
      std::cout << "EconSim::ctor() "
dauncey's avatar
dauncey committed
48 49 50 51
		<< "Entered" << std::endl;
    }

    setFormatBreakEven();
dauncey's avatar
dauncey committed
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66
    fActiveInputBuffer=0;    
    fWriteElink=0;

    for(unsigned b(0);b<NumberOfParallelBuffers;b++) {
      for(unsigned block(0);block<20;block++) {
	fReadHgcrocNumber[b][block]=EconFile::MaxNumberOfHgcrocs;
	fReadWord[b][block]=0xffffffff;

	if(fPrintLevel>2) {
	  std::cout << "EconSim::ctor() "
		    << "First buffer " << b << ", block " << block
		    << ", zeroing HGCROC number " << fReadHgcrocNumber[b][block]
		    << ", word number " << fReadWord[b][block] << std::endl;
	}
      }
dauncey's avatar
dauncey committed
67
      
dauncey's avatar
dauncey committed
68 69 70 71 72 73 74 75 76 77 78
      for(unsigned h(0);h<EconFile::MaxNumberOfHgcrocs;h++) {
	fFirstBuffer[b][h].resize(channelsToWords(72,false));
      }
    }
  }

  void boj(unsigned s, unsigned e, const EconFile &f, const EconArch &a) {
    fSlink=s;
    fEcon=e;
    fEconFile=&f;
    fEconArch=&a;
dauncey's avatar
dauncey committed
79

dauncey's avatar
dauncey committed
80
    fNewestL1Accept=0;
dauncey's avatar
dauncey committed
81 82
    for(unsigned block(0);block<fEconArch->fNumberOfBlocks;block++) {
      fEventBuffer[block].reset(16*4096);
dauncey's avatar
dauncey committed
83
      fOldestL1Accept[block]=0;
dauncey's avatar
dauncey committed
84
    }
dauncey's avatar
dauncey committed
85
    
dauncey's avatar
dauncey committed
86
  }
dauncey's avatar
dauncey committed
87
  
dauncey's avatar
dauncey committed
88 89 90 91 92 93 94 95 96 97 98 99 100 101
  void slinkNumber(unsigned s) {
    fSlink=s;
  }
  
  void econNumber(unsigned e) {
    fEcon=e;
  }
  
  void econFile(const EconFile *e) {
    fEconFile=e;
  }
  
  const EconFile& econFile() const {
    return *fEconFile;
dauncey's avatar
dauncey committed
102 103 104 105
  }
  
  double mean(unsigned h) {
    assert(h<18);
dauncey's avatar
dauncey committed
106
    return fEconFile->fHgcrocMean[h];
dauncey's avatar
dauncey committed
107
  }
dauncey's avatar
dauncey committed
108
  
dauncey's avatar
dauncey committed
109
  void processZs(uint64_t bx, uint64_t l1a) {
dauncey's avatar
dauncey committed
110
    if(fPrintLevel>3) {
dauncey's avatar
dauncey committed
111 112
      std::cout << "EconSim[" << fSlink << "][" << fEcon << "]::processZs(" << bx
		<< "," << l1a << ") "
dauncey's avatar
dauncey committed
113 114 115
		<< "Entered" << std::endl;
    }
    
dauncey's avatar
dauncey committed
116 117 118 119 120 121 122
    fNewestL1Accept=l1a;    

    if(fPrintLevel>5) {
      std::cout << "Incrementing newest L1Accept to " << fNewestL1Accept
		<< std::endl;
    }
    
dauncey's avatar
dauncey committed
123
    TRandom &random(Random::random());
dauncey's avatar
dauncey committed
124 125 126
    bool binomialOrFlat;
  
    for(unsigned h(0);h<fEconFile->fNumberOfHgcrocs;h++) {
dauncey's avatar
dauncey committed
127

dauncey's avatar
dauncey committed
128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155
      // Switch for different random methods
    
      if(fDataRandomMethod==NotRandom) {
	fNumberOfChannels[h]=unsigned(fEconFile->fHgcrocMean[h]+0.5);

      } else if(fDataRandomMethod==Binomial) {
	fNumberOfChannels[h]=random.Binomial(72,fEconFile->fHgcrocMean[h]/72.0);

      } else if(fDataRandomMethod==Flat) {
	int im(fEconFile->fHgcrocMean[h]+0.5);
	if(im>36) {
	  fNumberOfChannels[h]=2*im-72+random.Integer(145-2*im);
	} else {
	  fNumberOfChannels[h]=random.Integer(2*im+1);
	}

      } else if(fDataRandomMethod==Mixed) {
	binomialOrFlat=(random.Integer(2)==0);
	if(binomialOrFlat) {
	  fNumberOfChannels[h]=random.Binomial(72,fEconFile->fHgcrocMean[h]/72.0);
	} else {
	  int im(fEconFile->fHgcrocMean[h]+0.5);
	  if(im>36) {
	    fNumberOfChannels[h]=2*im-72+random.Integer(145-2*im);
	  } else {
	    fNumberOfChannels[h]=random.Integer(2*im+1);
	  }
	}
dauncey's avatar
dauncey committed
156
      
dauncey's avatar
dauncey committed
157 158 159 160 161 162 163
      } else {
	assert(false);
      }

      // Switch for different format methods
      
      if(fDataFormatMethod==FixedChannelBitmap) {
dauncey's avatar
dauncey committed
164 165 166 167 168 169
	fNumberOfWords[h]=channelsToWords(fNumberOfChannels[h],true);

      } else if(fDataFormatMethod==FixedChannelLabels) {
	fNumberOfWords[h]=channelsToWords(fNumberOfChannels[h],false);

      } else if(fDataFormatMethod==FixedMixture) {
dauncey's avatar
dauncey committed
170
	fNumberOfWords[h]=channelsToWords(fNumberOfChannels[h],fEconFile->fHgcrocMean[h]>fFormatBreakEven);
dauncey's avatar
dauncey committed
171 172 173 174 175 176 177 178 179
	
      } else if(fDataFormatMethod==VariableMixture) {
	fNumberOfWords[h]=channelsToWords(fNumberOfChannels[h],fNumberOfChannels[h]>fFormatBreakEven);

      } else {
	assert(false);
      }

      if(fPrintLevel>4) {
dauncey's avatar
dauncey committed
180 181
	std::cout << "EconSim[" << fSlink << "][" << fEcon << "]::processZs(" << bx
		  << "," << l1a << ") "
dauncey's avatar
dauncey committed
182 183 184 185 186
		  << "Hgcroc " << h << ", number of channels = "
		  << fNumberOfChannels[h] << ", words = "
		  << fNumberOfWords[h] << std::endl;
      }
      
dauncey's avatar
dauncey committed
187
      // Create HGCROC header
dauncey's avatar
dauncey committed
188

dauncey's avatar
dauncey committed
189
      HgcrocBoe hboe(fEcon,h,bx&0xff,l1a&0xff,fNumberOfWords[h]);
dauncey's avatar
dauncey committed
190 191

      if(fPrintLevel>4) {
dauncey's avatar
dauncey committed
192 193
	std::cout << "EconSim[" << fSlink << "][" << fEcon << "]::processZs(" << bx
		  << "," << l1a << ") "
dauncey's avatar
dauncey committed
194
		  << "Hgcroc " << h << " BOE" << std::endl;
dauncey's avatar
dauncey committed
195 196 197
	hboe.print();
      }
    
dauncey's avatar
dauncey committed
198 199
      // Write data into selected buffer

dauncey's avatar
dauncey committed
200
      assert(fActiveInputBuffer==l1a);
dauncey's avatar
dauncey committed
201 202 203
      fFirstBuffer[fActiveInputBuffer%NumberOfParallelBuffers][h].resize(fNumberOfWords[h]);
      fFirstBuffer[fActiveInputBuffer%NumberOfParallelBuffers][h][0]=hboe.word();

dauncey's avatar
dauncey committed
204
      for(unsigned i(1);i<fNumberOfWords[h];i++) {
dauncey's avatar
dauncey committed
205
	fFirstBuffer[fActiveInputBuffer%NumberOfParallelBuffers][h][i]=((l1a&0xff)<<24)+i;
dauncey's avatar
dauncey committed
206 207
      }
    }
dauncey's avatar
dauncey committed
208 209
    
    // Set counters to zero for this buffer
dauncey's avatar
dauncey committed
210

dauncey's avatar
dauncey committed
211 212 213 214
    for(unsigned block(0);block<fEconArch->fNumberOfBlocks;block++) {
      fReadHgcrocNumber[fActiveInputBuffer%NumberOfParallelBuffers][block]=0;
      fReadWord[fActiveInputBuffer%NumberOfParallelBuffers][block]=0;
    }
dauncey's avatar
dauncey committed
215
    
dauncey's avatar
dauncey committed
216
    fActiveInputBuffer++;
dauncey's avatar
dauncey committed
217 218
  }

dauncey's avatar
dauncey committed
219

dauncey's avatar
dauncey committed
220 221
  void processBx(uint32_t *a) {

dauncey's avatar
dauncey committed
222 223
    fExceededBuffer=false;

dauncey's avatar
dauncey committed
224 225
    // Switch for different dataflow methods

dauncey's avatar
dauncey committed
226 227
    if(fDataFlowMethod==FixedHgcrocMap) {

dauncey's avatar
dauncey committed
228 229
      //  4 words per BX for 7 eLinks
      unsigned nWords(4);
dauncey's avatar
dauncey committed
230 231
      
      if(fPrintLevel>3) {
dauncey's avatar
dauncey committed
232 233 234
	std::cout << "EconSim[" << fSlink << "][" << fEcon << "]::processBx() "
		  << "Data flow method = fixed HGCROC map, reading "
		  << nWords << " words per BX"	<< std::endl;
dauncey's avatar
dauncey committed
235
      }
dauncey's avatar
dauncey committed
236
	    
dauncey's avatar
dauncey committed
237 238 239 240
      assert(false);

#ifdef NOT_YET
      
dauncey's avatar
dauncey committed
241 242
      for(unsigned b(0);b<NumberOfParallelBuffers;b++) {
	if(b!=(fActiveInputBuffer%NumberOfParallelBuffers)) {
dauncey's avatar
dauncey committed
243
	  
dauncey's avatar
dauncey committed
244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261
	  for(unsigned e(0);e<7;e++) {
	    if(fReadHgcroc[b]<fEconFile->fNumberOfHgcrocs) {
	      
	      for(unsigned w(0);w<nWords;w++) {
		assert(fReadHgcroc[b]<fEconFile->fNumberOfHgcrocs);
		assert(fReadWord[b]<fFirstBuffer[b][fReadHgcroc[b]].size());
		
		if(fPrintLevel>4) {
		  std::cout << "EconSim[" << fSlink << "][" << fEcon << "]::processBx() "
			    << "Copying BX word " << w << " from first buffer " << b
			    << ", HGCROC " << fReadHgcroc[b] << ", word " << fReadWord[b]
			    << " of " << fFirstBuffer[b][fReadHgcroc[b]].size() << " = "
			    << std::hex << fFirstBuffer[b][fReadHgcroc[b]][fReadWord[b]]
			    << std::dec << std::endl;
		}
		assert(fElink[fHgcrocToElink[h]].writeAndIncrementPtr(fFirstBuffer[b][fReadHgcrocNumber[b]][fReadWord[b]]));
	      }
	    }
dauncey's avatar
dauncey committed
262 263 264
	  }
	}
      }
dauncey's avatar
dauncey committed
265 266 267

      // Add zero padding word if odd
      //if((nWords%2)==1) assert(fElink[fHgcrocToElink[h]].writeAndIncrementPtr(0));
dauncey's avatar
dauncey committed
268 269 270
      
      uint64_t d;
      for(unsigned e(0);e<7;e++) {
dauncey's avatar
dauncey committed
271
	if(fElink[e].readAndIncrementPtr(d)) a[e]=(d&0xffffffff);
dauncey's avatar
dauncey committed
272 273 274
	else a[e]=0;

	if(fPrintLevel>4) {
dauncey's avatar
dauncey committed
275 276
	  std::cout << "EconSim[" << fSlink << "][" << fEcon << "]::processBx() "
		    << "Sending eLink " << e << " = "
dauncey's avatar
dauncey committed
277 278 279 280
		    << std::hex << a[e]
		    << std::dec << std::endl;
	}
      }
dauncey's avatar
dauncey committed
281 282

#endif
dauncey's avatar
dauncey committed
283
      
dauncey's avatar
dauncey committed
284 285 286 287 288 289 290 291 292 293
    } else if(fDataFlowMethod==VariableHgcrocMap) {

      unsigned nWords(0);
      
      if(fPrintLevel>3) {
	std::cout << "EconSim[" << fSlink << "][" << fEcon << "]::processBx() "
		  << "Data flow method = variable HGCROC map, reading "
		  << nWords << " words per BX"	<< std::endl;
      }
	    
dauncey's avatar
dauncey committed
294 295
      assert(false);

dauncey's avatar
dauncey committed
296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318
      
    } else if(fDataFlowMethod==EventBuild) {
      
      // 24 words per BX for 2 parallel buffers = 960 MHz
      // 12 words per BX for 3 parallel buffers = 480 MHz
      //  8 words per BX for 4 parallel buffers = 320 MHz
      //unsigned nWords(24/(NumberOfParallelBuffers-1));


      // For one block, must be > 55 words x 18 HGCROCs/44 BX = 22.5; also more than output = 7 words/BX
      //  OR
      // For one block, must be > 39 words x 18 HGCROCs/44 BX = 15.95; also more than output = 7 words/BX
      // For seven blocks, must be > 55 words x 3 HGCROCs/44 BX = 3.75; also more than output = 1 word/BX
      //  OR
      // For seven blocks, must be > 39 words x 3 HGCROCs/44 BX = 2.66; also more than output = 1 word/BX

      unsigned nWords(fEconArch->fNumberOfBlocks==1?24:4);
      //unsigned nWords(fEconArch->fNumberOfBlocks==1?16:3);
      
      if(fPrintLevel>3) {
	std::cout << "EconSim[" << fSlink << "][" << fEcon << "]::processBx() "
		  << "Data flow method = event build, reading "
		  << nWords << " words per BX"	<< std::endl;
dauncey's avatar
dauncey committed
319 320
      }
	    
dauncey's avatar
dauncey committed
321
      for(unsigned block(0);block<fEconArch->fNumberOfBlocks;block++) {
dauncey's avatar
dauncey committed
322

dauncey's avatar
dauncey committed
323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371
	for(unsigned b(0);b<NumberOfParallelBuffers;b++) {
	  if(b!=(fActiveInputBuffer%NumberOfParallelBuffers)) {

	    if(fPrintLevel>4) {
	      std::cout << "EconSim[" << fSlink << "][" << fEcon << "]::processBx() "
			<< "Reading HGCROC number " << fReadHgcrocNumber[b][block]
			<< " < " << fEconArch->fHgcrocNumber[block].size()
			<< ", word number " << fReadWord[b][block] << std::endl;
	    }
	    
	    //if(fReadHgcrocNumber[b]<fEconFile->fNumberOfHgcrocs) {
	    if(fReadHgcrocNumber[b][block]<fEconArch->fHgcrocNumber[block].size()) {

	      for(unsigned w(0);w<nWords;w++) {
		//assert(fReadHgcroc[b]<fEconFile->fNumberOfHgcrocs);
		
		unsigned readHgcroc(fEconArch->fHgcrocNumber[block][fReadHgcrocNumber[b][block]]);
		std::vector<uint32_t> &readBuffer(fFirstBuffer[b][readHgcroc]); // Convenient
		assert(fReadWord[b][block]<readBuffer.size());
	      
		if(fPrintLevel>4) {
		  std::cout << "EconSim[" << fSlink << "][" << fEcon << "]::processBx() "
			    << "Copying BX word " << w << " from block " << block << ", first buffer " << b
			    << ", HGCROC " << readHgcroc << ", word " << fReadWord[b][block]
			    << " of " << readBuffer.size() << " = "
			    << std::hex << readBuffer[fReadWord[b][block]]
			    << std::dec << std::endl;
		}

		// Write word to FIFO
		
		assert(fEventBuffer[block].writeAndIncrementPtr(readBuffer[fReadWord[b][block]]));
		
		// Check if completed all words of this HGCROC
		
		fReadWord[b][block]++;
		if(fReadWord[b][block]==readBuffer.size()) {
		  fReadWord[b][block]=0;
		  fReadHgcrocNumber[b][block]++;
		  
		  // Check if completed all HGCROCs
		  
		  if(fReadHgcrocNumber[b][block]==fEconArch->fHgcrocNumber[block].size()) w=nWords;
		}
	      }
	    }
	  }
	}

dauncey's avatar
dauncey committed
372 373 374 375
	if(fEventBuffer[block].used()>=255) fExceededBuffer=true;
	
	// Read out for elinks
	
dauncey's avatar
dauncey committed
376
	uint32_t d;
dauncey's avatar
dauncey committed
377
	for(unsigned e(0);e<fEconArch->fElinkNumber[block].size();e++) {
dauncey's avatar
dauncey committed
378
	  //if(fEventBuffer[block].readAndIncrementPtr(d)) a[fEconArch->fElinkNumber[block][e]]=(d&0xffffffff);
dauncey's avatar
dauncey committed
379 380 381 382 383 384 385 386 387 388 389 390 391 392
	  if(fEventBuffer[block].readAndIncrementPtr(d)) {
	    a[fEconArch->fElinkNumber[block][e]]=d;

	    HgcrocBoe tempBoe(d);
	    if(tempBoe.l1a()==((fOldestL1Accept[block]+1)&0xff)) {
	      fOldestL1Accept[block]++;
	      if(fPrintLevel>5) {
		std::cout << "Incrementing block " << block
			  << " oldest L1Accept to " << fOldestL1Accept[block]
			  << std::endl;
	      }
	    }
	    
	  } else a[fEconArch->fElinkNumber[block][e]]=0;
dauncey's avatar
dauncey committed
393 394 395 396 397 398 399 400 401 402 403 404 405 406
	}
      }

      if(fPrintLevel>4) {
	for(unsigned e(0);e<7;e++) {
	  std::cout << "EconSim[" << fSlink << "][" << fEcon << "]::processBx() "
		    << "Sending eLink " << e << " = "
		    << std::hex << a[e]
		    << std::dec << std::endl;
	}
      }
        
    } else {
      assert(false);
dauncey's avatar
dauncey committed
407 408 409
    }
  }

dauncey's avatar
dauncey committed
410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425
  bool exceededBuffer() const {
    if(fPrintLevel>5) {
      if(fExceededBuffer) {
	std::cout << "EconSim[" << fSlink << "][" << fEcon << "]::exceededBuffer() "
		  << "Buffer exceeded" << std::endl;
      }
    }
    
    return fExceededBuffer;
  }
    
  unsigned l1AcceptDifference(unsigned b) const {
    assert(b<fEconArch->fNumberOfBlocks);
    return fNewestL1Accept-fOldestL1Accept[b];
  }
    
dauncey's avatar
dauncey committed
426 427
  unsigned numberOfHgcrocs() const {
    return fEconFile->fNumberOfHgcrocs;
dauncey's avatar
dauncey committed
428
  }
dauncey's avatar
dauncey committed
429
  /*
dauncey's avatar
dauncey committed
430 431 432 433 434 435 436 437 438
  unsigned space(unsigned elink) {
    assert(elink<7);
    return fElink[elink].space();
  }

  unsigned used(unsigned elink) {
    assert(elink<7);
    return fElink[elink].used();
  }
dauncey's avatar
dauncey committed
439
  */
dauncey's avatar
dauncey committed
440 441 442 443 444 445 446 447 448
  unsigned numberOfChannels(unsigned h) const {
    assert(h<18);
    return fNumberOfChannels[h];
  }

  unsigned numberOfWords(unsigned h) const {
    assert(h<18);
    return fNumberOfWords[h];
  }
dauncey's avatar
dauncey committed
449
  /*
dauncey's avatar
dauncey committed
450 451 452 453 454
  void reset() {
    for(unsigned e(0);e<7;e++) {
      fElink[e].reset();
    }
  }
dauncey's avatar
dauncey committed
455
  */
dauncey's avatar
dauncey committed
456 457 458 459 460
  static unsigned channelsToWords(unsigned c, bool map) {
    if(map) return 3+(c+1)/2;
    else    return 1+3*(c+1)/4;
  }
  /*
dauncey's avatar
dauncey committed
461 462 463
    unsigned channelsToWords(unsigned c, double m) const {
    if(fDataFormatMethod==FixedChannelBitmap) {
    return channelsToWords(c,true);
dauncey's avatar
dauncey committed
464 465
      
    } else if(fDataFormatMethod==FixedChannelLabels) {
dauncey's avatar
dauncey committed
466
    return channelsToWords(c,false);
dauncey's avatar
dauncey committed
467 468
      
    } else if(fDataFormatMethod==FixedMixture) {
dauncey's avatar
dauncey committed
469
    return channelsToWords(c,m>fFormatBreakEven);
dauncey's avatar
dauncey committed
470 471
      
    } else if(fDataFormatMethod==VariableMixture) {
dauncey's avatar
dauncey committed
472
    return channelsToWords(c,c>fFormatBreakEven);
dauncey's avatar
dauncey committed
473 474
      
    } else {
dauncey's avatar
dauncey committed
475
    assert(false);
dauncey's avatar
dauncey committed
476 477
    }
    return -1;
dauncey's avatar
dauncey committed
478
    }
dauncey's avatar
dauncey committed
479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504
  */
  
  static void setFormatBreakEven() {
    if(fFormatBreakEven==0) {    
      if(fPrintLevel>1) {
	std::cout << "EconSim::setFormatBreakEven() " 
		  << "Entered" << std::endl;
      }
      
      unsigned wMap,wLabel;
      for(unsigned c(0);c<72;c++) {
	wMap=channelsToWords(c,true);
	wLabel=channelsToWords(c,false);

	if(fPrintLevel>1) {
	  std::cout << "EconSim::setFormatBreakEven() " 
		    << "Channels = " << c << ", map words = "
		    << wMap << ", label words = " << wLabel
		    << std::endl;
	}

	if(wLabel<=wMap) fFormatBreakEven=c;
	else break;
      }

      if(fPrintLevel>0) {
dauncey's avatar
dauncey committed
505
	std::cout << "EconSim::setFormatBreakEven() "
dauncey's avatar
dauncey committed
506 507 508 509 510 511 512 513 514
		  << "Break-even channel number = " << fFormatBreakEven
		  << std::endl;
      }
    }
  }

  unsigned econNumber() const {
    return fEcon;
  }
dauncey's avatar
dauncey committed
515 516 517 518

  unsigned econSlink() const {
    return fSlink;
  }
dauncey's avatar
dauncey committed
519
  
dauncey's avatar
dauncey committed
520 521 522 523
  const EconArch& econArch() const {
    return *fEconArch;
  }

dauncey's avatar
dauncey committed
524 525
public:
  static unsigned fPrintLevel;
dauncey's avatar
dauncey committed
526 527

  static DataRandomMethod fDataRandomMethod;
dauncey's avatar
dauncey committed
528 529 530
  static DataFormatMethod fDataFormatMethod;
  static DataFlowMethod fDataFlowMethod;
  static unsigned fFormatBreakEven;
dauncey's avatar
dauncey committed
531
  
dauncey's avatar
dauncey committed
532 533
protected:
private:
dauncey's avatar
dauncey committed
534 535 536 537 538
  unsigned fSlink;
  unsigned fEcon;
  const EconFile *fEconFile;
  const EconArch *fEconArch;

dauncey's avatar
dauncey committed
539 540 541 542 543
  bool fExceededBuffer;

  uint64_t fNewestL1Accept;
  uint64_t fOldestL1Accept[Dimensions::MaxNumberOfBlocksPerEcon];
  
dauncey's avatar
dauncey committed
544 545 546
  //unsigned fNumberOfHgcrocs;
  //double fHgcrocMean[18];
  
dauncey's avatar
dauncey committed
547
  //unsigned fHgcrocToElink[18];
dauncey's avatar
dauncey committed
548 549 550 551
  //CircularBufferUR<1> fElink[7];

  //CircularBufferUR<16> fEventBuffer[7];
CircularBuffer32 fEventBuffer[7];
dauncey's avatar
dauncey committed
552 553 554 555

  unsigned fNumberOfChannels[18];
  unsigned fNumberOfWords[18];

dauncey's avatar
dauncey committed
556 557 558 559
  //unsigned fReadHgcroc[NumberOfParallelBuffers];
  //unsigned fReadWord[NumberOfParallelBuffers];
  unsigned fReadHgcrocNumber[NumberOfParallelBuffers][20];
  unsigned fReadWord[NumberOfParallelBuffers][20];
dauncey's avatar
dauncey committed
560
  unsigned fWriteElink;
dauncey's avatar
dauncey committed
561 562 563 564

  //unsigned fNumberOfBlocks;
  std::vector<unsigned> fHgcrocNumber[7];
  std::vector<unsigned> fElinkNumber[7];
dauncey's avatar
dauncey committed
565
  
dauncey's avatar
dauncey committed
566 567
  unsigned fActiveInputBuffer;
  std::vector<uint32_t> fFirstBuffer[NumberOfParallelBuffers][18];
dauncey's avatar
dauncey committed
568 569 570 571
};

unsigned EconSim::fPrintLevel(1);

dauncey's avatar
dauncey committed
572 573 574
EconSim::DataRandomMethod EconSim::fDataRandomMethod(EconSim::Binomial);
EconSim::DataFormatMethod EconSim::fDataFormatMethod(EconSim::FixedChannelBitmap);
EconSim::DataFlowMethod EconSim::fDataFlowMethod(EconSim::FixedHgcrocMap);unsigned EconSim::fFormatBreakEven(0);
dauncey's avatar
dauncey committed
575 576

#endif