StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
RunJetSimuSkimReader.C
1 class StChain;
2 StChain *chain;
3 int total=0;
4 TObjArray *HList=0;
5 TFile *fd=0;
6 
7 void RunJetSimuSkimReader(int nevents=100,
8  const char* jetInFile = "/star/institutions/uky/jettrees/jets_pt35_01.root",
9  const char* skimInFile = "/star/institutions/uky/jettrees/skim_pt35_01.root",
10  const char* histfile = "pt35.hist.root")
11 {
12 
13 
14  //setMacroPath();
15  //gROOT->Macro("LoadJetLibraries.C");
16 
17  // Load shared libraries
18  gROOT->Macro("loadMuDst.C");
19  gSystem->Load("StTpcDb");
20  gSystem->Load("StDetectorDbMaker");
21  gSystem->Load("StDbUtilities");
22  gSystem->Load("StMcEvent");
23  gSystem->Load("StMcEventMaker");
24  gSystem->Load("StDaqLib");
25  gSystem->Load("StEmcRawMaker");
26  gSystem->Load("StEmcADCtoEMaker");
27  gSystem->Load("StEpcMaker");
28  gSystem->Load("StEmcSimulatorMaker");
29  gSystem->Load("StDbBroker");
30  gSystem->Load("St_db_Maker");
31  gSystem->Load("StEEmcUtil");
32  gSystem->Load("StEEmcDbMaker");
33  gSystem->Load("StSpinDbMaker");
34  gSystem->Load("StEmcTriggerMaker");
35  gSystem->Load("StTriggerUtilities");
36  gSystem->Load("StMCAsymMaker");
37  gSystem->Load("StJetFinder");
38  gSystem->Load("StJetSkimEvent");
39  gSystem->Load("StJets");
40  gSystem->Load("StJetMaker");
41 
42  double pi = atan(1.0)*4.0;
43  cout << " loading done " << endl;
44 
45  chain= new StChain("StChain");
46  chain->SetDebug(1);
47  gMessMgr->SwitchOn("D");
48  gMessMgr->SwitchOff("I");
49 
50  //Instantiate the JetReader
51  StJetSimuReader* jetReader = new StJetSimuReader("JetReader",0);
52 
53  chain->Init();
54 
55  //these 3 lines are critical and must be called after chain->Init()
56  //Call in exactly this order
57  jetReader->InitFile(jetInFile);
58  jetReader->InitJetSkimFile(skimInFile);
59  int ready = jetReader->preparedForDualRead();
60  HList=new TObjArray ;
61  //jetReader->SetHList(HList);
62  //jetReader->PythiaAnaHisto();
63 
64  chain->PrintInfo();
65 
66  for (Int_t iev=0;iev<nevents; iev++) {
67  cout << "****************************************** " << endl;
68  cout << "Working on eventNumber " << iev << endl;
69  cout << "*************************1***************** " << endl;
70  chain->Clear();
71  int iret = chain->Make(iev);
72  total++;
73  if (iret) {
74  cout << "Bad return code!" << endl;
75  break;
76  }
77  //Here's where you can do your analysis, for an example look in this method
78  //jetReader->PythiaAna();
79  }
80  chain->Finish();
81  cout << "****************************************** " << endl;
82  cout << "total number of events " << total << endl;
83  cout << "****************************************** " << endl;
84 
85 
86  fd=new TFile(histfile,"recreate");
87  cout<<"Opening "<<histfile<<endl;
88  assert(fd->IsOpen());
89  cout<<"Open Baby!"<<endl;
90  HList->Write();
91  printf("%d histos are written to '%s' ...\n",HList->GetEntries(),fd->GetName());
92  fd->Close();
93 
94 }
95 
96 void setMacroPath()
97  {
98  TString path(gROOT->GetMacroPath());
99  path = TString(gSystem->Getenv("STAR")) + "/StRoot/StJetMaker/macros:" + path;
100  path = "./StRoot/StJetMaker/macros:" + path;
101  path = "./StJetMaker/macros:" + path;
102  path = "./macros:" + path;
103  path = "../macros:" + path;
104  path = ".:" + path;
105  gROOT->SetMacroPath(path);
106  }
107 
108 
virtual void Clear(Option_t *option="")
User defined functions.
Definition: StChain.cxx:77
virtual Int_t Finish()
Definition: StChain.cxx:85
virtual Int_t Make()
Definition: StChain.cxx:110
virtual void InitJetSkimFile(const char *file)
Recover the &quot;fast&quot; tree of StJetSkimEvent.
virtual void InitFile(const char *file)
Recover the TTree from file and prepare for reading.
int preparedForDualRead()
Check if we are all ready to read the Skim and Jet trees together.