Changeset 952 for trunk


Ignore:
Timestamp:
09/27/01 13:25:51 (23 years ago)
Author:
tbretz
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/Changelog

    r951 r952  
    88   * mmain/MAnalysis.[h,cc]:
    99     - added entry field for cleaning levels
     10     - restructured code a bit
     11
     12   * mhist/MHHillas.[h,cc]:
     13     - Added comments
     14     - Added DrawClone
     15     - Removed kCanDelete bits from Draw function
     16     
     17   * mhist/MHStarMap.[h,cc]:
     18     - Added comments
     19     - Added DrawClone
     20     - moved some code from the Draw-functions to PrepareDrawing
    1021
    1122
  • trunk/MagicSoft/Mars/mhist/MHHillas.cc

    r897 r952  
    1919ClassImp(MHHillas);
    2020
     21// --------------------------------------------------------------------------
     22//
     23// Setup four histograms for Alpha, Width, Length and Dist
     24//
    2125MHHillas::MHHillas (const char *name, const char *title)
    2226{
     
    5761}
    5862
     63// --------------------------------------------------------------------------
     64//
     65// Delete the four histograms
     66//
    5967MHHillas::~MHHillas()
    6068{
     
    6573}
    6674
     75// --------------------------------------------------------------------------
     76//
     77// Fill the four histograms with data from a MHillas-Container.
     78// Be careful: Only call this with an object of type MHillas
     79//
    6780void MHHillas::Fill(const MParContainer *par)
    6881{
     
    7588}
    7689
     90// --------------------------------------------------------------------------
     91//
     92// Draw clones of all four histograms. So that the object can be deleted
     93// and the histograms are still visible in the canvas.
     94// The cloned object are deleted together with the canvas if the canvas is
     95// destroyed. If you want to handle dostroying the canvas you can get a
     96// pointer to it from this function
     97//
     98TObject *MHHillas::DrawClone(Option_t *opt)
     99{
     100    TCanvas *c = new TCanvas("Hillas", "Histograms of Hillas Parameters");
     101    c->Divide(2,2);
     102
     103    //
     104    // This is necessary to get the expected bahviour of DrawClone
     105    //
     106    gROOT->SetSelectedPad(NULL);
     107
     108    c->cd(1);
     109    fAlpha->DrawClone()->SetBit(kCanDelete);
     110
     111    c->cd(2);
     112    fLength->DrawClone()->SetBit(kCanDelete);
     113
     114    c->cd(3);
     115    fDist->DrawClone()->SetBit(kCanDelete);
     116
     117    c->cd(4);
     118    fWidth->DrawClone()->SetBit(kCanDelete);
     119
     120    c->Modified();
     121    c->Update();
     122
     123    return c;
     124}
     125
     126// --------------------------------------------------------------------------
     127//
     128// Creates a new canvas and draws the four histograms into it.
     129// Be careful: The histograms belongs to this object and won't get deleted
     130// together with the canvas.
     131//
    77132void MHHillas::Draw(Option_t *)
    78133{
     
    86141
    87142    c->cd(1);
    88     fAlpha->SetBit(kCanDelete);
     143    //fAlpha->SetBit(kCanDelete);
    89144    fAlpha->Draw();
     145
    90146    c->cd(2);
    91     fLength->SetBit(kCanDelete);
     147    //fLength->SetBit(kCanDelete);
    92148    fLength->Draw();
     149
    93150    c->cd(3);
    94     fDist->SetBit(kCanDelete);
     151    //fDist->SetBit(kCanDelete);
    95152    fDist->Draw();
     153
    96154    c->cd(4);
    97     fWidth->SetBit(kCanDelete);
     155    //fWidth->SetBit(kCanDelete);
    98156    fWidth->Draw();
    99157
  • trunk/MagicSoft/Mars/mhist/MHHillas.h

    r887 r952  
    3333
    3434    void Draw(Option_t *opt=NULL);
     35    TObject *DrawClone(Option_t *opt=NULL);
    3536
    3637    ClassDef(MHHillas, 1) // Container which holds hostograms for the Hillas parameters
  • trunk/MagicSoft/Mars/mhist/MHStarMap.cc

    r887 r952  
    4444ClassImp(MHStarMap);
    4545
     46// --------------------------------------------------------------------------
     47//
     48// Create the star map histogram
     49//
    4650MHStarMap::MHStarMap (const char *name, const char *title)
    4751{
     
    6872}
    6973
     74// --------------------------------------------------------------------------
     75//
     76// delete the histogram instance
     77//
    7078MHStarMap::~MHStarMap()
    7179{
     
    7381}
    7482
    75 void MHStarMap::Draw(Option_t *)
    76 {
    77     //
    78     // Creates a new canvas, creates a useful palette and
    79     // draws the histogram in the new created canvas
    80     //
    81 
    82     TCanvas *c = new TCanvas("Star Map", "Star Map created from Hillas Parameters", 500, 500);
    83 
    84     //
    85     // Set the palette you wanna use:
    86     //  - you could set the root "Pretty Palette Violet->Red" by
    87     //    gStyle->SetPalette(1, 0), but in some cases this may look
    88     //    confusing
    89     //  - The maximum colors root allowes us to set by ourself
    90     //    is 50 (idx: 51-100). This colors are set to a grayscaled
    91     //    palette
    92     //  - the number of contours must be two less than the number
    93     //    of palette entries
    94     //
    95 
    96     const Int_t numg = 32; // number of gray scaled colors
    97     const Int_t numw = 32; // number of white
    98 
    99     Int_t palette[numg+numw];
    100 
    101     //
    102     // The first half of the colors are white.
    103     // This is some kind of optical background supression
    104     //
    105     gROOT->GetColor(51)->SetRGB(1, 1, 1);
    106 
    107     Int_t i;
    108     for (i=0; i<numw; i++)
    109         palette[i] = 51;
    110 
    111     //
    112     // now the (gray) scaled part is coming
    113     //
    114     for (;i<numw+numg; i++)
    115     {
    116         const Float_t gray = 1.0-(float)(i-numw)/(numg-1.0);
    117 
    118         gROOT->GetColor(52+i)->SetRGB(gray, gray, gray);
    119         palette[i] = 52+i;
    120     }
    121 
    122     //
    123     // Set the palette and the number of contour levels
    124     //
    125     gStyle->SetPalette(numg+numw, palette);
    126     fStarMap->SetContour(numg+numw-2);
    127 
    128     // gStyle->SetPalette(1, 0);
    129     fStarMap->Draw("colz");
    130 
    131     c->Modified();
    132     c->Update();
    133 }
    134 
     83// --------------------------------------------------------------------------
     84//
     85// Fill the four histograms with data from a MHillas-Container.
     86// Be careful: Only call this with an object of type MHillas
     87//
    13588void MHStarMap::Fill(const MParContainer *par)
    13689{
     
    160113}
    161114
     115// --------------------------------------------------------------------------
     116//
     117// Set the palette you wanna use:
     118//  - you could set the root "Pretty Palette Violet->Red" by
     119//    gStyle->SetPalette(1, 0), but in some cases this may look
     120//    confusing
     121//  - The maximum colors root allowes us to set by ourself
     122//    is 50 (idx: 51-100). This colors are set to a grayscaled
     123//    palette
     124//  - the number of contours must be two less than the number
     125//    of palette entries
     126//
     127void MHStarMap::PrepareDrawing()
     128{
     129    const Int_t numg = 32; // number of gray scaled colors
     130    const Int_t numw = 32; // number of white
     131
     132    Int_t palette[numg+numw];
     133
     134    //
     135    // The first half of the colors are white.
     136    // This is some kind of optical background supression
     137    //
     138    gROOT->GetColor(51)->SetRGB(1, 1, 1);
     139
     140    Int_t i;
     141    for (i=0; i<numw; i++)
     142        palette[i] = 51;
     143
     144    //
     145    // now the (gray) scaled part is coming
     146    //
     147    for (;i<numw+numg; i++)
     148    {
     149        const Float_t gray = 1.0-(float)(i-numw)/(numg-1.0);
     150
     151        gROOT->GetColor(52+i)->SetRGB(gray, gray, gray);
     152        palette[i] = 52+i;
     153    }
     154
     155    //
     156    // Set the palette and the number of contour levels
     157    //
     158    gStyle->SetPalette(numg+numw, palette);
     159    fStarMap->SetContour(numg+numw-2);
     160}
     161
     162
     163// --------------------------------------------------------------------------
     164//
     165// Draw clones of the  histograms, so that the object can be deleted
     166// and the histogram is still visible in the canvas.
     167// The cloned object is deleted together with the canvas if the canvas is
     168// destroyed. If you want to handle destroying the canvas you can get a
     169// pointer to it from this function
     170//
     171TObject *MHStarMap::DrawClone(Option_t *opt)
     172{
     173    TCanvas *c = new TCanvas("Star Map", "Star Map created from Hillas Parameters", 500, 500);
     174
     175    //
     176    // This is necessary to get the expected bahviour of DrawClone
     177    //
     178    gROOT->SetSelectedPad(NULL);
     179
     180    PrepareDrawing();
     181
     182    fStarMap->DrawClone("colz")->SetBit(kCanDelete);
     183
     184    c->Modified();
     185    c->Update();
     186
     187    return c;
     188}
     189
     190// --------------------------------------------------------------------------
     191//
     192// Creates a new canvas and draw the histogram into it.
     193// Be careful: The histogram belongs to this object and won't get deleted
     194// together with the canvas.
     195//
     196void MHStarMap::Draw(Option_t *)
     197{
     198    TCanvas *c = new TCanvas("Star Map", "Star Map created from Hillas Parameters", 500, 500);
     199
     200    PrepareDrawing();
     201
     202    fStarMap->Draw("colz");
     203
     204    c->Modified();
     205    c->Update();
     206}
     207
  • trunk/MagicSoft/Mars/mhist/MHStarMap.h

    r887 r952  
    2323    TH2F *fStarMap;
    2424
     25    void PrepareDrawing();
     26
    2527public:
    2628     MHStarMap(const char *name=NULL, const char *title=NULL);
     
    2931    void Fill(const MParContainer *par);
    3032
    31     TH2F *GetHist()               { return fStarMap; }
     33    TH2F *GetHist() { return fStarMap; }
     34
    3235    void Draw(Option_t *opt=NULL);
     36    TObject *DrawClone(Option_t *opt=NULL);
    3337
    3438    ClassDef(MHStarMap, 1) // Container to hold 2-dim histogram (starmap)
  • trunk/MagicSoft/Mars/mmain/MAnalysis.cc

    r951 r952  
    230230    plist.AddToList(&hillas);
    231231
    232     MHHillas *hists = new MHHillas;
    233     plist.AddToList(hists);
    234 
    235     MHStarMap *smap = new MHStarMap;
    236     plist.AddToList(smap);
    237 
    238     // FIXME: Where do we delete this two objects???
     232    MHHillas  hists;
     233    MHStarMap smap;
     234    plist.AddToList(&hists);
     235    plist.AddToList(&smap);
    239236
    240237    //
     
    254251    //   CalEvents:  Calibration Events
    255252    //
    256     MReadTree      read("Events", fInputFile);
    257     MCerPhotCalc   ncalc;
    258     MImgCleanStd   clean(cleanlvl1, cleanlvl2);
    259     MHillasCalc    hcalc;
    260     MFillH         hfill(&hillas, hists);
    261     MFillH         sfill(&hillas, smap);
     253    MReadTree    read("Events", fInputFile);
     254    MCerPhotCalc ncalc;
     255    MImgCleanStd clean(cleanlvl1, cleanlvl2);
     256    MHillasCalc  hcalc;
    262257
    263258    tlist.AddToList(&read);
     
    265260    tlist.AddToList(&clean);
    266261    tlist.AddToList(&hcalc);
    267     tlist.AddToList(&hfill);
    268     tlist.AddToList(&sfill);
     262
     263    MFillH hfill(&hillas, &hists);
     264    MFillH sfill(&hillas, &smap);
     265
     266    if (displhillas)
     267        tlist.AddToList(&hfill);
     268
     269    if (displstarmap)
     270        tlist.AddToList(&sfill);
    269271
    270272    //
     
    283285    // After the analysis is finished we can display the histograms
    284286    //
    285 
    286287    if (displhillas)
    287         hists->Draw();
     288        hists.DrawClone();
    288289
    289290    if (displstarmap)
    290         smap->Draw();
    291 
     291        smap.DrawClone();
     292
     293    cout << endl;
    292294    cout << "Calculation of Hillas Parameters finished without error!" << endl;
    293295}
  • trunk/MagicSoft/Mars/mmain/MBrowser.cc

    r951 r952  
    255255    fInputFile[0] = '\0';
    256256
     257    fList = new TList;
    257258    fList->SetOwner();
    258259
     
    308309    fClient->FreePicture(fPic2);
    309310    fClient->FreePicture(fPic3);
     311
     312    delete fList;
    310313}
    311314
Note: See TracChangeset for help on using the changeset viewer.