getCentralityBins.C 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211
  1. //----------------------------------------------------------------------------------------------------
  2. // Example macro how to use StRefMultCorr
  3. // $Id$
  4. // $Log$
  5. // Revision 1.13 2015/05/27 02:53:20 hmasui
  6. // Add text file for special scale factor in Run14, and update the usage in the macro accordingly.
  7. //
  8. // Revision 1.12 2012/05/19 00:51:14 hmasui
  9. // Update the usage for refmult3
  10. //
  11. // Revision 1.11 2012/05/17 10:31:22 hmasui
  12. // Add comment for library load
  13. //
  14. // Revision 1.10 2012/05/17 09:59:24 hmasui
  15. // Fix the refmult2 argument in initEvent function
  16. //
  17. // Revision 1.9 2012/05/14 00:43:32 hmasui
  18. // Added invalid run number test
  19. //
  20. // Revision 1.8 2012/05/09 22:25:52 hmasui
  21. // Update comments (thanks to Bill Llope for suggestions)
  22. //
  23. // Revision 1.7 2012/05/08 05:38:57 hmasui
  24. // Update the description of the usage for refmult2
  25. //
  26. // Revision 1.6 2012/05/08 03:23:11 hmasui
  27. // Update the usage for refmult2
  28. //
  29. // Revision 1.5 2012/05/08 03:20:00 hmasui
  30. // Move parameters to Centrality_def_refmult.txt
  31. //
  32. // Revision 1.4 2012/04/26 23:40:09 hmasui
  33. // Added how to use CentralityMaker, StRefMultCorr::isBadRun() function to remove outliers
  34. //
  35. // Revision 1.3 2011/11/08 19:12:24 hmasui
  36. // Update usage based on the latest update for 200 GeV (luminosity correction)
  37. //
  38. // Revision 1.2 2011/08/12 20:28:45 hmasui
  39. // Change interface according to the update of StRefMultCorr class
  40. //
  41. //----------------------------------------------------------------------------------------------------
  42. //____________________________________________________________________________________________________
  43. // Example macro for StRefMutlCorr class implementation
  44. // * Before accessing centrality bins via StRefMutlCorr, you must call 'init(const Int_t RunId)'
  45. // to specify which parameters you want to use
  46. // - If you stick to the one specific run, you only need to call this function once in your code.
  47. // - If you read data from multiple different runs, you need to call this function
  48. // whenever you switch to the run number
  49. //
  50. // * In the standard STAR analysis maker, the best (and only) place to call 'init(...)' function
  51. // is 'Make(...)'
  52. //
  53. // * Comment for luminosity (zdc coincidence rate) correction
  54. // - Luminosity correction is only valid for 200 GeV
  55. // - The default argument is 0 for zdc coincidence rate in initEvent() function, see header StRefMultCorr.h,
  56. // so that you can still use previous initEvent() function like
  57. // void StRefMultCorr::initEvent(refmult, vz) ;
  58. // without specifying zdc coincidence rate for lower beam energies
  59. // - (Very important) You should use BBC coincidence rate for refmult2
  60. //
  61. // * You can now use the interface "CentralityMaker" class to access the StRefMultCorr
  62. // see the usage below.
  63. // * The refmult2 & refmult3 correction classes are ready. You can access the correction by
  64. // - StRefMultCorr* refmult2CorrUtil = CentralityMaker::instance()->getRefMult2Corr() ;
  65. // (note the '2' in the function, replace 2 to 3 for refmult3)
  66. // - You can use exactly the same functions used in StRefMultCorr (see below)
  67. void getCentralityBins()
  68. {
  69. //----------------------------------------------------------------------------------------------------
  70. // NOTE:
  71. // - The usage below is under the assumption that users add StRefMultCorr class in their StRoot/ and compiled it by cons.
  72. // - You can definitely use the correction classes in your local pc with ROOT
  73. // because the codes under StRefMultCorr don't depend on any STAR libraries.
  74. //----------------------------------------------------------------------------------------------------
  75. // In the compiled code, don't forget to add
  76. // #include "StRoot/StRefMultCorr/StRefMultCorr.h"
  77. // #include "StRoot/StRefMultCorr/CentralityMaker.h"
  78. // Load StRefMultCorr library
  79. // NOTE: Add this line in your 'macro', not in the source code
  80. gSystem->Load("StRefMultCorr");
  81. // For refmult
  82. StRefMultCorr* refmultCorrUtil = CentralityMaker::instance()->getRefMultCorr() ;
  83. // For refmult2
  84. StRefMultCorr* refmult2CorrUtil = CentralityMaker::instance()->getRefMult2Corr() ;
  85. // For refmult3
  86. StRefMultCorr* refmult3CorrUtil = CentralityMaker::instance()->getRefMult3Corr() ;
  87. // For grefmult
  88. StRefMultCorr* grefmultCorrUtil = CentralityMaker::instance()->getgRefMultCorr() ;
  89. // You can also access the StRefMultCorr by direct instantiation
  90. // StRefMultCorr* refmultCorrUtil = new StRefMultCorr("refmult");
  91. // StRefMultCorr* refmult2CorrUtil = new StRefMultCorr("refmult2");
  92. // You need to specify the run number you are going to process
  93. refmultCorrUtil->init(11078000);
  94. refmult2CorrUtil->init(11078000);
  95. refmult3CorrUtil->init(11078000);
  96. grefmultCorrUtil->init(15075008);
  97. //----------------------------------------------------------------------------------------------------
  98. // *** Optional functions (not necessary to call)
  99. // void StRefMultCorr::print(const Optiont_t option="");
  100. // Int_t StRefMultCorr::getBeginRun(const Double_t energy, const Int_t year) ;
  101. // Int_t StRefMultCorr::getEndRun(const Double_t energy, const Int_t year) ;
  102. // Print all parameters
  103. refmultCorrUtil->print();
  104. refmult2CorrUtil->print();
  105. refmult3CorrUtil->print();
  106. grefmultCorrUtil->print();
  107. // scale factor test
  108. grefmultCorrUtil->setVzForWeight(6, -6.0, 6.0);
  109. grefmultCorrUtil->readScaleForWeight("StRoot/StRefMultCorr/macros/weight_grefmult_vpd30_vpd5_Run14.txt");
  110. // Obtain begin and end run number from energy and year
  111. cout << "Run " << refmultCorrUtil->getBeginRun(200.0, 2010) << " - " << refmultCorrUtil->getEndRun(200.0, 2010) << endl;
  112. // You can check the 'bad run' based on the event-wise QA for refmult centrality
  113. // by using StRefMultCorr::isBadRun() function
  114. if ( refmultCorrUtil->isBadRun(12177061) ) {
  115. cout << "Run 12177061 is bad" << endl;
  116. }
  117. if ( refmult2CorrUtil->isBadRun(12177061) ) {
  118. cout << "Run 12177061 is bad" << endl;
  119. }
  120. if ( refmult3CorrUtil->isBadRun(12177061) ) {
  121. cout << "Run 12177061 is bad" << endl;
  122. }
  123. //----------------------------------------------------------------------------------------------------
  124. // Dummy refmult and primary z-vertex to test the functions
  125. const UShort_t refmult = 100 ;
  126. const UShort_t refmult2 = 100 ;
  127. const UShort_t refmult3 = 100 ;
  128. const Double_t vz = 20.0 ; // cm
  129. const Double_t zdcCoincidenceRate = 20000 ; // Hz
  130. const Double_t bbcCoincidenceRate = 20000 ; // Hz
  131. // The following functions should be called inside the event loop (event-by-event)
  132. // ******* IMPORTANT ***********
  133. // Call initEvent(const UShort_t RefMult, const Double_t z) function
  134. // event-by-event at the beginning before using any other functions
  135. refmultCorrUtil->initEvent(refmult, vz, zdcCoincidenceRate) ;
  136. // This also works for 7.7 - 62.4 GeV (see comments above)
  137. // refmultCorrUtil->initEvent(refmult, vz);
  138. // ******* VERY IMPORTANT ***********
  139. // USE BBC COINCIDENCE RATE RATHER THAN ZDC COINCIDENCE RATE FOR REFMULT2
  140. refmult2CorrUtil->initEvent(refmult2, vz, bbcCoincidenceRate) ;
  141. // This also works for 7.7 - 62.4 GeV (see comments above)
  142. // refmult2CorrUtil->initEvent(refmult2, vz);
  143. refmult3CorrUtil->initEvent(refmult3, vz, zdcCoincidenceRate) ;
  144. // This also works for 7.7 - 62.4 GeV (see comments above)
  145. // refmult3CorrUtil->initEvent(refmult3, vz);
  146. //----------------------------------------------------------------------------------------------------
  147. // Get centrality bins
  148. // - You can use exactly the same functions to obtain centrality, reweighting
  149. // and corrected multiplicity for refmult2
  150. //
  151. // see StRefMultCorr.h for the definition of centrality bins
  152. const Int_t cent16 = refmultCorrUtil->getCentralityBin16() ;
  153. const Int_t cent9 = refmultCorrUtil->getCentralityBin9() ;
  154. // Centrality from refmult2
  155. const Int_t cent16_refmult2 = refmult2CorrUtil->getCentralityBin16() ;
  156. const Int_t cent9_refmult2 = refmult2CorrUtil->getCentralityBin9() ;
  157. // Centrality from refmult3
  158. const Int_t cent16_refmult3 = refmult3CorrUtil->getCentralityBin16() ;
  159. const Int_t cent9_refmult3 = refmult3CorrUtil->getCentralityBin9() ;
  160. // Re-weighting corrections for peripheral bins
  161. const Double_t reweight = refmultCorrUtil->getWeight() ;
  162. const Double_t reweight_refmult2 = refmult2CorrUtil->getWeight() ;
  163. const Double_t reweight_refmult3 = refmult3CorrUtil->getWeight() ;
  164. //----------------------------------------------------------------------------------------------------
  165. // Corrected refmult (with z-vertex dependent correction and luminositiy correction)
  166. // NOTE: type should be double or float, not integer
  167. const Double_t refmultCor = refmultCorrUtil->getRefMultCorr() ;
  168. const Double_t refmult2Cor = refmult2CorrUtil->getRefMultCorr() ;
  169. const Double_t refmult3Cor = refmult3CorrUtil->getRefMultCorr() ;
  170. //----------------------------------------------------------------------------------------------------
  171. // Invalid run number test
  172. const Int_t runId = 12154037 ;
  173. cout << "Invalid run number test: " << runId << endl;
  174. cout << "The program should be stopped with the error messages from isIndexOk function" << endl;
  175. refmult2CorrUtil->init(runId);
  176. refmult2CorrUtil->getWeight();
  177. // Program should stop here
  178. cout << "Problem if you see this message. Contact hmasui@lbl.gov" << endl;
  179. }