Ignore:
Timestamp:
04/22/02 11:28:38 (23 years ago)
Author:
tbretz
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars/mhist
Files:
4 added
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/mhist/HistLinkDef.h

    r1228 r1283  
    88
    99#pragma link C++ class MH+;
     10#pragma link C++ class MH3+;
    1011#pragma link C++ class MHFadcCam+;
    1112#pragma link C++ class MHFadcPix+;
    1213#pragma link C++ class MHHillas+;
    1314#pragma link C++ class MHHillasSrc+;
     15#pragma link C++ class MHHillasExt+;
    1416#pragma link C++ class MHStarMap+;
    1517#pragma link C++ class MHEnergyTime+;
  • trunk/MagicSoft/Mars/mhist/MFillH.cc

    r1211 r1283  
    238238        const TString name = ExtractName(fHName);
    239239
    240         TObject *obj = pList->FindCreateObj(cls, name);
     240        TObject *obj=NULL;
     241        if (cls==name)
     242            obj = pList->FindObject(fHName);
     243
     244        if (!obj)
     245            obj = pList->FindCreateObj(cls, name);
     246
    241247        if (!obj)
    242248            return kFALSE;
     
    277283    // list. If it could not be found we cannot proceed.
    278284    //
     285    if (fParContainerName.IsNull())
     286    {
     287        fParContainer = pList;
     288        return kTRUE;
     289    }
     290
    279291    fParContainer = (MParContainer*)pList->FindObject(fParContainerName);
    280292    if (fParContainer)
    281293        return kTRUE;
    282294
    283     *fLog << err << dbginf << fParContainerName << " [MParContainer] not found... aborting." << endl;
     295    *fLog << err << dbginf << "'" << fParContainerName << "' [MParContainer] not found... aborting." << endl;
    284296    return kFALSE;
    285297}
  • trunk/MagicSoft/Mars/mhist/MH.cc

    r1276 r1283  
    6666    //   set the name and title of this object
    6767    //
    68     fName  = name  ? name  : "MH" ;
    69     fTitle = title ? title : "Base class for Mars histograms" ;
     68    fName  = name  ? name  : "MH";
     69    fTitle = title ? title : "Base class for Mars histograms";
    7070}
    7171
     
    8383// number of all existing canvases plus one)
    8484//
    85 TCanvas *MH::MakeDefCanvas(const char *name, const char *title,
     85TCanvas *MH::MakeDefCanvas(TString name, const char *title,
    8686                           const UInt_t w, const UInt_t h)
    8787{
    8888    const TList *list = (TList*)gROOT->GetListOfCanvases();
    8989
    90     const char *def = name ? name : gROOT->GetDefCanvasName();
    91 
    92     TCanvas *c;
    93     if (list->FindObject(def))
    94     {
    95         const char *n = StrDup(Form("%s <%d>", def, list->GetSize()+1));
    96         c = new TCanvas(n, title, w, h);
    97         delete [] n;
    98     }
    99     else
    100         c = new TCanvas(def, title, w, h);
    101 
    102     return c;
     90    if (name.IsNull())
     91        name = gROOT->GetDefCanvasName();
     92
     93    if (list->FindObject(name))
     94        name += Form(" <%d>", list->GetSize()+1);
     95
     96    return new TCanvas(name, title, w, h);
    10397}
    10498
  • trunk/MagicSoft/Mars/mhist/MH.h

    r1207 r1283  
    2222    virtual Bool_t Fill(const MParContainer *par) = 0;
    2323
    24     static TCanvas *MakeDefCanvas(const char *name=NULL, const char *title="",
     24    static TCanvas *MakeDefCanvas(TString name="", const char *title="",
    2525                                  const UInt_t w=700, const UInt_t h=500);
    2626    static TCanvas *MakeDefCanvas(const TObject *obj,
  • trunk/MagicSoft/Mars/mhist/MHHillas.cc

    r1277 r1283  
    5353//
    5454MHHillas::MHHillas(const char *name, const char *title)
    55     : fMm2Deg(-1), fUseMmScale(kFALSE)
     55    : fMm2Deg(-1), fUseMmScale(kTRUE)
    5656{
    5757    //
     
    7272    fWidth->SetDirectory(NULL);
    7373
    74     fLength->GetXaxis()->SetTitle("Length [mm]");
    75     fWidth->GetXaxis()->SetTitle("Width [mm]");
    76 
    77     fLength->GetYaxis()->SetTitle("Counts");
    78     fWidth->GetYaxis()->SetTitle("Counts");
     74    fLength->SetXTitle("Length [mm]");
     75    fWidth->SetXTitle("Width [mm]");
     76
     77    fLength->SetYTitle("Counts");
     78    fWidth->SetYTitle("Counts");
    7979}
    8080
     
    119119    }
    120120
    121     fLength->GetXaxis()->SetTitle("Length [\\circ]");
    122     fWidth->GetXaxis()->SetTitle("Width [\\circ]");
    123 
    124     fMm2Deg = geom->GetConvMm2Deg();
     121    fLength->SetXTitle("Length [\\circ]");
     122    fWidth->SetXTitle("Width [\\circ]");
     123
     124    fMm2Deg     = geom->GetConvMm2Deg();
     125    fUseMmScale = kFALSE;
    125126
    126127    return kTRUE;
     
    189190    if (fUseMmScale)
    190191    {
    191         fLength->GetXaxis()->SetTitle("Length [mm]");
    192         fWidth->GetXaxis()->SetTitle("Width [mm]");
     192        fLength->SetXTitle("Length [mm]");
     193        fWidth->SetXTitle("Width [mm]");
    193194
    194195        fLength->Scale(1./fMm2Deg);
     
    197198    else
    198199    {
    199         fLength->GetXaxis()->SetTitle("Length [\\circ]");
    200         fWidth->GetXaxis()->SetTitle("Width [\\circ]");
     200        fLength->SetXTitle("Length [\\circ]");
     201        fWidth->SetXTitle("Width [\\circ]");
    201202
    202203        fLength->Scale(fMm2Deg);
  • trunk/MagicSoft/Mars/mhist/MHHillas.h

    r1263 r1283  
    77
    88class TH1F;
    9 class MHillas;
    109
    1110class MHHillas : public MH
     
    1514    TH1F *fLength;
    1615
     16protected:
    1717    Float_t fMm2Deg;
    1818
     
    2424
    2525    void SetMmScale(Bool_t mmscale=kTRUE);
    26     void SetMm2Deg(Float_t mmdeg);
     26    virtual void SetMm2Deg(Float_t mmdeg);
    2727
    2828    Bool_t SetupFill(const MParList *pList);
  • trunk/MagicSoft/Mars/mhist/MHStarMap.cc

    r1263 r1283  
    3939#include <TCanvas.h>  // TCanvas
    4040
     41#include "MLog.h"
     42#include "MLogManip.h"
     43
     44#include "MParList.h"
     45
     46#include "MGeomCam.h"
    4147#include "MHillas.h"
     48#include "MBinning.h"
    4249
    4350ClassImp(MHStarMap);
     
    4855//
    4956MHStarMap::MHStarMap(const char *name, const char *title)
     57    : fMm2Deg(-1), fUseMmScale(kTRUE)
    5058{
    5159    //
     
    5765    //   set the name and title of this object
    5866    //
    59    
    6067    fName  = name  ? name  : "MHStarMap" ;
    6168    fTitle = title ? title : "Container for a Star Map" ;
     
    8895// --------------------------------------------------------------------------
    8996//
     97// Setup the Binning for the histograms automatically if the correct
     98// instances of MBinning (with the names 'BinningWidth' and 'BinningLength')
     99// are found in the parameter list
     100// Use this function if you want to set the conversion factor which
     101// is used to convert the mm-scale in the camera plain into the deg-scale
     102// used for histogram presentations. The conversion factor is part of
     103// the camera geometry. Please create a corresponding MGeomCam container.
     104//
     105Bool_t MHStarMap::SetupFill(const MParList *plist)
     106{
     107    const MGeomCam *geom = (MGeomCam*)plist->FindObject("MGeomCam");
     108    if (geom)
     109    {
     110        fMm2Deg = geom->GetConvMm2Deg();
     111        fUseMmScale = kFALSE;
     112
     113        fStarMap->SetXTitle("x [\\circ]");
     114        fStarMap->SetYTitle("y [\\circ]");
     115    }
     116
     117    const MBinning *bins = (MBinning*)plist->FindObject("BinningStarMap");
     118    if (!bins)
     119    {
     120        float r = geom ? geom->GetMaxRadius() : 600;
     121        r *= 2./3;
     122        if (!fUseMmScale)
     123            r *= fMm2Deg;
     124
     125        MBinning b;
     126        b.SetEdges(100, -r, r);
     127        SetBinning(fStarMap, &b, &b);
     128    }
     129    else
     130        SetBinning(fStarMap, bins, bins);
     131
     132    if (!geom)
     133    {
     134        *fLog << warn << dbginf << "No Camera Geometry available. Using mm-scale for histograms." << endl;
     135        return kTRUE;
     136    }
     137
     138    return kTRUE;
     139}
     140
     141// --------------------------------------------------------------------------
     142//
    90143// Fill the four histograms with data from a MHillas-Container.
    91144// Be careful: Only call this with an object of type MHillas
     
    98151
    99152    const float m = tan(delta);
    100     const float t = h.GetMeanY() - m*h.GetMeanX();
     153
     154    float t = h.GetMeanY() - m*h.GetMeanX();
     155
     156    if (!fUseMmScale)
     157        t *= fMm2Deg;
    101158
    102159    if (m>-1 && m<1)
    103         for (int x=-298; x<298; x+=4)
     160    {
     161        TAxis &axe = *fStarMap->GetXaxis();
     162
     163        const int N = axe.GetXbins()->GetSize();
     164        for (int i=0; i<N; i++)
    104165        {
     166            const float x = axe.GetBinCenter(i);
    105167            const float y = m*x+t;
    106168
    107169            fStarMap->Fill(x, y);
    108170        }
     171    }
    109172    else
    110         for (int y=-298; y<298; y+=4)
     173    {
     174        TAxis &axe = *fStarMap->GetYaxis();
     175
     176        const int N = axe.GetXbins()->GetSize();
     177        for (int i=0; i<N; i++)
    111178        {
     179            const float y = axe.GetBinCenter(i);
    112180            const float x = (y-t)/m;
    113181
    114182            fStarMap->Fill(x, y);
    115183        }
     184    }
    116185
    117186    return kTRUE;
     187}
     188
     189// --------------------------------------------------------------------------
     190//
     191// Use this function to setup your own conversion factor between degrees
     192// and millimeters. The conversion factor should be the one calculated in
     193// MGeomCam. Use this function with Caution: You could create wrong values
     194// by setting up your own scale factor.
     195//
     196void MHStarMap::SetMm2Deg(Float_t mmdeg)
     197{
     198    if (mmdeg<0)
     199    {
     200        *fLog << warn << dbginf << "Warning - Conversion factor < 0 - nonsense. Ignored." << endl;
     201        return;
     202    }
     203
     204    if (fMm2Deg>=0)
     205        *fLog << warn << dbginf << "Warning - Conversion factor already set. Overwriting" << endl;
     206
     207    fMm2Deg = mmdeg;
     208}
     209
     210// --------------------------------------------------------------------------
     211//
     212// With this function you can convert the histogram ('on the fly') between
     213// degrees and millimeters.
     214//
     215void MHStarMap::SetMmScale(Bool_t mmscale)
     216{
     217    if (fUseMmScale == mmscale)
     218        return;
     219
     220    if (fMm2Deg<0)
     221    {
     222        *fLog << warn << dbginf << "Warning - Sorry, no conversion factor for conversion available." << endl;
     223        return;
     224    }
     225
     226    if (fUseMmScale)
     227    {
     228        fStarMap->SetXTitle("x [mm]");
     229        fStarMap->SetYTitle("y [mm]");
     230
     231        fStarMap->Scale(1./fMm2Deg);
     232    }
     233    else
     234    {
     235        fStarMap->SetXTitle("x [\\circ]");
     236        fStarMap->SetYTitle("y [\\circ]");
     237
     238        fStarMap->Scale(1./fMm2Deg);
     239    }
     240
     241    fUseMmScale = mmscale;
    118242}
    119243
  • trunk/MagicSoft/Mars/mhist/MHStarMap.h

    r1207 r1283  
    1717    TH2F *fStarMap;
    1818
     19    Float_t fMm2Deg;
     20
     21    Bool_t fUseMmScale;
     22
    1923    void PrepareDrawing() const;
    2024
     
    2327    ~MHStarMap();
    2428
     29    void SetMmScale(Bool_t mmscale=kTRUE);
     30    void SetMm2Deg(Float_t mmdeg);
     31
     32    Bool_t SetupFill(const MParList *pList);
    2533    Bool_t Fill(const MParContainer *par);
    2634
  • trunk/MagicSoft/Mars/mhist/Makefile

    r1228 r1283  
    3131           MBinning.cc \
    3232           MH.cc \
     33           MH3.cc \
    3334           MHFadcPix.cc \
    3435           MHFadcCam.cc \
    3536           MHHillas.cc \
    3637           MHHillasSrc.cc \
     38           MHHillasExt.cc \
    3739           MHStarMap.cc \
    3840           MHEnergyTime.cc \
Note: See TracChangeset for help on using the changeset viewer.