Changeset 5007 for trunk


Ignore:
Timestamp:
09/14/04 17:00:14 (20 years ago)
Author:
gaug
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/Changelog

    r5003 r5007  
    3232
    3333 2004/09/14: Markus Gaug
     34
     35   * mhcalib/MHGausEvents.cc
     36     - some changes in Draw for the case that there is no histogram
    3437
    3538   * manalysis/MHPedestalPix.[h,cc]
  • trunk/MagicSoft/Mars/mhbase/MH.cc

    r5003 r5007  
    11811181    const Int_t size = array.GetSize();
    11821182
     1183    TH1I *h1=0;
     1184
     1185    //check if histogram with identical name exist
     1186    TObject *h1obj = gROOT->FindObject(name);
     1187    if (h1obj && h1obj->InheritsFrom("TH1I"))
     1188    {
     1189        h1 = (TH1I*)h1obj;
     1190        h1->Reset();
     1191    }
     1192
    11831193    Double_t min = size>0 ? array[0] : 0;
    11841194    Double_t max = size>0 ? array[0] : 1;
     
    11931203    Int_t newbins = 0;
    11941204    FindGoodLimits(nbins, newbins, min, max, kFALSE);
    1195    
    1196     TH1I *h1 = new TH1I(name, title, nbins, min, max);
    1197     h1->SetXTitle("");
    1198     h1->SetYTitle("Counts");
    1199     h1->SetDirectory(NULL);
     1205
     1206    if (!h1)
     1207    {
     1208        h1 = new TH1I(name, title, nbins, min, max);
     1209        h1->SetXTitle("");
     1210        h1->SetYTitle("Counts");
     1211        h1->SetDirectory(gROOT);
     1212    }
    12001213
    12011214    // Second loop to fill the histogram
     
    12171230    Double_t max = size>0 ? array[0] : 1;
    12181231
     1232    TH1I *h1=0;
     1233
     1234    //check if histogram with identical name exist
     1235    TObject *h1obj = gROOT->FindObject(name);
     1236    if (h1obj && h1obj->InheritsFrom("TH1I"))
     1237    {
     1238        h1 = (TH1I*)h1obj;
     1239        h1->Reset();
     1240    }
     1241
    12191242    // first loop over array to find the min and max
    12201243    for (Int_t i=1; i<size;i++)
     
    12271250    FindGoodLimits(nbins, newbins, min, max, kFALSE);
    12281251
    1229     TH1I *h1 = new TH1I(name, title, newbins, min, max);
    1230     h1->SetXTitle("");
    1231     h1->SetYTitle("Counts");
    1232     h1->SetDirectory(NULL);
    1233 
     1252    if (!h1)
     1253    {
     1254      h1 = new TH1I(name, title, newbins, min, max);
     1255      h1->SetXTitle("");
     1256      h1->SetYTitle("Counts");
     1257      h1->SetDirectory(gROOT);
     1258    }
     1259   
    12341260    // Second loop to fill the histogram
    12351261    for (Int_t i=0;i<size;i++)
     
    12461272                       const char* name, const char* title)
    12471273{
    1248     const TArrayF arr(array.GetSize(), array.GetArray());
    1249     return ProjectArray(arr, nbins, name, title);
     1274    return ProjectArray(TArrayF(array.GetSize(),array.GetArray()), nbins, name, title);
    12501275}
    12511276
     
    12561281TH1I* MH::ProjectArray(const MArrayD &array, Int_t nbins, const char* name, const char* title)
    12571282{
    1258     const TArrayD arr(array.GetSize(), array.GetArray());
    1259     return ProjectArray(arr, nbins, name, title);
     1283    return ProjectArray(TArrayD(array.GetSize(),array.GetArray()), nbins, name, title);
    12601284}
    12611285
  • trunk/MagicSoft/Mars/mhcalib/MHGausEvents.cc

    r4994 r5007  
    386386  fPowerSpectrum     = fourier.PowerSpectrumDensity(&fEvents);
    387387  fHPowerProbability = ProjectArray(*fPowerSpectrum, fPowerProbabilityBins,
    388                                     Form("%s%s","PowerProbability",GetName()),
     388                                    Form("%s%s","PowerProb",GetName()),
    389389                                    "Probability of Power occurrance");
    390390  fHPowerProbability->SetXTitle("P(f)");
     
    521521
    522522  if (option.Contains("events"))
    523     {
    524       option.ReplaceAll("events","");
    525       win += 1;
    526     }
     523    win += 1;
    527524  if (option.Contains("fourier"))
    528     {
    529       option.ReplaceAll("fourier","");
    530       win += 2;
    531     }
    532  
     525    win += 2;
     526  if (IsEmpty())
     527    win--;
     528
    533529  pad->SetBorderMode(0);
    534530  pad->Divide(1,win);
    535   pad->cd(1);
    536 
    537   if (!IsEmpty() && !IsOnlyOverflow() && !IsOnlyUnderflow())
    538     gPad->SetLogy();
     531
     532  Int_t cwin = 1;
    539533
    540534  gPad->SetTicks();
    541535
    542   fHGausHist.Draw(option);
    543 
    544   if (fFGausFit)
    545     {
    546       fFGausFit->SetLineColor(IsGausFitOK() ? kGreen : kRed);
    547       fFGausFit->Draw("same");
    548     }
    549   switch (win)
    550     {
    551     case 2:
    552       pad->cd(2);
     536  if (!IsEmpty())
     537    {
     538      pad->cd(cwin++);
     539
     540      if (!IsOnlyOverflow() && !IsOnlyUnderflow())
     541        gPad->SetLogy();
     542
     543      fHGausHist.Draw(option);
     544     
     545      if (fFGausFit)
     546        {
     547          fFGausFit->SetLineColor(IsGausFitOK() ? kGreen : kRed);
     548          fFGausFit->Draw("same");
     549        }
     550    }
     551 
     552  if (option.Contains("events"))
     553    {
     554      pad->cd(cwin++);
    553555      DrawEvents();
    554       break;
    555     case 3:
    556       pad->cd(2);
    557       DrawPowerSpectrum(*pad,3);
    558       break;
    559     case 4:
    560       pad->cd(2);
    561       DrawEvents();
    562       pad->cd(3);
    563       DrawPowerSpectrum(*pad,4);
    564       break;
     556    }
     557  if (option.Contains("fourier"))     
     558    {
     559      pad->cd(cwin++);
     560      DrawPowerSpectrum(*pad,cwin);
    565561    }
    566562}
Note: See TracChangeset for help on using the changeset viewer.