StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
writeEStructExample.C
1 /************************************************************************
2  * $Id: writeEStructExample.C,v 1.3 2006/04/10 23:44:06 porter Exp $
3  *
4  * Author: Jeff Porter
5  *
6  * example code for reading in MuDst files contained int "fileListFile"
7  * and writng out estruct pico dsts using new format
8  *
9  *****************************************************************/
10 
11 void writeEStructExample( const char* filelist,
12  const char* outputDir,
13  const char* scriptDir,
14  int maxNumEvents = 0 ) {
15 
16 
17  gROOT->LoadMacro("load2ptLibs.C");
18  load2ptLibs();
19 
20  char cutFile[1024];
21  sprintf(cutFile,"%s/CutsFile.txt",scriptDir);
22 
23  gROOT->LoadMacro("getOutFileName.C"); // for laying out file names
24  const char* scratchDir = "CuCu200data";
25 
26  // define centrality (just making stuff up below!!!)
27  StEStructCentrality* cent=StEStructCentrality::Instance();
28  const double mbBins[]={2,30,100,180,240,320,400,999999};
29  int mbNBins=1+1+1+1+1+1+1+1;
30  cent->setCentralities(mbBins,mbNBins);
31  int numberOfAnalyses=mbNBins-1;
32 
33  // create the low-level reader (here for MuDst)
34  // reader = reader interface + pointer to Data Maker + cut classes
35 
36  //***** depends on PDSF vs RCF .... below is RCF version of scheduler
37  // char fileListFile[1024];
38  // sprintf(fileListFile,"%s/%s",scriptDir,filelist);
39  StMuDstMaker* mk = new StMuDstMaker(0,0,"",filelist,".",5000);
40 
41  // create the generic EStructAnalysisMaker
42  StEStructAnalysisMaker *estructMaker = new StEStructAnalysisMaker("EStruct2pt");
43 
44  // Set up the reader with event/track cuts
45  StEStructEventCuts* ecuts = new StEStructEventCuts(cutFile);
46  StEStructTrackCuts* tcuts = new StEStructTrackCuts(cutFile);
47  StEStructMuDstReader* reader = new StEStructMuDstReader(mk,ecuts,tcuts,false);
48 
49  estructMaker->SetEventReader(reader);
50 
51  // create the QAHist object (must come after centrality and cutbin objects)
52  int EventType = 0; // real data
53  StEStructQAHists* qaHists = new StEStructQAHists(EventType);
54  qaHists->initHistograms();
55  estructMaker->SetQAHists(qaHists);
56 
57  StEStructEventWriter** analysis = new StEStructEventWriter*[mbNBins];
58  StEStructEventMaker** writeMakers = new StEStructEventMaker*[mbNBins];
59 
60  int analysisMode = 0; // 2pt correlations mode selection
61 
62  for(int i=0;i<numberOfAnalyses;i++){
63  int ic=i;
64  if(numberOfAnalyses==1)ic=-1;
65 
66  TString writerName("EStructWriterMaker"); writerName+=i;
67  writeMakers[i]=new StEStructEventMaker(writerName.Data());
68 
69  analysis[i]=new StEStructEventWriter(writeMakers[i]);
70  analysis[i]->setOutputFileName(getOutFileName(outputDir,scratchDir,"event",ic));
71  /*
72  analysis[i]->setQAHists(qaHists); // only 1 QA Object in this case
73  analysis[i]->setZBuffLimits(ecuts); // common to all
74  */
75  analysis[i]->setAnalysisIndex(i);
76  }
77  estructMaker->SetAnalyses(analysis,numberOfAnalyses);
78 
79  // --- now do the work ---
80 
81  estructMaker->Init();
82  estructMaker->startTimer();
83 
84  int counter=0, istat=0, i=0;
85 
86  while (istat!=2) {
87 
88  istat=estructMaker->Make(); // now includes filling qa histograms
89 
90  i++; counter++;
91  if (counter==200) {
92  cout<<"doing event ="<<i<<endl;
93  counter=0;
94  estructMaker->writeDiagnostics(0);
95  }
96  if ( maxNumEvents!=0 && i>=maxNumEvents ) {
97  istat=2;
98  }
99  }
100  estructMaker->stopTimer();
101 
102  //--- now write out stats and cuts ---
103  ofstream ofs(getOutFileName(outputDir,scratchDir,"stats"));
104  estructMaker->logAllStats(ofs);
105  ecuts->printCuts(ofs);
106  tcuts->printCuts(ofs);
107  ofs<<endl;
108  ofs.close();
109 
110  // --> root cut file
111  TFile* tf=new TFile(getOutFileName(outputDir,scratchDir,"cuts"),"RECREATE");
112  ecuts->writeCutHists(tf);
113  tcuts->writeCutHists(tf);
114  tf->Close();
115 
116 
117  // --- write out the data
118  estructMaker->Finish();
119 }
120 
121 
122 /**********************************************************************
123  *
124  * $Log: writeEStructExample.C,v $
125  * Revision 1.3 2006/04/10 23:44:06 porter
126  * Updated the writer example - tested it on pp and CuCu at 200
127  *
128  * Revision 1.2 2004/04/15 18:46:34 msd
129  * Updated centrality variable types
130  *
131  * Revision 1.1 2003/10/15 18:20:57 porter
132  * initial check in of Estruct Analysis maker codes.
133  *
134  *
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