]> jspc29.x-matter.uni-frankfurt.de Git - radhard.git/commitdiff
Run analyzer: Code cleanup
authorBenjamin Linnik <blinnik@jspc28.x-matter.uni-frankfurt.de>
Wed, 25 Feb 2015 18:05:10 +0000 (19:05 +0100)
committerBenjamin Linnik <blinnik@jspc28.x-matter.uni-frankfurt.de>
Wed, 25 Feb 2015 18:05:10 +0000 (19:05 +0100)
MABS_run_analyzer/ChargeSpektrum.c
MABS_run_analyzer/MAPS.c
MABS_run_analyzer/MAPS.h
MABS_run_analyzer/Run.c
MABS_run_analyzer/Run.h
MABS_run_analyzer/Run_analyzer.h
MABS_run_analyzer/doxygenconfig.cfg

index 6c7eaa5794253ef59038378b7a500ee536fe7e28..6c1cf097c4960d71c1adeef73eb0c70dc3d4e3fc 100644 (file)
@@ -1,6 +1,25 @@
+/**
+ * @file ChargeSpektrum.c
+ * @brief Use brief, otherwise the index won't have a brief explanation.
+ *
+ * Detailed explanation.
+ * 
+ * 
+ */
+
 #include "Run.h"
 #include "MAPS.h"
 
+
+/**
+ * @file
+ * @brief Use brief, otherwise the index won't have a brief explanation.
+ *
+ * Detailed explanation.
+ * 
+ * 
+ */
+
 // bad c- style fix me
 #include "Run.c"
 #include "MAPS.c"
index 8287669f5d74b58d86b40ca6ad1da555ea9e5493..e6d201b37ea1df7ce1cd6dc7efda18a81c5f2863 100644 (file)
@@ -1,3 +1,12 @@
+/**
+ * @file MAPS.c
+ * @brief Use brief, otherwise the index won't have a brief explanation.
+ *
+ * Detailed explanation.
+ * 
+ * 
+ */
+
 #include"MAPS.h"
 #include "Run.h"
 
@@ -30,7 +39,6 @@ MAPS::MAPS(Run* runp) {
     }        sleep(1); // TODO test if removable
     
 
