calcMult.cpp 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. #include <iostream>
  2. #include <fstream>
  3. #include <TStopwatch.h>
  4. #include <TString.h>
  5. #include <TFile.h>
  6. #include <TH1F.h>
  7. #include "fmcTypes.h"
  8. #include "fmcFunctions.cxx"
  9. int main(int argc, char **argv)
  10. {
  11. TString inFileName, outFileName;
  12. if (argc < 5)
  13. {
  14. std::cerr << "./calcMult -i input -o output" << std::endl;
  15. return 10;
  16. }
  17. for (int i = 1; i < argc; i++)
  18. {
  19. if (std::string(argv[i]) != "-i" &&
  20. std::string(argv[i]) != "-o")
  21. {
  22. std::cerr << "\ncalcMult: Unknown parameter " << i
  23. << ": " << argv[i] << std::endl;
  24. return 11;
  25. }
  26. else
  27. {
  28. if (std::string(argv[i]) == "-i" && i != argc - 1)
  29. {
  30. inFileName = argv[++i];
  31. }
  32. if (std::string(argv[i]) == "-i" && i == argc - 1)
  33. {
  34. std::cerr << "\ncalcMult: Input file name was not specified!" << std::endl;
  35. return 20;
  36. }
  37. if (std::string(argv[i]) == "-o" && i != argc - 1)
  38. {
  39. outFileName = argv[++i];
  40. }
  41. if (std::string(argv[i]) == "-o" && i == argc - 1)
  42. {
  43. std::cerr << "\ncalcMult: Output file name was not specified!" << std::endl;
  44. return 21;
  45. }
  46. }
  47. }
  48. TFile *fi = new TFile(inFileName.Data(),"read");
  49. if (fi->IsZombie()) return 1;
  50. TH1I *histSTAR = (TH1I*) fi->Get("hRefMultSTAR");
  51. TH1I *histPHENIX = (TH1I*) fi->Get("hRefMultPHENIX");
  52. if (!histSTAR || !histPHENIX){
  53. std::cerr << "Error: histogram was not found!" << std::endl;
  54. return 2;
  55. }
  56. std::cout << std::endl;
  57. std::cout << "STAR-like refMult" << std::endl;
  58. fmc::Lim limSTAR = fmc::CentralityBorders(histSTAR,1.);
  59. std::cout << std::endl;
  60. std::cout << "PHENIX-like refMult" << std::endl;
  61. fmc::Lim limPHENIX = fmc::CentralityBorders(histPHENIX,0.93);
  62. std::ofstream file(outFileName.Data());
  63. file << "STAR" << std::endl;
  64. for (int i=0; i<limSTAR.L.size(); i++)
  65. {
  66. file << limSTAR.L.at(i) << " " << limSTAR.H.at(i) << std::endl;
  67. }
  68. file << "PHENIX" << std::endl;
  69. for (int i=0; i<limPHENIX.L.size(); i++)
  70. {
  71. file << limPHENIX.L.at(i) << " " << limPHENIX.H.at(i) << std::endl;
  72. }
  73. return 0;
  74. }