Changeset 867


Ignore:
Timestamp:
07/13/01 18:13:06 (23 years ago)
Author:
tbretz
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars
Files:
17 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/Changelog

    r866 r867  
    11                                                                  -*-*- END -*-*-
     2
     3 2001/07/13: Thomas Bretz
     4
     5   * mbase/MEvtLoop.[h,cc]:
     6     - Added a result value to Eventloop to be able to detect if the
     7       execution was successfull
     8     - changes postProcess to return the return value from
     9       MTaskList::PostProcess
     10     
     11   * mbase/MParList.cc:
     12     - FindCreateObj removes now a 'dot' from the end of an indexed
     13       object name like "Events;7."
     14     
     15   * mbase/MReadTree.cc:
     16     - small changes to the output
     17
     18   * mbase/MTask.[h,cc]:
     19     - added Preprocessed flag. This enables the tasklist to only postprocess
     20       already preprocessed tasks
     21
     22   * mbase/MTaskList.cc:
     23     - don't postprocess non preprocessed tasks
     24   
     25   * mhist/MHMcCollectionArea.cc:
     26     - added descriptions to histrograms
     27     - changed names of histograms
     28     - added drawing of canvas to Draw-functions
     29
     30   * mhist/MHMcEnergy.[h,cc]:
     31     - added variables to store the calculated result
     32     - changed names and titles of histogram
     33     - added axis titles to histogram
     34     - moved result calculation into fit-function
     35
     36   * mmontecarlo/MMcCollectionAreaCalc.cc:
     37     - added name of input container to be able to process another
     38       container than "MMcTrig"
     39
     40   * mmontecarlo/MMcThresholdCalc.cc:
     41     - removed trailing dot from container name creation
     42   
     43   * mhist/MMcThresholdCalc.cc:
     44     - removed a wrong '.' behind the number when processing more than
     45       one trigger condition
     46
     47   * mraw/MRawRunHeader.cc:
     48     - added "Monte Carlo Data" as runtype
     49
     50
    251
    352 2001/07/10: Thomas Bretz
  • trunk/MagicSoft/Mars/mbase/MEvtLoop.cc

    r858 r867  
    105105
    106106    if (fLog != &gLog)
    107     {
    108107        fParList ->SetLogStream(fLog);
    109         fTaskList->SetLogStream(fLog);
    110     }
    111108
    112109    //
     
    180177        << " --> " << (maxcnt<0?dummy:maxcnt)/clock.CpuTime() << " Events/s"
    181178        << endl << endl;
    182 
    183179}
    184180
     
    188184//  for developers use only!
    189185//
    190 void MEvtLoop::PostProcess() const
     186Bool_t MEvtLoop::PostProcess() const
    191187{
    192188    //
    193189    //  execute the post process of all tasks
    194190    //
    195     fTaskList->PostProcess();
    196 }
    197 
    198 // --------------------------------------------------------------------------
    199 //
    200 // See class description above.
    201 //
    202 void MEvtLoop::Eventloop(Int_t maxcnt, const char *tlist)
    203 {
    204     if (!PreProcess(tlist))
    205         return;
    206 
    207     Process(maxcnt);
    208 
    209     PostProcess();
    210 }
    211 
     191    return fTaskList->PostProcess();
     192}
     193
     194// --------------------------------------------------------------------------
     195//
     196//  See class description above.
     197//
     198Bool_t MEvtLoop::Eventloop(Int_t maxcnt, const char *tlist)
     199{
     200    Bool_t rc = PreProcess();
     201
     202    if (rc)
     203        Process(maxcnt);
     204
     205    if (!PostProcess())
     206        return kFALSE;
     207
     208    return rc;
     209}
     210
  • trunk/MagicSoft/Mars/mbase/MEvtLoop.h

    r698 r867  
    3535    Bool_t PreProcess(const char *tlist="MTaskList");
    3636    void   Process(Int_t maxcnt) const;
    37     void  PostProcess() const;
     37    Bool_t PostProcess() const;
    3838
    39     void Eventloop(Int_t maxcnt=-1, const char *tlist="MTaskList");
     39    Bool_t Eventloop(Int_t maxcnt=-1, const char *tlist="MTaskList");
    4040
    4141    ClassDef(MEvtLoop, 0) // Class to execute the tasks in a tasklist
  • trunk/MagicSoft/Mars/mbase/MParList.cc

    r860 r867  
    199199//  after the last appearance of a semicolon is stripped to get the
    200200//  Name of the Class. Normally this is used to number your objects.
    201 //  "Name;1", "Name;2", ...
     201//  "Name;1", "Name;2", ... If a semicolon is detected leading dots
     202//  are stripped from the object-name (eg. "name;5.")
    202203//
    203204MParContainer *MParList::FindCreateObj(const char *classname, const char *objname)
     
    223224    const char *semicolon = strrchr(cname, ';');
    224225
     226    TString oname(objname);
     227
    225228    if (semicolon)
     229    {
    226230        cname.Remove(semicolon-cname);
     231
     232        //
     233        // Remove leading dots from objectname (eg. "MMcTrig;5.")
     234        //
     235        Int_t sz = oname.Sizeof()-2;
     236
     237        while (sz>=0 && oname[sz]=='.')
     238            oname.Remove(sz--);
     239    }
    227240
    228241    //
     
    230243    // in the List. If we can find one we are done.
    231244    //
    232     MParContainer *pcont = (MParContainer*)FindObject(objname);
     245    MParContainer *pcont = (MParContainer*)FindObject(oname);
    233246
    234247    if (pcont)
     
    238251    // if object is not existing in the list try to create one
    239252    //
    240     *fLog << dbginf << "Object '" << objname << "' of type '" << cname << "' not found... creating." << endl;
     253    *fLog << dbginf << "Object '" << oname << "' of type '" << cname << "' not found... creating." << endl;
    241254
    242255    //
     
    263276    // set the new object name of the object
    264277    //
    265     pcont->SetName(objname);
     278    pcont->SetName(oname);
    266279
    267280    //
  • trunk/MagicSoft/Mars/mbase/MReadTree.cc

    r858 r867  
    173173            // we cannot proceed reading this branch
    174174            //
    175             *fLog << "MReadTree::PreProcess - Warning: Class '" << name << "' not existing in dictionary. Branch skipped." << endl;
     175            *fLog << dbginf << "Warning: Class '" << name << "' not existing in dictionary. Branch skipped." << endl;
    176176            continue;
    177177        }
  • trunk/MagicSoft/Mars/mbase/MTask.h

    r858 r867  
    2222    const MFilter *fFilter;
    2323
     24    Bool_t fIsPreprocessed; // Indicates the success of the PreProcessing (set by MTaskList)
     25
    2426public:
    25     MTask() : fFilter(NULL) {}
     27    MTask() : fFilter(NULL), fIsPreprocessed(kFALSE) {}
    2628    ~MTask()
    2729    {
     
    3032    const MFilter *GetFilter() const { return fFilter; }
    3133    void SetFilter(const MFilter *filter) { fFilter=filter; }
     34
     35    Bool_t IsPreprocessed() const { return fIsPreprocessed; }
     36    void SetIsPreprocessed(Bool_t state=kTRUE) { fIsPreprocessed = state; }
    3237
    3338    virtual Bool_t PreProcess(MParList *pList);
  • trunk/MagicSoft/Mars/mbase/MTaskList.cc

    r860 r867  
    193193        if (!task->PreProcess(fParList))
    194194            return kFALSE;
     195
     196        task->SetIsPreprocessed();
    195197    }
    196198
     
    307309    while ( (task=(MTask*)Next()) )
    308310    {
     311        if (!task->IsPreprocessed())
     312            continue;
     313
    309314        *fLog << task->GetName() << "... " << flush;
    310315
  • trunk/MagicSoft/Mars/mhist/MHMcCollectionArea.cc

    r859 r867  
    2626#include "MHMcCollectionArea.h"
    2727
    28 #include <MLog.h>
    29 #include <TH2.h>
     28#include <TH2.h>
     29#include <TCanvas.h>
    3030
    3131ClassImp(MHMcCollectionArea);
     
    4949
    5050
    51     fHistAll = new TH2D("collAreaAll", "all showers - Radius vs log(E) distribution",
     51    fHistAll = new TH2D("All Events", "All showers - Radius vs log(E) distribution",
    5252                        50, 0., 5.,
    5353                        50, 0., 500.);
    5454
    55     fHistSel = new TH2D("collAreaSel", "selected showers - Radius vs log(E) distribution",
     55    fHistAll->SetXTitle("log(E/GeV)");
     56    fHistAll->SetYTitle("r/m");
     57    fHistAll->SetZTitle("N");
     58
     59    fHistSel = new TH2D("Selected Events", "Selected showers - Radius vs log(E) distribution",
    5660                        50, 0., 5.,
    5761                        50, 0., 500.);
    5862
    59     fHistCol = new TH1D("collArea", "Collection Area",
     63    fHistSel->SetXTitle("log(E/GeV)");
     64    fHistSel->SetYTitle("r/m");
     65    fHistSel->SetYTitle("N");
     66
     67    fHistCol = new TH1D("Area", "Collection Area vs. log(E)",
    6068                        50, 0., 5.);
     69
     70    fHistCol->SetXTitle("log(E/GeV)");
     71    fHistCol->SetYTitle("A/m^2");
    6172}
    6273
     
    7889}
    7990
    80 void MHMcCollectionArea::DrawAll()
     91void MHMcCollectionArea::DrawAll(Option_t* option)
    8192{
    82     fHistAll->Draw();
     93    TCanvas *c=new TCanvas(fHistAll->GetName(), fHistAll->GetTitle());
     94
     95    fHistSel->Draw(option);
     96
     97    c->Modified();
     98    c->Update();
    8399}
    84100
    85 void MHMcCollectionArea::DrawSel()
     101void MHMcCollectionArea::DrawSel(Option_t* option)
    86102{
    87     fHistSel->Draw();
     103    TCanvas *c=new TCanvas(fHistSel->GetName(), fHistSel->GetTitle());
     104
     105    fHistSel->Draw(option);
     106
     107    c->Modified();
     108    c->Update();
    88109}
    89110
    90111void MHMcCollectionArea::Draw(Option_t* option)
    91112{
     113    TCanvas *c=new TCanvas(fHistCol->GetName(), fHistCol->GetTitle());
     114
    92115    fHistCol->Draw(option);
     116
     117    c->Modified();
     118    c->Update();
    93119}
    94120
  • trunk/MagicSoft/Mars/mhist/MHMcCollectionArea.h

    r853 r867  
    2121{
    2222private:
    23     TH2D  *fHistAll ; //! all simulated showers
    24     TH2D  *fHistSel ; //! the selected showers
    25     TH1D  *fHistCol ; //  the collection area
     23    TH2D *fHistAll; //! all simulated showers
     24    TH2D *fHistSel; //! the selected showers
     25
     26    TH1D *fHistCol; //  the collection area
    2627
    2728public:
    2829
    29     MHMcCollectionArea(const char *name=NULL, const char *title=NULL) ;
    30     ~MHMcCollectionArea() ;
     30    MHMcCollectionArea(const char *name=NULL, const char *title=NULL);
     31    ~MHMcCollectionArea();
    3132
    32     void FillAll(Float_t log10E, Float_t radius) ;
    33     void FillSel(Float_t log10E, Float_t radius) ;
    34     void DrawAll() ;
    35     void DrawSel() ;
    36     void Draw(Option_t* option = "") ;
    37     void CalcEfficiency() ;
     33    void FillAll(Float_t log10E, Float_t radius);
     34    void FillSel(Float_t log10E, Float_t radius);
     35
     36    void DrawAll(Option_t *option = "");
     37    void DrawSel(Option_t *option = "");
     38    void Draw   (Option_t *option = "");
     39
     40    void CalcEfficiency();
    3841
    3942    ClassDef(MHMcCollectionArea, 1)  //  Data Container to calculate Collection Area
  • trunk/MagicSoft/Mars/mhist/MHMcEnergies.cc

    r861 r867  
    6666    delete fHists;
    6767}
     68
    6869// --------------------------------------------------------------------------
    6970//
  • trunk/MagicSoft/Mars/mhist/MHMcEnergy.cc

    r863 r867  
    5151
    5252    if (idx>0)
    53         sprintf(aux+10, ";%i", idx);
     53        sprintf(aux+strlen(aux), ";%i", idx);
     54
    5455    *fName  = name  ? name  : aux;
    55     *fTitle = title ? title : "Container for a MC energy histogram" ;
     56    *fTitle = title ? title : "Container for an energy distribution histogram" ;
    5657
    57     //  - we initialize the histogram and the gaus function
     58    //  - we initialize the histogram
    5859    //  - we have to give diferent names for the diferent histograms because
    5960    //    root don't allow us to have diferent histograms with the same name
    6061
    61     strcpy(aux, "fLogEnergy");
     62    char text[256];
     63    sprintf(text, "Energy Distribution for trigger condition #%i", idx);
     64
     65    strcpy(aux, "log(E)");
    6266    if (idx>0)
    63         sprintf(aux+10, ";%i", idx);
    64     fLogEner = new TF1(aux, "gaus", 1., 3.);
    65 
    66     strcpy(aux, "hLogEnergy");
    67     if (idx>0)
    68         sprintf(aux+10, ";%i", idx);
    69     hLogEner = new TH1F(aux, "", 40, 0.5, 4.5);
    70     hLogEner->SetXTitle("log(E) [GeV]");
    71     hLogEner->SetYTitle("dN/dE");
     67        sprintf(aux+strlen(aux), " #%i", idx);
     68    fHist = new TH1F(aux, text, 40, 0.5, 4.5);
     69    fHist->SetXTitle("log(E/GeV)");
     70    fHist->SetYTitle("dN/dE");
    7271}
    7372
     
    7877MHMcEnergy::~MHMcEnergy()
    7978{
    80     delete hLogEner;
    81     delete fLogEner;
     79    delete fHist;
    8280}
    8381
     
    8886void MHMcEnergy::Fill(Float_t log10E, Float_t w)
    8987{
    90     hLogEner->Fill(log10E, w);
     88    fHist->Fill(log10E, w);
    9189}
    9290
     
    10199    // Q: quiet mode
    102100    //
    103     hLogEner->Fit(fLogEner->GetName(), "Q0", "", xxmin, xxmax);
     101    fHist->Fit("gaus", "Q0", "", xxmin, xxmax);
     102
     103    TF1 *result = fHist->GetFunction("gaus");
     104
     105    fThreshold    = CalcThreshold(result);
     106    fThresholdErr = CalcThresholdErr(result);
     107    fGaussPeak    = CalcGaussPeak(result);
     108    fGaussSigma   = CalcGaussSigma(result);
    104109}
    105110
     
    110115void MHMcEnergy::Draw(Option_t *option)
    111116{
    112     char text[50];
    113     sprintf(text, "Energy Threshold = %4.1f +- %4.1f GeV",
    114             GetThreshold(), GetThresholdErr());
     117    char text[256];
    115118
    116     const Float_t min = hLogEner->GetMinimum();
    117     const Float_t max = hLogEner->GetMaximum();
     119    const Float_t min = fHist->GetMinimum();
     120    const Float_t max = fHist->GetMaximum();
    118121    const Float_t sum = min+max;
    119122
    120     TCanvas *c=new TCanvas("Energy Distribution","Energy distribution for triggered events");
     123    TCanvas *c=new TCanvas(fHist->GetName(), fHist->GetTitle());
    121124
    122     hLogEner->Draw(option);
     125    fHist->Draw(option);
     126
     127    sprintf(text, "Energy Threshold = %4.1f +- %4.1f GeV",
     128            fThreshold, fThresholdErr);
    123129
    124130    TPaveLabel* label = new TPaveLabel(2.2, 0.75*sum, 4.4, 0.90*sum, text);
    125131    label->SetFillColor(10);
    126132    label->SetTextSize(0.3);
     133    label->SetBit(kCanDelete);
    127134    label->Draw();
    128135
     
    137144void MHMcEnergy::SetNumBins(Int_t nbins)
    138145{
    139     hLogEner->SetBins(nbins, 0.5, 4.5);
     146    fHist->SetBins(nbins, 0.5, 4.5);
    140147}
    141148// --------------------------------------------------------------------------
     
    145152void MHMcEnergy::Print(Option_t*)
    146153{
    147     cout << "Threshold: " << GetThreshold() << " +- " << GetThresholdErr() << endl;
     154    cout << "Threshold: " << fThreshold << " +- " << fThresholdErr << endl;
    148155}
    149156
     
    152159//  Return the threshold
    153160//
    154 Float_t MHMcEnergy::GetThreshold() const
     161Float_t MHMcEnergy::CalcThreshold(TF1 *gauss)
    155162{
    156     const Float_t p1 = fLogEner->GetParameter(1);
     163    const Float_t p1 = gauss->GetParameter(1);
    157164
    158165    return pow(10, p1);
     
    163170// Return the error of the threshold.
    164171//
    165 Float_t MHMcEnergy::GetThresholdErr() const
     172Float_t MHMcEnergy::CalcThresholdErr(TF1 *gauss)
    166173{
    167174    const Float_t lg10  = log(10);
    168     const Float_t p1    = fLogEner->GetParameter(1);
    169     const Float_t p1err = fLogEner->GetParError(1);
     175    const Float_t p1    = gauss->GetParameter(1);
     176    const Float_t p1err = gauss->GetParError(1);
    170177
    171178    // The error has into accuont the error in the fit
     
    177184// Return the peak of the fitted gaussan function.
    178185//
    179 Float_t MHMcEnergy::GetGaussPeak() const
     186Float_t MHMcEnergy::CalcGaussPeak(TF1 *gauss)
    180187{
    181     return fLogEner->GetParameter(1);
     188    return gauss->GetParameter(1);
    182189}
    183190
     
    186193// Return the sigma of the fitted gaussan function.
    187194//
    188 Float_t MHMcEnergy::GetGaussSigma() const
     195Float_t MHMcEnergy::CalcGaussSigma(TF1 *gauss)
    189196{
    190     return fLogEner->GetParameter(2);
     197    return gauss->GetParameter(2);
    191198}
    192199
  • trunk/MagicSoft/Mars/mhist/MHMcEnergy.h

    r863 r867  
    1616private:
    1717
    18     TH1F *hLogEner;  // histogram with the logarith of the energy
    19     TF1  *fLogEner;  // gausian function to fit the histogram
     18    TH1F *fHist;  // histogram with the logarith of the energy
     19
     20    Float_t fThreshold;
     21    Float_t fThresholdErr;
     22    Float_t fGaussPeak;
     23    Float_t fGaussSigma;
     24
     25    Float_t CalcThreshold(TF1 *gauss);
     26    Float_t CalcThresholdErr(TF1 *gauss);
     27
     28    Float_t CalcGaussPeak(TF1 *gauss);
     29    Float_t CalcGaussSigma(TF1 *gauss);
    2030
    2131public:
     
    2434    ~MHMcEnergy();
    2535
    26     Float_t GetThreshold() const;
    27     Float_t GetThresholdErr() const;
     36    Float_t GetThreshold() const { return fThreshold; }
     37    Float_t GetThresholdErr() const { return fThresholdErr; }
    2838
    29     Float_t GetGaussPeak() const;
    30     Float_t GetGaussSigma() const;
     39    Float_t GetGaussPeak() const { return fGaussPeak; }
     40    Float_t GetGaussSigma() const { return fGaussSigma; };
    3141
    3242    void Fill(Float_t log10E, Float_t w);
  • trunk/MagicSoft/Mars/mmontecarlo/MMcCollectionAreaCalc.cc

    r853 r867  
    3636#include "MHMcCollectionArea.h"
    3737
    38 ClassImp(MMcCollectionAreaCalc)
     38ClassImp(MMcCollectionAreaCalc);
    3939
    40 MMcCollectionAreaCalc::MMcCollectionAreaCalc (const char *name, const char *title)
     40MMcCollectionAreaCalc::MMcCollectionAreaCalc(const char *input,
     41                                             const char *name, const char *title)
    4142{
    4243    *fName  = name  ? name  : "MMcCollectionAreaCalc";
    43     *fTitle = title ? title : "Task to calc the collection area ";
     44    *fTitle = title ? title : "Task to calculate the collection area";
     45
     46    fObjName = input ? input : "MMcTrig";
    4447}
    4548
     
    5558    }
    5659
    57     fMcTrig = (MMcTrig*)pList->FindObject("MMcTrig");
     60    fMcTrig = (MMcTrig*)pList->FindObject(fObjName);
    5861    if (!fMcTrig)
    5962    {
    60         *fLog << dbginf << "MMcTrig not found... exit." << endl;
     63        *fLog << dbginf << fObjName << " not found... exit." << endl;
    6164        return kFALSE;
    6265    }
     
    8487}
    8588
    86 Bool_t MMcCollectionAreaCalc::PostProcess ()
     89Bool_t MMcCollectionAreaCalc::PostProcess()
    8790{
    8891    //
  • trunk/MagicSoft/Mars/mmontecarlo/MMcCollectionAreaCalc.h

    r860 r867  
    1919    MHMcCollectionArea *fCollArea;
    2020
     21    TString fObjName;
     22
    2123public:
    22     MMcCollectionAreaCalc(const char *name=NULL, const char *title=NULL);
     24    MMcCollectionAreaCalc(const char *input=NULL,
     25                          const char *name=NULL, const char *title=NULL);
    2326
    2427    Bool_t PreProcess(MParList *pList);
    25     Bool_t Process() ;
    26     Bool_t PostProcess() ;
     28    Bool_t Process();
     29    Bool_t PostProcess();
    2730
    2831    ClassDef(MMcCollectionAreaCalc, 0) // Task to calculate the collection area histogram
  • trunk/MagicSoft/Mars/mmontecarlo/MMcThresholdCalc.cc

    r866 r867  
    110110    {
    111111        if (fDimension>1)
    112             sprintf(auxname+7, ";%i.", i+1);
     112            sprintf(auxname+7, ";%i", i+1);
    113113
    114114        fMcTrig[i] = (MMcTrig*)pList->FindObject(auxname);
  • trunk/MagicSoft/Mars/mmontecarlo/Makefile

    r851 r867  
    3333SRCS    = $(SRCFILES)
    3434HEADERS = $(SRCFILES:.cc=.h)
    35 OBJS    = $(SRCFILES:.cc=.o) 
     35OBJS    = $(SRCFILES:.cc=.o)
    3636
    3737############################################################
  • trunk/MagicSoft/Mars/mraw/MRawRunHeader.cc

    r859 r867  
    141141        *fLog << "Calibration";
    142142        break;
     143    case 256:
     144        *fLog << "Monte Carlo Data";
     145        break;
    143146    }
    144147    *fLog << ")" << endl;
Note: See TracChangeset for help on using the changeset viewer.