00001 00002 // $Id: StMiniEmbed.C,v 1.10 2007/09/09 17:30:17 fisyak Exp $ 00003 // owner: Manuel Calderon de la Barca Sanchez 00004 // 00005 // what it does: reads .geant.root file from emedding data, produces minimc.root file 00006 // runs a chain with the makers: 00007 // StMcEventMaker,StAssociationMaker, 00008 // StMiniMcEventMaker 00009 // Note: it is currently written to write into a specific directory structure in PDSF 00010 // so if one needs to run elsewhere, and the output directory doesn't have the same 00011 // lower level directory structure, no output files will be done. 00012 // $Log: StMiniEmbed.C,v $ 00013 // Revision 1.10 2007/09/09 17:30:17 fisyak 00014 // use bfc.C for loading shared libraries 00015 // 00016 // Revision 1.9 2006/09/29 01:32:12 calderon 00017 // use event branch instead of dst branch. 00018 // 00019 // Revision 1.8 2006/07/24 19:25:26 calderon 00020 // Load EEmcUtil, needed by StMcEvent. 00021 // 00022 // Revision 1.7 2004/03/30 03:16:14 calderon 00023 // Modifications for running in bfc. 00024 // - Changed to use StiIOInterface (IOMaker in normal mode, TreeMaker in bfc) 00025 // - Cleaned up Init(), InitRun() to handle the changing file names. 00026 // - Initialize lots of variables and pointers in constructor. 00027 // - Delete some pointers in Finish (deleting the TTree causes a seg fault, though.) 00028 // - Note that currently the StHits in the ITTF chain don't have a usedInFit() flag, 00029 // so there will be many messages complaining about this. 00030 // - Removed the mDebug data member, every Maker already has one, so change 00031 // to use that throughout the package. 00032 // 00033 // Revision 1.6 2003/07/09 01:07:23 calderon 00034 // Addition of FTPC reference multiplicity 00035 // Addition of other multiplicity values for StMiniMcEvent 00036 // Changes to reflect the use of the setters and getters, no longer 00037 // access the data members directly. 00038 // 00039 // Revision 1.5 2002/06/28 22:15:12 calderon 00040 // Changes to deal with seg. faults in the file name handling: 00041 // Conventions: 00042 // StMiniMcMaker looks for the input file from the IO maker to figure out 00043 // if the file has changed. This is done using TString::Contains() in Make(). 00044 // Usually we will run one file at a time, but in order not to break Bum's scheme of being 00045 // able to process several files in one go, this is left as is. However, for 00046 // embedding, the file name is not enough, in Eric's new scheme there are repeated 00047 // file names. This is resolved by adding a prefix to the output file name. However, 00048 // this prefix should not be overwritten, so the current code only replaces the 00049 // string inside the output file name pertaining to the input file name, and leaves 00050 // the prefix of the output file intact. This was done for embedding looking for 00051 // st_physics, and here is where the problem arose: hijing files begin with a different 00052 // prefix. To solve this problem, the input file name prefix is now an input parameter 00053 // in the macro. 00054 // 00055 // StMiniEmbed.C and StMiniHijing.C now conform to this convention. StMiniEmbed.C 00056 // did not change its prototype, because all embedding files have st_phyics as prefix. 00057 // StMiniHijing.C changed its prototype, now it takes as an input argument the prefix, 00058 // but in order not to break Jenn's scripts if she was already using this macro, 00059 // this parameter was added at the end and defaults to "rcf", which is appropriate 00060 // for hijing files reconstructed in rcf. 00061 // 00062 // Revision 1.4 2002/06/11 19:09:34 calderon 00063 // Bug fix: the filename that was set in the macro was being overwritten 00064 // in InitRun, so the emb80x string which was added to the filename was lost. 00065 // This was fixed by not replacing the filename in InitRun and only replacing 00066 // the current filename starting from st_physics. 00067 // 00068 // Revision 1.3 2002/06/07 02:21:48 calderon 00069 // Protection against empty vector in findFirstLastHit 00070 // 00072 00073 // const char* ffile="/auto/pdsfdv09/starprod/embedding/P01hj/HighpT_piminus_101/1243006_0003.26283/st_physics_1243006_raw_0003.dst.root"; 00074 //const char* ffile="/beta/starprod/embedding/P02gd/Rev/Piminus_801_minbias/2254002_0021.21333/st_physics_2254002_raw_0021.geant.root"; 00075 const char* ffile="/star/data16/reco/pp200/pythia6_205/0_2gev/cdf_a/y2004y/gheisha_on/p05ih/rcf1273_99_4000evts.geant.root"; 00076 void StMiniEmbed(Int_t nevents=2, 00077 const char* MainFile=ffile, 00078 const char* outDir = "./", 00079 int commonHits=3) 00080 { 00081 00082 cout << "Using : " << MainFile << endl; 00083 // 00084 // the string manipulations below are for use in PDSF, from 00085 // the /beta/starprod/embedding/ input directory 00086 // to the /auto/pdsfdv41/starprod/QA/McMiniDst/ output directory 00087 // 00088 TString outDirName = outDir; 00089 TString filename = MainFile; 00090 TString embedrun = MainFile; 00091 if (filename.Contains("Rev")) 00092 outDirName.Append("RevFullField/"); 00093 else 00094 outDirName.Append("FullField/"); 00095 00096 if (filename.Contains("Piminus")) 00097 outDirName.Append("PiMinus/"); 00098 if (filename.Contains("Piplus")) 00099 outDirName.Append("PiPlus/"); 00100 if (filename.Contains("KMinus")) 00101 outDirName.Append("KMinus/"); 00102 if (filename.Contains("KPlus")) 00103 outDirName.Append("KPlus/"); 00104 if (filename.Contains("Pbar")) 00105 outDirName.Append("Pbar/"); 00106 if (filename.Contains("Proton")) 00107 outDirName.Append("Proton/"); 00108 int embedRunIndex = embedrun.Index("_",0); 00109 embedrun.Remove(0,embedRunIndex+1); 00110 embedRunIndex = embedrun.Index("_",0); 00111 embedrun.Remove(embedRunIndex); 00112 int fileBeginIndex = filename.Index("st_physics",0); 00113 filename.Remove(0,fileBeginIndex); 00114 filename.Prepend(embedrun); 00115 filename.Prepend("emb"); 00116 cout << "outdir : " << outDirName << endl; 00117 cout << "Output : " << filename << endl; 00118 00119 gROOT->LoadMacro("bfc.C"); 00120 TString Chain("in,StEvent,gen_T,sim_T,readall,nodefault,minimcmk"); 00121 bfc(-1,Chain.Data(),MainFile,0,filename); 00122 // Define the cuts for the Associations 00123 00124 StMcParameterDB* parameterDB = StMcParameterDB::instance(); 00125 // TPC 00126 parameterDB->setXCutTpc(.5); // 5 mm 00127 parameterDB->setYCutTpc(.5); // 5 mm 00128 parameterDB->setZCutTpc(.5); // 5 mm 00129 parameterDB->setReqCommonHitsTpc(commonHits); // Require 3 hits in common for tracks to be associated 00130 // FTPC 00131 parameterDB->setRCutFtpc(.3); // 3 mm 00132 parameterDB->setPhiCutFtpc(5*(3.1415927/180.0)); // 5 degrees 00133 parameterDB->setReqCommonHitsFtpc(3); // Require 3 hits in common for tracks to be associated 00134 // SVT 00135 parameterDB->setXCutSvt(.08); // 800 um 00136 parameterDB->setYCutSvt(.08); // 800 um 00137 parameterDB->setZCutSvt(.08); // 800 um 00138 parameterDB->setReqCommonHitsSvt(1); // Require 1 hits in common for tracks to be associated 00139 00140 00141 // now execute the chain member functions 00142 00143 //chain->PrintInfo(); 00144 Int_t initStat = chain->Init(); // This should call the Init() method in ALL makers 00145 if (initStat) chain->Fatal(initStat, "during Init()"); 00146 00147 int istat=0,iev=1; 00148 EventLoop: if (iev<=nevents && istat!=2) { 00149 chain->Clear(); 00150 cout << "---------------------- Processing Event : " << iev << " ----------------------" << endl; 00151 istat = chain->Make(iev); // This should call the Make() method in ALL makers 00152 if (istat == 2) { cout << "Last Event Processed. Status = " << istat << endl; } 00153 if (istat == 3) { cout << "Error Event Processed. Status = " << istat << endl; } 00154 iev++; goto EventLoop; 00155 } // Event Loop 00156 00157 // chain->Finish(); 00158 00159 } 00160
1.5.9