StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
doEStructFluctHIJING.C
1 /************************************************************************
2  * $Id: doEStructFluctHIJING.C,v 1.1 2006/04/04 22:15:57 porter Exp $
3  *
4  * Author: Duncan Prindle & Jeff Porter
5  *
6  * example code for rnning Hijing event generator 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 = "PPFluctHI";
24 
25  char buffer[1024];
26  gSystem->Load("THijing");
27  sprintf(buffer,"%s/hijev.inp",scriptDir);
28  THijing *hijingGenerator = new THijing(buffer);
29 
30 
31  // define centrality
32  StEStructCentrality* cent=StEStructCentrality::Instance();
33  cent->setCentTypeImpact(); // will use impact parameter here ..
34 
35  const double mbBins[] = {0.0, 6.0, 8.6, 10.6, 12.4, 14.0, 20.0};
36  int mbNBins = 1+1+1+1+1+1+1;
37 
38  cent->setCentralities(mbBins,mbNBins);
39 
40  const double ptCut[] = {0.15, 0.5, 2.0};
41  int mbNPts = 1+1+1;
42 
43  const double ptMultCut[] = {0.0, 6.0, 8.6, 10.6, 12.4, 14.0, 20.0};
44  int mbNPtBins = 1+1+1+1+1+1+1;;
45 
46  cent->setPts(ptCut,mbNPts,ptMultCut,mbNPtBins);
47 
48  int numberOfAnalyses = 1;
49 
50 
51  StEStructFluctAnal** analysis = new StEStructFluctAnal*[numberOfAnalyses];
52  StEStructFluctAnal* currentAnalysis;
53 
54  char *analysisType = "StEStructFluctuation";
55 
56  // Need an EStruct maker.
57  StEStructAnalysisMaker *estructMaker = new StEStructAnalysisMaker(analysisType);
58  // create the QAHist object (must come after centrality and cutbin objects)
59  int EventType = 1; // hijing from generator
60  StEStructQAHists* qaHists = new StEStructQAHists(EventType);
61  qaHists->initHistograms();
62  estructMaker->SetQAHists(qaHists);
63 
64  StEStructEventCuts* ecuts = new StEStructEventCuts(cutFile);
65  StEStructTrackCuts* tcuts = new StEStructTrackCuts(cutFile);
66  StEStructHijing* reader = new StEStructHijing(hijingGenerator,ecuts,tcuts,false,0,maxNumEvents);
67 
68  estructMaker->SetEventReader(reader);
69 
70  StEStructFluctAnal** analysis = new StEStructFluctAnal*[numberOfAnalyses];
71  StEStructFluctAnal* currentAnalysis;
72  StEStructPairCuts* pcuts = new StEStructPairCuts(cutFile);
73 
74  for(int i=0;i<numberOfAnalyses;i++){
75  int ic=i;
76  if(numberOfAnalyses==1)ic=-1;
77  analysis[i] = new StEStructFluctAnal();
78  analysis[i]->initStructures(tcuts); // cuts define min and max vals
79  analysis[i]->setPairCuts(pcuts);
80  analysis[i]->setOutputFileName(getOutFileName(outputDir,scratchDir,"data",ic));
81 
82  }
83  estructMaker->SetAnalyses(analysis,numberOfAnalyses);
84 
85  estructMaker->Init();
86  estructMaker->startTimer();
87 
88  int counter=0, istat=0, i=0;
89  while (istat!=2) {
90 
91  istat=estructMaker->Make();
92 
93  i++; counter++;
94  if (counter==100) {
95  cout<<"doing event ="<<i<<endl;
96  counter=0;
97  }
98  if ( maxNumEvents!=0 && i>=maxNumEvents ) {
99  istat=2;
100  }
101  }
102  estructMaker->stopTimer();
103 
104 
105  //--- now write out stats and cuts ---
106  ofstream ofs(getOutFileName(outputDir,scratchDir,"stats"));
107  estructMaker->logAllStats(ofs);
108  ecuts->printCuts(ofs);
109  tcuts->printCuts(ofs);
110  // --- not in fluctuations --- pcuts->printCuts(ofs);
111  ofs<<endl;
112  ofs.close();
113 
114  // --> root cut file
115  TFile* tf=new TFile(getOutFileName(outputDir,scratchDir,"cuts"),"RECREATE");
116  ecuts->writeCutHists(tf);
117  tcuts->writeCutHists(tf);
118  tf->Close();
119 
120  // --> root qa histogram file
121  estructMaker->writeQAHists(getOutFileName(outputDir,scratchDir,"QA"));
122 
123  // --- write out the data
124  estructMaker->Finish();
125 }
126 
127 /**********************************************************************
128  *
129  * $Log: doEStructFluctHIJING.C,v $
130  * Revision 1.1 2006/04/04 22:15:57 porter
131  * a large number of changes were done to simplify the doEStruct macros
132  * in the sense that these are now more similar and should be easier
133  * for Duncan's GUI to build. Here are some examples.
134  *
135  *
136  *********************************************************************/