]> jspc29.x-matter.uni-frankfurt.de Git - radhard.git/commitdiff
FSBB reOrder Sicherung
authorDennis Doering <doering@physik.uni-frankfurt.de>
Thu, 24 Sep 2015 10:09:31 +0000 (12:09 +0200)
committerDennis Doering <doering@physik.uni-frankfurt.de>
Thu, 24 Sep 2015 10:09:31 +0000 (12:09 +0200)
MABS_run_analyzer/ChargeSpektrumFunctions.c
MABS_run_analyzer/HistogramType.h
MABS_run_analyzer/MAPS.c
MABS_run_analyzer/MAPS.h
MABS_run_analyzer/Run.c
MABS_run_analyzer/Run.h
MABS_run_analyzer/help.h

index 1b36ac76a830074c5797890429f4f9dfe03ed376..1bfef59695acc49c5c440b2acc9097e5b3ecf942 100644 (file)
@@ -78,9 +78,9 @@ Bool_t writeObservableToFile()
 {
     if (numberRuns>0)
     {
-        system("mkdir "+ runs[0]->savepathresults + " -p");
+        system("mkdir "+ runs[0]->savepathresults + ownpath+ " -p");
         
-        TString filename = runs[0]->savepathresults + "/Spectra";
+        TString filename = runs[0]->savepathresults + ownpath + "/Spectra";
         TString header = "";
         for(Int_t runi=0;runi<numberRuns;runi++) // loop over runs read from file
         {
@@ -123,7 +123,7 @@ Bool_t writeDataToExcel()
     {
         headerInfo+=runs[runi]->runcode+"\t\t\t";
     }
-    TH1F* plothistogrampointer = runs[0]->plothistogrampointer;
+   // TH1F* plothistogrampointer = runs[0]->plothistogrampointer;
     TString runnumberListe="";
     TString header="";
        cout<<"komme ich hierher3"<<endl;
@@ -132,7 +132,7 @@ Bool_t writeDataToExcel()
             HistogramType* curhistogramclassp = compareHistogramClassVector.at(histogrami);
             TH1F* curhistogramclone;
             curhistogramclone = (TH1F*) curhistogramclassp->Seed->Clone();
-                       runnumberListe+=Form("%d_",curhistogramclassp->labbook.runnumber);
+       //              runnumberListe+=Form("%d_",curhistogramclassp->labbook.runnumber);
          //   header+=Form("%d\t%s\t\t\t", runs[runi]->labbook.runnumber, curhistogramclone->GetTitle());
                        
                }
index ac60cc084daa2d41618b79cb8817e20e5333eddf..bf2d7a733e49202c320ce616509c5df3578a1d00 100644 (file)
@@ -186,6 +186,7 @@ public:
     Float_t FitPerform(TH1F* histogrampointer, TString fitFuncType, Bool_t verbose = 0, Double_t* parameters = 0);
     /** @brief calculates Charge Collection Efficiency if Fe55 run */
     Bool_t calculteCCE();
+
     /**
      * @brief find the border between the noise and the signal in Sr90 runs
      * 
index f9c1582e4526a8169ad65df1163706f9292e9db2..2465a3d6c77d97cafbf145491276326b2afb7955 100644 (file)
@@ -33,7 +33,9 @@ MAPS::MAPS(Run* runp) {
             {
                 run->labbook.system = Form("USB");
             }
+                       cout<<"COLUMNS2"<<fColumns<<"ROWS"<<fRows<<endl;
             run->setSystemSpecificParameters();
+                       cout<<"COLUMNS3"<<fColumns<<"ROWS"<<fRows<<endl;
             error = initMapsRun( );
         }
     }
@@ -62,6 +64,7 @@ Bool_t MAPS::initNewRootFile() {
         fHitTree->Branch("pixelfixedthreshold", &fFrameInfo.pixelfixedthreshold[0],"pixelfixedthreshold[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);
+                       fHitTree->Branch( Form("n%i",i+1)   , &fFrameInfo.n[i][0]   , Form("n%i [hits]/F",i+1)  , 32000);
         }
         // Noise TTree
         fNoiseTree      = new TTree("noise", "noise");
@@ -78,11 +81,12 @@ Bool_t MAPS::initNewRootFile() {
 
 Bool_t MAPS::initOldRootFile() {
     fSave = false;
-    if ( !checkConf(fPixelsData) ) { // TODO FileEvNbInConfig
-        defaultConf();
-    }
-    int MaxFiles = TMath::Ceil((Float_t) FileTotalEvNbInConfig/FileEvNbInConfig);
-    checkDataFiles(MaxFiles);
+  //  if ( !checkConf(fPixelsData) ) { // TODO FileEvNbInConfig
+  //      defaultConf();
+  //  }
+  //  int MaxFiles = TMath::Ceil((Float_t) FileTotalEvNbInConfig/FileEvNbInConfig);
+  //  checkDataFiles(MaxFiles);
+  cout<<"COLUMNS"<<fColumns<<"ROWS"<<fRows<<endl;
     fOutputFile     = new TFile(fRootFile,"READ");
     if (fOutputFile->IsZombie())
     {
@@ -103,6 +107,7 @@ Bool_t MAPS::initOldRootFile() {
     
     for(int i=0; i<25; i++) {
         fHitTree->SetBranchAddress( Form("p%i",i+1)   , &fFrameInfo.p[i][0]);
+               fHitTree->SetBranchAddress( Form("n%i",i+1)   , &fFrameInfo.n[i][0]);
     }
     fNoiseTree =  (TTree*) fOutputFile->Get("noise");
     if (!fNoiseTree) // got pointer
@@ -117,6 +122,15 @@ Bool_t MAPS::initOldRootFile() {
     cout<<"-----------------------"<<endl;
     return 0;    
 }
+Bool_t MAPS::initOldRootFileFrame() {
+    fSave = false;
+       if ( !checkConf(fPixelsData) ) { // TODO FileEvNbInConfig
+               defaultConf();
+       }
+       int MaxFiles = TMath::Ceil((Float_t) FileTotalEvNbInConfig/FileEvNbInConfig);
+       checkDataFiles(MaxFiles);
+       initOldRootFile();
+}
 //####################################################################
 
 MAPS::~MAPS(void) {
@@ -234,8 +248,8 @@ Bool_t MAPS::initMapsRun( ) {
     
     if(fOrderCode=="FSBB")
     {
-        fRows = 8;
-        fColumns=208;
+    //    fRows = 8;
+    //    fColumns=208;
         fPixels        = fRows*fColumns;
         cout<<"fOrderCode is" <<fOrderCode<<"therefore for data read use fRows: "<<fRows<<"and fColumns: "<<fColumns<<". This is changed after calling reOrder in getFrame()"<<endl; 
     }
@@ -673,7 +687,7 @@ bool MAPS::getFrame(UInt_t FrameNumber) {
         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();   }
@@ -1244,7 +1258,7 @@ void MAPS::hitana() {
         Bool_t bordercluster=false;
         Float_t noisesumincluster=0;
         Float_t chargesumincluster=0;
-        
+        cout<<"COLUMNS"<<fColumns<<"ROWS"<<fRows<<endl;
         Float_t cdsMatrixSum=0;
         Float_t cdsmatrixCorrPed[fPixels];
         for(Int_t i=0; i<fPixels; i++)
@@ -1522,7 +1536,7 @@ void MAPS::hitana() {
             Float_t chargesumincluster4=0;
             Float_t noisesumincluster4=0;
             Float_t noisesumincluster4Square=0;
-            for(Int_t iClusterLauf=0;iClusterLauf<4;iClusterLauf++)
+            for(Int_t iClusterLauf=0;iClusterLauf<20;iClusterLauf++)
             {
                 chargesumincluster4+=pixelchargeincluster[index[iClusterLauf]];
                 //noisesumincluster4+=noiseincluster[index[iClusterLauf]];
@@ -1555,38 +1569,60 @@ 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;
+                                               };
+                                       }
+                               }
             }
             
             
             
             
-            
             //Begin: loop evaluate true seeds:
             if(CHANCE==100)
             {
                 if(fOrderCode=="FSBB")
                 {
-                    if (B < 2 || B > fColumns-3 || A < 1 || A > fRows-2)
-                        bordercluster = true;
+                    if (B < 1 || B > fColumns-2 || A < 1 || A > fRows-2)
+                        bordercluster = false;
                     else
                         bordercluster = false;
                 }
@@ -1630,6 +1666,7 @@ void MAPS::hitana() {
                     for(int clupos=0; clupos<25; clupos++)
                     {
                         fFrameInfo.p [clupos][fHits] = pixelchargeincluster[clupos];
+                                               fFrameInfo.n [clupos][fHits] = noiseincluster[clupos];
                     }
                     // for(Int_t row=0; row<5; row++)
                     // {
@@ -1645,7 +1682,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;
@@ -1775,18 +1812,64 @@ void MAPS::plotFrame(Int_t FrameNumber) {
     else {
         cout <<endl <<endl << colorwhite << "---------------- FRAME " << fFrameNumber << " ----------------" << colorreset << endl << endl;
         cout<<"CDS matrix:"<<endl;
-        debugStream<>(fCdsmatrix, fPixels, fColumns, 0, 39);
+        debugStream<>(fCdsmatrix, fPixels, fRows, 0, 39);
         Float_t cdsmatrixCorrPed[fPixels];
         for(Int_t i=0; i<fPixels; i++)
         {
             cdsmatrixCorrPed[i]=(float)(1.*fCdsmatrix[i]-fPedestals[i]);
         }
         cout<<"CDS matrix minus pedestals:"<<endl;
-        debugStream<>(cdsmatrixCorrPed, fPixels, fColumns, 0, 10);
+    //    debugStream<>(cdsmatrixCorrPed, fPixels, fRows, 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, fRows, 1, 1);
+               Double_t cdsmatrixSum;
+               for(Int_t i=0; i<fPixels; i++)
+        {
+            cdsmatrixSum+=cdsmatrixCorrPed[i];
+        }
+                Int_t index[fPixels];
+               TMath::Sort(fPixels,cdsmatrixCorrPed,index,1);
+               for(Int_t i=0; i<50; i++)
+        {
+           cout<<cdsmatrixCorrPed[index[i]]<<",";
+        }
+               cout<<"CDSMATRIXSUM-PEDESTAL "<<cdsmatrixSum<<endl;
+                cout << colorred <<"Accepted hit cluster:"<<endlr;
+               for (Int_t hiti = 0; hiti < fHits; hiti++)
+               {       
+                                       int index[25];
+                                       Double_t pixelchargeincluster[25]={ 0 };
+                                       Double_t pixelnoiseincluster[25]={ 0 };
+                                       Double_t pixelchargesum=0;
+                                       Double_t pixelnoisesum=0;
+                                       for(int clus=0;clus<25;clus++)
+                                       {
+                                               pixelchargeincluster[clus]=fFrameInfo.p[clus][hiti];
+                                               pixelnoiseincluster[clus]=fFrameInfo.n[clus][hiti];
+                                       }
+                                       TMath::Sort(25,pixelchargeincluster,index,1);
+                                       for(int clus=0;clus<20;clus++)
+                                       {
+                                               pixelchargesum+=pixelchargeincluster[index[clus]];
+                                               pixelnoisesum+=TMath::Power(pixelnoiseincluster[index[clus]],2);
+                                       }
+                                       pixelnoisesum=TMath::Sqrt(pixelnoisesum);
+                                       cout<<"Pixelcharge: "<<pixelchargesum<<"Noise: "<<5.0*pixelnoisesum<<endl;
+                       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;
+                       cout<<"PixelTreshold"<<fFrameInfo.pixelthreshold[hiti]<<endl;
+               }
+               
         TCanvas* cm1 = new TCanvas(Form("Frame %d",FrameNumber),Form("Frame %d",FrameNumber),50,100,1200,800);
         cm1->Divide(2,3);
         gStyle->SetOptFit(1011);
@@ -2443,67 +2526,216 @@ void MAPS::reorderMi29a() {
         }
     }
 }
-
 //####################################################################
 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, 39);
-    
-    Int_t subRows = 4;
-    Int_t subColumns = 208;
-    Int_t a0[subRows][subColumns];
-    Int_t a1[subRows][subColumns];
-    Int_t aMerge[fRows][fColumns];
-    
-    //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++)
+                       
+               Float_t CDSMATRIX       [fPixels];
+        Int_t F0MATRIX [fPixels];
+        Int_t F1MATRIX [fPixels];
+               for(Int_t i=0; i<fPixels; i++)
         {
-            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
+            CDSMATRIX  [i] = fCdsmatrix[i];
+            F0MATRIX   [i] = fF0matrix [i];
+            F1MATRIX   [i] = fF1matrix [i];
         }
-    }
-    // for(Int_t i=0; i<208; i++)
-    // {
-    // cout<< a0[3][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++)
+       //      fRows           = 4;
+    //    fColumns     = 416;
+        fPixels                = fRows*fColumns;
+       //      debugStream(CDSMATRIX, fPixels, fPixels, 0, 14);
+       //cout<<"Rows:"<<fRows<<"Columns"<<fColumns<<endl;
+       //exit(0);
+       
+               Int_t subRows = 208;
+               Int_t subColumns = 4;
+               Int_t a0[subColumns][subRows];
+               Int_t a1[subColumns][subRows];
+               Int_t aMerge[fColumns][fRows];
+       //      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<subColumns; iOutChannel++)
+                {
+                       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
+                       }
+
+               }
+               
+                // 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<subColumns; iOutChannel++)
         {
-            //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 iMerge2channels=0; iMerge2channels<subRows;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 iPixel=0; iPixel<fPixels;iPixel++)
+                       { 
+                               fCdsmatrix[iPixel]=-13;
+                       }
+               for(Int_t iOutChannel=0; iOutChannel<fColumns; iOutChannel++)
+               {
+                       for(Int_t iPixel=0; iPixel<fRows;iPixel++)
+                       { 
+                               fCdsmatrix[iOutChannel*fRows+iPixel]=aMerge[iOutChannel][iPixel];//Write the merged data in fCdsmatrix, which is 1dim array (standard) 
+                               
+                       }
+               }
+       //      debugStream<>(fCdsmatrix, fPixels, fColumns, 0, 20);
+               
+               Float_t tMatrix [fPixels];
+               for(Int_t iPixel=0; iPixel<fPixels;iPixel++)
+                       { 
+               //              cout<<fCdsmatrix[iPixel]<<","; 
+                               tMatrix[iPixel]=iPixel;
+                               //cout<<tMatrix[iPixel]<<","; 
+                       }
+                       //debugStream<>(tMatrix, fPixels, fColumns, 0, 20);
+       //      exit(0);
+}
+
+//####################################################################
+void MAPS::reorderFSBBSicherung() {
+                       
+               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, fPixels, 0, 14);
+       //exit(0);
+               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
+                       }
+
+               }
+               
+                // 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 iPixel=0; iPixel<fPixels;iPixel++)
+                       { 
+                               fCdsmatrix[iPixel]=-13;
+                       }
+               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);
+               
+               Float_t tMatrix [fPixels];
+               for(Int_t iPixel=0; iPixel<fPixels;iPixel++)
+                       { 
+               //              cout<<fCdsmatrix[iPixel]<<","; 
+                               tMatrix[iPixel]=iPixel;
+                               //cout<<tMatrix[iPixel]<<","; 
+                       }
+                       //debugStream<>(tMatrix, fPixels, fColumns, 0, 20);
+       //      exit(0);
 }
 
 //####################################################################
index f792b86b5ef1fe0b093215ec4bbe932a2d516892..fe1513428838751ae987c1f1a9de26ef3ad8fe14 100644 (file)
@@ -279,6 +279,7 @@ private:
     * Pixels are counted different here - account for this Two lines are merged together CURRENTLY A TODO
     */
       void reorderFSBB();  
+          void reorderFSBBSicherung();  
     /**
      * @brief Sums over a given array
      *
@@ -339,7 +340,13 @@ public:
      * 
      */
     Bool_t initOldRootFile();
-    
+    /**
+     * @brief Reopens an allready existing ROOT file for plotFrame
+     *
+     * Loads a ROOT file
+     * 
+     */
+    Bool_t initOldRootFileFrame();
     
     /** @brief Refill the noise branch every #MAPS::numberofframesfornoise frames or just use the initial initialization
      *
index b9beb7a87cdd810805918782c69af61326dba63e..859c8eb538001d6cf26b1373cf6e6e4ff4323245 100644 (file)
@@ -157,10 +157,11 @@ Run::Run(Int_t runnumber, Int_t loopi)
             // fixed threshold cut
             histogramfixedthreshold = new HistogramType(" fixed Threshold", &cursystemparam, &cursensorinfo, humanreadablestr, labbook.runnumber, rootcolors[plotStyle], rootlinestyle[plotStyle] );
             HistogramClassVector.push_back(histogramfixedthreshold);
-            // dennis megacut
-            dennismegacut = new HistogramType(" Dennis Mega Cut", &cursystemparam, &cursensorinfo, humanreadablestr, labbook.runnumber, rootcolors[plotStyle], rootlinestyle[plotStyle] );
-            HistogramClassVector.push_back(dennismegacut);
-            
+            // FSBB
+            histogramFSBB = new HistogramType(" FSBB", &cursystemparam, &cursensorinfo, humanreadablestr, labbook.runnumber, rootcolors[plotStyle+plotStyle*1], rootlinestyle[plotStyle] );
+            HistogramClassVector.push_back(histogramFSBB);
+            histogramFSBB2 = new HistogramType(" FSBB2", &cursystemparam, &cursensorinfo, humanreadablestr, labbook.runnumber, rootcolors[plotStyle+plotStyle*2], rootlinestyle[plotStyle] );
+            HistogramClassVector.push_back(histogramFSBB2);
             debugDBreadout();
         }
         else
@@ -236,7 +237,7 @@ void Run::setSensorInSystemParam()
     sensorinfostruct sensorinfoMi34USB( 8, 64 );
     sensorinfostruct sensorinfoMi34PXI( 16, /* rows */  64 /* columns */   );
     sensorinfostruct sensorinfoPegasus( 8, 56 );
-    sensorinfostruct sensorinfoFSBB( 4, 416 );
+    sensorinfostruct sensorinfoFSBB( 416, 4 );
     
     if (labbook.system.EqualTo("USB")  && labbook.chipGen.EqualTo("Mi34") )
         cursensorinfo=sensorinfoMi34USB;
@@ -350,7 +351,7 @@ Bool_t Run::analyzeRun(Bool_t force)
             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<1000000;i++) // TODO remove 100000 run 342272
            for(int i=0; i<nframes;i++) // TODO remove 100000 run 342272
             {
 //                 cout << "getframe " << i << endl;
@@ -381,7 +382,9 @@ Bool_t Run::analyzeRun(Bool_t force)
             cout << "Skipped analysis of run " << labbook.runnumber << ", I think the root file for this run allready exists." << endl;
             cout << colorwhite << "initOldRootFile():" << endlr;
         }
