15 #include "StMessMgr.h"
16 #include "StGlauberTree.h"
26 case 0: LOG_INFO <<
"StGlauberTree read mode" << endm; break ;
27 case 1: LOG_INFO <<
"StGlauberTree write mode" << endm; break ;
29 Error(
"StGlauberTree",
"Mode should 0(read) or 1(write). abort");
39 sprintf(mNameNucleusA,
"%s",
"") ;
40 sprintf(mNameNucleusB,
"%s",
"") ;
45 mSkinDepthA = -9999. ;
46 mSkinDepthB = -9999. ;
53 mRepulsionD = -9999. ;
55 mTotalXsecError = 0.0 ;
58 mCollisionHardCore = 0 ;
59 mCollisionGaussian = 0 ;
66 mEfficiency = -9999. ;
67 mIsConstEfficiency = 0 ;
86 for(UInt_t i=0;i<2;i++){
91 for(UInt_t i=0;i<4;i++){
100 mEccPP4[i] = -9999. ;
110 Int_t StGlauberTree::InitBranch()
113 mTree->SetMakeClass(1);
114 mTree->SetBranchAddress(
"b", &mB, &b_b);
115 mTree->SetBranchAddress(
"npart", &mNpart, &b_npart);
116 mTree->SetBranchAddress(
"ncoll", &mNcoll, &b_ncoll);
117 mTree->SetBranchAddress(
"mult", &mMultiplicity, &b_mult);
118 mTree->SetBranchAddress(
"theta", mTheta, &b_theta);
119 mTree->SetBranchAddress(
"phi", mPhi, &b_phi);
120 mTree->SetBranchAddress(
"sumx", mSumX, &b_sumx);
121 mTree->SetBranchAddress(
"sumy", mSumY, &b_sumy);
122 mTree->SetBranchAddress(
"sumx2", mSumX2, &b_sumx2);
123 mTree->SetBranchAddress(
"sumy2", mSumY2, &b_sumy2);
124 mTree->SetBranchAddress(
"sumxy", mSumXY, &b_sumxy);
125 mTree->SetBranchAddress(
"eccrp2", mEccRP2, &b_eccrp2);
126 mTree->SetBranchAddress(
"eccpp2", mEccPP2, &b_eccpp2);
127 mTree->SetBranchAddress(
"eccpp3", mEccPP3, &b_eccpp3);
128 mTree->SetBranchAddress(
"eccpp4", mEccPP4, &b_eccpp4);
129 mTree->SetBranchAddress(
"pp2", mPP2, &b_pp2);
130 mTree->SetBranchAddress(
"pp3", mPP3, &b_pp3);
131 mTree->SetBranchAddress(
"pp4", mPP4, &b_pp4);
134 mHeader->SetMakeClass(1);
135 mHeader->SetBranchAddress(
"nameA", mNameNucleusA, &b_nameA);
136 mHeader->SetBranchAddress(
"nameB", mNameNucleusB, &b_nameB);
137 mHeader->SetBranchAddress(
"massNumberA", &mMassNumberA, &b_massNumberA);
138 mHeader->SetBranchAddress(
"massNumberB", &mMassNumberB, &b_massNumberB);
139 mHeader->SetBranchAddress(
"radiusA", &mRadiusA, &b_radiusA);
140 mHeader->SetBranchAddress(
"radiusB", &mRadiusB, &b_radiusB);
141 mHeader->SetBranchAddress(
"skinDepthA", &mSkinDepthA, &b_skinDepthA);
142 mHeader->SetBranchAddress(
"skinDepthB", &mSkinDepthB, &b_skinDepthB);
143 mHeader->SetBranchAddress(
"beta2A", &mBeta2A, &b_beta2A);
144 mHeader->SetBranchAddress(
"beta4A", &mBeta4A, &b_beta4A);
145 mHeader->SetBranchAddress(
"beta2B", &mBeta2B, &b_beta2B);
146 mHeader->SetBranchAddress(
"beta4B", &mBeta4B, &b_beta4B);
147 mHeader->SetBranchAddress(
"sigmaNN", &mSigmaNN, &b_sigmaNN);
148 mHeader->SetBranchAddress(
"sqrtSNN", &mSqrtSNN, &b_sqrtSNN);
149 mHeader->SetBranchAddress(
"repulsionD", &mRepulsionD, &b_repulsionD);
150 mHeader->SetBranchAddress(
"totalXsec", &mTotalXsec, &b_totalXsec);
151 mHeader->SetBranchAddress(
"totalXsecError", &mTotalXsecError, &b_totalXsecError);
152 mHeader->SetBranchAddress(
"smearHardCore", &mSmearHardCore, &b_smearHardCore);
153 mHeader->SetBranchAddress(
"smearGaussian", &mSmearGaussian, &b_smearGaussian);
154 mHeader->SetBranchAddress(
"collisionHardCore", &mCollisionHardCore, &b_collisionHardCore);
155 mHeader->SetBranchAddress(
"collisionGaussian", &mCollisionGaussian, &b_collisionGaussian);
156 mHeader->SetBranchAddress(
"maxB", &mBMax, &b_maxB);
157 mHeader->SetBranchAddress(
"neventsAccept", &mNeventsAccept, &b_neventsAccept);
158 mHeader->SetBranchAddress(
"neventsThrow", &mNeventsThrow, &b_neventsThrow);
159 mHeader->SetBranchAddress(
"npp", &mNpp, &b_npp);
160 mHeader->SetBranchAddress(
"k", &mK, &b_k);
161 mHeader->SetBranchAddress(
"x", &mX, &b_x);
162 mHeader->SetBranchAddress(
"efficiency", &mEfficiency, &b_efficiency);
163 mHeader->SetBranchAddress(
"isConstEfficiency", &mIsConstEfficiency, &b_isConstEfficiency);
164 mHeader->SetBranchAddress(
"version", &mVersion, &b_version);
175 mFile = TFile::Open(filename);
176 if(!mFile || !mFile->IsOpen()){
177 Error(
"StGlauberTree::Open",
"can't open %s", filename.Data());
180 LOG_INFO <<
"StGlauberTree::Open Open input ROOT file: " << mFile->GetName() << endm;
183 mTree = (TTree*) mFile->Get(
"tree");
185 Error(
"StGlauberTree::Open",
"No tree found in %s", filename.Data());
189 mHeader = (TTree*) mFile->Get(
"header");
191 Error(
"StGlauberTree::Open",
"No header found in %s", filename.Data());
199 if(mFile)
delete mFile ;
200 if(mTree)
delete mTree ;
201 if(mHeader)
delete mHeader ;
204 mFile = TFile::Open(filename,
"recreate",
"", 9);
205 if(!mFile || !mFile->IsOpen()){
206 Error(
"StGlauberTree::Open",
"can't open %s", filename.Data());
209 LOG_INFO <<
"StGlauberTree::Open Open output ROOT file: " << mFile->GetName() << endm;
212 LOG_INFO <<
"StGlauberTree::Open Init tree" << endm;
213 mTree =
new TTree(
"tree",
"Event-wise information for Fast MC glauber tree");
214 mTree->Branch(
"b", &mB,
"b/D") ;
215 mTree->Branch(
"npart", &mNpart,
"npart/i") ;
216 mTree->Branch(
"ncoll", &mNcoll,
"ncoll/i") ;
217 mTree->Branch(
"mult", &mMultiplicity,
"mult/i") ;
218 mTree->Branch(
"theta", mTheta,
"theta[2]/D") ;
219 mTree->Branch(
"phi", mPhi,
"phi[2]/D") ;
220 mTree->Branch(
"sumx", mSumX,
"sumx[4]/D") ;
221 mTree->Branch(
"sumy", mSumY,
"sumy[4]/D") ;
222 mTree->Branch(
"sumx2", mSumX2,
"sumx2[4]/D") ;
223 mTree->Branch(
"sumy2", mSumY2,
"sumy2[4]/D") ;
224 mTree->Branch(
"sumxy", mSumXY,
"sumxy[4]/D") ;
225 mTree->Branch(
"eccrp2", mEccRP2,
"eccrp2[4]/D") ;
226 mTree->Branch(
"eccpp2", mEccPP2,
"eccpp2[4]/D") ;
227 mTree->Branch(
"eccpp3", mEccPP3,
"eccpp3[4]/D") ;
228 mTree->Branch(
"eccpp4", mEccPP4,
"eccpp4[4]/D") ;
229 mTree->Branch(
"pp2", mPP2,
"pp2[4]/D") ;
230 mTree->Branch(
"pp3", mPP3,
"pp3[4]/D") ;
231 mTree->Branch(
"pp4", mPP4,
"pp4[4]/D") ;
233 mHeader =
new TTree(
"header",
"Constants used in the Fast MC glauber");
234 mHeader->Branch(
"nameA", mNameNucleusA,
"nameA[2]/C");
235 mHeader->Branch(
"nameB", mNameNucleusB,
"nameB[2]/C");
236 mHeader->Branch(
"massNumberA", &mMassNumberA,
"massNumberA/i");
237 mHeader->Branch(
"massNumberB", &mMassNumberB,
"massNumberB/i");
238 mHeader->Branch(
"radiusA", &mRadiusA,
"radiusA/F");
239 mHeader->Branch(
"radiusB", &mRadiusB,
"radiusB/F");
240 mHeader->Branch(
"skinDepthA", &mSkinDepthA,
"skinDepthA/F");
241 mHeader->Branch(
"skinDepthB", &mSkinDepthB,
"skinDepthB/F");
242 mHeader->Branch(
"beta2A", &mBeta2A,
"beta2A/F");
243 mHeader->Branch(
"beta4A", &mBeta4A,
"beta4A/F");
244 mHeader->Branch(
"beta2B", &mBeta2B,
"beta2B/F");
245 mHeader->Branch(
"beta4B", &mBeta4B,
"beta4B/F");
246 mHeader->Branch(
"sigmaNN", &mSigmaNN,
"sigmaNN/F");
247 mHeader->Branch(
"sqrtSNN", &mSqrtSNN,
"sqrtSNN/F");
248 mHeader->Branch(
"repulsionD", &mRepulsionD,
"repulsionD/F");
249 mHeader->Branch(
"totalXsec", &mTotalXsec,
"totalXsec/F");
250 mHeader->Branch(
"totalXsecError", &mTotalXsecError,
"totalXsecError/F");
251 mHeader->Branch(
"smearHardCore", &mSmearHardCore,
"smearHardCore/i");
252 mHeader->Branch(
"smearGaussian", &mSmearGaussian,
"smearGaussian/i");
253 mHeader->Branch(
"collisionHardCore", &mCollisionHardCore,
"collisionHardCore/i");
254 mHeader->Branch(
"collisionGaussian", &mCollisionGaussian,
"collisionGaussian/i");
255 mHeader->Branch(
"maxB", &mBMax,
"maxB/F");
256 mHeader->Branch(
"neventsAccept", &mNeventsAccept,
"neventsAccept/i");
257 mHeader->Branch(
"neventsThrow", &mNeventsThrow,
"neventsThrow/i");
258 mHeader->Branch(
"npp", &mNpp,
"npp/F");
259 mHeader->Branch(
"k", &mK,
"k/F");
260 mHeader->Branch(
"x", &mX,
"x/F");
261 mHeader->Branch(
"efficiency", &mEfficiency,
"efficiency/F");
262 mHeader->Branch(
"isConstEfficiency", &mIsConstEfficiency,
"isConstEfficiency/i");
263 mHeader->Branch(
"version", &mVersion,
"version/i");
273 if( mMode == 1 ) mFile->GetList()->Sort() ;
279 return mTree->Fill();
285 return mHeader->Fill();
291 LOG_INFO <<
"StGlauberTree::Close close ROOT file : " << mFile->GetName() << endm;
292 if(mMode==1) mFile->Write();
301 return mTree->GetEntries() ;
307 return mTree->GetEntry(ievent);
311 Double_t StGlauberTree::GetSigmaA2(
const Double_t a2,
const Double_t a)
const
313 const Double_t val = a2 - a*a ;
315 Error(
"GetSigmaA2",
"{a^2}-{a}^2 < 0 (= %1.3f)", val);
323 Double_t StGlauberTree::GetSigmaXY(
const Double_t xy,
const Double_t x,
const Double_t y)
const
334 Error(
"StGlauberTree::GetSRP",
"Unknown id, id=%3d. abort",
id);
338 const Double_t sigmax2 = GetSigmaA2(mSumX2[
id], mSumX[
id]);
339 const Double_t sigmay2 = GetSigmaA2(mSumY2[
id], mSumY[
id]);
340 const Double_t area = TMath::Pi() * TMath::Sqrt(sigmax2*sigmay2) ;
351 Error(
"StGlauberTree::GetSPP",
"Unknown id, id=%3d. abort",
id);
355 const Double_t sigmax2 = GetSigmaA2(mSumX2[
id], mSumX[
id]);
356 const Double_t sigmay2 = GetSigmaA2(mSumY2[
id], mSumY[
id]);
357 const Double_t sigmaxy = GetSigmaXY(mSumXY[
id], mSumX[
id], mSumY[
id]);
358 const Double_t term = sigmax2*sigmay2 - sigmaxy*sigmaxy ;
359 if( term < 0 )
return -9999. ;
361 return TMath::Pi() * TMath::Sqrt(term) ;
365 void StGlauberTree::SetNameNucleusA(
const Char_t* val)
367 sprintf(mNameNucleusA,
"%s", val);
371 void StGlauberTree::SetNameNucleusB(
const Char_t* val)
373 sprintf(mNameNucleusB,
"%s", val);
Int_t Clear()
Default destructor.
Double_t GetSPP(const UInt_t id) const
Int_t GetEntries() const
Close ROOT file.
void Sort()
Open ROOT file, initialize tree.
Int_t FillHeader()
Fill event-wise tree.
Int_t GetEntry(const Int_t ievent)
Get entries.
Int_t Close()
Fill header tree.
virtual ~StGlauberTree()
Default constructor.
Double_t GetSRP(const UInt_t id) const
Int_t Open(const TString filename)
Clear data members.
Int_t Fill()
Sort outputs in ROOT file.