StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
doEStructPythia.C
1 /************************************************************************
2  * $Id: doEStructPythia.C,v 1.4 2006/04/04 22:15:57 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 doEStructPythia( const char* filelist,
16  const char* outputDir,
17  const char* scriptDir,
18  int maxNumEvents = 0 ) {
19 
20  gROOT->LoadMacro("load2ptLibs.C");
21  load2ptLibs();
22 
23  gROOT->LoadMacro("loadPythiaLibs.C");
24  loadPythiaLibs();
25  gROOT->LoadMacro("getPythia.C");
26 
27  char* jobid=gSystem->Getenv("JOBID");
28  const char* rframe="CMS";
29  const char* cproj ="p";
30  const char* ctarg ="p";
31  float rts = 200.0;
32  int pythiaTune = 0; // 1=TuneA, 2=TuneB, all else = minbias standard
33 
34  TPythia6* pythia=getPythia(rframe,cproj,ctarg,rts,pythiaTune,jobid);
35 
36  char cutFile[1024];
37  sprintf(cutFile,"%s/CutsFile.txt",scriptDir);
38 
39  gROOT->LoadMacro("getOutFileName.C"); // for laying out file names
40  const char* scratchDir = "PPPythia";
41 
42  // define centrality
43  StEStructCentrality* cent=StEStructCentrality::Instance();
44  const double temp[2]={0,2000};
45  cent->setCentralities(temp,2);
46  int mbNBins=cent->numCentralities()-1;
47 
48  // choose the mode for the binning
49  int cutBinMode = 1;
50  StEStructCutBin* cb=StEStructCutBin::Instance();
51  cb->setMode(cutBinMode);
52  int mbNCutBins = cb->getNumBins();
53 
54  // create the generic EStructAnalysisMaker
55  StEStructAnalysisMaker *estructMaker = new StEStructAnalysisMaker("EStruct2Pythia");
56 
57  // create the QAHist object (must come after centrality and cutbin objects)
58  int EventType = 2; // pythia from generator
59  StEStructQAHists* qaHists = new StEStructQAHists(EventType);
60  qaHists->initHistograms();
61  estructMaker->SetQAHists(qaHists);
62 
63  // Set up the reader with event/track cuts
64  StEStructEventCuts* ecuts = new StEStructEventCuts(cutFile);
65  StEStructTrackCuts* tcuts = new StEStructTrackCuts(cutFile);
66  StEStructPythia* reader = new StEStructPythia(pythia,ecuts,tcuts,false,0,maxNumEvents);
67 
68  estructMaker->SetEventReader(reader);
69 
70  StEStruct2ptCorrelations** analysis = new StEStructEmptyAnalysis*[mbNBins];
71  // StEStructPairCuts* pcuts = new StEStructPairCuts(cutFile);
72 
73  int analysisMode = 0; // 2pt correlations mode selection
74 
75  for(int i=0;i<mbNBins;i++){
76  int ic=i;
77  if(mbNBins==1)ic=-1;
78  analysis[i]=new StEStructEmptyAnalysis;
79  analysis[i]->setOutputFileName(getOutFileName(outputDir,scratchDir,"data",ic));
80  analysis[i]->setQAHists(qaHists); // only 1 QA Object in this case
81  analysis[i]->setZBuffLimits(ecuts); // common to all
82  }
83  estructMaker->SetAnalyses(analysis,mbNBins);
84 
85 
86  // --- now do the work ---
87  estructMaker->Init();
88  estructMaker->startTimer();
89 
90  int counter=0, istat=0, i=0;
91 
92  while (istat!=2) {
93 
94  istat=estructMaker->Make(); // now includes filling qa histograms
95 
96  i++; counter++;
97  if (counter==100) {
98  cout<<"doing event ="<<i<<endl;
99  counter=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: doEStructPythia.C,v $
132  * Revision 1.4 2006/04/04 22:15:57 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.3 2004/06/25 03:14:56 porter
138  * modified basic macro to take only 1 cutfile and moved some common
139  * features into a new macro=support.C..... this cleaned up the
140  * doEStruct macro somewhat
141  *
142  * Revision 1.2 2004/04/15 18:46:33 msd
143  * Updated centrality variable types
144  *
145  * Revision 1.1 2003/11/21 06:26:40 porter
146  * macros for running pythia
147  *
148  * Revision 1.1 2003/10/15 18:20:57 porter
149  * initial check in of Estruct Analysis maker codes.
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 
207 
208 
209 
210