StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
RunJetSimuFinder.C
1 // NOTE - This macro is ONLY for running MC simulation data!!
2 // If using StJetSimuWeightMaker class on simulation data before 2004 you will
3 // need to comment out all references to St_g2t_pythia class. These tables
4 // were not included until 2004
5 //=========================================================================================
6 class StChain *chain;
7 int total=0;
8 #include <string>
9 
10 void RunJetSimuFinder(
11  int nevents = 100,
12  const char* file="/star/data40/reco/pp200/pythia6_205/above_35gev/cdf_a/y2004y/gheisha_on/trs_p05ie/rcf1230_10_4000evts.MuDst.root",
13  const char *fname="/star/data40/reco/pp200/pythia6_205/above_35gev/cdf_a/y2004y/gheisha_on/trs_p05ie/rcf1230_10_4000evts.event.root",
14  //const char* file="/star/institutions/lbl/kiryluk/Herwig_test/rcf1250_*.MuDst.root",
15  //const char *fname="/star/institutions/lbl/kiryluk/Herwig_test/rcf1250_*.event.root",
16  const char *outfile="Jets_out.root",
17  const char *soutfile="Simu_out.root"
18  )
19 
20 {
21  const char *dir ="";
22  const char *filter = "";
23 
24  if (gClassTable->GetID("TTable") < 0) {
25  gSystem->Load("libStar");
26  gSystem->Load("libPhysics");
27  }
28  gROOT->LoadMacro("$STAR/StRoot/StMuDSTMaker/COMMON/macros/loadSharedLibraries.C");
29  loadSharedLibraries();
30  //gSystem->Load("StMagF");
31  gSystem->Load("StTpcDb");
32  gSystem->Load("StDbUtilities");
33  gSystem->Load("StMcEvent");
34  gSystem->Load("StMcEventMaker");
35  gSystem->Load("StDaqLib");
36  gSystem->Load("StEmcRawMaker");
37  gSystem->Load("StEmcADCtoEMaker");
38  gSystem->Load("StPreEclMaker");
39  gSystem->Load("StEpcMaker");
40  gSystem->Load("StEmcSimulatorMaker");
41  gSystem->Load("StEmcUtil");
42  gSystem->Load("StDbBroker");
43  gSystem->Load("StDetectorDbMaker");
44  gSystem->Load("St_db_Maker");
45  gSystem->Load("StEEmcUtil");// needed by EEMC-Db
46  gSystem->Load("StEEmcDbMaker");
47  gSystem->Load("StEmcTriggerMaker");
48  gSystem->Load("StSpinDbMaker");
49  gSystem->Load("StJetFinder");
50  gSystem->Load("StJetMaker");
51 
52  double pi = atan(1.0)*4.0;
53  cout << " loading done " << endl;
54 
55  chain= new StChain("StChain");
56  chain->SetDebug(1);
57  gMessMgr->SwitchOff("D");
58  gMessMgr->SwitchOff("I");
59 
60  //StIOMaker - to read geant files
61  StIOMaker* ioMaker = new StIOMaker();
62  ioMaker->SetFile(fname);
63  ioMaker->SetIOMode("r");
64  ioMaker->SetBranch("*",0,"0"); //deactivate all branches
65  ioMaker->SetBranch("geantBranch",0,"r"); //activate geant Branch
66 
67  // Instantiate StMcEventMaker - to get pythia pid from McEvent
68  class StMcEventMaker *mcEventMaker = new StMcEventMaker();
69  mcEventMaker->doPrintEventInfo = false;
70  mcEventMaker->doPrintMemoryInfo = false;
71 
72  //Instantiate the MuDstReader
74  StMuDstMaker* muDstMaker = new StMuDstMaker(0,0,dir,file,filter,1e6,"MuDst");
75 
76  //Database -- get a real calibration (this is ok, MLM)
77  St_db_Maker* dbMk = new St_db_Maker("db","$HOME/StarDb","MySQL:StarDb","$STAR/StarDb");
78  dbMk->SetDateTime(20040427,101529); //run 5118011 status in DBx
79 
80  // ideal gains
81  //St_db_Maker *dbMk =new St_db_Maker("db","MySQL:StarDb","$STAR/StarDb","StarDb");
82  //dbMk->SetDateTime(20031120,0);
83  //dbMk->SetFlavor("sim","bemcPed");
84  //dbMk->SetFlavor("sim","bemcStatus");
85  //dbMk->SetFlavor("sim","bemcCalib");
86  //dbMk->SetFlavor("sim","bemcGain");
87  //dbMk->SetFlavor("sim","eemcPMTcal");
88  //dbMk->SetFlavor("sim","eemcPIXcal");
89 
90 
91  //Database interface
92  StDetectorDbMaker* detDbMk = new StDetectorDbMaker();
93 
94  //Endcap DB
95  StEEmcDbMaker* eemcb = new StEEmcDbMaker("eemcDb");
96 
97  //get BEMC calibration (this is ok, MLM)
98  //StEmcADCtoEMaker *adc = new StEmcADCtoEMaker(); // this will just convert what's in MuDst to ADC, use for data only!
99  StEmcSimulatorMaker* emcSim = new StEmcSimulatorMaker(); //use this instead to "redo" converstion from geant->adc
100  StPreEclMaker* preEcl = new StPreEclMaker(); //need this to fill new StEvent information
101 
102  //Alex/Mike TrigMaker
103  StJetEmcTrigSim *htTrig = new StJetEmcTrigSim("StJetEmcTrigSim",dbMk,muDstMaker);
104 
105  //StEmcTrigger
106  //Need to uncomment StEmcTrigger and StBemcTrigger lines in StJetSimuTrigMaker and StJetSimuTreeMaker
107  StEmcTriggerMaker *emcTrig = new StEmcTriggerMaker("bemctrigger");
108  emcTrig->setDbMaker(dbMk);
109 
110  //Instantiate Trigger maker for simulation
111  StJetSimuTrigMaker *trig = new StJetSimuTrigMaker("SimuTrig");
112  trig->setPrintOption(0);
113 
114  //Instantiate Maker with Pythia event record etc for simulation
115  StJetSimuWeightMaker *weight = new StJetSimuWeightMaker("SimuWeight");
116  weight->setPrintOption(0);
117  weight->setUnpolPDF(101);//cteq
118  weight->setPolPDF(103);//grsv
119 
120  //Instantiate Tree Maker for simulation
121  StJetSimuTreeMaker *stree = new StJetSimuTreeMaker("SimuTree",soutfile);
122  stree->setPrintOption(0);
123 
124  //test Mike's new 4p maker:
125  bool doTowerSwapFix = false;
126  StBET4pMaker* bet4pMaker = new StBET4pMaker("BET4pMaker",muDstMaker, doTowerSwapFix);
127 
128  //Pythia4pMaker
129  StPythiaFourPMaker* pythiaFourPMaker = new StPythiaFourPMaker("StPythiaFourPMaker",weight, mcEventMaker);
130 
131  //Instantiate the JetMaker
132  StJetMaker* emcJetMaker = new StJetMaker("emcJetMaker", muDstMaker, outfile);
133 
134  //Instantiate Jet Histogram Maker
135  // StJetHistMaker* jetHistMaker = new StJetHistMaker(muDstMaker, histfile.Data() );
136 
137  //Now setup 3 jet analyses that use the same track/jet cuts
138  //set the analysis cuts: (see StJetMaker/StppJetAnalyzer.h -> class StppAnaPars )
139  StppAnaPars* anapars = new StppAnaPars();
140  anapars->setFlagMin(0); //track->flag() > 0
141  anapars->setNhits(20); //track->nHitsFit()>20 (changed in cvs by MLM, 2/24/06)
142  anapars->setCutPtMin(0.2); //track->pt() > 0.2
143  anapars->setAbsEtaMax(1.6); //abs(track->eta())<1.6
144  anapars->setJetPtMin(3.0);
145  anapars->setJetEtaMax(100.0);
146  anapars->setJetEtaMin(0);
147  anapars->setJetNmin(0);
148 
149  //Setup the kt finder for measured particles (See StJetFinder/StKtCluFinder.h -> class StKtCluPars)
150  //StKtCluPars* ktpars = new StKtCluPars();
151  //ktpars->setR(0.7);
152  //ktpars->setDebug(false);
153  //emcJetMaker->addAnalyzer(anapars, ktpars, bet4pMaker, "KtJet");
154 
155 
156  //Setup the cone finder with R=0.4
157  StConePars* cpars4 = new StConePars();
158  cpars4->setGridSpacing(56, -1.6, 1.6, 120, -pi, pi);
159  cpars4->setConeRadius(0.4);
160  cpars4->setSeedEtMin(0.5);
161  cpars4->setAssocEtMin(0.1);
162  cpars4->setSplitFraction(0.5);
163  cpars4->setPerformMinimization(true);
164  cpars4->setAddMidpoints(true);
165  cpars4->setRequireStableMidpoints(true);
166  cpars4->setDoSplitMerge(true);
167  cpars4->setDebug(false);
168  emcJetMaker->addAnalyzer(anapars, cpars4, bet4pMaker, "MkConeR04");
169 
170  //set the analysis cuts for pythia clustering: (see StJetMaker/StppJetAnalyzer.h -> class StppAnaPars )
171  StppAnaPars* pythiapars = new StppAnaPars();
172  pythiapars->setFlagMin(0);
173  pythiapars->setNhits(0);
174  pythiapars->setCutPtMin(0.0001);
175  pythiapars->setAbsEtaMax(5.0);
176  pythiapars->setJetPtMin(3.0);
177  pythiapars->setJetEtaMax(5.0);
178  pythiapars->setJetEtaMin(0);
179  pythiapars->setJetNmin(0);
180 
181  //Setup the kt finder for measured particles (See StJetFinder/StKtCluFinder.h -> class StKtCluPars)
182  //StKtCluPars* pythia_ktpars = new StKtCluPars();
183  //pythia_ktpars->setR(0.7);
184  //pythia_ktpars->setDebug(false);
185  //emcJetMaker->addAnalyzer(pythiapars, pythia_ktpars, pythiaFourPMaker, "PyKtJet");
186 
187 
188  StConePars* pythia_cpars4 = new StConePars();
189  pythia_cpars4->setGridSpacing(200, -5.0, 5.0, 120, -pi, pi);
190  pythia_cpars4->setConeRadius(0.4);
191  pythia_cpars4->setSeedEtMin(0.5);
192  pythia_cpars4->setAssocEtMin(0.1);
193  pythia_cpars4->setSplitFraction(0.5);
194  pythia_cpars4->setPerformMinimization(true);
195  pythia_cpars4->setAddMidpoints(true);
196  pythia_cpars4->setRequireStableMidpoints(true);
197  pythia_cpars4->setDoSplitMerge(true);
198  pythia_cpars4->setDebug(false);
199  emcJetMaker->addAnalyzer(pythiapars, pythia_cpars4, pythiaFourPMaker, "PythiaConeR04");
200 
201  chain->Init();
202  chain->PrintInfo();
203 
204  //Note: ------------ Must do this stuff after Init()
205  int controlVal = 2;
206  controlEmcSimulatorMaker_st* simControl = emcSim->getControlSimulator()->GetTable();
207  simControl->keyDB[0] = controlVal;
208  simControl->keyDB[1] = 0;
209  simControl->keyDB[2] = controlVal;
210  simControl->keyDB[3] = controlVal;
211  //keyDB[det] = 0 -> NO database (default value)
212  // = 1 - only gains are applied
213  // = 2 - gains and pedestals are applied
214  // In other words, for pure MC should be 2, and
215  // for embedding should be 1.
216 
217  chain->ls(3);
218 
219  TChain* fileChain = muDstMaker->chain();
220  assert(fileChain);
221  int ntotal = fileChain->GetEntries();
222 
223  for (Int_t iev=0;iev<nevents; iev++) {
224  cout << "****************************************** " << endl;
225  cout << "Working on eventNumber:\t" << iev <<"\tof:\t"<<ntotal<<endl;
226  cout << "*************************1***************** " << endl;
227  chain->Clear();
228  int iret = chain->Make(iev);
229  total++;
230  if (iret) {
231  cout << "Bad return code!" << endl;
232  break;
233  }
234  }
235 
236  chain->Finish();
237  cout << "****************************************** " << endl;
238  cout << "total number of events " << total << endl;
239  cout << "****************************************** " << endl;
240 }
241 
242 
243 
void setConeRadius(double v)
Set cone radius:
Definition: StConePars.h:65
void setAddMidpoints(bool v)
Add seeds at midpoints?
Definition: StConePars.h:56
virtual void SetIOMode(Option_t *iomode="w")
number of transactions
Definition: StIOInterFace.h:35
virtual void Clear(Option_t *option="")
User defined functions.
Definition: StChain.cxx:77
void setSplitFraction(double v)
split jets if E_shared/E_neighbor&gt;splitFraction
Definition: StConePars.h:50
static void setLevel(unsigned int level)
sets the debug level
Definition: StMuDebug.h:74
void setGridSpacing(int nEta, double etaMin, double etaMax, int nPhi, double phiMin, double phiMax)
Set the grid spacing:
Definition: StConePars.h:36
virtual Int_t Finish()
Definition: StChain.cxx:85
void setDoSplitMerge(bool v)
Do Split/Merge step?
Definition: StConePars.h:59
void setDebug(bool v)
Toggle debug streams on/off.
Definition: StConePars.h:68
Filling of all StMcEvent classes from g2t tables Transform all the data in the g2t tables into the co...
void setSeedEtMin(double v)
minimum et threshold to be considered a seed
Definition: StConePars.h:44
virtual void ls(Option_t *option="") const
Definition: TDataSet.cxx:495
Bool_t doPrintMemoryInfo
lots of screen output
virtual Int_t Make()
Definition: StChain.cxx:110
void setAssocEtMin(double v)
minimum et threshold to be considered for addition to the seed
Definition: StConePars.h:47
TChain * chain()
In read mode, returns pointer to the chain of .MuDst.root files that where selected.
Definition: StMuDstMaker.h:426
void setRequireStableMidpoints(bool v)
Require stable midpoints?
Definition: StConePars.h:62
void setPerformMinimization(bool v)
Let jet wander to minimum?
Definition: StConePars.h:53