BeSlinkAna.hh 4.23 KB
Newer Older
dauncey's avatar
dauncey committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
#ifndef BeSlinkAna_HH
#define BeSlinkAna_HH

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

#include "TH1D.h"
#include "TH2D.h"
#include "TH1I.h"

#include "Buffering/BeSlinkSim.hh"


class BeSlinkAna {
public:
  BeSlinkAna() {
  }

  void boj(const BeSlinkSim &b, unsigned nHistory=100000) {
    fBeSlinkSim=&b;
    
    std::ostringstream sout;
    sout << "BeSlinkAna" << std::setw(2) << std::setfill('0')
dauncey's avatar
dauncey committed
25
	 << fBeSlinkSim->slinkNumber();
dauncey's avatar
dauncey committed
26 27 28
    
    std::string sHgcroc[18]={"00","01","02","03","04","05","06","07","08",
			     "09","10","11","12","13","14","15","16","17"};
dauncey's avatar
dauncey committed
29
    /*
dauncey's avatar
dauncey committed
30 31 32 33 34 35 36 37 38
    hBitmapWordsVsChannels=new TH1I((sout.str()+"BitmapWordsVsChannels").c_str(),
				";Number of channels per HGCROC packet;Number of words per HGCROC packet",73,-0.5,72.5);
    hLabelsWordsVsChannels=new TH1I((sout.str()+"LabelsWordsVsChannels").c_str(),
				   ";Number of channels per HGCROC packet;Number of words per HGCROC packet",73,-0.5,72.5);
    
    hTotalChannels=new TH1D((sout.str()+"TotalChannels").c_str(),
			      ";ECON total number of channels",1300,0,1300);
    hTotalWords=new TH1D((sout.str()+"TotalWords").c_str(),
			      ";ECON total number of words",1000,0,1000);
dauncey's avatar
dauncey committed
39
    */
dauncey's avatar
dauncey committed
40
    
dauncey's avatar
dauncey committed
41 42 43 44 45 46 47 48 49 50 51
    const SlinkArch &slinkArch(*(fBeSlinkSim->fSlinkArch));
    for(unsigned e(0);e<slinkArch.numberOfEcons();e++) {
      const EconArch &econArch(slinkArch.econArch(e));
      for(unsigned b(0);b<econArch.numberOfBlocks();b++) {
	hEventBufferUsed[e][b]=new TH1D((sout.str()+"Econ"+sHgcroc[e]+"Block"+sHgcroc[b]+"EventBufferUsed").c_str(),
					";Number of event buffer words used",1000,0,10000);
	hEventBufferUsedHistory[e][b]=new TH1I((sout.str()+"Econ"+sHgcroc[e]+"Block"+sHgcroc[b]+"EventBufferUsedHistory").c_str(),
					       ";BX;Number of event buffer words used",nHistory,0,nHistory);
      }
    }
    /*    
dauncey's avatar
dauncey committed
52 53 54 55 56 57 58 59
    for(unsigned h(0);h<18;h++) {
      hChannels[h]=new TH1D((sout.str()+"Hgcroc"+sHgcroc[h]+"Channels").c_str(),
			    ";Number of channels per HGCROC packet",73,0,73);
      hWords[h]=new TH1D((sout.str()+"Hgcroc"+sHgcroc[h]+"Words").c_str(),
			 ";Number of words per HGCROC packet",60,0,60);
      hWordsVsChannels[h]=new TH2D((sout.str()+"Hgcroc"+sHgcroc[h]+"WordsVsChannels").c_str(),
				   ";Number of channels per HGCROC packet;Number of words per HGCROC packet",73,-0.5,72.5,60,-0.5,59.5);
    }
dauncey's avatar
dauncey committed
60
    */
dauncey's avatar
dauncey committed
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90
  }
  
  void analyseL1Accept(uint64_t bx) {
    /*    
    unsigned nChannels(0),nWords(0);
    for(unsigned h(0);h<18;h++) {
      hChannels[h]->Fill(fEconSim->numberOfChannels(h));
      hWords[h]->Fill(fEconSim->numberOfWords(h));
      hWordsVsChannels[h]->Fill(fEconSim->numberOfChannels(h),fEconSim->numberOfWords(h));
      nChannels+=fEconSim->numberOfChannels(h);
      nWords+=fEconSim->numberOfWords(h);
    }

    hTotalChannels->Fill(nChannels);
    hTotalWords->Fill(nWords);
    
    for(unsigned block(0);block<fEconSim->fEconArch.fNumberOfBlocks;block++) {
      unsigned nBlockChannels(0),nBlockWords(0);
      for(unsigned i(0);i<fEconSim->fEconArch.fHgcrocNumber[block].size();i++) {
	unsigned h(fEconSim->fEconArch.fHgcrocNumber[block][i]);
	nBlockChannels+=fEconSim->numberOfChannels(h);
	nBlockWords+=fEconSim->numberOfWords(h);
      }
      hBlockTotalChannels[block]->Fill(nBlockChannels);
      hBlockTotalWords[block]->Fill(nBlockWords);
    }
    */
  }
  
  void analyseBx(uint64_t bx) {
dauncey's avatar
dauncey committed
91 92 93 94 95 96 97
    const SlinkArch &slinkArch(*(fBeSlinkSim->fSlinkArch));
    for(unsigned e(0);e<slinkArch.numberOfEcons();e++) {
      const EconArch &econArch(slinkArch.econArch(e));
      for(unsigned b(0);b<econArch.numberOfBlocks();b++) {
	hEventBufferUsed[e][b]->Fill(fBeSlinkSim->fEventBuffer[e][b].used());
	hEventBufferUsedHistory[e][b]->Fill(bx,fBeSlinkSim->fEventBuffer[e][b].used());
      }
dauncey's avatar
dauncey committed
98 99 100 101 102 103 104 105 106
    }
  }
  
  void eoj() {
  }
  
private:
  const BeSlinkSim *fBeSlinkSim;

dauncey's avatar
dauncey committed
107 108
  //TH1I *hBitmapWordsVsChannels;
  //TH1I *hLabelsWordsVsChannels;
dauncey's avatar
dauncey committed
109

dauncey's avatar
dauncey committed
110
  //TH1D *hMeans;
dauncey's avatar
dauncey committed
111
  
dauncey's avatar
dauncey committed
112 113 114 115 116 117 118 119
  //TH1D *hChannels[18];
  //TH1D *hWords[18];
  //TH2D *hWordsVsChannels[18];

  //TH1D *hTotalChannels;
  //TH1D *hTotalWords;
  //TH1D *hBlockTotalChannels[7];
  //TH1D *hBlockTotalWords[7];
dauncey's avatar
dauncey committed
120

dauncey's avatar
dauncey committed
121 122
  TH1D *hEventBufferUsed[Dimensions::MaxNumberOfEconsPerSlink][Dimensions::MaxNumberOfBlocksPerEcon];
  TH1I *hEventBufferUsedHistory[Dimensions::MaxNumberOfEconsPerSlink][Dimensions::MaxNumberOfBlocksPerEcon];
dauncey's avatar
dauncey committed
123 124 125
};

#endif