BeSlinkAna.hh 4 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 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 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 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120
#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')
	 << fBeSlinkSim->fSlink;
    
    std::string sHgcroc[18]={"00","01","02","03","04","05","06","07","08",
			     "09","10","11","12","13","14","15","16","17"};

    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);

    for(unsigned block(0);block<1;block++) {
      hBlockTotalChannels[block]=new TH1D((sout.str()+"Block"+sHgcroc[block]+"TotalChannels").c_str(),
				       ";Block total number of channels",1300,0,1300);
      hBlockTotalWords[block]=new TH1D((sout.str()+"Block"+sHgcroc[block]+"TotalWords").c_str(),
				       ";Block total number of words",1000,0,1000);
      hEventBufferUsed[block]=new TH1D((sout.str()+"Block"+sHgcroc[block]+"EventBufferUsed").c_str(),
				       ";Number of event buffer words used",50000,0,50000);
      hEventBufferUsedHistory[block]=new TH1I((sout.str()+"Block"+sHgcroc[block]+"EventBufferUsedHistory").c_str(),
					      ";BX;Number of event buffer words used",nHistory,0,nHistory);
    }
    
    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);
    }
  }
  
  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) {
    /*
    for(unsigned block(0);block<fEconSim->fEconArch.fNumberOfBlocks;block++) {
      hEventBufferUsed[block]->Fill(fEconSim->fEventBuffer[block].used());
      hEventBufferUsedHistory[block]->Fill(bx,fEconSim->fEventBuffer[block].used());
    }
    */
  }
  
  void eoj() {
  }
  
private:
  const BeSlinkSim *fBeSlinkSim;

  TH1I *hBitmapWordsVsChannels;
  TH1I *hLabelsWordsVsChannels;

  TH1D *hMeans;
  
  TH1D *hChannels[18];
  TH1D *hWords[18];
  TH2D *hWordsVsChannels[18];

  TH1D *hTotalChannels;
  TH1D *hTotalWords;
  TH1D *hBlockTotalChannels[7];
  TH1D *hBlockTotalWords[7];
  TH1D *hEventBufferUsed[7];
  TH1I *hEventBufferUsedHistory[7];
};

#endif