StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StGlauberAnalysisMaker.cxx
1 /******************************************************************************
2  * $Id: StGlauberAnalysisMaker.cxx,v 1.3 2012/04/25 05:05:08 hmasui Exp $
3  * $Log: StGlauberAnalysisMaker.cxx,v $
4  * Revision 1.3 2012/04/25 05:05:08 hmasui
5  * Fix the multiplicity calculation in the analysis maker, use multiplicity from tree. Added higher harmonics. Unit weight for multiplicity related quantities. Use STAR logger.
6  *
7  * Revision 1.2 2010/11/21 02:27:56 hmasui
8  * Add re-weighting. Calculate multiplicity from Npart and Ncoll. Use STAR logger
9  *
10  ******************************************************************************/
11 
12 #include <assert.h>
13 #include <fstream>
14 
15 #include "TError.h"
16 #include "TFile.h"
17 #include "TSystem.h"
18 #include "TTree.h"
19 #include "TSystem.h"
20 
21 #include "StMessMgr.h"
22 #include "StCentralityMaker/StCentrality.h"
23 #include "StCentralityMaker/StCentralityMaker.h"
24 #include "StCentralityMaker/StNegativeBinomial.h"
25 #include "StGlauberConstUtilities.h"
26 #include "StGlauberHistogramMaker.h"
27 #include "StGlauberCumulantHistogramMaker.h"
28 #include "StGlauberTree/StGlauberTree.h"
29 #include "StGlauberUtilities/StGlauberUtilities.h"
30 
31 #include "StGlauberAnalysisMaker.h"
32 
33 using std::fstream ;
34 using std::map ;
35 using std::pair ;
36 
37 ClassImp(StGlauberAnalysisMaker)
38 
39  const TString StGlauberAnalysisMaker::mTypeName[] = {
40  "default", "small", "large", "smallXsec", "largeXsec", "gauss",
41  "smallNpp", "largeNpp", "smallTotal", "largeTotal",
42  "lowrw", "highrw"
43  };
44 
45 const TString StGlauberAnalysisMaker::mDescription[] = {
46  "default",
47  "small R, large d",
48  "large R, small d",
49  "small #sigma_{NN}",
50  "large #sigma_{NN}",
51  // "gray disk overlap",
52  "gaussian overlap",
53  "small n_{pp}, large x",
54  "large n_{pp}, small x",
55  "-5\% total cross section",
56  "+5\% total cross section",
57  "+2(-2) sigma p0 (p1) parameter for re-weighting",
58  "-2(+2) sigma p0 (p1) parameter for re-weighting"
59 };
60 
61 // const UInt_t StGlauberAnalysisMaker::mCentralityId[] = {
62 // 0, // "default",
63 // 0, // "small R, large d",
64 // 0, // "large R, small d",
65 // 0, // "small #sigma_{NN}",
66 // 0, // "large #sigma_{NN}",
67 // 0, // "gray disk overlap",
68 // 0, // "gaussian overlap",
69 // 1, // "small n_{pp}, large x",
70 // 2, // "large n_{pp}, small x",
71 // 0, // "-5% total cross section",
72 // 0 // "+5% total cross section"
73 // };
74 
75 //____________________________________________________________________________________________________
76 // Default constructor
77 StGlauberAnalysisMaker::StGlauberAnalysisMaker(const TString type, const TString system, const TString outputFileName,
78  const TString tableDir)
79 : mType(type), mOutputFile(0), mOutputFileName(outputFileName),
80  mUnitWeight(kFALSE), // Unit weight flag (default is false, use multiplicity weight)
81  mReweighting(kFALSE) // Re-weighting flag (default is false, no re-weighting correction)
82 {
83  // Init StGlauberTree (read mode)
84  mGlauberTree = new StGlauberTree(0);
85 
86  // System should be like "AuAu_200GeV" (case insensitive)
87  mCentralityMaker = new StCentralityMaker(system) ;
88 
89 
90  // for(Int_t it=0; it<mNMaxType; it++){
91  // LOG_INFO << Form("StGlauberAnalysisMaker Define centrality id map: id=%5d for type %20s",
92  // mCentralityId[it], mTypeName[it].Data())
93  // << endm;
94  // mCentralityIdMap.insert( pair<const TString, const UInt_t>(mTypeName[it], mCentralityId[it]) );
95  // }
96 
97  // Make sure table directory exists (0=directory exists)
98  if ( gSystem->AccessPathName(tableDir.Data()) == 1 ){
99  Error("StGlauberAnalysisMaker", "can't find directory %s", tableDir.Data());
100  assert(0);
101  }
102 
103  mNevents = 0 ;
104 
105  Init(tableDir) ;
106 }
107 
108 //____________________________________________________________________________________________________
109 // Default destructor
111 {
112  if(mCentralityMaker) delete mCentralityMaker ;
113  if(mGlauberTree) delete mGlauberTree ;
114 }
115 
116 //____________________________________________________________________________________________________
117 Bool_t StGlauberAnalysisMaker::Init(const TString tableDir)
118 {
120  if(mOutputFile) return kTRUE ;
121 
122  mOutputFile = TFile::Open(mOutputFileName, "recreate");
123  if(!mOutputFile || !mOutputFile->IsOpen() || mOutputFile->IsZombie()){
124  Error("StGlauberAnalysisMaker::Init", "can't open %s", mOutputFileName.Data());
125  assert(0);
126  }
127  LOG_INFO << "StGlauberAnalysisMaker::Init Open output ROOT file: " << mOutputFile->GetName() << endm;
128 
129  const TString title(mType) ;
130  mImpactParameter = new StGlauberHistogramMaker("ImpactParameter", title, "impact parameter b (fm)",
131  StGlauberConstUtilities::GetImpactParameterBin(), 0.0, StGlauberConstUtilities::GetImpactParameterMax())
132  ;
133 
134  mNpart = new StGlauberHistogramMaker("Npart", title, "N_{part}",
135  StGlauberConstUtilities::GetNpartBin(), 0.0, StGlauberConstUtilities::GetNpartMax())
136  ;
137 
138  mNcoll = new StGlauberHistogramMaker("Ncoll", title, "N_{coll}",
139  StGlauberConstUtilities::GetNcollBin(), 0.0, StGlauberConstUtilities::GetNcollMax())
140  ;
141 
142  mMultiplicity = new StGlauberHistogramMaker("Multiplicity", title, "Multiplicity",
143  StGlauberConstUtilities::GetMultiplicityBin(), 0.0, StGlauberConstUtilities::GetMultiplicityMax())
144  ;
145 
146  // Aera
147  const Int_t areaBin = 100 ;
148  const Double_t areaMin = 0.0 ;
149  const Double_t areaMax = 50.0 ;
150  mAreaRP = new StGlauberHistogramMaker("AreaRP", title, "#LTS_{RP}#GT", areaBin, areaMin, areaMax);
151  mAreaPP = new StGlauberHistogramMaker("AreaPP", title, "#LTS_{PP}#GT", areaBin, areaMin, areaMax) ;
152 
153  // Eccentricity
154  const Int_t eccBin = 100 ;
155  const Double_t eccMin = -1.0 ;
156  const Double_t eccMax = 1.0 ;
157  mEccRP = new StGlauberCumulantHistogramMaker("EccRP", title, "#LT#varepsilon_{RP}#GT", eccBin, eccMin, eccMax);
158  mEccRPM = new StGlauberCumulantHistogramMaker("EccRPM", title, "#LT#varepsilon_{RP}#GT", eccBin, eccMin, eccMax);
159 
160  for(Int_t io=0; io<3; io++){
161  mEccPP[io] = new StGlauberCumulantHistogramMaker(Form("EccPP_%d", io), title, Form("#LT#varepsilon_{PP,%d}#GT", io+2), eccBin/2, 0.0, eccMax) ;
162  mEccPPM[io] = new StGlauberCumulantHistogramMaker(Form("EccPPM_%d", io), title, Form("#LT#varepsilon_{PP,%d}#GT", io+2), eccBin/2, 0.0, eccMax) ;
163  }
164 
165  // Set table output directory
166  mImpactParameter->SetTableDirectory(tableDir);
167  mNpart->SetTableDirectory(tableDir);
168  mNcoll->SetTableDirectory(tableDir);
169  mMultiplicity->SetTableDirectory(tableDir);
170  mAreaRP->SetTableDirectory(tableDir);
171  mAreaPP->SetTableDirectory(tableDir);
172  mEccRP->SetTableDirectory(tableDir);
173  mEccRPM->SetTableDirectory(tableDir);
174  for(Int_t io=0; io<3; io++){
175  mEccPP[io]->SetTableDirectory(tableDir);
176  mEccPPM[io]->SetTableDirectory(tableDir);
177  }
178 
179  mOutputFile->GetList()->Sort() ;
180 
181  return kTRUE ;
182 }
183 
184 //____________________________________________________________________________________________________
186 {
188  if(mDebug){
189  LOG_INFO << "StGlauberAnalysisMaker::Make Set x-axis" << endm;
190  }
191 
192  const UInt_t centId = 0 ; // Fix default (no need to change id unless one calculate multiplicity here)
193  // const UInt_t centId = mCentralityIdMap[mType] ; // 0:default, 1:small npp (large x), 2:large npp (small x)
194 
195  // Calculate multiplicity here
196  // in order to deal with the change of centrality bins
197  const Double_t multiplicity = mGlauberTree->GetMultiplicity() ;
198  // const Double_t npart = static_cast<Double_t>(mGlauberTree->GetNpart()) ;
199  // const Double_t ncoll = static_cast<Double_t>(mGlauberTree->GetNcoll()) ;
200  // const Double_t multiplicity = mCentralityMaker->GetNegativeBinomial()->GetMultiplicity(npart, ncoll);
201 
202  // Re-weighting correction
203  const Double_t reweighting = (mReweighting) ? mCentralityMaker->GetCentrality(centId)->GetReweighting(multiplicity) : 1.0 ;
204 
206  if( mReweighting && StGlauberUtilities::instance()->GetUniform() > reweighting) return kFALSE ;
207 
208  // mImpactParameter->SetXaxis(*mGlauberTree, *(mCentralityMaker->GetCentrality(centId)), mType);
209  // mNpart ->SetXaxis(*mGlauberTree, *(mCentralityMaker->GetCentrality(centId)), mType);
210  // mNcoll ->SetXaxis(*mGlauberTree, *(mCentralityMaker->GetCentrality(centId)), mType);
211  // mMultiplicity ->SetXaxis(*mGlauberTree, *(mCentralityMaker->GetCentrality(centId)), mType);
212  // mAreaRP ->SetXaxis(*mGlauberTree, *(mCentralityMaker->GetCentrality(centId)), mType);
213  // mAreaPP ->SetXaxis(*mGlauberTree, *(mCentralityMaker->GetCentrality(centId)), mType);
214  // mEccRP ->SetXaxis(*mGlauberTree, *(mCentralityMaker->GetCentrality(centId)), mType);
215  // mEccRPM ->SetXaxis(*mGlauberTree, *(mCentralityMaker->GetCentrality(centId)), mType);
216  mImpactParameter->SetXaxis(*mGlauberTree, *mCentralityMaker, mType);
217  mNpart ->SetXaxis(*mGlauberTree, *mCentralityMaker, mType);
218  mNcoll ->SetXaxis(*mGlauberTree, *mCentralityMaker, mType);
219  mMultiplicity ->SetXaxis(*mGlauberTree, *mCentralityMaker, mType);
220  mAreaRP ->SetXaxis(*mGlauberTree, *mCentralityMaker, mType);
221  mAreaPP ->SetXaxis(*mGlauberTree, *mCentralityMaker, mType);
222  mEccRP ->SetXaxis(*mGlauberTree, *mCentralityMaker, mType);
223  mEccRPM ->SetXaxis(*mGlauberTree, *mCentralityMaker, mType);
224 
225  for(Int_t io=0; io<3; io++){
226  // mEccPP[io]->SetXaxis(*mGlauberTree, *(mCentralityMaker->GetCentrality(centId)), mType);
227  // mEccPPM[io]->SetXaxis(*mGlauberTree, *(mCentralityMaker->GetCentrality(centId)), mType);
228  mEccPP[io]->SetXaxis(*mGlauberTree, *mCentralityMaker, mType);
229  mEccPPM[io]->SetXaxis(*mGlauberTree, *mCentralityMaker, mType);
230  }
231 
232  if(mDebug){
233  LOG_INFO << "StGlauberAnalysisMaker::Make Start fill: " << endm;
234  }
235 
237  const Double_t weight = (mUnitWeight) ? 1.0 // Unit weight (event-wise average)
238  : static_cast<Double_t>( multiplicity ) ; // Multiplicity weight (particle-wise average)
239 
240  // Unit weight
241  mImpactParameter->Fill(mGlauberTree->GetB(), 1.0) ;
242  mNpart->Fill(mGlauberTree->GetNpart(), 1.0) ;
243  mNcoll->Fill(mGlauberTree->GetNcoll(), 1.0) ;
244  mMultiplicity->Fill(multiplicity, 1.0) ;
245 
246  if(mDebug){
247  LOG_INFO << "StGlauberAnalysisMaker::Make reweighting = " << reweighting
248  << ", b = " << mGlauberTree->GetB() << " fm"
249  << ", npart = " << mGlauberTree->GetNpart()
250  << ", ncoll = " << mGlauberTree->GetNcoll()
251  << ", mult = " << multiplicity
252  << endm ;
253  }
254 
255  const Double_t areaRP = mGlauberTree->GetSRP(0) ;
256  mAreaRP->Fill(areaRP, weight) ;
257 
258  const Double_t areaPP = mGlauberTree->GetSPP(0) ;
259  if( areaPP > -9999. ) mAreaPP->Fill(areaPP, weight) ;
260 
261  // LOG_INFO << areaRP << " " << areaPP << endm;
262 
263  // Reaction plane
264  const Double_t eccRP = mGlauberTree->GetEccRP2(0) ;
265  if( eccRP > -9999.) mEccRP->Fill(eccRP, weight) ;
266 
267  const Double_t eccRPM = mGlauberTree->GetEccRP2(2) ;
268  if( eccRP > -9999.) mEccRPM->Fill(eccRPM, weight) ;
269 
270  // Participant plane
271  for(Int_t io=0; io<3; io++){
272  Double_t eccPP = -9999. ;
273  Double_t eccPPM = -9999. ;
274  if( io == 0 ){ eccPP = mGlauberTree->GetEccPP2(0) ; eccPPM = mGlauberTree->GetEccPP2(2) ; }
275  else if( io == 1 ){ eccPP = mGlauberTree->GetEccPP3(0) ; eccPPM = mGlauberTree->GetEccPP3(2) ; }
276  else if( io == 2 ){ eccPP = mGlauberTree->GetEccPP4(0) ; eccPPM = mGlauberTree->GetEccPP4(2) ; }
277 
278  if( eccPP > -9999.) mEccPP[io]->Fill(eccPP, weight) ;
279  if( eccPPM > -9999.) mEccPPM[io]->Fill(eccPPM, weight) ;
280  }
281 
282  return kTRUE ;
283 }
284 
285 //____________________________________________________________________________________________________
286 Bool_t StGlauberAnalysisMaker::RunFile(const TString inputFileName)
287 {
288  mGlauberTree->Open(inputFileName);
289 
290  const Int_t nevents = mGlauberTree->GetEntries() ;
291  LOG_INFO << Form("StGlauberAnalysisMaker::RunFile Process %10d events ...", nevents) << endm;
292 
293  for(Int_t ievent=0; ievent<nevents; ievent++){
294  mGlauberTree->Clear() ;
295 
296  if(mDebug){
297  LOG_INFO << "StGlauberAnalysisMaker::RunFile Event# = " << ievent << endm;
298  }
299 
300  mGlauberTree->GetEntry(ievent);
301 
303  const Bool_t isEventOk = Make() ;
304  if(isEventOk) mNevents++;
305 
306 
308  if( ievent%1000 == 0 ){
309  LOG_INFO << "StGlauberAnalysisMaker::RunFile ";
310  LOG_INFO << Form("event %10d/%10d : (Npart, Ncoll, b(fm), mult, cent, {x^2}, {x}) = (%5d, %5d, %1.2f, %5d, %1.1f, %1.4f, %1.4f)",
311  mNevents, ievent, mGlauberTree->GetNpart(), mGlauberTree->GetNcoll(), mGlauberTree->GetB(),
312  mGlauberTree->GetMultiplicity(),
313  mCentralityMaker->GetCentrality()->GetCentrality(mGlauberTree->GetMultiplicity()),
314  mGlauberTree->GetSumX2(0), mGlauberTree->GetSumX(0)
315  )
316  << endm;
317  }
318  }
319 
321  if(mDebug){
322  LOG_INFO << "StGlauberAnalysisMaker::RunFile Close input file" << endm;
323  }
324  mGlauberTree->Close() ;
325 
326  return kTRUE ;
327 }
328 
329 //____________________________________________________________________________________________________
330 Bool_t StGlauberAnalysisMaker::Run(const TString inputFileList)
331 {
332  ifstream fin(inputFileList.Data());
333  if(!fin){
334  Error("StGlauberAnalysisMaker::run", "can't find %s", inputFileList.Data());
335  assert(fin);
336  }
337  LOG_INFO << "StGlauberAnalysisMaker::Run Open file list: " << inputFileList.Data() << endm;
338 
339  TString file ;
340  while ( fin >> file ){
341  RunFile(file);
342  }
343 
344  return kTRUE ;
345 }
346 
347 //____________________________________________________________________________________________________
349 {
354 
355  mOutputFile->cd();
356  mImpactParameter->Finish(mType) ;
357  mNpart->Finish(mType) ;
358  mNcoll->Finish(mType) ;
359  mMultiplicity->Finish(mType) ;
360  mAreaRP->Finish(mType) ;
361  mAreaPP->Finish(mType) ;
362  mEccRP->Finish(mType) ;
363  mEccRPM->Finish(mType) ;
364  for(Int_t io=0; io<3; io++){
365  mEccPP[io]->Finish(mType) ;
366  mEccPPM[io]->Finish(mType) ;
367  }
368 
369  mOutputFile->GetList()->Sort() ;
370 
372  LOG_INFO << "StGlauberAnalysisMaker::Finish Write/Close output file: " << mOutputFile->GetName() << endm;
373  mOutputFile->Write();
374  mOutputFile->Close();
375 
376  return kTRUE ;
377 }
378 
379 //____________________________________________________________________________________________________
381 {
382  mUnitWeight = kTRUE ;
383  LOG_INFO << "StGlauberAnalysisMaker::UnitWeightOn Use unit weight" << endm ;
384 }
385 
386 //____________________________________________________________________________________________________
388 {
389  mReweighting = kTRUE ;
390  LOG_INFO << "StGlauberAnalysisMaker::ReweightingOn Apply re-weighting correction" << endm;
391 }
392 
393 //____________________________________________________________________________________________________
395 {
396  mDebug = 1 ;
397 
398  mImpactParameter->DebugOn() ;
399  mNpart->DebugOn() ;
400  mNcoll->DebugOn() ;
401  mMultiplicity->DebugOn() ;
402  mAreaRP->DebugOn() ;
403  mAreaPP->DebugOn() ;
404  mEccRP->DebugOn() ;
405  mEccRPM->DebugOn() ;
406  for(Int_t io=0; io<3; io++){
407  mEccPP[io]->DebugOn() ;
408  mEccPPM[io]->DebugOn() ;
409  }
410 
411  LOG_INFO << "StGlauberAnalysisMaker::DebugOn Print debugging messages" << endm;
412 }
413 
414 
Int_t Clear()
Default destructor.
Double_t GetSPP(const UInt_t id) const
Definition: FJcore.h:367
Int_t GetEntries() const
Close ROOT file.
Bool_t Make()
Default destructor.
Bool_t Run(const TString inputFileList)
Loop over all events in one file.
void SetTableDirectory(const TString directory)
Default destructor.
Bool_t RunFile(const TString inputFileName="icmaker.root")
Make one event.
void UnitWeightOn()
Finish analysis.
Int_t GetEntry(const Int_t ievent)
Get entries.
void DebugOn()
Apply re-weighting correction.
void SetXaxis(const StGlauberTree &tree, const StCentralityMaker &centralityMaker, const TString type)
Initialize histograms.
virtual void Fill(const Double_t y, const Double_t weight)
Set X-axis variable.
Int_t Close()
Fill header tree.
void DebugOn()
Get histogram name.
void Fill(const Double_t y, const Double_t weight)
Set X-axis variable.
Double_t GetReweighting(const UInt_t multiplicity) const
Get trigger bias.
Bool_t Finish()
Loop over all file lists.
virtual void Finish(const TString type)
Fill histogram &#39;y&#39; value with &#39;weight&#39;.
Double_t GetSRP(const UInt_t id) const
Double_t GetCentrality(const UInt_t multiplicity, const UInt_t mode=0) const
Print help messages.
Int_t Open(const TString filename)
Clear data members.
virtual ~StGlauberAnalysisMaker()
Default constructor.
void ReweightingOn()
Use unit weight instead of multiplicity weight.