data analysis scripts
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.4 KiB

  1. {
  2. gROOT->Reset();
  3. gROOT->ProcessLine(".x lhcbStyle.C");
  4. TCanvas * c1 = new TCanvas("c1","b2",1000,1000);
  5. c1->Divide(1,7);
  6. Int_t fileorder[7][7] = {{0,41,42,43,44,45,0},{31,15,11,7,17,23,26},{32,14,10,6,16,22,27},{33,3,2,1,4,5,28},{34,18,12,8,20,24,29},{35,19,13,9,21,25,30},{0,36,37,38,39,40,0}};
  7. Int_t counter = 0;
  8. TFile *runfile[49];
  9. TVector * copysumvector_ptr[49];
  10. TVector * copybeamontime_ptr[49];
  11. TVector * rowvector_b0_ptr[7];
  12. TVector * rowvector_b1_ptr[7];
  13. TVector * rowvector_b2_ptr[7];
  14. TVector * rowvector_b3_ptr[7];
  15. TH1F * histo[7];
  16. TH1F * histo_clone[7];
  17. TF1 * f1[7];
  18. // rowvector_b0_ptr->ResizeTo(128);
  19. // rowvector_b1_ptr->ResizeTo(128);
  20. // rowvector_b2_ptr->ResizeTo(128);
  21. // rowvector_b3_ptr->ResizeTo(128);
  22. for (int i = 0;i<7;i++){
  23. rowvector_b2_ptr[i] = new TVector(128);
  24. f1[i] = new TF1(Form("f1[%i]",i),"[0]*(exp(-0.5*(x-[1])^2/(13.7^2))+exp(-0.5*(x-[1]-20/0.8)^2/(13.7^2))+exp(-0.5*(x-[1]-40/0.8)^2/(13.7^2))+exp(-0.5*(x-[1]-60/0.8)^2/(13.7^2))+exp(-0.5*(x-[1]-80/0.8)^2/(13.7^2)) )");
  25. f1[i]->SetParameters(1E3,20);
  26. }
  27. for (int i = 0;i<7;i++){
  28. for (int j = 0;j<7;j++){
  29. if (fileorder[j][i]==0) {
  30. counter++;
  31. continue;
  32. }
  33. runfile[counter] = new TFile(Form("/work/leverington/beamprofilemonitor/hitdata/HIT_17_12_2017/root/run%i.root",fileorder[i][j]),"READ");
  34. runfile[counter]->GetObject("sumvector_b2",copysumvector_ptr[counter]);
  35. runfile[counter]->GetObject("beamontime",copybeamontime_ptr[counter]);
  36. //copysumvector_ptr[counter]->Print();
  37. for (int k = 0; k<128; k++){
  38. rowvector_b2_ptr[i]->operator[](k) += copysumvector_ptr[counter]->operator[](k)/copybeamontime_ptr[counter]->operator[](2); // rowvector_b2_ptr[i] is over i now, not j
  39. }
  40. runfile[counter]->Close();
  41. counter++;
  42. }
  43. }
  44. TFile * outputfile = new TFile("rowsum.root","RECREATE");
  45. for (int j = 0;j<7;j++){
  46. // rowvector_b2_ptr[j]->Print();
  47. c1->cd(j+1);
  48. histo[j] = new TH1F(Form("histo[%i]",j),Form("histo[%i]",j),128,0,128);
  49. for (int i = 0; i<128;i++){
  50. histo[j]->SetBinContent(i+1,rowvector_b2_ptr[j]->operator[](i));
  51. }
  52. histo[j]->SetMinimum(0);
  53. histo[j]->GetYaxis()->SetLabelSize(0.1);
  54. histo[j]->GetXaxis()->SetLabelSize(0.14);
  55. histo[j]->GetXaxis()->SetNdivisions(15,5,0);
  56. histo[j]->GetYaxis()->SetNdivisions(10,0,0);
  57. histo[j]->Draw("");
  58. // rowvector_b2_ptr[j]->Draw("");
  59. // histo[j] = (TH1F*)gDirectory->Get("TVectorF");
  60. // histo_clone[j] = (TH1F*)histo[j]->Clone(Form("histoclone[%i]",j));
  61. histo[j]->Fit(f1[j]);
  62. for (int i = 0; i<128;i++){
  63. cout << f1[j]->Eval(i)/histo[j]->GetBinContent(i+1) << ", " ;
  64. }
  65. histo[j]->Write();
  66. }
  67. c1->Update();
  68. c1->Write();
  69. TCanvas * c2 = new TCanvas("c2","b2",1000,1000);
  70. c2->Divide(1,7);
  71. for (int j = 0;j<7;j++){
  72. // rowvector_b2_ptr[j]->Print();
  73. c2->cd(j+1);
  74. histo_clone[j] = (TH1F*)histo[j]->Clone(Form("histo_clone[%i]",j));
  75. histo_clone[j]->Divide(histo[6]);
  76. histo_clone[j]->GetYaxis()->SetLabelSize(0.1);
  77. histo_clone[j]->GetXaxis()->SetLabelSize(0.14);
  78. histo_clone[j]->GetXaxis()->SetNdivisions(15,5,0);
  79. histo_clone[j]->GetYaxis()->SetNdivisions(10,0,0);
  80. histo_clone[j]->SetMinimum(0);
  81. histo_clone[j]->SetMaximum(1.2);
  82. histo_clone[j]->Draw();
  83. }
  84. outputfile->Write();
  85. // outputfile->Close();
  86. }