+               cout<<"BLABLABLA"<<endl;
         if (processed->initOldRootFile()) return 1;
+               cout<<"BLABLABLA2"<<endl;
         frames_found = processed->GetNumberFrames();
 //         cout << colorwhite << "plotPixSignal():"<< flush << endlr;
 //         processed->plotPixSignal(0,10000000,351);
@@ -403,7 +406,7 @@ Bool_t Run::analyzeRun(Bool_t force)
         histogramfixedthreshold->integrateSr90Spectra(histogramfixedthreshold->Seed, frames_found, 0);
         rescaleHistogramClasses();
         cout << colorwhite << "updateDatabase():" << endlr;
-        updateDatabase();
+    //    updateDatabase();
         cout << colorwhite << "delete MAPS class:" << endlr;
         delete processed;
         return 0;
@@ -449,7 +452,7 @@ Bool_t Run::analyzeFrame(Int_t frame)
     if (!error)
     {
         processed = new MAPS(this);
-        processed->initNewRootFile();
+        processed->initOldRootFileFrame();
         int entries = processed->GetNumberFrames();
         if (frame < entries)
         {
@@ -713,13 +716,16 @@ string Run::to_str_w_prec(const Float_t a_value, int precision = 3)
 }
 
 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};
     oneHistogramClass->Noise->Reset();
     processed->fNoiseTree->SetBranchAddress("noise", &noise, &noiseBranch);    
