]> jspc29.x-matter.uni-frankfurt.de Git - radhard.git/commitdiff
Run analyzer: Added possibility to analyze runs not finished yet
authorBenjamin Linnik <blinnik@jspc28.x-matter.uni-frankfurt.de>
Thu, 25 Jun 2015 13:39:28 +0000 (15:39 +0200)
committerBenjamin Linnik <blinnik@jspc28.x-matter.uni-frankfurt.de>
Thu, 25 Jun 2015 13:39:28 +0000 (15:39 +0200)
MABS_run_analyzer/ChargeSpektrum.c
MABS_run_analyzer/MAPS.c
MABS_run_analyzer/MAPS.h
MABS_run_analyzer/Run.c

index a7c1adbc7604fb61a84d25a93892c8fadda677fb..ee658a811f8c5b1b86479fe856a6e2a7849bbcd9 100644 (file)
@@ -160,8 +160,8 @@ void ChargeSpektrum(TString runnumber = "")
                     if (!isBatch)
                         gROOT->SetBatch(kFALSE);
                             runs[runi]->plotAllHistograms();
-//                     runs[runi]->plotAllHistogramsThresholdCluster();
-//                     runs[runi]->plotAllHistogramsThresholdClusterCalibrated();
+//                    runs[runi]->plotAllHistogramsThresholdCluster();
+                    runs[runi]->plotAllHistogramsThresholdClusterCalibrated();
                      runs[runi]->plotAllHistogramsCalibrated(); 
                     runs[runi]->writeAllHistogramsToFile(); 
                 }
@@ -171,6 +171,6 @@ void ChargeSpektrum(TString runnumber = "")
 //     plotAllRuns("");
     plotAllRuns("seed calibrated");
 //     writeObservableToFile("seed threshold calibrated");
-    writeObservableToFile("seed threshold");
+//    writeObservableToFile("seed threshold");
        writeObservableToFile("seed threshold calibrated");
 }
index c692665f9d1d5c4a1b02e6ad91b7b20e5e44374b..427a8171716588f65dac99f0d4a7cda334324f79 100644 (file)
@@ -43,34 +43,33 @@ MAPS::MAPS(Run* runp) {
 
 Bool_t MAPS::initNewRootFile() {
     fSave = true;
-    if ( checkConf(fPixelsData) ) // TODO FileEvNbInConfig
+    if ( !checkConf(fPixelsData) ) { // TODO FileEvNbInConfig
+        defaultConf();
+    }
+    //-----------------------------------------------
+    //Check and open Data Files
+    int MaxFiles = TMath::Ceil((Float_t) FileTotalEvNbInConfig/FileEvNbInConfig);
+    if( checkDataFiles(MaxFiles) )
     {
-            //-----------------------------------------------
-            //Check and open Data Files
-            int MaxFiles = TMath::Ceil((Float_t) FileTotalEvNbInConfig/FileEvNbInConfig);
-            if( checkDataFiles(MaxFiles) )
-                fOutputFile     = new TFile(fRootFile,"RECREATE");
-            {
-                // Hit TTree
-                fHitTree        = new TTree("hit", "hit");
-                fHitTree->Branch("frame"    , &fFrameInfo.frame ,     "frame/i"         , 32000);
-                fHitTree->Branch("hits"     , &fFrameInfo.hits  ,     "hits/i"          , 32000);
-                fHitTree->Branch("pixel"    , &fFrameInfo.pixel[0]  , "pixel[hits]/i"   , 32000);
-                fHitTree->Branch("pixelthreshold", &fFrameInfo.pixelthreshold[0],"pixelthreshold[hits]/i", 32000);
-                for(int i=0; i<25; i++) {
-                    fHitTree->Branch( Form("p%i",i+1)   , &fFrameInfo.p[i][0]   , Form("p%i [hits]/F",i+1)  , 32000);
-                }
-                // Noise TTree
-                fNoiseTree      = new TTree("noise", "noise");
-                fDynNoiseTree   = fNoiseTree;
-                initHistograms();
-                cout<<"-----------------------"<<endl;
-                cout<<fRootFile<<" recreated!"<<endl;
-                cout<<"-----------------------"<<endl;
-                return 0;
+        fOutputFile     = new TFile(fRootFile,"RECREATE");
+        // Hit TTree
+        fHitTree        = new TTree("hit", "hit");
+        fHitTree->Branch("frame"    , &fFrameInfo.frame ,     "frame/i"         , 32000);
+        fHitTree->Branch("hits"     , &fFrameInfo.hits  ,     "hits/i"          , 32000);
+        fHitTree->Branch("pixel"    , &fFrameInfo.pixel[0]  , "pixel[hits]/i"   , 32000);
+        fHitTree->Branch("pixelthreshold", &fFrameInfo.pixelthreshold[0],"pixelthreshold[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);
         }
-            //-----------------------------------------------
-    }        sleep(1); // TODO test if removable
+        // Noise TTree
+        fNoiseTree      = new TTree("noise", "noise");
+        fDynNoiseTree   = fNoiseTree;
+        initHistograms();
+        cout<<"-----------------------"<<endl;
+        cout<<fRootFile<<" recreated!"<<endl;
+        cout<<"-----------------------"<<endl;
+        return 0;
+    }
     return 1;    
 }
 
@@ -229,16 +228,15 @@ Bool_t MAPS::initMapsRun( ) {
         }
     }
     
