Ignore:
Timestamp:
05/09/07 13:15:53 (18 years ago)
Author:
tbretz
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars/mhvstime
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/mhvstime/MHVsTime.cc

    r8082 r8478  
    1818!   Author(s): Thomas Bretz, 11/2003 <mailto:tbretz@astro.uni-wuerzburg.de>
    1919!
    20 !   Copyright: MAGIC Software Development, 2000-2004
     20!   Copyright: MAGIC Software Development, 2000-2007
    2121!
    2222!
     
    5858//  - MDataChain *fError;     // Object from which the error is filled
    5959//
     60// Class Version 3:
     61// ----------------
     62//  + Double_t fMinimum;      // User defined minimum
     63//  + Double_t fMaximum;      // User defined maximum
     64//
    6065/////////////////////////////////////////////////////////////////////////////
    6166#include "MHVsTime.h"
     
    9297MHVsTime::MHVsTime(const char *rule, const char *error)
    9398    : fGraph(NULL), fData(NULL), fError(NULL), fScale(1), fMaxPts(-1),
    94     fNumEvents(1), fUseEventNumber(0)
     99    fNumEvents(1), fMinimum(-1111), fMaximum(-1111), fUseEventNumber(0)
    95100{
    96101    fName  = gsDefName;
     
    129134// --------------------------------------------------------------------------
    130135//
    131 // Call SetMinimum of fGraph
    132 //
    133 void MHVsTime::SetMinimum(Double_t min)
    134 {
    135     if (fGraph)
    136         fGraph->SetMinimum(min);
    137 }
    138 
    139 // --------------------------------------------------------------------------
    140 //
    141136// Return the data members used by the data chain to be used in
    142137// MTask::AddBranchToList
     
    178173    fMean = 0;
    179174    fN    = 0;
     175
     176    fMin =  FLT_MAX;
     177    fMax = -FLT_MAX;
    180178
    181179    return kTRUE;
     
    252250        }
    253251
    254         fGraph->SetPoint(fGraph->GetN(), t, fMean/fN*fScale);
     252        const Double_t val = fMean/fN*fScale;
     253
     254        fGraph->SetPoint(fGraph->GetN(), t, val);
    255255
    256256        if (fError)
    257257            static_cast<TGraphErrors*>(fGraph)->SetPointError(fGraph->GetN()-1, 0, fMeanErr/fN*fScale);
     258
     259        fMin = TMath::Min(fMin, val);
     260        fMax = TMath::Max(fMax, val);
    258261
    259262        fMean = 0;
     
    265268}
    266269
     270// --------------------------------------------------------------------------
     271//
     272// Set Minimum and Maximum;
     273Bool_t MHVsTime::Finalize()
     274{
     275    const Double_t add = (fMax-fMin)*0.15;
     276
     277    if (fMinimum==-1111)
     278        fGraph->SetMinimum(fMin-add);
     279    if (fMaximum==-1111)
     280        fGraph->SetMaximum(fMax+add);
     281
     282    return kTRUE;
     283}
     284
    267285void MHVsTime::Paint(Option_t *opt)
    268286{
    269     /*
    270      *fLog << all << fGraph << " " << gPad->GetName() << " ----> Paint " << opt << endl;
    271      TListIter Next(gPad->GetListOfPrimitives()); TObject *obj;
    272      while ((obj=Next())) *fLog << obj << " " << obj->GetName() << " " << obj->ClassName() << " " << Next.GetOption() << endl;
    273      */
    274287    if (!fGraph)
    275288        return;
    276 
    277 //    *fLog << all << fGraph->GetN() << " " << opt << endl;
    278289
    279290    if (fGraph->GetN()==0)
     
    318329        gPad->SetLogy();
    319330
     331    // If this is set to early the plot remains empty in root 5.12/00
     332    if (fMinimum!=-1111)
     333        fGraph->SetMinimum(fMinimum);
     334    if (fMaximum!=-1111)
     335        fGraph->SetMaximum(fMaximum);
     336
     337
    320338    // This is a workaround if the TGraph has only one point.
    321339    // Otherwise MStatusDisplay::Update hangs.
    322 //    gPad->GetListOfPrimitives()->Remove(fGraph);
    323 //    fGraph->Draw(fGraph->GetN()<2 ? "A" : str.Data());
    324     //gPad->GetListOfPrimitives()->Add(fGraph, fGraph->GetN()<2 ? "A" : opt);
    325     //    AppendPad(str);
    326     //    fGraph->Draw(str);
    327 
     340    gPad->GetListOfPrimitives()->Remove(fGraph);
     341    fGraph->Draw(fGraph->GetN()<2 ? "A" : str.Data());
    328342}
    329343
     
    339353    pad->SetBorderMode(0);
    340354    AppendPad(opt);
    341 
    342     fGraph->Draw("A");
    343355}
    344356
  • trunk/MagicSoft/Mars/mhvstime/MHVsTime.h

    r8082 r8478  
    3434    MTime       fLast;      //! For checks
    3535
     36    Double_t fMinimum;      // User defined minimum
     37    Double_t fMaximum;      // User defined maximum
     38
     39    Double_t fMin;          //! Calculation of minimum
     40    Double_t fMax;          //! Calculation of maximum
     41
    3642    enum {
    3743        kIsLogy = BIT(18)
     
    4046    Bool_t fUseEventNumber;
    4147
     48    Bool_t Finalize();
     49
    4250public:
    4351    MHVsTime(const char *rule=NULL, const char *ruleerr=NULL);
     
    4553
    4654    void SetScale(Double_t scale) { fScale = scale; }
    47     void SetMinimum(Double_t min=-1111);
     55
     56    void SetMinimum(Double_t min=-1111) { fMinimum = min; }
     57    void SetMaximum(Double_t max=-1111) { fMaximum = max; }
    4858
    4959    Int_t GetNbins() const;
     
    7888    void SetMaxPts(Int_t n) { fMaxPts=n; }
    7989
    80     ClassDef(MHVsTime, 2) // Generalized 1/2/3D-histogram for Mars variables
     90    ClassDef(MHVsTime, 3) // Generalized 1/2/3D-histogram for Mars variables
    8191};
    8292
Note: See TracChangeset for help on using the changeset viewer.