Changeset 4833


Ignore:
Timestamp:
09/02/04 15:18:09 (20 years ago)
Author:
tbretz
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/manalysis/MEventRateCalc.cc

    r2917 r4833  
    4747//
    4848//
     49//  In addition the difference between the event time of the current event
     50//  and the last event is written into a MParameterD calles MTimeDiff.
     51//
     52//
    4953//  Input Containers:
    5054//    MTime
     
    5256//  Output Containers:
    5357//    MEventRate
     58//    MTimeDiff [MParameterD]
    5459//    MTimeRate [MTime] (missing)
    5560//
     
    6267#include "MEventRateCalc.h"
    6368
    64 #include "MParList.h"
     69#include <fstream>
    6570
    6671#include "MLog.h"
    6772#include "MLogManip.h"
    6873
     74#include "MParList.h"
     75
    6976#include "MTime.h"
    7077#include "MEventRate.h"
     78#include "MParameters.h"
    7179
    7280ClassImp(MEventRateCalc);
     
    7482using namespace std;
    7583
     84const TString MEventRateCalc::gsDefName  = "MEventRateCalc";
     85const TString MEventRateCalc::gsDefTitle = "Calculate event rate";
     86
     87const TString MEventRateCalc::gsNameTime      = "MTime";
     88const TString MEventRateCalc::gsNameEventRate = "MEventRate";
     89const TString MEventRateCalc::gsNameTimeDiff  = "MTimeDiff";
     90
     91const Int_t MEventRateCalc::gsNumEvents = 1000;
     92
    7693// --------------------------------------------------------------------------
    7794//
     
    7996//
    8097MEventRateCalc::MEventRateCalc(const char *name, const char *title)
    81     : fTimes(1000)
    82 {
    83     fName  = name  ? name  : "MEventRateCalc";
    84     fTitle = title ? title : "Calculate trigger rate";
     98    : fNameTime(gsNameTime), fNameEventRate(gsNameEventRate),
     99    fNameTimeDiff(gsNameTimeDiff), fTimes(gsNumEvents)
     100{
     101    fName  = name  ? name  : gsDefName.Data();
     102    fTitle = title ? title : gsDefTitle.Data();
    85103}
    86104
     
    97115Int_t MEventRateCalc::PreProcess(MParList *pList)
    98116{
    99     fTime = (MTime*)pList->FindObject("MTime");
     117    fTime = (MTime*)pList->FindObject(AddSerialNumber(fNameTime), "MTime");
    100118    if (!fTime)
    101119    {
     
    104122    }
    105123
    106     fRate = (MEventRate*)pList->FindCreateObj("MEventRate");
     124    fRate = (MEventRate*)pList->FindCreateObj("MEventRate", AddSerialNumber(fNameEventRate));
    107125    if (!fRate)
     126        return kFALSE;
     127
     128    fTimeDiff = (MParameterD*)pList->FindCreateObj("MParameterD", AddSerialNumber(fNameTimeDiff));
     129    if (!fTimeDiff)
    108130        return kFALSE;
    109131
     
    137159    fRate->SetReadyToSave();
    138160
     161    fTimeDiff->SetVal(exec==0 ? -1 : fTimes[n1%n] - fTimes[(n1+n-1)%n]);
     162    fTimeDiff->SetReadyToSave();
     163
    139164    return kTRUE;
    140165}
     166
     167// --------------------------------------------------------------------------
     168//
     169// Implementation of SavePrimitive. Used to write the call to a constructor
     170// to a macro. In the original root implementation it is used to write
     171// gui elements to a macro-file.
     172//
     173void MEventRateCalc::StreamPrimitive(ofstream &out) const
     174{
     175    out << "   MEventRateCalc " << GetUniqueName() << "(";
     176    if (fName!=gsDefName || fTitle!=gsDefTitle)
     177    {
     178        out << "\"" <<fName << "\"";
     179        if (fTitle!=gsDefTitle)
     180            out << ", \"" << fTitle << "\"";
     181    }
     182    out << ");" << endl;
     183
     184    if (fTimes.GetSize()!=gsNumEvents)
     185        out << "   " << GetUniqueName() << ".SetNumEvents(" << fTimes.GetSize() << ");" << endl;
     186}
     187
     188// --------------------------------------------------------------------------
     189//
     190// Read the setup from a TEnv, eg:
     191//   MEventRateCalc.NumEvents: 1000
     192//
     193Int_t MEventRateCalc::ReadEnv(const TEnv &env, TString prefix, Bool_t print)
     194{
     195    Bool_t rc = kFALSE;
     196    if (IsEnvDefined(env, prefix, "NumEvents", print))
     197    {
     198        rc = kTRUE;
     199        SetNumEvents(GetEnvValue(env, prefix, "NumEvents", fTimes.GetSize()));
     200    }
     201
     202    return rc;
     203}
  • trunk/MagicSoft/Mars/manalysis/MEventRateCalc.h

    r2626 r4833  
    55#include "MTask.h"
    66#endif
    7 #ifndef MARS_MTime
    8 #include "MTime.h"
    9 #endif
    107#ifndef ROOT_TArrayD
    118#include <TArrayD.h>
    129#endif
    1310
     11class MTime;
    1412class MEventRate;
     13class MParameterD;
    1514
    1615class MEventRateCalc : public MTask
    1716{
    18     MTime      *fTime;  //!
    19     MEventRate *fRate;  //!
     17private:
     18    static const TString gsDefName;       //! Default name of container
     19    static const TString gsDefTitle;      //! Default title of container
    2020
    21     //ULong_t fEvtNumber; //!
    22     //MTime   fEvtTime;   //!
     21    static const TString gsNameTime;      //! Default name of time container
     22    static const TString gsNameEventRate; //! default name of rate container
     23    static const TString gsNameTimeDiff;  //! default name of time-diff container
    2324
    24     //UInt_t  fNumEvents;
     25    static const Int_t gsNumEvents;       //! Default number of events
    2526
    26     TArrayD fTimes;     //!
    2727
     28    MTime       *fTime;       //! pointer to event time
     29    MEventRate  *fRate;       //! pointer to rate storage container
     30    MParameterD *fTimeDiff;   //! Difference of time between two consecutive events
     31
     32    TString fNameTime;       // name of time container
     33    TString fNameEventRate;  // name of event rate container
     34    TString fNameTimeDiff;   // name of time-diff container
     35
     36    TArrayD  fTimes;         //! internal array to store the last n event times
    2837
    2938
     
    3140    Int_t Process();
    3241
     42    void  StreamPrimitive(ofstream &out) const;
     43    Int_t ReadEnv(const TEnv &env, TString prefix, Bool_t print);
     44
    3345public:
    3446    MEventRateCalc(const char *name=NULL, const char *title=NULL);
    3547
    36     void SetNumEvents(ULong_t num) { /*fNumEvents = num;*/ fTimes.Set(num); }
     48    void SetNumEvents(ULong_t num) { fTimes.Set(num); }
    3749
    38     ClassDef(MEventRateCalc, 0)// Task to calculate event rates
     50    void SetNameTime(const char *name)      { fNameTime = name; }
     51    void SetNameEventRate(const char *name) { fNameEventRate = name; }
     52    void SetNameTimeDiff(const char *name)  { fNameTimeDiff = name; }
     53
     54    ClassDef(MEventRateCalc, 1)// Task to calculate event rates
    3955};
    4056 
  • trunk/MagicSoft/Mars/mbase/MContinue.cc

    r3583 r4833  
    120120    }
    121121
    122     fTaskList = (MTaskList*)list->FindObject("MTaskList");
     122    fTaskList = (MTaskList*)list->FindTaskListWithTask(this);
    123123    if (!fTaskList)
    124124    {
    125         *fLog << err << dbginf << "ERROR - Tasklist 'MTaskList' not found... abort." << endl;
     125        *fLog << err << dbginf << "ERROR - MTasklist not found... abort." << endl;
    126126        return kFALSE;
    127127    }
  • trunk/MagicSoft/Mars/mimage/MHNewImagePar.cc

    r3682 r4833  
    200200}
    201201
     202void MHNewImagePar::Paint(Option_t *)
     203{
     204    TVirtualPad *savepad = gPad;
     205    if (fHistLeakage1.GetEntries()>0 && fHistLeakage2.GetEntries()>0)
     206    {
     207        fHistLeakage1.SetMinimum(-1111);
     208        fHistLeakage2.SetMinimum(-1111);
     209        gPad->cd(1);
     210        gPad->SetLogy();
     211    }
     212    gPad = savepad;
     213}
     214
    202215// --------------------------------------------------------------------------
    203216//
  • trunk/MagicSoft/Mars/mimage/MHNewImagePar.h

    r3682 r4833  
    4646    TH1F &GetHistConc1()     { return fHistConc1; }
    4747
    48     void Draw(Option_t *opt=NULL);
     48    void Draw(Option_t *opt="");
     49    void Paint(Option_t *opt="");
    4950
    5051    ClassDef(MHNewImagePar, 1) // Histograms of new image parameters
Note: See TracChangeset for help on using the changeset viewer.