StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
MakeHists.cxx
1 // $Id: MakeHists.cxx,v 1.14 2006/08/15 21:42:59 jeromel Exp $
2 // $Log: MakeHists.cxx,v $
3 // Revision 1.14 2006/08/15 21:42:59 jeromel
4 // Fix rhic -> rhic.bnl.gov
5 //
6 // Revision 1.13 2003/09/02 18:00:19 perev
7 // gcc 3.2 updates + WarnOff
8 //
9 // Revision 1.12 2000/01/19 21:00:40 kathy
10 // update macros to use standard default xdf files in /afs/rhic.bnl.gov/star/data/samples
11 //
12 // Revision 1.11 1999/10/11 17:18:00 kathy
13 // changed names of some macros to make them more standard; changed default input file to MakeHists since previous no longer existed; combined some macros so that the one example will show all functionality
14 //
15 // Revision 1.10 1999/06/03 16:40:36 kathy
16 // put back old dedx.C and restore original macros that use non-existent input file
17 //
18 // Revision 1.8 1999/05/21 15:33:51 kathy
19 // made sure Log & Id are in each file and also put in standard comment line with name of owner
20 //
21 //=======================================================================
22 // owner: Valery Fine
23 // what it does:
24 //=======================================================================
25 //*-- Author : Valery Fine 21/07/98 (E-mail:fine@bnl.gov)
26 // #include "St_mevsim_Module.h"
27 void MakeHists(Char_t *xdffilename=
28  "/afs/rhic.bnl.gov/star/data/samples/gstar.dst.xdf")
29 {
30 
31  gROOT->Reset();
32  Bool_t NT = kFALSE;
33  if (strcmp(gSystem.GetName(),"WinNT")==0){
34  NT = kTRUE;
35  if (gSystem.Load("St_base.dll")) printf(" Loading DLL \"St_base.dll\" failed \n");
36  if (gSystem.Load("St_Tables.dll")) printf(" Loading DLL \"St_Tables.dll\" failed \n");
37  }
38  else{
39  if (gSystem.Load("St_base.so")) printf(" Loading DLL \"St_base.so\" failed \n");
40  if (gSystem.Load("xdf2root.so")) printf(" Loading DLL \"xdf2root.so\" failed \n");
41  if (gSystem.Load("St_Tables.so")) printf(" Loading DLL \"St_Tables.so\" failed \n");
42  }
43 
44 // Read XDF file
45  St_XDFFile xdf(xdffilename);
46  St_DataSet *event = xdf.NextEventGet();
47  if (!event) { printf(" NO events \n"); return;}
48  event->ls("*");
49  St_DataSet *set=0;
50  St_DataSetIter root(event);
51  set = root.Cd("/evgen/particle");
52  // set = root.Cd("/Event/hepe_gent");
53  if (set && set->HasData()) {
54  St_particle *pa = (St_particle *)set;
55  pa->ls("*");
56 
57  printf(" Checking the results \n");
58 
59  table_head_st *t1_h = pa->GetHeader();
60 
61  printf(" Name=%s type=%s t1_h.nok = %i \n", t1_h->name, t1_h->type, t1_h->nok);
62  printf(" t1_h.rbytes = %i \n", t1_h.rbytes);
63 
64  particle_st *particle = pa->GetTable();
65 
66  // Create "histograms"
67 
68 //*-* nt/plot 666.phep(3)
69 
70  TH1F *h1 = new TH1F("h1","phep(3)",100);
71  h1->SetFillColor(16);
72 
73 //*-* nt/plot 666.::sqrt(phep(1)**2+phep(2)**2) (0.ne.phep(1))
74 
75  TH1F *h1Sqrt=new TH1F("h1Sqrt","666.sqrt",100);
76 
77 
78 //*-* nt/plot 666.::log(tan(0.5*atan(phep(3)/::sqrt(phep(1)**2+phep(2)**2))+.7854)) (0.ne.phep(1))
79 
80  TH1F *h2Log1= new TH1F("h2Log1","666.log1",100);
81  h2Log1->SetFillColor(42);
82 
83 //*-* nt/plot 666.::log(tan(0.5*atan(phep(3)/::sqrt(phep(1)**2+phep(2)**2))+.7854)) (idhep.eq.211.or.idhep.eq.-211)\n");
84 
85  TH1F *h3Log2=new TH1F("h3Log2","666.log2",100);
86  h3Log2->SetFillColor(46);
87 
88  TSlider *slider = 0;
89 
90  Int_t kUPDATE = t1_h.nok/20;
91 
92 //*-* Create a canvas to show the result (based on root/tutorials/hsum.C )
93 
94  c1 = new TCanvas("c1","The reading STAF table: \"particle.h\"",200,10,600,800);
95  c1->SetGrid();
96  gBenchmark->Start("hsum");
97 
98  Int_t l = 0;
99  Int_t nev =0;
100  for (l=0; l < pa->GetNRows(); l++)
101  {
102  nev++;
103  particle_st *p = particle[l];
104 
105  //*-* Fill a'la nt/plot 666.phep(3)
106 
107  h1->Fill(p->phep[2]);
108  //
109  //
110  // Fill a'la nt/plot 666.::sqrt(phep(1)**2+phep(2)**2) (0.ne.phep(1))
111  // and
112  // nt/plot 666.::log(tan(0.5*atan(phep(3)/::sqrt(phep(1)**2+phep(2)**2))+.7854)) (0.ne.phep(1))
113  //
114  // in a single step because of the common condition: (0.ne.phep(1))
115  //
116 
117  // ****** be aware CINT feature -> Non standard expressions "**" follow
118 
119  if ( p->phep[0] != 0 )
120  {
121  h1Sqrt->Fill(::sqrt(p->phep[0]**2+p->phep[1]**2));
122  h2Log1->Fill(::sqrt(tan(0.5*atan(p->phep[2]/::sqrt(p->phep[0]**2+p->phep[1]**2))+.7854)));
123  }
124 
125  //*-*
126  //*-* Fill a'la nt/plot 666.::log(tan(0.5*atan(phep(3)/::sqrt(phep(1)**2+phep(2)**2))+.7854)) (idhep->eq.211.or.idhep->eq.-211)\n");
127  //
128  if ( p->idhep ==211 || p->idhep == -211)
129  h3Log2->Fill(::log(tan(0.5*atan(p->phep[2]/::sqrt(p->phep[0]**2+p->phep[1]**2))+.7854)));
130 
131  // Update the view of these histograms (just for fun)
132 
133  if (l && (l%kUPDATE) == 0) {
134  if (l == kUPDATE) {
135  h1Sqrt->Draw("e1p");
136  h2Log1->Draw("same");
137  h1->Draw("same");
138  h3Log2->Draw("same");
139  c1->Update();
140  slider = new TSlider("slider","test",1.05,0,1.1,h1Sqrt->GetMaximum()*1.3,38);
141  slider->SetFillColor(46);
142  }
143  if (slider) slider->SetRange(0,Float_t(l)/t1_h->nok);
144  c1->Modified();
145  c1->Update();
146  }
147  }
148 
149  slider->SetRange(0,1);
150  c1->Modified();
151  gBenchmark->Show("hsum");
152  }
153  printf(" This is a finish \n");
154  printf(" You may pick up this example from /afs/rhic.bnl.gov/star/packages/dev/StRoot/macros/MakeHists.cxx\n");
155 }
156 
char type[20]
Definition: table_header.h:13
virtual TDataSet * Cd(const Char_t *dirname)
virtual void ls(Option_t *option="") const
Definition: TDataSet.cxx:495
char name[20]
Definition: table_header.h:12