Ignore:
Timestamp:
05/09/07 13:15:53 (17 years ago)
Author:
tbretz
Message:
*** empty log message ***
File:
1 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
Note: See TracChangeset for help on using the changeset viewer.