StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
doEStruct2pt.C
1 /************************************************************************
2  * $Id: doEStruct2pt.C,v 1.8 2006/04/04 22:15:56 porter 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 doEStruct2pt(const char* fileListFile, const char* outputDir, const char* cutFile, const char* jobName=0, int cutBinMode=0, int maxNumEvents=0){
16 
17 void doEStruct2pt( const char* filelist,
18  const char* outputDir,
19  const char* scriptDir,
20  int maxNumEvents = 0 ) {
21 
22 
23  gROOT->LoadMacro("load2ptLibs.C");
24  load2ptLibs();
25 
26  char cutFile[1024];
27  sprintf(cutFile,"%s/CutsFile.txt",scriptDir);
28 
29  gROOT->LoadMacro("getOutFileName.C"); // for laying out file names
30  const char* scratchDir = "PPData_01";
31 
32  // define centrality
33  StEStructCentrality* cent=StEStructCentrality::Instance();
34  const double mbBins[]={2,3,4,6,8,11,14,99};
35  int mbNBins=1+1+1+1+1+1+1+1;
36  cent->setCentralities(mbBins,mbNBins);
37  int numberOfAnalyses=mbNBins-1;
38 
39  // choose the mode for the binning
40  int cutBinMode = 4;
41  StEStructCutBin* cb=StEStructCutBin::Instance();
42  cb->setMode(cutBinMode);
43  int mbNCutBins = cb->getNumBins();
44 
45  // create the low-level reader (here for MuDst)
46  // reader = reader interface + pointer to Data Maker + cut classes
47 
48  //***** depends on PDSF vs RCF .... below is RCF version of scheduler
49  // char fileListFile[1024];
50  // sprintf(fileListFile,"%s/%s",scriptDir,filelist);
51  StMuDstMaker* mk = new StMuDstMaker(0,0,"",filelist,".",5000);
52 
53  // create the generic EStructAnalysisMaker
54  StEStructAnalysisMaker *estructMaker = new StEStructAnalysisMaker("EStruct2pt");
55 
56  // Set up the reader with event/track cuts
57  StEStructEventCuts* ecuts = new StEStructEventCuts(cutFile);
58  StEStructTrackCuts* tcuts = new StEStructTrackCuts(cutFile);
59  StEStructMuDstReader* reader = new StEStructMuDstReader(mk,ecuts,tcuts,false);
60  estructMaker->SetEventReader(reader);
61 
62  // create the QAHist object (must come after centrality and cutbin objects)
63  int EventType = 0; // real data
64  StEStructQAHists* qaHists = new StEStructQAHists(EventType);
65  qaHists->initHistograms();
66  estructMaker->SetQAHists(qaHists);
67 
68  StEStruct2ptCorrelations** analysis = new StEStruct2ptCorrelations*[mbNBins];
69  StEStructPairCuts* pcuts = new StEStructPairCuts(cutFile);
70 
71  int analysisMode = 0; // 2pt correlations mode selection
72 
73  for(int i=0;i<numberOfAnalyses;i++){
74  int ic=i;
75  if(numberOfAnalyses==1)ic=-1;
76  analysis[i]=new StEStruct2ptCorrelations(pcuts,analysisMode);
77  analysis[i]->setOutputFileName(getOutFileName(outputDir,scratchDir,"data",ic));
78  analysis[i]->setQAHists(qaHists); // only 1 QA Object in this case
79  analysis[i]->setZBuffLimits(ecuts); // common to all
80  analysis[i]->setAnalysisIndex(i);
81  }
82  estructMaker->SetAnalyses(analysis,numberOfAnalyses);
83 
84  // --- now do the work ---
85 
86  estructMaker->Init();
87  estructMaker->startTimer();
88 
89  int counter=0, istat=0, i=0;
90 
91  while (istat!=2) {
92 
93  istat=estructMaker->Make(); // now includes filling qa histograms
94 
95  i++; counter++;
96  if (counter==200) {
97  cout<<"doing event ="<<i<<endl;
98  counter=0;
99  estructMaker->writeDiagnostics(0);
100  }
101  if ( maxNumEvents!=0 && i>=maxNumEvents ) {
102  istat=2;
103  }
104  }
105  estructMaker->stopTimer();
106 
107  //--- now write out stats and cuts ---
108  ofstream ofs(getOutFileName(outputDir,scratchDir,"stats"));
109  estructMaker->logAllStats(ofs);
110  ecuts->printCuts(ofs);
111  tcuts->printCuts(ofs);
112  pcuts->printCuts(ofs);
113  ofs<<endl;
114  ofs.close();
115 
116  // --> root cut file
117  TFile* tf=new TFile(getOutFileName(outputDir,scratchDir,"cuts"),"RECREATE");
118  ecuts->writeCutHists(tf);
119  tcuts->writeCutHists(tf);
120  tf->Close();
121 
122  // --> root qa histogram file
123  estructMaker->writeQAHists(getOutFileName(outputDir,scratchDir,"QA"));
124 
125  // --- write out the data
126  estructMaker->Finish();
127 }
128 
129 /**********************************************************************
130  *
131  * $Log: doEStruct2pt.C,v $
132  * Revision 1.8 2006/04/04 22:15:56 porter
133  * a large number of changes were done to simplify the doEStruct macros
134  * in the sense that these are now more similar and should be easier
135  * for Duncan's GUI to build. Here are some examples.
136  *
137  * Revision 1.7 2005/03/03 01:33:36 porter
138  * modified macros
139  *
140  * Revision 1.6 2004/08/23 19:12:46 msd
141  * Added note about usage for pre-compiled cut database
142  *
143  * Revision 1.5 2004/06/26 16:28:42 porter
144  * fixed typo in getDirNames.C
145  *
146  * Revision 1.4 2004/06/25 03:14:55 porter
147  * modified basic macro to take only 1 cutfile and moved some common
148  * features into a new macro=support.C..... this cleaned up the
149  * doEStruct macro somewhat
150  *
151  * Revision 1.3 2004/04/15 18:46:31 msd
152  * Updated centrality variable types
153  *
154  * Revision 1.2 2003/11/21 06:26:40 porter
155  * macros for running pythia
156  *
157  * Revision 1.1 2003/10/15 18:20:57 porter
158  * initial check in of Estruct Analysis maker codes.
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 
207 
208 
209 
210 
211 
212 
213 
214 
215 
216 
217 
218 
219