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