-    ifstream    inn(fConfigFile, ios::binary);
-    if( !inn.good() )
-    {
-        cout<<"-----------------------"<<endl;
-        cout << colorred << "Configuration file not found: " ;
-        cout << fConfigFile;
-        cout << endlr;
-        cout << " -- STOP -- " << endl;
-        return true;
-    }
+//     ifstream    inn(fConfigFile, ios::binary);
+//     if( !inn.good() )
+//     {
+//         cout<<"-----------------------"<<endl;
+//         cout << colorred << "Configuration file not found: " ;
+//         cout << fConfigFile;
+//         cout << endlr;
+//         return true;
+//     }
     
     return false;
 //-----------------------------------------------
@@ -286,53 +284,49 @@ bool MAPS::switchsystem( )
     else
     {
         cout<<"-----------------------"<<endl;
-        cout << "\033[1;31mConfiguration file not found: ";
-        cout << fConfigFile;
-        cout << endl;
-
-        cout << " -- STOP -- " << endl;
+        cout << coloryellow << "Configuration file not found: ";
+        cout << fConfigFile << endlr;
         return false;
     }
     return false;
 }
 
 
-
 bool MAPS::checkConf( Int_t &PixelData ) {
-
+    
     UInt_t DataSz;
     UInt_t NrAdcBoards;
-
-    ifstream   inn(fConfigFile, ios::binary);
-
+    
+    ifstream    inn(fConfigFile, ios::binary);
+    
     if( inn.good() )
     {
         inn.seekg(0, ios::end);
         int End = inn.tellg();
         inn.seekg(0, ios::beg);
-
+        
         char* RAWDATA = new char[End];
-        inn.read       ( RAWDATA, End);
+        inn.read    ( RAWDATA, End);
         inn.close();
-
-        FileEvNbInConfig       = littleEndian32( RAWDATA, 4*3);        ///< Event number per file
-        FileTotalEvNbInConfig  = littleEndian32( RAWDATA, 4*4);        ///< Total events in RUN - should be less if RUN was stopped before endl
-//         FileTotalEvNbInConfig = 100000000;
-        DataSz         = littleEndian32( RAWDATA, 4*6);        ///< Datas size = BDB_VFAS_RAM_SZ_W32 X Adc number ( VFasRunNb field )
-        NrAdcBoards    = littleEndian32( RAWDATA, 4*9);        ///< Number of Adc boards installed in the system
-
-        PixelData      = DataSz/4;
+        
+        FileEvNbInConfig    = littleEndian32( RAWDATA, 4*3);    ///< Event number per file
+        FileTotalEvNbInConfig   = littleEndian32( RAWDATA, 4*4);    ///< Total events in RUN - should be less if RUN was stopped before endl
+        //         FileTotalEvNbInConfig = 100000000;
+        DataSz      = littleEndian32( RAWDATA, 4*6);    ///< Datas size = BDB_VFAS_RAM_SZ_W32 X Adc number ( VFasRunNb field )
+        NrAdcBoards = littleEndian32( RAWDATA, 4*9);    ///< Number of Adc boards installed in the system
+        
+        PixelData   = DataSz/4;
         
         TString System[5] = {"","","USB","","PXI"};
         if( fSystem == "" )
         {
-            if( NrAdcBoards == 1)      {
+            if( NrAdcBoards == 1)   {
                 fSystem = "USB";
             }
-            if( NrAdcBoards == 2)      {
+            if( NrAdcBoards == 2)   {
                 fSystem = "USB";
             }
-            if( NrAdcBoards == 4)      {
+            if( NrAdcBoards == 4)   {
                 fSystem = "PXI";
             }
         }
@@ -341,7 +335,7 @@ bool MAPS::checkConf( Int_t &PixelData ) {
             cout<<"---------"<<endl;
             cout<<"System specification ( "<<fSystem<<" ) might be incorrect!"<<endl;
             cout<<"Wait 10 sec. to continue: ";
-
+            
             for(int i=0; i<10; i++)
             {
                 cout<<".";
@@ -351,34 +345,34 @@ bool MAPS::checkConf( Int_t &PixelData ) {
             cout<<endl;
             cout<<"---------"<<endl;
         }
-
+        
         delete[] RAWDATA;
-//-----------------------------------------------
+        //-----------------------------------------------
         cout<<"-----------------------"<<endl;
         cout<<" ==> Check config file ..."<<endl;
         cout<<"-----------------------"<<endl;
-        cout<<" Config File           : "<< fRootFile  <<endl;
-        cout<<" Events per File       : "<<setw(10)<<left<< FileEvNbInConfig   <<endl;
-        cout<<" Total Events          : "<<setw(10)<<left<< FileTotalEvNbInConfig              <<" (?)"<<endl;
+        cout<<" Config File           : "<< fRootFile   <<endl;
+        cout<<" Events per File       : "<<setw(10)<<left<< FileEvNbInConfig    <<endl;
+        cout<<" Total Events          : "<<setw(10)<<left<< FileTotalEvNbInConfig       <<" (?)"<<endl;
         cout<<" Pixels in Data        : "<<fPixelsData<<endl;
         cout<<" System found          : "<<System[NrAdcBoards]<<endl;
         cout<<"-----------------------"<<endl;
-
+        
         if( fPixelsData<fPixels )
         {
             cout<<"ERROR -> Number of Pixels defined is bigger than found: "<<fPixels<<" <-> "<<fPixelsData<<endl;
             cout<<"-----------------------"<<endl;
             return false;
         }
-//-----------------------------------------------
-//PARAMETER:
-        fF0matrix      = new Int_t             [fPixelsData]();
-        fF1matrix      = new Int_t             [fPixelsData]();
-        fCdsmatrix     = new Float_t           [fPixelsData]();
-        fNoise         = new Float_t   [fPixelsData]();
-        fPedestals     = new Float_t   [fPixelsData]();
-        fHittedPixel= new Int_t                [fPixelsData]();
-//-----------------------------------------------
+        //-----------------------------------------------
+        //PARAMETER:
+        fF0matrix   = new Int_t     [fPixelsData]();
+        fF1matrix   = new Int_t     [fPixelsData]();
+        fCdsmatrix  = new Float_t       [fPixelsData]();
+        fNoise      = new Float_t   [fPixelsData]();
+        fPedestals  = new Float_t   [fPixelsData]();
+        fHittedPixel= new Int_t     [fPixelsData]();
+        //-----------------------------------------------
         return true;
     }
     else
@@ -387,12 +381,35 @@ bool MAPS::checkConf( Int_t &PixelData ) {
         cout << "Configuration file not found: ";
         cout << fConfigFile;
         cout << endl;
-
-        cout << " -- STOP -- " << endl;
         return false;
     }
 }
 
+bool MAPS::defaultConf(  ) {
+    FileEvNbInConfig    = 20000;    ///< Event number per file
+    FileTotalEvNbInConfig   = 10000000;
+    fPixelsData = run->sensorinfocur.columns*run->sensorinfocur.rows;
+//-----------------------------------------------
+    cout<<"-----------------------"<<endl;
+    cout<<" ==> Load default config file ..."<<endl;
+    cout<<"-----------------------"<<endl;
+    cout<<" Config File           : default"  <<endl;
+    cout<<" Events per File       : "<<setw(10)<<left<< FileEvNbInConfig       <<endl;
+    cout<<" Total Events          : "<<setw(10)<<left<< "?" <<endl;
+    cout<<" Pixels in Data        : "<<fPixelsData<<endl;
+    cout<<"-----------------------"<<endl;
+
+//PARAMETER:
+    fF0matrix  = new Int_t             [fPixelsData]();
+    fF1matrix  = new Int_t             [fPixelsData]();
+    fCdsmatrix = new Float_t           [fPixelsData]();
+    fNoise             = new Float_t   [fPixelsData]();
+    fPedestals = new Float_t   [fPixelsData]();
+    fHittedPixel= new Int_t            [fPixelsData]();
+//-----------------------------------------------
+    return true;
+}
+
 //####################################################################
 
 bool MAPS::checkDataFiles( Int_t MaxFiles ) {
@@ -426,8 +443,8 @@ bool MAPS::checkDataFiles( Int_t MaxFiles ) {
     cout<< "TOTAL FRAMES FOUND: "<<fEventsSum<<endl;
     if (FileTotalEvNbInConfig != fEventsSum)
     {
-        cout<< colorred <<"-----------------------"<<endl;
-        cout<<"WARNING: Number of found events not equal to number of events stated in config file! " << FileTotalEvNbInConfig << " != " << fEventsSum << endl;
+        cout<< "-----------------------"<<endl;
+        cout<< coloryellow << "Number of found events not equal to number of events stated in config file! " << FileTotalEvNbInConfig << " != " << fEventsSum << endlr;
         cout<<"-----------------------" << endlr;
     }
     if(!fOk)
index 385bdbc827e67f8b6ada717a181a9ea24a256be7..85b6889769ec321a7983122a3a5835b2c5d27c98 100644 (file)
@@ -228,6 +228,15 @@ private:
      */
     bool        checkConf(Int_t&);
     
+    /**
+     *  @brief  Sets default parameters of a typical configuration file
+     *  @return  true on success, false on failure
+     * 
+     * If no config file was found, assume a typical config file .
+     * This procedure allows to analyze RAW data runs not finished yet.
+     */
+    bool        defaultConf();
+    
     /**
      *  @brief  If specified system (USB or PXI) is wrong, return true
      *  @return  true on wrong specification, false on correct
index f67d28bda16bb3e303848f2591028d655893ec7c..0f59284c440f06978ad102d8f7c781112014989c 100644 (file)
@@ -639,8 +639,6 @@ string Run::to_str_w_prec(const Float_t a_value, int precision = 3)
     return out.str();
 }
 
-
-
 Bool_t Run::binNoise()
 {
     Float_t noise;
@@ -764,7 +762,6 @@ Bool_t Run::plotSeed()
     return 1;
 }
 
-
 Bool_t Run::plotSeedThreshold()
 {
     if (!error)
@@ -785,8 +782,6 @@ Bool_t Run::plotSeedThresholdCalibrated()
     return 1;
 }
 
-
-
 Bool_t Run::plotSum()
 {
     if (!error)
@@ -1203,7 +1198,8 @@ Bool_t Run::writeAllHistogramsToFile()
     TString filename= savepathresults + "/" + runcode + " histograms.dat";
     fstream* fout = new fstream(filename,ios::out);
     
-    TString header = Form("#bin [ADU]\tbin [e]\tSeed\tSum\tVeto\tSeed thrsh\tSum thrsh\tbin noise [ADU]\tbin noise [e]\tnoise\n");
+    TString header = Form("#%s %lu frames\n", runcode.Data(), (labbook.frames_foundDB>0)?labbook.frames_foundDB:frames_found);
+    header += Form("#bin [ADU]\tbin [e]\tSeed\tSum\tVeto\tSeed thrsh\tSum thrsh\tbin noise [ADU]\tbin noise [e]\tnoise\n");
     header += Form("#posVeto, run: %.1f, DB: %.1f, Fe55 DB (%d, %.1f): %.1f\n", histogram.posVeto, labbook.posVetoDB, Fe55run.posVetorunnumber, Fe55run.temperature, Fe55run.posVeto);
     header += Form("#posSeed, run: %.1f, DB: %.1f\n", histogram.posSeed, labbook.posSeedDB);
     header += Form("#posSum, run: %.1f, DB: %.1f\n", histogram.posSum, labbook.posSumDB);