finishSchedulerJobs.pl 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. #! /opt/star/bin/perl -w
  2. use File::Basename;
  3. use Getopt::Std;
  4. use Cwd 'abs_path'; # aka realpath()
  5. my %opt;
  6. getopts('htoz:b:m:adn:q:x:y:s',\%opt);
  7. my $usage = "$0 combinedDir \n";
  8. #----
  9. my $combinedDir = shift or die $usage;
  10. #my $pwd = abs_path ( $ENV { 'PWD' } );
  11. my $pwd = `pwd`;
  12. if ($pwd=~/direct/) { #if at RCF, /direct/star+dataxx/ does not work ! ANNOYING
  13. $pwd=~ s/\/direct//;
  14. $pwd=~ s/\+/\//; # change /direct/star+dataxx to /star/dataxx
  15. }
  16. chomp($pwd);
  17. @flowCents = (
  18. # "cen1",
  19. # "cen2",
  20. # "cen3",
  21. "cen4"
  22. # "cen5",
  23. # "cen6",
  24. # "cen7",
  25. # "cen8",
  26. # "cen9"
  27. );
  28. my $stdHistName = "flow.hist.root";
  29. my $tempMacroName="myWriteHeader";
  30. open ( tempMacro, ">".$tempMacroName.".C");
  31. print tempMacro "void $tempMacroName(const char* histFileName, const char* headerFileName) { \n";
  32. print tempMacro " TFile* histFile = new TFile(histFileName,\"READ\"); \n";
  33. print tempMacro " TVectorD* cumulConstants =(TVectorD* ) histFile->Get(\"CumulConstants\"); \n";
  34. print tempMacro " int nHars = (*cumulConstants)(0); \n";
  35. print tempMacro " int nSels = (*cumulConstants)(1); \n";
  36. print tempMacro " int nSubs = (*cumulConstants)(2); \n";
  37. print tempMacro " int nPhiBins = (*cumulConstants)(3); \n";
  38. print tempMacro " int nPhiBinsFtpc = (*cumulConstants)(4); \n";
  39. print tempMacro " int nEtaBins = (*cumulConstants)(5); \n";
  40. print tempMacro " int nPtBins = (*cumulConstants)(6); \n";
  41. print tempMacro " int nCumulIntegOrders = (*cumulConstants)(7); \n";
  42. print tempMacro " int nCumulInteg_qMax = (*cumulConstants)(8); \n";
  43. print tempMacro " int nCumulDiffOrders = (*cumulConstants)(9); \n";
  44. print tempMacro " int nCumulDiff_qMax = (*cumulConstants)(10); \n";
  45. print tempMacro " int nCumulMixHar_pMax = (*cumulConstants)(11); \n";
  46. print tempMacro " int nCumulMixHar_qMax = (*cumulConstants)(12); \n";
  47. print tempMacro " double r0 = (*cumulConstants)(13); \n";
  48. print tempMacro " int m_M = (*cumulConstants)(14); \n";
  49. print tempMacro " int isPidFlow = (*cumulConstants)(15); \n";
  50. print tempMacro " double r0Mix = (*cumulConstants)(16); \n";
  51. print tempMacro " double profScale = (*cumulConstants)(17); \n";
  52. print tempMacro " TObjString* oldNewTag = (TObjString* )histFile->Get(\"CumulMethodTag\"); \n";
  53. print tempMacro " int isNewMethod = ((oldNewTag->GetString()).Contains(\"cumulNew\")) ? 1 : 0; \n";
  54. print tempMacro " FILE* f = fopen(headerFileName,\"w\"); \n";
  55. print tempMacro " fprintf(f, \"const int nHars = %d; \\n\", nHars); \n";
  56. print tempMacro " fprintf(f, \"const int nSels = %d; \\n\", nSels); \n";
  57. print tempMacro " fprintf(f, \"const int nSubs = %d; \\n\", nSubs); \n";
  58. print tempMacro " fprintf(f, \"const int nPhiBins = %d; \\n\", nPhiBins); \n";
  59. print tempMacro " fprintf(f, \"const int nPhiBinsFtpc = %d; \\n\", nPhiBinsFtpc); \n";
  60. print tempMacro " fprintf(f, \"const int nEtaBins = %d; \\n\", nEtaBins); \n";
  61. print tempMacro " fprintf(f, \"const int nPtBins = %d; \\n\", nPtBins); \n";
  62. print tempMacro " fprintf(f, \"const int nCumulIntegOrders = %d; \\n\", nCumulIntegOrders); \n";
  63. print tempMacro " fprintf(f, \"const int nCumulInteg_qMax = %d; \\n\", nCumulInteg_qMax); \n";
  64. print tempMacro " fprintf(f, \"const int nCumulDiffOrders = %d; \\n\", nCumulDiffOrders); \n";
  65. print tempMacro " fprintf(f, \"const int nCumulDiff_qMax = %d; \\n\", nCumulDiff_qMax); \n";
  66. print tempMacro " fprintf(f, \"const int nCumulMixHar_pMax = %d; \\n\", nCumulMixHar_pMax); \n";
  67. print tempMacro " fprintf(f, \"const int nCumulMixHar_qMax = %d; \\n\", nCumulMixHar_qMax); \n";
  68. print tempMacro " fprintf(f, \"const double r0 = %f; \\n\", r0); \n";
  69. print tempMacro " fprintf(f, \"const int m_M = %d; \\n\", m_M); \n";
  70. print tempMacro " fprintf(f, \"const int isPidFlow = %d; \\n\", isPidFlow); \n";
  71. print tempMacro " fprintf(f, \"const double r0Mix = %f; \\n\", r0Mix); \n";
  72. print tempMacro " fprintf(f, \"const double profScale = %f; \\n\", profScale); \n";
  73. print tempMacro " fprintf(f, \"const int isNewMethod = %f; \\n\", 1); \n";
  74. print tempMacro " fclose(f); \n";
  75. print tempMacro " } \n";
  76. close tempMacro;
  77. # do not move around the two lines below.
  78. my $writeHeaderMacroName = $tempMacroName;
  79. my $tempMacroName="calculateCumulant"; # do not change this name
  80. if (-e "$pwd/myWriteCalcCumuHeaderFile.log"){
  81. print `rm $pwd/myWriteCalcCumuHeaderFile.log \n`;
  82. }
  83. $dummy = $flowCents[0];
  84. `time root4star -b -q '$writeHeaderMacroName.C("$pwd/$combinedDir/$dummy/$stdHistName", "$tempMacroName.h")' > myWriteCalcCumuHeaderFile.log`;
  85. foreach $eachCent(@flowCents) {
  86. print "calculating flow result from cumulants for $cent \n";
  87. print "$pwd/$combinedDir/$eachCent/$stdHistName \n";
  88. if (-e "$pwd/$combinedDir/$eachCent/myCalcCumulantStd$cent.log"){
  89. print `rm $pwd/$combinedDir/$eachCent/myCalcCumulantStd$cent.log \n`;
  90. }
  91. `time root4star -b -q '$tempMacroName.C("$pwd/$combinedDir/$eachCent/$stdHistName")' > $pwd/$combinedDir/$eachCent/myCalcCumulantStd$cent.log`;
  92. #if (-e "$pwd/$combinedDir/$eachCent/myCalcCumulantCumul$cent.log"){
  93. #print `rm $pwd/$combinedDir/$eachCent/myCalcCumulantCumul$cent.log \n`;
  94. #}
  95. # `time root4star -b -q '$tempMacroName.C("$pwd/$combinedDir/$eachCent/$stdHistFile/$cumulHistName")' > $pwd/$combinedDir/$eachCent/myCalcCumulantCumul$cent.log`;
  96. }
  97. exit;