Ignore:
Timestamp:
09/25/04 13:51:15 (20 years ago)
Author:
gaug
Message:
*** empty log message ***
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/mhcalib/MHGausEvents.cc

    r5115 r5135  
    8888#include <TCanvas.h>
    8989#include <TStyle.h>
     90#include <TRandom.h>
    9091
    9192#include "MFFT.h"
     
    151152  fHGausHist.UseCurrentStyle();
    152153  fHGausHist.SetDirectory(NULL);
    153   fHGausHist.GetYaxis()->CenterTitle();
     154  //  TAxis *xaxe = fHGausHist.GetXaxis();
     155  //  xaxe->Set(100,0.,100.);
     156  TAxis *yaxe = fHGausHist.GetYaxis();
     157  //  yaxe->SetDefaults();
     158  yaxe->CenterTitle();
    154159}
    155160
     
    173178{
    174179
    175   // delete histograms
    176   if (fHPowerProbability)
    177     delete fHPowerProbability;
    178 
    179180  //
    180181  // The next two lines are important for the case that
     
    193194      delete fFExpFit;
    194195 
     196  // delete histograms
     197  if (fHPowerProbability)
     198    delete fHPowerProbability;
     199
    195200  // delete arrays
    196201  if (fPowerSpectrum) 
     
    203208  if (fGraphPowerSpectrum)
    204209    delete fGraphPowerSpectrum;
     210
    205211
    206212}
     
    522528    {
    523529      pad->cd(cwin++);
    524       DrawPowerSpectrum(*pad,cwin);
    525     }
    526 }
    527 
     530      DrawPowerSpectrum();
     531      pad->cd(cwin);
     532      DrawPowerProjection();
     533    }
     534}
     535
     536// -----------------------------------------------------------------------------
     537//
     538// DrawEvents:
     539//
     540// Will draw the graph with the option "A", unless the option:
     541// "SAME" has been chosen
     542//
    528543void MHGausEvents::DrawEvents(Option_t *opt)
    529544{
     
    551566
    552567
    553 void MHGausEvents::DrawPowerSpectrum(TVirtualPad &pad, Int_t i)
    554 {
    555  
     568// -----------------------------------------------------------------------------
     569//
     570// DrawPowerSpectrum
     571//
     572// Will draw the fourier spectrum of the events sequence with the option "A", unless the option:
     573// "SAME" has been chosen
     574//
     575void MHGausEvents::DrawPowerSpectrum(Option_t *option)
     576{
     577
     578  TString opt(option);
     579 
     580  if (!fPowerSpectrum)
     581    CreateFourierSpectrum();
     582
    556583  if (fPowerSpectrum)
    557584    {
    558585      if (!fGraphPowerSpectrum)
    559586        CreateGraphPowerSpectrum();
     587
     588      if (!fGraphPowerSpectrum)
     589        return;
    560590     
    561       fGraphPowerSpectrum->Draw("AL");         
    562       fGraphPowerSpectrum->SetBit(kCanDelete);
    563     }
    564  
    565   pad.cd(i);
     591      if (opt.Contains("same"))
     592        {
     593          opt.ReplaceAll("same","");     
     594          fGraphPowerSpectrum->Draw(opt+"L");
     595        }
     596      else
     597        {
     598          fGraphPowerSpectrum->Draw(opt+"AL"); 
     599          fGraphPowerSpectrum->SetBit(kCanDelete);
     600        }
     601    }
     602}
     603
     604// -----------------------------------------------------------------------------
     605//
     606// DrawPowerProjection
     607//
     608// Will draw the projection of the fourier spectrum onto the power probability axis
     609// with the possible options of TH1D
     610//
     611void MHGausEvents::DrawPowerProjection(Option_t *option)
     612{
     613 
     614  TString opt(option);
     615
     616  if (!fHPowerProbability)
     617    CreateFourierSpectrum();
    566618
    567619  if (fHPowerProbability && fHPowerProbability->GetEntries() > 0)
    568620    {
    569621      gPad->SetLogy();
    570       fHPowerProbability->Draw();
     622      fHPowerProbability->Draw(opt.Data());
    571623      if (fFExpFit)
    572624        {
     
    772824void MHGausEvents::InitBins()
    773825{
     826  //  const TAttAxis att(fHGausHist.GetXaxis());
    774827  fHGausHist.SetBins(fNbins,fFirst,fLast);
     828  //  att.Copy(fHGausHist.GetXaxis());
    775829}
    776830
     
    904958}
    905959
     960// ----------------------------------------------------------------------------
     961//
     962// Simulates Gaussian events and fills them  into the histogram and the array
     963// In order to do a fourier analysis, call CreateFourierSpectrum()
     964//
     965void  MHGausEvents::SimulateGausEvents(const Float_t mean, const Float_t sigma, const Int_t nevts)
     966{
     967
     968  if (!IsEmpty())
     969    *fLog << warn << "The histogram is already filled, will superimpose simulated events on it..." << endl;
     970 
     971  for (Int_t i=0;i<nevts;i++) {
     972    const Double_t ran = gRandom->Gaus(mean,sigma);
     973    FillHistAndArray(ran);
     974  }
     975 
     976}
Note: See TracChangeset for help on using the changeset viewer.