Go to the documentation of this file.00001
00002 void treedrawgo4(const char* filename)
00003 {
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 gSystem->Load("$GO4SYS/Go4Example2Step/libGo4UserAnalysis.so");
00021
00022 TString fname(filename);
00023 if(!fname.EndsWith(".root")) fname.Append(".root");
00024 TGo4Analysis* go4=TGo4Analysis::Instance();
00025 go4->CloseAnalysis();
00026 go4->InitEventClasses();
00027
00028
00029
00030 TFile myfile(fname.Data());
00031
00032 TTree* theTree=0;
00033 TKey* kee=0;
00034 TIter iter(myfile.GetListOfKeys());
00035 while ( ( kee=dynamic_cast<TKey*>(iter()) ) !=0 ) {
00036 theTree = dynamic_cast<TTree*>(kee->ReadObj());
00037 if (theTree)
00038 break;
00039 }
00040 if(theTree)
00041 {
00042 go4->AddTree(theTree);
00043 go4->Message(1,"Loaded tree %s from file %s",theTree->GetName(),myfile.GetName());
00046
00047
00048
00049 TH2D* histo2d=go4->GetHistogram("map1");
00050 if(histo2d==0)
00051 {
00052 histo2d=new TH2D("map1","result of treedraw example",100,0,4000,100,0,4000);
00053 go4->AddHistogram(histo2d);
00054 }
00055 TH1D* histo1d=go4->GetHistogram("his1");
00056 if(histo1d==0)
00057 {
00058 histo1d=new TH1D("his1","result of treedraw example",4000,0,4000);
00059 go4->AddHistogram(histo1d);
00060 }
00061 gROOT->cd();
00062
00063 theTree->Draw("XXXAnlEvent.frData[0]:XXXAnlEvent.frData[1] >>+map1","XXXAnlEvent.frData[0]>500");
00064 theTree->Draw("XXXAnlEvent.frData[0]>>+his1");
00065 go4->Message(1,"Tree Draw has finished.");
00068
00069 go4->Message(1,"Please create dynamic entry for tree and press go4 start.");
00070 while(1)
00071 {
00072 if(go4->WaitForStart()<0) break;
00073 while(go4->Process()==0){;}
00074 }
00075 gROOT->SetInterrupt(kFALSE);
00076 go4->RemoveTree(theTree);
00077 }
00078 else
00079 {
00080 go4->Message(3,"No Tree in File %s", myfile->GetName());
00081 }
00082
00083 }