00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 void par_anal(Char_t *xdffilename="/afs/rhic.bnl.gov/star/packages/dev/StRoot/macros/data/test.xdf")
00018 {
00019
00020
00021 gROOT->Reset();
00022 Bool_t NT = kFALSE;
00023 if (strcmp(gSystem.GetName(),"WinNT")==0){
00024 NT = kTRUE;
00025 if (gSystem.Load("St_base.dll")) printf(" Loading DLL \"St_base.dll\" failed \n");
00026 if (gSystem.Load("St_Tables.dll")) printf(" Loading DLL \"St_Tables.dll\" failed \n");
00027 }
00028 else{
00029 if (gSystem.Load("St_base.so")) printf(" Loading DLL \"St_base.so\" failed \n");
00030 if (gSystem.Load("xdf2root.so")) printf(" Loading DLL \"xdf2root.so\" failed \n");
00031 if (gSystem.Load("St_Tables.so")) printf(" Loading DLL \"St_Tables.so\" failed \n");
00032 }
00033
00034
00035
00036 printf(" File: \"%s\" \n", xdffilename);
00037 St_XDFFile xdf;
00038 if (xdf.OpenXDF(xdffilename)){
00039 printf("Can not open file %s \n",xdffilename);
00040 return;
00041 }
00042
00043
00044
00045 Bool_t drawinit=kFALSE;
00046 Int_t nxpt = 50;
00047 Int_t nyetha = 50;
00048 Float_t xminpt = 0.0;
00049 Float_t xmaxpt = 5.0;
00050 Float_t yminetha = -4.0;
00051 Float_t ymaxetha = 4.0;
00052
00053 TH2F *h1 = new TH2F("h1","Particle pt",nxpt,xminpt,xmaxpt,nyetha,yminetha,ymaxetha);
00054 h1->SetXTitle("pt (GeV)");
00055 h1->SetYTitle("etha (rad) ");
00056 TH2F *h2 = new TH2F("h2","Particle etha",nxpt,xminpt,xmaxpt,nyetha,yminetha,ymaxetha);
00057 h2->SetXTitle("pt (GeV)");
00058 h2->SetYTitle("etha (rad)");
00059 TH1F *h3 = new TH1F("h3","Particle multiplicity",2,0.5,2.5);
00060
00061
00062
00063 c1 = new TCanvas("c1","Particle pt by reading STAF table: \"particle.h\"",200,10,600,400);
00064 c2 = new TCanvas("c2","Particle etha by reading STAF table: \"particle.h\"",200,410,600,400);
00065 c3 = new TCanvas("c3","Particle multiplicity by reading STAF table: \"particle.h\"",800,100,250,250);
00066 c1->SetGrid();
00067 c2->SetGrid();
00068
00069 TSlider *slider = 0;
00070
00071 St_DataSet *event = 0;
00072 gBenchmark->Start("hsum");
00073 while (event = xdf.NextEventGet() )
00074 {
00075 St_DataSetIter root(event);
00076 St_DataSet *set = root.Cd("/evgen/particle");
00077 if (set) {
00078 set->ls("*");
00079 printf(" Getting the tables \n");
00080
00081 St_particle *pa= (St_particle *)set;
00082 particle_st *particle = pa->GetTable();
00083
00084
00085 Int_t kUPDATE = pa->GetNRows()/5;
00086
00087 Int_t l = 0;
00088 for (l=0; l < pa->GetNRows(); l++)
00089 {
00090 particle_st *p = particle+l;
00091 if (p->isthep == 1) {
00092 Float_t px = p->phep[0];
00093 Float_t py = p->phep[1];
00094 Float_t pz = p->phep[2];
00095 Double_t pt = TMath::Sqrt(px*px+py*py);
00096
00097 Double_t theta = atan2 ( pt, pz );
00098 Double_t eta = -TMath::Log(TMath::Tan(theta/2.));
00099
00100 if (p->idhep==211) {
00101 h3->Fill(1);
00102 h1->Fill(pt,eta);
00103 }
00104 else if (TMath::Abs(p->idhep) == 2212) {
00105 h3->Fill(2);
00106 if (TMath::Abs(eta) < 20)
00107 h2->Fill(pt,eta);
00108 }
00109 }
00110
00111
00112 if (l && (l%kUPDATE) == 0) {
00113 if ( l==kUPDATE && !drawinit) {
00114 drawinit = kTRUE;
00115 c2->cd();
00116 h2->Draw();
00117 c1->cd();
00118 h1->Draw();
00119 c3->cd();
00120 h3->Draw("lego3");
00121 slider = new TSlider("slider","test",1.05,0,1.1,h1->GetMaximum()*1.3,38);
00122 slider->SetFillColor(46);
00123 c1->Update();
00124 c2->Update();
00125 c3->Update();
00126 }
00127 if (slider) slider->SetRange(0,Float_t(l)/pa->GetNRows());
00128 c1->Modified();
00129 c1->Update();
00130 c2->Modified();
00131 c2->Update();
00132 c3->Modified();
00133 c3->Update();
00134
00135 }
00136 }
00137 }
00138
00139
00140 if (event) delete event;
00141 event = 0;
00142 }
00143 c1->Modified();
00144 c2->Modified();
00145 c3->Modified();
00146 printf("\n");
00147 gBenchmark->Show("hsum");
00148 printf(" This is a finish \n");
00149 printf(" You may pick up this example from /afs/rhic.bnl.gov/star/packages/dev/StRoot/macros/par_anal.cxx\n");
00150 }
00151