Changeset 17075 for trunk/Mars/fact


Ignore:
Timestamp:
09/05/13 11:34:42 (11 years ago)
Author:
tbretz
Message:
Read and write header; use gLog; increased ssbin range for rate; added histogram for crosstalk coefficient.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Mars/fact/analysis/gain/fit_spectra.C

    r17053 r17075  
    99#include <TStyle.h>
    1010
     11#include "MLog.h"
     12#include "MLogManip.h"
    1113#include "MStatusArray.h"
    1214#include "MStatusDisplay.h"
     
    1517#include "MParameters.h"
    1618#include "MArrayI.h"
     19#include "MRawRunHeader.h"
    1720
    1821using namespace std;
     
    140143    if (file.IsZombie())
    141144    {
    142         cout << "Opening file '" << filename << "' failed." << endl;
     145        gLog << err << "Opening file '" << filename << "' failed." << endl;
    143146        return 1;
    144147    }
     
    147150    if (arr.Read()<=0)
    148151    {
    149         cout << "Reading of MStatusArray from '" << filename << "' failed." << endl;
     152        gLog << err << "Reading of MStatusArray from '" << filename << "' failed." << endl;
    150153        return 2;
    151154    }
     
    154157    if (!hsignal)
    155158    {
    156         cout << "Histogram Signal not found in '" << filename << "'." << endl;
     159        gLog << err << "Histogram Signal not found in '" << filename << "'." << endl;
    157160        return 3;
    158161    }
     
    160163    if (!htime)
    161164    {
    162         cout << "Histogram Time not found in '" << filename << "'." << endl;
    163         return 3;
     165        gLog << err << "Histogram Time not found in '" << filename << "'." << endl;
     166        return 4;
    164167    }
    165168    TProfile2D *hpulse = (TProfile2D*)arr.FindObjectInCanvas("Pulse", "TProfile2D", "MHSingles");
    166169    if (!hpulse)
    167170    {
    168         cout << "Histogram Pulse not found in '" << filename << "'." << endl;
    169         return 3;
     171        gLog << err << "Histogram Pulse not found in '" << filename << "'." << endl;
     172        return 5;
    170173    }
    171174    TH2F *hbase = (TH2F*)arr.FindObjectInCanvas("Baseline", "TH2F", "MHBaseline");
    172175    if (!hbase)
    173176    {
    174         cout << "Histogram Baseline not found in '" << filename << "'." << endl;
    175         return 3;
     177        gLog << err << "Histogram Baseline not found in '" << filename << "'." << endl;
     178        return 6;
     179    }
     180
     181    MRawRunHeader header;
     182    if (header.Read()<=0)
     183    {
     184        gLog << err << "MRawRunheader not found in '" << filename << "'." << endl;
     185        return 7;
    176186    }
    177187
     
    179189    if (par.Read()<=0)
    180190    {
    181         cout << "NumEvents not found in '" << filename << "'." << endl;
    182         return 4;
     191        gLog << err << "NumEvents not found in '" << filename << "'." << endl;
     192        return 8;
    183193    }
    184194
     
    186196    if (ext.Read("ExtractionRange")<=0)
    187197    {
    188         cout << "ExtractionRange not found in '" << filename << "'." << endl;
    189         return 5;
     198        gLog << err << "ExtractionRange not found in '" << filename << "'." << endl;
     199        return 9;
    190200
    191201    }
     
    226236
    227237    // Instantiate 1D histograms for the distributions
    228     TH1F hRate     ("Rate",      "Dark count rate",       100,  0,    10);
     238    TH1F hRate     ("Rate",      "Dark count rate",       150,  0,    15);
    229239    TH1F hGain     ("Gain",      "Gain distribution",     100,  0,   400);
    230240    TH1F hRelSigma ("RelSigma",  "Rel. Sigma",            160,  0,  0.40);
     
    317327    if (fwhmSum==0)
    318328    {
    319         cout << "Could not determine start value for sigma." << endl;
     329        gLog << warn << "Could not determine start value for sigma." << endl;
    320330    }
    321331
     
    393403        if (hist->GetEntries()<100)
    394404        {
    395             cout << pixel << " ...histogram empty." << endl;
     405            gLog << warn << pixel << " ...histogram empty." << endl;
    396406            usePixel[pixel] = 0;
    397407            delete hist;
     
    488498        // mark pixels suspicious with failed fit
    489499        if (!ok)
    490             cout <<  pixel << " ...fit failed!" << endl;
     500            gLog << warn <<  pixel << " ...fit failed!" << endl;
    491501
    492502        // mark pixels suspicious with negative GainRMS
    493503        if (fabs(fGain/gain-1)>0.3)
    494504        {
    495             cout <<  pixel << " ...gain deviates more than 30% from sum-gain." << endl;
     505            gLog << warn <<  pixel << " ...gain deviates more than 30% from sum-gain." << endl;
    496506            ok = 0;
    497507        }
     
    499509        if (fabs(fOffset/integration_window)>3)
    500510        {
    501             cout <<  pixel << " ...baseline deviates." << endl;
     511            gLog << warn <<  pixel << " ...baseline deviates." << endl;
    502512            ok = 0;
    503513        }
     
    548558        hNormGain.Fill(  fGain/gain);
    549559        hFitProb.Fill(   fit_prob);
     560        hCrosstalkP.Fill(fCrosstalkP);
     561        hCoeffR.Fill(    fCoeffR);
    550562
    551563        // Fill sum spectrum
     
    771783    // ================================================================
    772784
    773     cout << "saving results to rootfile" << endl;
     785    cout << "Saving results to '" << outfile << "'" << endl;
    774786    d->SaveAs(outfile);
    775787    cout << "..success!" << endl;
     
    778790    par.Write();
    779791    ext.Write("ExtractionRange");
     792    header.Write();
    780793
    781794    return 0;
Note: See TracChangeset for help on using the changeset viewer.