StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
MakeMiniMcTree.C
1 // $Id: MakeMiniMcTree.C,v 1.2 2008/12/29 16:12:49 kocolosk Exp $
2 
3 /*****************************************************************************
4  * @author Adam Kocoloski
5  *
6  * macro to regenerate MiniMc tree, since it gets removed from disk sometimes
7  *****************************************************************************/
8 
9 void MakeMiniMcTree(Int_t nevents=3,
10  const char* MainFile="hijing_b0_3/rcf0147_01*geant.root",
11  const char* outDir = "./",
12  TString filePrefix="rcf")
13 {
14  gROOT->Macro("LoadLogger.C");
15  gSystem->Load("St_base");
16  gSystem->Load("StChain");
17  gSystem->Load("St_Tables");
18  gSystem->Load("StUtilities");
19  gSystem->Load("StIOMaker");
20  gSystem->Load("StarClassLibrary");
21  gSystem->Load("StDetectorDbMaker");
22  gSystem->Load("StTpcDb");
23  gSystem->Load("StEvent");
24  gSystem->Load("StEventMaker");
25  gSystem->Load("StEmcUtil");
26  gSystem->Load("StEEmcUtil");
27  gSystem->Load("StMcEvent");
28  gSystem->Load("StMcEventMaker");
29  gSystem->Load("StAssociationMaker");
30  gSystem->Load("StMcAnalysisMaker");
31  gSystem->Load("StMiniMcEvent");
32  gSystem->Load("StMiniMcMaker");
33 
34  StChain chain;
35 
36  StIOMaker ioMk("IO","r",MainFile,"bfcTree");
37  ioMk.SetIOMode("r");
38  ioMk.SetBranch("*",0,"0");
39  ioMk.SetBranch("geantBranch",0,"r");
40  ioMk.SetBranch("eventBranch",0,"r");
41 
42  StMcEventMaker mcEventMk;
43 
44  StAssociationMaker assocMk;
45  assocMk.useInTracker();
46 
47  TString filename = MainFile;
48  int fileBeginIndex = filename.Index(filePrefix,0);
49  filename.Remove(0,fileBeginIndex);
50 
51  StMiniMcMaker miniMcMk;
52  miniMcMk.setOutDir(outDir);
53  miniMcMk.setPtCut(1.5);
54  miniMcMk.setFileName(filename);
55  miniMcMk.setFilePrefix(filePrefix);
56 
57  StMcParameterDB* parameterDB = StMcParameterDB::instance();
58  parameterDB->setXCutTpc(.5); // 5 mm
59  parameterDB->setYCutTpc(.5); // 5 mm
60  parameterDB->setZCutTpc(.5); // 5 mm
61  parameterDB->setReqCommonHitsTpc(3);
62 
63  TStopwatch total;
64  TStopwatch timer;
65  TMemStat memory;
66 
67  chain.Init();
68 
69  int i=0;
70  while(i<nevents && chain.Make()==kStOk) {
71  if(i % 500 == 0) {
72  cout << "done with event " << i
73  << "\tcpu: " << timer.CpuTime()
74  << "\treal: " << timer.RealTime()
75  << "\tratio: " << timer.CpuTime()/timer.RealTime() << endl;
76  timer.Start();
77  memory.PrintMem(NULL);
78  }
79  ++i;
80  chain.Clear();
81  }
82 
83  chain.Finish();
84  cout << "my macro processed " << i << " events"
85  << "\tcpu: " << total.CpuTime()
86  << "\treal: " << total.RealTime()
87  << "\tratio: " << total.CpuTime()/total.RealTime() << endl;
88 }
89 
90 /*****************************************************************************
91  * $Log: MakeMiniMcTree.C,v $
92  * Revision 1.2 2008/12/29 16:12:49 kocolosk
93  * added $Id$/$Log$ as needed
94  *
95  * Revision 1.1 2008/07/18 16:57:41 kocolosk
96  * macro to regenerate MiniMc tree, since it gets removed from disk sometimes
97  *
98  *****************************************************************************/
virtual void Clear(Option_t *option="")
User defined functions.
Definition: StChain.cxx:77
virtual Int_t Finish()
Definition: StChain.cxx:85
Filling of all StMcEvent classes from g2t tables Transform all the data in the g2t tables into the co...
virtual Int_t Make()
Definition: StChain.cxx:110
Definition: Stypes.h:41