2-d scatter plots are solid black

From: Chris Jillings (chris@owl.phy.queensu.ca)
Date: Mon Jul 13 1998 - 17:34:41 MEST


Hi,
    I have built a class (.h and .cpp below) which contains two
TCutg objects and 4 TH2F objects. My cut class does two things: it takes
the logical "and" of the two TCutg objects and histograms results. Four
histograms are made: the passes and fails of each TCutg. The problem is
that sometimes the 2-d hist scatter plot for the cut histograms is solid
black. I dumped the histograms (one dump shown below) and in fact they are
empty. 

Any ideas?

Thanks,

Chris

fNcells                  252004      number of bins(1D), cells (2D)
+U/Overflows
fXaxis.fNbins            500         Number of bins
fXaxis.fXmin             -1000       low edge of first bin
fXaxis.fXmax             4000        upper edge of last bin
fXaxis.fXbins.*fArray    ->0         Array of fN floats
fXaxis.fXbins.fN         0           Number of array elements
fXaxis.*fXlabels         ->0         !Labels associated to axis
fXaxis.fFirst            0           first bin to display
fXaxis.fLast             0           last bin to display
fXaxis.fName.*fData      xaxis
fXaxis.fTitle.*fData     
fXaxis.fUniqueID         0           object unique identifier
fXaxis.fBits             50331648    bit field status word
fXaxis.fNdivisions       510         Number of divisions(10000*n3 + 100*n2
+ n1)
fXaxis.fAxisColor        1           color of the line axis
fXaxis.fLabelColor       1           color of labels
fXaxis.fLabelFont        62          font for labels
fXaxis.fLabelOffset      0.005       offset of labels
fXaxis.fLabelSize        0.04        size of labels
fXaxis.fTickLength       0.03        length of tick marks
fXaxis.fTitleOffset      1           offset of axis title
fXaxis.fTitleSize        0.04        size of axis title
fYaxis.fNbins            500         Number of bins
fYaxis.fXmin             -1000       low edge of first bin
fYaxis.fXmax             4000        upper edge of last bin
fYaxis.fXbins.*fArray    ->0         Array of fN floats
fYaxis.fXbins.fN         0           Number of array elements
fYaxis.*fXlabels         ->0         !Labels associated to axis
fYaxis.fFirst            0           first bin to display
fYaxis.fLast             0           last bin to display
fYaxis.fName.*fData      yaxis
fYaxis.fTitle.*fData     
fYaxis.fUniqueID         0           object unique identifier
fYaxis.fBits             50331648    bit field status word
fYaxis.fNdivisions       510         Number of divisions(10000*n3 + 100*n2
+ n1)
fYaxis.fAxisColor        1           color of the line axis
fYaxis.fLabelColor       1           color of labels
fYaxis.fLabelFont        62          font for labels
fYaxis.fLabelOffset      0.005       offset of labels
fYaxis.fLabelSize        0.04        size of labels
fYaxis.fTickLength       0.03        length of tick marks
fYaxis.fTitleOffset      1           offset of axis title
fYaxis.fTitleSize        0.04        size of axis title
fZaxis.fNbins            1           Number of bins
fZaxis.fXmin             0           low edge of first bin
fZaxis.fXmax             1           upper edge of last bin
fZaxis.fXbins.*fArray    ->0         Array of fN floats
fZaxis.fXbins.fN         0           Number of array elements
fZaxis.*fXlabels         ->0         !Labels associated to axis
fZaxis.fFirst            0           first bin to display
fZaxis.fLast             0           last bin to display
fZaxis.fName.*fData      zaxis
fZaxis.fTitle.*fData     
fZaxis.fUniqueID         0           object unique identifier
fZaxis.fBits             50331648    bit field status word
fZaxis.fNdivisions       510         Number of divisions(10000*n3 + 100*n2
+ n1)
fZaxis.fAxisColor        1           color of the line axis
fZaxis.fLabelColor       1           color of labels
fZaxis.fLabelFont        62          font for labels
fZaxis.fLabelOffset      0.005       offset of labels
fZaxis.fLabelSize        0.04        size of labels
fZaxis.fTickLength       0.03        length of tick marks
fZaxis.fTitleOffset      1           offset of axis title
fZaxis.fTitleSize        0.04        size of axis title
fBarOffset               0           (1000*offset) for bar charts or legos
fBarWidth                1000        (1000*width) for bar charts or legos
fEntries                 3           Number of entries
fTsumw                   0           Total Sum of weights
fTsumw2                  0           Total Sum of squares of weights
fTsumwx                  0           Total Sum of weight*X
fTsumwx2                 0           Total Sum of weight*X*X
fMaximum                 -1111       Maximum value for plotting
fMinimum                 -1111       Minimum value for plotting
fNormFactor              0           Normalization factor
fContour.*fArray         ->0         Array of fN floats
fContour.fN              0           Number of array elements
fSumw2.*fArray           ->0         Array of fN doubles
fSumw2.fN                0           Number of array elements
fOption.*fData           
*fFunctions              ->85e3ac8   Pointer to list of functions (fits
and user)
*fDirectory              ->85d1698   Pointer to directory holding this
histogram
fDimension               2           Histogram dimension (1, 2 or 3 dim)
fName.*fData             cut_sl
fTitle.*fData            Cut: Short Long
fUniqueID                0           object unique identifier
fBits                    50331656    bit field status word
fLineColor               1           line color
fLineStyle               1           line style
fLineWidth               1           line width
fFillColor               0           fill area color
fFillStyle               1001        fill area style
fMarkerColor             1           Marker color index
fMarkerStyle             1           Marker style
fMarkerSize              1           Marker size
*fArray                  0           Array of fN floats
fN                       252004      Number of array elements
fScalefactor             1           Scale factor
fTsumwy                  -3e+06      Total Sum of weight*Y
fTsumwy2                 2.99999e+12 Total Sum of weight*Y*Y
fTsumwxy                 -5.13999e+07Total Sum of weight*X*Y


