StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
doEStruct2ptAuAu.C
1 /************************************************************************
2  * $Id: doEStruct2ptAuAu.C,v 1.2 2006/04/26 18:52:50 dkettler Exp $
3  *
4  * Author: Jeff Porter
5  *
6  * example code for reading in MuDst files contained int "fileListFile"
7  * and running the 2pt correlations analysis, producing hist files in,
8  *
9  * outputDir/jobName/data/XX/
10  *
11  * where XX = event level selection imposed by the cut files.
12  * This example (from PP) contains 3 selections on event mult
13  *
14  *************************************************************************/
15 void doEStruct2ptAuAu(const char* fileListFile, const char* outputDir, const char* cutFile, const char* jobName=0, int cutBinMode=0, int maxNumEvents=0){
16 
17  // libraries required and helper macros in $STAR/StRoot/StEStructPool/macros
18  gROOT->LoadMacro("load2ptLibs.C");
19  load2ptLibs();
20  gROOT->LoadMacro("getOutFileName.C");
21  gROOT->LoadMacro("support.C");
22 
23  /* *******************************************************************
24  changed the use model of the cut file. I found that I always keep
25  the cuts for a given pass the same except for the centrality cut.
26  Now I add this cut directly and I use only 1 cut file, PPCutsAll.txt,
27  and with the centrality cut set below
28  ************************************************************************/
29 
30  // in this example, all cuts (event, track, pair) are in same file
31  // cutFile can also refer to an entry in the cut DB
32  // (see StEStructPool/AnalysisMaker/StEStructCuts.cxx for pre-compiled cuts)
33  const char* evtCutFile=cutFile;
34 
35  const char* trackCutFile=evtCutFile;
36  const char* pairCutFile =evtCutFile;
37 
38 
39  // simple (global) centrality definition ...not persistant to event file..
40  // and not used in this particular example
41  StEStructCentrality* cent=StEStructCentrality::Instance();
42  const double temp[6]={4,30,100,200,400,2000}; //=5 centralies
43  cent->setCentralities(temp,6);
44  int nset=cent->numCentralities()-1;
45 
46  char** datadirs=getDirNames("data",nset);
47  char** cutdirs=getDirNames("cuts",nset);
48 
49  // choose the mode for the binning
50  StEStructCutBin* cb=StEStructCutBin::Instance();
51  cb->setMode(cutBinMode);
52 
53  // create the low-level reader (here for MuDst)
54  StMuDstMaker* mk = new StMuDstMaker(0,0,"",fileListFile,".",5000);
55 
56  // create the generic EStructAnalysisMaker
57  StEStructAnalysisMaker *estructMaker = new StEStructAnalysisMaker("EStruct2pt");
58 
59  // Set up the EStruct data Readers and Writer codes
60  char** outputFile = new char*[nset];
61  StEStructEventCuts** ecuts = new StEStructEventCuts*[nset];
62  StEStructTrackCuts** tcuts = new StEStructTrackCuts*[nset];
63  StEStruct2ptCorrelations** analysis = new StEStruct2ptCorrelations*[nset];
64  StEStructMuDstReader** readers = new StEStructMuDstReader*[nset];
65 
66  // only 1 reader actually reads the event, the others just pull from mem.
67  // this 'skipMake' ensures this to be the case
68  bool* skipMake=new bool[nset];
69  skipMake[0]=false;
70  for(int i=1;i<nset;i++)skipMake[i]=true;
71 
72  // build the NSET readers & NSET analysis objects
73  // analysis = analysis interface & contains pair-cut object (needs file)
74  // reader = reader interface + pointer to StMuDstMaker + cut classes
75  for(int i=0;i<nset;i++){
76 
77  outputFile[i]=getOutFileName(outputDir,jobName,datadirs[i]);
78  analysis[i]=new StEStruct2ptCorrelations();
79  analysis[i]->setCutFile(pairCutFile);
80  analysis[i]->setOutputFileName(outputFile[i]);
81 
82  /* here's the new way to set the numTracks cut */
83  ecuts[i]=new StEStructEventCuts(evtCutFile);
84  int min=floor(cent->minCentrality(i));
85  int max=floor(cent->maxCentrality(i));
86  char** tmp=getNumTracksStrings(min,max); // find in support.C
87  ecuts[i]->loadBaseCuts("numTracks",tmp,2);
88 
89  tcuts[i]=new StEStructTrackCuts(trackCutFile);
90  readers[i]=new StEStructMuDstReader(mk,ecuts[i],tcuts[i],skipMake[i]);
91  estructMaker->SetReaderAnalysisPair(readers[i],analysis[i]);
92  }
93 
94  // --- now do the work ---
95  //estructMaker->SetReactionPlaneAnalysis("/home/dkettler/working/weights/PhiWgt.root");
96  doTheWork(estructMaker,maxNumEvents);
97 
98  //--- now write out stats and cuts ---
99  char* statsFileName=getOutFileName(outputDir,jobName,"stats");
100  ofstream ofs(statsFileName);
101 
102  ofs<<endl;
103  estructMaker->logAnalysisTime(ofs);
104  estructMaker->logInputEvents(ofs);
105  estructMaker->logOutputEvents(ofs);
106  estructMaker->logOutputRate(ofs);
107  estructMaker->logAnalysisStats(ofs);
108 
109  for(int i=0;i<nset;i++){
110  ofs<<" *************** ";
111  ofs<<" Cut Stats for Analysis Number = "<<i;
112  ofs<<" *************** "<<endl;
113  ecuts[i]->printCuts(ofs);
114  tcuts[i]->printCuts(ofs);
115 
116  StEStructPairCuts* pcuts=NULL;
117  if(analysis){
118  pcuts=&analysis[i]->getPairCuts();
119  pcuts->printCuts(ofs);
120  }
121 
122  // --> root cut file
123  char* rootCutFile=getOutFileName(outputDir,jobName,cutdirs[i]);
124  TFile* tf=new TFile(rootCutFile,"RECREATE");
125  ecuts[i]->writeCutHists(tf);
126  tcuts[i]->writeCutHists(tf);
127  if(pcuts)pcuts->writeCutHists(tf);
128  tf->Close();
129 
130  }
131  ofs.close();
132 
133  // --- write out the data
134  estructMaker->Finish();
135 }
136 
137 /**********************************************************************
138  *
139  * $Log: doEStruct2ptAuAu.C,v $
140  * Revision 1.2 2006/04/26 18:52:50 dkettler
141  * Added reaction plane determination for the analysis
142  *
143  * Added reaction plane angle calculation
144  *
145  * Case 3 in buildPtChargeTypes needs to be corrected
146  *
147  * Flag added for enabling reaction plane analysis
148  *
149  * Revision 1.1 2005/03/03 18:30:59 porter
150  * example correlations macro and scheduler xml
151  *
152  * Revision 1.6 2004/08/23 19:12:46 msd
153  * Added note about usage for pre-compiled cut database
154  *
155  * Revision 1.5 2004/06/26 16:28:42 porter
156  * fixed typo in getDirNames.C
157  *
158  * Revision 1.4 2004/06/25 03:14:55 porter
159  * modified basic macro to take only 1 cutfile and moved some common
160  * features into a new macro=support.C..... this cleaned up the
161  * doEStruct macro somewhat
162  *
163  * Revision 1.3 2004/04/15 18:46:31 msd
164  * Updated centrality variable types
165  *
166  * Revision 1.2 2003/11/21 06:26:40 porter
167  * macros for running pythia
168  *
169  * Revision 1.1 2003/10/15 18:20:57 porter
170  * initial check in of Estruct Analysis maker codes.
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 
207 
208 
209 
210 
211 
212 
213 
214 
215 
216 
217 
218 
219 
220 
221 
222 
223 
224 
225 
226 
227 
228 
229 
230 
231