StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
doEStruct2ptPythia.C
1 /************************************************************************
2  * $Id: doEStruct2ptPythia.C,v 1.5 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 doEStruct2ptPythia(const char* fileListFile, const char* outputDir, const char* cutFile, const char* jobName=0, int nset=3, int maxNumEvents=0){
16 
17 void doEStruct2ptPythia( const char* filelist,
18  const char* outputDir,
19  const char* scriptDir,
20  int maxNumEvents = 0 ) {
21 
22  gROOT->LoadMacro("load2ptLibs.C");
23  load2ptLibs();
24 
25  gROOT->LoadMacro("loadPythiaLibs.C");
26  loadPythiaLibs();
27  gROOT->LoadMacro("getPythia.C");
28 
29  char* jobid=gSystem->Getenv("JOBID");
30  const char* rframe="CMS";
31  const char* cproj ="p";
32  const char* ctarg ="p";
33  float rts = 200.0;
34  int pythiaTune = 0; // 1=TuneA, 2=TuneB, all else = minbias standard
35 
36  TPythia6* pythia=getPythia(rframe,cproj,ctarg,rts,pythiaTune,jobid);
37 
38  char cutFile[1024];
39  sprintf(cutFile,"%s/CutsFile.txt",scriptDir);
40 
41  gROOT->LoadMacro("getOutFileName.C"); // for laying out file names
42  const char* scratchDir = "PPPythia";
43 
44  // define centrality
45  StEStructCentrality* cent=StEStructCentrality::Instance();
46  const double mbBins[]={2,3,4,6,8,11,14,99};
47  int mbNBins=1+1+1+1+1+1+1+1;
48  int mbNBins=cent->numCentralities()-1;
49 
50  // choose the mode for the binning
51  int cutBinMode = 4;
52  StEStructCutBin* cb=StEStructCutBin::Instance();
53  cb->setMode(cutBinMode);
54  int mbNCutBins = cb->getNumBins();
55 
56  // create the generic EStructAnalysisMaker
57  StEStructAnalysisMaker *estructMaker = new StEStructAnalysisMaker("EStruct2Pythia");
58 
59  // create the QAHist object (must come after centrality and cutbin objects)
60  int EventType = 2; // pythia from generator
61  StEStructQAHists* qaHists = new StEStructQAHists(EventType);
62  qaHists->initHistograms();
63  estructMaker->SetQAHists(qaHists);
64 
65  // Set up the reader with event/track cuts
66  StEStructEventCuts* ecuts = new StEStructEventCuts(cutFile);
67  StEStructTrackCuts* tcuts = new StEStructTrackCuts(cutFile);
68  StEStructPythia* reader = new StEStructPythia(pythia,ecuts,tcuts,false,0,maxNumEvents);
69 
70  estructMaker->SetEventReader(reader);
71 
72  StEStruct2ptCorrelations** analysis = new StEStruct2ptCorrelations*[mbNBins];
73  StEStructPairCuts* pcuts = new StEStructPairCuts(cutFile);
74 
75  int analysisMode = 0; // 2pt correlations mode selection
76 
77  for(int i=0;i<mbNBins;i++){
78  int ic=i;
79  if(mbNBins==1)ic=-1;
80  analysis[i]=new StEStruct2ptCorrelations(pcuts,analysisMode);
81  analysis[i]->setOutputFileName(getOutFileName(outputDir,scratchDir,"data",ic));
82  analysis[i]->setQAHists(qaHists); // only 1 QA Object in this case
83  analysis[i]->setZBuffLimits(ecuts); // common to all
84  }
85  estructMaker->SetAnalyses(analysis,mbNBins);
86 
87 
88  // --- now do the work ---
89  estructMaker->Init();
90  estructMaker->startTimer();
91 
92  int counter=0, istat=0, i=0;
93 
94  while (istat!=2) {
95 
96  istat=estructMaker->Make(); // now includes filling qa histograms
97 
98  i++; counter++;
99  if (counter==100) {
100  cout<<"doing event ="<<i<<endl;
101  counter=0;
102  }
103  if ( maxNumEvents!=0 && i>=maxNumEvents ) {
104  istat=2;
105  }
106  }
107  estructMaker->stopTimer();
108 
109  //--- now write out stats and cuts ---
110  ofstream ofs(getOutFileName(outputDir,scratchDir,"stats"));
111  estructMaker->logAllStats(ofs);
112  ecuts->printCuts(ofs);
113  tcuts->printCuts(ofs);
114  pcuts->printCuts(ofs);
115  ofs<<endl;
116  ofs.close();
117 
118  // --> root cut file
119  TFile* tf=new TFile(getOutFileName(outputDir,scratchDir,"cuts"),"RECREATE");
120  ecuts->writeCutHists(tf);
121  tcuts->writeCutHists(tf);
122  tf->Close();
123 
124  // --> root qa histogram file
125  estructMaker->writeQAHists(getOutFileName(outputDir,scratchDir,"QA"));
126 
127  // --- write out the data
128  estructMaker->Finish();
129 }
130 
131 /**********************************************************************
132  *
133  * $Log: doEStruct2ptPythia.C,v $
134  * Revision 1.5 2006/04/04 22:15:56 porter
135  * a large number of changes were done to simplify the doEStruct macros
136  * in the sense that these are now more similar and should be easier
137  * for Duncan's GUI to build. Here are some examples.
138  *
139  * Revision 1.4 2004/07/01 00:39:24 porter
140  * added 'libPhysics.so' to load2ptLibs.C which allows our codes to run
141  * in root.exe instead of root4star. Thus we can use TPythia6.
142  *
143  * added a rewritten version of my makePlots.C with example.
144  * Also, 'selectASNS.C' is an example for using the StEStructSupport code.
145  *
146  * Revision 1.3 2004/06/25 03:14:56 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.2 2004/03/02 21:51:11 prindle
152  *
153  * I forgot to cvs add my EventGenerator readers.
154  *
155  * Revision 1.1 2003/11/21 06:26:40 porter
156  * macros for running pythia
157  *
158  * Revision 1.1 2003/10/15 18:20:57 porter
159  * initial check in of Estruct Analysis maker codes.
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 
220