Changeset 988


Ignore:
Timestamp:
10/24/01 15:12:21 (23 years ago)
Author:
tbretz
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars
Files:
4 deleted
18 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/NEWS

    r961 r988  
    1212     object at any state of the analysis, so that the output are several
    1313     states
     14
     15   - Fixed a bug in the collection area error calculation
     16     (Thanks to Ciro and Abelardo)
     17
     18   - Fixed a bug which causes merpp to crash in some environments
     19
     20   - Speed up reading MC files alot, by choosing the right Branches/Leafs
    1421
    1522
  • trunk/MagicSoft/Mars/macros/collarea.C

    r971 r988  
    3434    MTaskList tasklist;
    3535
    36     //
    37     // Setup the parameter list.
    38     //  - we need to create MCollArea only. The other containers
    39     //    are created automatically without loss - we don't have to
    40     //    access them-
    41     //  - MCollArea must be created by us because we need the pointer
    42     //    to it and if it would get created automatically it would also be
    43     //    deleted automatically
    44     //
    4536    parlist.AddToList(&tasklist);
    46 
    47     MHMcCollectionArea *collArea = new MHMcCollectionArea;
    48     parlist.AddToList(collArea);
    4937
    5038    //
     
    6452    MTask task;
    6553    tasklist.AddToList(&task);
    66 
    6754
    6855    //
     
    8471    // filled and can be displayd
    8572    //
    86     collArea->Draw();
     73    parlist.FindObject("MHMcCollectionArea")->DrawClone();
    8774}
  • trunk/MagicSoft/Mars/macros/threshold.C

    r971 r988  
    2424
    2525
    26 void threshold(char* filename="data/CrabNebula_dnsb_09_loop.root")
     26void threshold(char* filename="data/camera.root")
    2727{
    2828    //
     
    3030    // MMcThresholdCalc and shows the results.
    3131    //
    32     MParList  parlist;
     32    MParList parlist;
    3333
    3434    MTaskList tasklist;
     
    4343    //      taking only the trigger information from MMcTrig
    4444    //
    45     const UInt_t numtriggerconditions = 4;
     45    const UInt_t numtrigcond = 0;
     46
     47    UInt_t from = numtrigcond>0 ?           1 : -numtrigcond;
     48    UInt_t to   = numtrigcond>0 ? numtrigcond : -numtrigcond;
     49
     50    Int_t dim = to-from+1;
    4651
    4752    //
     
    4954    // and store the histograms in an TObjArray
    5055    //
    51     TObjArray *hists = new TObjArray(MParList::CreateObjList("MHMcEnergy", numtriggerconditions));
     56    TObjArray hists(MParList::CreateObjList("MHMcEnergy", from, to));
     57    hists.SetOwner();
    5258
    5359    //
    5460    // Check if the list really contains the right number of histograms
    5561    //
    56     if (hists->GetEntriesFast() != numtriggerconditions)
     62    if (hists.GetEntriesFast() != dim)
    5763        return;
    5864
     
    6066    // Add the histograms to the paramater list.
    6167    //
    62     parlist.AddToList(hists);
     68    parlist.AddToList(&hists);
    6369
    6470    //
     
    7177    //      like one dimension MMcThresholdCalc
    7278    //
    73     MReadTree        read("Events;7", filename);
    74     MMcThresholdCalc calc(numtriggerconditions);
     79    MReadTree read("Events", filename);
     80    read.UseLeaf("fEnergy");
     81    read.UseLeaf("fNumFirstLevel");
     82
     83    MMcThresholdCalc calc(numtrigcond);
    7584
    7685    tasklist.AddToList(&read);
     
    9099    // Now you can display the results
    91100    //
    92     for (UInt_t i=0; i<numtriggerconditions; i++)
    93         ((*hists)[i])->Draw();
     101    TIter Next(&hists);
     102    TObject *obj;
     103    while ((obj=Next()))
     104        obj->DrawClone();
    94105}
  • trunk/MagicSoft/Mars/macros/trigrate.C

    r984 r988  
    109109        return;
    110110
    111     TIter Next(&hists);
    112     MHMcRate *r=NULL;
    113     while ((r=(MHMcRate*)Next()))
    114         r->Print();
     111    hists.Print();
    115112}
  • trunk/MagicSoft/Mars/mbase/MReadTree.cc

    r965 r988  
    4242// calling MReadTree::UseLeaf.                                             //
    4343//                                                                         //
     44// FIXME: An automatic enabeling scheme would be nice.                     //
     45//                                                                         //
    4446// Later we'll use TChain::SetNotify to notify MReadTree if the TChain     //
    4547// starts to read a new file.                                              //
     
    258260Bool_t MReadTree::Process()
    259261{
    260     return fChain->GetEntry(fNumEntry++, 0) == 0 ? kFALSE : kTRUE;
     262    return fChain->GetEntry(fNumEntry++) == 0 ? kFALSE : kTRUE;
    261263}
    262264
  • trunk/MagicSoft/Mars/mbase/MTask.cc

    r961 r988  
    6767#include "MTask.h"
    6868
     69#include "MLog.h"
     70#include "MLogManip.h"
     71
     72#include "MFilter.h"
     73
    6974ClassImp(MTask);
     75
     76MTask::MTask(const char *name, const char *title)
     77    : fFilter(NULL), fIsPreprocessed(kFALSE), fNumExecutions()
     78{
     79    *fName  = name  ? name  : "MTask";
     80    *fTitle = title ? title : "Base class for all tasks (dummy task).";
     81}
     82
     83// --------------------------------------------------------------------------
     84//
     85// Mapper function for PreProcess.
     86// Sets the preprocessed flag dependend on the return value of PreProcess.
     87//
     88Bool_t MTask::CallPreProcess(MParList *plist)
     89{
     90    if (!PreProcess(plist))
     91        return kFALSE;
     92
     93    fIsPreprocessed = kTRUE;
     94    return kTRUE;
     95}
     96
     97// --------------------------------------------------------------------------
     98//
     99// Mapper function for Process.
     100// Executes Process dependent on the existance of a filter and its possible
     101// return value.
     102// If Process is executed, the execution counter is increased.
     103//
     104inline Bool_t MTask::CallProcess()
     105{
     106    //
     107    // Check for the existance of a filter. If a filter is existing
     108    // check for its value. If the value is kFALSE don't execute
     109    // this task.
     110    //
     111    const Bool_t exec = fFilter ? fFilter->IsExpressionTrue() : kTRUE;
     112
     113    if (!exec)
     114        return kTRUE;
     115
     116    fNumExecutions++;
     117    return Process();
     118}
     119
     120// --------------------------------------------------------------------------
     121//
     122// Mapper function for PreProcess.
     123// Calls Postprocess dependent on the state of the preprocessed flag,
     124// resets this flag.
     125//
     126Bool_t MTask::CallPostProcess()
     127{
     128    if (!fIsPreprocessed)
     129        return kTRUE;
     130
     131    fIsPreprocessed = kFALSE;
     132    return PostProcess();
     133}
    70134
    71135// --------------------------------------------------------------------------
     
    105169}
    106170
    107 
     171// --------------------------------------------------------------------------
     172//
     173// Prints the number of times this task has been processed.
     174// For convinience the lvl argument results in a number of spaces at the
     175// beginning of the line. So that the structur of a tasklist can be
     176// identified.
     177//
     178void MTask::PrintStatistics(const Int_t lvl) const
     179{
     180    *fLog << setw(lvl) << " " << GetName() << " [";
     181    *fLog << ClassName() << "] \t" << fNumExecutions;
     182    *fLog << endl;
     183}
  • trunk/MagicSoft/Mars/mbase/MTask.h

    r867 r988  
    2323
    2424    Bool_t fIsPreprocessed; // Indicates the success of the PreProcessing (set by MTaskList)
    25 
    26 public:
    27     MTask() : fFilter(NULL), fIsPreprocessed(kFALSE) {}
    28     ~MTask()
    29     {
    30     }
    31 
    32     const MFilter *GetFilter() const { return fFilter; }
    33     void SetFilter(const MFilter *filter) { fFilter=filter; }
    34 
    35     Bool_t IsPreprocessed() const { return fIsPreprocessed; }
    36     void SetIsPreprocessed(Bool_t state=kTRUE) { fIsPreprocessed = state; }
     25    UInt_t fNumExecutions;  // Number of Excutions
    3726
    3827    virtual Bool_t PreProcess(MParList *pList);
     
    4029    virtual Bool_t PostProcess();
    4130
     31public:
     32    MTask(const char *name=NULL, const char *title=NULL);
     33    virtual ~MTask()
     34    {
     35    }
     36
     37    void SetFilter(const MFilter *filter) { fFilter=filter; }
     38    virtual void PrintStatistics(const Int_t lvl=0) const;
     39
     40    Bool_t CallPreProcess(MParList *plist);
     41    Bool_t CallProcess();
     42    Bool_t CallPostProcess();
     43
    4244    ClassDef(MTask, 0)          //Abstract base class for a task
    4345};
  • trunk/MagicSoft/Mars/mbase/MTaskList.cc

    r961 r988  
    4949#include "MLog.h"
    5050#include "MLogManip.h"
    51 #include "MFilter.h"
     51
    5252#include "MParList.h"
    5353#include "MInputStreamID.h"
     
    232232        *fLog << task->GetName() << "... " << flush;
    233233
    234         if (!task->PreProcess(fParList))
     234        if (!task->CallPreProcess(fParList))
    235235            return kFALSE;
    236 
    237         task->SetIsPreprocessed();
    238236    }
    239237
     
    278276
    279277        //
    280         // Check for the existance of a filter. If a filter is existing
    281         // check for its value. If the value is kFALSE don't execute
    282         // this task.
    283         //
    284         const MFilter *filter = task->GetFilter();
    285 
    286         const Bool_t rc = filter ? filter->IsExpressionTrue() : kTRUE;
    287 
    288         if (!rc)
    289             continue;
    290 
    291         //
    292         // if it has the right stream id execute the Process() function
     278        // if it has the right stream id execute the CallProcess() function
    293279        // and check what the result of it is.
    294         //
    295         switch (task->Process())
     280        // The CallProcess() function increases the execution counter and
     281        // calls the Process() function dependent on the existance and
     282        // return value of a filter.
     283        //
     284        switch (task->CallProcess())
    296285        {
    297286        case kTRUE:
     
    312301            //
    313302            return kTRUE;
     303
     304        default:
     305            *fLog << "MTaskList::Process: Unknown return value from MTask::Process()... ignored." << endl;
    314306        }
    315307    }
     
    349341    while ( (task=(MTask*)Next()) )
    350342    {
    351         if (!task->IsPreprocessed())
    352             continue;
     343        if (!task->CallPostProcess())
     344            return kFALSE;
    353345
    354346        *fLog << task->GetName() << "... " << flush;
    355 
    356         //
    357         // FIXME: should we only skip this task?
    358         //
    359         if (!task->PostProcess())
    360             return kFALSE;
    361347    }
    362348
     
    367353
    368354// --------------------------------------------------------------------------
    369 void MTaskList::Print(Option_t *t)
    370 {
    371     *fLog << "TaskList: " << this->GetName() << " <" <<  this->GetTitle() << ">" << endl;
     355//
     356//  Prints the number of times all the tasks in the list has been.
     357//  For convinience the lvl argument results in a number of spaces at the
     358//  beginning of the line. So that the structur of a tasklist can be
     359//  identified. Use MTaskList::PrintStatistics without an argument.
     360//
     361void MTaskList::PrintStatistics(const Int_t lvl) const
     362{
     363    if (lvl==0)
     364    {
     365        *fLog << endl;
     366        *fLog << "Execution Statistics: " << endl;
     367        *fLog << "---------------------" << endl;
     368        *fLog << GetName() << " [" << ClassName() << "]" << endl;
     369    }
     370    else
     371    {
     372        *fLog << setw(lvl) << " " << GetName() << " [";
     373        *fLog << ClassName() << "]" << endl;
     374    }
     375
     376    //
     377    //  create the Iterator for the TaskList
     378    //
     379    TIter Next(&fTasks);
     380
     381    MTask *task=NULL;
     382    //
     383    //  loop over all tasks for postprocessing
     384    //  only tasks which have successfully been preprocessed are postprocessed.
     385    //
     386    while ( (task=(MTask*)Next()) )
     387        task->PrintStatistics(lvl+1);
     388
     389    if (lvl==0)
     390        *fLog << endl;
     391}
     392
     393// --------------------------------------------------------------------------
     394void MTaskList::Print(Option_t *t) const
     395{
     396    *fLog << "TaskList: " << GetName() << " <" << GetTitle() << ">" << endl;
    372397
    373398    fTasks.Print();
  • trunk/MagicSoft/Mars/mbase/MTaskList.h

    r959 r988  
    2727    MParList      *fParList;
    2828
     29    UInt_t *fCntContinue;
     30    UInt_t *fCntTrue;
     31
    2932    enum { kIsOwner = BIT(14) };
    3033
     
    4649    Bool_t PostProcess();
    4750
    48     void Print(Option_t *opt = "");
     51    void Print(Option_t *opt = "") const;
     52    void PrintStatistics(const Int_t lvl=0) const;
    4953    void SetOwner(Bool_t enable=kTRUE);
    5054
  • trunk/MagicSoft/Mars/mmain/MMonteCarlo.cc

    r954 r988  
    219219    //
    220220    MReadTree reader("Events", fInputFile);
     221    reader.UseLeaf("fImpact");
     222    reader.UseLeaf("fEnergy");
     223    reader.UseLeaf("fNumFirstLevel");
     224
    221225    tlist.AddToList(&reader);
    222226
     
    288292    // Check if the list really contains the right number of histograms
    289293    //
    290     if (hists.GetEntriesFast() != dim)
     294    if (hists.GetEntriesFast() != dim && dim)
    291295        return;
    292296
     
    304308    //
    305309    MReadTree reader("Events", fInputFile);
     310    reader.UseLeaf("fImpact");
     311    reader.UseLeaf("fEnergy");
     312    reader.UseLeaf("fPhi");
     313    reader.UseLeaf("fTheta");
     314    reader.UseLeaf("fNumFirstLevel");
     315    reader.UseLeaf("fPhotElfromShower");
     316
    306317    tlist.AddToList(&reader);
    307318
    308     Float_t BgR[10]={660,4,0,0,0,0,0,0,0,0};
    309 
    310     MMcTriggerRateCalc crate(dim, 14, BgR, 100000, 2.75, 10.91e-2);
     319    Float_t BgR[10]={660, 4, 0, 0, 0, 0, 0, 0, 0, 0};
     320
     321    MMcTriggerRateCalc crate(dim, 14, BgR, 100000);
    311322    tlist.AddToList(&crate);
    312323
     
    323334        return;
    324335
    325     TIter Next(&hists);
    326     MHMcRate *rate=NULL;
    327     while ((rate=(MHMcRate*)Next()))
    328         rate->Print();
     336    hists.Print();
    329337}
    330338
     
    378386    //      like one dimension MMcThresholdCalc
    379387    //
    380     MReadTree        read("Events", fInputFile);
     388    MReadTree read("Events", fInputFile);
     389    read.VetoBranch("MRawEvtData");
     390    read.VetoBranch("MRawEvtHeader");
     391
    381392    MMcThresholdCalc calc(dim);
    382 
    383393    tlist.AddToList(&read);
    384394    tlist.AddToList(&calc);
     
    398408    //
    399409    TIter Next(&hists);
    400     MHMcRate *hist=NULL;
    401     while ((hist=(MHMcRate*)Next()))
    402         hist->DrawClone();
     410    TObject *obj;
     411    while ((obj=Next()))
     412        obj->DrawClone();
    403413}
    404414
  • trunk/MagicSoft/Mars/mmontecarlo/MMcThresholdCalc.cc

    r984 r988  
    6363// dim < 0: use only condition number dim (eg "MMcTrig;3")
    6464// dim = 0: use only condition without a number ("MMcTrig")
    65 // dim > 0: use conditions up to dim
     65// dim > 0: use conditions up to dim (from "MMcTrig;1" to "MMcTrig;dim")
    6666//
    6767MMcThresholdCalc::MMcThresholdCalc(const Int_t dim, const char* name,
  • trunk/MagicSoft/Mars/mmontecarlo/MMcTriggerRateCalc.cc

    r984 r988  
    4343    *fTitle = title ? title : "Task to calc the trigger rate ";
    4444
     45    fMcTrig = NULL;
     46    fMcRate = NULL;
     47
    4548    fDimension = dim;
    4649
     
    9194}
    9295
     96MMcTriggerRateCalc::~MMcTriggerRateCalc()
     97{
     98    if (fMcTrig)
     99        delete fMcTrig;
     100
     101    if (fMcRate)
     102        delete fMcRate;
     103}
     104
    93105
    94106// --------------------------------------------------------------------------
  • trunk/MagicSoft/Mars/mmontecarlo/MMcTriggerRateCalc.h

    r984 r988  
    5050                       const char *name=NULL, const char *title=NULL);
    5151
     52    ~MMcTriggerRateCalc();
     53
    5254    Bool_t PreProcess(MParList *pList);
    5355    Bool_t Process();
  • trunk/MagicSoft/Mars/mraw/MRawCrateData.h

    r654 r988  
    4040    }
    4141
    42     void Print(Option_t *t=NULL);
     42    void Print(Option_t *t=NULL) const;
    4343
    4444    void ReadEvt(istream& fin);
  • trunk/MagicSoft/Mars/mraw/MRawEvtHeader.cc

    r859 r988  
    178178//  This member function prints all Data of one Event to *fLog.
    179179//
    180 void MRawEvtHeader::Print(Option_t *o)
     180void MRawEvtHeader::Print(Option_t *o) const
    181181{
    182182    *fLog << "DAQEvtNr: " << dec << fDAQEvtNumber << "  (";
  • trunk/MagicSoft/Mars/mraw/MRawEvtHeader.h

    r766 r988  
    4949
    5050    void Clear(Option_t * = NULL);
    51     void Print(Option_t * = NULL);
     51    void Print(Option_t * = NULL) const;
    5252
    5353    void FillHeader(UInt_t, Float_t=0);
  • trunk/MagicSoft/Mars/mraw/MRawRunHeader.cc

    r967 r988  
    123123// print run header information on *fLog
    124124//
    125 void MRawRunHeader::Print(Option_t *t)
     125void MRawRunHeader::Print(Option_t *t) const
    126126{
    127127    *fLog << endl;
  • trunk/MagicSoft/Mars/mraw/MRawRunHeader.h

    r782 r988  
    8888    UShort_t GetNumPixel() const;
    8989
    90     void Print(Option_t *t=NULL);
     90    void Print(Option_t *t=NULL) const;
    9191
    9292    void ReadEvt(istream& fin);
Note: See TracChangeset for help on using the changeset viewer.