StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StMiniEmbed.C
1 // $Id: StMiniEmbed.C,v 1.10 2007/09/09 17:30:17 fisyak Exp $
3 // owner: Manuel Calderon de la Barca Sanchez
4 //
5 // what it does: reads .geant.root file from emedding data, produces minimc.root file
6 // runs a chain with the makers:
7 // StMcEventMaker,StAssociationMaker,
8 // StMiniMcEventMaker
9 // Note: it is currently written to write into a specific directory structure in PDSF
10 // so if one needs to run elsewhere, and the output directory doesn't have the same
11 // lower level directory structure, no output files will be done.
12 // $Log: StMiniEmbed.C,v $
13 // Revision 1.10 2007/09/09 17:30:17 fisyak
14 // use bfc.C for loading shared libraries
15 //
16 // Revision 1.9 2006/09/29 01:32:12 calderon
17 // use event branch instead of dst branch.
18 //
19 // Revision 1.8 2006/07/24 19:25:26 calderon
20 // Load EEmcUtil, needed by StMcEvent.
21 //
22 // Revision 1.7 2004/03/30 03:16:14 calderon
23 // Modifications for running in bfc.
24 // - Changed to use StiIOInterface (IOMaker in normal mode, TreeMaker in bfc)
25 // - Cleaned up Init(), InitRun() to handle the changing file names.
26 // - Initialize lots of variables and pointers in constructor.
27 // - Delete some pointers in Finish (deleting the TTree causes a seg fault, though.)
28 // - Note that currently the StHits in the ITTF chain don't have a usedInFit() flag,
29 // so there will be many messages complaining about this.
30 // - Removed the mDebug data member, every Maker already has one, so change
31 // to use that throughout the package.
32 //
33 // Revision 1.6 2003/07/09 01:07:23 calderon
34 // Addition of FTPC reference multiplicity
35 // Addition of other multiplicity values for StMiniMcEvent
36 // Changes to reflect the use of the setters and getters, no longer
37 // access the data members directly.
38 //
39 // Revision 1.5 2002/06/28 22:15:12 calderon
40 // Changes to deal with seg. faults in the file name handling:
41 // Conventions:
42 // StMiniMcMaker looks for the input file from the IO maker to figure out
43 // if the file has changed. This is done using TString::Contains() in Make().
44 // Usually we will run one file at a time, but in order not to break Bum's scheme of being
45 // able to process several files in one go, this is left as is. However, for
46 // embedding, the file name is not enough, in Eric's new scheme there are repeated
47 // file names. This is resolved by adding a prefix to the output file name. However,
48 // this prefix should not be overwritten, so the current code only replaces the
49 // string inside the output file name pertaining to the input file name, and leaves
50 // the prefix of the output file intact. This was done for embedding looking for
51 // st_physics, and here is where the problem arose: hijing files begin with a different
52 // prefix. To solve this problem, the input file name prefix is now an input parameter
53 // in the macro.
54 //
55 // StMiniEmbed.C and StMiniHijing.C now conform to this convention. StMiniEmbed.C
56 // did not change its prototype, because all embedding files have st_phyics as prefix.
57 // StMiniHijing.C changed its prototype, now it takes as an input argument the prefix,
58 // but in order not to break Jenn's scripts if she was already using this macro,
59 // this parameter was added at the end and defaults to "rcf", which is appropriate
60 // for hijing files reconstructed in rcf.
61 //
62 // Revision 1.4 2002/06/11 19:09:34 calderon
63 // Bug fix: the filename that was set in the macro was being overwritten
64 // in InitRun, so the emb80x string which was added to the filename was lost.
65 // This was fixed by not replacing the filename in InitRun and only replacing
66 // the current filename starting from st_physics.
67 //
68 // Revision 1.3 2002/06/07 02:21:48 calderon
69 // Protection against empty vector in findFirstLastHit
70 //
72 
73 // const char* ffile="/auto/pdsfdv09/starprod/embedding/P01hj/HighpT_piminus_101/1243006_0003.26283/st_physics_1243006_raw_0003.dst.root";
74 //const char* ffile="/beta/starprod/embedding/P02gd/Rev/Piminus_801_minbias/2254002_0021.21333/st_physics_2254002_raw_0021.geant.root";
75 const char* ffile="/star/data16/reco/pp200/pythia6_205/0_2gev/cdf_a/y2004y/gheisha_on/p05ih/rcf1273_99_4000evts.geant.root";
76 void StMiniEmbed(Int_t nevents=2,
77  const char* MainFile=ffile,
78  const char* outDir = "./",
79  int commonHits=3)
80 {
81 
82  cout << "Using : " << MainFile << endl;
83  //
84  // the string manipulations below are for use in PDSF, from
85  // the /beta/starprod/embedding/ input directory
86  // to the /auto/pdsfdv41/starprod/QA/McMiniDst/ output directory
87  //
88  TString outDirName = outDir;
89  TString filename = MainFile;
90  TString embedrun = MainFile;
91  if (filename.Contains("Rev"))
92  outDirName.Append("RevFullField/");
93  else
94  outDirName.Append("FullField/");
95 
96  if (filename.Contains("Piminus"))
97  outDirName.Append("PiMinus/");
98  if (filename.Contains("Piplus"))
99  outDirName.Append("PiPlus/");
100  if (filename.Contains("KMinus"))
101  outDirName.Append("KMinus/");
102  if (filename.Contains("KPlus"))
103  outDirName.Append("KPlus/");
104  if (filename.Contains("Pbar"))
105  outDirName.Append("Pbar/");
106  if (filename.Contains("Proton"))
107  outDirName.Append("Proton/");
108  int embedRunIndex = embedrun.Index("_",0);
109  embedrun.Remove(0,embedRunIndex+1);
110  embedRunIndex = embedrun.Index("_",0);
111  embedrun.Remove(embedRunIndex);
112  int fileBeginIndex = filename.Index("st_physics",0);
113  filename.Remove(0,fileBeginIndex);
114  filename.Prepend(embedrun);
115  filename.Prepend("emb");
116  cout << "outdir : " << outDirName << endl;
117  cout << "Output : " << filename << endl;
118 
119  gROOT->LoadMacro("bfc.C");
120  TString Chain("in,StEvent,gen_T,sim_T,readall,nodefault,minimcmk");
121  bfc(-1,Chain.Data(),MainFile,0,filename);
122  // Define the cuts for the Associations
123 
124  StMcParameterDB* parameterDB = StMcParameterDB::instance();
125  // TPC
126  parameterDB->setXCutTpc(.5); // 5 mm
127  parameterDB->setYCutTpc(.5); // 5 mm
128  parameterDB->setZCutTpc(.5); // 5 mm
129  parameterDB->setReqCommonHitsTpc(commonHits); // Require 3 hits in common for tracks to be associated
130  // FTPC
131  parameterDB->setRCutFtpc(.3); // 3 mm
132  parameterDB->setPhiCutFtpc(5*(3.1415927/180.0)); // 5 degrees
133  parameterDB->setReqCommonHitsFtpc(3); // Require 3 hits in common for tracks to be associated
134  // SVT
135  parameterDB->setXCutSvt(.08); // 800 um
136  parameterDB->setYCutSvt(.08); // 800 um
137  parameterDB->setZCutSvt(.08); // 800 um
138  parameterDB->setReqCommonHitsSvt(1); // Require 1 hits in common for tracks to be associated
139 
140 
141  // now execute the chain member functions
142 
143  //chain->PrintInfo();
144  Int_t initStat = chain->Init(); // This should call the Init() method in ALL makers
145  if (initStat) chain->Fatal(initStat, "during Init()");
146 
147  int istat=0,iev=1;
148  EventLoop: if (iev<=nevents && istat!=2) {
149  chain->Clear();
150  cout << "---------------------- Processing Event : " << iev << " ----------------------" << endl;
151  istat = chain->Make(iev); // This should call the Make() method in ALL makers
152  if (istat == 2) { cout << "Last Event Processed. Status = " << istat << endl; }
153  if (istat == 3) { cout << "Error Event Processed. Status = " << istat << endl; }
154  iev++; goto EventLoop;
155  } // Event Loop
156 
157 // chain->Finish();
158 
159 }
160 
virtual void Clear(Option_t *option="")
User defined functions.
Definition: StChain.cxx:77
virtual Int_t Make()
Definition: StChain.cxx:110