]> jspc29.x-matter.uni-frankfurt.de Git - radhard.git/commitdiff
FSBB nach Version A
authorDennis Doering <doering@physik.uni-frankfurt.de>
Fri, 11 Sep 2015 13:20:25 +0000 (15:20 +0200)
committerDennis Doering <doering@physik.uni-frankfurt.de>
Fri, 11 Sep 2015 13:20:25 +0000 (15:20 +0200)
0 208 416 624
1
2
207
832
833
Weitere Versuche als reOrder drin aber nicht genutzt

MABS_run_analyzer/MAPS.c
MABS_run_analyzer/MAPS.h
MABS_run_analyzer/Run.c
MABS_run_analyzer/Run.h

index d0e949630bccf8d35f770142385b9dc149bf06a0..3490fde462a7fce3ffd7586332d2f8b9897c6853 100644 (file)
@@ -1549,26 +1549,49 @@ void MAPS::hitana() {
             // cout << endl;
             
             //Check seeds (whether highest entry in cluster):
-            for(Int_t i=6; i<19; i++) // why not over full cluster? (I=0 i<25 TODO
-            {
-                if          ( (i!=12) && (pixelchargeincluster[i] > pixelchargeincluster[12]) )               {
-                    CHANCE=0;                    
-//                     cout << "kill cluster: " << Hitlist[hit] << " with ADC: " << pixelchargeincluster[12] << endl;
-                    break;
-                }
-                // maybe this is unnecessary, if upper if clause is a >= comparison
-                else if     ( (i!=12) && (pixelchargeincluster[i] == pixelchargeincluster[12]) && i>12 )      {
-                    cout << "WARNING: next pixel value identical to precessor, frame : " << fFrameInfo.frame << ", values: " << pixelchargeincluster[i] << " == " << pixelchargeincluster[12] << endl;
-                    CHANCE=0;    //NOTE: potential error source
-                    break;
-                }
-                else {
-                    CHANCE=100;
-                    if(i%5==3) {
-                        i+=2;
-                    };
-                }
-            }
+                       if(fOrderCode=="FSBB")
+                       {
+                               for(Int_t i=0; i<25; i++) // why not over full cluster? (I=0 i<25 TODO
+                               {
+                                       if          ( (i!=12) && (pixelchargeincluster[i] > pixelchargeincluster[12]) )               {
+                                               CHANCE=0;                    
+                                       //       cout << "kill cluster: " << Hitlist[hit] << " with ADC: " << pixelchargeincluster[12] << endl;
+                                               break;
+                                       }
+                                       // maybe this is unnecessary, if upper if clause is a >= comparison
+                                       else if     ( (i!=12) && (pixelchargeincluster[i] == pixelchargeincluster[12]) && i>12 )      {
+                                               cout << "WARNING: next pixel value identical to precessor, frame : " << fFrameInfo.frame << ", values: " << pixelchargeincluster[i] << " == " << pixelchargeincluster[12] << endl;
+                                               CHANCE=0;    //NOTE: potential error source
+                                               break;
+                                       }
+                                       else {
+                                               CHANCE=100;
+                                       }
+                               }
+                       }
+                       else
+                       {
+                               for(Int_t i=6; i<19; i++) // why not over full cluster? (I=0 i<25 TODO
+                               {
+                                       if          ( (i!=12) && (pixelchargeincluster[i] > pixelchargeincluster[12]) )               {
+                                               CHANCE=0;                    
+                               //               cout << "kill cluster: " << Hitlist[hit] << " with ADC: " << pixelchargeincluster[12] << endl;
+                                               break;
+                                       }
+                                       // maybe this is unnecessary, if upper if clause is a >= comparison
+                                       else if     ( (i!=12) && (pixelchargeincluster[i] == pixelchargeincluster[12]) && i>12 )      {
+                                               cout << "WARNING: next pixel value identical to precessor, frame : " << fFrameInfo.frame << ", values: " << pixelchargeincluster[i] << " == " << pixelchargeincluster[12] << endl;
+                                               CHANCE=0;    //NOTE: potential error source
+                                               break;
+                                       }
+                                       else {
+                                               CHANCE=100;
+                                               if(i%5==3) {
+                                                       i+=2;
+                                               };
+                                       }
+                               }
+                       }
             
             
             
@@ -1577,6 +1600,7 @@ void MAPS::hitana() {
             //Begin: loop evaluate true seeds:
             if(CHANCE==100)
             {
+                       //cout<<"CLUSTER ACCEPTED"<<Hitlist[hit]<< " with ADC: " << pixelchargeincluster[12]<<endl;
                        if(fOrderCode=="FSBB")
                        {
                                if (B < 2 || B > fColumns-3 || A < 1 || A > fRows-2)
@@ -1591,26 +1615,26 @@ void MAPS::hitana() {
                 else
                     bordercluster = false;
                        }
-                for(Int_t row=0; row<5; row++)
-                {
-                    for(Int_t column=0; column<5; column++)
-                    {
-                        if          ( (row==0) && (A<2) )                   { }
-                        else if     ( (row==1) && (A<1) )                   { }
-                        else if     ( (row==3) && (A>= (fRows-1)) )         { }
-                        else if     ( (row==4) && (A>= (fRows-2)) )         { }
-                        else
-                        {
-                            if      ( (column==0) && (B<2) )                { }
-                            else if ( (column==1) && (B==0) )               { }
-                            else if ( (column==3) && (B==fColumns-1))       { }
-                            else if ( (column==4) && (B>fColumns-3))        { }
-                            else                                            {
-                                fHittedPixel[Hitlist[hit]+(row-2)*fColumns+(column-2)] = bordercluster?-1:1;
-                            }
-                        }
-                    }
-                }
+                       for(Int_t row=0; row<5; row++)
+                       {
+                               for(Int_t column=0; column<5; column++)
+                               {
+                                       if          ( (row==0) && (A<2) )                   { }
+                                       else if     ( (row==1) && (A<1) )                   { }
+                                       else if     ( (row==3) && (A>= (fRows-1)) )         { }
+                                       else if     ( (row==4) && (A>= (fRows-2)) )         { }
+                                       else
+                                       {
+                                               if      ( (column==0) && (B<2) )                { }
+                                               else if ( (column==1) && (B==0) )               { }
+                                               else if ( (column==3) && (B==fColumns-1))       { }
+                                               else if ( (column==4) && (B>fColumns-3))        { }
+                                               else                                            {
+                                                       fHittedPixel[Hitlist[hit]+(row-2)*fColumns+(column-2)] = bordercluster?-1:1;
+                                               }
+                                       }
+                               }
+                       }
           //       cout<<"Hitted pixel discriminator matrix:"<<endl;
           //       debugStream<>(fHittedPixel, fPixels, fColumns, 1, 1);
                 if (bordercluster)
@@ -1639,7 +1663,7 @@ void MAPS::hitana() {
                     // if cluster charge > clusternoise * const
                                        if(fOrderCode=="FSBB")
                                        {
-                                               if (1.0*chargesumincluster4 > noisesumincluster4*6.0)
+                                               if (1.0*chargesumincluster4 > noisesumincluster4*5.0)
                                                        fFrameInfo.pixelthreshold[fHits] = Hitlist[hit];
                                                else
                                                        fFrameInfo.pixelthreshold[fHits] = 0;
@@ -1759,19 +1783,36 @@ void MAPS::plotFrame(Int_t FrameNumber) {
         cout<<"Frame could not be loaded!"<<endl;
     }
     else {
+       
         cout <<endl <<endl << colorwhite << "---------------- FRAME " << fFrameNumber << " ----------------" << colorreset << endl << endl;
         cout<<"CDS matrix:"<<endl;
-        debugStream<>(fCdsmatrix, fPixels, fColumns, 0, 39);
+       // debugStream<>(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]);
                }
-               debugStream<>(cdsmatrixCorrPed, fPixels, fColumns, 0, 10);
+       //      debugStream<>(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, fColumns, 1, 1);
-        
+        //cout<<"Hitted pixel discriminator matrix:"<<endl;
+        //debugStream<>(fHittedPixel, fPixels, fColumns, 1, 1);
+               
+        cout << colorred <<"Accepted hit cluster:"<<endlr;
+               for (Int_t hiti = 0; hiti < fHits; hiti++)
+               {
+                       for(Int_t row=0; row<5; row++)
+                       {
+                               for(Int_t column=0; column<5; column++)
+                               {
+                                       std::cout.width(10);
+                                       std::cout << std::fixed;
+                                       std::cout << std::left << std::setprecision(2) << fFrameInfo.p[row*5+column][hiti];
+                               }
+                               cout << endl;
+                       }
+                       cout << endl;
+               }
+        /*
         TCanvas* cm1 = new TCanvas(Form("Frame %d",FrameNumber),Form("Frame %d",FrameNumber),50,100,1200,800);
         cm1->Divide(2,3);
         gStyle->SetOptFit(1011);
@@ -1848,6 +1889,7 @@ void MAPS::plotFrame(Int_t FrameNumber) {
         cm1->Update();
         cout<<"\rPIXELMATRIX plotted!                           "<<endl;
         cout<<"-------------------"<<endl;
+               */
     }
 }
 
@@ -2416,9 +2458,20 @@ void MAPS::reorderMi29a() {
         }
     }
 }
-
 //####################################################################
-void MAPS::reorderFSBB() {
+void MAPS::reorderFSBB2() {
+                       //fCdsMatrix from datastream: from 0,1,2,3,4,5 
+                       // Mean in electronic channels:
+                       // 0 1 2 3 4 5 6 7
+                       // 8 9 10 11 12 13 14 15
+                       //...
+                       // In real:
+                       // 0 1 2 3 
+                       // 4 5 6 7 
+                       //8 9 10 11
+                       // So data stream looks like: 0 4 8... 1 5 9 
+                       
+                       
                        
                Float_t CDSMATRIX       [fPixels];
         Int_t F0MATRIX [fPixels];
@@ -2432,26 +2485,189 @@ void MAPS::reorderFSBB() {
                fRows           = 4;
         fColumns       = 416;
         fPixels                = fRows*fColumns;
-       //      debugStream(CDSMATRIX, fPixels, 208, 0, 39);
+       //      debugStream(CDSMATRIX, fPixels, 208, 0, 2000);
        
                Int_t subRows = 4;
                Int_t subColumns = 208;
                Int_t a0[subRows][subColumns];
                Int_t a1[subRows][subColumns];
                Int_t aMerge[fRows][fColumns];
-
+       //      cout<<"CDS matrix:"<<endl;
+     //   debugStream<>(fCdsmatrix, fPixels, 4*416, 0, 39);
+               //Divide CDSMATRIX in the channels. First pixel is from A0-0, then A0-1, then A0-2, then A0-3, then A1-0, then A1-1, then A1-2, then A1-3, then second pixel is from A0-0, then...
+               // for(Int_t iPixelInZeile=0; iPixelInZeile<subColumns; iPixelInZeile++)
+        // {
+                       // for(Int_t iOutChannel=0; iOutChannel<subRows; iOutChannel++)
+                       // {    
+       //              cout<<iPixelInZeile<<":"<<(4+iOutChannel)+iPixelInZeile*subRows*2<<endl;
+                          // a0[iOutChannel][iPixelInZeile]=CDSMATRIX  [iOutChannel+iPixelInZeile*subRows*2];
+                          // a1[iOutChannel][iPixelInZeile]=CDSMATRIX  [(4+iOutChannel)+iPixelInZeile*subRows*2];//4+iOutChannel, because this is A1, which is shifted by four channels of A0
+                       // }
+               // }
+               // for(Int_t i=0; i<208; i++)
+        // {
+          // cout<< a0[0][i]<<",";
+        // }
+               // cout<<endl;
                //Divide CDSMATRIX in the channels. First 208 pixels are from A0-0, then A0-1, then A0-2, then A0-3, then A1-0, then A1-1, then A1-2, then A1-3
                 for(Int_t iOutChannel=0; iOutChannel<subRows; iOutChannel++)
+                {
+                       for(Int_t iPixelInZeile=0; iPixelInZeile<subColumns; iPixelInZeile++)
+                       {
+                       //      cout<<iPixelInZeile<<":"<<(4+iOutChannel)*subColumns+iPixelInZeile<<"-";
+                          a0[iOutChannel][iPixelInZeile]=CDSMATRIX     [iOutChannel+iPixelInZeile*8];
+                          a1[iOutChannel][iPixelInZeile]=CDSMATRIX     [(4+iOutChannel)+iPixelInZeile*8];//4+iOutChannel, because this is A1, which is shifted by four channels of A0
+                       }
+                       
+                       
+                       // Start Filter CommonMode
+                       /*Float_t       CommonModeInRow = 0;
+                       bool warning=false;
+                       CommonModeInRow = TMath::Median(subColumns, a0[iOutChannel]); // Don't use mean, consider hitted pixel !
+                       if (CommonModeInRow < 0)
+                               plus++;
+                       else
+                               minus++;
+                       
+                       if(TMath::Abs(CommonModeInRow)>0) // TODO better warning criteria
+                       {
+                               warning = true;
+                       }
+                       if(warning) { cout<<"\rFrame: "<<fFrameNumber<< " row: " << iOutChannel << " Median of row: " << CommonModeInRow <<  " --> Common Mode suspiciously high!               "<<endl; 
+                                debugStream<>(fCdsmatrix, fPixels, fColumns, 0, 20);
+                               debugStream<>(a0[iOutChannel], subColumns, subColumns, 1, 20);
+                       }
+
+                       for(int column=0; column<subColumns; column++ )
+                       {
+                               a0[iOutChannel][column ] -= CommonModeInRow;
+                       }
+                       // End Filter CommonMode*/
+               }
+               
+                // for(Int_t i=0; i<208; i++)
+        // {
+          // cout<< a0[0][i]<<",";
+        // }
+               // cout<<endl;
+                // for(Int_t i=0; i<208; i++)
+        // {
+          // cout<< a1[3][i]<<",";
+        // }
+               // cout<<endl;
+               
+               // for(Int_t iOutChannel=0; iOutChannel<subRows; iOutChannel++)
+        // {
+                       // for(Int_t iMerge2channels=0; iMerge2channels<subColumns;iMerge2channels++)
+                       // {
+               //      Merge A0-0[0],A1-0[0],A0-0[1],A1-0[1],A0-0[2],A1-0[2],... output is an array of 4 geometrically columns
+                               // aMerge[iOutChannel][iMerge2channels*2]=a0[iOutChannel][iMerge2channels];//A0-iOutChannel[iMerge2channels]
+                               // aMerge[iOutChannel][iMerge2channels*2+1]=a1[iOutChannel][iMerge2channels];//A1-iOutChannel[iMerge2channels]
+                       // }
+               // }
+               for(Int_t iOutChannel=0; iOutChannel<subRows; iOutChannel++)
+        {
+                       for(Int_t iMerge2channels=0; iMerge2channels<subColumns;iMerge2channels++)
+                       {
+                       //Merge A0-0[0],A1-0[0],A0-0[1],A1-0[1],A0-0[2],A1-0[2],... output is an array of 4 geometrically columns
+                               aMerge[iOutChannel][iMerge2channels*2]=a0[iOutChannel][iMerge2channels];//A0-iOutChannel[iMerge2channels]
+                               aMerge[iOutChannel][iMerge2channels*2+1]=a1[iOutChannel][iMerge2channels];//A1-iOutChannel[iMerge2channels]
+                       }
+               }
+               
+               for(Int_t iOutChannel=0; iOutChannel<fRows; iOutChannel++)
+               {
+                       for(Int_t iPixel=0; iPixel<fColumns;iPixel++)
+                       { 
+                               fCdsmatrix[iOutChannel*fColumns+iPixel]=aMerge[iOutChannel][iPixel];//Write the merged data in fCdsmatrix, which is 1dim array (standard) 
+                               
+                       }
+               }
+               for(Int_t iPixel=0; iPixel<fPixels;iPixel++)
+                       { 
+                       //      cout<<fCdsmatrix[iPixel]<<","; 
+                               
+                       }
+               
+}
+//####################################################################
+void MAPS::reorderFSBB3() {
+                       
+               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];
+        }
+               fRows           = 4;
+        fColumns       = 416;
+        fPixels                = fRows*fColumns;
+       //      debugStream(CDSMATRIX, fPixels, 208, 0, 2000);
+       
+               Int_t subRows = 4;
+               Int_t subColumns = 208;
+               Int_t a0[subRows][subColumns];
+               Int_t a1[subRows][subColumns];
+               Int_t aMerge[fRows][fColumns];
+       //      cout<<"CDS matrix:"<<endl;
+     //   debugStream<>(fCdsmatrix, fPixels, 4*416, 0, 39);
+               //Divide CDSMATRIX in the channels. First pixel is from A0-0, then A0-1, then A0-2, then A0-3, then A1-0, then A1-1, then A1-2, then A1-3, then second pixel is from A0-0, then...
+               // for(Int_t iPixelInZeile=0; iPixelInZeile<subColumns; iPixelInZeile++)
+        // {
+                       // for(Int_t iOutChannel=0; iOutChannel<subRows; iOutChannel++)
+                       // {    
+       //              cout<<iPixelInZeile<<":"<<(4+iOutChannel)+iPixelInZeile*subRows*2<<endl;
+                          // a0[iOutChannel][iPixelInZeile]=CDSMATRIX  [iOutChannel+iPixelInZeile*subRows*2];
+                          // a1[iOutChannel][iPixelInZeile]=CDSMATRIX  [(4+iOutChannel)+iPixelInZeile*subRows*2];//4+iOutChannel, because this is A1, which is shifted by four channels of A0
+                       // }
+               // }
+               // for(Int_t i=0; i<208; i++)
+        // {
+          // cout<< a0[0][i]<<",";
+        // }
+               // cout<<endl;
+               //Divide CDSMATRIX in the channels. First 208 pixels are from A0-0, then A0-1, then A0-2, then A0-3, then A1-0, then A1-1, then A1-2, then A1-3
+                for(Int_t iOutChannel=0; iOutChannel<subRows; iOutChannel++)
+                {
                        for(Int_t iPixelInZeile=0; iPixelInZeile<subColumns; iPixelInZeile++)
                        {
+                       //      cout<<iPixelInZeile<<":"<<(4+iOutChannel)*subColumns+iPixelInZeile<<"-";
                           a0[iOutChannel][iPixelInZeile]=CDSMATRIX     [iOutChannel*subColumns+iPixelInZeile];
                           a1[iOutChannel][iPixelInZeile]=CDSMATRIX     [(4+iOutChannel)*subColumns+iPixelInZeile];//4+iOutChannel, because this is A1, which is shifted by four channels of A0
                        }
+                       
+                       
+                       // Start Filter CommonMode
+                       /*Float_t       CommonModeInRow = 0;
+                       bool warning=false;
+                       CommonModeInRow = TMath::Median(subColumns, a0[iOutChannel]); // Don't use mean, consider hitted pixel !
+                       if (CommonModeInRow < 0)
+                               plus++;
+                       else
+                               minus++;
+                       
+                       if(TMath::Abs(CommonModeInRow)>0) // TODO better warning criteria
+                       {
+                               warning = true;
+                       }
+                       if(warning) { cout<<"\rFrame: "<<fFrameNumber<< " row: " << iOutChannel << " Median of row: " << CommonModeInRow <<  " --> Common Mode suspiciously high!               "<<endl; 
+                                debugStream<>(fCdsmatrix, fPixels, fColumns, 0, 20);
+                               debugStream<>(a0[iOutChannel], subColumns, subColumns, 1, 20);
+                       }
+
+                       for(int column=0; column<subColumns; column++ )
+                       {
+                               a0[iOutChannel][column ] -= CommonModeInRow;
+                       }
+                       // End Filter CommonMode*/
                }
+               
                 // for(Int_t i=0; i<208; i++)
         // {
-          // cout<< a0[3][i]<<",";
+          // cout<< a0[0][i]<<",";
         // }
                // cout<<endl;
                 // for(Int_t i=0; i<208; i++)
@@ -2460,6 +2676,15 @@ void MAPS::reorderFSBB() {
         // }
                // cout<<endl;
                
+               // for(Int_t iOutChannel=0; iOutChannel<subRows; iOutChannel++)
+        // {
+                       // for(Int_t iMerge2channels=0; iMerge2channels<subColumns;iMerge2channels++)
+                       // {
+               //      Merge A0-0[0],A1-0[0],A0-0[1],A1-0[1],A0-0[2],A1-0[2],... output is an array of 4 geometrically columns
+                               // aMerge[iOutChannel][iMerge2channels*2]=a0[iOutChannel][iMerge2channels];//A0-iOutChannel[iMerge2channels]
+                               // aMerge[iOutChannel][iMerge2channels*2+1]=a1[iOutChannel][iMerge2channels];//A1-iOutChannel[iMerge2channels]
+                       // }
+               // }
                for(Int_t iOutChannel=0; iOutChannel<subRows; iOutChannel++)
         {
                        for(Int_t iMerge2channels=0; iMerge2channels<subColumns;iMerge2channels++)
@@ -2469,14 +2694,271 @@ void MAPS::reorderFSBB() {
                                aMerge[iOutChannel][iMerge2channels*2+1]=a1[iOutChannel][iMerge2channels];//A1-iOutChannel[iMerge2channels]
                        }
                }
+               
                for(Int_t iOutChannel=0; iOutChannel<fRows; iOutChannel++)
                {
                        for(Int_t iPixel=0; iPixel<fColumns;iPixel++)
                        { 
                                fCdsmatrix[iOutChannel*fColumns+iPixel]=aMerge[iOutChannel][iPixel];//Write the merged data in fCdsmatrix, which is 1dim array (standard) 
+                               
                        }
                }
+               for(Int_t iPixel=0; iPixel<fPixels;iPixel++)
+                       { 
+                       //      cout<<fCdsmatrix[iPixel]<<","; 
+                               
+                       }
+               //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];
+        }
+               fRows           = 4;
+        fColumns       = 416;
+        fPixels                = fRows*fColumns;
+       //      debugStream(CDSMATRIX, fPixels, 208, 0, 2000);
+       
+               Int_t subRows = 4;
+               Int_t subColumns = 208;
+               Int_t a0[subRows][subColumns];
+               Int_t a1[subRows][subColumns];
+               Int_t aMerge[fRows][fColumns];
+       //      cout<<"CDS matrix:"<<endl;
+     //   debugStream<>(fCdsmatrix, fPixels, 4*416, 0, 39);
+               //Divide CDSMATRIX in the channels. First pixel is from A0-0, then A0-1, then A0-2, then A0-3, then A1-0, then A1-1, then A1-2, then A1-3, then second pixel is from A0-0, then...
+               // for(Int_t iPixelInZeile=0; iPixelInZeile<subColumns; iPixelInZeile++)
+        // {
+                       // for(Int_t iOutChannel=0; iOutChannel<subRows; iOutChannel++)
+                       // {    
+       //              cout<<iPixelInZeile<<":"<<(4+iOutChannel)+iPixelInZeile*subRows*2<<endl;
+                          // a0[iOutChannel][iPixelInZeile]=CDSMATRIX  [iOutChannel+iPixelInZeile*subRows*2];
+                          // a1[iOutChannel][iPixelInZeile]=CDSMATRIX  [(4+iOutChannel)+iPixelInZeile*subRows*2];//4+iOutChannel, because this is A1, which is shifted by four channels of A0
+                       // }
+               // }
+               // for(Int_t i=0; i<208; i++)
+        // {
+          // cout<< a0[0][i]<<",";
+        // }
+               // cout<<endl;
+               //Divide CDSMATRIX in the channels. First 208 pixels are from A0-0, then A0-1, then A0-2, then A0-3, then A1-0, then A1-1, then A1-2, then A1-3
+                for(Int_t iOutChannel=0; iOutChannel<subRows; iOutChannel++)
+                {
+                       for(Int_t iPixelInZeile=0; iPixelInZeile<subColumns; iPixelInZeile++)
+                       {
+                       //      cout<<iPixelInZeile<<":"<<(4+iOutChannel)*subColumns+iPixelInZeile<<"-";
+                          a0[iOutChannel][iPixelInZeile]=CDSMATRIX     [iOutChannel*subColumns+iPixelInZeile];
+                          a1[iOutChannel][iPixelInZeile]=CDSMATRIX     [(4+iOutChannel)*subColumns+iPixelInZeile];//4+iOutChannel, because this is A1, which is shifted by four channels of A0
+                       }
+                       
+                       
+                       // Start Filter CommonMode
+                       /*Float_t       CommonModeInRow = 0;
+                       bool warning=false;
+                       CommonModeInRow = TMath::Median(subColumns, a0[iOutChannel]); // Don't use mean, consider hitted pixel !
+                       if (CommonModeInRow < 0)
+                               plus++;
+                       else
+                               minus++;
+                       
+                       if(TMath::Abs(CommonModeInRow)>0) // TODO better warning criteria
+                       {
+                               warning = true;
+                       }
+                       if(warning) { cout<<"\rFrame: "<<fFrameNumber<< " row: " << iOutChannel << " Median of row: " << CommonModeInRow <<  " --> Common Mode suspiciously high!               "<<endl; 
+                                debugStream<>(fCdsmatrix, fPixels, fColumns, 0, 20);
+                               debugStream<>(a0[iOutChannel], subColumns, subColumns, 1, 20);
+                       }
 
+                       for(int column=0; column<subColumns; column++ )
+                       {
+                               a0[iOutChannel][column ] -= CommonModeInRow;
+                       }
+                       // End Filter CommonMode*/
+               }
+               
+                // for(Int_t i=0; i<208; i++)
+        // {
+          // cout<< a0[0][i]<<",";
+        // }
+               // cout<<endl;
+                // for(Int_t i=0; i<208; i++)
+        // {
+          // cout<< a1[3][i]<<",";
+        // }
+               // cout<<endl;
+               
+               // for(Int_t iOutChannel=0; iOutChannel<subRows; iOutChannel++)
+        // {
+                       // for(Int_t iMerge2channels=0; iMerge2channels<subColumns;iMerge2channels++)
+                       // {
+               //      Merge A0-0[0],A1-0[0],A0-0[1],A1-0[1],A0-0[2],A1-0[2],... output is an array of 4 geometrically columns
+                               // aMerge[iOutChannel][iMerge2channels*2]=a0[iOutChannel][iMerge2channels];//A0-iOutChannel[iMerge2channels]
+                               // aMerge[iOutChannel][iMerge2channels*2+1]=a1[iOutChannel][iMerge2channels];//A1-iOutChannel[iMerge2channels]
+                       // }
+               // }
+               for(Int_t iOutChannel=0; iOutChannel<subRows; iOutChannel++)
+        {
+                       for(Int_t iMerge2channels=0; iMerge2channels<subColumns;iMerge2channels++)
+                       {
+                       //Merge A0-0, then A1-0 in one line, then A0-1 and A1-1 in one line...
+                               aMerge[iOutChannel][iMerge2channels]=a0[iOutChannel][iMerge2channels];//A0-iOutChannel[iMerge2channels]
+                               aMerge[iOutChannel][iMerge2channels+subColumns]=a1[iOutChannel][iMerge2channels];//A1-iOutChannel[iMerge2channels]
+                       }
+               }
+               
+               for(Int_t iOutChannel=0; iOutChannel<fRows; iOutChannel++)
+               {
+                       for(Int_t iPixel=0; iPixel<fColumns;iPixel++)
+                       { 
+                               fCdsmatrix[iOutChannel*fColumns+iPixel]=aMerge[iOutChannel][iPixel];//Write the merged data in fCdsmatrix, which is 1dim array (standard) 
+                               
+                       }
+               }
+               //debugStream<>(fCdsmatrix, fPixels, fColumns, 0, 20);
+               for(Int_t iPixel=0; iPixel<fPixels;iPixel++)
+                       { 
+               //              cout<<fCdsmatrix[iPixel]<<","; 
+                               
+                       }
+               //exit(0);
+}
+
+//####################################################################
+//####################################################################
+void MAPS::reorderFSBB_B() {
+                       // War: A0-0, A1-0, A0-1, A1-1
+                       //0,1,...,415
+                       //416,...,
+                       //Ist Blödsinn, deshalb wird zuerst A0 ausgelesen, und dann A1
+               Float_t CDSMATRIX       [fPixels];
+        Int_t F0MATRIX [fPixels];
+        Int_t F1MATRIX [fPixels];
+               for(Int_t i=0; i<fPixels; i++)
+        {
+            CDSMATRIX  [i] = i;
+            F0MATRIX   [i] = fF0matrix [i];
+            F1MATRIX   [i] = fF1matrix [i];
+        }
+               fRows           = 4;
+        fColumns       = 416;
+        fPixels                = fRows*fColumns;
+       //      debugStream(CDSMATRIX, fPixels, 416, 0, 2000);
+       
+               Int_t subRows = 4;
+               Int_t subColumns = 2*208;
+               Int_t a0[subRows][subColumns];
+               Int_t a1[subRows][subColumns];
+               Int_t aMerge[fRows][fColumns];
+       //      cout<<"CDS matrix:"<<endl;
+     //   debugStream<>(fCdsmatrix, fPixels, 4*416, 0, 39);
+               //Divide CDSMATRIX in the channels. First pixel is from A0-0, then A0-1, then A0-2, then A0-3, then A1-0, then A1-1, then A1-2, then A1-3, then second pixel is from A0-0, then...
+               // for(Int_t iPixelInZeile=0; iPixelInZeile<subColumns; iPixelInZeile++)
+        // {
+                       // for(Int_t iOutChannel=0; iOutChannel<subRows; iOutChannel++)
+                       // {    
+       //              cout<<iPixelInZeile<<":"<<(4+iOutChannel)+iPixelInZeile*subRows*2<<endl;
+                          // a0[iOutChannel][iPixelInZeile]=CDSMATRIX  [iOutChannel+iPixelInZeile*subRows*2];
+                          // a1[iOutChannel][iPixelInZeile]=CDSMATRIX  [(4+iOutChannel)+iPixelInZeile*subRows*2];//4+iOutChannel, because this is A1, which is shifted by four channels of A0
+                       // }
+               // }
+               // for(Int_t i=0; i<208; i++)
+        // {
+          // cout<< a0[0][i]<<",";
+        // }
+               // cout<<endl;
+               //Divide CDSMATRIX in the channels. First 208 pixels are from A0-0, then A0-1, then A0-2, then A0-3, then A1-0, then A1-1, then A1-2, then A1-3
+                for(Int_t iOutChannel=0; iOutChannel<subRows; iOutChannel++)
+                {
+                       for(Int_t iPixelInZeile=0; iPixelInZeile<fColumns; iPixelInZeile++)
+                       {
+                       //      cout<<iPixelInZeile<<":"<<(4+iOutChannel)*subColumns+iPixelInZeile<<"-";
+                          a0[iOutChannel][iPixelInZeile]=CDSMATRIX     [iOutChannel*fColumns+iPixelInZeile];
+                       //   a1[iOutChannel][iPixelInZeile]=CDSMATRIX   [(4+iOutChannel)*subColumns+iPixelInZeile];//4+iOutChannel, because this is A1, which is shifted by four channels of A0
+                       }
+                       
+                       
+                       // Start Filter CommonMode
+                       /*Float_t       CommonModeInRow = 0;
+                       bool warning=false;
+                       CommonModeInRow = TMath::Median(subColumns, a0[iOutChannel]); // Don't use mean, consider hitted pixel !
+                       if (CommonModeInRow < 0)
+                               plus++;
+                       else
+                               minus++;
+                       
+                       if(TMath::Abs(CommonModeInRow)>0) // TODO better warning criteria
+                       {
+                               warning = true;
+                       }
+                       if(warning) { cout<<"\rFrame: "<<fFrameNumber<< " row: " << iOutChannel << " Median of row: " << CommonModeInRow <<  " --> Common Mode suspiciously high!               "<<endl; 
+                                debugStream<>(fCdsmatrix, fPixels, fColumns, 0, 20);
+                               debugStream<>(a0[iOutChannel], subColumns, subColumns, 1, 20);
+                       }
+
+                       for(int column=0; column<subColumns; column++ )
+                       {
+                               a0[iOutChannel][column ] -= CommonModeInRow;
+                       }
+                       // End Filter CommonMode*/
+               }
+               
+                // for(Int_t i=0; i<208*2; i++)
+        // {
+          // cout<< a0[0][i]<<",";
+        // }
+               // cout<<endl;
+                // for(Int_t i=0; i<208; i++)
+        // {
+          // cout<< a1[3][i]<<",";
+        // }
+               // cout<<endl;
+               
+               // for(Int_t iOutChannel=0; iOutChannel<subRows; iOutChannel++)
+        // {
+                       // for(Int_t iMerge2channels=0; iMerge2channels<subColumns;iMerge2channels++)
+                       // {
+               //      Merge A0-0[0],A1-0[0],A0-0[1],A1-0[1],A0-0[2],A1-0[2],... output is an array of 4 geometrically columns
+                               // aMerge[iOutChannel][iMerge2channels*2]=a0[iOutChannel][iMerge2channels];//A0-iOutChannel[iMerge2channels]
+                               // aMerge[iOutChannel][iMerge2channels*2+1]=a1[iOutChannel][iMerge2channels];//A1-iOutChannel[iMerge2channels]
+                       // }
+               // }
+               for(Int_t iOutChannel=0; iOutChannel<subRows; iOutChannel++)
+        {
+                       for(Int_t iMerge2channels=0; iMerge2channels<fColumns;iMerge2channels++)
+                       {
+                       //Merge A0-0[0],A1-0[0],A0-0[1],A1-0[1],A0-0[2],A1-0[2],... output is an array of 4 geometrically columns
+                               aMerge[iOutChannel][iMerge2channels]=a0[iOutChannel][iMerge2channels];//A0-iOutChannel[iMerge2channels]
+                       //      aMerge[iOutChannel][iMerge2channels+subColumns]=a1[iOutChannel][iMerge2channels];//A1-iOutChannel[iMerge2channels]
+                       }
+               }
+               
+               for(Int_t iOutChannel=0; iOutChannel<fRows; iOutChannel++)
+               {
+                       for(Int_t iPixel=0; iPixel<fColumns;iPixel++)
+                       { 
+                               fCdsmatrix[iOutChannel*fColumns+iPixel]=aMerge[iOutChannel][iPixel];//Write the merged data in fCdsmatrix, which is 1dim array (standard) 
+                               
+                       }
+               }
+               debugStream<>(fCdsmatrix, fPixels, fColumns, 0, 20);
+               for(Int_t iPixel=0; iPixel<fPixels;iPixel++)
+                       { 
+               //              cout<<fCdsmatrix[iPixel]<<","; 
+                               
+                       }
+               //exit(0);
 }
 
 //####################################################################
index 8a372def3abdb53f039ef498134a02926295520f..05032f47886a8127dc1a3f48f5f1ee1d28cf31ae 100644 (file)
@@ -279,6 +279,9 @@ private:
     * Pixels are counted different here - account for this Two lines are merged together CURRENTLY A TODO
     */
       void reorderFSBB();  
+         void reorderFSBB2();  
+         void reorderFSBB3(); 
+               void reorderFSBB_B();     
     /**
      * @brief Sums over a given array
      *
@@ -490,7 +493,7 @@ public:
     Int_t*          GetF0Frame()                    { return fF0matrix;                     }
     Int_t*          GetF1Frame()                    { return fF1matrix;                     }
     Float_t*        GetNoise()                      { return fNoise;                        }
-    
+    Int_t           GetHitNumberInFrame()               { return fHits;                      }
     // Output Directory, set and passed initMapsRun() to  in the constructor
     
     /// Some documentation for first.
index f6d6d8763f2d9d8fede283dddf8b9ad0c39ada74..9bd22c86bd858a438977fbe051abec3889b5decc 100644 (file)
@@ -265,17 +265,20 @@ Bool_t Run::analyzeRun(Bool_t force)
             ULong_t progress_tmp=-1;
             /// progress meter
             Float_t progress;
+                       if (dynamicalNoise)
             processed->InitialDynNoise();
             int start   = 0;
             int nframes = processed->GetNumberFrames();
-          //   for(int i=0; i<1000;i++) // TODO remove 100000 run 342272
-           for(int i=0; i<nframes;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->getFrame(i);
                //                 processed->filterCommonMode();
 //                     cout << "hitana " << i << endl;
                 processed->hitana();
+               //              if(processed->GetHitNumberInFrame()>0)
+               //              processed->plotFrame(i);
 //                 cout << "regetDynNoise " << endl;
                 if (dynamicalNoise)
                     processed->regetDynNoise();
@@ -366,6 +369,7 @@ Bool_t Run::rescaleHistograms()
     rescaleHistogram(histogramCalibrated.Seed, histogram.Seed);
     rescaleHistogram(histogramCalibrated.Sum, histogram.Sum);
     rescaleHistogram(histogramCalibrated.Veto, histogram.Veto);
+    rescaleHistogram(histogramCalibrated.VetoSum, histogram.VetoSum);
     rescaleHistogram(histogramCalibrated.Noise, histogram.Noise);
     
     if (histogram.histAvgCluster != nullptr)
@@ -383,6 +387,7 @@ Bool_t Run::rescaleHistograms()
     rescaleHistogram(histogramthresholdCalibrated.Seed, histogramthreshold.Seed);
     rescaleHistogram(histogramthresholdCalibrated.Sum, histogramthreshold.Sum);
     rescaleHistogram(histogramthresholdCalibrated.Veto, histogramthreshold.Veto);
+    rescaleHistogram(histogramthresholdCalibrated.VetoSum, histogramthreshold.VetoSum);
     rescaleHistogram(histogramthresholdCalibrated.Noise, histogramthreshold.Noise);
     
     histogramthresholdCalibrated.posSeed = histogramthreshold.posSeed * gain;
@@ -441,7 +446,8 @@ Bool_t Run::analyzeFrame(Int_t frame)
         processed->initNewRootFile();
         int entries = processed->GetNumberFrames();
         if (frame < entries)
-        {
+        {      
+                       if (dynamicalNoise)
             processed->InitialDynNoise(100);
             processed->getFrame(frame);
             // processed->filterCommonMode();
@@ -609,12 +615,12 @@ void Run::selectSubMatrixFSBB(TString matrixname)
 {   
 
     if (matrixname.EqualTo("A0"))    {
-        setSubMatrixBorders(0, sensorinfocur.columns/2-2, 0, sensorinfocur.rows, false);
+        setSubMatrixBorders(0, sensorinfocur.columns/2-2, 0, sensorinfocur.rows, true);
         runcodesuffix += "_A0_";
         humanreadablesuffix += "A0, ";
     }
     else if (matrixname.EqualTo("A1")) {
-        setSubMatrixBorders(sensorinfocur.columns/2+2, sensorinfocur.columns, 0, sensorinfocur.rows, false);   
+        setSubMatrixBorders(sensorinfocur.columns/2+2, sensorinfocur.columns, 0, sensorinfocur.rows, true);   
         runcodesuffix += "_A1_";
         humanreadablesuffix += "A1, ";
     }
@@ -777,7 +783,7 @@ Bool_t Run::binSeedSumVeto()
     /// collected charge in cluster
     Float_t pixelSum = 0;
     Float_t notSeedSum = 0;
-        
+   //  for (Int_t framei=0; framei<10000; framei++) // loop over all frames   
     for (Int_t framei=0; framei<processed->fHitTree->GetEntries(); framei++) // loop over all frames
     {
         processed->fHitTree->GetEntry(framei);
@@ -840,9 +846,37 @@ Bool_t Run::binSeedSumVeto()
                         histogramthreshold.numberofhits++;
                         
                         histogramthreshold.Seed->Fill(processed->fFrameInfo.p[12][hiti]);
+                                               // cout<<"Hitnummer"<<framei<<":"<<hiti<<": "<<"Threshold: "<<processed->fFrameInfo.pixelthreshold[hiti]<<":";
+                                                       // for(int col=0;col<25;col++)
+                                                       // cout<<processed->fFrameInfo.p[col][hiti]<<",";
+                                                       // cout<<endl;
+                                                                               // cout << colorred <<"Accepted hit cluster:"<<framei<<":"<<hiti<<endlr;
+                                               
+                                                       // for(Int_t row=0; row<5; row++)
+                                                       // {
+                                                               // for(Int_t column=0; column<5; column++)
+                                                               // {
+                                                                       // std::cout.width(10);
+                                                                       // std::cout << std::fixed;
+                                                                       // std::cout << std::left << std::setprecision(2) << processed->fFrameInfo.p[row*5+column][hiti];
+                                                               // }
+                                                               // cout << endl;
+                                                       // }
+                                                       // cout << endl;
+                                               
                         histogramthreshold.Sum->Fill(pixelSum);
                         if (TMath::Abs(notSeedSum) < systemparamcur.vetothreshold && (labbook.source.Contains("Fe")||labbook.source.Contains("Cd")))
                             histogramthreshold.Veto->Fill(processed->fFrameInfo.p[12][hiti]);    // histogram with the single pixel
+                                                       
+                                                if (TMath::Abs(pixelSum) > 200 && (labbook.source.Contains("Fe")))
+                                                { 
+                            histogramthreshold.VetoSum->Fill(processed->fFrameInfo.p[12][hiti]);    // histogram with the single pixel
+                                                       //histogramthreshold.VetoSum->Fill(pixelSum);
+                                                       // cout<<"Hitnummer"<<framei<<":"<<hiti<<": ";
+                                                       // for(int col=0;col<25;col++)
+                                                       // cout<<processed->fFrameInfo.p[col][hiti]<<",";
+                                                       // cout<<endl;
+                                                }
                     }
                 }
             }
@@ -1101,7 +1135,15 @@ Bool_t Run::plotSeed()
     }
     return 1;
 }
-
+Bool_t Run::plotVetoSumThreshold()
+{
+    if (!error)
+    {
+        plot1DHistogram(histogramthreshold.VetoSum, "landau");
+        return 0;
+    }
+    return 1;
+}
 Bool_t Run::plotSeedThreshold()
 {
     if (!error)
@@ -1888,6 +1930,7 @@ void Run::initHistograms(histogramstruct* histogramstructpointer, TString suffix
     initHistogram(histogramstructpointer->Seed, "Seed" + suffix);
     initHistogram(histogramstructpointer->Sum, "Sum" + suffix);
     initHistogram(histogramstructpointer->Veto, "Veto" + suffix);
+    initHistogram(histogramstructpointer->VetoSum, "VetoSum" + suffix);
     
     TString prefix = "Noise" + suffix;
     
index 590248d68470e8686acc15688aac2d364953307e..dbafc9d70ada554e0426be02f269eeb97a74be57 100644 (file)
@@ -387,7 +387,8 @@ public:
     Bool_t plotSeedThresholdCalibrated();
     Bool_t plotSum();
     Bool_t plotVeto();
-    
+    Bool_t plotVetoSumThreshold();
+       
     /** @brief Prints all data gathered from the database */
     Bool_t debugDBreadout();
     
@@ -497,6 +498,8 @@ public:
         TH1F* Sum;
         /// Veto spectrum, used to find better calibration peak, only entries where Sum over not seed pixels is below @c Run::vetothreshold are binned into this histogram
         TH1F* Veto;
+               /// Seed spectrum with Veto condition, accept only clusters with a sum charge>150 (hopefully helps to clean FSBB-spectrum, be careful, might not work for irradiated sensors due to recombinations
+        TH1F* VetoSum;
         /// Noise histogram
         TH1F* Noise;