A FLUKA simulation that records the energy deposited in a single layer of polysterene from an ion beam. HTCondor submission scripts are included.
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.

144 lines
5.0 KiB

3 years ago
3 years ago
  1. #define eventdatroot_cxx
  2. #include "eventdatroot.h"
  3. #include <TH2.h>
  4. #include <TStyle.h>
  5. #include <TCanvas.h>
  6. #include <TH1.h>
  7. #include <iostream>
  8. #include <fstream>
  9. #include <iomanip>
  10. #include <cstdlib>
  11. #include <cmath>
  12. #include <string.h>
  13. #include <TLorentzVector.h>
  14. #include <vector>
  15. #include <TApplication.h>
  16. //#include <TROOT.h>
  17. #include <TF1.h>
  18. #include <TAxis.h>
  19. #include <stdio.h>
  20. #include <stdlib.h>
  21. #include <TFile.h>
  22. #include <TTree.h>
  23. using namespace std;
  24. void eventdatroot::Loop(Float_t scale)
  25. {
  26. // In a ROOT session, you can do:
  27. // root> .L eventdatroot.C
  28. // root> eventdatroot t
  29. // root> t.GetEntry(12); // Fill t data members with entry number 12
  30. // root> t.Show(); // Show values of entry 12
  31. // root> t.Show(16); // Read and show values of entry 16
  32. // root> t.Loop(); // Loop on all entries
  33. //
  34. // This is the loop skeleton where:
  35. // jentry is the global entry number in the chain
  36. // ientry is the entry number in the current Tree
  37. // Note that the argument to GetEntry must be:
  38. // jentry for TChain::GetEntry
  39. // ientry for TTree::GetEntry and TBranch::GetEntry
  40. //
  41. // To read only selected branches, Insert statements like:
  42. // METHOD1:
  43. // fChain->SetBranchStatus("*",0); // disable all branches
  44. // fChain->SetBranchStatus("branchname",1); // activate branchname
  45. // METHOD2: replace line
  46. // fChain->GetEntry(jentry); //read all branches
  47. //by b_branchname->GetEntry(ientry); //read only this branch
  48. Float_t ratio_electron, ratio_primary, etotal, spratio;
  49. // TF1 * f_sp_ps = new TF1("f_sp_ps","[0]*pow(x,[1])+[2]", 50, 250); //stopping power of protons in polystyrene [MeV cm2 /g]
  50. // f_sp_ps->SetParameters(361.936, -0.892255, 1.19133); //protons between 50 and 220 MeV
  51. // TF1 * f_c12sp_ps = new TF1("f_c12sp_ps","[0]*pow(x,[1])+[2]", 80, 480); //stopping power of carbon in polystyrene [MeV cm2 /g]
  52. // f_c12sp_ps->SetParameters(14538.9, -0.922423,49.2859); //carbon between 80 and 480 MeV
  53. TF1 * f_h2sp_ps = new TF1("f_h2sp_ps","[0]*pow(x,[1])+[2]", 50, 250); //stopping power of helium in polystyrene [MeV cm2 /g]
  54. f_h2sp_ps->SetParameters(1387.08, -0.882686,4.60833); //heelium between 50 and 300 MeV
  55. if (fChain == 0) return;
  56. Long64_t nentries = fChain->GetEntriesFast();
  57. Long64_t nbytes = 0, nb = 0;
  58. for (Long64_t jentry=0; jentry<nentries;jentry++) {
  59. Long64_t ientry = LoadTree(jentry);
  60. if (ientry < 0) break;
  61. nb = fChain->GetEntry(jentry); nbytes += nb;
  62. // if (Cut(ientry) < 0) continue;
  63. // cout << jentry << endl;
  64. h_endist_0->Fill(ENDIST[0]); // edep by ionisation
  65. h_endist_1->Fill(ENDIST[1]); // edep by pi0, e-, e+ and #gamma
  66. h_endist_2->Fill(ENDIST[2]); // edep by nuclear recoils and heavy fragments
  67. h_endist_3->Fill(ENDIST[3]); // edep by part. #lt threshold
  68. h_endist_4->Fill(ENDIST[4]); // E leaving the syste
  69. h_endist_5->Fill(ENDIST[5]); // E carried by discarded particles
  70. h_endist_6->Fill(ENDIST[6]); // resid, excit. E after evap.
  71. h_endist_7->Fill(ENDIST[7]); // edep by low-energy neutrons
  72. h_endist_8->Fill(ENDIST[8]); // E of part. #gt time limit
  73. h_endist_9->Fill(ENDIST[9]); // E lost in endothermic nuclear reactions
  74. h_endist_10->Fill(ENDIST[10]); // E lost in endothermic low-E n-reaction
  75. h_endist_11->Fill(ENDIST[11]); // missing E
  76. etotal = 0.;
  77. for (unsigned int i = 0; i<3; i++ ){
  78. etotal += ENDIST[i];
  79. }
  80. ratio_electron = ENDIST[1] / etotal;
  81. ratio_primary = ENDIST[0] / etotal;
  82. h_ratio_e->Fill(ratio_electron);
  83. h_ratio_p->Fill(ratio_primary);
  84. h_sum_ep->Fill(ENDIST[1]+ENDIST[0]);
  85. h_let_ep->Fill( (ENDIST[1]+ENDIST[0])/scale/4. ); //GeV/cm/Z^2
  86. h_let_e->Fill( (ENDIST[1])/scale/4. );
  87. h_let_p->Fill( (ENDIST[0])/scale/4. );
  88. spratio = ( ( (ENDIST[0]+ENDIST[1])/scale*1000./1.06) / f_h2sp_ps->Eval( (DATA_ENERGY[0]+ENDIST[4])*1000./4. ) ); //ratio of deposited energy to MSTAR stopping power (MeV/cm/density) / MeVcm2/g
  89. h_spratio->Fill(spratio);
  90. // cout << ( (ENDIST[0]+ENDIST[1])/scale*1000/1.06) << " " << f_sp_ps->Eval( (DATA_ENERGY[0]+ENDIST[4])*1000 ) << " " << spratio << endl;
  91. }
  92. }
  93. int main(int argc, const char* argv[])
  94. {
  95. Int_t thickkey = atoi(argv[2]);
  96. // Float_t THICKNESS[6] = {0.025, 0.050, 0.075, 0.100, 0.0125, 0.150, 0.2500, 0.500}; //#cm
  97. // Float_t THICKNESS[6] = {0.025, 0.050, 0.100, 0.150, 0.500, 0.125 }; //#cm
  98. Float_t THICKNESS[7] = {0.025, 0.050, 0.100, 0.150, 0.500, 1.000, 0.035};// #cm
  99. // Float_t THICKNESS[5] = {0.050, 0.100, 0.150, 1.000, 10.00}; //#cm
  100. ///open the input and output root files
  101. char finname[50];
  102. sprintf(finname, "%s.root",argv[1]);
  103. TFile * f = new TFile(finname,"OPEN");
  104. char foutname[50];
  105. sprintf(foutname, "%s_out.root",argv[1]);
  106. cout << foutname << endl;
  107. TFile * fout = new TFile(foutname, "RECREATE");
  108. //run the analysis loop above
  109. eventdatroot t;
  110. TTree * tree;
  111. f->GetObject("EVENTDAT",tree);
  112. t.Init(tree);
  113. t.Loop( THICKNESS[thickkey] );
  114. t.Closefile(fout);
  115. return 1;
  116. }