StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
doEStructFluct.C
1 /************************************************************************
2  * $Id: doEStructFluct.C,v 1.1 2006/04/04 22:15:56 porter Exp $
3  *
4  * Author: Duncan Prindle & Jeff Porter
5  *
6  * example code for reading in MuDst files and running
7  * the estruct fluctuations analysis, producing hist files....
8  *************************************************************************/
9 
10 void doEStruct( const char* filelist,
11  const char* outputDir,
12  const char* scriptDir,
13  int maxNumEvents = 0 ) {
14 
15 
16  gROOT->LoadMacro("load2ptLibs.C");
17  load2ptLibs();
18 
19  char cutFile[1024];
20  sprintf(cutFile,"%s/CutsFile.txt",scriptDir);
21 
22  gROOT->LoadMacro("getOutFileName.C");
23  const char* scratchDir = "PPFluct";
24 
25  // define centrality
26  StEStructCentrality* cent=StEStructCentrality::Instance();
27  const double mbBins[] = {5, 24, 69, 156, 297, 513, 911};
28  int mbNBins = 1+1+1+1+1+1+1;
29  cent->setCentralities(mbBins,mbNBins);
30 
31  const double ptCut[] = {0.15, 0.5, 2.0};
32  int mbNPts = 1+1+1;
33 
34  const double ptMultCut[] = {0.0, 6.0, 8.6, 10.6, 12.4, 14.0, 20.0};
35  int mbNPtBins = 1+1+1+1+1+1+1;;
36  cent->setPts(ptCut,mbNPts,ptMultCut,mbNPtBins);
37 
38  int numberOfAnalyses=1;
39 
40  char *analysisType = "StEStructFluctuation";
41 
42  // Need an EStruct maker.
43  StEStructAnalysisMaker *estructMaker = new StEStructAnalysisMaker(analysisType);
44 
45  // reader = reader interface + pointer to Data Maker + cut classes
46  // char fileListFile[1024];
47  // sprintf(fileListFile,"%s/%s",scriptDir,filelist);
48  StMuDstMaker* mk = new StMuDstMaker(0,0,"",filelist,".",500);
49  // Set up the reader with event/track cuts
50  StEStructEventCuts* ecuts = new StEStructEventCuts(cutFile);
51  StEStructTrackCuts* tcuts = new StEStructTrackCuts(cutFile);
52  StEStructMuDstReader* reader = new StEStructMuDstReader(mk,ecuts,tcuts,false);
53  estructMaker->SetEventReader(reader);
54 
55  StEStructFluctAnal** analysis = new StEStructFluctAnal*[numberOfAnalyses];
56  StEStructFluctAnal* currentAnalysis;
57  StEStructPairCuts* pcuts = new StEStructPairCuts(cutFile);
58 
59  for(int i=0;i<numberOfAnalyses;i++){
60  int ic=i;
61  if(numberOfAnalyses==1)ic=-1;
62  analysis[i] = new StEStructFluctAnal();
63  analysis[i]->initStructures(tcuts); // cuts define min and max vals
64  analysis[i]->setPairCuts(pcuts);
65  analysis[i]->setOutputFileName(getOutFileName(outputDir,scratchDir,"data",ic));
66 
67  }
68  estructMaker->SetAnalyses(analysis,numberOfAnalyses);
69 
70  // --- now do the work ---
71 
72  estructMaker->Init();
73  estructMaker->startTimer();
74 
75  int counter=0, istat=0, i=0;
76  while (istat!=2) {
77 
78  istat=estructMaker->Make();
79 
80  i++; counter++;
81  if (counter==100) {
82  cout<<"doing event ="<<i<<endl;
83  counter=0;
84  }
85  if ( maxNumEvents!=0 && i>=maxNumEvents ) {
86  istat=2;
87  }
88  }
89  estructMaker->stopTimer();
90 
91  //--- now write out stats and cuts ---
92  ofstream ofs(getOutFileName(outputDir,scratchDir,"stats"));
93  estructMaker->logAllStats(ofs);
94  ecuts->printCuts(ofs);
95  tcuts->printCuts(ofs);
96  // --- not in fluctuations --- pcuts->printCuts(ofs);
97  ofs<<endl;
98  ofs.close();
99 
100  // --> root cut file
101  TFile* tf=new TFile(getOutFileName(outputDir,scratchDir,"cuts"),"RECREATE");
102  ecuts->writeCutHists(tf);
103  tcuts->writeCutHists(tf);
104  tf->Close();
105 
106  // --> root qa histogram file
107  estructMaker->writeQAHists(getOutFileName(outputDir,scratchDir,"QA"));
108 
109  // --- write out the data
110  estructMaker->Finish();
111 }
112 
113 /**********************************************************************
114  *
115  * $Log: doEStructFluct.C,v $
116  * Revision 1.1 2006/04/04 22:15:56 porter
117  * a large number of changes were done to simplify the doEStruct macros
118  * in the sense that these are now more similar and should be easier
119  * for Duncan's GUI to build. Here are some examples.
120  *
121  *
122  *********************************************************************/