Commit 2e079021 authored by dauncey's avatar dauncey

Including ECON architectures

parent eea2c1cc
#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
This diff is collapsed.
#ifndef BlockCheck_HH
#define BlockCheck_HH
#include <iostream>
#include <iomanip>
#include <cassert>
class BlockCheck {
public:
BlockCheck() {
}
BlockCheck(unsigned s, unsigned e, unsigned b, const std::vector<unsigned> &h) {
initialise(s,e,b,h);
}
void initialise(unsigned s, unsigned e, unsigned b, const std::vector<unsigned> &h) {
fSlink=s;
fEcon=e;
fBlock=b;
fHgcrocNumber=&h;
if(fPrintLevel>1) {
std::cout << "BlockCheck[" << fSlink << "][" << fEcon
<< "][" << fBlock << "]::initialise() "
<< "Number of HGCROCs = " << h.size()
<< ", numbers =";
for(unsigned n(0);n<h.size();n++) std::cout << " " << h[n];
std::cout << std::endl;
}
fActivePacket=false;
fActiveHgcroc=false;
}
bool processBx(uint32_t a) {
if(fPrintLevel>4) {
std::cout << "BlockCheck[" << fSlink << "][" << fEcon
<< "][" << fBlock << "]::processBx(" << std::hex << a << std::dec << ") "
<< "Entered" << std::endl;
}
if(!fActivePacket) {
if(a!=0) {
fActivePacket=true;
fActiveHgcroc=true;
//for(unsigned h(0);h<fEconArch.fHgcrocNumber.size();h++) fHgcrocSeen[fEconArch.fHgcrocNumber[h]]=false;
fHgcroc=(*fHgcrocNumber)[0];
fNumberSeen=1;
checkHeader(a,true);
fBx=fHgcrocBoe.bx();
fWords=1;
if(fPrintLevel>4) {
std::cout << "BlockCheck[" << fSlink << "][" << fEcon
<< "][" << fBlock << "]::processBx() "
<< "New packet found" << std::endl;
std::cout << "New HGCROC found" << std::endl;
fHgcrocBoe.print();
}
if(fHgcrocBoe.numberOfWords()==1) {
fActiveHgcroc=false;
fHgcrocSeen[fHgcrocBoe.hgcroc()]=true;
if(fPrintLevel>4) {
std::cout << "BlockCheck[" << fSlink << "][" << fEcon
<< "][" << fBlock << "]::processBx() "
<< "HGCROC " << unsigned(fHgcrocBoe.hgcroc())
<< " completed" << std::endl;
}
}
}
} else {
assert(a!=0);
if(!fActiveHgcroc) {
fActiveHgcroc=true;
fHgcroc=(*fHgcrocNumber)[fNumberSeen];
fNumberSeen++;
checkHeader(a,false);
fWords=1;
if(fPrintLevel>4) {
std::cout << "BlockCheck[" << fSlink << "][" << fEcon
<< "][" << fBlock << "]::processBx() "
<< "New HGCROC found" << std::endl;
fHgcrocBoe.print();
}
if(fHgcrocBoe.numberOfWords()==1) {
fActiveHgcroc=false;
fHgcrocSeen[fHgcrocBoe.hgcroc()]=true;
if(fPrintLevel>4) {
std::cout << "BlockCheck[" << fSlink << "][" << fEcon
<< "][" << fBlock << "]::processBx() "
<< "HGCROC " << unsigned(fHgcrocBoe.hgcroc())
<< " completed" << std::endl;
}
}
} else {
assert((a>>24)==fL1Accept);
assert((a&0xffffff)==fWords);
fWords++;
if(fWords==fHgcrocBoe.numberOfWords()) {
fActiveHgcroc=false;
fHgcrocSeen[fHgcrocBoe.hgcroc()]=true;
if(fPrintLevel>4) {
std::cout << "BlockCheck[" << fSlink << "][" << fEcon
<< "][" << fBlock << "]::processBx() "
<< "HGCROC " << unsigned(fHgcrocBoe.hgcroc())
<< " completed" << std::endl;
}
if(fNumberSeen==(*fHgcrocNumber).size()) {
fActivePacket=false;
if(fPrintLevel>4) {
std::cout << "BlockCheck[" << fSlink << "][" << fEcon
<< "][" << fBlock << "]::processBx() "
<< "Packet ended" << std::endl;
}
fL1Accept++;
return true;
}
}
}
}
return false;
}
void checkHeader(uint32_t a, bool first) {
fHgcrocBoe.word(a);
if(first) fBx=fHgcrocBoe.bx();
//assert(!fHgcrocSeen[fHgcrocBoe.hgcroc()]);
//fHgcrocSeen[fHgcrocBoe.hgcroc()]=true;
assert(fHgcrocBoe.econ()==fEcon);
assert(fHgcrocBoe.hgcroc()==fHgcroc);
assert(fHgcrocBoe.bx()==fBx);
assert(fHgcrocBoe.l1a()==fL1Accept);
}
static unsigned fPrintLevel;
private:
unsigned fSlink;
unsigned fEcon;
unsigned fBlock;
unsigned fHgcroc;
unsigned fNumberSeen;
const std::vector<unsigned> *fHgcrocNumber;
bool fActivePacket;
bool fActiveHgcroc;
uint8_t fL1Accept;
uint8_t fBx;
HgcrocBoe fHgcrocBoe;
unsigned fWords;
bool fHgcrocSeen[18];
};
unsigned BlockCheck::fPrintLevel(1);
#endif
#ifndef Dimensions_HH
#define Dimensions_HH
class Dimensions {
public:
enum {
MaxNumberOfSlinks=12,
MaxNumberOfEconsPerSlink=5,
MaxNumberOfElinksPerEcon=7,
MaxNumberOfBlocksPerEcon=MaxNumberOfElinksPerEcon,
MaxNumberOfHgcrocsPerEcon=18,
MaxNumberOfHgcrocsPerElink=3
};
};
#endif
......@@ -14,33 +14,51 @@
class EconAna {
public:
EconAna(const EconSim &e, unsigned nHistory=100000) :
fEconSim(e) {
EconAna() {
}
void boj(const EconSim &e, unsigned nHistory=100000) {
fEconSim=&e;
std::ostringstream sout;
sout << "EconAna" << std::setw(2) << std::setfill('0')
<< fEconSim.econNumber();
<< fEconSim->econNumber();
std::string sHgcroc[18]={"00","01","02","03","04","05","06","07","08",
"09","10","11","12","13","14","15","16","17"};
hMapWordsVsChannels=new TH1I((sout.str()+"MapWordsVsChannels").c_str(),
";Number of channels per HGCROC packet;Number of words per HGCROC packet",73,0,73);
hLabelWordsVsChannels=new TH1I((sout.str()+"LabelWordsVsChannels").c_str(),
";Number of channels per HGCROC packet;Number of words per HGCROC packet",73,0,73);
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(),
";Total number of words",1000,0,1000);
hEventBufferUsed=new TH1D((sout.str()+"EventBufferUsed").c_str(),
";Number of event buffer words used",10000,0,10000);
hEventBufferUsedHistory=new TH1I((sout.str()+"EventBufferUsedHistory").c_str(),
";BX;Number of event buffer words used",nHistory,0,nHistory);
";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);
}
for(unsigned c(0);c<=72;c++) {
hMapWordsVsChannels->Fill(c,fEconSim.channelsToWords(c,true));
hLabelWordsVsChannels->Fill(c,fEconSim.channelsToWords(c,false));
hBitmapWordsVsChannels->Fill(c,fEconSim->channelsToWords(c,true));
hLabelsWordsVsChannels->Fill(c,fEconSim->channelsToWords(c,false));
}
hMeans=new TH1D((sout.str()+"Means").c_str(),
";HGCROC;Mean number of channels",18,0,18);
for(unsigned h(0);h<fEconSim->econFile().numberOfHgcrocs();h++) {
hMeans->SetBinContent(h+1,fEconSim->econFile().mean(h));
}
for(unsigned h(0);h<18;h++) {
hChannels[h]=new TH1D((sout.str()+"Hgcroc"+sHgcroc[h]+"Channels").c_str(),
......@@ -48,39 +66,64 @@ public:
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,73,60,0,60);
";Number of channels per HGCROC packet;Number of words per HGCROC packet",73,-0.5,72.5,60,-0.5,59.5);
}
}
void analyseZs(uint64_t bx) {
unsigned nWords(0);
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));
nWords+=fEconSim.numberOfWords(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->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);
}
}
void analyseBx(uint64_t bx) {
hEventBufferUsed->Fill(fEconSim.fEventBuffer.used());
hEventBufferUsedHistory->Fill(bx,fEconSim.fEventBuffer.used());
for(unsigned block(0);block<fEconSim->econArch().fNumberOfBlocks;block++) {
hEventBufferUsed[block]->Fill(fEconSim->fEventBuffer[block].used());
hEventBufferUsedHistory[block]->Fill(bx,fEconSim->fEventBuffer[block].used());
}
}
void eoj() {
}
private:
const EconSim &fEconSim;
const EconSim *fEconSim;
TH1I *hMapWordsVsChannels;
TH1I *hLabelWordsVsChannels;
TH1I *hBitmapWordsVsChannels;
TH1I *hLabelsWordsVsChannels;
TH1D *hMeans;
TH1D *hChannels[18];
TH1D *hWords[18];
TH2D *hWordsVsChannels[18];
TH1D *hTotalChannels;
TH1D *hTotalWords;
TH1D *hEventBufferUsed;
TH1I *hEventBufferUsedHistory;
TH1D *hBlockTotalChannels[7];
TH1D *hBlockTotalWords[7];
TH1D *hEventBufferUsed[7];
TH1I *hEventBufferUsedHistory[7];
};
#endif
#ifndef EconArch_HH
#define EconArch_HH
#include <vector>
#include "EconFile.hh"
class EconArch {
public:
EconArch() {
};
void initialise(bool b, const EconFile &econFile) {
unsigned nh=econFile.numberOfHgcrocs();
assert(nh<=Dimensions::MaxNumberOfHgcrocsPerEcon);
for(unsigned b(0);b<Dimensions::MaxNumberOfBlocksPerEcon;b++) {
fHgcrocNumber[b].resize(0);
fElinkNumber[b].resize(0);
}
if(b) {
fNumberOfBlocks=1;
//for(unsigned h(0);h<MaxNumberOfHgcrocs;h++) {
for(unsigned h(0);h<nh;h++) {
fHgcrocNumber[0].push_back(h);
}
for(unsigned e(0);e<Dimensions::MaxNumberOfElinksPerEcon;e++) {
fElinkNumber[0].push_back(e);
}
} else {
fNumberOfBlocks=Dimensions::MaxNumberOfBlocksPerEcon;
//for(unsigned h(0);h<MaxNumberOfHgcrocs;h++) {
for(unsigned h(0);h<nh;h++) {
fHgcrocNumber[h%fNumberOfBlocks].push_back(h);
}
for(unsigned e(0);e<Dimensions::MaxNumberOfBlocksPerEcon;e++) {
fElinkNumber[e].push_back(e);
}
}
}
unsigned numberOfBlocks() const {
return fNumberOfBlocks;
}
const std::vector<unsigned>& hgcrocNumber(unsigned b) const {
assert(b<fNumberOfBlocks);
return fHgcrocNumber[b];
}
const std::vector<unsigned>& elinkNumber(unsigned b) const {
assert(b<fNumberOfBlocks);
return fElinkNumber[b];
}
void print() const {
std::cout << "EconArch::print() "
<< "Number of blocks = " << fNumberOfBlocks << std::endl;
for(unsigned block(0);block<fNumberOfBlocks;block++) {
std::cout << " Block " << block << ", HGCROCs =";
for(unsigned h(0);h<fHgcrocNumber[block].size();h++) {
std::cout << " " << fHgcrocNumber[block][h];
}
std::cout << ", Elinks =";
for(unsigned e(0);e<fElinkNumber[block].size();e++) {
std::cout << " " << fElinkNumber[block][e];
}
std::cout << std::endl;
}
}
unsigned fNumberOfBlocks;
std::vector<unsigned> fHgcrocNumber[Dimensions::MaxNumberOfElinksPerEcon];
std::vector<unsigned> fElinkNumber[Dimensions::MaxNumberOfElinksPerEcon];
};
#endif
#ifndef EconFile_HH
#define EconFile_HH
#include <fstream>
class EconFile {
friend class EconSim;
public:
enum {
MaxNumberOfHgcrocs=18
};
EconFile () : fNumberOfHgcrocs(-1) {
}
bool read(std::istream &fin) {
if(!fin) return false;
char lead;
fin >> lead >> fNumberOfHgcrocs;
if(lead!='E') return false;
if(fNumberOfHgcrocs>MaxNumberOfHgcrocs) return false;
for(unsigned h(0);h<fNumberOfHgcrocs;h++) {
fin >> fHgcrocMean[h];
if(fHgcrocMean[h]< 0) return false;
if(fHgcrocMean[h]>72) return false;
}
if(!fin) return false;
return true;
}
unsigned numberOfHgcrocs() const {
return fNumberOfHgcrocs;
}
double mean(unsigned h) const {
assert(h<fNumberOfHgcrocs);
return fHgcrocMean[h];
}
void print() const {
std::cout << "EconFile::print() Number of HGCROCs = "
<< fNumberOfHgcrocs << ", means =";
for(unsigned h(0);h<fNumberOfHgcrocs;h++) {
std::cout << " " << fHgcrocMean[h];
}
std::cout << std::endl;
}
private:
protected:
unsigned fNumberOfHgcrocs;
double fHgcrocMean[MaxNumberOfHgcrocs];
};
#endif
This diff is collapsed.
......@@ -13,17 +13,33 @@
class HgcrocAna {
public:
HgcrocAna(const HgcrocSim &h, unsigned nHistory=100000) :