EconAna.hh 5.3 KB
Newer Older
dauncey's avatar
dauncey committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
#ifndef EconAna_HH
#define EconAna_HH

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

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

#include "Buffering/EconSim.hh"


class EconAna {
public:
dauncey's avatar
dauncey committed
17 18 19 20 21
  EconAna() {
  }

  void boj(const EconSim &e, unsigned nHistory=100000) {
    fEconSim=&e;
dauncey's avatar
dauncey committed
22 23 24
    
    std::ostringstream sout;
    sout << "EconAna" << std::setw(2) << std::setfill('0')
dauncey's avatar
dauncey committed
25
	 << fEconSim->econNumber();
dauncey's avatar
dauncey committed
26 27 28 29
    
    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
30 31 32 33
    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);
dauncey's avatar
dauncey committed
34
    
dauncey's avatar
dauncey committed
35 36
    hTotalChannels=new TH1D((sout.str()+"TotalChannels").c_str(),
			      ";ECON total number of channels",1300,0,1300);
dauncey's avatar
dauncey committed
37
    hTotalWords=new TH1D((sout.str()+"TotalWords").c_str(),
dauncey's avatar
dauncey committed
38 39 40 41 42 43 44 45 46 47 48
			      ";ECON total number of words",1000,0,1000);

    for(unsigned block(0);block<fEconSim->econArch().numberOfBlocks();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);
dauncey's avatar
dauncey committed
49 50 51 52 53 54
      hEventBufferExceeded[block]=new TH1D((sout.str()+"Block"+sHgcroc[block]+"EventBufferExceeded").c_str(),
					   ";Number of event buffer words used",50000,0,50000);
      hL1AcceptDifference[block]=new TH1D((sout.str()+"Block"+sHgcroc[block]+"L1AcceptDifference").c_str(),
				       ";Difference in L1Accept numbers",100,0,100);
      hL1AcceptDifferenceHistory[block]=new TH1I((sout.str()+"Block"+sHgcroc[block]+"L1AcceptDifferenceHistory").c_str(),
					      ";BX;Difference in L1Accept numbers",nHistory,0,nHistory);
dauncey's avatar
dauncey committed
55
    }
dauncey's avatar
dauncey committed
56 57
    
    for(unsigned c(0);c<=72;c++) {
dauncey's avatar
dauncey committed
58 59
      hBitmapWordsVsChannels->Fill(c,fEconSim->channelsToWords(c,true));
      hLabelsWordsVsChannels->Fill(c,fEconSim->channelsToWords(c,false));
dauncey's avatar
dauncey committed
60
    }
dauncey's avatar
dauncey committed
61 62 63

    hMeans=new TH1D((sout.str()+"Means").c_str(),
		   ";HGCROC;Mean number of channels",18,0,18);
dauncey's avatar
dauncey committed
64
    
dauncey's avatar
dauncey committed
65 66 67
    for(unsigned h(0);h<fEconSim->econFile().numberOfHgcrocs();h++) {
      hMeans->SetBinContent(h+1,fEconSim->econFile().mean(h));
    }
dauncey's avatar
dauncey committed
68 69 70 71 72 73 74
    
    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(),
dauncey's avatar
dauncey committed
75
				   ";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
76 77 78 79
    }
  }
  
  void analyseZs(uint64_t bx) {
dauncey's avatar
dauncey committed
80 81
    unsigned nChannels(0),nWords(0);
    
dauncey's avatar
dauncey committed
82
    for(unsigned h(0);h<18;h++) {
dauncey's avatar
dauncey committed
83 84 85 86 87
      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);
dauncey's avatar
dauncey committed
88
    }
dauncey's avatar
dauncey committed
89 90

    hTotalChannels->Fill(nChannels);
dauncey's avatar
dauncey committed
91
    hTotalWords->Fill(nWords);
dauncey's avatar
dauncey committed
92 93 94 95 96 97 98 99 100 101 102
    
    for(unsigned block(0);block<fEconSim->econArch().numberOfBlocks();block++) {
      unsigned nBlockChannels(0),nBlockWords(0);
      for(unsigned i(0);i<fEconSim->econArch().fHgcrocNumber[block].size();i++) {
	unsigned h(fEconSim->econArch().fHgcrocNumber[block][i]);
	nBlockChannels+=fEconSim->numberOfChannels(h);
	nBlockWords+=fEconSim->numberOfWords(h);
      }
      hBlockTotalChannels[block]->Fill(nBlockChannels);
      hBlockTotalWords[block]->Fill(nBlockWords);
    }
dauncey's avatar
dauncey committed
103 104 105
  }
  
  void analyseBx(uint64_t bx) {
dauncey's avatar
dauncey committed
106 107 108
    for(unsigned block(0);block<fEconSim->econArch().fNumberOfBlocks;block++) {
      hEventBufferUsed[block]->Fill(fEconSim->fEventBuffer[block].used());
      hEventBufferUsedHistory[block]->Fill(bx,fEconSim->fEventBuffer[block].used());
dauncey's avatar
dauncey committed
109 110 111 112
      if(fEconSim->exceededBuffer()) hEventBufferExceeded[block]->Fill(fEconSim->fEventBuffer[block].used());

      hL1AcceptDifference[block]->Fill(fEconSim->l1AcceptDifference(block));
      hL1AcceptDifferenceHistory[block]->Fill(bx,fEconSim->l1AcceptDifference(block));
dauncey's avatar
dauncey committed
113
    }
dauncey's avatar
dauncey committed
114
  }
dauncey's avatar
dauncey committed
115 116 117 118
  
  void eoj() {
  }
  
dauncey's avatar
dauncey committed
119
private:
dauncey's avatar
dauncey committed
120
  const EconSim *fEconSim;
dauncey's avatar
dauncey committed
121

dauncey's avatar
dauncey committed
122 123
  TH1I *hBitmapWordsVsChannels;
  TH1I *hLabelsWordsVsChannels;
dauncey's avatar
dauncey committed
124

dauncey's avatar
dauncey committed
125 126
  TH1D *hMeans;
  
dauncey's avatar
dauncey committed
127 128 129 130
  TH1D *hChannels[18];
  TH1D *hWords[18];
  TH2D *hWordsVsChannels[18];

dauncey's avatar
dauncey committed
131
  TH1D *hTotalChannels;
dauncey's avatar
dauncey committed
132
  TH1D *hTotalWords;
dauncey's avatar
dauncey committed
133 134 135 136
  TH1D *hBlockTotalChannels[7];
  TH1D *hBlockTotalWords[7];
  TH1D *hEventBufferUsed[7];
  TH1I *hEventBufferUsedHistory[7];
dauncey's avatar
dauncey committed
137 138 139
  TH1D *hEventBufferExceeded[7];
  TH1D *hL1AcceptDifference[7];
  TH1I *hL1AcceptDifferenceHistory[7];
dauncey's avatar
dauncey committed
140 141 142
};

#endif