-    for (Int_t cnt=0; cnt<processed->fNoiseTree->GetEntries(); cnt++) {
+   // for (Int_t cnt=0; cnt<processed->fNoiseTree->GetEntries(); cnt++) {
+   
+   for (Int_t cnt=208*lauf; cnt<208*(lauf+1); cnt++) {
         processed->fNoiseTree->GetEntry(cnt);
         oneHistogramClass->Noise->Fill(noise);
     }    
@@ -727,6 +733,8 @@ Bool_t Run::binNoise(HistogramType* oneHistogramClass)
     oneHistogramClass->avgNoise = noisequantiles[1];
     oneHistogramClass->avgNoisePlus = noisequantiles[2] - noisequantiles[1];
     oneHistogramClass->avgNoiseMinus = noisequantiles[1] - noisequantiles[0];
+       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
@@ -738,12 +746,18 @@ Bool_t Run::binSeedSumVeto()
     /// collected charge in cluster
     Float_t pixelSum = 0;
     Float_t notSeedSum = 0;
-        
+    Int_t pixels=cursensorinfo.columns*cursensorinfo.rows;
+       fPixelFakeHits  = new Float_t [pixels]();
+               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();   
     for (Int_t framei=0; framei<processed->fHitTree->GetEntries(); framei++) // loop over all frames
     {
         processed->fHitTree->GetEntry(framei);
         // account only frames with less then 10 hits
-        if (processed->fFrameInfo.hits<(unsigned int)10)
+               // if (processed->fFrameInfo.hits>=(unsigned int)3)
+               // cout<<"Warning, frame "<<framei<<" contains "<<processed->fFrameInfo.hits<<" hits"<<endl;
+        if (processed->fFrameInfo.hits==(unsigned int)1)
         {
             for(Int_t hiti=0; (unsigned int)hiti<processed->fFrameInfo.hits;hiti++)
             {
@@ -815,16 +829,45 @@ Bool_t Run::binSeedSumVeto()
                         if (TMath::Abs(notSeedSum) < cursystemparam.vetothreshold && (labbook.source.Contains("Fe")||labbook.source.Contains("Cd")))
                             histogramfixedthreshold->Veto->Fill(processed->fFrameInfo.p[12][hiti]);    // histogram with the single pixel
                     }
-                    
-                    if (processed->fFrameInfo.pixel[hiti]>800)
+                    // FSBB CODE START
+                                       int index[25];
+                                       Double_t pixelchargeincluster[25]={ 0 };
+                                       Double_t pixelnoiseincluster[25]={ 0 };
+                                       Double_t pixelchargesum=0;
+                                       Double_t pixelnoisesum=0;
+                                       for(int clus=0;clus<25;clus++)
+                                       {
+                                               pixelchargeincluster[clus]=processed->fFrameInfo.p[clus][hiti];
+                                               pixelnoiseincluster[clus]=processed->fFrameInfo.n[clus][hiti];
+                                       }
+                                       TMath::Sort(25,pixelchargeincluster,index,1);
+                                       for(int clus=0;clus<20;clus++)
+                                       {
+                                               pixelchargesum+=pixelchargeincluster[index[clus]];
+                                               pixelnoisesum+=TMath::Power(pixelnoiseincluster[index[clus]],2);
+                                       }
+                                       pixelnoisesum=TMath::Sqrt(pixelnoisesum);
+                                       
+                    if (pixelchargesum>5.0*pixelnoisesum&& fPixelFakeHits[processed->fFrameInfo.pixel[hiti]+1]>0)
                     {
-                        dennismegacut->numberofhits++;
-                        
-                        dennismegacut->Seed->Fill(processed->fFrameInfo.p[12][hiti]);
-                        dennismegacut->Sum->Fill(pixelSum);
+                        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
+                    }
+                                        if (pixelchargesum>5.0*pixelnoisesum)
+                    {
+                        histogramFSBB2->numberofhits++;
+                     //   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")))
-                            dennismegacut->Veto->Fill(processed->fFrameInfo.p[12][hiti]);    // histogram with the single pixel
+                            histogramFSBB->Veto->Fill(processed->fFrameInfo.p[12][hiti]);    // histogram with the single pixel
                     }
+                                       
+                                       //FSBB CODE END
                 }
             }
         }
