StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
doEStruct2ptDst.C
1 /************************************************************************
2  * $Id: doEStruct2ptDst.C,v 1.3 2004/06/25 03:14:56 porter Exp $
3  *
4  * Author: Jeff Porter
5  *
6  * example code for reading in EStruct Dst files contained in "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 doEStruct2ptDst(const char* fileListFile, const char* outputDir, const char* cutFile, const char* jobName=0, int nset=3, 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  // in this example, all cuts (event, track, pair) are in same file
24  char* evtCutFile=cutFile;
25  char* trackCutFile=evtCutFile;
26  char* pairCutFile =evtCutFile;
27 
28  char** datadirs=getDirNames("data",nset);
29  char** cutdirs=getDirNames("cuts",nset);
30 
31  // simple (global) centrality definition ...not persistant to event file..
32  // and not used in this particular example
33  StEStructCentrality* cent=StEStructCentrality::Instance();
34  const double temp[4]={0,4,7,50};
35  cent->setCentralities(temp,4);
36 
37  // create the low-level reader (here for EStructDst)
39  mk->setInputFileList(fileListFile);
40 
41  // create the generic EStructAnalysisMaker
42  StEStructAnalysisMaker *estructMaker = new StEStructAnalysisMaker("EStruct2pt");
43 
44  // Set up the EStruct data Readers and Writer codes
45  char** outputFile = new char*[nset];
46  StEStructEventCuts** ecuts = new StEStructEventCuts*[nset];
47  StEStructTrackCuts** tcuts = new StEStructTrackCuts*[nset];
48  StEStruct2ptCorrelations** analysis = new StEStruct2ptCorrelations*[nset];
49  StEStructDstReader** readers = new StEStructDstReader*[nset];
50 
51  // only 1 reader actually reads the event, the others just pull from mem.
52  // this 'skipMake' ensures this to be the case
53  bool* skipMake=new bool[nset];
54  skipMake[0]=false;
55  for(int i=1;i<nset;i++)skipMake[i]=true;
56 
57  // build the NSEt readers & NSET analysis objects
58  // analysis = analysis interface & contains pair-cut object (needs file)
59  // reader = reader interface + pointer to StMuDstMaker + cut classes
60 
61  for(int i=0;i<nset;i++){
62 
63  outputFile[i]=getOutFileName(outputDir,jobName,datadirs[i]);
64  analysis[i]=new StEStruct2ptCorrelations(1);
65  analysis[i]->setCutFile(pairCutFile);
66  analysis[i]->setOutputFileName(outputFile[i]);
67 
68  /* here's the new way to set the numTracks cut */
69  ecuts[i]=new StEStructEventCuts(evtCutFile);
70  int min=floor(cent->minCentrality(i));
71  int max=floor(cent->maxCentrality(i));
72  char** tmp=getNumTracksStrings(min,max); // find in getOutFileName.C
73  ecuts[i]->loadBaseCuts("numTracks",tmp,2);
74 
75  tcuts[i]=new StEStructTrackCuts(trackCutFile);
76  readers[i]=new StEStructDstReader(mk,ecuts[i],tcuts[i],skipMake[i]);
77  estructMaker->SetReaderAnalysisPair(readers[i],analysis[i]);
78  }
79 
80  // --- now do the work ---
81  doTheWork(estructMaker,maxNumEvents);
82 
83  // write event-stats to log file
84  char* statsFileName=getOutFileName(outputDir,jobName,"stats");
85  ofstream ofs(statsFileName);
86 
87  ofs<<endl;
88  estructMaker->logAnalysisTime(ofs);
89  estructMaker->logInputEvents(ofs);
90  estructMaker->logOutputEvents(ofs);
91  estructMaker->logOutputRate(ofs);
92  estructMaker->logAnalysisStats(ofs);
93 
94  //
95  // --> cuts stats streamed to stdout (logfile)
96  //
97  for(int i=0;i<nset;i++){
98  ofs<<" *************** ";
99  ofs<<" Cut Stats for Analysis Number = "<<i;
100  ofs<<" *************** "<<endl;
101  ecuts[i]->printCuts(ofs);
102  tcuts[i]->printCuts(ofs);
103  StEStructPairCuts& pcuts=analysis[i]->getPairCuts();
104  pcuts.printCuts(ofs);
105 
106  //
107  // --> root cut file
108  //
109  char* rootCutFile=getOutFileName(outputDir,jobName,cutdirs[i]);
110  TFile* tf=new TFile(rootCutFile,"RECREATE");
111  ecuts[i]->writeCutHists(tf);
112  tcuts[i]->writeCutHists(tf);
113  pcuts.writeCutHists(tf);
114  tf->Close();
115  }
116  ofs.close();
117 
118  // --- write out the data
119  estructMaker->Finish();
120 }
121 
122 /**********************************************************************
123  *
124  * $Log: doEStruct2ptDst.C,v $
125  * Revision 1.3 2004/06/25 03:14:56 porter
126  * modified basic macro to take only 1 cutfile and moved some common
127  * features into a new macro=support.C..... this cleaned up the
128  * doEStruct macro somewhat
129  *
130  * Revision 1.2 2004/04/15 18:46:32 msd
131  * Updated centrality variable types
132  *
133  * Revision 1.1 2003/10/15 18:20:57 porter
134  * initial check in of Estruct Analysis maker codes.
135  *
136  *
137  *********************************************************************/
138 
139 
140 
141 
142 
143 
144 
145 
146 
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