CentralityCalculator.h 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. #ifndef CENTRALITYCALCULATOR_H
  2. #define CENTRALITYCALCULATOR_H
  3. #include <Rtypes.h>
  4. #include <TH1F.h>
  5. #include <TRandom3.h>
  6. #include <iostream>
  7. //#include "../Utils/Funcs.cc"
  8. struct Lim{
  9. unsigned short L[10];
  10. unsigned short H[10];
  11. };
  12. // Calculate centrality bins borders
  13. //S----------------------------------------------------------------
  14. Lim CentralityBorders(TH1F* nCh){
  15. // printf(">>> Centrality file: %s\n", refMultFileName.Data());
  16. // TFile *cFile = new TFile(refMultFileName.Data(), "READ");
  17. // TH1F *nCh = (TH1F*) cFile -> Get("hMultPHENIX");
  18. int HistLim = nCh -> GetNbinsX();
  19. double Integral = nCh -> Integral(1, HistLim);
  20. double tmpIntegral;
  21. int RightLim;
  22. Lim lim;
  23. double efficiency = 0.93;
  24. double BinWidth = 10.;
  25. double Nbins = 100. / BinWidth;
  26. double fraction = (Integral / 100.) * efficiency * BinWidth;
  27. printf("Integral: %8.0f\n", Integral);
  28. printf("Centrality bins width: %2.1f, number of bins: %2.0f\n", BinWidth, Nbins);
  29. printf("Trigger efficiency: %1.2f\n", efficiency);
  30. printf("Fraction of events in each centrality bin: %8.2f\n", fraction);
  31. RightLim = HistLim;
  32. int j = 0;
  33. for(int i = HistLim; i > 0; --i){
  34. tmpIntegral = nCh -> Integral(i, RightLim);
  35. if(tmpIntegral >= fraction){
  36. printf("[%d,%d]: %8.2f\n", i, RightLim, tmpIntegral);
  37. lim.H[j] = RightLim;
  38. lim.L[j] = i;
  39. ++j;
  40. RightLim = i - 1;
  41. }
  42. }
  43. // cFile -> Close();
  44. return lim;
  45. }
  46. //E----------------------------------------------------------------
  47. class CentralityCalculator
  48. {
  49. private:
  50. TH1F *fHmult;
  51. static const Int_t NmultiplicityBins = 100;
  52. Double_t multiplicity_bins[NmultiplicityBins+1];
  53. TRandom3 *RNG;
  54. TString fModel;
  55. Double_t fEnergy;
  56. Int_t GetCent(Int_t multiplicity);
  57. Int_t Integrate(Int_t max_bin, Float_t sum);
  58. Double_t fEfficiency;
  59. Lim lim;
  60. public:
  61. CentralityCalculator();
  62. virtual ~CentralityCalculator();
  63. void SetHistogram(TH1F *const& _h) { fHmult = _h; }
  64. void SetModel(TString _s) { fModel = _s; }
  65. void SetEfficiency(Double_t _a) { fEfficiency = _a; }
  66. void SetEnergy(Double_t _a) { fEnergy = _a; }
  67. Int_t GetCentrality(Int_t multiplicity);
  68. void Calc();
  69. void DrawHistogram(TString outName);
  70. void GenerateMacro(TString outName = "");
  71. };
  72. #endif