@@ -1642,5 +1685,51 @@ void Run::initRootParameters()
     rootcolors = new Int_t[13]{1, 2, 4, 6, 8, 13, 46, 28, 32, 33, 12, 20, 40};
     rootlinestyle = new Int_t[13]{1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1};
 }
-
+void Run::getPixelWithFakehits()
+{      
+       Int_t pixels=cursensorinfo.columns*cursensorinfo.rows;
+       histoPixel = new TH1F("pixel histo","pixel histo",pixels,0,pixels);
+       for (Int_t framei=0; framei<processed->fHitTree->GetEntries(); framei++) // loop over all frames
+    {
+        processed->fHitTree->GetEntry(framei);
+               for(Int_t hiti=0; (unsigned int)hiti<processed->fFrameInfo.hits;hiti++)
+            {
+                               histoPixel->Fill(processed->fFrameInfo.pixel[hiti]); 
+                       }
+       }
+       fPixelFakeHits  = new Float_t [pixels]();
+       fcountPixelFakeHits=0;
+       Float_t fakehitrate=0.0001;
+       Float_t sourceIntensity=1;//Adjust it depending on the intensity of the used source
+       if(labbook.source.Contains("Fe"))
+       {
+               sourceIntensity=30;
+       }
+       else if(labbook.source.Contains("Sr"))
+       {
+               sourceIntensity=2;
+       }
+       else if(labbook.source.Contains("Cd"))
+       {
+               sourceIntensity=2;
+       }
+       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
+               {       
+                       fcountPixelFakeHits++;
+                       fPixelFakeHits[ipixel]=0;//pixel is a fake hit pixel
+                       
+                        cout<<ipixel<<":"<<histoPixel->GetBinContent(ipixel)<<endl;
+               }
+               else
+               {       
+               //      cout<<ipixel<<":"<<histoPixel->GetBinContent(ipixel)<<"\t";
+                       fPixelFakeHits[ipixel]=1;//pixel is NOT a fake hit pixel
+               }
+               
+       }
+       cout<<"Number of masked pixel due to a fake hit rate above "<<fakehitrate<<"is: "<<fcountPixelFakeHits<<" of "<<pixels<<endl;
+return;        
+}
 #endif
