Changeset 4887


Ignore:
Timestamp:
09/07/04 18:31:53 (20 years ago)
Author:
tbretz
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars
Files:
2 added
13 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/Changelog

    r4885 r4887  
    4444       and maybe to secure everything from compiler bugs a bit more
    4545
     46   * callisto.cc, star.cc:
     47     - do not allow implicit batch-mode
     48
     49   * showlog.cc:
     50     - removed an unused variable
     51
     52   * manalysis/MEventRateCalc.[h,cc]:
     53     - started implementing a corrsponding time
     54
     55   * manalysis/MParameters.[h,cc], manalysis/AnalysisLinkDef.h:
     56     - added MParameterDerr
     57
     58   * mbadpixels/MHBadPixels.[h,cc]:
     59     - removed obsolete fPedPhotCam
     60
     61   * mbase/MTime.[h,cc]:
     62     - added AddMilliSeconds
     63     - added SetMean
     64
     65
    4666
    4767
     
    6888     - included functions AddCamContent(MArrayD...) and
    6989       SetCamContent(MArrayD... )
     90
    7091
    7192
  • trunk/MagicSoft/Mars/callisto.cc

    r4800 r4887  
    262262
    263263    TApplication app("Callisto", &argc, argv);
    264     if (!gROOT->IsBatch() && !gClient)
     264    if (!gROOT->IsBatch() && !gClient || gROOT->IsBatch() && !kBatch)
    265265    {
    266266        gLog << err << "Bombing... maybe your DISPLAY variable is not set correctly!" << endl;
  • trunk/MagicSoft/Mars/manalysis/AnalysisLinkDef.h

    r4841 r4887  
    4040#pragma link C++ class MParameterI+;
    4141#pragma link C++ class MParameterD+;
     42#pragma link C++ class MParameterDerr+;
    4243//#pragma link C++ class MParameters+;
    4344
  • trunk/MagicSoft/Mars/manalysis/MEventRateCalc.cc

    r4833 r4887  
    8888const TString MEventRateCalc::gsNameEventRate = "MEventRate";
    8989const TString MEventRateCalc::gsNameTimeDiff  = "MTimeDiff";
     90const TString MEventRateCalc::gsNameTimeRate  = "MTimeRate";
    9091
    9192const Int_t MEventRateCalc::gsNumEvents = 1000;
     
    9697//
    9798MEventRateCalc::MEventRateCalc(const char *name, const char *title)
    98     : fNameTime(gsNameTime), fNameEventRate(gsNameEventRate),
    99     fNameTimeDiff(gsNameTimeDiff), fTimes(gsNumEvents)
     99    : fNameEventRate(gsNameEventRate), fNameTime(gsNameTime),
     100    fNameTimeRate(gsNameTimeRate), fNameTimeDiff(gsNameTimeDiff),
     101    fTimes(gsNumEvents)
    100102{
    101103    fName  = name  ? name  : gsDefName.Data();
     
    118120    if (!fTime)
    119121    {
    120         *fLog << err << "MTime not found... aborting." << endl;
     122        *fLog << err << AddSerialNumber(fNameTime) << " [MTime] not found... aborting." << endl;
    121123        return kFALSE;
    122124    }
     
    124126    fRate = (MEventRate*)pList->FindCreateObj("MEventRate", AddSerialNumber(fNameEventRate));
    125127    if (!fRate)
     128        return kFALSE;
     129
     130    fTimeRate = (MTime*)pList->FindCreateObj("MTime", AddSerialNumber(fNameTimeRate));
     131    if (!fTimeRate)
    126132        return kFALSE;
    127133
     
    145151    const ULong_t exec = GetNumExecutions()-1;
    146152
     153    // Calculate the rate
    147154    const UInt_t n = fTimes.GetSize();
    148155
     156    // Get the positon in the ring-buffer
    149157    const UInt_t n1 = exec;
    150158    const UInt_t n2 = exec>=n ? exec+1 : 0;
    151159
     160    // Store the current event time
    152161    fTimes[n1%n] = *fTime;
    153162
     163    // Get the number of events
    154164    const UInt_t cnt = n1<n2 ? n : n1-n2;
    155165
     166    // Calculate the rate
    156167    const Double_t rate = (Double_t)cnt/(fTimes[n1%n]-fTimes[n2%n]);
    157168
     169    // Store the time difference between two consecutive events
     170    fTimeDiff->SetVal(exec==0 ? -1 : fTimes[n1%n] - fTimes[(n1+n-1)%n]);
     171    fTimeDiff->SetReadyToSave();
     172
     173    // Store the rate
    158174    fRate->SetRate(exec>1?rate:0, cnt);
    159175    fRate->SetReadyToSave();
    160176
    161     fTimeDiff->SetVal(exec==0 ? -1 : fTimes[n1%n] - fTimes[(n1+n-1)%n]);
    162     fTimeDiff->SetReadyToSave();
     177    // Store the corresponding time
     178    fTimeRate->SetMean(fTimes[n1%n], fTimes[n2%n]);
    163179
    164180    return kTRUE;
  • trunk/MagicSoft/Mars/manalysis/MEventRateCalc.h

    r4833 r4887  
    1919    static const TString gsDefTitle;      //! Default title of container
    2020
     21    static const TString gsNameEventRate; //! default name of rate container
    2122    static const TString gsNameTime;      //! Default name of time container
    22     static const TString gsNameEventRate; //! default name of rate container
    2323    static const TString gsNameTimeDiff;  //! default name of time-diff container
     24    static const TString gsNameTimeRate;  //! default name of time-rate container
    2425
    2526    static const Int_t gsNumEvents;       //! Default number of events
     
    2728
    2829    MTime       *fTime;       //! pointer to event time
     30    MTime       *fTimeRate;   //! pointer to time of event rate
    2931    MEventRate  *fRate;       //! pointer to rate storage container
    3032    MParameterD *fTimeDiff;   //! Difference of time between two consecutive events
    3133
     34    TString fNameEventRate;  // name of event rate container
    3235    TString fNameTime;       // name of time container
    33     TString fNameEventRate;  // name of event rate container
     36    TString fNameTimeRate;   // name of event rate time container
    3437    TString fNameTimeDiff;   // name of time-diff container
    3538
    3639    TArrayD  fTimes;         //! internal array to store the last n event times
    37 
    3840
    3941    Int_t PreProcess(MParList *pList);
     
    4850    void SetNumEvents(ULong_t num) { fTimes.Set(num); }
    4951
     52    void SetNameEventRate(const char *name) { fNameEventRate = name; }
    5053    void SetNameTime(const char *name)      { fNameTime = name; }
    51     void SetNameEventRate(const char *name) { fNameEventRate = name; }
    5254    void SetNameTimeDiff(const char *name)  { fNameTimeDiff = name; }
     55    void SetNameTimeRate(const char *name)  { fNameTimeRate = name; }
    5356
    5457    ClassDef(MEventRateCalc, 1)// Task to calculate event rates
  • trunk/MagicSoft/Mars/manalysis/MParameters.cc

    r2173 r4887  
    1818!   Author(s): Thomas Bretz 03/2003 <mailto:tbretz@astro.uni-wuerzburg.de>
    1919!
    20 !   Copyright: MAGIC Software Development, 2000-2003
     20!   Copyright: MAGIC Software Development, 2000-2004
    2121!
    2222!
     
    4242ClassImp(MParameterD);
    4343ClassImp(MParameterI);
     44ClassImp(MParameterDerr);
    4445//ClassImp(MParameter);
    4546
     
    6061// Default constructor.
    6162//
     63MParameterDerr::MParameterDerr(const char *name, const char *title)
     64{
     65    fName  = name  ? name  : "MParameterDerr";
     66    fTitle = title ? title : "Storgare container for general parameters (double) and its error";
     67}
     68
     69// --------------------------------------------------------------------------
     70//
     71// Default constructor.
     72//
    6273MParameterI::MParameterI(const char *name, const char *title)
    6374{
  • trunk/MagicSoft/Mars/manalysis/MParameters.h

    r1951 r4887  
    1818
    1919    ClassDef(MParameterD, 1) // Container to hold a generalized parameters (double)
     20};
     21
     22class MParameterDerr : public MParContainer
     23{
     24private:
     25    Double_t fVal;
     26    Double_t fErr;
     27
     28public:
     29    MParameterDerr(const char *name=NULL, const char *title=NULL);
     30
     31    void SetVal(Double_t v, Double_t e) { fVal = v; fErr = e; }
     32    Double_t GetVal() const { return fVal; }
     33    Double_t GetErr() const { return fErr; }
     34
     35    ClassDef(MParameterDerr, 1) // Container to hold a generalized parameters (double) and its Error
    2036};
    2137
  • trunk/MagicSoft/Mars/mbadpixels/MHBadPixels.cc

    r4874 r4887  
    3535#include "MBadPixelsCam.h"
    3636#include "MGeomCam.h"
    37 #include "MPedPhotCam.h"
    3837#include "MParList.h"
    3938#include "MBinning.h"
     
    5150//
    5251MHBadPixels::MHBadPixels(const char *name, const char *title)
     52    : fNamePedPhotCam("MPedPhotCam")
    5353{
    5454    fName  = name  ? name  : "MHBadPixels";
     
    6767    fBadN.SetYTitle("number of bad pixels");
    6868
    69     fNamePedPhotCam = "MPedPhotCamFromData";
    7069}
    7170
     
    7978    if (!fCam)   
    8079    {
    81         *fLog << err << "MHBadPixels::SetupFill; MGeomCam not found... aborting." << endl;
     80        *fLog << err << "MGeomCam not found... aborting." << endl;
    8281        return kFALSE;
    8382    }
    84     *fLog << "MHBadPixels::SetupFill; fCam = " << fCam << endl;
    85 
    8683    fPointPos = (MPointingPos*)plist->FindObject("MPointingPos");
    8784    if (!fPointPos)
     
    9188    }
    9289
    93    
    94     fPedPhot = (MPedPhotCam*)plist->FindObject(AddSerialNumber(fNamePedPhotCam), "MPedPhotCam");
    95     if (!fPedPhot)
    96     {
    97         *fLog << err << AddSerialNumber(fNamePedPhotCam)
    98               << "[MPedPhotCam] not found... aborting." << endl;
    99         return kFALSE;
    100     }
    101     fPedPhot->InitSize(fCam->GetNumPixels());
    102 
    10390    //----------------------------------------------------
    10491    // Get Theta Binning
     
    10693    if (!binstheta)
    10794    {
    108         *fLog << err << "Object 'BinningTheta' [MBinning] not found... aborting" << endl;
     95        *fLog << err << "BinningTheta [MBinning] not found... aborting" << endl;
    10996        return kFALSE;
    11097    }
    11198
    11299    // Get binning for pixel number
    113     const UInt_t npix1 = fPedPhot->GetSize()+1;
    114 
    115     *fLog << "MHBadPixels::SetupFill; npix1 = " << npix1 << endl;
     100    const UInt_t npix1 = fCam->GetNumPixels()+1;
    116101
    117102    MBinning binspix("BinningPixel");
     
    121106    SetBinning(&fBadId, binstheta, &binspix);
    122107    SetBinning(&fBadN,  binstheta, &binspix);
    123 
    124     //----------------------------------------------------
    125     *fLog << inf << "Name of MPedPhotCam container : " << fNamePedPhotCam
    126           << endl;
    127108
    128109    return kTRUE;
     
    141122    Double_t theta = fPointPos->GetZd();
    142123
    143     const MBadPixelsCam *fBadPixels = (MBadPixelsCam*)par;
     124    const MBadPixelsCam *badpixels = (MBadPixelsCam*)par;
    144125
    145     const UInt_t entries = fPedPhot->GetSize();
     126    const UInt_t entries = badpixels->GetSize();
     127
    146128    UInt_t nb = 0;
    147129    for (UInt_t i=0; i<entries; i++)
    148130    {
    149       //*fLog << "MHBadPixels::Fill; i = " << i << endl;
    150 
    151       if ( (*fBadPixels)[i].IsUnsuitable() )
    152       {
    153         //*fLog << "MHBadPixels::Fill; (UnSuitable) " << endl;
    154 
    155           fBadId.Fill(theta, i, w);
    156           nb++;
    157       }   
     131        if ( (*badpixels)[i].IsUnsuitable() )
     132        {
     133            fBadId.Fill(theta, i, w);
     134            nb++;
     135        }
    158136    }
    159137    fBadN.Fill(theta, nb, w);
     
    204182    pad->Update();
    205183}
    206 //==========================================================================
    207 
    208 
    209 
    210 
    211 
    212 
    213 
    214 
    215 
    216 
    217 
  • trunk/MagicSoft/Mars/mbadpixels/MHBadPixels.h

    r4841 r4887  
    1818private:
    1919    MGeomCam      *fCam;      //!
    20     MPedPhotCam   *fPedPhot;  //!
    2120    MPointingPos  *fPointPos; //!
    2221
     
    3736    const TH2D *GetBadN() const { return &fBadN; }
    3837
    39     TH2 *GetBadIdByName(const TString name) { return &fBadId; }
    40     TH2 *GetBadNByName(const TString name) { return &fBadN; }
    41 
    4238    void Draw(Option_t* option = "");
    4339    Bool_t SetupFill(const MParList *plist);
  • trunk/MagicSoft/Mars/mbase/MTime.cc

    r4732 r4887  
    563563    return fin;
    564564}
     565
     566void MTime::AddMilliSeconds(UInt_t ms)
     567{
     568    fTime += ms;
     569
     570    fTime += 11*kHour;
     571    fMjd  += (Long_t)fTime/kDay;
     572    fTime  = (Long_t)fTime%kDay;
     573    fTime -= 11*kHour;
     574}
     575/*
     576MTime MTime::operator-(const MTime &tm1)
     577{
     578    const MTime &tm0 = *this;
     579
     580    MTime t0 = tm0>tm1 ? tm0 : tm1;
     581    const MTime &t1 = tm0>tm1 ? tm1 : tm0;
     582
     583    if (t0.fNanoSec<t1.fNanoSec)
     584    {
     585        t0.fNanoSec += 1000000;
     586        t0.fTime -= 1;
     587    }
     588
     589    t0.fNanoSec -= t1.fNanoSec;
     590    t0.fTime    -= t1.fTime;
     591
     592    if ((Long_t)t0.fTime<-(Long_t)kHour*11)
     593    {
     594        t0.fTime += kDay;
     595        t0.fMjd--;
     596    }
     597
     598    t0.fMjd -= t1.fMjd;
     599
     600    return t0;
     601}
     602
     603void MTime::operator-=(const MTime &t)
     604{
     605    *this = *this-t;
     606}
     607
     608MTime MTime::operator+(const MTime &t1)
     609{
     610    MTime t0 = *this;
     611
     612    t0.fNanoSec += t1.fNanoSec;
     613
     614    if (t0.fNanoSec>999999)
     615    {
     616        t0.fNanoSec -= 1000000;
     617        t0.fTime += kDay;
     618    }
     619
     620    t0.fTime += t1.fTime;
     621
     622    if ((Long_t)t0.fTime>=(Long_t)kHour*13)
     623    {
     624        t0.fTime -= kDay;
     625        t0.fMjd++;
     626    }
     627
     628    t0.fMjd += t1.fMjd;
     629
     630    return t0;
     631}
     632
     633void MTime::operator+=(const MTime &t)
     634{
     635    *this = *this+t;
     636}
     637*/
     638
     639void MTime::SetMean(const MTime &t0, const MTime &t1)
     640{
     641    // This could be an operator+
     642    *this = t0;
     643
     644    fNanoSec += t1.fNanoSec;
     645
     646    if (fNanoSec>999999)
     647    {
     648        fNanoSec -= 1000000;
     649        fTime += kDay;
     650    }
     651
     652    fTime += t1.fTime;
     653
     654    if ((Long_t)fTime>=(Long_t)kHour*13)
     655    {
     656        fTime -= kDay;
     657        fMjd++;
     658    }
     659
     660    fMjd += t1.fMjd;
     661
     662    // This could be an operator/
     663    if ((Long_t)fTime<0)
     664    {
     665        fTime += kDay;
     666        fMjd--;
     667    }
     668
     669    Int_t reminder = fMjd%2;
     670    fMjd /= 2;
     671
     672    fTime += reminder*kDay;
     673    reminder = (Long_t)fTime%2;
     674    fTime /= 2;
     675
     676    fNanoSec += reminder*1000000;
     677    fNanoSec /= 2;
     678
     679    fTime += 11*kHour;
     680    fMjd  += (Long_t)fTime/kDay;
     681    fTime  = (Long_t)fTime%kDay;
     682    fTime -= 11*kHour;
     683}
     684
     685void MTime::SetMean(Double_t t0, Double_t t1)
     686{
     687    const Double_t mean = (t0+t1)*(500./kDay);
     688    SetMjd(mean);
     689}
  • trunk/MagicSoft/Mars/mbase/MTime.h

    r4627 r4887  
    3535    UInt_t fNanoSec; // [ns] NanoSec part of TimeOfDay (<1000000)
    3636
     37
    3738    ULong_t GetTime24() const
    3839    {
     
    7576    void Now();
    7677
     78    // Setter functions
    7779    Bool_t   Set(UShort_t y, Byte_t m, Byte_t d, Byte_t h=13, Byte_t min=0, Byte_t s=0, UShort_t ms=0, UInt_t ns=0);
    7880    void     Set(const struct timeval &tv);
     
    8587    Bool_t   SetMjd(UInt_t mjd, ULong_t ms, UInt_t ns=0);
    8688    void     SetMjd(Double_t m);
     89
     90    // Getter functions
    8791    Double_t GetMjd() const;
    8892    Double_t GetGmst() const;
     
    111115    UInt_t Sec() const   { Byte_t h, m, s; GetTime(h,m,s); return s; }
    112116
     117    // I/O functions
    113118    istream &ReadBinary(istream &fin);
    114119
    115     operator double() const   //[s]
    116     {
    117         return ((Double_t)fMjd*kDay+(Long_t)fTime+fNanoSec/1e6)/1000;
    118     }
    119     double operator()() const //[s]
    120     {
    121         return operator double();
    122     }
    123 
    124     bool operator<(const MTime &t) const
    125     {
    126         if (fMjd<t.fMjd)
    127             return true;
    128         if (fMjd==t.fMjd && fTime<t.fTime)
    129             return true;
    130         if (fMjd==t.fMjd && fTime==t.fTime && fNanoSec<t.fNanoSec)
    131             return true;
    132         return false;
    133     }
    134     bool operator>(const MTime &t) const
    135     {
    136         if (fMjd>t.fMjd)
    137             return true;
    138         if (fMjd==t.fMjd && fTime>t.fTime)
    139             return true;
    140         if (fMjd==t.fMjd && fTime==t.fTime && fNanoSec>t.fNanoSec)
    141             return true;
    142         return false;
    143     }
    144 
    145     bool operator<=(const MTime &t) const
    146     {
    147         return !operator>(t);
    148     }
    149 
    150     bool operator>=(const MTime &t) const
    151     {
    152         return !operator<(t);
    153     }
    154 
    155     bool operator==(const MTime &t) const
    156     {
    157         return fNanoSec==t.fNanoSec && fTime==t.fTime && fMjd==t.fMjd;
    158     }
    159 
    160     bool operator!=(const MTime &t) const
    161     {
    162         return fNanoSec!=t.fNanoSec || fTime!=t.fTime || fMjd!=t.fMjd;
    163     }
    164 
    165     bool operator!() const
    166     {
    167         return fNanoSec==0 && (ULong_t)fTime==0 && fMjd==0;
    168     }
     120    // Conversion functions
     121    operator double() const;   //[s]
     122    double operator()() const; //[s]
     123
     124    // Calculation functions
     125    void AddMilliSeconds(UInt_t ms);
     126    void SetMean(const MTime &t0, const MTime &t1);
     127    void SetMean(Double_t t0, Double_t t1);
     128    /*
     129     MTime operator-(const MTime &tm1);
     130     void operator-=(const MTime &t);
     131     MTime operator+(const MTime &t1);
     132     void operator+=(const MTime &t);
     133     */
     134
     135    // Base comparison operators
     136    bool operator<(const MTime &t) const;
     137    bool operator>(const MTime &t) const;
     138
     139    // Derived comparison operators
     140    bool operator<=(const MTime &t) const;
     141    bool operator>=(const MTime &t) const;
     142    bool operator==(const MTime &t) const;
     143    bool operator!=(const MTime &t) const;
     144    bool operator!() const;
    169145
    170146    ClassDef(MTime, 3)  //A generalized MARS time stamp
     
    186162}
    187163
    188 #endif
     164inline MTime::operator double() const   //[s]
     165{
     166    return ((Double_t)fMjd*kDay+(Long_t)fTime+fNanoSec/1e6)/1000;
     167}
     168
     169inline double MTime::operator()() const //[s]
     170{
     171    return operator double();
     172}
     173
     174inline bool MTime::operator<(const MTime &t) const
     175{
     176    if (fMjd<t.fMjd)
     177        return true;
     178    if (fMjd==t.fMjd && fTime<t.fTime)
     179        return true;
     180    if (fMjd==t.fMjd && fTime==t.fTime && fNanoSec<t.fNanoSec)
     181        return true;
     182    return false;
     183}
     184
     185inline bool MTime::operator>(const MTime &t) const
     186{
     187    if (fMjd>t.fMjd)
     188        return true;
     189    if (fMjd==t.fMjd && fTime>t.fTime)
     190        return true;
     191    if (fMjd==t.fMjd && fTime==t.fTime && fNanoSec>t.fNanoSec)
     192        return true;
     193    return false;
     194}
     195
     196inline bool MTime::operator<=(const MTime &t) const
     197{
     198    return !operator>(t);
     199}
     200
     201inline bool MTime::operator>=(const MTime &t) const
     202{
     203    return !operator<(t);
     204}
     205
     206inline bool MTime::operator==(const MTime &t) const
     207{
     208    return fNanoSec==t.fNanoSec && fTime==t.fTime && fMjd==t.fMjd;
     209}
     210
     211inline bool MTime::operator!=(const MTime &t) const
     212{
     213    return fNanoSec!=t.fNanoSec || fTime!=t.fTime || fMjd!=t.fMjd;
     214}
     215
     216inline bool MTime::operator!() const
     217{
     218    return fNanoSec==0 && (ULong_t)fTime==0 && fMjd==0;
     219}
     220
     221#endif
  • trunk/MagicSoft/Mars/showlog.cc

    r4800 r4887  
    3232{
    3333    static const TRegexp regexp("[][[][0-9]+[m]");
    34 
    35     int i=0;
    3634
    3735    while (1)
  • trunk/MagicSoft/Mars/star.cc

    r4828 r4887  
    182182
    183183    TApplication app("Star", &argc, argv);
    184     if (!gROOT->IsBatch() && !gClient)
     184    if (!gROOT->IsBatch() && !gClient || gROOT->IsBatch() && !kBatch)
    185185    {
    186186        gLog << err << "Bombing... maybe your DISPLAY variable is not set correctly!" << endl;
Note: See TracChangeset for help on using the changeset viewer.