StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
doEStructGevsim.C
1 void doEStructGevsim(int numEvents, const char* outputDir, const char* cutFile, const char* jobName=0, int cutBinMode=0, int analysisMode = 0){
2 
3  // libraries required and helper macros in $STAR/StRoot/StEStructPool/macros
4  gROOT->LoadMacro("load2ptLibs.C");
5  load2ptLibs();
6  gROOT->LoadMacro("getOutFileName.C");
7  gROOT->LoadMacro("support.C");
8 
9  const char* evtCutFile=cutFile;
10  const char* trackCutFile=evtCutFile;
11  const char* pairCutFile =evtCutFile;
12 
13  // For documentation on how to use gevsim, visit:
14  // http://www.star.bnl.gov/protected/estruct/msd/gevsim.html
15 
16  // *** gevsim ***
17  gSystem->Load("libEG.so");
18  gSystem->Load("libPhysics.so");
19  gSystem->Load("StEStructPoolGevsim.so");
20  gSystem->Load("StEStructPoolEventGenerators.so");
21 
22  // add particles
23  TGeVSim *gener = new TGeVSim("GeVSim", 0);
24  TGeVSimParticle *pip = new TGeVSimParticle(211, TGeVSim::kLevy, 500, 0.2, 1, 0.0457);
25  TGeVSimParticle *pim = new TGeVSimParticle(-211, TGeVSim::kLevy, 500, 0.2, 1, 0.0457);
26 
27  pip->SetEllipticSimple(0.05);
28  pim->SetEllipticSimple(0.05);
29 
30  gener->AddParticleType(pip);
31  gener->AddParticleType(pim);
32 
33  // event-by-event fluctuations
34  //TF1 *mult = new TF1("gevsimMultRndm", "gaus(0)", 0,2);
35  //mult->SetParameters(1, 1, 0.1);
36 
37  TF1 *temp = new TF1("gevsimTempRndm", "gaus(0)", 0,2);
38  temp->SetParameters(1, 1, 0.015);
39 
40  TF1 *psi = new TF1("gevsimPsiRndm", "1", 0,360);
41 
42  gener->SetVerbose(kFALSE);
43  gener->Print();
44  // *************
45 
46  StEStructCentrality* cent=StEStructCentrality::Instance();
47  //const double temp[2]={0,2000}; //=1 centrality
48  //const double temp[2]={1,20}; //=1 centrality
49  //cent->setCentralities(temp,2);
50  //const double temp[13]={1,14,30,56,94,146,217,312,431,510,660,810,1500};
51  //cent->setCentralities(temp,13);
52  //int nset=cent->numCentralities()-1;
53  int nset=1;
54 
55  char** datadirs=getDirNames("data",nset);
56  char** cutdirs=getDirNames("cuts",nset);
57 
58  // choose the mode for the binning
59  StEStructCutBin* cb=StEStructCutBin::Instance();
60  cb->setMode(cutBinMode);
61 
62  // create the low-level reader (here for MuDst)
63  //StMuDstMaker* mk = new StMuDstMaker(0,0,"",fileListFile,".",5000);
64 
65  // create the generic EStructAnalysisMaker
66  StEStructAnalysisMaker *estructMaker = new StEStructAnalysisMaker("EStruct2pt");
67 
68  // Set up the EStruct data Readers and Writer codes
69  char** outputFile = new char*[nset];
70  StEStructEventCuts** ecuts = new StEStructEventCuts*[nset];
71  StEStructTrackCuts** tcuts = new StEStructTrackCuts*[nset];
72  StEStruct2ptCorrelations** analysis = new StEStruct2ptCorrelations*[nset];
73  //StEStructMuDstReader** readers = new StEStructMuDstReader*[nset];
74  StEStructGevsim** readers = new StEStructGevsim*[nset];
75 
76 
77  // only 1 reader actually reads the event, the others just pull from mem.
78  // this 'skipMake' ensures this to be the case
79  bool* skipMake=new bool[nset];
80  skipMake[0]=false;
81  for(int i=1;i<nset;i++)skipMake[i]=true;
82 
83  // build the NSET readers & NSET analysis objects
84  // analysis = analysis interface & contains pair-cut object (needs file)
85  // reader = reader interface + pointer to StMuDstMaker + cut classes
86  for(int i=0;i<nset;i++){
87 
88  outputFile[i]=getOutFileName(outputDir,jobName,datadirs[i]);
89  analysis[i]=new StEStruct2ptCorrelations(analysisMode);
90  analysis[i]->setCutFile(pairCutFile);
91  analysis[i]->setOutputFileName(outputFile[i]);
92 
93  /* here's the new way to set the numTracks cut */
94  ecuts[i]=new StEStructEventCuts(evtCutFile);
95  //int min=floor(cent->minCentrality(i));
96  //int max=floor(cent->maxCentrality(i));
97  //char** tmp=getNumTracksStrings(min,max); // find in support.C
98  //ecuts[i]->loadBaseCuts("numTracks",tmp,2);
99  //ecuts[i]->loadBaseCuts("centrality",tmp,2);
100 
101  tcuts[i]=new StEStructTrackCuts(trackCutFile);
102  //readers[i]=new StEStructMuDstReader(mk,ecuts[i],tcuts[i],skipMake[i]);
103  readers[i]=new StEStructGevsim(numEvents,gener,ecuts[i],tcuts[i]);
104  estructMaker->SetReaderAnalysisPair(readers[i],analysis[i]);
105  }
106 
107  // --- now do the work ---
108  doTheWork(estructMaker,numEvents);
109 
110  //--- now write out stats and cuts ---
111  char* statsFileName=getOutFileName(outputDir,jobName,"stats");
112  ofstream ofs(statsFileName);
113 
114  ofs<<endl;
115  estructMaker->logAnalysisTime(ofs);
116  estructMaker->logInputEvents(ofs);
117  estructMaker->logOutputEvents(ofs);
118  estructMaker->logOutputRate(ofs);
119  estructMaker->logAnalysisStats(ofs);
120 
121  for(int i=0;i<nset;i++){
122  ofs<<" *************** ";
123  ofs<<" Cut Stats for Analysis Number = "<<i;
124  ofs<<" *************** "<<endl;
125  ecuts[i]->printCuts(ofs);
126  tcuts[i]->printCuts(ofs);
127 
128  StEStructPairCuts* pcuts=NULL;
129  if(analysis){
130  pcuts=&analysis[i]->getPairCuts();
131  pcuts->printCuts(ofs);
132  }
133 
134  // --> root cut file
135  char* rootCutFile=getOutFileName(outputDir,jobName,cutdirs[i]);
136  TFile* tf=new TFile(rootCutFile,"RECREATE");
137  ecuts[i]->writeCutHists(tf);
138  tcuts[i]->writeCutHists(tf);
139  if(pcuts)pcuts->writeCutHists(tf);
140  tf->Close();
141 
142  }
143  ofs.close();
144 
145  // --- write out the data
146  estructMaker->Finish();
147 }
148 
149 
150 
151 
152 
153 
154 
155 
156 
157 
158 
159 
160 
161 
162 
163 
164 
165 
166 
167 
168 
169 
170 
171 
172 
173 
174 
175 
176 
177 
178 
179 
180 
181 
182 
183 
184 
185 
186 
187 
188 
189 
190 
191 
192 
193 
194 
195 
196 
197 
198 
199 
200 
201 
202 
203 
204 
205 
206