Ignore:
Timestamp:
07/13/01 18:13:06 (23 years ago)
Author:
tbretz
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars/mhist
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/mhist/MHMcCollectionArea.cc

    r859 r867  
    2626#include "MHMcCollectionArea.h"
    2727
    28 #include <MLog.h>
    29 #include <TH2.h>
     28#include <TH2.h>
     29#include <TCanvas.h>
    3030
    3131ClassImp(MHMcCollectionArea);
     
    4949
    5050
    51     fHistAll = new TH2D("collAreaAll", "all showers - Radius vs log(E) distribution",
     51    fHistAll = new TH2D("All Events", "All showers - Radius vs log(E) distribution",
    5252                        50, 0., 5.,
    5353                        50, 0., 500.);
    5454
    55     fHistSel = new TH2D("collAreaSel", "selected showers - Radius vs log(E) distribution",
     55    fHistAll->SetXTitle("log(E/GeV)");
     56    fHistAll->SetYTitle("r/m");
     57    fHistAll->SetZTitle("N");
     58
     59    fHistSel = new TH2D("Selected Events", "Selected showers - Radius vs log(E) distribution",
    5660                        50, 0., 5.,
    5761                        50, 0., 500.);
    5862
    59     fHistCol = new TH1D("collArea", "Collection Area",
     63    fHistSel->SetXTitle("log(E/GeV)");
     64    fHistSel->SetYTitle("r/m");
     65    fHistSel->SetYTitle("N");
     66
     67    fHistCol = new TH1D("Area", "Collection Area vs. log(E)",
    6068                        50, 0., 5.);
     69
     70    fHistCol->SetXTitle("log(E/GeV)");
     71    fHistCol->SetYTitle("A/m^2");
    6172}
    6273
     
    7889}
    7990
    80 void MHMcCollectionArea::DrawAll()
     91void MHMcCollectionArea::DrawAll(Option_t* option)
    8192{
    82     fHistAll->Draw();
     93    TCanvas *c=new TCanvas(fHistAll->GetName(), fHistAll->GetTitle());
     94
     95    fHistSel->Draw(option);
     96
     97    c->Modified();
     98    c->Update();
    8399}
    84100
    85 void MHMcCollectionArea::DrawSel()
     101void MHMcCollectionArea::DrawSel(Option_t* option)
    86102{
    87     fHistSel->Draw();
     103    TCanvas *c=new TCanvas(fHistSel->GetName(), fHistSel->GetTitle());
     104
     105    fHistSel->Draw(option);
     106
     107    c->Modified();
     108    c->Update();
    88109}
    89110
    90111void MHMcCollectionArea::Draw(Option_t* option)
    91112{
     113    TCanvas *c=new TCanvas(fHistCol->GetName(), fHistCol->GetTitle());
     114
    92115    fHistCol->Draw(option);
     116
     117    c->Modified();
     118    c->Update();
    93119}
    94120
  • trunk/MagicSoft/Mars/mhist/MHMcCollectionArea.h

    r853 r867  
    2121{
    2222private:
    23     TH2D  *fHistAll ; //! all simulated showers
    24     TH2D  *fHistSel ; //! the selected showers
    25     TH1D  *fHistCol ; //  the collection area
     23    TH2D *fHistAll; //! all simulated showers
     24    TH2D *fHistSel; //! the selected showers
     25
     26    TH1D *fHistCol; //  the collection area
    2627
    2728public:
    2829
    29     MHMcCollectionArea(const char *name=NULL, const char *title=NULL) ;
    30     ~MHMcCollectionArea() ;
     30    MHMcCollectionArea(const char *name=NULL, const char *title=NULL);
     31    ~MHMcCollectionArea();
    3132
    32     void FillAll(Float_t log10E, Float_t radius) ;
    33     void FillSel(Float_t log10E, Float_t radius) ;
    34     void DrawAll() ;
    35     void DrawSel() ;
    36     void Draw(Option_t* option = "") ;
    37     void CalcEfficiency() ;
     33    void FillAll(Float_t log10E, Float_t radius);
     34    void FillSel(Float_t log10E, Float_t radius);
     35
     36    void DrawAll(Option_t *option = "");
     37    void DrawSel(Option_t *option = "");
     38    void Draw   (Option_t *option = "");
     39
     40    void CalcEfficiency();
    3841
    3942    ClassDef(MHMcCollectionArea, 1)  //  Data Container to calculate Collection Area
  • trunk/MagicSoft/Mars/mhist/MHMcEnergies.cc

    r861 r867  
    6666    delete fHists;
    6767}
     68
    6869// --------------------------------------------------------------------------
    6970//
  • trunk/MagicSoft/Mars/mhist/MHMcEnergy.cc

    r863 r867  
    5151
    5252    if (idx>0)
    53         sprintf(aux+10, ";%i", idx);
     53        sprintf(aux+strlen(aux), ";%i", idx);
     54
    5455    *fName  = name  ? name  : aux;
    55     *fTitle = title ? title : "Container for a MC energy histogram" ;
     56    *fTitle = title ? title : "Container for an energy distribution histogram" ;
    5657
    57     //  - we initialize the histogram and the gaus function
     58    //  - we initialize the histogram
    5859    //  - we have to give diferent names for the diferent histograms because
    5960    //    root don't allow us to have diferent histograms with the same name
    6061
    61     strcpy(aux, "fLogEnergy");
     62    char text[256];
     63    sprintf(text, "Energy Distribution for trigger condition #%i", idx);
     64
     65    strcpy(aux, "log(E)");
    6266    if (idx>0)
    63         sprintf(aux+10, ";%i", idx);
    64     fLogEner = new TF1(aux, "gaus", 1., 3.);
    65 
    66     strcpy(aux, "hLogEnergy");
    67     if (idx>0)
    68         sprintf(aux+10, ";%i", idx);
    69     hLogEner = new TH1F(aux, "", 40, 0.5, 4.5);
    70     hLogEner->SetXTitle("log(E) [GeV]");
    71     hLogEner->SetYTitle("dN/dE");
     67        sprintf(aux+strlen(aux), " #%i", idx);
     68    fHist = new TH1F(aux, text, 40, 0.5, 4.5);
     69    fHist->SetXTitle("log(E/GeV)");
     70    fHist->SetYTitle("dN/dE");
    7271}
    7372
     
    7877MHMcEnergy::~MHMcEnergy()
    7978{
    80     delete hLogEner;
    81     delete fLogEner;
     79    delete fHist;
    8280}
    8381
     
    8886void MHMcEnergy::Fill(Float_t log10E, Float_t w)
    8987{
    90     hLogEner->Fill(log10E, w);
     88    fHist->Fill(log10E, w);
    9189}
    9290
     
    10199    // Q: quiet mode
    102100    //
    103     hLogEner->Fit(fLogEner->GetName(), "Q0", "", xxmin, xxmax);
     101    fHist->Fit("gaus", "Q0", "", xxmin, xxmax);
     102
     103    TF1 *result = fHist->GetFunction("gaus");
     104
     105    fThreshold    = CalcThreshold(result);
     106    fThresholdErr = CalcThresholdErr(result);
     107    fGaussPeak    = CalcGaussPeak(result);
     108    fGaussSigma   = CalcGaussSigma(result);
    104109}
    105110
     
    110115void MHMcEnergy::Draw(Option_t *option)
    111116{
    112     char text[50];
    113     sprintf(text, "Energy Threshold = %4.1f +- %4.1f GeV",
    114             GetThreshold(), GetThresholdErr());
     117    char text[256];
    115118
    116     const Float_t min = hLogEner->GetMinimum();
    117     const Float_t max = hLogEner->GetMaximum();
     119    const Float_t min = fHist->GetMinimum();
     120    const Float_t max = fHist->GetMaximum();
    118121    const Float_t sum = min+max;
    119122
    120     TCanvas *c=new TCanvas("Energy Distribution","Energy distribution for triggered events");
     123    TCanvas *c=new TCanvas(fHist->GetName(), fHist->GetTitle());
    121124
    122     hLogEner->Draw(option);
     125    fHist->Draw(option);
     126
     127    sprintf(text, "Energy Threshold = %4.1f +- %4.1f GeV",
     128            fThreshold, fThresholdErr);
    123129
    124130    TPaveLabel* label = new TPaveLabel(2.2, 0.75*sum, 4.4, 0.90*sum, text);
    125131    label->SetFillColor(10);
    126132    label->SetTextSize(0.3);
     133    label->SetBit(kCanDelete);
    127134    label->Draw();
    128135
     
    137144void MHMcEnergy::SetNumBins(Int_t nbins)
    138145{
    139     hLogEner->SetBins(nbins, 0.5, 4.5);
     146    fHist->SetBins(nbins, 0.5, 4.5);
    140147}
    141148// --------------------------------------------------------------------------
     
    145152void MHMcEnergy::Print(Option_t*)
    146153{
    147     cout << "Threshold: " << GetThreshold() << " +- " << GetThresholdErr() << endl;
     154    cout << "Threshold: " << fThreshold << " +- " << fThresholdErr << endl;
    148155}
    149156
     
    152159//  Return the threshold
    153160//
    154 Float_t MHMcEnergy::GetThreshold() const
     161Float_t MHMcEnergy::CalcThreshold(TF1 *gauss)
    155162{
    156     const Float_t p1 = fLogEner->GetParameter(1);
     163    const Float_t p1 = gauss->GetParameter(1);
    157164
    158165    return pow(10, p1);
     
    163170// Return the error of the threshold.
    164171//
    165 Float_t MHMcEnergy::GetThresholdErr() const
     172Float_t MHMcEnergy::CalcThresholdErr(TF1 *gauss)
    166173{
    167174    const Float_t lg10  = log(10);
    168     const Float_t p1    = fLogEner->GetParameter(1);
    169     const Float_t p1err = fLogEner->GetParError(1);
     175    const Float_t p1    = gauss->GetParameter(1);
     176    const Float_t p1err = gauss->GetParError(1);
    170177
    171178    // The error has into accuont the error in the fit
     
    177184// Return the peak of the fitted gaussan function.
    178185//
    179 Float_t MHMcEnergy::GetGaussPeak() const
     186Float_t MHMcEnergy::CalcGaussPeak(TF1 *gauss)
    180187{
    181     return fLogEner->GetParameter(1);
     188    return gauss->GetParameter(1);
    182189}
    183190
     
    186193// Return the sigma of the fitted gaussan function.
    187194//
    188 Float_t MHMcEnergy::GetGaussSigma() const
     195Float_t MHMcEnergy::CalcGaussSigma(TF1 *gauss)
    189196{
    190     return fLogEner->GetParameter(2);
     197    return gauss->GetParameter(2);
    191198}
    192199
  • trunk/MagicSoft/Mars/mhist/MHMcEnergy.h

    r863 r867  
    1616private:
    1717
    18     TH1F *hLogEner;  // histogram with the logarith of the energy
    19     TF1  *fLogEner;  // gausian function to fit the histogram
     18    TH1F *fHist;  // histogram with the logarith of the energy
     19
     20    Float_t fThreshold;
     21    Float_t fThresholdErr;
     22    Float_t fGaussPeak;
     23    Float_t fGaussSigma;
     24
     25    Float_t CalcThreshold(TF1 *gauss);
     26    Float_t CalcThresholdErr(TF1 *gauss);
     27
     28    Float_t CalcGaussPeak(TF1 *gauss);
     29    Float_t CalcGaussSigma(TF1 *gauss);
    2030
    2131public:
     
    2434    ~MHMcEnergy();
    2535
    26     Float_t GetThreshold() const;
    27     Float_t GetThresholdErr() const;
     36    Float_t GetThreshold() const { return fThreshold; }
     37    Float_t GetThresholdErr() const { return fThresholdErr; }
    2838
    29     Float_t GetGaussPeak() const;
    30     Float_t GetGaussSigma() const;
     39    Float_t GetGaussPeak() const { return fGaussPeak; }
     40    Float_t GetGaussSigma() const { return fGaussSigma; };
    3141
    3242    void Fill(Float_t log10E, Float_t w);
Note: See TracChangeset for help on using the changeset viewer.