The header file is 
#ifndef __QCHARGECUTS_H 
#define __QCHARGECUTS_H


//*-- Author : Chris Jillings                          
//* Copyright (c) 1998 Chris Jillings      

#include "QEvent.h"
#include "QPMT.h"

#ifdef COMPILED_ROOT
#include "TCutG.h"
#include "TFile.h"
#include "TH2.h"
#include "TPad.h"
#endif

class QChargeCuts : public TObject {
 public:
  ClassDef(QChargeCuts,1)
  QChargeCuts();
  QChargeCuts(char* aFileName);  // filename points to the file containing the Cuts
  ~QChargeCuts();
  Bool_t Cut(QEvent* aEvent); 
  void Draw(TPad* p1);
  void Report();
  UInt_t GetNumberPassed() { return fNumberPassed; }
  UInt_t GetNumberFailed() { return fNumberFailed; }

 private:

  TFile* fCutFile;
  TCutG* fLowHighLong;
  TCutG* fHighShortHighLong;
  TH2F* cut_lh;
  TH2F* cut_sl;
  TH2F* pass_lh;
  TH2F* pass_sl;
  UInt_t fNumberPassed;
  UInt_t fNumberFailed;

  void init(char* aFilename);

  Int_t fnp;

};

#endif

The .cpp file is
#include "QChargeCuts.h" 
#include <stdlib.h>

ClassImp(QChargeCuts)

QChargeCuts::QChargeCuts() {
  // This is the default constructor. Don't ever use it. 
  fprintf(stderr,"Warning: Using Default constructor for class QChargeCuts.\n");
  fprintf(stderr,"Warning: Using Default file RelaxedChargeCuts.root.\n");
  init("RelaxedChargeCuts.root");
}

QChargeCuts::QChargeCuts(char* aFilename) {
  init(aFilename);
}


