// }
// int MaxFiles = TMath::Ceil((Float_t) FileTotalEvNbInConfig/FileEvNbInConfig);
// checkDataFiles(MaxFiles);
- cout<<"COLUMNS"<<fColumns<<"ROWS"<<fRows<<endl;
+ // cout<<"COLUMNS"<<fColumns<<"ROWS"<<fRows<<endl;
fOutputFile = new TFile(fRootFile,"READ");
if (fOutputFile->IsZombie())
{
if (fOrderCode == "") { }
else if (fOrderCode == "Mi34") { }
else if (fOrderCode == "Pegasus"){ }
- // else if (fOrderCode == "FSBB") { }
+ // else if (fOrderCode == "FSBB") { }
else if (fOrderCode == "FSBB") { reorderFSBB(); }
else if (fOrderCode == "Mi29a") { reorderMi29a(); }
// else if (fOrderCode == "Mi29b") { reorderMi29b(); }
cout << colorwhite << "----------------------------------" << colorreset << endl;
cout << endl;
}
-
+template <typename arraytype>
+void MAPS::debugStreamVerse(const arraytype* (a), Int_t n, Int_t rows, Int_t precision, float highlightabove) {
+ cout << colorwhite << "----------------------------------" << colorreset << endl;
+
+ for (int irows=0; irows<rows;irows++)
+ {
+ for (int i=0; i<n/rows;i++)
+ {
+ if (a[irows+i*rows] > highlightabove)
+ std::cout << colorgreen;
+ else if ((-1)*a[irows+i*rows] > highlightabove)
+ std::cout << colorred;
+ std::cout.width(precision+5);
+ std::cout << std::fixed;
+ std::cout << std::left << std::setprecision(precision);
+ std::cout << a[i*rows+irows] << colorreset;
+
+
+ }
+ cout << endl<<endl;
+ }
+ cout << colorwhite << "----------------------------------" << colorreset << endl;
+ cout << endl;
+ cout<<rows<<endl;
+}
bool MAPS::regetDynNoise(Int_t Frames) {
Bool_t pedestalhighinthisframe = false;
Bool_t bordercluster=false;
Float_t noisesumincluster=0;
Float_t chargesumincluster=0;
- cout<<"COLUMNS"<<fColumns<<"ROWS"<<fRows<<endl;
+ // cout<<"COLUMNS"<<fColumns<<"ROWS"<<fRows<<endl;
Float_t cdsMatrixSum=0;
Float_t cdsmatrixCorrPed[fPixels];
for(Int_t i=0; i<fPixels; i++)
// Determine clusters around them
for(UInt_t rechargingpixeli=0; rechargingpixeli<rechargePixellist.size(); rechargingpixeli++)
{
+ if(fOrderCode=="FSBB")
+ {
+ seedrow = (rechargePixellist[rechargingpixeli])/fColumns; // row of seed
+ seedcolumn = (rechargePixellist[rechargingpixeli])%fColumns; // column of seed
+ }
+ else
+ {
seedrow = (rechargePixellist[rechargingpixeli])/fColumns; // row of seed
seedcolumn = (rechargePixellist[rechargingpixeli])%fColumns; // column of seed
-
+ }
//Provide 5x5 clusters with CDS - content:
for(Int_t row=0; row<5; row++)
{
if(CHANCE==100)
{
if(fOrderCode=="FSBB")
- {
- if (B < 1 || B > fColumns-2 || A < 1 || A > fRows-2)
- bordercluster = false;
+ {
+ //cout<<fFrameNumber<<"B: "<<B<<"fColumns: "<<fColumns<<"A: "<<A<<" fRows: "<<fRows<<endl;
+ if (B < 1 || B > fColumns-2 || A < 2 || A > fRows-3)
+ {
+ bordercluster = true;
+ // cout<<"border cluster in frame "<<fFrameNumber<<endl;
+ }
else
bordercluster = false;
}
}
else {
cout <<endl <<endl << colorwhite << "---------------- FRAME " << fFrameNumber << " ----------------" << colorreset << endl << endl;
- cout<<"CDS matrix:"<<endl;
- debugStream<>(fCdsmatrix, fPixels, fRows, 0, 39);
+ // cout<<"CDS matrix:"<<endl;
+ debugStreamVerse<>(fCdsmatrix, fPixels, fColumns, 0, 39);
Float_t cdsmatrixCorrPed[fPixels];
for(Int_t i=0; i<fPixels; i++)
{
- cdsmatrixCorrPed[i]=(float)(1.*fCdsmatrix[i]-fPedestals[i]);
+ cdsmatrixCorrPed[i]=(float)(1.*fCdsmatrix[i]-fPedestals[i]);
}
cout<<"CDS matrix minus pedestals:"<<endl;
- // debugStream<>(cdsmatrixCorrPed, fPixels, fRows, 0, 10);
+ debugStreamVerse<>(cdsmatrixCorrPed, fPixels, fColumns, 0, 10);
// cout<<fCdsmatrix[0]<<","<<fCdsmatrix[1]<<","<<fCdsmatrix[2]<<","<<fCdsmatrix[3]<<","<<fCdsmatrix[4]<<","<<fCdsmatrix[5]<<","<<fCdsmatrix[6]<<endl;
// cout<<"Hitted pixel discriminator matrix:"<<endl;
- // debugStream<>(fHittedPixel, fPixels, fRows, 1, 1);
- Double_t cdsmatrixSum;
+ // debugStream<>(fHittedPixel, fPixels, fColumns, 1, 1);
+ Double_t cdsmatrixSum=0;
for(Int_t i=0; i<fPixels; i++)
{
cdsmatrixSum+=cdsmatrixCorrPed[i];
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);
+ // gStyle->SetHistLineWidth(5);
+ // 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 *h1 = new TH1F("Frame 0 vs T" , "Frame 0 vs T" , Frames, Start, Start+Frames);
TH1F *h2 = new TH1F("Frame 1 vs T" , "Frame 1 vs T" , Frames, Start, Start+Frames);
TH1F *h3 = new TH1F("CDS vs T" , "CDS vs T" , Frames, Start, Start+Frames);
// h5->SetBit(TH1::kCanRebin);
// h6->SetBit(TH1::kCanRebin);
// h4->Rebin(k)
-
- for(UInt_t i=Start; i<Start+Frames; i++)
+ for(UInt_t i=0; i<Frames; i++)
{
if(getFrame(i))
{
-// h1->Fill( i,fF0matrix[Pixel]) ;
-// h2->Fill( i,fF1matrix[Pixel]) ;
-// h3->Fill( i,fCdsmatrix[Pixel] );
- h1->SetBinContent( i,fF0matrix[Pixel]) ;
+ // h1->Fill( i,fF0matrix[Pixel]) ;
+ // h2->Fill( i,fF1matrix[Pixel]) ;
+ // h3->Fill( i,fCdsmatrix[Pixel] );
+ Double_t cdsFrameSum=0;
+ for(UInt_t iPixel=0; iPixel<fPixels; iPixel++)
+ {
+ cdsFrameSum+=fCdsmatrix[iPixel]-fPedestals[iPixel];
+ }
+ h1->SetBinContent( i,cdsFrameSum) ;
+ //h1->SetBinContent( i,fF0matrix[Pixel]) ;
h2->SetBinContent( i,fF1matrix[Pixel]) ;
h3->SetBinContent( i,fCdsmatrix[Pixel] );
+
+ }
+ }
+
+ for(UInt_t i=Start; i<Start+Frames; i++)
+ {
+ if(getFrame(i))
+ {
+ // h1->Fill( i,fF0matrix[Pixel]) ;
+ // h2->Fill( i,fF1matrix[Pixel]) ;
+ // h3->Fill( i,fCdsmatrix[Pixel] );
+
h4->Fill( fF0matrix[Pixel] );
h5->Fill( fF1matrix[Pixel] );
cm4->cd(1);
// h1->Draw("colz");
- h1->Draw("");
+ h1->SetLineStyle(1);
+ h1->Draw("ARR");
+
h1->GetXaxis()->SetTitle("Frame#");
h1->GetYaxis()->SetTitle("Signal");
cm4->cd(2);
- h2->Draw("");
+ h2->Draw("c");
h2->GetXaxis()->SetTitle("Frame#");
h2->GetYaxis()->SetTitle("Signal");
cm4->cd(3);
- h3->Draw("");
+ h3->Draw("c");
h3->GetXaxis()->SetTitle("Frame#");
h3->GetYaxis()->SetTitle("Signal");
}
}
//####################################################################
-void MAPS::reorderFSBB() {
+void MAPS::reorderFSBB2() {
Float_t CDSMATRIX [fPixels];
Int_t F0MATRIX [fPixels];
for(Int_t iPixelInZeile=0; iPixelInZeile<subRows; iPixelInZeile++)
{
// cout<<iPixelInZeile<<":"<<(4+iOutChannel)*subColumns+iPixelInZeile<<"-";
- a0[iOutChannel][iPixelInZeile]=CDSMATRIX [iOutChannel*subRows+iPixelInZeile];
- a1[iOutChannel][iPixelInZeile]=CDSMATRIX [(4+iOutChannel)*subRows+iPixelInZeile];//4+iOutChannel, because this is A1, which is shifted by four channels of A0
+ a0[iOutChannel][iPixelInZeile]=CDSMATRIX [iOutChannel+4*subRows+iPixelInZeile*subColumns];
+ a1[iOutChannel][iPixelInZeile]=CDSMATRIX [(iOutChannel)+iPixelInZeile*subColumns];//4+iOutChannel, because this is A1, which is shifted by four channels of A0
}
}
//debugStream<>(tMatrix, fPixels, fColumns, 0, 20);
// exit(0);
}
+void MAPS::reorderFSBB() {
+
+ Float_t CDSMATRIX [fPixels];
+ Int_t F0MATRIX [fPixels];
+ Int_t F1MATRIX [fPixels];
+ for(Int_t i=0; i<fPixels; i++)
+ {
+ CDSMATRIX [i] = fCdsmatrix[i];
+ F0MATRIX [i] = fF0matrix [i];
+ F1MATRIX [i] = fF1matrix [i];
+ }
+
+ int var[8]={0,4,1,5,2,6,3,7};//A0-0,A1-0,A0-1,A1-1,A0-2,A1-2,A0-3,A1-3, one line goes from 0..3 (which is A0), then newline, the second line goes from 4-7 (which is A1)
+ for(Int_t j=0; j<8; j++)
+ {
+ int count=0;
+ for(Int_t i=0; i<208; i++)
+ {
+ fCdsmatrix[count+var[j]] = CDSMATRIX [i+208*j];
+ fF0matrix[count+var[j]] = F0MATRIX [i+208*j];
+ fF1matrix[count+var[j]] = F1MATRIX [i+208*j];
+
+ count+=8;
+ }
+ }
+ // for(Int_t iPixel=0; iPixel<fPixels;iPixel++)
+ // {
+ // cout<<fCdsmatrix[iPixel]<<",";
+
+ // }
+ // debugStreamVerse<>(fCdsmatrix, fPixels, 4, 0, 20);
+ // for(Int_t iPixel=0; iPixel<fPixels;iPixel++)
+ // {
+ // fCdsmatrix[iPixel]=iPixel;
+
+ // }
+ // debugStreamVerse<>(fCdsmatrix, fPixels, 4, 0, 20);
+ // exit(0);
+}
//####################################################################
void MAPS::reorderFSBBSicherung() {
systemparam systemparamUSB (2800/*maxbin*/,2800/4/*nbins*/, 25/*vetothreshold*/, 10/*maxbinnoise*/, 100/*nbinsnoise*/);
systemparam systemparamPegasus (2800,2800/2,20,10,100);
systemparam systemparamPXI (800*16,800,75,150,150);
- systemparam systemparamFSBB (2800,2800/4,25,10,100);
+ systemparam systemparamFSBB (2000,2000,20,10,100);
if (labbook.system.EqualTo("USB") && labbook.chipGen.EqualTo("Mi34") )
cursystemparam = systemparamUSB;
else if (labbook.system.EqualTo("USB") && labbook.chipGen.EqualTo("FSBB") )
- cursystemparam = systemparamUSB;
+ cursystemparam = systemparamFSBB;
else if (labbook.system.EqualTo("PXI")) // && labbook.chipGen.EqualTo("34") )
cursystemparam = systemparamPXI;
else if (labbook.system.EqualTo("Pegasus")) // && labbook.chipGen.EqualTo("34") )
processed->InitialDynNoise();
int start = 0;
int nframes = processed->GetNumberFrames();
- // for(int i=0; i<1000000;i++) // TODO remove 100000 run 342272
+ // for(int i=0; i<1000000;i++) // TODO remove 100000 run 342272
for(int i=0; i<nframes;i++) // TODO remove 100000 run 342272
{
// cout << "getframe " << i << endl;
processed->filterCommonMode();
// cout << "hitana " << i << endl;
processed->hitana();
+ // if(processed->GetNumberHits()>0)
+ // processed->plotFrame(i);
// cout << "regetDynNoise " << endl;
if (dynamicalNoise)
processed->regetDynNoise();
return 1;
}
-Bool_t Run::analyzeFrame(Int_t frame)
+Bool_t Run::analyzeFrame(Int_t frame, Int_t pixel)
{
+cout<<"ANALYZE FRAME "<<frame<<" AND PIXEL "<<pixel<<endl;
if (!error)
{
processed = new MAPS(this);
processed->filterCommonMode();
processed->hitana();
processed->plotFrame(frame);
+ processed->plotPixSignal(0, frame+1000,pixel);
+ // cout<<"CDS-Matrix"<<endl;
+ // for(int i=0;i<20;i++)
+ // {
+ // processed->getFrame(frame-10+i);
+ // cout<<processed->GetCDSFrame()[78]<<"\t";
+ // }
+ // cout<<endl;
+ // cout<<"F0-Matrix"<<endl;
+ // for(int i=0;i<20;i++)
+ // {
+ // processed->getFrame(frame-10+i);
+ // cout<<processed->GetF0Frame()[78]<<"\t";
+ // }
+ // cout<<endl;
+ // cout<<"F1-Matrix"<<endl;
+ // for(int i=0;i<20;i++)
+ // {
+ // processed->getFrame(frame-10+i);
+ // cout<<processed->GetF1Frame()[78]<<"\t";
+ // }
+ // cout<<endl;
delete processed;
return 0;
}
void Run::selectSubMatrixFSBB(TString matrixname)
{
-
- if (matrixname.EqualTo("A0")) {
- setSubMatrixBorders(0, cursensorinfo.columns/2-2, 0, cursensorinfo.rows, false);
+ if (matrixname.EqualTo("A0")&& labbook.chipGen.EqualTo("FSBB")) {
+ setSubMatrixBorders(0, cursensorinfo.columns, 0, cursensorinfo.rows/2-2, false);
runcodesuffix += "_A0_";
humanreadablesuffix += "A0, ";
}
- else if (matrixname.EqualTo("A1")) {
- setSubMatrixBorders(cursensorinfo.columns/2+2, cursensorinfo.columns, 0, cursensorinfo.rows, false);
+ else if (matrixname.EqualTo("A1")&& labbook.chipGen.EqualTo("FSBB")) {
+ setSubMatrixBorders(0, cursensorinfo.columns, cursensorinfo.rows/2+2, cursensorinfo.rows, false);
runcodesuffix += "_A1_";
humanreadablesuffix += "A1, ";
}
Bool_t Run::binNoise(HistogramType* oneHistogramClass)
{
- for (Int_t lauf=0; lauf<8; lauf++) {
Float_t noise;
TBranch* noiseBranch;
Double_t const probabilities[] = {0.3415/2, 0.5, 1-0.3415/2}; // sigma/2 from gaus to the left and to the right //{0.17, 0.5, 1-0.17};
processed->fNoiseTree->SetBranchAddress("noise", &noise, &noiseBranch);
// for (Int_t cnt=0; cnt<processed->fNoiseTree->GetEntries(); cnt++) {
- for (Int_t cnt=208*lauf; cnt<208*(lauf+1); cnt++) {
+ for (Int_t cnt=submatrix_y_start*submatrix_x_end; cnt<submatrix_y_end*submatrix_x_end; cnt++) {//Achtung, die Randpixel zwischen den Submatrizen sind aufgrund der Struktur submatrix_y_start und submatrix_y_end ebenfalls rausgenommen
processed->fNoiseTree->GetEntry(cnt);
oneHistogramClass->Noise->Fill(noise);
}
oneHistogramClass->avgNoise = noisequantiles[1];
oneHistogramClass->avgNoisePlus = noisequantiles[2] - noisequantiles[1];
oneHistogramClass->avgNoiseMinus = noisequantiles[1] - noisequantiles[0];
- cout<<"Channel: "<<lauf<<"Noise :"<<oneHistogramClass->avgNoise<<endl;
- }
+ //cout<<"Channel: "<<lauf<<"Noise :"<<oneHistogramClass->avgNoise<<endl;
+
// if (labbook.system == "PXI")
// for (int j=0; j<3; j++)
// noisequantiles[j] /= 16.0; // TODO analyze PXI scales
for(int iPixel=0;iPixel<pixels;iPixel++)
fPixelFakeHits[iPixel]=1; //Initiate fPixelFakeHits so that all pixel are accepted (=1), will be overwritten, if getPixelWithFakehits is executed
getPixelWithFakehits();
+ Int_t foundSuspFrame=0;
+ // for (Int_t framei=0; framei<100000; framei++) // loop over all frames
for (Int_t framei=0; framei<processed->fHitTree->GetEntries(); framei++) // loop over all frames
{
processed->fHitTree->GetEntry(framei);
}
pixelnoisesum=TMath::Sqrt(pixelnoisesum);
- if (pixelchargesum>5.0*pixelnoisesum&& fPixelFakeHits[processed->fFrameInfo.pixel[hiti]+1]>0)
- {
+ //if (pixelchargesum>2.0*pixelnoisesum&& fPixelFakeHits[processed->fFrameInfo.pixel[hiti]+1]>0)
+ if (pixelchargesum>2.0*pixelnoisesum)
+ {
histogramFSBB->numberofhits++;
// cout<<framei<<":"<<processed->fFrameInfo.n[12][hiti]<<endl;
histogramFSBB->Seed->Fill(processed->fFrameInfo.p[12][hiti]);
histogramFSBB->Sum->Fill(pixelSum);
- if (TMath::Abs(notSeedSum) < cursystemparam.vetothreshold && (labbook.source.Contains("Fe")||labbook.source.Contains("Cd")))
- histogramFSBB->Veto->Fill(processed->fFrameInfo.p[12][hiti]); // histogram with the single pixel
+ // cout<<framei<<"Pixelnr."<<processed->fFrameInfo.pixel[hiti]<<" Charge in Seed: "<<processed->fFrameInfo.p[12][hiti]<<" Charge in Sum: "<<pixelSum<<endl;
+ // if (TMath::Abs(notSeedSum) < cursystemparam.vetothreshold && (labbook.source.Contains("Fe")||labbook.source.Contains("Cd")))
+ // histogramFSBB->Veto->Fill(processed->fFrameInfo.p[12][hiti]); // histogram with the single pixel
+ histogramFSBB->Veto->Fill(processed->fFrameInfo.pixel[hiti]);
}
- if (pixelchargesum>5.0*pixelnoisesum)
+ if (pixelchargesum<265&& fPixelFakeHits[processed->fFrameInfo.pixel[hiti]+1]>0&&processed->fFrameInfo.p[12][hiti]>40)
{
+ foundSuspFrame++;
histogramFSBB2->numberofhits++;
- // cout<<framei<<":"<<processed->fFrameInfo.n[12][hiti]<<endl;
+ // cout<<framei<<":"<<processed->fFrameInfo.n[12][hiti]<<endl;
histogramFSBB2->Seed->Fill(processed->fFrameInfo.p[12][hiti]);
histogramFSBB2->Sum->Fill(pixelSum);
- if (TMath::Abs(notSeedSum) < cursystemparam.vetothreshold && (labbook.source.Contains("Fe")||labbook.source.Contains("Cd")))
- histogramFSBB->Veto->Fill(processed->fFrameInfo.p[12][hiti]); // histogram with the single pixel
+ histogramFSBB2->Veto->Fill(processed->fFrameInfo.pixel[hiti]); // histogram with the single pixel
+ // if(processed->fFrameInfo.p[12][hiti]>20&&processed->fFrameInfo.p[12][hiti]<60)
+ // cout<<framei<<"Pixelnr."<<processed->fFrameInfo.pixel[hiti]<<" Charge in Seed: "<<processed->fFrameInfo.p[12][hiti]<<" Charge in Sum: "<<pixelSum<<endl;
}
//FSBB CODE END
}
}
}
+ cout<<"Found suspicious frames "<<foundSuspFrame<<endl;
// gROOT->SetBatch(kTRUE);
for (vector<HistogramType*>::iterator curHistogramClass = HistogramClassVector.begin(); curHistogramClass != HistogramClassVector.end(); curHistogramClass++) {
{
sourceIntensity=2;
}
+ cout<<"Pixel 321"<<histoPixel->GetBinContent(321)<<endl;
+ cout<<"!!!!!!!!!!!!!!!!Pixel 322"<<histoPixel->GetBinContent(322)<<"must be larger than"<<fakehitrate*sourceIntensity*labbook.frames_foundDB<<endl;
for(int ipixel=0;ipixel<pixels;ipixel++)
{
if(histoPixel->GetBinContent(ipixel)>fakehitrate*sourceIntensity*labbook.frames_foundDB)//show only pixels with a fake hit rate above 1e-5
+ //if(histoPixel->GetBinContent(ipixel)>1000)//show only pixels with a fake hit rate above 1e-5
{
fcountPixelFakeHits++;
fPixelFakeHits[ipixel]=0;//pixel is a fake hit pixel