From: hadeshyp Date: Thu, 6 Aug 2009 16:01:01 +0000 (+0000) Subject: *** empty log message *** X-Git-Url: https://jspc29.x-matter.uni-frankfurt.de/git/?a=commitdiff_plain;h=c31c74cc7b7e863ea5e13ab3e4fb0ea014a8e441;p=mdcoep.git *** empty log message *** --- diff --git a/root/NoiseTestMult.C b/root/NoiseTestMult.C new file mode 100755 index 0000000..99a45ce --- /dev/null +++ b/root/NoiseTestMult.C @@ -0,0 +1,256 @@ + +#include "TObjArray.h" +#include "TH1F.h" +#include "TH2F.h" +#include "TStyle.h" +#include "TString.h" +#include "TCanvas.h" +#include "TGraph.h" + +#include +using namespace std; + +#define BUF_SIZE 100 +#define GET_LINE(buf,file) if (fgets((buf),BUF_SIZE,(file)) == NULL) break + +Int_t readNoiseFile(TString input="",TObjArray* hists_boards=0,TObjArray* hists_channels=0,TObjArray* hists_times=0,Bool_t print = kFALSE) +{ + if(input.CompareTo("")==0){ + + cout<<"File name ist empty!"<FindObject(mbName.Data())) == 0){ // die funktion geht die dateien durch, + h = new TH1F(mbName.Data(),mbName.Data(),120,0,120); // wenn eine mbo# neu ist, wird ein neues + hists_boards->Add(h); // histogramm angelegt + h->Sumw2(); + } + if(print) + cout << " MBO Worte: " << datawords << endl; + h-> Fill(datawords); + + for(Int_t j = 0; j < datawords; j++) { //read datawords + GET_LINE(line,fp); + if (line[0] == '#') { + cout << "Wrong datacount" << endl; + break; + } + sscanf(&line[2],"%x",&dataword); + dataword >>= 12; + dataword &= 0x7F; + if((h = (TH1F*)hists_channels->FindObject(mbchName.Data())) == 0){ // die funktion geht die dateien durch, + h = new TH1F(mbchName.Data(),mbchName.Data(),96,0,96); // wenn eine mbo# neu ist, wird ein neues + hists_channels->Add(h); // histogramm angelegt + h->Sumw2(); + } + h-> Fill(dataword); + + sscanf(&line[2],"%x",&dataword); + dataword &= 0x7ff; + if((h = (TH1F*)hists_times->FindObject(mbchTime.Data())) == 0){ // die funktion geht die dateien durch, + h = new TH1F(mbchTime.Data(),mbchTime.Data(),2048,0,2048); // wenn eine mbo# neu ist, wird ein neues + hists_times->Add(h); // histogramm angelegt + h->Sumw2(); + } + h-> Fill(dataword); + + + + } + GET_LINE(line,fp); //naechste Zahl Datenwoerter + } while(line[0] != '#'); + } + + fclose(fp); + + + return evtct; +} + + + +void NoiseTestMult() +{ + gStyle->SetOptTitle(0); + //gStyle->SetOptStat(0); + gStyle->SetOptFit(11); + gStyle->SetCanvasColor(10); + gStyle->SetTitleFillColor(10); + gStyle->SetStatColor(10); + gStyle->SetPadLeftMargin(0.15); + + + TCanvas* c1 = new TCanvas("c1","Noise Test",200,10,1000,800); + c1->SetGridx(); + c1->SetGridy(); + + TCanvas* c2 = new TCanvas("c2","datawords/board/event",200,10,2200,1900); + c2->SetGridx(); + c2->SetGridy(); + c2->Divide(2,2); + + TCanvas* c3 = new TCanvas("c3","datawords/channel",200,10,2200,1900); + c3->SetGridx(); + c3->SetGridy(); + c3->Divide(2,2); + + TCanvas* c4 = new TCanvas("c4","TDC Data",0,0,2200,1900); + c4->SetGridx(); + c4->SetGridy(); + c4->Divide(2,2); + + + + TH2F* plotocc=new TH2F("plotocc","Noise Test",80,40,120,10000,0,0.5); + plotocc->SetXTitle("Threshold"); + plotocc->SetYTitle("Noise Occupancy [hits/channel/event]"); + plotocc->SetMarkerStyle(20); + + //plot->Fill(60,occ); + + TObjArray* hists_boards = new TObjArray(); + TObjArray* hists_channels = new TObjArray(); + TObjArray* hists_times = new TObjArray(); + + + Char_t* files[]={"noise_4_70","noise_4_60","noise_4_50","noise_4_40","noise_4_30",}; +// "noisedata_00.txt", +// "noisedata_10.txt", +// "noisedata_20.txt", +// "noisedata_30.txt", +// "noisedata_40.txt", +// "noisedata_50.txt", +// "noisedata_70.txt" + Int_t evts, allevts = 0; + + for(Int_t i=0;i<5;i++) { + evts = readNoiseFile(files[i],hists_boards,hists_channels,hists_times,kFALSE); + allevts = allevts + evts; + } + + + //------------------------------------------------------------------ + + hists_boards->Print(); + for(Int_t i = 0; i < hists_boards->GetEntries();i++){ + c2->cd(i+1); + TH1F* h = (TH1F*)hists_boards->At(i); + h->SetXTitle("number of datawords per event"); + h->SetFillColor(4); + cout<GetName()<<" Integral "<Integral()*h->GetMean()<<" mean "<GetMean()<GetName(),"OEP%x_Thresh%x",&board,&threshold); + if (board == 0x119) + plotocc->Fill(threshold,(h->GetMean())/96.); + else + plotocc->Fill(threshold,(h->GetMean())/64.); + h->Draw(); + } + + + hists_channels->Print(); + for(Int_t i = 0; i < hists_channels->GetEntries();i++){ + c3->cd(i+1); + TH1F* h = (TH1F*)hists_channels->At(i); + h->SetXTitle("datawords per channel"); + h->SetFillColor(4); + h->Draw(); + } + + + hists_times->Print(); + for(Int_t i = 0; i < hists_times->GetEntries();i++){ + c4->cd(i+1); + TH1F* h = (TH1F*)hists_times->At(i); + h->SetXTitle("TDC data"); + h->SetFillColor(4); + h->Draw(); + } + + //------------------------------------------------------------------ + // calculating occupancy per channel + + c1->cd(); + plotocc->Draw(); + +// float occ; + +// occ = (h->Integral()*h->GetMean())/(2*2*64*allevts); + //h->Integral()*h->GetMean(): Anzahl der Datenw�rter aus Histogrammen + +// cout << "OCC: " << occ << endl; + +// int ct = 1; +// const Int_t n = 100; +// Float_t x[n] = {0}; +// Float_t y[n] = {0}; +// +// x[0] = 60; //test +// y[0] = occ; +// +// TGraph* gr = new TGraph(ct,x,y); +// gr->SetMarkerColor(2); +// gr->SetMarkerStyle(21); +// gr->Draw("LPsame"); +// c1->Update(); + + //------------------------------------------------------------------ + +} + +