-
     if ( checkConf(fPixelsData) ) // TODO FileEvNbInConfig
     {
         //-----------------------------------------------
@@ -116,7 +124,7 @@ void MAPS::initMapsRun( ) {
     fRootFile   = fInDir+Form("/RUN_%i_i.root",fRunNumber);
 
     cout<<"================================================================="<<endl;
-    cout<<"-----------------------"<<endl;
+    cout<<"-----------------------"  << endl;
     cout<<" == Initiate MAPS() ... == "<<endl;
     cout<<"-----------------------"<<endl;
     cout<<" Input  Directory      : "<<fInDir<<endl;
@@ -127,6 +135,11 @@ void MAPS::initMapsRun( ) {
     cout<<" Ordering according to : "<<fOrderCode<<endl;
     cout<<" Save/Overwrite data   : "<<fSave<<endl;
     cout<<" System specified      : "<<fSystem<<endl;
+    cout<<" Dynamic noise calc    : ";
+    if (useexponentialdecayingnoisewindow)
+        cout << "Modified moving average (MMA)" << endl;
+    else
+        cout << "Simple moving average (SMA)" << endl;
 
 //-----------------------------------------------
     unsigned short int vi,vj;
@@ -530,7 +543,6 @@ bool MAPS::getFrame(Int_t FrameNumber) {
                 fF0matrix      [i]     = value1        [(UChar_t)RAWDATA[4*i+1]]       [(UChar_t)RAWDATA[4*i+2]];
                 fF1matrix      [i]     = value2        [(UChar_t)RAWDATA[4*i]] [(UChar_t)RAWDATA[4*i+1]];
             }
-
             fCdsmatrix [i] = fF0matrix[i] - fF1matrix[i];
         }
 //==========================================================================
@@ -710,8 +722,6 @@ bool MAPS::InitialDynNoise(Int_t startframe, Int_t frames) {
         {
             fPedestals[pixeli] /= frames;
         }
-//         cout << "Pedestials, first estimate: ";
-//         debugStream(fPedestals, fPixels, fColumns, 3);
         
         // sum up over all frames every variance from the pedestial, pixelwise
         for(Int_t framei=startframe; framei<frames+startframe; framei++)
@@ -722,14 +732,10 @@ bool MAPS::InitialDynNoise(Int_t startframe, Int_t frames) {
                 fNoise[pixeli] += TMath::Power(1.*fCdsmatrix[pixeli]-fPedestals[pixeli],2);
             }
         }
-//         cout << endl << endl;
-        // calculate average noise of each pixel
         for(Int_t pixeli=0; pixeli<fPixels; pixeli++)
         {
             fNoise[pixeli] = TMath::Sqrt(fNoise[pixeli]/(frames-1)); // Standard deviation is defined with n-1 
         }
-//         cout << "Noise, first estimate: ";
-//         debugStream(fNoise, fPixels, fColumns, 3);
         
         // second estimate
         // cut away pixels with cds - Pedestals > 5 * sigma
@@ -792,16 +798,13 @@ bool MAPS::InitialDynNoise(Int_t startframe, Int_t frames) {
         for(Int_t framei=startframe; framei<frames+startframe; framei++)
         {
             getFrame(framei);
-            if (framei==0)
-                debugStream(fCdsmatrix, fPixels, fColumns, 2);
             for(Int_t pixeli=0; pixeli<fPixels; pixeli++)
             {
                 if (abs(1.*(fCdsmatrix[pixeli]-pixelpedestal2[pixeli])) < 5.*pixelnoise2[pixeli])
                 {
                     fPedestals[pixeli] += fCdsmatrix[pixeli];
-//                     if (pixeli==0)
-//                         cout << fCdsmatrix[pixeli] << "  ";
-                    noiselastframes[pixeli].push(fCdsmatrix[pixeli]);
+                    if (!useexponentialdecayingnoisewindow)
+                        noiselastframes[pixeli].push(fCdsmatrix[pixeli]);
                 }
                 else
                 {
@@ -810,13 +813,9 @@ bool MAPS::InitialDynNoise(Int_t startframe, Int_t frames) {
                 }
             }
         }
-//         cout << noiselastframes[0].front() << endl;
-//         cout << noiselastframes[0].size() << endl;
-        // calculate average pedestal of each pixel
         for(Int_t pixeli=0; pixeli<fPixels; pixeli++)
         {
             fPedestals[pixeli] /= (frames-nframescutawaythirdnoiseestimate[pixeli]);
-//             fPedestals[pixeli] = 0;
         }
         
         // sum up over all frames every variance from the pedestial, pixelwise
@@ -1045,26 +1044,23 @@ bool MAPS::getDynNoise2(Int_t Frames) {
 //####################################################################
 
 
-bool MAPS::regetDynNoise(Int_t Frames) {  
-    
+bool MAPS::regetDynNoise(Int_t Frames) {
     for(Int_t pixeli=0; pixeli<fPixels; pixeli++)
     {
         if (fHittedPixel[fColumns]==0)
         {
-            fNoise[pixeli]-=(TMath::Power(noiselastframes[pixeli].front()-fPedestals[pixeli],2)-TMath::Power(fCdsmatrix[pixeli]-fPedestals[pixeli],2))/(noiselastframes[pixeli].size()-1);
-            fPedestals[pixeli] -= (noiselastframes[pixeli].front()-fCdsmatrix[pixeli])/noiselastframes[pixeli].size();
-//                fPedestals[pixeli] = ( (Frames-1)*fPedestals[pixeli] + fCdsmatrix[pixeli] )/Frames;
-//             if (pixeli==0*fColumns && fFrameNumber%10000==0)
-//             {
-//                 cout << "( 99 * " << fPedestals[pixeli] << " + " << fCdsmatrix[pixeli] << " )/ " << Frames << endl;
-//             }
-//                 cout << fPedestals[pixeli] << "  " <<endl;
-            //             fNoise[pixeli]= ( (Frames-1)*fNoise[pixeli] + TMath::Power(1.*fCdsmatrix[pixeli]-fPedestals[pixeli],2) )/(Frames);
-//             if (pixeli==0)
-//                 cout << noiselastframes[pixeli].front() << "  " ;
-            noiselastframes[pixeli].pop();
-            noiselastframes[pixeli].push(fCdsmatrix[pixeli]);
-            
+            if (useexponentialdecayingnoisewindow)
+            {
+                fNoise[pixeli]     = ( (Frames-1)*fNoise[pixeli] + TMath::Power(1.*fCdsmatrix[pixeli]-fPedestals[pixeli],2) )/(Frames);
+                fPedestals[pixeli] = ( (Frames-1)*fPedestals[pixeli] + fCdsmatrix[pixeli] )/Frames;
+            }
+            else
+            {
+                fNoise[pixeli]     -= (TMath::Power(noiselastframes[pixeli].front()-fPedestals[pixeli],2)-TMath::Power(fCdsmatrix[pixeli]-fPedestals[pixeli],2))/(noiselastframes[pixeli].size()-1);
+                fPedestals[pixeli] -= (noiselastframes[pixeli].front()-fCdsmatrix[pixeli])/noiselastframes[pixeli].size();
+                noiselastframes[pixeli].pop();
+                noiselastframes[pixeli].push(fCdsmatrix[pixeli]);
+            }
         }
         else
         {
@@ -1077,16 +1073,16 @@ bool MAPS::regetDynNoise(Int_t Frames) {
             {
                 fNoiseMean      = TMath::Mean((const int)fPixels, fNoise);
                 fPedestalsMean  = TMath::Mean((const int)fPixels, fPedestals);
-                
                 fDynNoiseTree->Fill();
             }
         }
     }
     
-    if ( fFrameNumber%10000==0)
-    {
-        debugStream<>(fPedestals, fPixels, fColumns, 2);
-    }
+// debug    
+//     if ( fFrameNumber%10000==0)
+//     {
+//         debugStream<>(fPedestals, fPixels, fColumns, 2);
+//     }
     return true;
 }
 
@@ -1282,6 +1278,7 @@ void MAPS::hitana() {
                     }
                 }
             }
+//             debug
 //             for(Int_t row=0; row<5; row++)
 //             {
 //                 for(Int_t column=0; column<5; column++)
@@ -1446,7 +1443,6 @@ void MAPS::filterCommonMode() {
 
         for(int column=0; column<fColumns; column++ )
         {
-//             Arr[column] = fCdsmatrix[ row*fColumns+column ];
             Arr[column] = fCdsmatrix[ row*fColumns+column ] - fPedestals[ row*fColumns+column ];       // Bugfix: Considered pedestals in common mode calculation
         }
 
@@ -1457,14 +1453,6 @@ void MAPS::filterCommonMode() {
         else
             minus++;
         
-//         if (row==0 && fFrameNumber%10000==0)
-//         {
-//             cout << endl;
-//             for(int column=0; column<fColumns; column++ )
-//                 cout << Arr[column] << endl;
-//             cout << endl << " --> " << CommonModeInRow << endl;
-//         }
-        
         if(TMath::Abs(CommonModeInRow)>20) // TODO better warning criteria
         {
             warning = true;
@@ -1478,10 +1466,10 @@ void MAPS::filterCommonMode() {
             fCdsmatrix[ row*fColumns+column ] -= CommonModeInRow;
         }
     }
-    if ( fFrameNumber%10000==0)
-    {
-        debugStream<>(fPedestals, fPixels, fColumns, 2);
-    }
+//     if ( fFrameNumber%10000==0)
+//     {
+//         debugStream<>(fPedestals, fPixels, fColumns, 2);
+//     }
 }
 
 //####################################################################
index ac72e38e16d76c4505b8363a12a5db751bbb5ead..19842e2f058a17eb7148f896d6a4142cb38866cb 100644 (file)
 class Run;
 
 /**
- * @file
+ * @file MAPS.h
  * @brief Use brief, otherwise the index won't have a brief explanation.
  *
  * Detailed explanation.
  * 
  * 
  */
-class MAPS {
+class MAPS {   
     
 private:
     /// Input Directory, set and passed initMapsRun() to  in the constructor
@@ -382,6 +382,7 @@ public:
     // pointer to TTree with hit, frame and cluster information
     TTree*  fHitTree;
     
+    Bool_t useexponentialdecayingnoisewindow = 0;
     
     Long_t plus = 0;
     Long_t minus = 0;
index 1401eb6a730fe34ca60ea2a0a94381a91053b184..2e52091fbf120ac649aa8e5af4bb1e1e38a3c577 100644 (file)
@@ -1,3 +1,12 @@
+/**
+ * @file Run.c
+ * @brief Use brief, otherwise the index won't have a brief explanation.
+ *
+ * Detailed explanation.
+ * 
+ * 
+ */
+
 #include "Run.h"
 using namespace std;
 
@@ -108,7 +117,7 @@ Bool_t Run::analyzeRun(Bool_t force)
                 processed->hitana();
                 processed->regetDynNoise();
                 progress = (Int_t)(((i-start)*100)/(nframes-1)*10);
-//                 if (progress!=progress_tmp)  { print_progress( (((i-start)*100.)/(nframes-1)) ); progress_tmp=progress;}
+                if (progress!=progress_tmp)  { print_progress( (((i-start)*100.)/(nframes-1)) ); progress_tmp=progress;}
             }
             cout << processed->plus << " vs. " << processed->minus << " : " << (processed->plus*1.0)/processed->minus<< endl;
             // print a dummy file to indicate, that a root file was created once
@@ -136,8 +145,9 @@ Bool_t Run::analyzeRun(Bool_t force)
 //             cout << "\033[1;31mError: cannot open " << rootfilepath << "\033[0m\n";
 //             exit(0);
 //         }
-        
+        return true;
     }
+    return false;
 }
 
 
@@ -155,13 +165,14 @@ Bool_t Run::analyzeFrame(Int_t frame)
             processed->hitana();
             processed->plotFrame(frame);
             binNoise();
+            return true;
         }
         else
         {
             cout << "\033[1;33mFrame number too big, max frame: " << entries << "\033[0m" << endl;
         }
-           
     }
+    return false;
 }
 
 // generateSeedSpectrum()
index 237a4f451de1dc6130d1778286272da338bd8c5c..3eebd9eedac2d2a7aa6e990e95a6aec75c9255cd 100644 (file)
@@ -27,8 +27,8 @@
 #include "MAPS.h"
 class MAPS;
 
-
 /**
+ * @file Run.h
  * @brief Has all the raw and processed information about a specific run
  *
  * This class makes SQL requests to the server, gets database results to a given runnumber,
index f630a1b77e0d8ddc2220af9115af4a034a714274..0049ae0f244bb2e0c271d1375bece72ec6dcf1f0 100644 (file)
@@ -8,7 +8,7 @@ Int_t numberRuns=0;
 
 
 /**
- * @file
+ * @file Run_analyzer.h
  * @brief Analyze and plot MABS runs
  *
  * Detailed explanation.
index d2c864e34235b29b8be0401c13d0f09a5f59529a..f79afb2a9a663bb4252fc837b9d50aefd2972925 100644 (file)
@@ -788,12 +788,12 @@ FILTER_SOURCE_PATTERNS =
 # Note: To get rid of all source code in the generated output, make sure also
 # VERBATIM_HEADERS is set to NO.
 
-SOURCE_BROWSER         = NO
+SOURCE_BROWSER         = YES
 
 # Setting the INLINE_SOURCES tag to YES will include the body
 # of functions and classes directly in the documentation.
 
-INLINE_SOURCES         = NO
+INLINE_SOURCES         = YES
 
 # Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct
 # doxygen to hide any special comment blocks from generated source code