THStack problem

From: Roberta Ferretti <Roberta.Ferretti_at_cern.ch>
Date: Thu, 16 Oct 2008 12:16:46 +0200

Dear Rootters,

I have a problem in using THStack, I think. I would like to draw in a single canvas 60 histograms and group them six by six with different colour for each group. Here is the code I am using:

int main(int argc, char **argv) {
  if (argc!=3) {
    printf("Usage: analyzerefScan.exe refDataDir runNr\n");     return -1;
  }

  TString refDataDir = Form("%s",argv[1]);   UInt_t runNr = atoi(argv[2]);

  UInt_t step = 0;
  Float_t pixel100 = 0.0;
  Float_t TPeff = 0.0;
  UInt_t k = 0;
  UInt_t i = 0;   

  TCanvas *c1 = new TCanvas("c1","Test Pulse efficiency",300,200,600,400);   c1->SetFillColor(10);   

  THStack *hstack = new THStack("hstack","Test Pulse Efficiency");   TH1I *h1[10][6];   

  AliITSOnlineSPDscan *scanObj[20];
  for (UInt_t eq=10; eq<20; eq++) {
    TString fileName = Form("%s/%d_SPD_ref_scan_eq_%d",refDataDir.Data(),runNr,eq);     scanObj[eq] = new AliITSOnlineSPDscan(fileName.Data());

    for (UInt_t hs=0; hs<6; hs++) {

      h1[eq][hs]=new TH1I("h1","h",60,0,60);
      
        for (UInt_t chip=0; chip<10; chip++) {	    
	  for (UInt_t col=0; col<32; col++) {
	    for (UInt_t row=0; row<26; row++) {
	      UInt_t nrHits = scanObj[eq]->GetHits(step,hs,chip,col,row);
	      if (nrHits==100) pixel100++;
	    }
	  }
	  
        }
      
	
        TPeff=(pixel100 / 8320)*100;
	
	h1[eq][hs]->Fill(hs+6*k,TPeff);
	h1[eq][hs]->SetFillColor(40+k);
	
	hstack->Add(h1[eq][hs]);
	
	
	pixel100=0;
	
      }
      
      
      k++;
      delete scanObj[eq];

    }         
    hstack->Draw("nostack");
    hstack->GetXaxis()->SetTitle("Half Staves");
    hstack->GetYaxis()->SetTitle("Half Staves Efficiency");
    hstack->GetXaxis()->CenterTitle();
    hstack->GetYaxis()->CenterTitle();
    
   c1->SaveAs("TPefficiency.C");

   c1->SaveAs("TPefficiency.ps");
   c1->SaveAs("TPefficiency.gif");          

  return 0;
}

When I run it something strange happens: histograms 6, 12, 18 and so on are not drawn. Why?

thank you very much for your help.

Regards,

Roberta Received on Thu Oct 16 2008 - 12:16:50 CEST

This archive was generated by hypermail 2.2.0 : Thu Oct 16 2008 - 17:50:02 CEST