index c71d41dd66b0b45134e8e5a334e3c67cf5a919b7..04f67122dd6c7c7de9eb77ab038f698657d91509 100644 (file)
@@ -392,7 +392,14 @@ public:
     HistogramType* histogram;
     HistogramType* histogramthreshold;
     HistogramType* histogramfixedthreshold;
-    HistogramType* dennismegacut;
+    HistogramType* histogramFSBB;
+       HistogramType* histogramFSBB2;
+       
+       void getPixelWithFakehits();
+       TH1F* histoPixelDiodeDiff;
+       TH1F* histoPixel; 
+    Float_t* fPixelFakeHits;
+       Int_t fcountPixelFakeHits;
     /// 
     /** @brief A vector able to hold pointer of type #Run::histogramstruct
      *
index 16dc6a9fe66e3938265cdd77b7ff123b4d701365..931d0db55980f4500d78c1157872e17c27bec4d4 100644 (file)
@@ -115,6 +115,8 @@ struct frameInfo{
     UInt_t  pixelfixedthreshold       [MAXHITS];
     /// holds charge collected by cluster for a given hit in frame, p[12][7] f.e. holds seed pixel charge of hit number 8 in frame
        Float_t p               [25][MAXHITS];
+       /// holds noise of the cluster for every pixel a cluster
+       Float_t n               [25][MAXHITS];
 };
 
 /** @brief system specific constants