ROOT Analysis for the Inclusive Detachted Dilepton Trigger Lines
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

104 lines
3.3 KiB

  1. #include "TH1D.h"
  2. #include "TH2D.h"
  3. #include "THStack.h"
  4. #include "TGraph.h"
  5. #include "TTree.h"
  6. #include "TChain.h"
  7. #include "TFile.h"
  8. #include "TCanvas.h"
  9. #include "TROOT.h"
  10. #include "TStyle.h"
  11. #include "TColor.h"
  12. #include "TLorentzVector.h"
  13. #include "TRandom3.h"
  14. #include "TLorentzVector.h"
  15. #include "RooDataHist.h"
  16. #include "RooRealVar.h"
  17. #include "RooPlot.h"
  18. #include "RooGaussian.h"
  19. #include "RooExponential.h"
  20. #include "RooRealConstant.h"
  21. #include "RooAddPdf.h"
  22. #include "RooFitResult.h"
  23. #include "RooProduct.h"
  24. #include "RooCrystalBall.h"
  25. #include "RooBreitWigner.h"
  26. #include <string>
  27. #include <iostream>
  28. #include <cmath>
  29. const int nBins = 70;
  30. const Double_t MASS_HIST_MIN = 4000.;
  31. const Double_t MASS_HIST_MAX = 8500.;
  32. const Double_t J_PSI_MASS = 3096.916;
  33. const Double_t K_MASS = 493.677;
  34. std::vector<RooPlot*> CreateRooFit(TH1D *hist);
  35. bool inRange(double value, double center, double low_intvl, double up_intvl) {
  36. return center - low_intvl < value && value < center + up_intvl;
  37. }
  38. bool inRange(double value, double center, double intvl) {
  39. return inRange(value, center, intvl, intvl);
  40. }
  41. int subs_mass()
  42. {
  43. // files to load
  44. std::vector<std::string> data_filenames =
  45. {
  46. "/auto/data/pfeiffer/inclusive_detached_dilepton/data_samples/spruce_magdown_2023_v0r1_tuple_90000000_2023_v0r0p6288631.root"};
  47. TChain *data_chain = new TChain("BuToHpMuMu/DecayTree");
  48. for (unsigned int i = 0; i < data_filenames.size(); i++)
  49. {
  50. data_chain->Add(data_filenames.at(i).c_str());
  51. }
  52. Double_t Jpsi_M, L1_M, L2_M, Hp_M;
  53. Float_t L1_PX, L1_PY, L1_PZ, L1_ENERGY, L2_PX, L2_PY, L2_PZ, L2_ENERGY, Hp_PX, Hp_PY, Hp_PZ, Hp_ENERGY;
  54. data_chain->SetBranchAddress("Jpsi_M", &Jpsi_M);
  55. data_chain->SetBranchAddress("L1_M", &L1_M);
  56. data_chain->SetBranchAddress("L2_M", &L2_M);
  57. data_chain->SetBranchAddress("Hp_M", &Hp_M);
  58. data_chain->SetBranchAddress("L1_PX", &L1_PX);
  59. data_chain->SetBranchAddress("L1_PY", &L1_PY);
  60. data_chain->SetBranchAddress("L1_PZ", &L1_PZ);
  61. data_chain->SetBranchAddress("L1_ENERGY", &L1_ENERGY);
  62. data_chain->SetBranchAddress("L2_PX", &L2_PX);
  63. data_chain->SetBranchAddress("L2_PY", &L2_PY);
  64. data_chain->SetBranchAddress("L2_PZ", &L2_PZ);
  65. data_chain->SetBranchAddress("L2_ENERGY", &L2_ENERGY);
  66. data_chain->SetBranchAddress("Hp_PX", &Hp_PX);
  67. data_chain->SetBranchAddress("Hp_PY", &Hp_PY);
  68. data_chain->SetBranchAddress("Hp_PZ", &Hp_PZ);
  69. data_chain->SetBranchAddress("Hp_ENERGY", &Hp_ENERGY);
  70. unsigned int entries = data_chain->GetEntries();
  71. TH1D *h1_B_M = new TH1D("h1_B_M", "m(#pi_{K} #mu^{+} #mu^{-})", nBins, MASS_HIST_MIN, MASS_HIST_MAX);
  72. for (unsigned int i = 0; i < entries; i++)
  73. {
  74. data_chain->GetEntry(i);
  75. TVector3 K_momentum(Hp_PX, Hp_PY, Hp_PZ);
  76. double K_energy = TMath::Sqrt(TMath::Sq(K_MASS) + K_momentum.Mag2());
  77. TLorentzVector K_4v(K_momentum, K_energy);
  78. TLorentzVector l1_4v(L1_PX, L1_PY, L1_PZ, L1_ENERGY);
  79. TLorentzVector l2_4v(L2_PX, L2_PY, L2_PZ, L2_ENERGY);
  80. Double_t reconstructed_B_Mass = (K_4v + l1_4v + l2_4v).M();
  81. h1_B_M->Fill(reconstructed_B_Mass);
  82. }
  83. TCanvas* c1 = new TCanvas("c1", "c1", 0, 0, 900, 850);
  84. h1_B_M->Draw();
  85. c1->Draw();
  86. c1->SaveAs("BuToKpMuMu_incl_ap_B_M_uncut_subid.jpg");
  87. return 0;
  88. }