Changeset 1463 for trunk/MagicSoft


Ignore:
Timestamp:
07/31/02 18:03:51 (22 years ago)
Author:
tbretz
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/Changelog

    r1461 r1463  
    3333   * manalysis/MImgCleanStd.cc:
    3434     - changed ispixused array size from max to max+1
     35
     36   * macros/MagicHillas.C:
     37     - use the default binning of the histograms
     38
     39   * mhist/MH.[h,cc]:
     40     - changed argument of SetBinning from TArrayD* to TArrayD&
     41     - added ScaleArray
     42     - added ScaleAxis
     43     - proved that ScaleAxis is really working
     44     - Added ApplyBinning
     45
     46   * mhist/MHHillas.[h,cc], mhist/MHHillasSrc.[h,cc]:
     47     - corrected the default binning
     48     - take use of MH::ApplyBinning
     49     - don't stop execution if no binning was found (take default)
     50     - made sure, that rescaling of the axis is working properly
    3551
    3652
  • trunk/MagicSoft/Mars/macros/MagicHillas.C

    r1443 r1463  
    1616!
    1717!
    18 !   Author(s): Thomas Bretz  12/2000 (tbretz@uni-sw.gwdg.de)
     18!   Author(s): Thomas Bretz et al,  12/2000 <mailto:tbretz@astro.uni-wuerzburg.de>
    1919!
    20 !   Copyright: MAGIC Software Development, 2000-2001
     20!   Copyright: MAGIC Software Development, 2000-2002
    2121!
    2222!
     
    2424
    2525
    26 void MagicHillas(const char *filename="~/data/gamma*.root")
     26void MagicHillas(const char *filename="~/data/Gamma*.root")
    2727{
    2828    //
    2929    // This is a demonstration program which calculates the Hillas
    30     // parameter out of a Magic root file.
     30    // parameter out of a Magic root file (raw data file).
     31    //
    3132
    3233    //
     
    4344    // of MHillas
    4445    //
    45     //MHillasExt hext;
    46     //plist.AddToList(&hext);
     46    /*
     47     MHillasExt hext;
     48     plist.AddToList(&hext);
     49     */
    4750
    4851    //
     
    5457
    5558    //
    56     // Setup binning for your histograms.
     59    // Use this if you want to change the binning of one of
     60    // the histograms
    5761    //
    58     MBinning binswidth("BinningWidth");
    59     binswidth.SetEdges(100, 0, 1);   // 100 bins from 0 to 1 deg
     62    /*
     63     MBinning binswidth("BinningWidth");
     64     binswidth.SetEdges(100, 0, 0.1);     // 100 bins from 0 to 1 deg
     65     plist.AddToList(&binswidth);
    6066
    61     MBinning binslength("BinningLength");
    62     binslength.SetEdges(100, 0, 1);  // 100 bins from 0 to 1 deg
     67     MBinning binslength("BinningLength");
     68     binslength.SetEdges(100, 0, 1);      // 100 bins from 0 to 1 deg
     69     plist.AddToList(&binslength);
    6370
    64     MBinning binsalpha("BinningAlpha");
    65     binsalpha.SetEdges(90, 0, 90);   // 90 bins from 0 to 90 deg
     71     MBinning binsdist("BinningDist");
     72     binsdist.SetEdges(100, 0, 1.5);      // 100 bins from 0 to 1 deg
     73     plist.AddToList(&binsdist);
    6674
    67     MBinning binsdist("BinningDist");
    68     binsdist.SetEdges(100, 0, 2);    // 100 bins from 0 to 2 deg
     75     MBinning binsht("BinningHeadTail");
     76     binsht.SetEdges(100, -1.5, 1.5);     // 100 bins from 0 to 1 deg
     77     plist.AddToList(&binsht);
    6978
    70     plist.AddToList(&binswidth);
    71     plist.AddToList(&binslength);
    72     plist.AddToList(&binsalpha);
    73     plist.AddToList(&binsdist);
     79     MBinning binsalpha("BinningAlpha");
     80     binsalpha.SetEdges(90, 0, 90);       // 90 bins from 0 to 90 deg
     81     plist.AddToList(&binsalpha);
     82
     83     MBinning binscam("BinningCamera");
     84     binscam.SetEdges(50, -1.5, 1.5);     //  20 bins from -2 to 2 deg
     85     plist.AddToList(&binscam);
     86    */
    7487
    7588    //
     
    101114    MMcPedestalCopy   pcopy;
    102115    MMcPedestalNSBAdd pnsb;
     116
    103117    MCerPhotCalc      ncalc;
    104 
    105 //  Alternative photon calculation:
    106 //    MCerPhotCalc2     ncalc;
    107 //  Example: use only 2nd to 6th FADC slices for photon calculation:
    108 //    const Float_t x[15]={0., 1., 1., 1., 1., 1., 0.,0.,0.,0.,0.,0.,0.,0.,0.};
    109 //    TArrayF w(15,x);
    110 //    ncalc.SetWeights(w);
     118    //
     119    //  Alternative photon calculation:
     120    //  Example: use only 2nd to 6th FADC slices for photon calculation:
     121    //
     122    //    MCerPhotCalc2 ncalc;
     123    //    const Float_t x[15]={0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0};
     124    //    TArrayF w(15,x);
     125    //    ncalc.SetWeights(w);
     126    //
    111127
    112128    MImgCleanStd      clean;
     
    121137    MFillH hfill2a("HistAntiSrc [MHHillasSrc]", "HillasAntiSrc");
    122138
     139    MWriteRootFile write("hillas.root");
     140    write.AddContainer("MHillas",       "Hillas");
     141    write.AddContainer("HillasSource",  "Hillas");
     142    write.AddContainer("HillasAntiSrc", "Hillas");
     143    write.AddContainer("MHStarMap");
     144    write.AddContainer("MMcEvt","Hillas");
     145
    123146    /*
    124      MWriteRootFile write("hillas.root");
    125      write.AddContainer("MHillas",       "Hillas");
    126      write.AddContainer("HillasSource",  "Hillas");
    127      write.AddContainer("HillasAntiSrc", "Hillas");
    128      write.AddContainer("MMcEvt",        "Hillas");
    129      write.AddContainer("MHStarMap");
    130 
    131147     MWriteAsciiFile write("hillas.txt");
    132148     write.AddColumn("MHillas.fLength*MGeomCam.fConvMm2Deg");
     
    143159    tlist.AddToList(&hcalc);
    144160    tlist.AddToList(&csrc1);
     161
    145162    tlist.AddToList(&csrc2);
    146163    tlist.AddToList(&hfill);
     
    148165    tlist.AddToList(&hfill2s);
    149166    tlist.AddToList(&hfill2a);
     167    tlist.AddToList(&write);
    150168
    151169    //
     
    165183    //
    166184    // After the analysis is finished we can display the histograms
    167 
     185    //
     186    plist.FindObject("HistSource")->DrawClone();
    168187    plist.FindObject("MHHillas")->DrawClone();
    169     plist.FindObject("HistSource")->DrawClone();
    170188    plist.FindObject("HistAntiSrc")->DrawClone();
    171189    plist.FindObject("MHStarMap")->DrawClone();
    172190}
     191
  • trunk/MagicSoft/Mars/mhist/MH.cc

    r1449 r1463  
    5656
    5757#include "MLog.h"
     58#include "MLogManip.h"
     59
     60#include "MParList.h"
     61#include "MParContainer.h"
    5862
    5963#include "MBinning.h"
     
    228232}
    229233
    230 void MH::SetBinning(TH1 *h, const TArrayD *binsx)
     234void MH::SetBinning(TH1 *h, const TArrayD &binsx)
    231235{
    232236    MBinning bx;
    233     bx.SetEdges(*binsx);
     237    bx.SetEdges(binsx);
    234238    SetBinning(h, &bx);
    235239}
    236240
    237 void MH::SetBinning(TH2 *h, const TArrayD *binsx, const TArrayD *binsy)
     241void MH::SetBinning(TH2 *h, const TArrayD &binsx, const TArrayD &binsy)
    238242{
    239243    MBinning bx;
    240244    MBinning by;
    241     bx.SetEdges(*binsx);
    242     by.SetEdges(*binsy);
     245    bx.SetEdges(binsx);
     246    by.SetEdges(binsy);
    243247    SetBinning(h, &bx, &by);
    244248}
    245249
    246 void MH::SetBinning(TH3 *h, const TArrayD *binsx, const TArrayD *binsy, const TArrayD *binsz)
     250void MH::SetBinning(TH3 *h, const TArrayD &binsx, const TArrayD &binsy, const TArrayD &binsz)
    247251{
    248252    MBinning bx;
    249253    MBinning by;
    250254    MBinning bz;
    251     bx.SetEdges(*binsx);
    252     by.SetEdges(*binsy);
    253     bz.SetEdges(*binsz);
     255    bx.SetEdges(binsx);
     256    by.SetEdges(binsy);
     257    bz.SetEdges(binsz);
    254258    SetBinning(h, &bx, &by, &bz);
    255259}
     
    263267    bx[nx] = binsx->GetXmax();
    264268
    265     SetBinning(h, &bx);
     269    SetBinning(h, bx);
    266270}
    267271
     
    278282    by[ny] = binsy->GetXmax();
    279283
    280     SetBinning(h, &bx, &by);
     284    SetBinning(h, bx, by);
    281285}
    282286
     
    297301    bz[nz] = binsz->GetXmax();
    298302
    299     SetBinning(h, &bx, &by, &bz);
     303    SetBinning(h, bx, by, bz);
    300304}
    301305
     
    319323}
    320324
    321 void MH::ScaleAxis(TArrayD &bins, Double_t f)
     325void MH::ScaleArray(TArrayD &bins, Double_t f)
    322326{
    323327    for (int i=0; i<bins.GetSize(); i++)
     
    325329}
    326330
     331TArrayD MH::ScaleAxis(TAxis &axe, Double_t f)
     332{
     333    TArrayD arr(axe.GetNbins()+1);
     334
     335    for (int i=1; i<=axe.GetNbins()+1; i++)
     336        arr[i-1] = axe.GetBinLowEdge(i);
     337
     338    ScaleArray(arr, f);
     339
     340    return arr;
     341}
     342
    327343void MH::ScaleAxis(TH1 *h, Double_t fx, Double_t fy, Double_t fz)
    328344{
    329345    if (h->InheritsFrom(TH3::Class()))
    330         ScaleAxis(*((TH3*)h)->GetZaxis()->GetXbins(), fz);
     346    {
     347        SetBinning((TH3*)h,
     348                   ScaleAxis(*h->GetXaxis(), fx),
     349                   ScaleAxis(*h->GetYaxis(), fy),
     350                   ScaleAxis(*h->GetZaxis(), fz));
     351        return;
     352    }
    331353
    332354    if (h->InheritsFrom(TH2::Class()))
    333         ScaleAxis(*((TH2*)h)->GetYaxis()->GetXbins(), fy);
     355    {
     356        SetBinning((TH2*)h,
     357                   ScaleAxis(*h->GetXaxis(), fx),
     358                   ScaleAxis(*h->GetYaxis(), fy));
     359        return;
     360    }
    334361
    335362    if (h->InheritsFrom(TH1::Class()))
    336         ScaleAxis(*h->GetXaxis()->GetXbins(), fx);
     363        SetBinning(h, ScaleAxis(*h->GetXaxis(), fx));
     364}
     365
     366Bool_t MH::ApplyBinning(const MParList &plist, TString name, TH1 *h)
     367{
     368    const MBinning *bins = (MBinning*)plist.FindObject("Binning"+name);
     369    if (!bins)
     370    {
     371        gLog << warn << "Object 'Binning" << name << "' [MBinning] not found... no binning applied." << endl;
     372        return kFALSE;
     373    }
     374
     375    SetBinning(h, bins);
     376    return kTRUE;
    337377}
    338378
  • trunk/MagicSoft/Mars/mhist/MH.h

    r1449 r1463  
    3434    static void SetBinning(TH3 *h, const MBinning *binsx, const MBinning *binsy, const MBinning *binsz);
    3535
    36     static void SetBinning(TH1 *h, const TArrayD *binsx);
    37     static void SetBinning(TH2 *h, const TArrayD *binsx, const TArrayD *binsy);
    38     static void SetBinning(TH3 *h, const TArrayD *binsx, const TArrayD *binsy, const TArrayD *binsz);
     36    static void SetBinning(TH1 *h, const TArrayD &binsx);
     37    static void SetBinning(TH2 *h, const TArrayD &binsx, const TArrayD &binsy);
     38    static void SetBinning(TH3 *h, const TArrayD &binsx, const TArrayD &binsy, const TArrayD &binsz);
    3939
    4040    static void SetBinning(TH1 *h, const TAxis *binsx);
     
    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);
     46    static Bool_t ApplyBinning(const MParList &plist, TString name, TH1 *h);
     47
     48    static void    ScaleArray(TArrayD &bins, Double_t f);
     49    static TArrayD ScaleAxis(TAxis &axe, Double_t f);
     50    static void    ScaleAxis(TH1 *bins, Double_t fx=1, Double_t fy=1, Double_t fz=1);
    4851
    4952    static void FindGoodLimits(Int_t nbins, Int_t &newbins, Double_t &xmin, Double_t &xmax, Bool_t isInteger);
  • trunk/MagicSoft/Mars/mhist/MHHillas.cc

    r1441 r1463  
    5959//
    6060MHHillas::MHHillas(const char *name, const char *title)
    61     : fMm2Deg(1), fUseMmScale(kFALSE)
     61    : fMm2Deg(1), fUseMmScale(kTRUE)
    6262{
    6363    //
     
    6767    fTitle = title ? title : "Source independent image parameters";
    6868
    69     fLength = new TH1F("Length", "Length of Ellipse", 100, 0, 300);
     69    fLength = new TH1F("Length", "Length of Ellipse",               100,   0, 296.7);
     70    fWidth  = new TH1F("Width",  "Width of Ellipse",                100,   0, 296.7);
     71    fDistC  = new TH1F("DistC",  "Distance from center of camera",  100,   0, 445);
     72    fDelta  = new TH1F("Delta",  "Angle (Main axis - x-axis)",      101, -90,  90);
     73
    7074    fLength->SetDirectory(NULL);
     75    fWidth->SetDirectory(NULL);
     76    fDistC->SetDirectory(NULL);
     77    fDelta->SetDirectory(NULL);
     78
    7179    fLength->SetXTitle("Length [mm]");
     80    fWidth->SetXTitle("Width [mm]");
     81    fDistC->SetXTitle("Distance [mm]");
     82    fDelta->SetXTitle("Delta [\\circ]");
     83
    7284    fLength->SetYTitle("Counts");
    73 
    74     fWidth  = new TH1F("Width",  "Width of Ellipse",  100, 0, 300);
    75     fWidth->SetDirectory(NULL);
    76     fWidth->SetXTitle("Width [mm]");
    7785    fWidth->SetYTitle("Counts");
    78 
    79     fDistC  = new TH1F("DistC",  "Distance from center of camera",  100, 0, 600);
    80     fDistC->SetDirectory(NULL);
    81     fDistC->SetXTitle("Distance [mm]");
    8286    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]");
    8787    fDelta->SetYTitle("Counts");
    8888
     
    101101    MH::SetBinning(fSize, &bins);
    102102
    103     fCenter = new TH2F("Center", "Center of Ellipse", 60, -600, 600, 60, -600, 600);
     103    fCenter = new TH2F("Center", "Center of Ellipse", 51, -445, 445, 51, -445, 445);
    104104    fCenter->SetDirectory(NULL);
    105105    fCenter->SetXTitle("x [mm]");
     
    136136Bool_t MHHillas::SetupFill(const MParList *plist)
    137137{
    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)
    144     {
    145         *fLog << err << dbginf << "At least one MBinning not found... aborting." << endl;
    146         return kFALSE;
    147     }
    148 
    149     SetBinning(fWidth,  binsw);
    150     SetBinning(fLength, binsl);
    151     SetBinning(fDistC,  binsd);
    152     SetBinning(fCenter, binsc, binsc);
    153 
    154138    const MGeomCam *geom = (MGeomCam*)plist->FindObject("MGeomCam");
    155139    if (!geom)
    156     {
    157140        *fLog << warn << dbginf << "No Camera Geometry available. Using mm-scale for histograms." << endl;
    158         return kTRUE;
    159     }
    160 
    161     fMm2Deg     = geom->GetConvMm2Deg();
    162     fUseMmScale = kFALSE;
    163 
    164     fLength->SetXTitle("Length [\\circ]");
    165     fWidth->SetXTitle("Width [\\circ]");
    166     fDistC->SetXTitle("Distance [\\circ]");
    167     fCenter->SetXTitle("x [\\circ]");
    168     fCenter->SetYTitle("y [\\circ]");
     141    else
     142    {
     143        fMm2Deg = geom->GetConvMm2Deg();
     144        SetMmScale(kFALSE);
     145    }
     146
     147    ApplyBinning(*plist, "Width",  fWidth);
     148    ApplyBinning(*plist, "Length", fLength);
     149    ApplyBinning(*plist, "Dist",   fDistC);
     150    ApplyBinning(*plist, "Camera", fCenter);
     151    ApplyBinning(*plist, "Delta",  fDelta);
     152    ApplyBinning(*plist, "Size",   fSize);
    169153
    170154    return kTRUE;
     
    208192    }
    209193
    210     if (fUseMmScale)
    211     {
    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 
     194    const Double_t scale = mmscale ? 1./fMm2Deg : fMm2Deg;
     195    MH::ScaleAxis(fLength, scale);
     196    MH::ScaleAxis(fWidth,  scale);
     197    MH::ScaleAxis(fDistC,  scale);
     198    MH::ScaleAxis(fCenter, scale, scale);
     199
     200    if (mmscale)
     201    {
    217202        fLength->SetXTitle("Length [mm]");
    218203        fWidth->SetXTitle("Width [mm]");
     204        fDistC->SetXTitle("Distance [mm]");
    219205        fCenter->SetXTitle("x [mm]");
    220206        fCenter->SetYTitle("y [mm]");
     
    222208    else
    223209    {
    224         MH::ScaleAxis(fLength, fMm2Deg);
    225         MH::ScaleAxis(fWidth,  fMm2Deg);
    226         MH::ScaleAxis(fDistC,  fMm2Deg);
    227         MH::ScaleAxis(fCenter, fMm2Deg, fMm2Deg);
    228 
    229210        fLength->SetXTitle("Length [\\circ]");
    230211        fWidth->SetXTitle("Width [\\circ]");
     
    247228
    248229    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());
     230    const Double_t scale = fUseMmScale ? 1 : fMm2Deg;
     231
     232    fLength->Fill(scale*h.GetLength());
     233    fWidth ->Fill(scale*h.GetWidth());
     234    fDistC ->Fill(scale*d);
     235    fCenter->Fill(scale*h.GetMeanX(), scale*h.GetMeanY());
     236    fDelta ->Fill(kRad2Deg*h.GetDelta());
     237    fSize  ->Fill(h.GetSize());
    267238
    268239    return kTRUE;
     
    275246void MHHillas::SetColors() const
    276247{
     248    // FIXME: This must be redone each time the canvas is repainted....
    277249    gStyle->SetPalette(51, NULL);
    278250    Int_t c[50];
     
    292264TObject *MHHillas::DrawClone(Option_t *opt) const
    293265{
    294     TCanvas *c = MakeDefCanvas("Hillas", fTitle, 700, 750);
     266    TCanvas *c = MakeDefCanvas("Hillas", fTitle, 720, 810);
    295267    c->Divide(2,3);
    296268
     
    332304{
    333305    if (!gPad)
    334         MakeDefCanvas("Hillas", fTitle, 700, 750);
     306        MakeDefCanvas("Hillas", fTitle, 720, 810);
    335307
    336308    gPad->Divide(2,3);
  • trunk/MagicSoft/Mars/mhist/MHHillas.h

    r1441 r1463  
    1414private:
    1515
    16     TH1F *fLength;
    17     TH1F *fWidth;
     16    TH1F *fLength; //->
     17    TH1F *fWidth;  //->
    1818
    19     TH1F *fDistC;
    20     TH1F *fDelta;
     19    TH1F *fDistC;  //->
     20    TH1F *fDelta;  //->
    2121
    22     TH1F *fSize;
    23     TH2F *fCenter;
     22    TH1F *fSize;   //->
     23    TH2F *fCenter; //->
    2424
    2525    void SetColors() const;
  • trunk/MagicSoft/Mars/mhist/MHHillasSrc.cc

    r1442 r1463  
    6868    // connect all the histogram with the container fHist
    6969    //
    70     fAlpha    = new TH1F("Alpha",    "Alpha of Ellipse",             90,  0,  90);
    71     fDist     = new TH1F("Dist",     "Dist of Ellipse",             100,  0, 600);
    72     fHeadTail = new TH1F("HeadTail", "HeadTail of Ellipse",          45,  0,  90);
    73     fCosDA    = new TH1F("CosDA",    "cos(Delta,Alpha) of Ellipse", 100, -1,   1);
     70    fAlpha    = new TH1F("Alpha",    "Alpha of Ellipse",             90,    0,  90);
     71    fDist     = new TH1F("Dist",     "Dist of Ellipse",             100,    0, 445);
     72    fHeadTail = new TH1F("HeadTail", "HeadTail of Ellipse",         101, -445, 445);
     73    fCosDA    = new TH1F("CosDA",    "cos(Delta,Alpha) of Ellipse", 101,  -1,   1);
    7474
    7575    fAlpha->SetDirectory(NULL);
     
    8080    fAlpha->SetXTitle("\\alpha [\\circ]");
    8181    fDist->SetXTitle("Dist [mm]");
    82     fHeadTail->SetXTitle("Head-Tail [\\circ]");
     82    fHeadTail->SetXTitle("Head-Tail [mm]");
    8383    fCosDA->SetXTitle("cos(\\delta,\\alpha) [mm]");
    8484
     
    113113Bool_t MHHillasSrc::SetupFill(const MParList *plist)
    114114{
    115     const MBinning* binsa = (MBinning*)plist->FindObject("BinningAlpha");
    116     const MBinning* binsd = (MBinning*)plist->FindObject("BinningDist");
    117     if (!binsa || !binsd)
    118     {
    119         *fLog << err << dbginf << "At least one MBinning not found... aborting." << endl;
    120         return kFALSE;
    121     }
    122 
    123     SetBinning(fAlpha, binsa);
    124     SetBinning(fDist,  binsd);
    125 
    126115    const MGeomCam *geom = (MGeomCam*)plist->FindObject("MGeomCam");
    127116    if (!geom)
    128     {
    129117        *fLog << warn << dbginf << "No Camera Geometry available. Using mm-scale for histograms." << endl;
    130         return kTRUE;
    131     }
    132 
    133     fDist->SetXTitle("Dist [\\circ]");
    134 
    135     fMm2Deg = geom->GetConvMm2Deg();
    136     fUseMmScale = kFALSE;
     118    else
     119    {
     120        fMm2Deg = geom->GetConvMm2Deg();
     121        SetMmScale(kFALSE);
     122    }
     123
     124    ApplyBinning(*plist, "Alpha",    fAlpha);
     125    ApplyBinning(*plist, "Dist",     fDist);
     126    ApplyBinning(*plist, "HeadTail", fHeadTail);
    137127
    138128    return kTRUE;
     
    150140    fAlpha   ->Fill(fabs(h.GetAlpha()));
    151141    fDist    ->Fill(fUseMmScale ? h.GetDist() : fMm2Deg*h.GetDist());
    152     fHeadTail->Fill(h.GetHeadTail());
     142    fHeadTail->Fill(fUseMmScale ? h.GetHeadTail() : fMm2Deg*h.GetHeadTail());
    153143    fCosDA   ->Fill(h.GetCosDeltaAlpha());
    154144
    155145    return kTRUE;
     146}
     147
     148// --------------------------------------------------------------------------
     149//
     150// Use this function to setup your own conversion factor between degrees
     151// and millimeters. The conversion factor should be the one calculated in
     152// MGeomCam. Use this function with Caution: You could create wrong values
     153// by setting up your own scale factor.
     154//
     155void MHHillasSrc::SetMm2Deg(Float_t mmdeg)
     156{
     157    if (mmdeg<0)
     158    {
     159        *fLog << warn << dbginf << "Warning - Conversion factor < 0 - nonsense. Ignored." << endl;
     160        return;
     161    }
     162
     163    if (fMm2Deg>=0)
     164        *fLog << warn << dbginf << "Warning - Conversion factor already set. Overwriting" << endl;
     165
     166    fMm2Deg = mmdeg;
     167}
     168
     169// --------------------------------------------------------------------------
     170//
     171// With this function you can convert the histogram ('on the fly') between
     172// degrees and millimeters.
     173//
     174void MHHillasSrc::SetMmScale(Bool_t mmscale)
     175{
     176    if (fUseMmScale == mmscale)
     177        return;
     178
     179    if (fMm2Deg<0)
     180    {
     181        *fLog << warn << dbginf << "Warning - Sorry, no conversion factor for conversion available." << endl;
     182        return;
     183    }
     184
     185    const Double_t scale = mmscale ? 1./fMm2Deg : fMm2Deg;
     186    MH::ScaleAxis(fDist,     scale);
     187    MH::ScaleAxis(fHeadTail, scale);
     188
     189    if (mmscale)
     190    {
     191        fDist->SetXTitle("Dist [mm]");
     192        fHeadTail->SetXTitle("Head-Tail [mm]");
     193    }
     194    else
     195    {
     196        fDist->SetXTitle("Dist [\\circ]");
     197        fHeadTail->SetXTitle("Head-Tail [\\circ]");
     198    }
     199
     200    fUseMmScale = mmscale;
    156201}
    157202
     
    187232
    188233    c->cd(4);
     234    gPad->SetLogy();
    189235    fCosDA->DrawCopy();
    190236
     
    221267
    222268    gPad->cd(2);
     269    gPad->SetLogy();
    223270    fCosDA->Draw();
    224271
  • trunk/MagicSoft/Mars/mhist/MHHillasSrc.h

    r1442 r1463  
    1212{
    1313private:
    14     TH1F *fAlpha;
    15     TH1F *fDist;
    16     TH1F *fHeadTail;     
    17     TH1F *fCosDA;
     14    TH1F *fAlpha;     //->
     15    TH1F *fDist;      //->
     16    TH1F *fHeadTail;  //->   
     17    TH1F *fCosDA;     //->
    1818
    1919    Float_t fMm2Deg;
     
    2424    ~MHHillasSrc();
    2525
    26     void SetUseMmScale(Bool_t mmscale=kTRUE) { fUseMmScale = mmscale; }
     26    void SetMmScale(Bool_t mmscale=kTRUE);
     27    void SetMm2Deg(Float_t mmdeg);
    2728
    2829    Bool_t SetupFill(const MParList *pList);
Note: See TracChangeset for help on using the changeset viewer.