Ignore:
Timestamp:
01/09/04 22:47:53 (21 years ago)
Author:
gaug
Message:
*** empty log message ***
File:
1 edited

Legend:

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

    r2698 r2762  
    103103//  Default Constructor. To be used by the root system ONLY.
    104104//
    105 MHCamera::MHCamera() : TH1D(), fGeomCam(NULL), fColors(kItemsLegend)
     105MHCamera::MHCamera() : TH1D(), fGeomCam(NULL), fColors(kItemsLegend), fYProj(NULL)
    106106{
    107107    Init();
     
    116116MHCamera::MHCamera(const MGeomCam &geom, const char *name, const char *title)
    117117: fGeomCam(NULL), /*TH1D(name, title, geom.GetNumPixels(), -0.5, geom.GetNumPixels()-0.5),
    118 fUsed(geom.GetNumPixels()),*/ fColors(kItemsLegend)
     118                    fUsed(geom.GetNumPixels()),*/ fColors(kItemsLegend), fYProj(NULL)
    119119{
    120120    //fGeomCam = (MGeomCam*)geom.Clone();
     
    160160{
    161161    if (fGeomCam)
    162         delete fGeomCam;
     162      delete fGeomCam;
    163163    if (fNotify)
    164         delete fNotify;
     164      delete fNotify;
     165    if (fYProj)
     166      delete fYProj;
     167
    165168}
    166169
     
    399402    gPad->SetBorderMode(0);
    400403
     404    TString opt(option);
     405    opt.ToLower();
     406
    401407    AppendPad(option);
    402408
     
    414420// If this makes trouble please write a bug report.
    415421//
    416 TObject *MHCamera::DrawClone(Option_t *option) const
     422TObject *MHCamera::DrawClone(Option_t *option) const 
    417423{
    418424   // Draw a clone of this object in the current pad
     
    423429
    424430   TObject *newobj = Clone();
     431
    425432   if (!newobj)
    426433       return 0;
     
    437444   */
    438445
    439    const TString opt(option);
     446   TString opt(option);
     447   opt.ToLower();
     448
    440449   newobj->Draw(opt.IsNull() ? GetDrawOption() : option);
    441450
     
    445454   return newobj;
    446455}
     456
     457void MHCamera::CreateProjection()
     458{
     459 
     460  Int_t nbins = 50;
     461
     462  // Create the projection histogram
     463  TString ytitle(GetYaxis()->GetTitle());
     464  fYProj = new TH1D(ytitle.Data(),GetTitle(),nbins,GetMinimum()-0.1,GetMaximum()+0.1);
     465  fYProj->SetXTitle(ytitle.Data());
     466  fYProj->SetYTitle("Nr. of pixels");
     467  fYProj->Sumw2();
     468  fYProj->SetDirectory(NULL);
     469
     470  // Fill the projected histogram
     471  Double_t cont;
     472  for (Int_t binx =0;binx<=GetNbinsX()+1;binx++) {
     473    cont  = GetBinContent(binx);
     474    if (cont)
     475      fYProj->Fill(cont);
     476  }
     477}
     478
    447479
    448480// ------------------------------------------------------------------------
     
    592624    }
    593625
     626    if (opt.Contains("proj"))
     627    {
     628
     629      CreateProjection();
     630      opt.ReplaceAll("proj", "");
     631      fYProj->Paint(opt);
     632      return;
     633    }
     634   
    594635    gPad->Clear();
    595636
Note: See TracChangeset for help on using the changeset viewer.