void QChargeCuts::init(char* aFilename) {
  char* envar;
  envar = getenv("QSNO_ROOT");
  if (envar==NULL) exit(-1);
  char*fnbase = new char[strlen(envar)+30+strlen(aFilename)+1];
  strcpy(fnbase,envar);
  strcat(fnbase,"/parameters/");
  strcat(fnbase,aFilename);

  fCutFile = new TFile(fnbase);
  if( fCutFile->IsOpen()==kFALSE ) {
    fprintf(stderr,"The cut file  was not opened properly.\n");
    fprintf(stderr,"The cuts will reject everything.\n");
    fLowHighLong = NULL;
    fHighShortHighLong = NULL;
  } else {
    fLowHighLong = (TCutG*)fCutFile->Get("lowHighLong");
    fHighShortHighLong = (TCutG*)fCutFile->Get("highShortHighLong");
    if ( fLowHighLong==NULL || fHighShortHighLong==NULL ) {
      fprintf(stderr,"Could not get one of the curs from the file. Everything");
      fprintf(stderr,"will be cut.\n");
    }
  }
  cut_lh  =  new TH2F("cut_lh","Cut: Low High",500,-1000,4000,500,-1000,4000);
  cut_sl  =  new TH2F("cut_sl","Cut: Short Long",500,-1000,4000,500,-1000,4000);
  pass_lh = new TH2F("pass_lh","Pass: Low High",500,-1000,4000,500,-1000,4000);
  pass_sl = new TH2F("pass_sl","Pass: Short Long",500,-1000,4000,500,-1000,4000);

  fNumberPassed = 0;
  fNumberFailed = 0;
  fnp = 0;
}

QChargeCuts::~QChargeCuts() {
  delete fLowHighLong;
  delete fHighShortHighLong;
  if (fCutFile->IsOpen()) fCutFile->Close();
  if (cut_lh!=NULL) delete cut_lh;
  if (cut_sl!=NULL) delete cut_sl;
  if (pass_lh!=NULL) delete pass_lh;
  if (pass_sl!=NULL) delete pass_sl;
}

Bool_t QChargeCuts::Cut(QEvent* aEvent) {
  Bool_t hello;
  Float_t low,highShort,highLong;
  QPMT* pmt;
  Int_t tester;
  if( fLowHighLong==NULL || fHighShortHighLong==NULL ) hello = kTRUE;

  else {
    hello = 1;  // hello will be inverted at end of else clause
    for( Int_t j=0 ; j<aEvent->GetNhits() ; j++ ) {
      pmt = (QPMT*)aEvent->GetQPMTs()->At(j);
      low       = pmt->Getlx();
      highShort = pmt->Geths();
      highLong  = pmt->Gethl();
      tester    = fLowHighLong->IsInside(low,highLong);
      if( tester==0 ) {
	cut_lh->Fill(low,highLong);
	fnp++;
	hello*=0;
      } else {
	pass_lh->Fill(low,highLong);
      }
      tester    = fHighShortHighLong->IsInside(highShort,highLong);
      if( tester==0 ) {
	cut_sl->Fill(highShort,highLong);
	hello*=0;
      } else {
	pass_sl->Fill(highShort,highLong);
      }
    }
    if(hello==1) {hello = kFALSE;fNumberPassed++;}
    else {hello = kTRUE;fNumberFailed++;}
  }

  return hello;
}


void QChargeCuts::Draw(TPad* p1) {
   p1->cd();
   p1->Divide(2,2);
   p1->cd(1);
   cut_lh->Draw();
   fLowHighLong->Draw("L");
   p1->cd(2);
   cut_sl->Draw();
   fHighShortHighLong->Draw("L");
   p1->cd(3);
   pass_lh->Draw();
   fLowHighLong->Draw("L");
   p1->cd(4);
   pass_sl->Draw();
   fHighShortHighLong->Draw("L");

}

void QChargeCuts::Report() {
  fprintf(stderr,"The total number cut was %d.\n",fNumberFailed);
  fprintf(stderr,"The total number passed was %d.\n",fNumberPassed);
  fprintf(stderr,"The number of points in cut_low_high is %d\n",fnp);

}













=================================================================
=                                                               =
= Chris Jillings                                                =
= Department of Physics   phone/voice mail: (613) 545-6000x4805 =   
= Queen's University      fax: (613) 545-6813                   =
= Kingston, Ontario       email: chris@sno.phy.queensu.ca       =             
= Canada, K7L 3N6         web: http://sno.phy.queensu.ca        =
=                                                               =
=================================================================



This archive was generated by hypermail 2b29 : Tue Jan 04 2000 - 00:34:35 MET