2021-08-30 16:15:26 +02:00
# define eventdatroot_cxx
# include "eventdatroot.h"
# include <TH2.h>
# include <TStyle.h>
# include <TCanvas.h>
# include <TH1.h>
# include <iostream>
# include <fstream>
# include <iomanip>
# include <cstdlib>
# include <cmath>
# include <string.h>
# include <TLorentzVector.h>
# include <vector>
# include <TApplication.h>
//#include <TROOT.h>
# include <TF1.h>
# include <TAxis.h>
# include <stdio.h>
# include <stdlib.h>
# include <TFile.h>
# include <TTree.h>
using namespace std ;
void eventdatroot : : Loop ( Float_t scale )
{
// In a ROOT session, you can do:
// root> .L eventdatroot.C
// root> eventdatroot t
// root> t.GetEntry(12); // Fill t data members with entry number 12
// root> t.Show(); // Show values of entry 12
// root> t.Show(16); // Read and show values of entry 16
// root> t.Loop(); // Loop on all entries
//
// This is the loop skeleton where:
// jentry is the global entry number in the chain
// ientry is the entry number in the current Tree
// Note that the argument to GetEntry must be:
// jentry for TChain::GetEntry
// ientry for TTree::GetEntry and TBranch::GetEntry
//
// To read only selected branches, Insert statements like:
// METHOD1:
// fChain->SetBranchStatus("*",0); // disable all branches
// fChain->SetBranchStatus("branchname",1); // activate branchname
// METHOD2: replace line
// fChain->GetEntry(jentry); //read all branches
//by b_branchname->GetEntry(ientry); //read only this branch
Float_t ratio_electron , ratio_primary , etotal , spratio ;
// 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]
// f_sp_ps->SetParameters(361.936, -0.892255, 1.19133); //protons between 50 and 220 MeV
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]
f_c12sp_ps - > SetParameters ( 14538.9 , - 0.922423 , 49.2859 ) ; //carbon between 80 and 480 MeV
if ( fChain = = 0 ) return ;
Long64_t nentries = fChain - > GetEntriesFast ( ) ;
Long64_t nbytes = 0 , nb = 0 ;
for ( Long64_t jentry = 0 ; jentry < nentries ; jentry + + ) {
Long64_t ientry = LoadTree ( jentry ) ;
if ( ientry < 0 ) break ;
nb = fChain - > GetEntry ( jentry ) ; nbytes + = nb ;
// if (Cut(ientry) < 0) continue;
// cout << jentry << endl;
h_endist_0 - > Fill ( ENDIST [ 0 ] ) ; // edep by ionisation
h_endist_1 - > Fill ( ENDIST [ 1 ] ) ; // edep by pi0, e-, e+ and #gamma
h_endist_2 - > Fill ( ENDIST [ 2 ] ) ; // edep by nuclear recoils and heavy fragments
h_endist_3 - > Fill ( ENDIST [ 3 ] ) ; // edep by part. #lt threshold
h_endist_4 - > Fill ( ENDIST [ 4 ] ) ; // E leaving the syste
h_endist_5 - > Fill ( ENDIST [ 5 ] ) ; // E carried by discarded particles
h_endist_6 - > Fill ( ENDIST [ 6 ] ) ; // resid, excit. E after evap.
h_endist_7 - > Fill ( ENDIST [ 7 ] ) ; // edep by low-energy neutrons
h_endist_8 - > Fill ( ENDIST [ 8 ] ) ; // E of part. #gt time limit
h_endist_9 - > Fill ( ENDIST [ 9 ] ) ; // E lost in endothermic nuclear reactions
h_endist_10 - > Fill ( ENDIST [ 10 ] ) ; // E lost in endothermic low-E n-reaction
h_endist_11 - > Fill ( ENDIST [ 11 ] ) ; // missing E
etotal = 0. ;
for ( unsigned int i = 0 ; i < 3 ; i + + ) {
etotal + = ENDIST [ i ] ;
}
ratio_electron = ENDIST [ 1 ] / etotal ;
ratio_primary = ENDIST [ 0 ] / etotal ;
h_ratio_e - > Fill ( ratio_electron ) ;
h_ratio_p - > Fill ( ratio_primary ) ;
h_sum_ep - > Fill ( ENDIST [ 1 ] + ENDIST [ 0 ] ) ;
h_let_ep - > Fill ( ( ENDIST [ 1 ] + ENDIST [ 0 ] ) / scale / 36. ) ; // [GeV/cm/Z^2]
h_let_e - > Fill ( ( ENDIST [ 1 ] ) / scale / 36. ) ;
h_let_p - > Fill ( ( ENDIST [ 0 ] ) / scale / 36. ) ;
spratio = ( ( ( ENDIST [ 0 ] + ENDIST [ 1 ] ) / scale * 1000. / 1.06 ) / f_c12sp_ps - > Eval ( ( DATA_ENERGY [ 0 ] + ENDIST [ 4 ] ) * 1000. / 12. ) ) ; //ratio of deposited energy to PSTAR stopping power (MeV/cm/density) / MeVcm2/g
h_spratio - > Fill ( spratio ) ;
// cout << ( (ENDIST[0]+ENDIST[1])/scale*1000/1.06) << " " << f_sp_ps->Eval( (DATA_ENERGY[0]+ENDIST[4])*1000 ) << " " << spratio << endl;
}
}
int main ( int argc , const char * argv [ ] )
{
Int_t thickkey = atoi ( argv [ 2 ] ) ;
2021-09-03 14:30:47 +02:00
Float_t THICKNESS [ 7 ] = { 0.025 , 0.035 , 0.050 , 0.100 , 0.125 , 0.15 , 0.20 } ; //#cm
2021-08-30 16:15:26 +02:00
// Float_t THICKNESS[5] = {0.050, 0.100, 0.150, 1.000, 10.00}; //#cm
///open the input and output root files
char finname [ 50 ] ;
sprintf ( finname , " %s.root " , argv [ 1 ] ) ;
TFile * f = new TFile ( finname , " OPEN " ) ;
char foutname [ 50 ] ;
sprintf ( foutname , " %s_out.root " , argv [ 1 ] ) ;
cout < < foutname < < endl ;
TFile * fout = new TFile ( foutname , " RECREATE " ) ;
//run the analysis loop above
eventdatroot t ;
TTree * tree ;
f - > GetObject ( " EVENTDAT " , tree ) ;
t . Init ( tree ) ;
t . Loop ( THICKNESS [ thickkey ] ) ;
t . Closefile ( fout ) ;
return 1 ;
}