Changeset 5620 for trunk


Ignore:
Timestamp:
12/17/04 13:27:08 (20 years ago)
Author:
tbretz
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/Changelog

    r5619 r5620  
    2828   * mcalib/MCalibColorSet.cc:
    2929     - replaced arbitrary number for run type by correct enum
     30
     31   * mbase/MStatusDisplay.[h,cc]:
     32     - changed DrawClonePad such that
     33       + before cloning we change into the pad (necessary for
     34         GetDrawOption)
     35       + removed SetSelectedPad (seems not necessary at all)
     36       + SetBit(kCanDelete) for all cloned object
     37       + copy bits kMustCleanup, kCannotPick and kNoContextMenu
     38       + oldc is not const anymore (cd()!)
     39
     40   * mhbase/MH3.[h,cc]:
     41     - removed fNameProfX, fNameProfY - didn't work with a more accurate
     42       scheme to get the handle to the profile histograms
     43     - moved most code from Draw to Paint so that a more accurate handling
     44       of read pads containing these histograms is possible
     45
     46   * mhvstime/MHVsTime.[h,cc]:
     47     - moved most code from Draw to Paint so that a more accurate handling
     48       of read pads containing these histograms is possible
     49
     50   * mhflux/MHEffectiveOnTime.[h,cc]:
     51     - removed fNameProj* - didn't work with a more accurate
     52       scheme to get the handle to the profile histograms
     53     - set no option for default AppendPad (istead of "fit" which
     54       didn't work for saved files - for unknown reasons)
    3055
    3156
  • trunk/MagicSoft/Mars/mbase/MStatusDisplay.cc

    r5557 r5620  
    15881588// Draws a clone of a canvas into a new canvas. Taken from TCanvas.
    15891589//
    1590 void MStatusDisplay::DrawClonePad(TCanvas &newc, const TCanvas &oldc) const
     1590void MStatusDisplay::DrawClonePad(TCanvas &newc, TCanvas &oldc) const
    15911591{
    15921592    //copy pad attributes
     
    16051605    ((TAttPad&)oldc).Copy((TAttPad&)newc);
    16061606
     1607    // This must be there: Otherwise GetDrawOption() won't work
     1608    TVirtualPad *padsav = gPad;
     1609    oldc.cd();
     1610
    16071611    //copy primitives
    16081612    TObject *obj;
    16091613    TIter next(oldc.GetListOfPrimitives());
    1610     while ((obj=next())) {
    1611         gROOT->SetSelectedPad(&newc);
    1612         newc.GetListOfPrimitives()->Add(obj->Clone(),obj->GetDrawOption());
     1614    while ((obj=next()))
     1615    {
     1616        // Old line - I think it is not necessary anymore because of the cd()
     1617        //gROOT->SetSelectedPad(&newc);
     1618
     1619        // Now make a clone of the object
     1620        TObject *clone = obj->Clone();
     1621
     1622        // Clone also important bits (FIXME: Is this correct)
     1623        clone->SetBit(obj->TestBits(kMustCleanup|kCannotPick|kNoContextMenu));
     1624
     1625        // Now make sure that the clones are deleted at a later time
     1626        clone->SetBit(kCanDelete);
     1627
     1628        // Add the clone and its draw-option to the current pad
     1629        newc.GetListOfPrimitives()->Add(clone, obj->GetDrawOption());
    16131630    }
    16141631    newc.Modified();
    16151632    newc.Update();
     1633
     1634    padsav->cd();
    16161635}
    16171636
  • trunk/MagicSoft/Mars/mbase/MStatusDisplay.h

    r5498 r5620  
    117117    void UpdateTab(TGCompositeFrame *f);
    118118
    119     void DrawClonePad(TCanvas &newc, const TCanvas &oldc) const;
     119    void DrawClonePad(TCanvas &newc, TCanvas &oldc) const;
    120120    void CanvasSetFillColor(TPad &c, Int_t col) const;
    121121    Bool_t Display(const TObjArray &list);
  • trunk/MagicSoft/Mars/mhbase/MH3.cc

    r5603 r5620  
    103103//
    104104MH3::MH3(const unsigned int dim)
    105     : fDimension(dim>3?3:dim), fHist(NULL),
     105    : fDimension(dim>3?3:dim), fHist(NULL)/*,
    106106    fNameProfX(Form("ProfX_%p", this)),
    107     fNameProfY(Form("ProfY_%p", this))
     107    fNameProfY(Form("ProfY_%p", this))*/
    108108
    109109    switch (fDimension)
     
    205205//
    206206MH3::MH3(const char *memberx, const char *membery)
    207     : fDimension(2), fNameProfX(Form("ProjX_%p", this)), fNameProfY(Form("ProjY_%p", this))
     207    : fDimension(2)/*, fNameProfX(Form("ProjX_%p", this)), fNameProfY(Form("ProjY_%p", this))*/
    208208{
    209209    fHist = new TH2F;
     
    507507void MH3::Paint(Option_t *o)
    508508{
     509    /*
     510     *fLog << all << fHist << " " << gPad->GetName() << " ----> Paint " << o << endl;
     511     TListIter Next(gPad->GetListOfPrimitives()); TObject *obj;
     512     while ((obj=Next())) *fLog << obj << " " << obj->GetName() << " " << obj->ClassName() << " " << Next.GetOption() << " " << (int)obj->TestBit(kCanDelete) << endl;
     513     */
     514    /*
    509515    TString str(o);
    510 
    511     // FIXME: Do it in Paint()
    512     /*
    513      if (str.Contains("COL", TString::kIgnoreCase))
    514     {
    515         SetColors();
    516         return;
    517     }
    518     */
    519516
    520517    if (str.Contains("log", TString::kIgnoreCase))
     
    536533        if ((h0 = (TProfile*)gPad->FindObject(fNameProfY)))
    537534            ((TH2*)fHist)->ProfileY(fNameProfY, -1, 9999, "s");
    538     }
     535            }
     536            */
     537
     538    fHist->SetFillStyle(4000);
     539
     540    TString str(o);
     541    str = str.Strip(TString::kBoth);
     542
     543    Bool_t only = str.Contains("ONLY", TString::kIgnoreCase) && fDimension==2;
     544    Bool_t same = str.Contains("SAME", TString::kIgnoreCase) && fDimension==2;
     545    Bool_t blue = str.Contains("BLUE", TString::kIgnoreCase) && fDimension==2;
     546
     547    // FIXME: We may have to remove all our own options from str!
     548    if (!only && !gPad->GetListOfPrimitives()->FindObject(fHist))
     549        fHist->Draw(str);
     550
     551    if (str.Contains("PROFX", TString::kIgnoreCase) && fDimension==2)
     552    {
     553        TProfile *p = ((TH2*)fHist)->ProfileX("ProfX", -1, 9999, "s");
     554        if (!gPad->GetListOfPrimitives()->FindObject(p))
     555        {
     556            p->UseCurrentStyle();
     557            p->SetLineColor(blue ? kBlue : fHist->GetLineColor());
     558            p->SetBit(kCanDelete);
     559            p->SetDirectory(NULL);
     560            p->SetXTitle(fHist->GetXaxis()->GetTitle());
     561            p->SetYTitle(fHist->GetYaxis()->GetTitle());
     562            p->Draw(only&&!same?"":"same");
     563        }
     564    }
     565    if (str.Contains("PROFY", TString::kIgnoreCase) && fDimension==2)
     566    {
     567        TProfile *p = ((TH2*)fHist)->ProfileY("ProfY", -1, 9999, "s");
     568        if (!gPad->GetListOfPrimitives()->FindObject(p))
     569        {
     570            p->UseCurrentStyle();
     571            p->SetLineColor(blue ? kBlue : fHist->GetLineColor());
     572            p->SetBit(kCanDelete);
     573            p->SetDirectory(NULL);
     574            p->SetYTitle(fHist->GetXaxis()->GetTitle());
     575            p->SetXTitle(fHist->GetYaxis()->GetTitle());
     576            p->Draw(only&&!same?"":"same");
     577        }
     578    }
     579
     580    if (fHist->TestBit(kIsLogx) && fHist->GetEntries()>0) gPad->SetLogx();
     581    if (fHist->TestBit(kIsLogy) && fHist->GetEntries()>0) gPad->SetLogy();
     582    if (fHist->TestBit(kIsLogz) && fHist->GetEntries()>0) gPad->SetLogz();
    539583}
    540584
     
    559603    TVirtualPad *pad = gPad ? gPad : MakeDefCanvas(fHist);
    560604    pad->SetBorderMode(0);
    561 
     605    AppendPad(opt);
     606
     607    return;
     608/*
    562609    fHist->SetFillStyle(4000);
    563610
     
    597644    }
    598645
    599     AppendPad("log");
     646    AppendPad("log");*/
    600647}
    601648
  • trunk/MagicSoft/Mars/mhbase/MH3.h

    r5429 r5620  
    2626    Double_t    fScale[3];       // Scale for the three axis (eg unit)
    2727
    28     TString     fNameProfX;      //! This should make sure, that gROOT doen't confuse the profile with something else
    29     TString     fNameProfY;      //! This should make sure, that gROOT doen't confuse the profile with something else
     28    // TString     fNameProfX;      //! This should make sure, that gROOT doen't confuse the profile with something else
     29    // TString     fNameProfY;      //! This should make sure, that gROOT doen't confuse the profile with something else
    3030
    3131    void StreamPrimitive(ofstream &out) const;
     
    3636        kIsLogz = BIT(19)
    3737    };
     38
     39//    Int_t DistancetoPrimitive(Int_t px, Int_t py);
     40//    void  ExecuteEvent(Int_t event, Int_t px, Int_t py);
    3841
    3942public:
  • trunk/MagicSoft/Mars/mhflux/MHEffectiveOnTime.cc

    r5143 r5620  
    107107MHEffectiveOnTime::MHEffectiveOnTime(const char *name, const char *title)
    108108    : fPointPos(0), fTime(0), fParam(0), fIsFinalized(kFALSE),
    109     fNumEvents(200*60), fNameProjDeltaT(Form("DeltaT_%p", this)),
    110     fNameProjTheta(Form("Theta_%p", this))
     109    fNumEvents(200*60)/*, fNameProjDeltaT(Form("DeltaT_%p", this)),
     110    fNameProjTheta(Form("Theta_%p", this))*/
    111111{
    112112    //
     
    646646void MHEffectiveOnTime::Paint(Option_t *opt)
    647647{
     648    *fLog << all << "Paint: '" << opt << "'" << endl;
     649
    648650    TH1D *h=0;
    649651    TPaveStats *st=0;
     
    675677
    676678        pad->GetPad(1)->cd(1);
    677         if ((h = (TH1D*)gPad->FindObject(fNameProjDeltaT)))
     679        if ((h = (TH1D*)gPad->FindObject("ProjDeltaT"/*fNameProjDeltaT*/)))
    678680        {
    679             h = fH2DeltaT.ProjectionX(fNameProjDeltaT, -1, 9999, "E");
     681            h = fH2DeltaT.ProjectionX("ProjDeltaT"/*fNameProjDeltaT*/, -1, 9999, "E");
    680682            if (h->GetEntries()>0)
    681683                gPad->SetLogy();
     
    683685
    684686        pad->GetPad(2)->cd(1);
    685         if ((h = (TH1D*)gPad->FindObject(fNameProjTheta)))
    686             fH2DeltaT.ProjectionY(fNameProjTheta, -1, 9999, "E");
     687        if ((h = (TH1D*)gPad->FindObject("ProjTheta"/*fNameProjTheta*/)))
     688            fH2DeltaT.ProjectionY("ProjTheta"/*fNameProjTheta*/, -1, 9999, "E");
    687689
    688690        if (!fIsFinalized)
     
    692694    if (o==(TString)"paint")
    693695    {
    694         if ((h = (TH1D*)gPad->FindObject(fNameProjDeltaT)))
     696        if ((h = (TH1D*)gPad->FindObject("ProjDeltaT"/*fNameProjDeltaT*/)))
    695697        {
    696698            Double_t res[7];
     
    771773    pad->GetPad(1)->cd(1);
    772774    gPad->SetBorderMode(0);
    773     h = fH2DeltaT.ProjectionX(fNameProjDeltaT, -1, 9999, "E");
     775    h = fH2DeltaT.ProjectionX("ProjDeltaT"/*fNameProjDeltaT*/, -1, 9999, "E");
    774776    h->SetTitle("Distribution of \\Delta t [s]");
    775777    h->SetXTitle("\\Delta t [s]");
     
    801803    pad->GetPad(2)->cd(1);
    802804    gPad->SetBorderMode(0);
    803     h = fH2DeltaT.ProjectionY(fNameProjTheta, -1, 9999, "E");
     805    h = fH2DeltaT.ProjectionY("ProjTheta"/*fNameProjTheta*/, -1, 9999, "E");
    804806    h->SetTitle("Distribution of  \\Theta [\\circ]");
    805807    h->SetXTitle("\\Theta [\\circ]");
  • trunk/MagicSoft/Mars/mhflux/MHEffectiveOnTime.h

    r4999 r5620  
    5050    Int_t fNumEvents;    // Number of events to be used for a bin in time
    5151
    52     const TString fNameProjDeltaT; //! This should make sure, that gROOT doen't confuse the projection with something else
    53     const TString fNameProjTheta;  //! This should make sure, that gROOT doen't confuse the projection with something else
     52    //const TString fNameProjDeltaT; //! This should make sure, that gROOT doen't confuse the projection with something else
     53    //const TString fNameProjTheta;  //! This should make sure, that gROOT doen't confuse the projection with something else
    5454
    5555    Bool_t FitH(TH1D *h, Double_t *res, Bool_t paint=kFALSE) const;
  • trunk/MagicSoft/Mars/mhvstime/MHVsTime.cc

    r4891 r5620  
    8383//
    8484MHVsTime::MHVsTime(const char *rule, const char *error)
    85     : fGraph(NULL), fData(NULL), fError(0), fScale(1), fMaxPts(-1),
     85    : fGraph(NULL), fData(NULL), fError(NULL), fScale(1), fMaxPts(-1),
    8686    fNumEvents(1), fUseEventNumber(0)
    8787{
     
    114114    if (fData)
    115115        delete fData;
     116
     117    if (fError)
     118        delete fError;
    116119}
    117120
     
    169172{
    170173    fGraph->SetName(name);
    171     MParContainer::SetName(name);
     174    MH::SetName(name);
    172175}
    173176
     
    179182{
    180183    fGraph->SetTitle(title);
    181     MParContainer::SetTitle(title);
     184    MH::SetTitle(title);
    182185}
    183186
     
    247250void MHVsTime::Paint(Option_t *opt)
    248251{
     252    /*
     253     *fLog << all << fGraph << " " << gPad->GetName() << " ----> Paint " << opt << endl;
     254     TListIter Next(gPad->GetListOfPrimitives()); TObject *obj;
     255     while ((obj=Next())) *fLog << obj << " " << obj->GetName() << " " << obj->ClassName() << " " << Next.GetOption() << endl;
     256     */
     257
     258    if (!fGraph)
     259        return;
     260
     261//    *fLog << all << fGraph->GetN() << " " << opt << endl;
     262
     263    if (fGraph->GetN()==0)
     264        return;
     265
     266    TString str(opt);
     267    if (!str.Contains("A"))
     268        str += "A";
     269    if (!str.Contains("P"))
     270        str += "P";
     271    if (str.Contains("same", TString::kIgnoreCase))
     272    {
     273        str.ReplaceAll("same", "");
     274        str.ReplaceAll("A", "");
     275    }
     276
    249277    // SetPoint deletes the histogram!
    250278    if (fUseEventNumber)
     
    264292    // Otherwise MStatusDisplay::Update hangs.
    265293    gPad->GetListOfPrimitives()->Remove(fGraph);
    266     gPad->GetListOfPrimitives()->Add(fGraph, fGraph->GetN()<2 ? "A" : opt);
     294    fGraph->Draw(fGraph->GetN()<2 ? "A" : str);
     295    //gPad->GetListOfPrimitives()->Add(fGraph, fGraph->GetN()<2 ? "A" : opt);
     296    //    AppendPad(str);
     297    //    fGraph->Draw(str);
     298
    267299}
    268300
     
    275307void MHVsTime::Draw(Option_t *opt)
    276308{
    277     if (!fGraph)
    278         return;
    279 
    280     if (fGraph->GetN()==0)
    281         return;
    282 
    283309    TVirtualPad *pad = gPad ? gPad : MakeDefCanvas(fGraph);
    284310    pad->SetBorderMode(0);
    285 
    286     TString str(opt);
    287 
    288     if (!str.Contains("A"))
    289         str += "A";
    290     if (!str.Contains("P"))
    291         str += "P";
    292 
    293     if (str.Contains("same", TString::kIgnoreCase))
    294     {
    295         str.ReplaceAll("same", "");
    296         str.ReplaceAll("A", "");
    297     }
    298 
    299     AppendPad(str);
    300     fGraph->Draw(str);
     311    AppendPad(opt);
    301312}
    302313
Note: See TracChangeset for help on using the changeset viewer.