From: Dennis Doering Date: Tue, 10 Sep 2013 15:39:39 +0000 (+0200) Subject: Initial commit X-Git-Url: https://jspc29.x-matter.uni-frankfurt.de/git/?a=commitdiff_plain;h=1fb53e90f54722c271b58c6ef038fdefe23f4929;p=radhard.git Initial commit --- diff --git a/newCOMBI/MAPS.C b/newCOMBI/MAPS.C new file mode 100755 index 0000000..1ce08b2 --- /dev/null +++ b/newCOMBI/MAPS.C @@ -0,0 +1,1437 @@ +#include +#include +#include +#include +#include "Riostream.h" +#include +#include "TString.h" +#include "TMath.h" +#include +#include +#include +#include +#include "TH1.h" +#include "TF1.h" +#include "TROOT.h" +#include +#include "TCanvas.h" +#include "TObject.h" +#include "TStyle.h" +#include "TEnv.h" +#include "TGraph.h" +#include "TGaxis.h" +#include "TStyle.h" +#include "TFrame.h" +#include "TVector.h" +#include "TVectorD.h" +#include "Foption.h" +#include "TRandom.h" +#include "TSpline.h" +#include "TPaveStats.h" +#include "TVirtualFitter.h" +#include "TVirtualPad.h" +#include "TVirtualGraphPainter.h" +#include "TBrowser.h" +#include "TSystem.h" +#include "TPluginManager.h" +#include "TPad.h" +#include +#include +#include +#include +#include +#include +#include + +using namespace std; + +#include"MAPS.h" +//#################################################################### + +MAPS::MAPS() { + +}; + +//#################################################################### + +MAPS::MAPS( TString InDir, TString OutDir, Int_t RunNumber, Int_t Rows, Int_t Columns, TString System, TString OrderCode, Int_t Matrix, bool Save ) { +//----------------------------------------------- + + initMapsRun( InDir, OutDir, RunNumber, Rows, Columns, System, OrderCode, Matrix, Save); + + UInt_t FileEvNb; // Event number per file + UInt_t TotEvNb; // Total events in RUN - should be less if RUN was stopped before endl + + if ( checkConf(FileEvNb, TotEvNb, fPixelsData) ) + { +//----------------------------------------------- +//Check and open Data Files + sleep(1); + int MaxFiles = TotEvNb/FileEvNb; + + if( checkDataFiles(MaxFiles) ) + { + initSave(); + } +//----------------------------------------------- + } +} + +//#################################################################### + +MAPS::~MAPS(void) { + + if(fSave && fOk) + { + fOutputFile->cd(); + + fHitTree->Write("",TObject::kOverwrite); + fNoiseTree->Write("",TObject::kOverwrite); + + hint1->Write("",TObject::kOverwrite); + hint2->Write("",TObject::kOverwrite); + + fOutputFile->Save(); + fOutputFile->Close(); + + cout<Close(); + cout<<"...finished!"<ProcessLine("new TBrowser;"); + +// delete[] fOutputFile; +// delete[] fHitNtup; +// delete[] fNoiseNtup; +// delete[] fMeanNoiseNtup; + } + + for(Int_t i=0;i "<SetOptFit(1011); + gStyle->SetPalette(1); + gStyle->SetCanvasColor(0); + gStyle->SetFrameFillColor(10); + gStyle->SetOptStat(0); +//----------------------------------------------- +} + +//#################################################################### + +bool MAPS::checkConf( UInt_t &FileEvNb, UInt_t &TotEvNb, Int_t &PixelData ) { + + UInt_t DataSz; + UInt_t NrAdcBoards; + + TString FILENAME = fInDir+Form("%i/RUN_%i_i.rz",fRunNumber,fRunNumber); + ifstream inn(FILENAME, ios::binary); + + if( inn.good() ) + { + inn.seekg(0, ios::end); + int End = inn.tellg(); + inn.seekg(0, ios::beg); + + char* RAWDATA = new char[End]; + inn.read ( RAWDATA, End); + inn.close(); + + FileEvNb = littleEndian32( RAWDATA, 4*3); // Event number per file + TotEvNb = littleEndian32( RAWDATA, 4*4); // Total events in RUN - should be less if RUN was stopped before endl + DataSz = littleEndian32( RAWDATA, 4*6); // Datas size = BDB_VFAS_RAM_SZ_W32 X Adc number ( VFasRunNb field ) + NrAdcBoards = littleEndian32( RAWDATA, 4*9); // Number of Adc boards installed in the system + + PixelData = DataSz/4; + + TString System[5] = {"","","USB","","PXI"}; + if( fSystem == "" ) + { + if( NrAdcBoards == 1) { fSystem = "USB"; } + if( NrAdcBoards == 2) { fSystem = "USB"; } + if( NrAdcBoards == 4) { fSystem = "PXI"; } + } + else if( (NrAdcBoards == 2 && fSystem != "USB") || (NrAdcBoards == 4 && fSystem != "PXI") ) + { + cout<<"---------"< Check config file ..."< Number of Pixels defined is bigger than found: "< "<50) + { + cout<<"Expected Nr of Files is too big: "< Wrong Number of Pixels: ( "<< count-count_tmp-29 <<" ) in Framenr: "< ",fRunNumber,FileNr)<= 1) { printf("%6.2f TB ", (Float_t)(End/(TMath::Power(2,40))) ); } + else if (End/(TMath::Power(2,30)) >= 1) { printf("%6.2f GB ", (Float_t)(End/(TMath::Power(2,30))) ); } + else if (End/(TMath::Power(2,20)) >= 1) { printf("%6.2f MB ", (Float_t)(End/(TMath::Power(2,20))) ); } + else if (End/(TMath::Power(2,10)) >= 1) { printf("%6.2f kB ", (Float_t)(End/(TMath::Power(2,10))) ); } + else { printf("%6.2f B ", (Float_t)(End)); } + + cout<Branch("frame" , &fFrameInfo.frame , "frame/i" , 32000); + fHitTree->Branch("hits" , &fFrameInfo.hits , "hits/i" , 32000); + fHitTree->Branch("pixel" , &fFrameInfo.pixel[0] , "pixel[hits]/i" , 32000); + for(int i=0;i<25;i++) { fHitTree->Branch( Form("p%i",i+1) , &fFrameInfo.p[i][0] , Form("p%i [hits]/F",i+1) , 32000); } +// Noise TTree + fNoiseTree = new TTree("noise", "noise"); +//----------------------------------------------- + hint1 = new TH2F("Hitmulit", "Hit multiplicity", fColumns, 0, fColumns, fRows, 0, fRows); + hint2 = new TH2F("Pixmulit", "Pix multiplicity", fColumns, 0, fColumns, fRows, 0, fRows); + + hint1->GetXaxis()->SetRangeUser(0, fColumns); + hint1->GetYaxis()->SetRangeUser(0, fRows); + hint1->GetXaxis()->SetTitle("column"); + hint1->GetYaxis()->SetTitle("row"); + hint1->GetZaxis()->SetTitle("Signal [ADC]"); + + hint2->GetXaxis()->SetRangeUser(0, fColumns); + hint2->GetYaxis()->SetRangeUser(0, fRows); + hint2->GetXaxis()->SetTitle("column"); + hint2->GetYaxis()->SetTitle("row"); + hint2->GetZaxis()->SetTitle("Signal [ADC]"); +//----------------------------------------------- + cout<<"-----------------------"< fEventsSum ) { Frames = fEventsSum; printf("Changed 'Number Frames' to: %u\n", Frames ); } + if( Frames+Start > fEventsSum ) { Start = fEventsSum-Frames; printf("Changed 'First Event' to: %u\n", Start ); } +// Get fPixels and allocate array + Int_t *ARR = new Int_t[Frames*fPixels]; + Float_t PEDESTAL; + Float_t NOISE; + Int_t PIXEL; + + for(Int_t i=Start; iBranch("pixel" , &PIXEL , "pixel/i" , 32000); + fNoiseTree->Branch("noise" , &NOISE , "noise/F" , 32000); + fNoiseTree->Branch("pedestal" , &PEDESTAL , "pedestal/F" , 32000); + } + + for(Int_t i=0; iFill(); } + } + + cout<<"-----------------------"<IsZombie()) + { + cerr<<"ERROR: loadNoise() failed!"<Get("noise"); + + UInt_t PIXEL; + Float_t NOISE, PEDESTAL; + + noiseTree->SetBranchAddress("pixel" , &PIXEL ); + noiseTree->SetBranchAddress("noise" , &NOISE ); + noiseTree->SetBranchAddress("pedestal" , &PEDESTAL ); + + Int_t entries = noiseTree->GetEntries(); + + for(Int_t i=0; iGetEntry(i); + + fNoise[i] = NOISE; + fPedestals[i] = PEDESTAL; + } + cout<<"-----------------------"< (5.*fNoise[i]) ) + { + HITNR++; + HITS.Set(HITNR); + HITS.AddAt(i,(HITNR-1)); + + if(fSave) { hint2->Fill(i%fColumns, (int)(i/fColumns)); } + } + } + +//Rewrite HITS to fHitlist array + Hitlist= new Int_t[HITNR]; + + for(Int_t i=0;i Remove hits where the seed pixel is within 2 pixels beside the edge + // Hitlist[hit]%fColumn = x-coordinate of the seed pixel, Hitlist[hit]/fColumns = y-coordinate of the seed pixel + if (Hitlist[hit]%fColumns < 2 || Hitlist[hit]%fColumns > fColumns-3 || Hitlist[hit]/fColumns < 2 || Hitlist[hit]/fColumns > fRows-3) + continue; + +//Provide 5x5 clusters with CDS - content: + for(Int_t row=0;row<5;row++) + { + for(Int_t column=0;column<5;column++) + { + if ( (row==0) && (A<2) ) {CLUSTER[(row*5)+column]=DUMMY; } + else if ( (row==1) && (A<1) ) {CLUSTER[(row*5)+column]=DUMMY; } + else if ( (row==3) && (A>= (fRows-1)) ) {CLUSTER[(row*5)+column]=DUMMY; } + else if ( (row==4) && (A>= (fRows-2)) ) {CLUSTER[(row*5)+column]=DUMMY; } + else + { + if ( (column==0) && (B<2) ) {CLUSTER[(row*5)+column]=DUMMY; } + else if ( (column==1) && (B==0) ) {CLUSTER[(row*5)+column]=DUMMY; } + else if ( (column==3) && (B==fColumns-1)) {CLUSTER[(row*5)+column]=DUMMY; } + else if ( (column==4) && (B>fColumns-3)) {CLUSTER[(row*5)+column]=DUMMY; } + else {CLUSTER[(row*5)+column] = 1.*fCdsmatrix [Hitlist[hit]+(row-2)*fColumns+(column-2)] - fPedestals [Hitlist[hit]+(row-2)*fColumns+(column-2)]; } + } + } + } + +//Check seeds (whether highest entry in cluster): + for(Int_t i=6;i<19;i++) + { + if ( (i!=12) && (CLUSTER[i] > CLUSTER[12]) ) {CHANCE=0; break;} + else if ( (i!=12) && (CLUSTER[i] == CLUSTER[12]) && i>12 ) {CHANCE=0; break;} //NOTE: potential error source + else {CHANCE=100; if(i%5==3) {i+=2;}; } + } + +//Begin: loop evaluate true seeds: + if(CHANCE==100) + { +//Fill hit TTree: + fFrameInfo.pixel[fHits] = Hitlist[hit]; + for(int clupos=0;clupos<25;clupos++) + { + fFrameInfo.p [clupos][fHits] = CLUSTER[clupos]; + } + + fHits++; + + if(fSave) { hint1->Fill( Hitlist[hit]%fColumns, (int)(Hitlist[hit]/fColumns) ); } + } + } +//End: loop evaluate true seeds: +//End: loop over all potential seed pixels: + + if(fSave) + { + fFrameInfo.hits = fHits; + if(fHits<100) + { + fHitTree->Fill(); + } + else + { + cout<<"\rFrame: "<100) + { + warning = true; + } + + for(int column=0; column Common Mode suspiciously high! "<Divide(2,3); + gStyle->SetOptFit(1011); + gStyle->SetPalette(1); + gStyle->SetCanvasColor(0); + gStyle->SetFrameFillColor(10); + gStyle->SetOptStat(0); + + TH2F *h1 = new TH2F("CDS matrix", "CDS matrix", fColumns, 0, fColumns, fRows, 0, fRows); + TH2F *h2 = new TH2F("Frame 0 matrix", "Frame 0 matrix", fColumns, 0, fColumns, fRows, 0, fRows); + TH2F *h3 = new TH2F("Frame 1 matrix", "Frame 1 matrix", fColumns, 0, fColumns, fRows, 0, fRows); + TH1F *h4 = new TH1F("Frame 0 histo", "Frame 0 histo", 2*16384, -16384, 16384); + TH1F *h5 = new TH1F("Frame 1 histo", "Frame 1 histo", 2*16384, -16384, 16384); + + Int_t column; + Int_t row; + Float_t F0,F1,CDS; + + for(Int_t i=0; iFill(column,row,CDS); + h2->Fill(column,row,F0); + h3->Fill(column,row,F1); + h4->Fill(F0); + h5->Fill(F1); + + } + + cm1->cd(1); + h1->Draw("colz"); + h1->GetXaxis()->SetTitle("column"); + h1->GetYaxis()->SetTitle("row"); + h1->GetZaxis()->SetTitle("Signal [ADC]"); + + cm1->cd(2); + h1->Draw("surf2z"); + h1->GetXaxis()->SetTitle("column"); + h1->GetYaxis()->SetTitle("row"); + h1->GetZaxis()->SetTitle("Signal [ADC]"); + + cm1->cd(3); + h2->Draw("surf2z"); + h2->GetXaxis()->SetTitle("column"); + h2->GetYaxis()->SetTitle("row"); + h2->GetZaxis()->SetTitle("Signal [ADC]"); + + cm1->cd(4); + h3->Draw("surf2z"); + h3->GetXaxis()->SetTitle("column"); + h3->GetYaxis()->SetTitle("row"); + h3->GetZaxis()->SetTitle("Signal [ADC]"); + + cm1->cd(5); + h4->Draw(); + h4->GetXaxis()->SetTitle("Signal [ADC]"); + h4->GetYaxis()->SetTitle("Counts"); + + cm1->cd(6); + h5->Draw(); + h5->GetXaxis()->SetTitle("Signal [ADC]"); + h5->GetYaxis()->SetTitle("Counts"); + + cm1->DrawClone(); + cm1->Close(); + cm1->Update(); + cout<<"\rPIXELMATRIX plotted! "<Divide(2,2); + gStyle->SetOptFit(1011); + gStyle->SetPalette(1); + gStyle->SetCanvasColor(0); + gStyle->SetFrameFillColor(10); + gStyle->SetOptStat(1); + + TH1F *h1 = new TH1F("noisee", "noise", 2000, 0, 200); + TH1F *h2 = new TH1F("pedestal", "pedestal", 1000, -50, 50); + TH2F *h3 = new TH2F("noise matrix", "noise matrix", fColumns, 0, fColumns, fRows, 0, fRows); + TH2F *h4 = new TH2F("pedestal matrix", "pedestal matrix", fColumns, 0, fColumns, fRows, 0, fRows); + + Int_t column; + Int_t row; + Float_t NOISE,PEDESTAL; + + for(Int_t i=0; iFill(NOISE); + h2->Fill(PEDESTAL); + h3->Fill(column,row,NOISE); + h4->Fill(column,row,PEDESTAL); + } + + cm2->cd(1); + h3->Draw("colz"); + h3->GetXaxis()->SetTitle("column"); + h3->GetYaxis()->SetTitle("row"); + h3->GetZaxis()->SetTitle("Noise [ADC]"); + + cm2->cd(2); + h4->Draw("colz"); + h4->GetXaxis()->SetTitle("column"); + h4->GetYaxis()->SetTitle("row"); + h4->GetZaxis()->SetTitle("Pedstals [ADC]"); + + cm2->cd(3); + h1->Draw(); + h1->GetXaxis()->SetTitle("Noise [ADC]"); + h1->GetYaxis()->SetTitle("Counts"); + + cm2->cd(4); + h2->Draw(); + h2->GetXaxis()->SetTitle("Pedestal [ADC]"); + h2->GetYaxis()->SetTitle("Counts"); + + cm2->DrawClone(); + cm2->Close(); + cm2->Update(); + cout<<"NOISE plotted! "< fEventsSum ) { Frames = fEventsSum; printf("Changed 'Number Frames' to: %u\n", Frames ); } + if( Frames+Start > fEventsSum ) { Start = fEventsSum-Frames; printf("Changed 'First Event' to: %u\n", Start ); } + } +} + +//#################################################################### + +void MAPS::plotSignal(Int_t Start, Int_t Frames) { + + if(fOk) + { +//Check availabilty of Frames + if( Frames > fEventsSum ) { Frames = fEventsSum; printf("Changed 'Number Frames' to: %u\n", Frames ); } + if( Frames+Start > fEventsSum ) { Start = fEventsSum-Frames; printf("Changed 'First Event' to: %u\n", Start ); } + + TH2F *h1 = new TH2F("Frames 0 " , "Frame 0" , fPixels, 0, fPixels, 2*16384, -16384, 16384); + TH2F *h2 = new TH2F("Frames 1" , "Frame 1" , fPixels, 0, fPixels, 2*16384, -16384, 16384); + TH2F *h3 = new TH2F("CDS" , "CDS" , fPixels, 0, fPixels, 2*16384, -16384, 16384); + + TH1F *h4 = new TH1F("Frames 0 histo" , "Frames 0 histo" , 2*16384, -16384, 16384); + TH1F *h5 = new TH1F("Frames 1 histo" , "Frames 1 histo" , 2*16384, -16384, 16384); + TH1F *h6 = new TH1F("CDS histo" , "CDS histo" , 2*16384, -16384, 16384); + + for(int i=Start;iFill(j,fF0matrix [j]); + h2->Fill(j,fF1matrix [j]); + h3->Fill(j,fCdsmatrix [j]); + + h4->Fill(fF0matrix [j]); + h5->Fill(fF1matrix [j]); + h6->Fill(fCdsmatrix [j]); + } + } + } + + + TCanvas* cm11; + cm11 = new TCanvas("cm11","Signal",50,100,1200,800); + cm11->Divide(3,2); + gStyle->SetOptFit(1011); + gStyle->SetPalette(1); + gStyle->SetCanvasColor(0); + gStyle->SetFrameFillColor(10); + gStyle->SetOptStat(0); + + cm11->cd(1); + h1->Draw("colz"); + h1->GetXaxis()->SetTitle("Pixel#"); + h1->GetYaxis()->SetTitle("Signal"); + + cm11->cd(2); + h2->Draw("colz"); + h2->GetXaxis()->SetTitle("Pixel#"); + h2->GetYaxis()->SetTitle("Signal"); + + cm11->cd(3); + h3->Draw("colz"); + h3->GetXaxis()->SetTitle("Pixel#"); + h3->GetYaxis()->SetTitle("Signal"); + + cm11->cd(4); + h4->Draw(); + h4->GetXaxis()->SetTitle("Signal [ADC]"); + h4->GetYaxis()->SetTitle("Counts"); + + cm11->cd(5); + h5->Draw(); + h5->GetXaxis()->SetTitle("Signal [ADC]"); + h5->GetYaxis()->SetTitle("Counts"); + + cm11->cd(6); + h6->Draw(); + h6->GetXaxis()->SetTitle("Signal [ADC]"); + h6->GetYaxis()->SetTitle("Counts"); + + cm11->DrawClone(); + cm11->Close(); + cm11->Update(); + cout<<"\rSIGNALS plotted! "<Divide(3,2); + gStyle->SetOptFit(1011); + gStyle->SetPalette(1); + gStyle->SetCanvasColor(0); + gStyle->SetFrameFillColor(10); + gStyle->SetOptStat(0); + + if( Frames > fEventsSum ) { Frames = fEventsSum; printf("Changed 'Number Frames' to: %u\n", Frames ); } + if( Frames+Start > fEventsSum ) { Start = fEventsSum-Frames; printf("Changed 'First Event' to: %u\n", Start ); } + + TH2F *h1 = new TH2F("Frame 0 vs T" , "Frame 0 vs T" , Frames, Start, Start+Frames, 2*16384, -16384, 16384); + TH2F *h2 = new TH2F("Frame 1 vs T" , "Frame 1 vs T" , Frames, Start, Start+Frames, 2*16384, -16384, 16384); + TH2F *h3 = new TH2F("CDS vs T" , "CDS vs T" , Frames, Start, Start+Frames, 2*16384, -16384, 16384); + + TH1F *h4 = new TH1F("Frames 0 phisto" , "Frames 0 phisto" , 2*16384, -16384, 16384); + TH1F *h5 = new TH1F("Frames 1 phisto" , "Frames 1 phisto" , 2*16384, -16384, 16384); + TH1F *h6 = new TH1F("CDS phisto" , "CDS phisto" , 2*16384, -16384, 16384); + + for(int i=Start;iFill( i,fF0matrix[Pixel]) ; + h2->Fill( i,fF1matrix[Pixel]) ; + h3->Fill( i,fCdsmatrix[Pixel] ); + + h4->Fill( fF0matrix[Pixel] ); + h5->Fill( fF1matrix[Pixel] ); + h6->Fill( fCdsmatrix[Pixel] ); + } + } + + cm4->cd(1); + h1->Draw("colz"); + h1->GetXaxis()->SetTitle("Frame#"); + h1->GetYaxis()->SetTitle("Signal"); + + cm4->cd(2); + h2->Draw("colz"); + h2->GetXaxis()->SetTitle("Frame#"); + h2->GetYaxis()->SetTitle("Signal"); + + cm4->cd(3); + h3->Draw("colz"); + h3->GetXaxis()->SetTitle("Frame#"); + h3->GetYaxis()->SetTitle("Signal"); + + cm4->cd(4); + h4->Draw(); + h4->GetXaxis()->SetTitle("Signal [ADC]"); + h4->GetYaxis()->SetTitle("Counts"); + + cm4->cd(5); + h5->Draw(); + h5->GetXaxis()->SetTitle("Signal [ADC]"); + h5->GetYaxis()->SetTitle("Counts"); + + cm4->cd(6); + h6->Draw(); + h6->GetXaxis()->SetTitle("Signal [ADC]"); + h6->GetYaxis()->SetTitle("Counts"); + +// cm4->DrawClone(); +// cm4->Update(); +// cm4->Close(); + cout<<"\rPIXELSIGNALS plotted! "<=28 && (count%1053)<28+64*16 && countframes==11) +// if( (count%1053)>=28 && (count%1053)<28+64*16) +// { +// y = ((count%1053)-28)%64; +// x = ((count%1053)-28)/64; +// +// z1 = a1; +// z2 = a2; +// z3 = a1-a2; +// +// histo1[0]->Fill(z1); +// histo1[1]->Fill(z2); +// histo1[2]->Fill(z3); +// +// histo2[0]->Fill(x,y,z1); +// histo2[1]->Fill(x,y,z2); +// histo2[2]->Fill(x,y,z3); +// +// // cout<< (count%1053)-28 <<"\t"<=1050 && count<1053+50)) +// // if( count%1053==13 ) +// { +// cout<> (7-i)) & 1); +// } +// if(1) {cout<<" ";} +// } +// // cout<<" "; +// // cout<Divide(3,2); +// gStyle->SetOptFit(1011); +// gStyle->SetPalette(1); +// gStyle->SetCanvasColor(0); +// gStyle->SetFrameFillColor(10); +// gStyle->SetOptStat(1); +// +// cm->cd(1); +// histo1[0]->Draw(); +// histo1[0]->GetXaxis()->SetTitle("Signal [ADC]"); +// histo1[0]->GetYaxis()->SetTitle("Entries"); +// cm->Update(); +// cm->cd(2); +// histo1[1]->Draw(); +// histo1[1]->GetXaxis()->SetTitle("Signal [ADC]"); +// histo1[1]->GetYaxis()->SetTitle("Entries"); +// cm->Update(); +// cm->cd(3); +// histo1[2]->Draw(); +// histo1[2]->GetXaxis()->SetTitle("Signal [ADC]"); +// histo1[2]->GetYaxis()->SetTitle("Entries"); +// cm->Update(); +// +// cm->cd(4); +// histo2[0]->Draw("colz"); +// histo2[0]->GetXaxis()->SetTitle("column"); +// histo2[0]->GetYaxis()->SetTitle("row"); +// histo2[0]->GetZaxis()->SetTitle("Signal [ADC]"); +// cm->Update(); +// cm->cd(5); +// histo2[1]->Draw("colz"); +// histo2[1]->GetXaxis()->SetTitle("column"); +// histo2[1]->GetYaxis()->SetTitle("row"); +// histo2[1]->GetZaxis()->SetTitle("Signal [ADC]"); +// cm->Update(); +// cm->cd(6); +// histo2[2]->Draw("colz"); +// histo2[2]->GetXaxis()->SetTitle("column"); +// histo2[2]->GetYaxis()->SetTitle("row"); +// histo2[2]->GetZaxis()->SetTitle("Signal [ADC]"); +// cm->Update(); +} + +//#################################################################### +//#################################################################### + +UInt_t MAPS::littleEndian32(char* RawData, Int_t Pos) { + +// for(int j=3;j>=0;j--) +// { +// char a = RawData[j+Pos]; +// +// int n=CHAR_BIT*sizeof(a); +// +// cout<<" | "; +// for (int i=0;i5 ) + { + cerr<<"ERROR: "< + +class MAPS { + +private: + + TString fInDir; + TString fOutDir; + TString fOrderCode; // If the pixel data is in wrong order use this. You have to implement the class which does the ordering + Int_t fRunNumber; + Int_t fPixelsData; // Number of Pixels found in Raw Data + Int_t fPixels; // Number of Pixels written to fCdsmatrix and used for analysis + Int_t fRows; + Int_t fColumns; + Int_t fMatrix; // Variable to be able to subdivide the Matric according to fOrderCode + Int_t fEventsSum; + Int_t fFile; + + Int_t fFrameNumber; + bool fOk; + bool fSave; + bool fFrameOk; + bool fNoiseOk; + bool fNoiseExt; + Float_t HIT_tmp[29]; + + Int_t* fEvents; + Int_t* fF0matrix; + Int_t* fF1matrix; + Int_t* fCdsmatrix; + Float_t* fNoise; + Float_t* fPedestals; + Int_t fHits; + + frameInfo fFrameInfo;// = new frameInfo; + + ifstream* fInn; + TFile* fOutputFile; + TTree* fHitTree; + TTree* fNoiseTree; + + TString fSystem; + + unsigned short int value1[0x100][0x100]; + unsigned short int value2[0x100][0x100]; + + TH2F* hint1,*hint2; + bool plotHint; + + UInt_t littleEndian32(char* RawData, Int_t Pos); + Short_t littleEndian16(char* RawData, Int_t Pos); + + void initMapsRun( TString, TString, Int_t, Int_t, Int_t, TString, TString, Int_t, bool); + void initSave(); + bool checkConf(UInt_t&, UInt_t&, Int_t&); + bool checkDataFiles( Int_t ); + bool checkDataFile( UInt_t, UInt_t& ); + void filterCommonMode(); + + void reorderMi29a(); + +public: + + MAPS (void); + MAPS ( TString InDir, TString OutDir, Int_t RunNumber, Int_t Rows, Int_t Columns, TString System="USB", TString OrderCode="", Int_t Matrix=0, bool Save=1); + ~MAPS (void); + + bool getFrame (Int_t FrameNumber); + bool getNoise (Int_t Start, Int_t Frames); + bool loadNoise (TString InDir, Int_t RunNumber, Int_t Matrix=0); + bool setNoise (Float_t Noise); + bool setPedestals (Float_t Pedestals); + void hitana (); + + void plotNoise (void); + void plotFrame (Int_t FrameNumber); + void plotHitDis (Int_t Start, Int_t Frames); + void plotSignal (Int_t Start, Int_t Frames); + void plotPixSignal (Int_t Start, Int_t Frames, Int_t Pixel); + + void writeData (); + + Int_t GetNumberRun() { return fRunNumber; } + Int_t GetNumberFrames() { return fEventsSum; } + Int_t GetNumberPixels() { return fPixels; } + Int_t GetNumberRows() { return fRows; } + Int_t GetNumberColumn() { return fColumns; } + Int_t* GetCDSFrame() { return fCdsmatrix; } + Int_t* GetF0Frame() { return fF0matrix; } + Int_t* GetF1Frame() { return fF1matrix; } + Float_t* GetNoise() { return fNoise; } + +}; \ No newline at end of file diff --git a/newCOMBI/help.h b/newCOMBI/help.h new file mode 100644 index 0000000..6ce53da --- /dev/null +++ b/newCOMBI/help.h @@ -0,0 +1,112 @@ +#ifndef HELP_H +#define HELP_H + +#include +#include +#include +#include +#include +#include +#include +#include "TStopwatch.h" + +#define MAXHITS 1000000 + +//#################################################################### + +Int_t print_progress(Float_t ProgressInPercent) { + + Int_t nCharacter = printf("\r ["); + Int_t iBlock; + + for( iBlock=0; iBlockgetNoise(0,1000); + delete aa; + } + + MAPS *a = new MAPS(path,outpath,runnumber,rows,columns,system,ordercode,matrix,save); + + if(loadNoise) + { + a->loadNoise (outpath, runnumberNoise, matrix); + } + else + { + a->getNoise (0,1000); + } + + int start = 0; + int entries = a->GetNumberFrames(); + // entries = 4; + + for(int i=start; igetFrame(i); + a->filterCommonMode(); + a->hitana(); + + progress = (Int_t)(((i-start)*100)/(entries-1)*10); + if(progress!=progress_tmp) { print_progress( (((i-start)*100.)/(entries-1)) ); progress_tmp=progress;} + } + // a->getFrame(58879); + // a->getFrame(58880); + // a->getFrame(60319); + // a->getFrame(60320); + // a->getFrame(60321); + + delete a; + //------------------------------------------------------- + cout<