Ignore:
Timestamp:
04/09/03 20:10:16 (22 years ago)
Author:
tbretz
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars/mhist
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/mhist/MHMcTriggerLvl2.cc

    r1920 r1934  
    1616!
    1717!
    18 !   Author(s): Nicola Galante 2003 <mailto:nicola.galante@pi.infn.it>
    19 !!
    20 !   Copyright: MAGIC Software Development, 2000-2002
     18!   Author(s): Nicola Galante, 2003 <mailto:nicola.galante@pi.infn.it>
     19!
     20!   Copyright: MAGIC Software Development, 2000-2003
    2121!
    2222!
     
    5151#include "MBinning.h"
    5252
     53/*
     54 Please, DON'T USE IFDEFS IN SUCH A CONTEXT, Thomas.
     55 --------------------------------------------------
    5356#ifndef COLOR_LINELPS
    5457#define COLOR_LINELPS Int_t colorlps = 1
     
    6568COLOR_LINEPS;
    6669#endif
     70*/
     71
     72/* Use this insteadif you want to have some value which is the same for all
     73 your instances of MHMcTriggerLvl2, if not define the values in the constructor
     74 and remove the 'static'
     75 */
     76
     77Int_t MHMcTriggerLvl2::fColorLps = 1;
     78Int_t MHMcTriggerLvl2::fColorSbc = 1;
     79Int_t MHMcTriggerLvl2::fColorPs = 1;
    6780
    6881ClassImp(MHMcTriggerLvl2);
     
    145158// This method is called by the DrawClone method.
    146159//
    147 TObject *MHMcTriggerLvl2::DrawHist(TH1 *hist, TH1 *histNorm, const char *canvasname, Int_t *colore) const
    148 {
    149   ++(*colore);
    150 
    151   if((gROOT->FindObject(canvasname) != NULL)){
    152     hist->SetLineColor(*colore);
    153     ((TCanvas *)gROOT->FindObject(canvasname))->cd(1);
    154     hist->DrawCopy("same");
    155    
    156     ((TCanvas *)gROOT->FindObject(canvasname))->cd(2);
    157     histNorm->SetLineColor(*colore);
    158     histNorm->DrawCopy("same");
    159     ((TCanvas *)gROOT->FindObject(canvasname))->cd(2);
    160     return gROOT->FindObject(canvasname);
    161   }
    162   else{
    163     TCanvas *c3 = MakeDefCanvas(canvasname,canvasname, 800, 610);
    164     c3->Divide(2,1);
    165     c3->cd(1);
    166     hist->SetLineColor(*colore);
    167     hist->DrawCopy();
    168 
    169     c3->cd(2);
    170     histNorm->SetLineColor(*colore);
    171     histNorm->DrawCopy();
    172 
    173     return c3;
    174   }
    175 }
    176  
     160TObject *MHMcTriggerLvl2::DrawHist(TH1 &hist, TH1 &histNorm, const TString &canvasname, Int_t &col) const
     161{
     162    col++;
     163
     164    TCanvas *c = (TCanvas*)gROOT->FindObject(canvasname);
     165
     166    Bool_t same = kTRUE;
     167    if (!c)
     168    {
     169        c = MakeDefCanvas(canvasname,canvasname, 800, 610);
     170        c->Divide(2,1);
     171        same = kFALSE;
     172    }
     173
     174    c->cd(1);
     175    hist.SetLineColor(col);
     176    hist.DrawCopy(same?"same":"");
     177
     178    c->cd(2);
     179    histNorm.SetLineColor(col);
     180    histNorm.DrawCopy(same?"same":"");
     181
     182    return c;
     183}
     184
    177185
    178186// --------------------------------------------------------------------------
     
    191199TObject *MHMcTriggerLvl2::DrawClone(Option_t *opt) const
    192200{
    193   TString *def = new TString("ps");
    194   TString str(opt);
    195    
    196   if(*opt == NULL) str = *def;  // Default option
    197  
    198   if (str.Contains("lps",TString::kIgnoreCase))
    199     return this->DrawHist(hfLutPseudoSize,this->NormalizeHist(hfLutPseudoSizeNorm,hfLutPseudoSize),"CanvasLPS",&colorlps);
    200   else if (str.Contains("sbc",TString::kIgnoreCase))
    201     return this->DrawHist(hfSizeBiggerCell,this->NormalizeHist(hfSizeBiggerCellNorm,hfSizeBiggerCell),"CanvasSBC",&colorsbc);
    202   else if (str.Contains("ps",TString::kIgnoreCase))
    203     return this->DrawHist(hfPseudoSize,this->NormalizeHist(hfPseudoSizeNorm,hfPseudoSize),"CanvasPS",&colorps);
    204   else{
    205     *fLog << "ARGH!@! Possible options are \"lps\", \"sbc\", \"ps\" or NULL!" <<endl;
     201    TString str(opt);
     202
     203    if (str.IsNull())
     204        str = "ps";
     205
     206    if (!str.Contains("lps", TString::kIgnoreCase) &&
     207        !str.Contains("sbc", TString::kIgnoreCase) &&
     208        !str.Contains("ps",  TString::kIgnoreCase))
     209    {
     210        *fLog << "ARGH!@! Possible options are \"lps\", \"sbc\", \"ps\" or NULL!" <<endl;
     211        return NULL;
     212    }
     213
     214    TH1 *hist=NormalizeHist(hfLutPseudoSizeNorm, hfLutPseudoSize);
     215
     216    if (!hist)
     217        return NULL;
     218
     219    if (str.Contains("lps",TString::kIgnoreCase))
     220        return DrawHist(*hfLutPseudoSize, *hist, "CanvasLPS", fColorLps);
     221
     222    if (str.Contains("sbc",TString::kIgnoreCase))
     223        return DrawHist(*hfSizeBiggerCell, *hist, "CanvasSBC", fColorSbc);
     224
     225    if (str.Contains("ps",TString::kIgnoreCase))
     226        return DrawHist(*hfPseudoSize, *hist, "CanvasPS", fColorPs);
     227
    206228    return NULL;
    207   }
    208 
    209229}
    210230
  • trunk/MagicSoft/Mars/mhist/MHMcTriggerLvl2.h

    r1920 r1934  
    2525
    2626    TF1* f1;                      // Function used to normalize histograms
     27
     28    static Int_t fColorLps;
     29    static Int_t fColorSbc;
     30    static Int_t fColorPs;
    2731   
    2832public:
     
    5054private:
    5155
    52     TObject *DrawHist(TH1 *hist, TH1 *histNorm, const char *canvasname, Int_t *colore) const;
     56    TObject *DrawHist(TH1 &hist, TH1 &histNorm, const TString &canvasname, Int_t &colore) const;
    5357
    5458};
Note: See TracChangeset for help on using the changeset viewer.