Changeset 1209


Ignore:
Timestamp:
01/22/02 17:32:15 (23 years ago)
Author:
tbretz
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/Changelog

    r1208 r1209  
    88   * mfilter/MFAlpha.[h,cc]:
    99     - added
     10
     11   * mfilter/MFill.[h,cc]:
     12     - implemented a new calling style which allows you to let MFillH
     13       create the necessary histogram objects
     14
     15   * mmain/MAnalysis.cc, macros/MagicHillas.C:
     16     - changed to new stylish MHillas parameter containers
    1017
    1118
  • trunk/MagicSoft/Mars/macros/MagicHillas.C

    r1152 r1209  
    2424
    2525
    26 void MagicHillas(const char *filename="data/camera.root")
     26void MagicHillas(const char *filename="~/data/Gamma*.root")
    2727{
    2828    //
     
    4646    plist.AddToList(&geomcam);
    4747
    48     MPedestalCam pedest;
    49     plist.AddToList(&pedest);
     48    //
     49    // Craete the object which hlods the source positions in the camera
     50    // plain in respect to which the image parameters will be calculated.
     51    // For real data the containers will be filled by a task.
     52    //
     53    MSrcPosCam source("Source")
     54    source.SetXY(0, 0);
     55
     56    MSrcPosCam antisrc("AntiSrc");
     57    antisrc.SetXY(240, 0);
     58
     59    plist.AddToList(&source);
     60    plist.AddToList(&antisrc);
    5061
    5162    //
    5263    // Now setup the tasks and tasklist:
    53     //
    54     //  1) read in the data from a magic root file   MReadTree
    55     //  2) calculate number of cerenkov photons      MCerPhotCalc
    56     //  3) clean the image                           MImgCleanStd
    57     //  4) calculate hillas                          MHillasCalc
    58     //  5) fill the hillas into the histograms       MFillH
    59     //
    60 
     64    // ---------------------------------
    6165    //
    6266    // The first argument is the tree you want to read.
     
    6569    //   CalEvents:  Calibration Events
    6670    //
    67     MReadMarsFile  read("Events",filename);
     71    MReadMarsFile  read("Events", filename);
    6872
    6973    MMcPedestalCopy   pcopy;
     
    7377    MBlindPixelCalc   blind;
    7478    MHillasCalc       hcalc;
    75     MFillH            hfill("MHillas", "MHHillas");
    76     MFillH            sfill("MHillas", "MHStarMap");
     79    MHillasSrcCalc    csrc1("Source",  "HillasSource");
     80    MHillasSrcCalc    csrc2("AntiSrc", "HillasAntiSrc");
    7781
    78     //
    79     // Crete and setup Tasklist
    80     //
     82    MFillH hfill("MHHillas",   "MHillas");
     83    MFillH sfill("MHStarMap",  "MHillas");
     84    MFillH hfill2s("HistSource  [MHHillasSrc]", "HillasSource");
     85    MFillH hfill2a("HistAntiSrc [MHHillasSrc]", "HillasAntiSrc");
     86
    8187    MWriteRootFile write("hillas.root");
    82     write.AddContainer("MHillas");
     88    write.AddContainer("MHillas",       "Hillas");
     89    write.AddContainer("HillasSource",  "Hillas");
     90    write.AddContainer("HillasAntiSrc", "Hillas");
    8391    write.AddContainer("MHStarMap");
    8492
     
    9098    tlist.AddToList(&blind);
    9199    tlist.AddToList(&hcalc);
     100    tlist.AddToList(&csrc1);
     101    tlist.AddToList(&csrc2);
    92102    tlist.AddToList(&hfill);
    93103    tlist.AddToList(&sfill);
     104    tlist.AddToList(&hfill2s);
     105    tlist.AddToList(&hfill2a);
    94106    tlist.AddToList(&write);
    95107
     
    112124    //
    113125    plist.FindObject("MHHillas")->DrawClone();
     126    plist.FindObject("HistSource")->DrawClone();
     127    plist.FindObject("HistAntiSrc")->DrawClone();
    114128    plist.FindObject("MHStarMap")->DrawClone();
    115129}
  • trunk/MagicSoft/Mars/manalysis/MHillasSrcCalc.cc

    r1203 r1209  
    6767    if (!fHillas)
    6868    {
    69         *fLog << dbginf << "MHillas not found... aborting." << endl;
     69        *fLog << err << dbginf << "MHillas not found... aborting." << endl;
    7070        return kFALSE;
    7171    }
     
    7474    if (!fSrcPos)
    7575    {
    76         *fLog << dbginf << "MSrcPosCam missing in Parameter List... aborting." << endl;
     76        *fLog << err << dbginf << fSrcName << " [MSrcPosCam] not found... aborting." << endl;
    7777        return kFALSE;
    7878    }
  • trunk/MagicSoft/Mars/mfilter/MFAlpha.h

    r1208 r1209  
    44/////////////////////////////////////////////////////////////////////////////
    55//                                                                         //
    6 // MFAlpha                                                           //
     6// MFAlpha                                                                 //
    77//                                                                         //
    88/////////////////////////////////////////////////////////////////////////////
     
    3737    Bool_t Process();
    3838
    39     ClassDef(MFAlpha, 0)                // A Filter for the Level 1 Trigger
     39    ClassDef(MFAlpha, 0) // A Filter for cuts in fabs(alpha)
    4040};
    4141
  • trunk/MagicSoft/Mars/mhist/MFillH.cc

    r1082 r1209  
    3030//  histogram which is derived from MH can be filled with this task.        //
    3131//                                                                          //
    32 //  You must specifiy the parameter container with which data the histogram //
    33 //  container should be filled, and the histogram container which has       //
    34 //  to be filled. This can be done by either specifing the name of the      //
    35 //  objects in the parameter list or by specifiing a pointer to the object. //
    36 //  (s. Constructor)                                                        //
     32//  There are two options to use:                                           //
     33//                                                                          //
     34//  1) You specifiy the parameter container with which data the             //
     35//     histogram container should be filled, and the histogram container    //
     36//     which has to be filled. This can be done by either specifing the     //
     37//     name of the objects in the parameter list or by specifiing a pointer //
     38//     to the object. (s. Constructor)                                      //                  //
     39//                                                                          //
     40//  2) You specify the name and/or type of the histogram to become filled.  //
     41//     Any other action imust be taken by the histogram class.              //
     42//                                                                          //
     43//  PreProcess: In the preprocessing of this task we setup all pointers     //
     44//              to instances which are needed and call FillSetup of the     //
     45//              histogram class with the parameter list as an argument.     //
     46//                                                                          //
     47//  Process: The process function calls the Fill member function of the     //
     48//           histogram class instance (inheriting from MH) with either      //
     49//           a NULL pointer or a pointer to the corresponding container     //
     50//           as an argument.                                                //
    3751//                                                                          //
    3852//  WARNING:                                                                //
     
    8195// Constructor.
    8296//
    83 // - par is the name of the parameter container which should be filled into
    84 //   the histogram
    85 // - hist is the name of the histogram container (which must have been
    86 //   derived from MH)
    87 //
    88 MFillH::MFillH(const char *par, const char *hist, const char *name, const char *title)
     97// 1) - par is the name of the parameter container which should be filled into
     98//      the histogram
     99//    - hist is the name of the histogram container (which must have been
     100//      derived from MH)
     101//
     102//    In this case MH::Fill is called with a pointer to the corresponding
     103//    histogram instance.
     104//
     105// 2) - hist is the name and/or type of the histogram.
     106//      1) The name and type is identical, eg: "MHHillas"
     107//      2) They are not identical, eg: "MyHistogram [MHHillas]"
     108//         This searches for a class instance of MHHillas with the name
     109//         "MyHistogram". If it doesn't exist one is created.
     110//
     111//    In this case PreProcess calls MH::SetupFill with a pointer to the
     112//    parameter list and MH::Fill is called with a NULL-pointer.
     113//
     114MFillH::MFillH(const char *hist, const char *par, const char *name, const char *title)
    89115{
    90116    Init(name, title);
    91117
    92118    fHName = hist;
     119    fParContainerName = par;
     120}
     121
     122// --------------------------------------------------------------------------
     123//
     124// Constructor.
     125//
     126// 1) - par is a pointer to the instance of your parameter container from which
     127//      the data should be used to fill the histogram.
     128//    - hist is the name of the histogram container (which must have been
     129//      derived from MH)
     130//
     131//    In this case MH::Fill is called with a pointer to the corresponding
     132//    histogram instance.
     133//
     134// 2) - hist is the name and/or type of the histogram.
     135//      1) The name and type is identical, eg: "MHHillas"
     136//      2) They are not identical, eg: "MyHistogram [MHHillas]"
     137//         This searches for a class instance of MHHillas with the name
     138//         "MyHistogram". If it doesn't exist one is created. Everything
     139//         which is between the first '[' and the last ']' in the string
     140//         is used as the histogram type.
     141//
     142//    In this case PreProcess calls MH::SetupFill with a pointer to the
     143//    parameter list and MH::Fill is called with a NULL-pointer.
     144//
     145//
     146MFillH::MFillH(const char *hist, const MParContainer *par, const char *name, const char *title)
     147{
     148    Init(name, title);
     149
     150    fHName = hist;
     151    fParContainer = par;
     152    fParContainerName = par->GetName();
     153}
     154
     155// --------------------------------------------------------------------------
     156//
     157// Constructor.
     158//
     159// - par is a pointer to the instance of your parameter container from which
     160//   the data should be used to fill the histogram.
     161// - hist is a pointer to the instance of your histogram container (which must
     162//   have been derived from MH) into which the data should flow
     163//
     164MFillH::MFillH(MH *hist, const char *par, const char *name, const char *title)
     165{
     166    Init(name, title);
     167
     168    fH = hist;
     169    fHName = hist->GetName();
    93170    fParContainerName = par;
    94171}
     
    103180//   derived from MH)
    104181//
    105 MFillH::MFillH(const MParContainer *par, const char *hist, const char *name, const char *title)
    106 {
    107     Init(name, title);
    108 
    109     fHName = hist;
    110     fParContainer = par;
    111     fParContainerName = par->GetName();
    112 }
    113 
    114 // --------------------------------------------------------------------------
    115 //
    116 // Constructor.
    117 //
    118 // - par is a pointer to the instance of your parameter container from which
    119 //   the data should be used to fill the histogram.
    120 // - hist is a pointer to the instance of your histogram container (which must
    121 //   have been derived from MH) into which the data should flow
    122 //
    123 MFillH::MFillH(const char *par, MH *hist, const char *name, const char *title)
    124 {
    125     Init(name, title);
    126 
    127     fH = hist;
    128     fHName = hist->GetName();
    129     fParContainerName = par;
    130 }
    131 
    132 // --------------------------------------------------------------------------
    133 //
    134 // Constructor.
    135 //
    136 // - par is a pointer to the instance of your parameter container from which
    137 //   the data should be used to fill the histogram.
    138 // - hist is the name of the histogram container (which must have been
    139 //   derived from MH)
    140 //
    141 MFillH::MFillH(const MParContainer *par, MH *hist, const char *name, const char *title)
     182MFillH::MFillH(MH *hist, const MParContainer *par, const char *name, const char *title)
    142183{
    143184    Init(name, title);
     
    147188    fParContainer = par;
    148189    fParContainerName = par->GetName();
     190}
     191
     192TString MFillH::ExtractName(const char *name) const
     193{
     194    TString type = name;
     195
     196    const Ssiz_t first = type.First('[');
     197    const Ssiz_t last  = type.First(']');
     198
     199    if (!first || !last || first>=last)
     200        return type;
     201
     202    return type.Remove(first).Strip(TString::kBoth);
     203}
     204
     205TString MFillH::ExtractClass(const char *name) const
     206{
     207    TString type = name;
     208
     209    const Ssiz_t first = type.First('[');
     210    const Ssiz_t last  = type.First(']');
     211
     212    if (!first || !last || first>=last)
     213        return type;
     214
     215    const Ssiz_t length = last-first-1;
     216
     217    TString strip = fHName(first+1, length);
     218    return strip.Strip(TString::kBoth);
    149219}
    150220
     
    159229Bool_t MFillH::PreProcess(MParList *pList)
    160230{
    161     if (!fParContainer)
     231    //
     232    // Try to get the histogram container with name fHName from list
     233    // or create one with this name
     234    //
     235    if (!fH)
    162236    {
    163         fParContainer = (MParContainer*)pList->FindObject(fParContainerName);
    164         if (!fParContainer)
     237        const TString cls  = ExtractClass(fHName);
     238        const TString name = ExtractName(fHName);
     239
     240        TObject *obj = pList->FindCreateObj(cls, name);
     241        if (!obj)
     242            return kFALSE;
     243
     244        //
     245        // We were successfull getting it. Check whether it really inherits
     246        // from MH, FindCreateObj does only check for inheritance from
     247        // 'type'.
     248        //
     249        if (!obj->InheritsFrom(MH::Class()))
    165250        {
    166             *fLog << err << dbginf << fParContainerName << " [MParContainer] not found... aborting." << endl;
     251            *fLog << err << dbginf << obj->GetName() << " doesn't inherit ";
     252            *fLog << "from MH - cannot be used for MFillH... aborting." << endl;
    167253            return kFALSE;
    168254        }
     255
     256        fH = (MH*)obj;
    169257    }
    170258
    171     if (!fH)
     259    //
     260    // Now we have the histogram container available. Try to Setup Fill.
     261    //
     262    if (!fH->SetupFill(pList))
    172263    {
    173         fH = (MH*)pList->FindCreateObj(fHName);
    174         if (!fH)
    175             return kFALSE;
    176     }
    177 
    178     if (!fH->InheritsFrom("MH"))
    179     {
    180         *fLog << err << dbginf << fH->GetDescriptor() << " ";
    181         *fLog << "doesn't inherit from MH - cannot be used for MFillH... aborting." << endl;
     264        *fLog << err << dbginf << "Error: calling SetupFill for ";
     265        *fLog << fH->GetDescriptor() << "... aborting." << endl;
    182266        return kFALSE;
    183267    }
    184268
    185     return kTRUE;
     269    //
     270    // If also a parameter container is already set we are done.
     271    //
     272    if (fParContainer)
     273        return kTRUE;
     274
     275    //
     276    // If a name is given try to find the input container in the
     277    // list. If it could not be found we cannot proceed.
     278    //
     279    fParContainer = (MParContainer*)pList->FindObject(fParContainerName);
     280    if (fParContainer)
     281        return kTRUE;
     282
     283    *fLog << err << dbginf << fParContainerName << " [MParContainer] not found... aborting." << endl;
     284    return kFALSE;
    186285}
    187286
     
    192291Bool_t MFillH::Process()
    193292{
    194     fH->Fill(fParContainer);
    195 
    196     return kTRUE;
     293    return fH->Fill(fParContainer);
    197294}
    198295
  • trunk/MagicSoft/Mars/mhist/MFillH.h

    r1015 r1209  
    1818    TString fHName;
    1919
     20    TString ExtractName(const char *name) const;
     21    TString ExtractClass(const char *name) const;
     22
    2023    void Init(const char *name, const char *title);
    2124
    2225public:
    23     MFillH(const char *par,          const char *hist, const char *name=NULL, const char *title=NULL);
    24     MFillH(const MParContainer *par, const char *hist, const char *name=NULL, const char *title=NULL);
    25     MFillH(const char *par,          MH *hist,         const char *name=NULL, const char *title=NULL);
    26     MFillH(const MParContainer *par, MH *hist,        const char *name=NULL, const char *title=NULL);
     26    MFillH(const char *hist, const char *par=NULL,    const char *name=NULL, const char *title=NULL);
     27    MFillH(const char *hist, const MParContainer *par, const char *name=NULL, const char *title=NULL);
     28    MFillH(MH *hist,         const char *par=NULL,     const char *name=NULL, const char *title=NULL);
     29    MFillH(MH *hist,         const MParContainer *par, const char *name=NULL, const char *title=NULL);
    2730
    2831    Bool_t PreProcess(MParList *pList);
  • trunk/MagicSoft/Mars/mhist/MHHillas.h

    r1207 r1209  
    2727    TObject *DrawClone(Option_t *opt=NULL) const;
    2828
    29     ClassDef(MHHillas, 1) // Container which hilds hostograms for the Hillas parameters
     29    ClassDef(MHHillas, 1) // Container which holds histograms for length and width
    3030};
    3131
  • trunk/MagicSoft/Mars/mhist/MHHillasSrc.cc

    r1208 r1209  
    100100// --------------------------------------------------------------------------
    101101//
    102 // Draw clones of all four histograms. So that the object can be deleted
     102// Draw clones of all two histograms. So that the object can be deleted
    103103// and the histograms are still visible in the canvas.
    104104// The cloned object are deleted together with the canvas if the canvas is
     
    108108TObject *MHHillasSrc::DrawClone(Option_t *opt) const
    109109{
    110     TCanvas *c = MakeDefCanvas("Hillas", "Histograms of Hillas Parameters",
     110    TCanvas *c = MakeDefCanvas("Hillas", "Histograms of Source dependant Parameters",
    111111                               350, 500);
    112112    c->Divide(1, 2);
     113
     114    // FIXME: Display Source position
    113115
    114116    gROOT->SetSelectedPad(NULL);
     
    131133// --------------------------------------------------------------------------
    132134//
    133 // Creates a new canvas and draws the four histograms into it.
     135// Creates a new canvas and draws the two histograms into it.
    134136// Be careful: The histograms belongs to this object and won't get deleted
    135137// together with the canvas.
     
    138140{
    139141    if (!gPad)
    140         MakeDefCanvas("Hillas", "Histograms of Hillas Parameters", 350, 500);
     142        MakeDefCanvas("Hillas", "Histograms of Src dependant Parameters", 350, 500);
     143
     144    // FIXME: Display Source position
    141145
    142146    gPad->Divide(1, 2);
  • trunk/MagicSoft/Mars/mhist/MHHillasSrc.h

    r1208 r1209  
    2727    TObject *DrawClone(Option_t *opt=NULL) const;
    2828
    29     ClassDef(MHHillasSrc, 1) // Container which hilds hostograms for the Hillas parameters
     29    ClassDef(MHHillasSrc, 1) // Container which holds histograms for the source dependant parameters
    3030};
    3131
  • trunk/MagicSoft/Mars/mmain/MAnalysis.cc

    r1170 r1209  
    132132#include "MBlindPixelCalc.h"
    133133#include "MHillasCalc.h"
     134#include "MHillasSrcCalc.h"
     135#include "MSrcPosCam.h"
    134136#include "MFillH.h"
    135137#include "MEvtLoop.h"
     
    161163    plist.AddToList(&geomcam);
    162164
    163     MPedestalCam pedest;
    164     plist.AddToList(&pedest);
     165    MSrcPosCam source("Source");
     166    source.SetXY(0, 0);
     167
     168    MSrcPosCam antisrc("AntiSrc");
     169    antisrc.SetXY(240, 0);
     170
     171    plist.AddToList(&source);
     172    plist.AddToList(&antisrc);
    165173
    166174    //
     
    187195    MBlindPixelCalc    blind;
    188196    MHillasCalc        hcalc;
     197    MHillasSrcCalc    csrc1("Source",     "HillasSource");
     198    MHillasSrcCalc    csrc2("AntiSource", "HillasAntiSrc");
     199
     200    MFillH hfill("MHHillas",   "MHillas");
     201    MFillH sfill("MHStarMap",  "MHillas");
     202
     203    MFillH hfill2s("HistSource  [MHHillasSrc]", "HillasSource");
     204    MFillH hfill2a("HistAntiSrc [MHHillasSrc]", "HillasAntiSrc");
    189205
    190206    tlist.AddToList(&read);
     
    195211    tlist.AddToList(&blind);
    196212    tlist.AddToList(&hcalc);
    197 
    198     MFillH hfill("MHillas", "MHHillas");
    199     MFillH sfill("MHillas", "MHStarMap");
     213    tlist.AddToList(&csrc1);
     214    tlist.AddToList(&csrc2);
    200215
    201216    if (displhillas)
     217    {
    202218        tlist.AddToList(&hfill);
     219        tlist.AddToList(&hfill2s);
     220        tlist.AddToList(&hfill2a);
     221    }
    203222
    204223    if (displstarmap)
     
    234253    //
    235254    if (displhillas)
     255    {
    236256        plist.FindObject("MHHillas")->DrawClone();
     257        plist.FindObject("HistSource")->DrawClone();
     258        plist.FindObject("HistAntiSrc")->DrawClone();
     259    }
    237260
    238261    if (displstarmap)
Note: See TracChangeset for help on using the changeset viewer.