StQGSMdstQAMaker.cxx 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357
  1. #include "StQGSMdstQAMaker.h"
  2. ClassImp(StQGSMdstQAMaker)
  3. //_________________
  4. StQGSMdstQAMaker::StQGSMdstQAMaker(const char *dirName,
  5. const char *fileName,
  6. const char *filter,
  7. int maxFiles) {
  8. mDir = string(dirName);
  9. mFileName = string(fileName);
  10. mFilter = string(filter);
  11. mTree = 0;
  12. mChain = 0;
  13. mO97Event = 0;
  14. mEventId = 0;
  15. }
  16. //_________________
  17. Int_t StQGSMdstQAMaker::Init() {
  18. std::cout << "[StQGSMdstQAMaker]: Initialization... ";
  19. InitRead(mDir, mFileName, mFilter, mMaxFiles);
  20. mNEvents = (unsigned int)mChain->GetEntries();
  21. mOutFile = new TFile(mOutFileName, "RECREATE");
  22. if (!mOutFile) {
  23. std::cout << "FAIL" << std::endl;
  24. return kStErr;
  25. }
  26. else
  27. std::cout << "OK" << std::endl;
  28. //
  29. // Load PDG database
  30. //
  31. pdgDb = new TDatabasePDG;
  32. pdgDb->ReadPDGTable("StRoot/StFemtoDstMaker/pdg_table.txt");
  33. //
  34. // Creating event histograms
  35. //
  36. int refMultBins = 500;
  37. float refMultLo = 0.;
  38. float refMultHi = 500;
  39. hRefMultP90 = new TH1F("hRefMultP90", "reference multiplicity (greg) p_{#perp} > 0.09 GeV/c;RefMult;#", refMultBins, refMultLo, refMultHi);
  40. hRefMultP100 = new TH1F("hRefMultP100", "reference multiplicity (greg) p_{#perp} > 0.1 GeV/c;RefMult;#", refMultBins, refMultLo, refMultHi);
  41. hRefMultP120 = new TH1F("hRefMultP120", "reference multiplicity (greg) p_{#perp} > 0.12 GeV/c;RefMult;#", refMultBins, refMultLo, refMultHi);
  42. hRefMultP150 = new TH1F("hRefMultP150", "reference multiplicity (greg) p_{#perp} > 0.15 GeV/c;RefMult;#", refMultBins, refMultLo, refMultHi);
  43. hImpPar = new TH1F("hImpPar", "impact parameter;imp (fm/c);#", 100, 0., 20.);
  44. hSph = new TH1F("hSph",
  45. "Transverse sphericity (|#eta| < 0.5, p_{#perp} > 0.15 GeV/c);S_{#perp},#frac{dN}{dS_{#perp}}",
  46. 100, 0., 1.);
  47. hSph2 = new TH1F("hSph2",
  48. "Transverse sphericity (|#eta| < 1.0, p_{#perp} > 0.15 GeV/c);S_{#perp},#frac{dN}{dS_{#perp}}",
  49. 100, 0., 1.);
  50. hImpVsRef = new TH2F("hImpVsRef", "p_{#perp} > 0.15 [GeV/c] && |#eta| < 0.5;b [fm];RefMult", 100, 0., 20., refMultBins, refMultLo, refMultHi);
  51. //
  52. // Creating track histograms
  53. //
  54. hVx = new TH1F("hVx", "x freeze-out position;V_{x} (fm);#", 100, -2., 2.);
  55. hVy = new TH1F("hVy", "y freeze-out position;V_{y} (fm);#", 100, -2., 2.);
  56. hVz = new TH1F("hVz", "z freeze-out position;V_{z} (fm);#", 100, -2., 2.);
  57. hPx = new TH1F("hPx", "single particle p_{x};p_{x} (GeV/c);#", 200, -2., 2.);
  58. hPy = new TH1F("hPy", "single particle p_{y};p_{y} (GeV/c);#", 200, -2., 2.);
  59. hPz = new TH1F("hPz", "single particle p_{z};p_{z} (GeV/c);#", 200, -2., 2.);
  60. hP = new TH1F("hP", "single particle p;p (GeV/c);#", 400, 0., 2.);
  61. hPt = new TH1F("hPt", "single particle p_{T};p_{T} (GeV/c);#", 400, 0., 2.);
  62. hEta = new TH1F("hEta", ";#eta;#", 200, -10., 10.);
  63. hEtaInt = new TH1F("hEtaInt", ";#eta;#", 200, -10., 10.);
  64. hMSqrVsPt = new TH2F("hMSqrVsPt",
  65. "m^{2} vs p_{T};p_{T}*charge (GeV/c);m^{2} (GeV^{2})",
  66. 200, -2., 2., // Pt
  67. 100, 0., 2.); // msqr
  68. hMomElectron = new TH1F("hMomElectron", "Momentum of e^{#pm};p (GeV/c);#frac{dN}{dp}",
  69. 250, 0., 2.5);
  70. hMomPion = new TH1F("hMomPion", "Momentum of #pi^{#pm};p (GeV/c);#frac{dN}{dp}",
  71. 250, 0., 2.5);
  72. hMomKaon = new TH1F("hMomKaon", "Momentum of K^{#pm};p (GeV/c);#frac{dN}{dp}",
  73. 250, 0., 2.5);
  74. hMomProton = new TH1F("hMomProton", "Momentum of p^{#pm};p (GeV/c);#frac{dN}{dp}",
  75. 250, 0., 2.5);
  76. hRfrVsTfr_pion = new TH2F("hRfrVsTfr_pion", ";R^{#pi^{ch}}_{freeze out} [fm];#tau^{#pi^{ch}}_{freeze out} [fm/c]",
  77. 300, 0., 105.,
  78. 300, 0., 105.);
  79. hRfrVsTfr_kaon = new TH2F("hRfrVsTfr_kaon", ";R^{K^{ch}}_{freeze out} [fm];#tau^{K^{ch}}_{freeze out} [fm/c]",
  80. 300, 0., 105.,
  81. 300, 0., 105.);
  82. hRfrVsTfr_proton = new TH2F("hRfrVsTfr_proton", ";R^{p^{#pm}}_{freeze out} [fm];#tau^{p^{#pm}}_{freeze out} [fm/c]",
  83. 300, 0., 105.,
  84. 300, 0., 105.);
  85. hdNdTfr_pion = new TH1F("hdNdTfr_pion", ";#frac{dN}{d#tau^{#pi^{ch}_{freezeout}}};#tau^{#pi^{ch}}_{freezeout} [fm/c]",
  86. 105, 0., 105.);
  87. hdNdTfr_kaon = new TH1F("hdNdTfr_kaon", ";#frac{dN}{d#tau^{K^{ch}_{freezeout}}};#tau^{K^{ch}}_{freezeout} [fm/c]",
  88. 105, 0., 105.);
  89. hdNdTfr_proton = new TH1F("hdNdTfr_proton", ";#frac{dN}{d#tau^{p^{ch}_{freezeout}}};#tau^{p^{ch}}_{freezeout} [fm/c]",
  90. 105, 0., 105.);
  91. return kStOk;
  92. }
  93. //_________________
  94. Int_t StQGSMdstQAMaker::Finish() {
  95. UninitRead();
  96. mOutFile->Write();
  97. mOutFile->Close();
  98. delete pdgDb;
  99. return kStOk;
  100. }
  101. //_________________
  102. int StQGSMdstQAMaker::FillChain(TChain *chain, char *dir,
  103. const char *filter, int maxFiles) {
  104. TSystem *gSystem = new TSystem();
  105. if (!gSystem) {
  106. std::cout << "[StQGSMdstQAMaker]: can't allocate memory for TSystem" << std::endl;;
  107. return 0;
  108. }
  109. void *gDir = gSystem->OpenDirectory(dir);
  110. if (!gDir) {
  111. std::cout << "[StQGSMdstQAMaker]: can't open directory "
  112. << dir << std::endl;
  113. delete gSystem;
  114. return 0;
  115. }
  116. int count = 0;
  117. char *file;
  118. while ((file = (char *)gSystem->GetDirEntry(dir))) {
  119. if (strcmp(file, ".") == 0 || strcmp(file, "..") == 0)
  120. continue;
  121. if (strstr(file, filter)) {
  122. char *gFullName = gSystem->ConcatFileName(dir, file);
  123. std::cout << "[StQGSMdstQAMaker]: Adding "
  124. << gFullName << " to the chain" << std::endl;
  125. chain->Add(gFullName);
  126. delete gFullName;
  127. count++;
  128. if ((maxFiles > 0) && (count > maxFiles)) break;
  129. }
  130. }
  131. std::cout << "[StQGSMdstQAMaker]: Added " << count
  132. << " files to the chain" << std::endl;
  133. delete gSystem;
  134. return count;
  135. }
  136. //_________________
  137. int StQGSMdstQAMaker::FillChain(TChain *chain, const char *fileName,
  138. int maxFiles) {
  139. std::ifstream inStream(fileName);
  140. if (!inStream.is_open()) {
  141. std::cout << "[StFemtoDstQAMaker]: can't open file list: "
  142. << fileName << std::endl;
  143. return 0;
  144. }
  145. std::cout << "[StFemtoDstQAMaker]: using file list: "
  146. << fileName << std::endl;
  147. int count = 0;
  148. char buf[0xFF];
  149. for ( ; inStream.good(); ) {
  150. inStream.getline(buf, 0xFF);
  151. TString lFileName(buf);
  152. if (lFileName.Contains("root")) {
  153. chain->Add(buf);
  154. count++;
  155. if ((maxFiles > 0) && (count > maxFiles)) break;
  156. }
  157. }
  158. std::cout << "[StQGSMdstQAMaker]: Added " << count
  159. << " files to the chain" << std::endl;
  160. return count;
  161. }
  162. //_________________
  163. int StQGSMdstQAMaker::InitRead(string dir, string fileName,
  164. string filter, int maxFiles) {
  165. mEventId = 0;
  166. mChain = new TChain("StO97Dst", "StO97Dst");
  167. std::cout << "[StQGSMdstQAMaker]: Call InitRead" << std::endl;
  168. int numFiles = 0;
  169. if (!fileName.empty()) {
  170. if (strstr(fileName.c_str(), ".lis") ||
  171. strstr(fileName.c_str(), ".list")) {
  172. numFiles = FillChain(mChain,
  173. (dir + fileName).c_str(),
  174. maxFiles);
  175. }
  176. else {
  177. mChain->Add((dir + fileName).c_str());
  178. numFiles++;
  179. }
  180. } else {
  181. numFiles = FillChain(mChain, (char *)dir.c_str(), // not cool
  182. filter.c_str(), maxFiles);
  183. }
  184. mChain->SetBranchAddress("StO97Event", &mO97Event);
  185. mNEvents = (unsigned int)mChain->GetEntries();
  186. return numFiles;
  187. }
  188. //_________________
  189. void StQGSMdstQAMaker::UninitRead() {
  190. if (mChain) delete mChain;
  191. mO97Event = 0;
  192. mChain = 0;
  193. }
  194. //_________________
  195. int StQGSMdstQAMaker::GetNEvents() {
  196. if (mChain)
  197. return mNEvents;
  198. else
  199. return -1;
  200. }
  201. //_________________
  202. Int_t StQGSMdstQAMaker::Make() {
  203. if (!mNEvents) {
  204. std::cout << "[StQGSMdstQAMaker]: no events to read" << std::endl;
  205. return 0;
  206. }
  207. mO97Event->Clear();
  208. int bytes = mChain->GetEntry(mEventId++);
  209. if (mNEvents < mEventId) {
  210. std::cout << "[StQGSMdstQAMaker]: EOF" << std::endl;
  211. return 0;
  212. }
  213. if (!bytes) {
  214. std::cout << "[StQGSMdstQAMaker]: no event" << std::endl;
  215. return 0;
  216. }
  217. if (mO97Event) {
  218. int refMultP90 = 0;
  219. int refMultP100 = 0;
  220. int refMultP120 = 0;
  221. int refMultP150 = 0;
  222. float imp = mO97Event->GetImpactPar();
  223. TClonesArray *tracks = mO97Event->GetTracks();
  224. if (tracks) {
  225. int nTracks = tracks->GetEntries();
  226. for (int i = 0; i < nTracks; i++) {
  227. StO97Track *track = (StO97Track *)tracks->At(i);
  228. float px = track->GetPx();
  229. float py = track->GetPy();
  230. float pz = track->GetPz();
  231. float pt = sqrt(px*px + py*py);
  232. float p = sqrt(px*px + py*py + pz*pz);
  233. float massSqr = track->GetMass()*track->GetMass();
  234. float vx = track->GetXfr();
  235. float vy = track->GetYfr();
  236. float vz = track->GetZfr();
  237. float Rfr = TMath::Sqrt(vx*vx + vy*vy);
  238. float Tfr = track->GetTfr();
  239. float eta = pt > 0.05 /* i.e. pt > 0 */ ? 0.5*log((p + pz)/(p - pz)) : -999.;
  240. int pdg = track->GetPdgId(pdgDb);
  241. int charge = track->GetCharge(pdgDb, true);
  242. hEtaInt->Fill(eta);
  243. if (pt < 0.075 || fabs(eta) >= 0.5 /* STAR TPC acceptance */ ||
  244. charge == 0. /* only charged particles */ ||
  245. track->GetIsSpec()) {
  246. continue;
  247. }
  248. if (pt >= 0.09) refMultP90++;
  249. if (pt >= 0.10) refMultP100++;
  250. if (pt >= 0.12) refMultP120++;
  251. if (pt >= 0.15) refMultP150++;
  252. if (pt >= 0.1 /* STAR TPC lower momentum limit from STAR TPC NIM */) {
  253. hMSqrVsPt->Fill(pt*charge, massSqr);
  254. hVx->Fill(vx);
  255. hVy->Fill(vy);
  256. hVz->Fill(vz);
  257. hPx->Fill(px);
  258. hPy->Fill(py);
  259. hPz->Fill(pz);
  260. hPt->Fill(pt);
  261. hP->Fill(p);
  262. hEta->Fill(eta);
  263. }
  264. switch (abs(pdg)) {
  265. case 11: // Electron
  266. hMomElectron->Fill(p);
  267. break;
  268. case 211: // Pion
  269. hMomPion->Fill(p);
  270. hdNdTfr_pion->Fill(Tfr);
  271. hRfrVsTfr_pion->Fill(Rfr, Tfr);
  272. break;
  273. case 321: // Kaon
  274. hMomKaon->Fill(p);
  275. hdNdTfr_kaon->Fill(Tfr);
  276. hRfrVsTfr_kaon->Fill(Rfr, Tfr);
  277. break;
  278. case 2212: // Proton
  279. hMomProton->Fill(p);
  280. hdNdTfr_proton->Fill(Tfr);
  281. hRfrVsTfr_proton->Fill(Rfr, Tfr);
  282. } // switch (abs(pdg))
  283. } // for (int i = 0; i < nTracks; i++)
  284. } // if (tracks)
  285. else {
  286. std::cout << "[StQGSMdstQAMaker]: tracks == NULL" << std::endl;
  287. }
  288. if (refMultP90)
  289. hRefMultP90->Fill(refMultP90);
  290. if (refMultP100)
  291. hRefMultP100->Fill(refMultP100);
  292. if (refMultP120)
  293. hRefMultP120->Fill(refMultP120);
  294. if (refMultP150)
  295. hRefMultP150->Fill(refMultP150);
  296. hSph->Fill(mO97Event->GetTransverseSphericity());
  297. hSph2->Fill(mO97Event->GetTransverseSphericity2());
  298. hImpPar->Fill(imp);
  299. hImpVsRef->Fill(imp, refMultP150);
  300. } // if (mO97Event)
  301. return kStOk;
  302. }