Changeset 1441 for trunk/MagicSoft


Ignore:
Timestamp:
07/25/02 13:58:19 (22 years ago)
Author:
tbretz
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars/mhist
Files:
4 edited

Legend:

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

    r1389 r1441  
    317317    }
    318318}
     319
     320void MH::ScaleAxis(TArrayD &bins, Double_t f)
     321{
     322    for (int i=0; i<bins.GetSize(); i++)
     323        bins[i] *= f;
     324}
     325
     326void MH::ScaleAxis(TH1 *h, Double_t fx=1, Double_t fy=1, Double_t fz=1)
     327{
     328    if (h->InheritsFrom(TH3::Class()))
     329        ScaleAxis(*((TH3*)h)->GetZaxis()->GetXbins(), fz);
     330
     331    if (h->InheritsFrom(TH2::Class()))
     332        ScaleAxis(*((TH2*)h)->GetYaxis()->GetXbins(), fy);
     333
     334    if (h->InheritsFrom(TH1::Class()))
     335        ScaleAxis(*h->GetXaxis()->GetXbins(), fx);
     336}
  • trunk/MagicSoft/Mars/mhist/MH.h

    r1388 r1441  
    4444    static void SetBinning(TH1 *h, TH1 *x);
    4545
     46    static void ScaleAxis(TArrayD &bins, Double_t f);
     47    static void ScaleAxis(TH1 *bins, Double_t fx=1, Double_t fy=1, Double_t fz=1);
     48
    4649    ClassDef(MH, 1) //A histogram base class for Mars histograms
    4750};
  • trunk/MagicSoft/Mars/mhist/MHHillas.cc

    r1283 r1441  
    1717!
    1818!   Author(s): Thomas Bretz  2001 <mailto:tbretz@uni-sw.gwdg.de>
     19!              Wolfgang Wittek  2002 <mailto:wittek@mppmu.mpg.de>
    1920!
    2021!   Copyright: MAGIC Software Development, 2000-2002
     
    2728// MHHillas
    2829//
    29 // This class contains histograms for every Hillas parameter
     30// This class contains histograms for the source independent image parameters
    3031//
    3132/////////////////////////////////////////////////////////////////////////////
     
    3637
    3738#include <TH1.h>
     39#include <TH2.h>
    3840#include <TPad.h>
     41#include <TStyle.h>
    3942#include <TCanvas.h>
    4043
     
    4245#include "MLogManip.h"
    4346
     47#include "MParList.h"
     48
     49#include "MHillas.h"
    4450#include "MGeomCam.h"
    45 #include "MHillas.h"
    46 #include "MParList.h"
     51#include "MBinning.h"
     52
    4753
    4854ClassImp(MHHillas);
     
    5359//
    5460MHHillas::MHHillas(const char *name, const char *title)
    55     : fMm2Deg(-1), fUseMmScale(kTRUE)
     61    : fMm2Deg(1), fUseMmScale(kFALSE)
    5662{
    5763    //
     
    5965    //
    6066    fName  = name  ? name  : "MHHillas";
    61     fTitle = title ? title : "Container for Hillas histograms";
    62 
    63     //
    64     // loop over all Pixels and create two histograms
    65     // one for the Low and one for the High gain
    66     // connect all the histogram with the container fHist
    67     //
     67    fTitle = title ? title : "Source independent image parameters";
     68
     69    fLength = new TH1F("Length", "Length of Ellipse", 100, 0, 300);
     70    fLength->SetDirectory(NULL);
     71    fLength->SetXTitle("Length [mm]");
     72    fLength->SetYTitle("Counts");
     73
    6874    fWidth  = new TH1F("Width",  "Width of Ellipse",  100, 0, 300);
    69     fLength = new TH1F("Length", "Length of Ellipse", 100, 0, 300);
    70 
    71     fLength->SetDirectory(NULL);
    7275    fWidth->SetDirectory(NULL);
    73 
    74     fLength->SetXTitle("Length [mm]");
    7576    fWidth->SetXTitle("Width [mm]");
    76 
    77     fLength->SetYTitle("Counts");
    7877    fWidth->SetYTitle("Counts");
    79 }
    80 
    81 // --------------------------------------------------------------------------
    82 //
    83 // Delete the four histograms
     78
     79    fDistC  = new TH1F("DistC",  "Distance from center of camera",  100, 0, 600);
     80    fDistC->SetDirectory(NULL);
     81    fDistC->SetXTitle("Distance [mm]");
     82    fDistC->SetYTitle("Counts");
     83
     84    fDelta  = new TH1F("Delta",  "Angle (Main axis - x-axis)", 100, -90, 90);
     85    fDelta->SetDirectory(NULL);
     86    fDelta->SetXTitle("Delta [\\circ]");
     87    fDelta->SetYTitle("Counts");
     88
     89    MBinning bins;
     90    bins.SetEdgesLog(50, 1, 1e7);
     91
     92    fSize  = new TH1F;
     93    fSize->SetName("Size");
     94    fSize->SetTitle("Number of Photons");
     95    fSize->SetDirectory(NULL);
     96    fSize->SetXTitle("Size");
     97    fSize->SetYTitle("Counts");
     98    fSize->GetXaxis()->SetTitleOffset(1.2);
     99    fSize->GetXaxis()->SetLabelOffset(-0.015);
     100
     101    MH::SetBinning(fSize, &bins);
     102
     103    fCenter = new TH2F("Center", "Center of Ellipse", 60, -600, 600, 60, -600, 600);
     104    fCenter->SetDirectory(NULL);
     105    fCenter->SetXTitle("x [mm]");
     106    fCenter->SetYTitle("y [mm]");
     107    fCenter->SetZTitle("Counts");
     108}
     109
     110// --------------------------------------------------------------------------
     111//
     112// Delete the histograms
    84113//
    85114MHHillas::~MHHillas()
    86115{
     116    delete fLength;
    87117    delete fWidth;
    88     delete fLength;
     118
     119    delete fDistC;
     120    delete fDelta;
     121
     122    delete fSize;
     123    delete fCenter;
    89124}
    90125
     
    101136Bool_t MHHillas::SetupFill(const MParList *plist)
    102137{
    103     const MBinning* binsw = (MBinning*)plist->FindObject("BinningWidth");
    104     const MBinning* binsl = (MBinning*)plist->FindObject("BinningLength");
    105     if (!binsw || !binsl)
     138    const MBinning *binsw = (MBinning*)plist->FindObject("BinningWidth");
     139    const MBinning *binsl = (MBinning*)plist->FindObject("BinningLength");
     140    const MBinning *binsd = (MBinning*)plist->FindObject("BinningDist");
     141    const MBinning *binsc = (MBinning*)plist->FindObject("BinningCamera");
     142
     143    if (!binsw || !binsl || !binsd || !binsc)
    106144    {
    107145        *fLog << err << dbginf << "At least one MBinning not found... aborting." << endl;
     
    111149    SetBinning(fWidth,  binsw);
    112150    SetBinning(fLength, binsl);
     151    SetBinning(fDistC,  binsd);
     152    SetBinning(fCenter, binsc, binsc);
    113153
    114154    const MGeomCam *geom = (MGeomCam*)plist->FindObject("MGeomCam");
     
    119159    }
    120160
     161    fMm2Deg     = geom->GetConvMm2Deg();
     162    fUseMmScale = kFALSE;
     163
    121164    fLength->SetXTitle("Length [\\circ]");
    122165    fWidth->SetXTitle("Width [\\circ]");
    123 
    124     fMm2Deg     = geom->GetConvMm2Deg();
    125     fUseMmScale = kFALSE;
    126 
    127     return kTRUE;
    128 }
    129 
    130 // --------------------------------------------------------------------------
    131 //
    132 // Fill the four histograms with data from a MHillas-Container.
    133 // Be careful: Only call this with an object of type MHillas
    134 //
    135 Bool_t MHHillas::Fill(const MParContainer *par)
    136 {
    137     const MHillas &h = *(MHillas*)par;
    138 
    139     if (fUseMmScale)
    140     {
    141         fWidth ->Fill(h.GetWidth());
    142         fLength->Fill(h.GetLength());
    143     }
    144     else
    145     {
    146         fWidth ->Fill(fMm2Deg*h.GetWidth());
    147         fLength->Fill(fMm2Deg*h.GetLength());
    148     }
     166    fDistC->SetXTitle("Distance [\\circ]");
     167    fCenter->SetXTitle("x [\\circ]");
     168    fCenter->SetYTitle("y [\\circ]");
    149169
    150170    return kTRUE;
     
    190210    if (fUseMmScale)
    191211    {
     212        MH::ScaleAxis(fLength, 1./fMm2Deg);
     213        MH::ScaleAxis(fWidth,  1./fMm2Deg);
     214        MH::ScaleAxis(fDistC,  1./fMm2Deg);
     215        MH::ScaleAxis(fCenter, 1./fMm2Deg, 1./fMm2Deg);
     216
    192217        fLength->SetXTitle("Length [mm]");
    193218        fWidth->SetXTitle("Width [mm]");
    194 
    195         fLength->Scale(1./fMm2Deg);
    196         fWidth->Scale(1./fMm2Deg);
     219        fCenter->SetXTitle("x [mm]");
     220        fCenter->SetYTitle("y [mm]");
    197221    }
    198222    else
    199223    {
     224        MH::ScaleAxis(fLength, fMm2Deg);
     225        MH::ScaleAxis(fWidth,  fMm2Deg);
     226        MH::ScaleAxis(fDistC,  fMm2Deg);
     227        MH::ScaleAxis(fCenter, fMm2Deg, fMm2Deg);
     228
    200229        fLength->SetXTitle("Length [\\circ]");
    201230        fWidth->SetXTitle("Width [\\circ]");
    202 
    203         fLength->Scale(fMm2Deg);
    204         fWidth->Scale(fMm2Deg);
     231        fDistC->SetXTitle("Distance [\\circ]");
     232        fCenter->SetXTitle("x [\\circ]");
     233        fCenter->SetYTitle("y [\\circ]");
    205234    }
    206235
     
    210239// --------------------------------------------------------------------------
    211240//
    212 // Draw clones of all four histograms. So that the object can be deleted
     241// Fill the histograms with data from a MHillas-Container.
     242// Be careful: Only call this with an object of type MHillas
     243//
     244Bool_t MHHillas::Fill(const MParContainer *par)
     245{
     246    const MHillas &h = *(MHillas*)par;
     247
     248    const Double_t d = sqrt(h.GetMeanX()*h.GetMeanX() + h.GetMeanY()*h.GetMeanY());
     249
     250    if (fUseMmScale)
     251    {
     252        fLength->Fill(h.GetLength());
     253        fWidth ->Fill(h.GetWidth());
     254        fDistC ->Fill(d);
     255        fCenter->Fill(h.GetMeanX(), h.GetMeanY());
     256    }
     257    else
     258    {
     259        fLength->Fill(fMm2Deg*h.GetLength());
     260        fWidth ->Fill(fMm2Deg*h.GetWidth());
     261        fDistC ->Fill(fMm2Deg*d);
     262        fCenter->Fill(fMm2Deg*h.GetMeanX(), fMm2Deg*h.GetMeanY());
     263    }
     264
     265    fDelta->Fill(kRad2Deg*h.GetDelta());
     266    fSize->Fill(h.GetSize());
     267
     268    return kTRUE;
     269}
     270
     271// --------------------------------------------------------------------------
     272//
     273// Setup a inversed deep blue sea palette for the fCenter histogram.
     274//
     275void MHHillas::SetColors() const
     276{
     277    gStyle->SetPalette(51, NULL);
     278    Int_t c[50];
     279    for (int i=0; i<50; i++)
     280        c[49-i] = gStyle->GetColorPalette(i);
     281    gStyle->SetPalette(50, c);
     282}
     283
     284// --------------------------------------------------------------------------
     285//
     286// Draw clones of four histograms. So that the object can be deleted
    213287// and the histograms are still visible in the canvas.
    214288// The cloned object are deleted together with the canvas if the canvas is
     
    218292TObject *MHHillas::DrawClone(Option_t *opt) const
    219293{
    220     TCanvas *c = MakeDefCanvas("Hillas", "Histograms of Hillas Parameters",
    221                                350, 500);
    222     c->Divide(1, 2);
     294    TCanvas *c = MakeDefCanvas("Hillas", fTitle, 700, 750);
     295    c->Divide(2,3);
    223296
    224297    gROOT->SetSelectedPad(NULL);
    225298
    226     //
    227     // This is necessary to get the expected bahviour of DrawClone
    228     //
    229299    c->cd(1);
    230300    fLength->DrawCopy();
     
    232302    c->cd(2);
    233303    fWidth->DrawCopy();
     304
     305    c->cd(3);
     306    gPad->SetLogx();
     307    fSize->DrawCopy();
     308
     309    c->cd(4);
     310    fDelta->DrawCopy();
     311
     312    c->cd(5);
     313    fDistC->DrawCopy();
     314
     315    c->cd(6);
     316    SetColors();
     317    fCenter->DrawCopy("colz");
    234318
    235319    c->Modified();
     
    248332{
    249333    if (!gPad)
    250         MakeDefCanvas("Hillas", "Histograms of Hillas Parameters", 350, 500);
    251 
    252     gPad->Divide(1, 2);
     334        MakeDefCanvas("Hillas", fTitle, 700, 750);
     335
     336    gPad->Divide(2,3);
    253337
    254338    gPad->cd(1);
     
    258342    fWidth->Draw();
    259343
     344    gPad->cd(3);
     345    gPad->SetLogx();
     346    fSize->Draw();
     347
     348    gPad->cd(4);
     349    fDelta->Draw();
     350
     351    gPad->cd(5);
     352    fDistC->Draw();
     353
     354    gPad->cd(6);
     355    SetColors();
     356    fCenter->Draw("colz");
     357
    260358    gPad->Modified();
    261359    gPad->Update();
  • trunk/MagicSoft/Mars/mhist/MHHillas.h

    r1283 r1441  
    77
    88class TH1F;
     9class TH2F;
     10class MHillas;
    911
    1012class MHHillas : public MH
    1113{
    1214private:
     15
     16    TH1F *fLength;
    1317    TH1F *fWidth;
    14     TH1F *fLength;
     18
     19    TH1F *fDistC;
     20    TH1F *fDelta;
     21
     22    TH1F *fSize;
     23    TH2F *fCenter;
     24
     25    void SetColors() const;
    1526
    1627protected:
     
    2940    Bool_t Fill(const MParContainer *par);
    3041
     42    TH1F *GetHistLength() { return fLength; }
    3143    TH1F *GetHistWidth()  { return fWidth; }
    32     TH1F *GetHistLength() { return fLength; }
     44
     45    TH1F *GetHistDistC()  { return fDistC; }
     46    TH1F *GetHistDelta()  { return fDelta; }
     47
     48    TH1F *GetHistSize()   { return fSize; }
     49    TH2F *GetHistCenter() { return fCenter; }
    3350
    3451    void Draw(Option_t *opt=NULL);
    3552    TObject *DrawClone(Option_t *opt=NULL) const;
    3653
    37     ClassDef(MHHillas, 1) // Container which holds histograms for length and width
     54    ClassDef(MHHillas, 1) // Container which holds histograms for the source independent image parameters
    3855};
    3956
Note: See TracChangeset for help on using the changeset viewer.