diff --git a/.gitignore b/.gitignore index 52c6683..29d7791 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,10 @@ data/LundFiles/ data/RootFiles/ +data/LundFiles *.root *.lund build/ *_job.txt -Config_EIC_* \ No newline at end of file +Config_EIC_* +sjdkay_job.txt +*#* \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index 11c0e99..82d1154 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -14,10 +14,11 @@ find_package(ROOT REQUIRED COMPONENTS RIO Net Tree) include(${ROOT_USE_FILE}) include_directories(include) +include_directories("src/eic_evgen") include_directories(SYSTEM ${ROOT_INCLUDE_DIRS}) #include_directories(include/json) -file(GLOB SOURCES "src/*" "src/eic_evgen/eic.cc" "src/eic_evgen/eic_pim.cc" "src/eic_evgen/tssa_sig_Para.cc") +file(GLOB SOURCES "src/*" "src/eic_evgen/eic.cc" "src/eic_evgen/eic_pim.cc" "src/eic_evgen/tssa_sig_Para.cc" "src/eic_evgen/reaction_rountine.cc" "src/eic_evgen/legacy_function.cc" "src/eic_evgen/legacy_function.cc" "src/eic_evgen/process_routine/*") # file(GLOB SOURCES "src/*.cpp") message("Root Include Dirs: " ${ROOT_INCLUDE_DIRS}) diff --git a/Config.json b/Config.json index 813d87f..8e88cd6 100644 --- a/Config.json +++ b/Config.json @@ -6,12 +6,14 @@ // and degrees for angles. // n_events indicates number of attempts // "experiment" : "eic" or "solid" - //"experiment" : "solid", +// "experiment" : "solid", +// "output_file" : "RootFiles/Test.root", + "experiment" : "eic", -// "file_name" : "example_output", - "n_events" : 10000, -// "output_file" : "RootFiles/Test.root", + "file_name" : "example_output", + "n_events" : 1000000, + "generator_seed": 1234567, //************************************** /// This section if for EIC simulation only diff --git a/Config_EIC.json b/Config_EIC.json index a798c0e..944151d 100644 --- a/Config_EIC.json +++ b/Config_EIC.json @@ -9,14 +9,22 @@ // "experiment" : "solid", "experiment" : "eic", - "file_name" : "DEMPGen_1000000_1", - "n_events" : 1000000, + "file_name" : "DEMPGen_PionPlus_org", +// "file_name" : "DEMPGen_PionPlus_test", + "n_events" : 100000000, "output_file" : "RootFiles/Test.root", + "generator_seed": 1234567, //************************************** /// This section if for EIC simulation only "Targ_dir" : 1, // Target Direction (1->Up, 2->Down) "Kinematics_type" : 1, // Kinematics type (1->FF, 2->TSSA) + // "particle": "omega", // Choices: omega, pi+, pi0 + //"particle": "omega", // Choices: omega, pi+, pi0 + "particle": "Pion+", // Choices: omega, pi+, pi0 + //"particle": "Pi0", // Choices: omega, pi+, pi0 + //"particle": "Pi0", // Choices: omega, pi+, pi0 + "det_location": "ip8", // choices: ip6 for STAR, ip8 for PHENIX //************************************** /// This section is Solid only diff --git a/Config_EIC.json.original b/Config_EIC.json.original new file mode 100644 index 0000000..548c956 --- /dev/null +++ b/Config_EIC.json.original @@ -0,0 +1,53 @@ +{ + // This is an exmaple Json configuration file that will accept + // parameters for both EIC and Solid simulation. + //Config + // All values should use units of MeV for energies and momenta, + // and degrees for angles. + // n_events indicates number of attempts + // "experiment" : "eic" or "solid" + // "experiment" : "solid", + "experiment" : "eic", + + "file_name" : "DEMPGen_PionPlus_org", +// "file_name" : "DEMPGen_PionPlus_test", + "n_events" : 100000000, + "output_file" : "RootFiles/Test.root", + "generator_seed": 1234567, + + //************************************** + /// This section if for EIC simulation only + "Targ_dir" : 1, // Target Direction (1->Up, 2->Down) + "Kinematics_type" : 1, // Kinematics type (1->FF, 2->TSSA) + // "particle": "omega", // Choices: omega, pi+, pi0 + //"particle": "omega", // Choices: omega, pi+, pi0 + "particle": "Pion+", // Choices: omega, pi+, pi0 + //"particle": "Pi0", // Choices: omega, pi+, pi0 + //"particle": "Pi0", // Choices: omega, pi+, pi0 + + //************************************** + /// This section is Solid only + + "beam_energy": 11000, + "targ_pol_x": 0, + "targ_pol_y": 0, + "targ_pol_z": 0, + "scat_elec_Emin": 1100.0, + "scat_elec_Emax": 9900.0, + "scat_elec_thetamin": 5.0, + "scat_elec_thetamax": 27.0, + "prod_pion_thetamin": 5.0, + "prod_pion_thetamax": 20.0, + "multiple_scattering": false, + "ionization": false, + "bremsstrahlung": false, + "final_state_interaction": false, + "fermi_momentum": false, + "weight_cut": true, + "w_cut": true, + "w_min": 2, + "Qsq_cut": true, + "Qsq_min": 5, + "t_cut": true, + "t_min": -0.5 +} diff --git a/Config_EIC_Pi0.json b/Config_EIC_Pi0.json new file mode 100644 index 0000000..67d1fdf --- /dev/null +++ b/Config_EIC_Pi0.json @@ -0,0 +1,59 @@ +{ + // This is an exmaple Json configuration file that will accept + // parameters for both EIC and Solid simulation. + //Config + // All values should use units of MeV for energies and momenta, + // and degrees for angles. + // n_events indicates number of attempts + // "experiment" : "eic" or "solid" + // "experiment" : "solid", + "experiment" : "eic", + + "file_name" : "DEMPGen_Pion0_decay", +// "file_name" : "DEMPGen_PionPlus_test", + "n_events" : 1000000, + "output_file" : "RootFiles/Test.root", + "generator_seed": 1234567, + + //************************************** + /// This section if for EIC simulation only + "Targ_dir" : 1, // Target Direction (1->Up, 2->Down) + "Kinematics_type" : 1, // Kinematics type (1->FF, 2->TSSA) + // "particle": "omega", // Choices: omega, pi+, pi0 + //"particle": "omega", // Choices: omega, pi+, pi0 + //"particle": "Pion+", // Choices: omega, pi+, pi0 + //"particle": "Pi0", // Choices: omega, pi+, pi0 + "particle": "Pi0", // Choices: omega, pi+, pi0 + "pi0_decay": true, // + "det_location": "ip8", // choices: ip6 for STAR, ip8 for PHENIX + // Default choice: ip8 + // Attention: IF you donot know which to detection location to use, + // then please use ip8 as default + // "pi0_decay": false, + + //************************************** + /// This section is Solid only + + "beam_energy": 11000, + "targ_pol_x": 0, + "targ_pol_y": 0, + "targ_pol_z": 0, + "scat_elec_Emin": 1100.0, + "scat_elec_Emax": 9900.0, + "scat_elec_thetamin": 5.0, + "scat_elec_thetamax": 27.0, + "prod_pion_thetamin": 5.0, + "prod_pion_thetamax": 20.0, + "multiple_scattering": false, + "ionization": false, + "bremsstrahlung": false, + "final_state_interaction": false, + "fermi_momentum": false, + "weight_cut": true, + "w_cut": true, + "w_min": 2, + "Qsq_cut": true, + "Qsq_min": 4, + "t_cut": true, + "t_min": -1.2 +} diff --git a/Config_EIC_Pi0_decay.json b/Config_EIC_Pi0_decay.json new file mode 100644 index 0000000..1553269 --- /dev/null +++ b/Config_EIC_Pi0_decay.json @@ -0,0 +1,58 @@ +{ + // This is an exmaple Json configuration file that will accept + // parameters for both EIC and Solid simulation. + //Config + // All values should use units of MeV for energies and momenta, + // and degrees for angles. + // n_events indicates number of attempts + // "experiment" : "eic" or "solid" + // "experiment" : "solid", + "experiment" : "eic", + + "file_name" : "DEMPGen_Pi0_decay", +// "file_name" : "DEMPGen_PionPlus_test", +// "n_events" : 100000000, + "n_events" : 2000, + "output_file" : "RootFiles/Test.root", + "generator_seed": 1234567, + + //************************************** + /// This section if for EIC simulation only + "Targ_dir" : 1, // Target Direction (1->Up, 2->Down) + "Kinematics_type" : 1, // Kinematics type (1->FF, 2->TSSA) + // "particle": "omega", // Choices: omega, pi+, pi0 + //"particle": "omega", // Choices: omega, pi+, pi0 + //"particle": "Pion+", // Choices: omega, pi+, pi0 + //"particle": "Pi0", // Choices: omega, pi+, pi0 + "particle": "Pi0", // Choices: omega, pi+, pi0 + "pi0_decay": true, // + "det_location": "ip8", // choices: ip6 for STAR, ip8 for PHENIX + // Default choice: ip8 + // Attention: IF you donot know which to detection location to use, + // then please use ip8 as default + //************************************** + /// This section is Solid only + + "beam_energy": 11000, + "targ_pol_x": 0, + "targ_pol_y": 0, + "targ_pol_z": 0, + "scat_elec_Emin": 1100.0, + "scat_elec_Emax": 9900.0, + "scat_elec_thetamin": 5.0, + "scat_elec_thetamax": 27.0, + "prod_pion_thetamin": 5.0, + "prod_pion_thetamax": 20.0, + "multiple_scattering": false, + "ionization": false, + "bremsstrahlung": false, + "final_state_interaction": false, + "fermi_momentum": false, + "weight_cut": true, + "w_cut": true, + "w_min": 2, + "Qsq_cut": true, + "Qsq_min": 4, + "t_cut": true, + "t_min": -1.2 +} diff --git a/Config_EIC_Pi0_no_decay.json b/Config_EIC_Pi0_no_decay.json new file mode 100644 index 0000000..1f51973 --- /dev/null +++ b/Config_EIC_Pi0_no_decay.json @@ -0,0 +1,60 @@ +{ + // This is an exmaple Json configuration file that will accept + // parameters for both EIC and Solid simulation. + //Config + // All values should use units of MeV for energies and momenta, + // and degrees for angles. + // n_events indicates number of attempts + // "experiment" : "eic" or "solid" + // "experiment" : "solid", + "experiment" : "eic", + + "file_name" : "DEMPGen_Pion0_no_decay", +// "file_name" : "DEMPGen_PionPlus_test", +// "n_events" : 50000, // Per file size under 500k, due to g4e capability +// "n_events" : 85000, // Per file size under 500k, due to g4e capability + "n_events" : 10, // Per file size under 500k, due to g4e capability +// "n_events" : 10000, + "output_file" : "RootFiles/Test.root", + "generator_seed": 6423, + + //************************************** + /// This section if for EIC simulation only + "Targ_dir" : 1, // Target Direction (1->Up, 2->Down) + "Kinematics_type" : 1, // Kinematics type (1->FF, 2->TSSA) + // "particle": "omega", // Choices: omega, pi+, pi0 + //"particle": "omega", // Choices: omega, pi+, pi0 + //"particle": "Pion+", // Choices: omega, pi+, pi0 + //"particle": "Pi0", // Choices: omega, pi+, pi0 + "particle": "Pi0", // Choices: omega, pi+, pi0 + "pi0_decay": false, // + "det_location": "ip8", // choices: ip6 for STAR, ip8 for PHENIX + // Default choice: ip8 + // Attention: IF you donot know which to detection location to use, + // then please use ip8 as default + //************************************** + /// This section is Solid only + + "beam_energy": 11000, + "targ_pol_x": 0, + "targ_pol_y": 0, + "targ_pol_z": 0, + "scat_elec_Emin": 1100.0, + "scat_elec_Emax": 9900.0, + "scat_elec_thetamin": 5.0, + "scat_elec_thetamax": 27.0, + "prod_pion_thetamin": 5.0, + "prod_pion_thetamax": 20.0, + "multiple_scattering": false, + "ionization": false, + "bremsstrahlung": false, + "final_state_interaction": false, + "fermi_momentum": false, + "weight_cut": true, + "w_cut": true, + "w_min": 2, + "Qsq_cut": true, + "Qsq_min": 4, + "t_cut": true, + "t_min": -1.2 +} diff --git a/Config_EIC_PiPlus.json b/Config_EIC_PiPlus.json new file mode 100644 index 0000000..45c8b40 --- /dev/null +++ b/Config_EIC_PiPlus.json @@ -0,0 +1,54 @@ +{ + // This is an exmaple Json configuration file that will accept + // parameters for both EIC and Solid simulation. + //Config + // All values should use units of MeV for energies and momenta, + // and degrees for angles. + // n_events indicates number of attempts + // "experiment" : "eic" or "solid" + // "experiment" : "solid", + "experiment" : "eic", + + "file_name" : "DEMPGen_PionPlus_org", +// "file_name" : "DEMPGen_PionPlus_test", + "n_events" : 100000000, + "output_file" : "RootFiles/Test.root", + "generator_seed": 32059008, + + //************************************** + /// This section if for EIC simulation only + "Targ_dir" : 1, // Target Direction (1->Up, 2->Down) + "Kinematics_type" : 1, // Kinematics type (1->FF, 2->TSSA) + // "particle": "omega", // Choices: omega, pi+, pi0 + //"particle": "omega", // Choices: omega, pi+, pi0 + //"particle": "Pion+", // Choices: omega, pi+, pi0 + //"particle": "Pi0", // Choices: omega, pi+, pi0 + + "particle": "Pi+", // Choices: omega, pi+, pi0 + + //************************************** + /// This section is Solid only + + "beam_energy": 11000, + "targ_pol_x": 0, + "targ_pol_y": 0, + "targ_pol_z": 0, + "scat_elec_Emin": 1100.0, + "scat_elec_Emax": 9900.0, + "scat_elec_thetamin": 5.0, + "scat_elec_thetamax": 27.0, + "prod_pion_thetamin": 5.0, + "prod_pion_thetamax": 20.0, + "multiple_scattering": false, + "ionization": false, + "bremsstrahlung": false, + "final_state_interaction": false, + "fermi_momentum": false, + "weight_cut": true, + "w_cut": true, + "w_min": 2, + "Qsq_cut": true, + "Qsq_min": 4, + "t_cut": true, + "t_min": -1.2 +} diff --git a/New_Config_EIC.json b/New_Config_EIC.json new file mode 100644 index 0000000..4ba4490 --- /dev/null +++ b/New_Config_EIC.json @@ -0,0 +1,18 @@ +{ + // This is an exmaple Json configuration file that will accept + // parameters for both EIC and Solid simulation. + //Config + // All values should use units of MeV for energies and momenta, + // and degrees for angles. + // n_events indicates number of attempts + "experiment" : "eic", + + "file_name" : "DEMPGen_PionPlus_org", + "n_events" : 100000000, + "output_file" : "RootFiles/Test.root", + "generator_seed": 1234567, + "Targ_dir" : 1, // Target Direction (1->Up, 2->Down) + "Kinematics_type" : 1, // Kinematics type (1->FF, 2->TSSA) + "particle": "Pion+", // Choices: omega, pi+, pi0 + +} diff --git a/batch_runEIC.sh b/batch_runEIC.sh index 69ed501..9d0ed32 100755 --- a/batch_runEIC.sh +++ b/batch_runEIC.sh @@ -1,35 +1,37 @@ #! /bin/bash # Batch submission job script, executes run_EIC_batch.csh script -echo "Running as ${USER}" # Checks who you're running this as' +echo "Running as ${USER}" # Checks who you're running this as NumFiles=$1 NumEvents=$2 -NumFiles = `expr $NumFiles + 1` ##Output history file## historyfile=hist.$( date "+%Y-%m-%d_%H-%M-%S" ).log # Creates a log file -##Output batch script## -batch="${USER}_Job.txt" # The name of the job submission script it'll create each time +##Output batch script## auger="augerID.tmp" i=1 while [[ $i -le $NumFiles ]]; do + batch="${USER}_EICDempGen_5on100_${i}_Job.txt" # The name of the job submission script it'll create each time echo "Running ${batch} for file ${i}" cp /dev/null ${batch} + RandomSeed=$(od -An -N3 -i /dev/random) echo "#!/bin/csh" >> ${batch} # Tells your job which shell to run in - echo "#PBS -N DEMPGen_${NumEvents}_${i}" >> ${batch} # Name your job + echo "#PBS -N DEMPGen_5on100_${NumEvents}_${i}" >> ${batch} # Name your job echo "#PBS -m abe" >> ${batch} # Email you on job start, end or error - echo "#PBS -M ${USER}@jlab.org" >>${batch} # Your email address, change it to be what you like + #echo "#PBS -M ${USER}@jlab.org" >>${batch} # Your email address, change it to be what you like echo "#PBS -r n" >> ${batch} # Don't re-run if it crashes - echo "#PBS -o /home/${USER}/trq_output/DEMPGen_${NumEvents}_${i}.out" >> ${batch} # Output directory and file name, set to what you like - echo "#PBS -e /home/${USER}/trq_output/DEMPGen_${NumEvents}_${i}.err" >> ${batch} # Error output directory and file name + echo "#PBS -o /home/${USER}/trq_output/DEMPGen_5on100_${NumEvents}_${i}.out" >> ${batch} # Output directory and file name, set to what you like + echo "#PBS -e /home/${USER}/trq_output/DEMPGen_5on100_${NumEvents}_${i}.err" >> ${batch} # Error output directory and file name echo "date" >> ${batch} echo "cd /home/apps/DEMPgen/" >> ${batch} # Tell your job to go to the directory with the script you want to run - echo "./run_EIC_batch.csh ${i} ${NumEvents}" >> ${batch} # Run your script, change this to what you like + echo "./run_EIC_batch.csh ${i} ${NumEvents} ${RandomSeed}" >> ${batch} # Run your script, change this to what you like echo "date">>${batch} echo "exit">>${batch} # End of your job script echo "Submitting batch" eval "qsub ${batch} 2>/dev/null" # Use qsub to actually submit your job echo " " i=$(( $i + 1 )) + sleep 2 + rm ${batch} done diff --git a/batch_runEIC_10on100.sh b/batch_runEIC_10on100.sh new file mode 100755 index 0000000..d506a90 --- /dev/null +++ b/batch_runEIC_10on100.sh @@ -0,0 +1,37 @@ +#! /bin/bash +# Batch submission job script, executes run_EIC_batch.csh script + +echo "Running as ${USER}" # Checks who you're running this as +NumFiles=$1 +NumEvents=$2 + +##Output history file## +historyfile=hist.$( date "+%Y-%m-%d_%H-%M-%S" ).log # Creates a log file +##Output batch script## +auger="augerID.tmp" + +i=1 +while [[ $i -le $NumFiles ]]; do + batch="${USER}_EICDempGen_10on100_${i}_Job.txt" # The name of the job submission script it'll create each time + echo "Running ${batch} for file ${i}" + cp /dev/null ${batch} + RandomSeed=$(od -An -N3 -i /dev/random) + echo "#!/bin/csh" >> ${batch} # Tells your job which shell to run in + echo "#PBS -N DEMPGen_10on100_${NumEvents}_${i}" >> ${batch} # Name your job + echo "#PBS -m abe" >> ${batch} # Email you on job start, end or error + #echo "#PBS -M ${USER}@jlab.org" >>${batch} # Your email address, change it to be what you like + echo "#PBS -r n" >> ${batch} # Don't re-run if it crashes + echo "#PBS -o /home/${USER}/trq_output/DEMPGen_10on100_${NumEvents}_${i}.out" >> ${batch} # Output directory and file name, set to what you like + echo "#PBS -e /home/${USER}/trq_output/DEMPGen_10on100_${NumEvents}_${i}.err" >> ${batch} # Error output directory and file name + echo "date" >> ${batch} + echo "cd /home/apps/DEMPgen/" >> ${batch} # Tell your job to go to the directory with the script you want to run + echo "./run_EIC_batch_10on100.csh ${i} ${NumEvents} ${RandomSeed}" >> ${batch} # Run your script, change this to what you like + echo "date">>${batch} + echo "exit">>${batch} # End of your job script + echo "Submitting batch" + eval "qsub ${batch} 2>/dev/null" # Use qsub to actually submit your job + echo " " + i=$(( $i + 1 )) + sleep 2 + rm ${batch} +done diff --git a/batch_runEIC_5on100.sh b/batch_runEIC_5on100.sh new file mode 100755 index 0000000..7620e59 --- /dev/null +++ b/batch_runEIC_5on100.sh @@ -0,0 +1,37 @@ +#! /bin/bash +# Batch submission job script, executes run_EIC_batch.csh script + +echo "Running as ${USER}" # Checks who you're running this as +NumFiles=$1 +NumEvents=$2 + +##Output history file## +historyfile=hist.$( date "+%Y-%m-%d_%H-%M-%S" ).log # Creates a log file +##Output batch script## +auger="augerID.tmp" + +i=1 +while [[ $i -le $NumFiles ]]; do + batch="${USER}_EICDempGen_5on100_${i}_Job.txt" # The name of the job submission script it'll create each time + echo "Running ${batch} for file ${i}" + cp /dev/null ${batch} + RandomSeed=$(od -An -N3 -i /dev/random) + echo "#!/bin/csh" >> ${batch} # Tells your job which shell to run in + echo "#PBS -N DEMPGen_5on100_${NumEvents}_${i}" >> ${batch} # Name your job + echo "#PBS -m abe" >> ${batch} # Email you on job start, end or error + #echo "#PBS -M ${USER}@jlab.org" >>${batch} # Your email address, change it to be what you like + echo "#PBS -r n" >> ${batch} # Don't re-run if it crashes + echo "#PBS -o /home/${USER}/trq_output/DEMPGen_5on100_${NumEvents}_${i}.out" >> ${batch} # Output directory and file name, set to what you like + echo "#PBS -e /home/${USER}/trq_output/DEMPGen_5on100_${NumEvents}_${i}.err" >> ${batch} # Error output directory and file name + echo "date" >> ${batch} + echo "cd /home/apps/DEMPgen/" >> ${batch} # Tell your job to go to the directory with the script you want to run + echo "./run_EIC_batch_5on100.csh ${i} ${NumEvents} ${RandomSeed}" >> ${batch} # Run your script, change this to what you like + echo "date">>${batch} + echo "exit">>${batch} # End of your job script + echo "Submitting batch" + eval "qsub ${batch} 2>/dev/null" # Use qsub to actually submit your job + echo " " + i=$(( $i + 1 )) + sleep 2 + rm ${batch} +done diff --git a/batch_runEIC_5on41.sh b/batch_runEIC_5on41.sh new file mode 100755 index 0000000..f08911c --- /dev/null +++ b/batch_runEIC_5on41.sh @@ -0,0 +1,37 @@ +#! /bin/bash +# Batch submission job script, executes run_EIC_batch.csh script + +echo "Running as ${USER}" # Checks who you're running this as +NumFiles=$1 +NumEvents=$2 + +##Output history file## +historyfile=hist.$( date "+%Y-%m-%d_%H-%M-%S" ).log # Creates a log file +##Output batch script## +auger="augerID.tmp" + +i=1 +while [[ $i -le $NumFiles ]]; do + batch="${USER}_EICDempGen_5on41_${i}_Job.txt" # The name of the job submission script it'll create each time + echo "Running ${batch} for file ${i}" + cp /dev/null ${batch} + RandomSeed=$(od -An -N3 -i /dev/random) + echo "#!/bin/csh" >> ${batch} # Tells your job which shell to run in + echo "#PBS -N DEMPGen_5on41_${NumEvents}_${i}" >> ${batch} # Name your job + echo "#PBS -m abe" >> ${batch} # Email you on job start, end or error + #echo "#PBS -M ${USER}@jlab.org" >>${batch} # Your email address, change it to be what you like + echo "#PBS -r n" >> ${batch} # Don't re-run if it crashes + echo "#PBS -o /home/${USER}/trq_output/DEMPGen_5on41_${NumEvents}_${i}.out" >> ${batch} # Output directory and file name, set to what you like + echo "#PBS -e /home/${USER}/trq_output/DEMPGen_5on41_${NumEvents}_${i}.err" >> ${batch} # Error output directory and file name + echo "date" >> ${batch} + echo "cd /home/apps/DEMPgen/" >> ${batch} # Tell your job to go to the directory with the script you want to run + echo "./run_EIC_batch_5on41.csh ${i} ${NumEvents} ${RandomSeed}" >> ${batch} # Run your script, change this to what you like + echo "date">>${batch} + echo "exit">>${batch} # End of your job script + echo "Submitting batch" + eval "qsub ${batch} 2>/dev/null" # Use qsub to actually submit your job + echo " " + i=$(( $i + 1 )) + sleep 2 + rm ${batch} +done diff --git a/bill_notes b/bill_notes index 2d84322..9cc2748 100644 --- a/bill_notes +++ b/bill_notes @@ -22,9 +22,64 @@ Note Mar 5, 2020: 2. Main function in eiv_evgen is modified to accept Config.json file +/*--------------------------------------------------*/ +Note Mar 30, 2020: + + +1. Coding structure changes: + +Old code: DEMP->EIC->PiPlus_production_routine + +New code: DEMP->EIC->Reaction_rountine->XXX_production_routine + +Note that at the Reaction_rountine, it takes care of determining which sub process is selected, and the particle type is now an option in the Json configuration file. + +The event loop is intentionally left at the each sub process level, since one may want to have a customized output or other actions at the end of the run (like as in the PiPlus case, Ahmed really wanted to know how many events at a certain Q2 or W cuts). + +2. Sub process subroutine dir added. + +Note that for all subroutines, the source files are stored under: + +DEMPgen/src/eic_evgen/process_routine/ + +Note that we currently have Pi0_prod.cc, and PiPlus_prod.cc. The header file for the function is store in DEMPgen/src/eic_evgen/reaction_rountine.h. + +To create a new subroutine, one just have to declare the daughter class in reaction_rountine.h (with only process_reaction and customized Get_cross_section functions), add a if statement in the reaction_rountine.cc and create a new XXX_prod.cc file. + +3. The original PionPlus process routine (written by Ahmed) is now made to be generic. The code will determine which produced particle and which recoiled nucleon automatically. Ahmed's code are now converted to the Mother process routine, which other sub process routine can give borrow its structure and functions. + +I compared the functionality of new generic form of the code and old, and yes, they are exactly the same (with the same set of parameter, the numerical calculated results are 100% match ). However, the distribution are not 100% same due to how the random number generator is defined. If Stephen can further validate this would be fantastic. + +4. Using the particleType.h (under include/) and naming the produced particle. + +particleType.h is the particle data base used by GlueX analysis software, which has large data base of particle mass. The new code now uses the same naming convention as the GlueX. + +In terms of the particle naming in the Json file, it is extremely flexible. As an example: pi+, Pi+, piplus, PiPlus, Piplus, are all acceptable form of pi+. Same goes for all other changed particles such as k+, etc. pi, pi0, Pi0, PI0, Pion0, are all acceptable form of pi0. The code will standardize the names and get the particle mass from the library. + + + +5. In terms of performance compared to the old code, the new code run quite a bit faster see performance comparison + +---------------------------------------- + +New code test: +Time : Real time 0:03:50, CP time 230.730 +Event: 100000000 +Recorded events: 1768 +Memory used: 0.2G + +--------------------------------------- +Org code test: +Time : Real time 0:05:45, CP time 344.940 +Event: 100000000 +Recorded events: 1708 +Memory used: 0.1G +---------------------------------------- +6: Random generator is now initiallied during the sub process routine initialiation, in the reaction class. +7. Now, the recoil nucleon and produced particle X will assigned with the PDG type ID automatically when outputing the LUND files. diff --git a/data/output/test.root b/data/output/test.root deleted file mode 100644 index 41b0b1e..0000000 Binary files a/data/output/test.root and /dev/null differ diff --git a/data/performance_difference b/data/performance_difference new file mode 100644 index 0000000..9e22119 --- /dev/null +++ b/data/performance_difference @@ -0,0 +1,14 @@ +New code test: +Time : Real time 0:03:50, CP time 230.730 +Event: 100000000 +Recorded events: 1768 +Memory used: 0.2G + +Org code test: +Time : Real time 0:05:45, CP time 344.940 +Event: 100000000 +Recorded events: 1708 +Memory used: 0.1G + + + diff --git a/include/CustomRand.hxx b/include/CustomRand.hxx index 9d89a2b..025b864 100644 --- a/include/CustomRand.hxx +++ b/include/CustomRand.hxx @@ -32,6 +32,11 @@ class CustomRand CustomRand(const char * fname, double VRange[6]); + CustomRand(const char * fname, + double ERange[2], double ThetaRange[2], + double PhiRange[2], int demp_seed); + + /* CustomRand(double ERange[2], double PhiRange[2], */ /* bouble PhiRange[2], */ diff --git a/include/particleType.h b/include/particleType.h new file mode 100644 index 0000000..dd8e46f --- /dev/null +++ b/include/particleType.h @@ -0,0 +1,2906 @@ +/* + * particleType.h +*/ + +#ifndef particleTypeH_INCLUDED +#define particleTypeH_INCLUDED + +#include +#include +#include + +typedef enum { + + /* An extensive list of the GEANT3 particle + * codes can be found here: + * http://wwwasdoc.web.cern.ch/wwwasdoc/geant/node72.html + */ + + Unknown = 0, + Gamma = 1, + Positron = 2, + Electron = 3, + Neutrino = 4, + MuonPlus = 5, + MuonMinus = 6, + Pi0 = 7, + PiPlus = 8, + PiMinus = 9, + KLong = 10, + KPlus = 11, + KMinus = 12, + Neutron = 13, + Proton = 14, + AntiProton = 15, + KShort = 16, + Eta = 17, + Lambda = 18, + SigmaPlus = 19, + Sigma0 = 20, + SigmaMinus = 21, + Xi0 = 22, + XiMinus = 23, + OmegaMinus = 24, + AntiNeutron = 25, + AntiLambda = 26, + AntiSigmaMinus = 27, + AntiSigma0 = 28, + AntiSigmaPlus = 29, + AntiXi0 = 30, + AntiXiPlus = 31, + AntiOmegaPlus = 32, + Deuteron = 45, + Triton = 46, + Helium = 47, + Geantino = 48, + He3 = 49, + + Li6 = 61, + Li7 = 62, + Be7 = 63, + Be9 = 64, + B10 = 65, + B11 = 66, + C12 = 67, + N14 = 68, + O16 = 69, + F19 = 70, + Ne20 = 71, + Na23 = 72, + Mg24 = 73, + Al27 = 74, + Si28 = 75, + P31 = 76, + S32 = 77, + Cl35 = 78, + Ar36 = 79, + K39 = 80, + Ca40 = 81, + Sc45 = 82, + Ti48 = 83, + V51 = 84, + Cr52 = 85, + Mn55 = 86, + Fe56 = 87, + Co59 = 88, + Ni58 = 89, + Cu63 = 90, + Zn64 = 91, + Ge74 = 92, + Se80 = 93, + Kr84 = 94, + Sr88 = 95, + Zr90 = 96, + Mo98 = 97, + Pd106 = 98, + Cd114 = 99, + Sn120 = 100, + Xe132 = 101, + Ba138 = 102, + Ce140 = 103, + Sm152 = 104, + Dy164 = 105, + Yb174 = 106, + W184 = 107, + Pt194 = 108, + Au197 = 109, + Hg202 = 110, + Pb208 = 111, + U238 = 112, + + /* the constants defined by GEANT end here */ + + /* + * Several particle codes are added below which did + * not overlap with the original GEANT particle list. + * However, the link above has several other particle + * codes added which do actually overlap. Because of + * this, each of the values below was increased by + * 100 so that they don't overlap with any of the new + * codes and they can be used. + */ + + + /* These are E852-defined constants */ + Rho0 = 44, // was 157 + RhoPlus = 42, // was 158 + RhoMinus = 43, // was 159 + omega = 33, // was 160 + phiMeson = 34, // was 162 + EtaPrime = 35, // was 161 + //Rho0 = 157, + //RhoPlus = 158, + //RhoMinus = 159, + //omega = 160, + //EtaPrime = 161, + //phiMeson = 162, + a0_980 = 163, + f0_980 = 164, + + /* These are GlueX-defined constants */ + + KStar_892_0 = 165, + KStar_892_Plus = 166, + KStar_892_Minus = 167, + AntiKStar_892_0 = 168, + + K1_1400_Plus = 169, + K1_1400_Minus = 170, + + b1_1235_Plus = 171, + Sigma_1385_Minus = 172, + Sigma_1385_0 = 173, + Sigma_1385_Plus = 174, + + Jpsi = 183, + Eta_c = 184, + Chi_c0 = 185, + Chi_c1 = 186, + Chi_c2 = 187, + Psi2s = 188, + D0 = 189, + DPlus = 190, + Dstar0 = 191, + DstarPlus = 192, + Lambda_c = 193, + AntiD0 = 194, + + /* These are defined in pythia-geant.map in bggen */ + + //Rho0 = 80, // already defined above (44) + //omega = 81, // already defined above (33) + DeltaPlusPlus = 182 + + +} Particle_t; + +static inline Particle_t RemapParticleID(Particle_t p) +{ + // bggen defines these in pythia-geant.dat. However, + // they are not the same as the definitions used from + // E-852 in the enum above. Remap them using this routine + // which is called from several of the routines below. + //if(p==80) return Rho0; + //if(p==81) return omega; + return p; +} + +inline static int IsLepton(Particle_t p) +{ + return ((p == Electron) || (p == Positron) || (p == MuonPlus) || (p == MuonMinus) || (p == Neutrino)); +} + +inline static char* ParticleType(Particle_t p) +{ + p = RemapParticleID(p); + + switch (p) { + case Unknown: + return (char*)"Unknown"; + case Gamma: + return (char*)"Photon"; + case Positron: + return (char*)"Positron"; + case Electron: + return (char*)"Electron"; + case Neutrino: + return (char*)"Neutrino"; + case MuonPlus: + return (char*)"Muon+"; + case MuonMinus: + return (char*)"Muon-"; + case Pi0: + return (char*)"Pi0"; + case PiPlus: + return (char*)"Pi+"; + case PiMinus: + return (char*)"Pi-"; + case KLong: + return (char*)"KLong"; + case KPlus: + return (char*)"K+"; + case KMinus: + return (char*)"K-"; + case Neutron: + return (char*)"Neutron"; + case Proton: + return (char*)"Proton"; + case AntiProton: + return (char*)"AntiProton"; + case KShort: + return (char*)"KShort"; + case Eta: + return (char*)"Eta"; + case Lambda: + return (char*)"Lambda"; + case SigmaPlus: + return (char*)"Sigma+"; + case Sigma0: + return (char*)"Sigma0"; + case SigmaMinus: + return (char*)"Sigma-"; + case Xi0: + return (char*)"Xi0"; + case XiMinus: + return (char*)"Xi-"; + case OmegaMinus: + return (char*)"Omega-"; + case AntiNeutron: + return (char*)"AntiNeutron"; + case AntiLambda: + return (char*)"AntiLambda"; + case AntiSigmaMinus: + return (char*)"AntiSigma-"; + case AntiSigma0: + return (char*)"AntiSigma0"; + case AntiSigmaPlus: + return (char*)"AntiSigma+"; + case AntiXi0: + return (char*)"AntiXi0"; + case AntiXiPlus: + return (char*)"AntiXi+"; + case AntiOmegaPlus: + return (char*)"AntiOmega+"; + case Geantino: + return (char*)"Geantino"; + case Rho0: + return (char*)"Rho0"; + case RhoPlus: + return (char*)"Rho+"; + case RhoMinus: + return (char*)"Rho-"; + case omega: + return (char*)"Omega"; + case EtaPrime: + return (char*)"EtaPrime"; + case phiMeson: + return (char*)"Phi"; + case a0_980: + return (char*)"a0(980)"; + case f0_980: + return (char*)"f0(980)"; + case KStar_892_0: + return (char*)"K*(892)0"; + case KStar_892_Plus: + return (char*)"K*(892)+"; + case KStar_892_Minus: + return (char*)"K*(892)-"; + case AntiKStar_892_0: + return (char*)"antiK*(892)0"; + case K1_1400_Plus: + return (char*)"K1(1400)+"; + case K1_1400_Minus: + return (char*)"K1(1400)-"; + case b1_1235_Plus: + return (char*)"b1(1235)+"; + case Sigma_1385_Minus: + return (char*)"Sigma(1385)-"; + case Sigma_1385_0: + return (char*)"Sigma(1385)0"; + case Sigma_1385_Plus: + return (char*)"Sigma(1385)+"; + case Deuteron: + return (char*)"Deuteron"; + case Triton: + return (char*)"Triton"; + case Helium: + return (char*)"Helium"; + case He3: + return (char*)"Helium-3"; + case Li6: + return (char*)"Lithium-6"; + case Li7: + return (char*)"Lithium-7"; + case Be7: + return (char*)"Beryllium-7"; + case Be9: + return (char*)"Beryllium-9"; + case B10: + return (char*)"Boron-10"; + case B11: + return (char*)"Boron-11"; + case C12: + return (char*)"Carbon"; + case N14: + return (char*)"Nitrogen"; + case O16: + return (char*)"Oxygen"; + case F19: + return (char*)"Fluorine"; + case Ne20: + return (char*)"Neon"; + case Na23: + return (char*)"Sodium"; + case Mg24: + return (char*)"Magnesium"; + case Al27: + return (char*)"Aluminum"; + case Si28: + return (char*)"Silicon"; + case P31: + return (char*)"Phosphorous"; + case S32: + return (char*)"Sulphur"; + case Cl35: + return (char*)"Chlorine"; + case Ar36: + return (char*)"Argon"; + case K39: + return (char*)"Potassium"; + case Ca40: + return (char*)"Calcium"; + case Sc45: + return (char*)"Scandium"; + case Ti48: + return (char*)"Titanium"; + case V51: + return (char*)"Vanadium"; + case Cr52: + return (char*)"Chromium"; + case Mn55: + return (char*)"Manganese"; + case Fe56: + return (char*)"Iron"; + case Co59: + return (char*)"Cobalt"; + case Ni58: + return (char*)"Nickel"; + case Cu63: + return (char*)"Copper"; + case Zn64: + return (char*)"Zinc"; + case Ge74: + return (char*)"Germanium"; + case Se80: + return (char*)"Selenium"; + case Kr84: + return (char*)"Krypton"; + case Sr88: + return (char*)"Strontium"; + case Zr90: + return (char*)"Zirconium"; + case Mo98: + return (char*)"Molybdenum"; + case Pd106: + return (char*)"Palladium"; + case Cd114: + return (char*)"Cadmium"; + case Sn120: + return (char*)"Tin"; + case Xe132: + return (char*)"Xenon"; + case Ba138: + return (char*)"Barium"; + case Ce140: + return (char*)"Cesium"; + case Sm152: + return (char*)"Samerium"; + case Dy164: + return (char*)"Dysprosium"; + case Yb174: + return (char*)"Ytterbium"; + case W184: + return (char*)"Tungsten"; + case Pt194: + return (char*)"Platium"; + case Au197: + return (char*)"Gold"; + case Hg202: + return (char*)"Mercury"; + case Pb208: + return (char*)"Lead"; + case U238: + return (char*)"Uranium"; + case DeltaPlusPlus: + return (char*)"Delta++"; + case Jpsi: + return (char*)"Jpsi"; + case Eta_c: + return (char*)"EtaC"; + case Chi_c0: + return (char*)"ChiC0"; + case Chi_c1: + return (char*)"ChiC1"; + case Chi_c2: + return (char*)"ChiC2"; + case Psi2s: + return (char*)"Psi(2S)"; + case D0: + return (char*)"D0"; + case AntiD0: + return (char*)"AntiD0"; + case DPlus: + return (char*)"D+"; + case Dstar0: + return (char*)"D*0"; + case DstarPlus: + return (char*)"D*+"; + case Lambda_c: + return (char*)"LambdaC"; + default: + return (char*)"Unknown"; + } +} + +inline static char* EnumString(Particle_t p) +{ + //returns string that is exact match to enum name. for auto-generating code + p = RemapParticleID(p); + + switch (p) { + case Unknown: + return (char*)"Unknown"; + case Gamma: + return (char*)"Gamma"; + case Positron: + return (char*)"Positron"; + case Electron: + return (char*)"Electron"; + case Neutrino: + return (char*)"Neutrino"; + case MuonPlus: + return (char*)"MuonPlus"; + case MuonMinus: + return (char*)"MuonMinus"; + case Pi0: + return (char*)"Pi0"; + case PiPlus: + return (char*)"PiPlus"; + case PiMinus: + return (char*)"PiMinus"; + case KLong: + return (char*)"KLong"; + case KPlus: + return (char*)"KPlus"; + case KMinus: + return (char*)"KMinus"; + case Neutron: + return (char*)"Neutron"; + case Proton: + return (char*)"Proton"; + case AntiProton: + return (char*)"AntiProton"; + case KShort: + return (char*)"KShort"; + case Eta: + return (char*)"Eta"; + case Lambda: + return (char*)"Lambda"; + case SigmaPlus: + return (char*)"SigmaPlus"; + case Sigma0: + return (char*)"Sigma0"; + case SigmaMinus: + return (char*)"SigmaMinus"; + case Xi0: + return (char*)"Xi0"; + case XiMinus: + return (char*)"XiMinus"; + case OmegaMinus: + return (char*)"OmegaMinus"; + case AntiNeutron: + return (char*)"AntiNeutron"; + case AntiLambda: + return (char*)"AntiLambda"; + case AntiSigmaMinus: + return (char*)"AntiSigmaMinus"; + case AntiSigma0: + return (char*)"AntiSigma0"; + case AntiSigmaPlus: + return (char*)"AntiSigmaPlus"; + case AntiXi0: + return (char*)"AntiXi0"; + case AntiXiPlus: + return (char*)"AntiXiPlus"; + case AntiOmegaPlus: + return (char*)"AntiOmegaPlus"; + case Geantino: + return (char*)"Geantino"; + case Rho0: + return (char*)"Rho0"; + case RhoPlus: + return (char*)"RhoPlus"; + case RhoMinus: + return (char*)"RhoMinus"; + case omega: + return (char*)"omega"; + case EtaPrime: + return (char*)"EtaPrime"; + case phiMeson: + return (char*)"phiMeson"; + case a0_980: + return (char*)"a0_980"; + case f0_980: + return (char*)"f0_980"; + case KStar_892_0: + return (char*)"KStar_892_0"; + case KStar_892_Plus: + return (char*)"KStar_892_Plus"; + case KStar_892_Minus: + return (char*)"KStar_892_Minus"; + case AntiKStar_892_0: + return (char*)"AntiKStar_892_0"; + case K1_1400_Plus: + return (char*)"K1_1400_Plus"; + case K1_1400_Minus: + return (char*)"K1_1400_Minus"; + case b1_1235_Plus: + return (char*)"b1_1235_Plus"; + case Sigma_1385_Minus: + return (char*)"Sigma_1385_Minus"; + case Sigma_1385_0: + return (char*)"Sigma_1385_0"; + case Sigma_1385_Plus: + return (char*)"Sigma_1385_Plus"; + case Deuteron: + return (char*)"Deuteron"; + case Triton: + return (char*)"Triton"; + case Helium: + return (char*)"Helium"; + case He3: + return (char*)"Helium-3"; + case Li6: + return (char*)"Lithium-6"; + case Li7: + return (char*)"Lithium-7"; + case Be7: + return (char*)"Beryllium-7"; + case Be9: + return (char*)"Beryllium-9"; + case B10: + return (char*)"Boron-10"; + case B11: + return (char*)"Boron-11"; + case C12: + return (char*)"Carbon"; + case N14: + return (char*)"Nitrogen"; + case O16: + return (char*)"Oxygen"; + case F19: + return (char*)"Fluorine"; + case Ne20: + return (char*)"Neon"; + case Na23: + return (char*)"Sodium"; + case Mg24: + return (char*)"Magnesium"; + case Al27: + return (char*)"Aluminum"; + case Si28: + return (char*)"Silicon"; + case P31: + return (char*)"Phosphorous"; + case S32: + return (char*)"Sulphur"; + case Cl35: + return (char*)"Chlorine"; + case Ar36: + return (char*)"Argon"; + case K39: + return (char*)"Potassium"; + case Ca40: + return (char*)"Calcium"; + case Sc45: + return (char*)"Scandium"; + case Ti48: + return (char*)"Titanium"; + case V51: + return (char*)"Vanadium"; + case Cr52: + return (char*)"Chromium"; + case Mn55: + return (char*)"Manganese"; + case Fe56: + return (char*)"Iron"; + case Co59: + return (char*)"Cobalt"; + case Ni58: + return (char*)"Nickel"; + case Cu63: + return (char*)"Copper"; + case Zn64: + return (char*)"Zinc"; + case Ge74: + return (char*)"Germanium"; + case Se80: + return (char*)"Selenium"; + case Kr84: + return (char*)"Krypton"; + case Sr88: + return (char*)"Strontium"; + case Zr90: + return (char*)"Zirconium"; + case Mo98: + return (char*)"Molybdenum"; + case Pd106: + return (char*)"Palladium"; + case Cd114: + return (char*)"Cadmium"; + case Sn120: + return (char*)"Tin"; + case Xe132: + return (char*)"Xenon"; + case Ba138: + return (char*)"Barium"; + case Ce140: + return (char*)"Cesium"; + case Sm152: + return (char*)"Samerium"; + case Dy164: + return (char*)"Dysprosium"; + case Yb174: + return (char*)"Ytterbium"; + case W184: + return (char*)"Tungsten"; + case Pt194: + return (char*)"Platium"; + case Au197: + return (char*)"Gold"; + case Hg202: + return (char*)"Mercury"; + case Pb208: + return (char*)"Lead"; + case U238: + return (char*)"Uranium"; + case DeltaPlusPlus: + return (char*)"DeltaPlusPlus"; + case Jpsi: + return (char*)"Jpsi"; + case Eta_c: + return (char*)"Eta_c"; + case Chi_c0: + return (char*)"Chi_c0"; + case Chi_c1: + return (char*)"Chi_c1"; + case Chi_c2: + return (char*)"Chi_c2"; + case Psi2s: + return (char*)"Psi2s"; + case D0: + return (char*)"D0"; + case AntiD0: + return (char*)"AntiD0"; + case DPlus: + return (char*)"DPlus"; + case Dstar0: + return (char*)"Dstar0"; + case DstarPlus: + return (char*)"DstarPlus"; + case Lambda_c: + return (char*)"Lambda_c"; + default: + return (char*)"Unknown"; + } +} + +inline static char* EvtGenString(Particle_t p) +{ + //returns string that is exact match to enum name. for auto-generating code + p = RemapParticleID(p); + + switch (p) { + case Unknown: + return (char*)"Unknown"; + case Gamma: + return (char*)"gamma"; + case Positron: + return (char*)"e+"; + case Electron: + return (char*)"e-"; + case Neutrino: + return (char*)"nu_e"; + case MuonPlus: + return (char*)"mu+"; + case MuonMinus: + return (char*)"mu-"; + case Pi0: + return (char*)"pi0"; + case PiPlus: + return (char*)"pi+"; + case PiMinus: + return (char*)"pi-"; + case KLong: + return (char*)"K_L0"; + case KPlus: + return (char*)"K+"; + case KMinus: + return (char*)"K-"; + case Neutron: + return (char*)"n0"; + case Proton: + return (char*)"p+"; + case AntiProton: + return (char*)"anti-p-"; + case KShort: + return (char*)"K_S0"; + case Eta: + return (char*)"eta"; + case Lambda: + return (char*)"Lambda0"; + case SigmaPlus: + return (char*)"Sigma+"; + case Sigma0: + return (char*)"Sigma0"; + case SigmaMinus: + return (char*)"Sigma-"; + case Xi0: + return (char*)"Xi0"; + case XiMinus: + return (char*)"Xi-"; + case OmegaMinus: + return (char*)"Omega-"; + case AntiNeutron: + return (char*)"anti-n0"; + case AntiLambda: + return (char*)"anti-Lambda0"; + case AntiSigmaMinus: + return (char*)"anti-Sigma-"; + case AntiSigma0: + return (char*)"anti-Sigma0"; + case AntiSigmaPlus: + return (char*)"anti-Sigma+"; + case AntiXi0: + return (char*)"anti-Xi0"; + case AntiXiPlus: + return (char*)"anti-Xi+"; + case AntiOmegaPlus: + return (char*)"anti-Omega+"; + case Geantino: + return (char*)"geantino"; + case Rho0: + return (char*)"rho0"; + case RhoPlus: + return (char*)"rho+"; + case RhoMinus: + return (char*)"rho-"; + case omega: + return (char*)"omega"; + case EtaPrime: + return (char*)"eta'"; + case phiMeson: + return (char*)"phi"; + case a0_980: + return (char*)"a_0"; + case f0_980: + return (char*)"f_0"; + case KStar_892_0: + return (char*)"K*0"; + case KStar_892_Plus: + return (char*)"K*+"; + case KStar_892_Minus: + return (char*)"K*-"; + case AntiKStar_892_0: + return (char*)"anti-K*0"; + case K1_1400_Plus: + return (char*)"K'_1+"; + case K1_1400_Minus: + return (char*)"K'_1-"; + case b1_1235_Plus: + return (char*)"b_1+"; + case Sigma_1385_Minus: + return (char*)"Sigma_1385_Minus"; + case Sigma_1385_0: + return (char*)"Sigma_1385_0"; + case Sigma_1385_Plus: + return (char*)"Sigma_1385_Plus"; + case Deuteron: + return (char*)"deuteron"; + case Triton: + return (char*)"Triton"; // FIX + case Helium: + return (char*)"Helium"; // FIX + case He3: + return (char*)"He3"; + case Li6: + return (char*)"Lithium-6"; + case Li7: + return (char*)"Lithium-7"; + case Be7: + return (char*)"Beryllium-7"; + case Be9: + return (char*)"Beryllium-9"; + case B10: + return (char*)"Boron-10"; + case B11: + return (char*)"Boron-11"; + case C12: + return (char*)"Carbon"; + case N14: + return (char*)"Nitrogen"; + case O16: + return (char*)"Oxygen"; + case F19: + return (char*)"Fluorine"; + case Ne20: + return (char*)"Neon"; + case Na23: + return (char*)"Sodium"; + case Mg24: + return (char*)"Magnesium"; + case Al27: + return (char*)"Aluminum"; + case Si28: + return (char*)"Silicon"; + case P31: + return (char*)"Phosphorous"; + case S32: + return (char*)"Sulphur"; + case Cl35: + return (char*)"Chlorine"; + case Ar36: + return (char*)"Argon"; + case K39: + return (char*)"Potassium"; + case Ca40: + return (char*)"Calcium"; + case Sc45: + return (char*)"Scandium"; + case Ti48: + return (char*)"Titanium"; + case V51: + return (char*)"Vanadium"; + case Cr52: + return (char*)"Chromium"; + case Mn55: + return (char*)"Manganese"; + case Fe56: + return (char*)"Iron"; + case Co59: + return (char*)"Cobalt"; + case Ni58: + return (char*)"Nickel"; + case Cu63: + return (char*)"Copper"; + case Zn64: + return (char*)"Zinc"; + case Ge74: + return (char*)"Germanium"; + case Se80: + return (char*)"Selenium"; + case Kr84: + return (char*)"Krypton"; + case Sr88: + return (char*)"Strontium"; + case Zr90: + return (char*)"Zirconium"; + case Mo98: + return (char*)"Molybdenum"; + case Pd106: + return (char*)"Palladium"; + case Cd114: + return (char*)"Cadmium"; + case Sn120: + return (char*)"Tin"; + case Xe132: + return (char*)"Xenon"; + case Ba138: + return (char*)"Barium"; + case Ce140: + return (char*)"Cesium"; + case Sm152: + return (char*)"Samerium"; + case Dy164: + return (char*)"Dysprosium"; + case Yb174: + return (char*)"Ytterbium"; + case W184: + return (char*)"Tungsten"; + case Pt194: + return (char*)"Platium"; + case Au197: + return (char*)"Gold"; + case Hg202: + return (char*)"Mercury"; + case Pb208: + return (char*)"Lead"; + case U238: + return (char*)"Uranium"; + case DeltaPlusPlus: + return (char*)"Delta++"; + case Jpsi: + return (char*)"J/psi"; + case Eta_c: + return (char*)"eta_c"; + case Chi_c0: + return (char*)"chi_c0"; + case Chi_c1: + return (char*)"chi_c1"; + case Chi_c2: + return (char*)"chi_c2"; + case Psi2s: + return (char*)"psi(2S)"; + case D0: + return (char*)"D0"; + case AntiD0: + return (char*)"anti-D0"; + case DPlus: + return (char*)"D+"; + case Dstar0: + return (char*)"D*0"; + case DstarPlus: + return (char*)"D*+"; + case Lambda_c: + return (char*)"Lambda_c0"; + default: + return (char*)"Unknown"; + } +} + +inline static char* ShortName(Particle_t locPID) +{ + //returns string that is exact match to enum name. for auto-generating code + locPID = RemapParticleID(locPID); + + switch (locPID) { + case Unknown: + return (char*)"x"; + case Gamma: + return (char*)"g"; + case Positron: + return (char*)"ep"; + case Electron: + return (char*)"em"; + case Neutrino: + return (char*)"nu"; + case MuonPlus: + return (char*)"mup"; + case MuonMinus: + return (char*)"mum"; + case Pi0: + return (char*)"pi0"; + case PiPlus: + return (char*)"pip"; + case PiMinus: + return (char*)"pim"; + case KLong: + return (char*)"kl"; + case KPlus: + return (char*)"kp"; + case KMinus: + return (char*)"km"; + case Neutron: + return (char*)"n"; + case Proton: + return (char*)"prot"; + case AntiProton: + return (char*)"antip"; + case KShort: + return (char*)"ks"; + case Eta: + return (char*)"eta"; + case Lambda: + return (char*)"lamb"; + case SigmaPlus: + return (char*)"sigp"; + case Sigma0: + return (char*)"sig0"; + case SigmaMinus: + return (char*)"sigm"; + case Xi0: + return (char*)"xi0"; + case XiMinus: + return (char*)"xim"; + case OmegaMinus: + return (char*)"omegam"; + case AntiNeutron: + return (char*)"antin"; + case AntiLambda: + return (char*)"antilamb"; + case AntiSigmaMinus: + return (char*)"antisigm"; + case AntiSigma0: + return (char*)"antisig0"; + case AntiSigmaPlus: + return (char*)"antisigp"; + case AntiXi0: + return (char*)"antixi0"; + case AntiXiPlus: + return (char*)"antixip"; + case AntiOmegaPlus: + return (char*)"antiomegap"; + case Geantino: + return (char*)"geant"; + case omega: + return (char*)"omega"; + case EtaPrime: + return (char*)"etapr"; + case phiMeson: + return (char*)"phi"; + case Deuteron: + return (char*)"d"; + case Triton: + return (char*)"tri"; + case Helium: + return (char*)"he"; + case He3: + return (char*)"he3"; + case Li6: + return (char*)"li6"; + case Li7: + return (char*)"li7"; + case Be7: + return (char*)"be7"; + case Be9: + return (char*)"be9"; + case B10: + return (char*)"b10"; + case B11: + return (char*)"b11"; + case C12: + return (char*)"c12"; + case N14: + return (char*)"n14"; + case O16: + return (char*)"o16"; + case F19: + return (char*)"f19"; + case Ne20: + return (char*)"ne20"; + case Na23: + return (char*)"na23"; + case Mg24: + return (char*)"mg24"; + case Al27: + return (char*)"al27"; + case Si28: + return (char*)"si28"; + case P31: + return (char*)"p31"; + case S32: + return (char*)"s32"; + case Cl35: + return (char*)"cl35"; + case Ar36: + return (char*)"ar36"; + case K39: + return (char*)"k39"; + case Ca40: + return (char*)"ca40"; + case Sc45: + return (char*)"sc45"; + case Ti48: + return (char*)"ti48"; + case V51: + return (char*)"v51"; + case Cr52: + return (char*)"cr52"; + case Mn55: + return (char*)"mn55"; + case Fe56: + return (char*)"fe56"; + case Co59: + return (char*)"co59"; + case Ni58: + return (char*)"ni58"; + case Cu63: + return (char*)"cu63"; + case Zn64: + return (char*)"zn64"; + case Ge74: + return (char*)"ge74"; + case Se80: + return (char*)"se80"; + case Kr84: + return (char*)"kr84"; + case Sr88: + return (char*)"sr88"; + case Zr90: + return (char*)"zr90"; + case Mo98: + return (char*)"mo98"; + case Pd106: + return (char*)"pd106"; + case Cd114: + return (char*)"cd114"; + case Sn120: + return (char*)"sn120"; + case Xe132: + return (char*)"xe132"; + case Ba138: + return (char*)"ba138"; + case Ce140: + return (char*)"ce140"; + case Sm152: + return (char*)"sm152"; + case Dy164: + return (char*)"dy164"; + case Yb174: + return (char*)"yb174"; + case W184: + return (char*)"w184"; + case Pt194: + return (char*)"pt194"; + case Au197: + return (char*)"au197"; + case Hg202: + return (char*)"hg202"; + case Pb208: + return (char*)"pb208"; + case U238: + return (char*)"u238"; + case Jpsi: + return (char*)"jpsi"; + case Eta_c: + return (char*)"etac"; + case Chi_c0: + return (char*)"chic0"; + case Chi_c1: + return (char*)"chic1"; + case Chi_c2: + return (char*)"chic2"; + case Psi2s: + return (char*)"psi2s"; + case D0: + return (char*)"d0"; + case AntiD0: + return (char*)"antid0"; + case DPlus: + return (char*)"dp"; + case Dstar0: + return (char*)"ds0"; + case DstarPlus: + return (char*)"dsp"; + case Lambda_c: + return (char*)"lambc"; + + //not really supported + case Rho0: + return (char*)"Rho0"; + case RhoPlus: + return (char*)"RhoPlus"; + case RhoMinus: + return (char*)"RhoMinus"; + case a0_980: + return (char*)"a0_980"; + case f0_980: + return (char*)"f0_980"; + case KStar_892_0: + return (char*)"KStar_892_0"; + case KStar_892_Plus: + return (char*)"KStar_892_Plus"; + case KStar_892_Minus: + return (char*)"KStar_892_Minus"; + case AntiKStar_892_0: + return (char*)"AntiKStar_892_0"; + case K1_1400_Plus: + return (char*)"K1_1400_Plus"; + case K1_1400_Minus: + return (char*)"K1_1400_Minus"; + case b1_1235_Plus: + return (char*)"b1_1235_Plus"; + case Sigma_1385_Minus: + return (char*)"Sigma_1385_Minus"; + case Sigma_1385_0: + return (char*)"Sigma_1385_0"; + case Sigma_1385_Plus: + return (char*)"Sigma_1385_Plus"; + case DeltaPlusPlus: + return (char*)"DeltaPlusPlus"; + + default: + return (char*)"x"; + } +} + +inline static Particle_t ParticleEnum(const char* locParticleName) +{ + if(strcmp(locParticleName, "Unknown") == 0) + return Unknown; + else if(strcmp(locParticleName, "Photon") == 0) + return Gamma; + else if(strcmp(locParticleName, "Positron") == 0) + return Positron; + else if(strcmp(locParticleName, "Electron") == 0) + return Electron; + else if(strcmp(locParticleName, "Neutrino") == 0) + return Neutrino; + else if(strcmp(locParticleName, "Muon+") == 0) + return MuonPlus; + else if(strcmp(locParticleName, "Muon-") == 0) + return MuonMinus; + else if(strcmp(locParticleName, "Pi0") == 0) + return Pi0; + else if(strcmp(locParticleName, "Pi+") == 0) + return PiPlus; + else if(strcmp(locParticleName, "Pi-") == 0) + return PiMinus; + else if(strcmp(locParticleName, "KLong") == 0) + return KLong; + else if(strcmp(locParticleName, "K+") == 0) + return KPlus; + else if(strcmp(locParticleName, "K-") == 0) + return KMinus; + else if(strcmp(locParticleName, "Neutron") == 0) + return Neutron; + else if(strcmp(locParticleName, "Proton") == 0) + return Proton; + else if(strcmp(locParticleName, "AntiProton") == 0) + return AntiProton; + else if(strcmp(locParticleName, "KShort") == 0) + return KShort; + else if(strcmp(locParticleName, "Eta") == 0) + return Eta; + else if(strcmp(locParticleName, "Lambda") == 0) + return Lambda; + else if(strcmp(locParticleName, "Sigma+") == 0) + return SigmaPlus; + else if(strcmp(locParticleName, "Sigma0") == 0) + return Sigma0; + else if(strcmp(locParticleName, "Sigma-") == 0) + return SigmaMinus; + else if(strcmp(locParticleName, "Xi0") == 0) + return Xi0; + else if(strcmp(locParticleName, "Xi-") == 0) + return XiMinus; + else if(strcmp(locParticleName, "Omega-") == 0) + return OmegaMinus; + else if(strcmp(locParticleName, "AntiNeutron") == 0) + return AntiNeutron; + else if(strcmp(locParticleName, "AntiLambda") == 0) + return AntiLambda; + else if(strcmp(locParticleName, "AntiSigma-") == 0) + return AntiSigmaMinus; + else if(strcmp(locParticleName, "AntiSigma0") == 0) + return AntiSigma0; + else if(strcmp(locParticleName, "AntiSigma+") == 0) + return AntiSigmaPlus; + else if(strcmp(locParticleName, "AntiXi0") == 0) + return AntiXi0; + else if(strcmp(locParticleName, "AntiXi+") == 0) + return AntiXiPlus; + else if(strcmp(locParticleName, "AntiOmega+") == 0) + return AntiOmegaPlus; + else if(strcmp(locParticleName, "Geantino") == 0) + return Geantino; + else if(strcmp(locParticleName, "Rho0") == 0) + return Rho0; + else if(strcmp(locParticleName, "Rho+") == 0) + return RhoPlus; + else if(strcmp(locParticleName, "Rho-") == 0) + return RhoMinus; + else if(strcmp(locParticleName, "Omega") == 0) + return omega; + else if(strcmp(locParticleName, "EtaPrime") == 0) + return EtaPrime; + else if(strcmp(locParticleName, "Phi") == 0) + return phiMeson; + else if(strcmp(locParticleName, "a0(980)") == 0) + return a0_980; + else if(strcmp(locParticleName, "f0(980)") == 0) + return f0_980; + else if(strcmp(locParticleName, "K*(892)0") == 0) + return KStar_892_0; + else if(strcmp(locParticleName, "K*(892)+") == 0) + return KStar_892_Plus; + else if(strcmp(locParticleName, "K*(892)-") == 0) + return KStar_892_Minus; + else if(strcmp(locParticleName, "antiK*(892)0") == 0) + return AntiKStar_892_0; + else if(strcmp(locParticleName, "K1(1400)+") == 0) + return K1_1400_Plus; + else if(strcmp(locParticleName, "K1(1400)-") == 0) + return K1_1400_Minus; + else if(strcmp(locParticleName, "b1(1235)+") == 0) + return b1_1235_Plus; + else if(strcmp(locParticleName, "Sigma(1385)-") == 0) + return Sigma_1385_Minus; + else if(strcmp(locParticleName, "Sigma(1385)0") == 0) + return Sigma_1385_0; + else if(strcmp(locParticleName, "Sigma(1385)+") == 0) + return Sigma_1385_Plus; + else if(strcmp(locParticleName, "Deuteron") == 0) + return Deuteron; + else if(strcmp(locParticleName, "Triton") == 0) + return Triton; + else if(strcmp(locParticleName, "Helium") == 0) + return Helium; + else if(strcmp(locParticleName, "Helium-3") == 0) + return He3; + else if(strcmp(locParticleName, "Lithium-6") == 0) + return Li6; + else if(strcmp(locParticleName, "Lithium-7") == 0) + return Li7; + else if(strcmp(locParticleName, "Beryllium-7") == 0) + return Be7; + else if(strcmp(locParticleName, "Beryllium-9") == 0) + return Be9; + else if(strcmp(locParticleName, "Boron-10") == 0) + return B10; + else if(strcmp(locParticleName, "Boron-11") == 0) + return B11; + else if(strcmp(locParticleName, "Carbon") == 0) + return C12; + else if(strcmp(locParticleName, "Nitrogen") == 0) + return N14; + else if(strcmp(locParticleName, "Oxygen") == 0) + return O16; + else if(strcmp(locParticleName, "Fluorine") == 0) + return F19; + else if(strcmp(locParticleName, "Neon") == 0) + return Ne20; + else if(strcmp(locParticleName, "Sodium") == 0) + return Na23; + else if(strcmp(locParticleName, "Magnesium") == 0) + return Mg24; + else if(strcmp(locParticleName, "Aluminum") == 0) + return Al27; + else if(strcmp(locParticleName, "Silicon") == 0) + return Si28; + else if(strcmp(locParticleName, "Phosphorous") == 0) + return P31; + else if(strcmp(locParticleName, "Sulphur") == 0) + return S32; + else if(strcmp(locParticleName, "Chlorine") == 0) + return Cl35; + else if(strcmp(locParticleName, "Argon") == 0) + return Ar36; + else if(strcmp(locParticleName, "Potassium") == 0) + return K39; + else if(strcmp(locParticleName, "Calcium") == 0) + return Ca40; + else if(strcmp(locParticleName, "Scandium") == 0) + return Sc45; + else if(strcmp(locParticleName, "Titanium") == 0) + return Ti48; + else if(strcmp(locParticleName, "Vanadium") == 0) + return V51; + else if(strcmp(locParticleName, "Chromium") == 0) + return Cr52; + else if(strcmp(locParticleName, "Manganese") == 0) + return Mn55; + else if(strcmp(locParticleName, "Iron") == 0) + return Fe56; + else if(strcmp(locParticleName, "Cobalt") == 0) + return Co59; + else if(strcmp(locParticleName, "Nickel") == 0) + return Ni58; + else if(strcmp(locParticleName, "Copper") == 0) + return Cu63; + else if(strcmp(locParticleName, "Zinc") == 0) + return Zn64; + else if(strcmp(locParticleName, "Germanium") == 0) + return Ge74; + else if(strcmp(locParticleName, "Selenium") == 0) + return Se80; + else if(strcmp(locParticleName, "Krypton") == 0) + return Kr84; + else if(strcmp(locParticleName, "Strontium") == 0) + return Sr88; + else if(strcmp(locParticleName, "Zirconium") == 0) + return Zr90; + else if(strcmp(locParticleName, "Molybdenum") == 0) + return Mo98; + else if(strcmp(locParticleName, "Palladium") == 0) + return Pd106; + else if(strcmp(locParticleName, "Cadmium") == 0) + return Cd114; + else if(strcmp(locParticleName, "Tin") == 0) + return Sn120; + else if(strcmp(locParticleName, "Xenon") == 0) + return Xe132; + else if(strcmp(locParticleName, "Barium") == 0) + return Ba138; + else if(strcmp(locParticleName, "Cesium") == 0) + return Ce140; + else if(strcmp(locParticleName, "Samerium") == 0) + return Sm152; + else if(strcmp(locParticleName, "Dysprosium") == 0) + return Dy164; + else if(strcmp(locParticleName, "Ytterbium") == 0) + return Yb174; + else if(strcmp(locParticleName, "Tungsten") == 0) + return W184; + else if(strcmp(locParticleName, "Platium") == 0) + return Pt194; + else if(strcmp(locParticleName, "Gold") == 0) + return Au197; + else if(strcmp(locParticleName, "Mercury") == 0) + return Hg202; + else if(strcmp(locParticleName, "Lead") == 0) + return Pb208; + else if(strcmp(locParticleName, "Uranium") == 0) + return U238; + else if(strcmp(locParticleName, "Delta++") == 0) + return DeltaPlusPlus; + else if(strcmp(locParticleName, "Jpsi") == 0) + return Jpsi; + else if(strcmp(locParticleName, "EtaC") == 0) + return Eta_c; + else if(strcmp(locParticleName, "ChiC0") == 0) + return Chi_c0; + else if(strcmp(locParticleName, "ChiC1") == 0) + return Chi_c1; + else if(strcmp(locParticleName, "ChiC2") == 0) + return Chi_c2; + else if(strcmp(locParticleName, "Psi(2S)") == 0) + return Psi2s; + else if(strcmp(locParticleName, "D0") == 0) + return D0; + else if(strcmp(locParticleName, "AntiD0") == 0) + return AntiD0; + else if(strcmp(locParticleName, "D+") == 0) + return DPlus; + else if(strcmp(locParticleName, "D*0") == 0) + return Dstar0; + else if(strcmp(locParticleName, "D*+") == 0) + return DstarPlus; + else if(strcmp(locParticleName, "LambdaC") == 0) + return Lambda_c; + else + return Unknown; +} + +inline static unsigned short int IsFixedMass(Particle_t p) +{ + switch (p) + { + case Gamma: return 1; + case Positron: return 1; + case Electron: return 1; + case Neutrino: return 1; + case MuonPlus: return 1; + case MuonMinus: return 1; + case Pi0: return 1; + case PiPlus: return 1; + case PiMinus: return 1; + case KShort: return 1; + case KLong: return 1; + case KPlus: return 1; + case KMinus: return 1; + case Neutron: return 1; + case Proton: return 1; + case AntiProton: return 1; + case Eta: return 1; + case Lambda: return 1; + case SigmaPlus: return 1; + case Sigma0: return 1; + case SigmaMinus: return 1; + case Xi0: return 1; + case XiMinus: return 1; + case OmegaMinus: return 1; + case AntiNeutron: return 1; + case AntiLambda: return 1; + case AntiSigmaMinus: return 1; + case AntiSigma0: return 1; + case AntiSigmaPlus: return 1; + case AntiXi0: return 1; + case AntiXiPlus: return 1; + case AntiOmegaPlus: return 1; + case Geantino: return 1; + case EtaPrime: return 1; + case Deuteron: return 1; + case Triton: return 1; + case Helium: return 1; + case He3: return 1; + case Li6: return 1; + case Li7: return 1; + case Be7: return 1; + case Be9: return 1; + case B10: return 1; + case B11: return 1; + case C12: return 1; + case N14: return 1; + case O16: return 1; + case F19: return 1; + case Ne20: return 1; + case Na23: return 1; + case Mg24: return 1; + case Al27: return 1; + case Si28: return 1; + case P31: return 1; + case S32: return 1; + case Cl35: return 1; + case Ar36: return 1; + case K39: return 1; + case Ca40: return 1; + case Sc45: return 1; + case Ti48: return 1; + case V51: return 1; + case Cr52: return 1; + case Mn55: return 1; + case Fe56: return 1; + case Co59: return 1; + case Ni58: return 1; + case Cu63: return 1; + case Zn64: return 1; + case Ge74: return 1; + case Se80: return 1; + case Kr84: return 1; + case Sr88: return 1; + case Zr90: return 1; + case Mo98: return 1; + case Pd106: return 1; + case Cd114: return 1; + case Sn120: return 1; + case Xe132: return 1; + case Ba138: return 1; + case Ce140: return 1; + case Sm152: return 1; + case Dy164: return 1; + case Yb174: return 1; + case W184: return 1; + case Pt194: return 1; + case Au197: return 1; + case Hg202: return 1; + case Pb208: return 1; + case U238: return 1; + case Jpsi: return 1; + //case eta_c: return 1; + //case chi_c0: return 1; + case Chi_c1: return 1; + case Chi_c2: return 1; + case Psi2s: return 1; + case D0: return 1; + case AntiD0: return 1; + case DPlus: return 1; + case Dstar0: return 1; + case DstarPlus: return 1; + case Lambda_c: return 1; + default: return 0; + } +} + +inline static unsigned short int IsResonance(Particle_t p) +{ + p = RemapParticleID(p); + + if(IsFixedMass(p) == 1) + return 0; + if(p == Unknown) + return 0; + if(p == phiMeson) + return 0; + if(p == omega) + return 0; + return 1; +} + +inline static unsigned short int IsDetachedVertex(Particle_t p) +{ + switch (p) + { + case MuonPlus: return 1; + case MuonMinus: return 1; + case PiPlus: return 1; + case PiMinus: return 1; + case KShort: return 1; + case KLong: return 1; + case KPlus: return 1; + case KMinus: return 1; + case Neutron: return 1; + case Lambda: return 1; + case SigmaPlus: return 1; + case SigmaMinus: return 1; + case Xi0: return 1; + case XiMinus: return 1; + case OmegaMinus: return 1; + case AntiNeutron: return 1; + case AntiLambda: return 1; + case AntiSigmaMinus: return 1; + case AntiSigmaPlus: return 1; + case AntiXi0: return 1; + case AntiXiPlus: return 1; + case AntiOmegaPlus: return 1; + case Deuteron: return 1; + case Triton: return 1; + case Helium: return 1; + case He3: return 1; + default: return 0; + } +} + +inline static char* ParticleName_ROOT(Particle_t p) +{ + p = RemapParticleID(p); + + switch (p) { + case Unknown: + return (char*)"X"; + case Gamma: + return (char*)"#gamma"; + case Positron: + return (char*)"e^{#plus}"; + case Electron: + return (char*)"e^{#minus}"; + case Neutrino: + return (char*)"#nu"; + case MuonPlus: + return (char*)"#mu^{#plus}"; + case MuonMinus: + return (char*)"#mu^{#minus}"; + case Pi0: + return (char*)"#pi^{0}"; + case PiPlus: + return (char*)"#pi^{#plus}"; + case PiMinus: + return (char*)"#pi^{#minus}"; + case KLong: + return (char*)"K^{0}_{L}"; + case KPlus: + return (char*)"K^{#plus}"; + case KMinus: + return (char*)"K^{#minus}"; + case Neutron: + return (char*)"n"; + case Proton: + return (char*)"p"; + case AntiProton: + return (char*)"#bar{p}"; + case KShort: + return (char*)"K^{0}_{S}"; + case Eta: + return (char*)"#eta"; + case Lambda: + return (char*)"#Lambda"; + case SigmaPlus: + return (char*)"#Sigma^{#plus}"; + case Sigma0: + return (char*)"#Sigma^{0}"; + case SigmaMinus: + return (char*)"#Sigma^{#minus}"; + case Xi0: + return (char*)"#Xi^{0}"; + case XiMinus: + return (char*)"#Xi^{#minus}"; + case OmegaMinus: + return (char*)"#Omega^{#minus}"; + case AntiNeutron: + return (char*)"#bar^{n}"; + case AntiLambda: + return (char*)"#bar^{#Lambda}"; + case AntiSigmaMinus: + return (char*)"#bar{#Sigma}^{#minus}"; + case AntiSigma0: + return (char*)"#bar{#Sigma}^{0}"; + case AntiSigmaPlus: + return (char*)"#bar{#Sigma}^{#plus}"; + case AntiXi0: + return (char*)"#bar{#Xi}^{0}"; + case AntiXiPlus: + return (char*)"#bar{#Xi}^{#plus}"; + case AntiOmegaPlus: + return (char*)"#bar{#Omega}^{#plus}"; + case Geantino: + return (char*)"geantino"; + case Rho0: + return (char*)"#rho^{0}"; + case RhoPlus: + return (char*)"#rho^{#plus}"; + case RhoMinus: + return (char*)"#rho^{#minus}"; + case omega: + return (char*)"#omega"; + case EtaPrime: + return (char*)"#eta'"; + case phiMeson: + return (char*)"#phi"; + case a0_980: + return (char*)"a_{0}(980)"; + case f0_980: + return (char*)"f_{0}(980)"; + case KStar_892_0: + return (char*)"K*(892)^{0}"; + case KStar_892_Plus: + return (char*)"K*(892)^{#plus}"; + case KStar_892_Minus: + return (char*)"K*(892)^{#minus}"; + case AntiKStar_892_0: + return (char*)"#bar{K*}(892)^{0}"; + case K1_1400_Plus: + return (char*)"K_{1}(1400)^{#plus}"; + case K1_1400_Minus: + return (char*)"K_{1}(1400)^{#minus}"; + case b1_1235_Plus: + return (char*)"b_{1}(1235)^{#plus}"; + case Deuteron: + return (char*)"d"; + case Triton: + return (char*)"t"; + case Helium: + return (char*)"He"; + case He3: + return (char*)"^{3}He"; + case Li6: + return (char*)"^{6}Li"; + case Li7: + return (char*)"^{7}Li"; + case Be7: + return (char*)"^{7}Be"; + case Be9: + return (char*)"^{9}Be"; + case B10: + return (char*)"^{10}B"; + case B11: + return (char*)"^{11}B"; + case C12: + return (char*)"^{12}C"; + case N14: + return (char*)"^{14}N"; + case O16: + return (char*)"^{16}O"; + case F19: + return (char*)"^{19}F"; + case Ne20: + return (char*)"^{20}Ne"; + case Na23: + return (char*)"^{23}Na"; + case Mg24: + return (char*)"^{24}Mg"; + case Al27: + return (char*)"^{27}Al"; + case Si28: + return (char*)"^{28}Si"; + case P31: + return (char*)"^{31}P"; + case S32: + return (char*)"^{32}S"; + case Cl35: + return (char*)"^{35}Cl"; + case Ar36: + return (char*)"^{36}Ar"; + case K39: + return (char*)"^{39}K"; + case Ca40: + return (char*)"^{40}Ca"; + case Sc45: + return (char*)"^{45}Sc"; + case Ti48: + return (char*)"^{48}Ti"; + case V51: + return (char*)"^{51}V"; + case Cr52: + return (char*)"^{52}Cr"; + case Mn55: + return (char*)"^{55}Mn"; + case Fe56: + return (char*)"^{56}Fe"; + case Co59: + return (char*)"^{59}Co"; + case Ni58: + return (char*)"^{58}Ni"; + case Cu63: + return (char*)"^{63}Cu"; + case Zn64: + return (char*)"^{64}Zn"; + case Ge74: + return (char*)"^{74}Ge"; + case Se80: + return (char*)"^{80}Se"; + case Kr84: + return (char*)"^{84}Kr"; + case Sr88: + return (char*)"^{88}Sr"; + case Zr90: + return (char*)"^{90}Zr"; + case Mo98: + return (char*)"^{98}Mo"; + case Pd106: + return (char*)"^{106}Pd"; + case Cd114: + return (char*)"^{114}Cd"; + case Sn120: + return (char*)"^{120}Sn"; + case Xe132: + return (char*)"^{132}Xe"; + case Ba138: + return (char*)"^{138}Ba"; + case Ce140: + return (char*)"^{140}Ce"; + case Sm152: + return (char*)"^{152}Sm"; + case Dy164: + return (char*)"^{164}Dy"; + case Yb174: + return (char*)"^{174}Yb"; + case W184: + return (char*)"^{184}W"; + case Pt194: + return (char*)"^{194}Pt"; + case Au197: + return (char*)"^{197}Au"; + case Hg202: + return (char*)"^{202}Hg"; + case Pb208: + return (char*)"^{208}Pb"; + case U238: + return (char*)"^{238}U"; + case Sigma_1385_Minus: + return (char*)"#Sigma(1385)^{#minus}"; + case Sigma_1385_0: + return (char*)"#Sigma(1385)^{0}"; + case Sigma_1385_Plus: + return (char*)"#Sigma(1385)^{#plus}"; + case DeltaPlusPlus: + return (char*)"#Delta(1232)^{#plus#plus}"; + case Jpsi: + return (char*)"J/#psi"; + case Eta_c: + return (char*)"#eta_{c}"; + case Chi_c0: + return (char*)"#chi_{c0}"; + case Chi_c1: + return (char*)"#chi_{c1}"; + case Chi_c2: + return (char*)"#chi_{c2}"; + case Psi2s: + return (char*)"#psi(2S)"; + case D0: + return (char*)"D^{0}"; + case AntiD0: + return (char*)"#bar{D^{0}}"; + case DPlus: + return (char*)"D{^+}"; + case Dstar0: + return (char*)"D^{*0}"; + case DstarPlus: + return (char*)"D^{*+}"; + case Lambda_c: + return (char*)"#Lambda_{c}"; + + default: + return (char*)"X"; + } +} + +inline static double ParticleMass(Particle_t p) +{ + p = RemapParticleID(p); + + switch (p) { + case Unknown: return HUGE_VAL; + case Gamma: return 0; + case Positron: return 0.000510998928; + case Electron: return 0.000510998928; + case Neutrino: return 0; + case MuonPlus: return 0.1056583715; + case MuonMinus: return 0.1056583715; + case Pi0: return 0.1349766; + case PiPlus: return 0.13957018; + case PiMinus: return 0.13957018; + case KShort: return 0.497614; + case KLong: return 0.497614; + case KPlus: return 0.493677; + case KMinus: return 0.493677; + case Neutron: return 0.939565379; + case Proton: return 0.938272046; + case AntiProton: return 0.938272046; + case Eta: return 0.547862; + case Lambda: return 1.115683; + case SigmaPlus: return 1.18937; + case Sigma0: return 1.192642; + case SigmaMinus: return 1.197449; + case Xi0: return 1.31486; + case XiMinus: return 1.32171; + case OmegaMinus: return 1.67245; + case AntiNeutron: return 0.939565379; + case AntiLambda: return 1.115683; + case AntiSigmaMinus: return 1.18937; + case AntiSigma0: return 1.192642; + case AntiSigmaPlus: return 1.197449; + case AntiXi0: return 1.31486; + case AntiXiPlus: return 1.32171; + case AntiOmegaPlus: return 1.67245; + case Geantino: return 0.0; + case Rho0: return 0.7690; // neutral only, photoproduced and other reactions. e+ e- gives 775.26 + case RhoPlus: return 0.7665; // charged only, hadroproduced. tau decays and e+ e- gives 775.11 + case RhoMinus: return 0.7665; + case omega: return 0.78265; + case EtaPrime: return 0.95778; + case phiMeson: return 1.019455; + case a0_980: return 0.980; + case f0_980: return 0.990; + case KStar_892_0: return 0.89581; // neutral only + case KStar_892_Plus: return 0.89166; // charged only, hadroproduced + case KStar_892_Minus: return 0.89166; // charged only, hadroproduced + case AntiKStar_892_0: return 0.89581; // neutral only + case K1_1400_Plus: return 1.403; + case K1_1400_Minus: return 1.403; + case b1_1235_Plus: return 1.2295; + case Deuteron: return 1.875612859; // from NIST + case Triton: return 2.808921004; // from NIST 5.00735630 x 10^-27 kg + case Helium: return 3.727379238; // from NIST 6.64465675 x 10-27 kg + case He3: return 2.809413498; + case Li6: return 5.60305; + case Li7: return 6.53536; + case Be7: return 6.53622; + case Be9: return 8.39479; + case B10: return 9.32699; + case B11: return 10.25510; + case C12: return 11.17793; + case N14: return 13.04378; + case O16: return 14.89917; + case F19: return 17.69690; + case Ne20: return 18.62284; + case Na23: return 21.41483; + case Mg24: return 22.34193; + case Al27: return 25.13314; + case Si28: return 26.06034; + case P31: return 28.85188; + case S32: return 29.78180; + case Cl35: return 32.57328; + case Ar36: return 33.50356; + case K39: return 36.29447; + case Ca40: return 37.22492; + case Sc45: return 41.87617; + case Ti48: return 44.66324; + case V51: return 47.45401; + case Cr52: return 48.38228; + case Mn55: return 51.17447; + case Fe56: return 52.10307; + case Co59: return 54.89593; + case Ni58: return 53.96644; + case Cu63: return 58.61856; + case Zn64: return 59.54963; + case Ge74: return 68.85715; + case Se80: return 74.44178; + case Kr84: return 78.16309; + case Sr88: return 81.88358; + case Zr90: return 83.74571; + case Mo98: return 91.19832; + case Pd106: return 98.64997; + case Cd114: return 106.10997; + case Sn120: return 111.68821; + case Xe132: return 122.86796; + case Ba138: return 128.45793; + case Ce140: return 130.32111; + case Sm152: return 141.51236; + case Dy164: return 152.69909; + case Yb174: return 162.02245; + case W184: return 171.34924; + case Pt194: return 180.67513; + case Au197: return 183.47324; + case Hg202: return 188.13451; + case Pb208: return 193.72899; // NIST gives 207.976627 AMU + case U238: return 221.74295; + case Sigma_1385_Minus: return 1.3872; + case Sigma_1385_0: return 1.3837; + case Sigma_1385_Plus: return 1.38280; + case DeltaPlusPlus: return 1.232; + case Jpsi: return 3.069916; + case Eta_c: return 2.9836; + case Chi_c0: return 3.41475; + case Chi_c1: return 3.51066; + case Chi_c2: return 3.55620; + case Psi2s: return 3.686109; + case D0: return 1.86484; + case AntiD0: return 1.86484; + case DPlus: return 1.86961; + case Dstar0: return 2.01026; + case DstarPlus: return 2.00696; + case Lambda_c: return 2.28646; + default: + fprintf(stderr,"ParticleMass: Error: Unknown particle type %d,",p); + fprintf(stderr," returning HUGE_VAL...\n"); + return HUGE_VAL; + } +} + +inline static int ParticleCharge(Particle_t p) +{ + p = RemapParticleID(p); + + switch (p) { + case Unknown: return 0; + case Gamma: return 0; + case Positron: return +1; + case Electron: return -1; + case Neutrino: return 0; + case MuonPlus: return +1; + case MuonMinus: return -1; + case Pi0: return 0; + case PiPlus: return +1; + case PiMinus: return -1; + case KShort: return 0; + case KLong: return 0; + case KPlus: return +1; + case KMinus: return -1; + case Neutron: return 0; + case Proton: return +1; + case AntiProton: return -1; + case Eta: return 0; + case Lambda: return 0; + case SigmaPlus: return +1; + case Sigma0: return 0; + case SigmaMinus: return -1; + case Xi0: return 0; + case XiMinus: return -1; + case OmegaMinus: return -1; + case AntiNeutron: return 0; + case AntiLambda: return 0; + case AntiSigmaMinus: return -1; + case AntiSigma0: return 0; + case AntiSigmaPlus: return +1; + case AntiXi0: return 0; + case AntiXiPlus: return +1; + case AntiOmegaPlus: return +1; + case Geantino: return 0; + case Rho0: return 0; + case RhoPlus: return +1; + case RhoMinus: return -1; + case omega: return 0; + case EtaPrime: return 0; + case phiMeson: return 0; + case a0_980: return 0; + case f0_980: return 0; + case KStar_892_0: return 0; + case KStar_892_Plus: return 1; + case KStar_892_Minus: return -1; + case AntiKStar_892_0: return 0; + case K1_1400_Plus: return 1; + case K1_1400_Minus: return -1; + case b1_1235_Plus: return 1; + case Deuteron: return 1; + case Triton: return 1; + case Helium: return 2; + case He3: return 2; + case Li6: return 3; + case Li7: return 3; + case Be7: return 4; + case Be9: return 4; + case B10: return 5; + case B11: return 5; + case C12: return 6; + case N14: return 7; + case O16: return 8; + case F19: return 9; + case Ne20: return 10; + case Na23: return 11; + case Mg24: return 12; + case Al27: return 13; + case Si28: return 14; + case P31: return 15; + case S32: return 16; + case Cl35: return 17; + case Ar36: return 18; + case K39: return 19; + case Ca40: return 20; + case Sc45: return 21; + case Ti48: return 22; + case V51: return 23; + case Cr52: return 24; + case Mn55: return 25; + case Fe56: return 26; + case Co59: return 27; + case Ni58: return 28; + case Cu63: return 29; + case Zn64: return 30; + case Ge74: return 32; + case Se80: return 34; + case Kr84: return 36; + case Sr88: return 38; + case Zr90: return 40; + case Mo98: return 42; + case Pd106: return 46; + case Cd114: return 48; + case Sn120: return 50; + case Xe132: return 54; + case Ba138: return 56; + case Ce140: return 58; + case Sm152: return 62; + case Dy164: return 66; + case Yb174: return 70; + case W184: return 74; + case Pt194: return 78; + case Au197: return 79; + case Hg202: return 80; + case Pb208: return 82; + case U238: return 92; + case Sigma_1385_Minus: return -1; + case Sigma_1385_0: return 0; + case Sigma_1385_Plus: return 1; + case DeltaPlusPlus: return 2; + case Jpsi: return 0; + case Eta_c: return 0; + case Chi_c0: return 0; + case Chi_c1: return 0; + case Chi_c2: return 0; + case Psi2s: return 0; + case D0: return 0; + case AntiD0: return 0; + case DPlus: return 1; + case Dstar0: return 0; + case DstarPlus: return 1; + case Lambda_c: return 1; + + default: + fprintf(stderr,"ParticleCharge: Error: Unknown particle type %d,",p); + fprintf(stderr," returning 0...\n"); + return 0; + } +} + +inline static int PDGtype(Particle_t p) +{ + p = RemapParticleID(p); + + switch (p) { + case Unknown: return 0; + case Gamma: return 22; + case Positron: return -11; + case Electron: return 11; + case Neutrino: return 121416; + case MuonPlus: return -13; + case MuonMinus: return 13; + case Pi0: return 111; + case PiPlus: return 211; + case PiMinus: return -211; + case KShort: return 310; + case KLong: return 130; + case KPlus: return 321; + case KMinus: return -321; + case Neutron: return 2112; + case Proton: return 2212; + case AntiProton: return -2212; + case Eta: return 221; + case Lambda: return 3122; + case SigmaPlus: return 3222; + case Sigma0: return 3212; + case SigmaMinus: return 3112; + case Xi0: return 3322; + case XiMinus: return 3312; + case OmegaMinus: return 3334; + case AntiNeutron: return -2112; + case AntiLambda: return -3122; + case AntiSigmaMinus: return -3112; + case AntiSigma0: return -3212; + case AntiSigmaPlus: return -3222; + case AntiXi0: return -3322; + case AntiXiPlus: return -3312; + case AntiOmegaPlus: return -3334; + case Geantino: return 0; + case Rho0: return 113; + case RhoPlus: return 213; + case RhoMinus: return -213; + case omega: return 223; + case EtaPrime: return 331; + case phiMeson: return 333; + case a0_980: return 9000110; + case f0_980: return 9010221; + case KStar_892_0: return 313; + case AntiKStar_892_0: return -313; + case KStar_892_Plus: return 323; + case KStar_892_Minus: return -323; + case K1_1400_Plus: return 20323; + case K1_1400_Minus: return -20323; + case b1_1235_Plus: return 10213; + case Deuteron: return 45; + case Triton: return 46; + case Helium: return 47; + case He3: return 49; + case Sigma_1385_Minus: return 3114; + case Sigma_1385_0: return 3214; + case Sigma_1385_Plus: return 3224; + case Li6: return 1000030060; + case Li7: return 1000030070; + case Be7: return 1000040070; + case Be9: return 1000040090; + case B10: return 1000050100; + case B11: return 1000050110; + case C12: return 1000060120; + case N14: return 1000070140; + case O16: return 1000080160; + case F19: return 1000090190; + case Ne20: return 1000100200; + case Na23: return 1000110230; + case Mg24: return 1000120240; + case Al27: return 1000130270; + case Si28: return 1000140280; + case P31: return 1000150310; + case S32: return 1000160320; + case Cl35: return 1000170350; + case Ar36: return 1000180360; + case K39: return 1000190390; + case Ca40: return 1000200400; + case Sc45: return 1000210450; + case Ti48: return 1000220480; + case V51: return 1000230510; + case Cr52: return 1000240520; + case Mn55: return 1000250550; + case Fe56: return 1000260560; + case Co59: return 1000270590; + case Ni58: return 1000280580; + case Cu63: return 1000290630; + case Zn64: return 1000300640; + case Ge74: return 1000320740; + case Se80: return 1000340800; + case Kr84: return 1000360840; + case Sr88: return 1000380880; + case Zr90: return 1000400900; + case Mo98: return 1000420980; + case Pd106: return 1000461060; + case Cd114: return 1000481140; + case Sn120: return 1000501200; + case Xe132: return 1000541320; + case Ba138: return 1000561380; + case Ce140: return 1000581400; + case Sm152: return 1000621520; + case Dy164: return 1000661640; + case Yb174: return 1000701740; + case W184: return 1000741840; + case Pt194: return 1000781940; + case Au197: return 1000791970; + case Hg202: return 1000802020; + case Pb208: return 1000822080; + case U238: return 1000922380; + case DeltaPlusPlus: return 2224; + case Jpsi: return 443; + case Eta_c: return 441; + case Chi_c0: return 10441; + case Chi_c1: return 20443; + case Chi_c2: return 445; + case Psi2s: return 100443; + case D0: return 421; + case AntiD0: return -421; //FIX!! + case DPlus: return 411; + case Dstar0: return 423; + case DstarPlus: return 413; + case Lambda_c: return 4122; + default: return 0; + } +} + +inline static Particle_t PDGtoPType(int locPDG_PID) +{ + switch (locPDG_PID) { + case 0: return Unknown; + case 22: return Gamma; + case -11: return Positron; + case 11: return Electron; + case 121416: return Neutrino; + case -13: return MuonPlus; + case 13: return MuonMinus; + case 111: return Pi0; + case 211: return PiPlus; + case -211: return PiMinus; + case 310: return KShort; + case 130: return KLong; + case 321: return KPlus; + case -321: return KMinus; + case 2112: return Neutron; + case 2212: return Proton; + case -2212: return AntiProton; + case 221: return Eta; + case 3122: return Lambda; + case 3222: return SigmaPlus; + case 3212: return Sigma0; + case 3112: return SigmaMinus; + case 3322: return Xi0; + case 3312: return XiMinus; + case 3334: return OmegaMinus; + case -2112: return AntiNeutron; + case -3122: return AntiLambda; + case -3112: return AntiSigmaMinus; + case -3212: return AntiSigma0; + case -3222: return AntiSigmaPlus; + case -3322: return AntiXi0; + case -3312: return AntiXiPlus; + case -3334: return AntiOmegaPlus; + case 113: return Rho0; + case 213: return RhoPlus; + case -213: return RhoMinus; + case 223: return omega; + case 331: return EtaPrime; + case 333: return phiMeson; + case 9000110: return a0_980; + case 9010221: return f0_980; + case 313: return KStar_892_0; + case -313: return AntiKStar_892_0; + case 323: return KStar_892_Plus; + case -323: return KStar_892_Minus; + case 20323: return K1_1400_Plus; + case -20323: return K1_1400_Minus; + case 10213: return b1_1235_Plus; + case 45: return Deuteron; + case 46: return Triton; + case 47: return Helium; + case 49: return He3; + case 3114: return Sigma_1385_Minus; + case 3214: return Sigma_1385_0; + case 3224: return Sigma_1385_Plus; + case 1000030060: return Li6; + case 1000030070: return Li7; + case 1000040070: return Be7; + case 1000040090: return Be9; + case 1000050100: return B10; + case 1000050110: return B11; + case 1000060120: return C12; + case 1000070140: return N14; + case 1000080160: return O16; + case 1000090190: return F19; + case 1000100200: return Ne20; + case 1000110230: return Na23; + case 1000120240: return Mg24; + case 1000130270: return Al27; + case 1000140280: return Si28; + case 1000150310: return P31; + case 1000160320: return S32; + case 1000170350: return Cl35; + case 1000180360: return Ar36; + case 1000190390: return K39; + case 1000200400: return Ca40; + case 1000210450: return Sc45; + case 1000220480: return Ti48; + case 1000230510: return V51; + case 1000240520: return Cr52; + case 1000250550: return Mn55; + case 1000260560: return Fe56; + case 1000270590: return Co59; + case 1000280580: return Ni58; + case 1000290630: return Cu63; + case 1000300640: return Zn64; + case 1000320740: return Ge74; + case 1000340800: return Se80; + case 1000360840: return Kr84; + case 1000380880: return Sr88; + case 1000400900: return Zr90; + case 1000420980: return Mo98; + case 1000461060: return Pd106; + case 1000481140: return Cd114; + case 1000501200: return Sn120; + case 1000541320: return Xe132; + case 1000561380: return Ba138; + case 1000581400: return Ce140; + case 1000621520: return Sm152; + case 1000661640: return Dy164; + case 1000701740: return Yb174; + case 1000741840: return W184; + case 1000781940: return Pt194; + case 1000791970: return Au197; + case 1000802020: return Hg202; + case 1000822080: return Pb208; + case 1000922380: return U238; + case 2224: return DeltaPlusPlus; + case 443: return Jpsi; + case 441: return Eta_c; + case 10441: return Chi_c0; + case 20443: return Chi_c1; + case 445: return Chi_c2; + case 100443: return Psi2s; + case 421: return D0; + case -421: return AntiD0; + case 411: return DPlus; + case 423: return Dstar0; + case 413: return DstarPlus; + case 4122: return Lambda_c; + default: return Unknown; + } +} + +inline static int Is_FinalStateParticle(Particle_t locPID) +{ + switch(locPID) + { + case Gamma: return 1; + case Positron: return 1; + case Electron: return 1; + case Neutrino: return 1; + case MuonPlus: return 1; + case MuonMinus: return 1; + case PiPlus: return 1; + case PiMinus: return 1; + case KLong: return 1; + case KPlus: return 1; + case KMinus: return 1; + case Neutron: return 1; + case Proton: return 1; + case AntiProton: return 1; + case AntiNeutron: return 1; + case Deuteron: return 1; + case Triton: return 1; + case Helium: return 1; + case He3: return 1; + case Li6: return 1; + case Li7: return 1; + case Be7: return 1; + case Be9: return 1; + case B10: return 1; + case B11: return 1; + case C12: return 1; + case N14: return 1; + case O16: return 1; + case F19: return 1; + case Ne20: return 1; + case Na23: return 1; + case Mg24: return 1; + case Al27: return 1; + case Si28: return 1; + case P31: return 1; + case S32: return 1; + case Cl35: return 1; + case Ar36: return 1; + case K39: return 1; + case Ca40: return 1; + case Sc45: return 1; + case Ti48: return 1; + case V51: return 1; + case Cr52: return 1; + case Mn55: return 1; + case Fe56: return 1; + case Co59: return 1; + case Ni58: return 1; + case Cu63: return 1; + case Zn64: return 1; + case Ge74: return 1; + case Se80: return 1; + case Kr84: return 1; + case Sr88: return 1; + case Zr90: return 1; + case Mo98: return 1; + case Pd106: return 1; + case Cd114: return 1; + case Sn120: return 1; + case Xe132: return 1; + case Ba138: return 1; + case Ce140: return 1; + case Sm152: return 1; + case Dy164: return 1; + case Yb174: return 1; + case W184: return 1; + case Pt194: return 1; + case Au197: return 1; + case Hg202: return 1; + case Pb208: return 1; + case U238: return 1; + default: return 0; //decaying + } +} + +inline static char* Get_ShortName(Particle_t locPID) +{ + switch (locPID) { + case Gamma: + return (char*)"g"; + case Positron: + return (char*)"ep"; + case Electron: + return (char*)"em"; + case Neutrino: + return (char*)"neut"; + case MuonPlus: + return (char*)"mup"; + case MuonMinus: + return (char*)"mum"; + case Pi0: + return (char*)"pi0"; + case PiPlus: + return (char*)"pip"; + case PiMinus: + return (char*)"pim"; + case KLong: + return (char*)"kl"; + case KPlus: + return (char*)"kp"; + case KMinus: + return (char*)"km"; + case Neutron: + return (char*)"n"; + case Proton: + return (char*)"p"; + case AntiProton: + return (char*)"pbar"; + case KShort: + return (char*)"ks"; + case Eta: + return (char*)"eta"; + + case Lambda: + return (char*)"lamb"; + case SigmaPlus: + return (char*)"sigp"; + case Sigma0: + return (char*)"sig0"; + case SigmaMinus: + return (char*)"sigm"; + case Xi0: + return (char*)"xi0"; + case XiMinus: + return (char*)"xim"; + case OmegaMinus: + return (char*)"omgm"; + + case AntiNeutron: + return (char*)"nbar"; + case AntiLambda: + return (char*)"lbar"; + case AntiSigmaMinus: + return (char*)"sigmbar"; + case AntiSigma0: + return (char*)"sig0bar"; + case AntiSigmaPlus: + return (char*)"sigpbar"; + case AntiXi0: + return (char*)"xi0bar"; + case AntiXiPlus: + return (char*)"xipbar"; + case AntiOmegaPlus: + return (char*)"omgpbar"; + + case omega: + return (char*)"omg"; + case EtaPrime: + return (char*)"etap"; + case phiMeson: + return (char*)"phi"; + + case Deuteron: + return (char*)"d"; + case Triton: + return (char*)"tri"; + case Helium: + return (char*)"he"; + case He3: + return (char*)"he3"; + case Li6: + return (char*)"li6"; + case Li7: + return (char*)"li7"; + case Be7: + return (char*)"be7"; + case Be9: + return (char*)"be9"; + case B10: + return (char*)"b10"; + case B11: + return (char*)"b11"; + case C12: + return (char*)"c12"; + case N14: + return (char*)"n14"; + case O16: + return (char*)"o16"; + case F19: + return (char*)"f19"; + case Ne20: + return (char*)"ne20"; + case Na23: + return (char*)"na23"; + case Mg24: + return (char*)"mg24"; + case Al27: + return (char*)"al27"; + case Si28: + return (char*)"si28"; + case P31: + return (char*)"p31"; + case S32: + return (char*)"s32"; + case Cl35: + return (char*)"cl35"; + case Ar36: + return (char*)"ar36"; + case K39: + return (char*)"k39"; + case Ca40: + return (char*)"ca40"; + case Sc45: + return (char*)"sc45"; + case Ti48: + return (char*)"ti48"; + case V51: + return (char*)"v51"; + case Cr52: + return (char*)"cr52"; + case Mn55: + return (char*)"mn55"; + case Fe56: + return (char*)"fe56"; + case Co59: + return (char*)"co59"; + case Ni58: + return (char*)"ni58"; + case Cu63: + return (char*)"cu63"; + case Zn64: + return (char*)"zn64"; + case Ge74: + return (char*)"ge74"; + case Se80: + return (char*)"se80"; + case Kr84: + return (char*)"kr84"; + case Sr88: + return (char*)"sr88"; + case Zr90: + return (char*)"zr90"; + case Mo98: + return (char*)"mo98"; + case Pd106: + return (char*)"pd106"; + case Cd114: + return (char*)"cd114"; + case Sn120: + return (char*)"sn120"; + case Xe132: + return (char*)"xe132"; + case Ba138: + return (char*)"ba138"; + case Ce140: + return (char*)"ce140"; + case Sm152: + return (char*)"sm152"; + case Dy164: + return (char*)"dy164"; + case Yb174: + return (char*)"yb174"; + case W184: + return (char*)"w184"; + case Pt194: + return (char*)"pt194"; + case Au197: + return (char*)"au197"; + case Hg202: + return (char*)"hg202"; + case Pb208: + return (char*)"pb208"; + case U238: + return (char*)"u238"; + case Jpsi: + return (char*)"jpsi"; + case Eta_c: + return (char*)"etac"; + case Chi_c0: + return (char*)"chic0"; + case Chi_c1: + return (char*)"chic1"; + case Chi_c2: + return (char*)"chic2"; + case Psi2s: + return (char*)"psi2S"; + case D0: + return (char*)"d0"; + case AntiD0: + return (char*)"d0bar"; + case DPlus: + return (char*)"dp"; + case Lambda_c: + return (char*)"lambc"; + + default: + return (char*)"Unknown"; + } +} + +inline static int ParticleMultiplexPower(Particle_t locPID) +{ + locPID = RemapParticleID(locPID); + + switch(locPID) + { + //FINAL-STATE PARTICLES (+ pi0) (decimal: 10^power): + case Gamma: return 0; + case Positron: return 1; + case Electron: return 2; + case Neutrino: return 3; + case MuonPlus: return 4; + case MuonMinus: return 5; + case Pi0: return 6; + case PiPlus: return 7; + case PiMinus: return 8; + case KLong: return 9; + case KPlus: return 10; + case KMinus: return 11; + case Neutron: return 12; + case Proton: return 13; + case AntiProton: return 14; + case AntiNeutron: return 15; + + //DECAYING PARTICLES (- pi0): (binary: 2^power) + case KShort: return 0; + case Eta: return 1; + case Lambda: return 2; + case SigmaPlus: return 3; + case Sigma0: return 4; + case SigmaMinus: return 5; + case Xi0: return 6; + case XiMinus: return 7; + case OmegaMinus: return 8; + case AntiLambda: return 9; + case AntiSigmaMinus: return 10; + case AntiSigma0: return 11; + case AntiSigmaPlus: return 12; + case AntiXi0: return 13; + case AntiXiPlus: return 14; + case AntiOmegaPlus: return 15; + case Deuteron: return 16; + case Rho0: return 17; + case RhoPlus: return 18; + case RhoMinus: return 19; + case omega: return 20; + case EtaPrime: return 21; + case phiMeson: return 22; + case a0_980: return 23; + case f0_980: return 24; + case KStar_892_0: return 25; + case KStar_892_Plus: return 26; + case KStar_892_Minus: return 27; + case AntiKStar_892_0: return 28; + case K1_1400_Plus: return 29; + case K1_1400_Minus: return 30; + case b1_1235_Plus: return 31; + case Sigma_1385_Minus: return 32; + case Sigma_1385_0: return 33; + case Sigma_1385_Plus: return 34; + case DeltaPlusPlus: return 35; + case Jpsi: return 36; + case Eta_c: return 37; + case Chi_c0: return 38; + case Chi_c1: return 39; + case Chi_c2: return 40; + case Psi2s: return 41; + case D0: return 42; + case DPlus: return 43; + case Dstar0: return 44; + case DstarPlus: return 45; + case Lambda_c: return 46; + case AntiD0: return 47; + default: return -1; + } +} + +inline static Particle_t DemultiplexPID(int locBit, int locIsDecayingFlag) +{ + //FINAL-STATE PARTICLES (+ pi0) (decimal: 10^power): + if(locIsDecayingFlag == 0) + { + switch(locBit) + { + case 0: return Gamma; + case 1: return Positron; + case 2: return Electron; + case 3: return Neutrino; + case 4: return MuonPlus; + case 5: return MuonMinus; + case 6: return Pi0; + case 7: return PiPlus; + case 8: return PiMinus; + case 9: return KLong; + case 10: return KPlus; + case 11: return KMinus; + case 12: return Neutron; + case 13: return Proton; + case 14: return AntiProton; + case 15: return AntiNeutron; + default: return Unknown; + } + } + + //DECAYING PARTICLES (- pi0): (binary: 2^power) + switch(locBit) + { + case 0: return KShort; + case 1: return Eta; + case 2: return Lambda; + case 3: return SigmaPlus; + case 4: return Sigma0; + case 5: return SigmaMinus; + case 6: return Xi0; + case 7: return XiMinus; + case 8: return OmegaMinus; + case 9: return AntiLambda; + case 10: return AntiSigmaMinus; + case 11: return AntiSigma0; + case 12: return AntiSigmaPlus; + case 13: return AntiXi0; + case 14: return AntiXiPlus; + case 15: return AntiOmegaPlus; + case 16: return Deuteron; + case 17: return Rho0; + case 18: return RhoPlus; + case 19: return RhoMinus; + case 20: return omega; + case 21: return EtaPrime; + case 22: return phiMeson; + case 23: return a0_980; + case 24: return f0_980; + case 25: return KStar_892_0; + case 26: return KStar_892_Plus; + case 27: return KStar_892_Minus; + case 28: return AntiKStar_892_0; + case 29: return K1_1400_Plus; + case 30: return K1_1400_Minus; + case 31: return b1_1235_Plus; + case 32: return Sigma_1385_Minus; + case 33: return Sigma_1385_0; + case 34: return Sigma_1385_Plus; + case 35: return DeltaPlusPlus; + case 36: return Jpsi; + case 37: return Eta_c; + case 38: return Chi_c0; + case 39: return Chi_c1; + case 40: return Chi_c2; + case 41: return Psi2s; + case 42: return D0; + case 43: return DPlus; + case 44: return Dstar0; + case 45: return DstarPlus; + case 46: return Lambda_c; + case 47: return AntiD0; + default: return Unknown; + } +} + +typedef enum +{ + d_Charged, + d_Positive, + d_Negative, + d_Neutral, + d_AllCharges +} Charge_t; + +inline static int Is_CorrectCharge(Particle_t locPID, Charge_t locCharge) +{ + if(locPID == Unknown) + return (locCharge == d_AllCharges); + int locIntCharge = ParticleCharge(locPID); + switch(locCharge) + { + case d_Neutral: + return (locIntCharge == 0); + case d_Positive: + return (locIntCharge > 0); + case d_Negative: + return (locIntCharge < 0); + case d_Charged: + return (locIntCharge != 0); + case d_AllCharges: + return 1; + default: + return 0; + } +} + +// Deduce particle type from charge and mass +inline static Particle_t IDTrack(float locCharge, float locMass) +{ + float locMassTolerance = 0.010; + if (locCharge > 0.1) // Positive particles + { + if (fabs(locMass - ParticleMass(Triton)) < locMassTolerance) return Triton; + if (fabs(locMass - ParticleMass(Deuteron)) < locMassTolerance) return Deuteron; + if (fabs(locMass - ParticleMass(Proton)) < locMassTolerance) return Proton; + if (fabs(locMass - ParticleMass(PiPlus)) < locMassTolerance) return PiPlus; + if (fabs(locMass - ParticleMass(KPlus)) < locMassTolerance) return KPlus; + if (fabs(locMass - ParticleMass(Positron)) < locMassTolerance) return Positron; + if (fabs(locMass - ParticleMass(MuonPlus)) < locMassTolerance) return MuonPlus; + } + else if(locCharge < -0.1) // Negative particles + { + if (fabs(locMass - ParticleMass(PiMinus)) < locMassTolerance) return PiMinus; + if (fabs(locMass - ParticleMass(KMinus)) < locMassTolerance) return KMinus; + if (fabs(locMass - ParticleMass(MuonMinus)) < locMassTolerance) return MuonMinus; + if (fabs(locMass - ParticleMass(Electron)) < locMassTolerance) return Electron; + if (fabs(locMass - ParticleMass(AntiProton)) < locMassTolerance) return AntiProton; + } + else //Neutral Track + { + if (fabs(locMass - ParticleMass(Gamma)) < locMassTolerance) return Gamma; + if (fabs(locMass - ParticleMass(Neutron)) < locMassTolerance) return Neutron; + } + return Unknown; +} + + +#endif diff --git a/run_EIC_batch.csh b/run_EIC_batch.csh index 8054798..ee9e1fb 100755 --- a/run_EIC_batch.csh +++ b/run_EIC_batch.csh @@ -2,12 +2,14 @@ set FileNum=$1 set NumEvents=$2 -echo "Running target polarisation up, FF setting for file $FileNum with $NumEvents events per file" +set RandomSeed=$3 +echo "Running target polarisation up, FF setting for file $FileNum with $NumEvents events per file using random seed $RandomSeed" cp Config_EIC.json Config_EIC_$FileNum.json -sed -i 's/"file_name" \:.*/"file_name" \: "DEMPGen_'$NumEvents'_'$FileNum'",/' Config_EIC_$FileNum.json +sed -i 's/"file_name" \:.*/"file_name" \: "DEMPGen_5on100_'$NumEvents'_'$FileNum'",/' Config_EIC_$FileNum.json sed -i 's/"n_events" \:.*/"n_events" \: '$NumEvents',/' Config_EIC_$FileNum.json +sed -i 's/"generator_seed"\:.*/"generator_seed" \: '$RandomSeed',/' Config_EIC_$FileNum.json cd data/ ./../build/DEMPgen ../Config_EIC_$FileNum.json sleep 5 -mv "LundFiles/eic_input_DEMPGen_"$NumEvents"_"$FileNum".dat" "LundFiles/eic_DEMPGen_"$NumEvents"_"$FileNum".lund" +mv "LundFiles/eic_input_DEMPGen_5on100_"$NumEvents"_"$FileNum".dat" "LundFiles/eic_DEMPGen_5on100_"$NumEvents"_"$FileNum".lund" rm -rf ../Config_EIC_$FileNum.json diff --git a/run_EIC_batch_10on100.csh b/run_EIC_batch_10on100.csh new file mode 100755 index 0000000..05d671f --- /dev/null +++ b/run_EIC_batch_10on100.csh @@ -0,0 +1,15 @@ +#!/bin/csh + +set FileNum=$1 +set NumEvents=$2 +set RandomSeed=$3 +echo "Running target polarisation up, FF setting for file $FileNum with $NumEvents events per file using random seed $RandomSeed" +cp Config_EIC.json Config_EICC_10on100_$FileNum.json +sed -i 's/"file_name" \:.*/"file_name" \: "DEMPGen_10on100_'$NumEvents'_'$FileNum'",/' Config_EICC_10on100_$FileNum.json +sed -i 's/"n_events" \:.*/"n_events" \: '$NumEvents',/' Config_EICC_10on100_$FileNum.json +sed -i 's/"generator_seed"\:.*/"generator_seed" \: '$RandomSeed',/' Config_EICC_10on100_$FileNum.json +cd data/ +./../build/DEMPgen ../Config_EICC_10on100_$FileNum.json +sleep 5 +mv "LundFiles/eic_input_DEMPGen_10on100_"$NumEvents"_"$FileNum".dat" "LundFiles/eic_DEMPGen_10on100_"$NumEvents"_"$FileNum".lund" +rm -rf ../Config_EICC_10on100_$FileNum.json diff --git a/run_EIC_batch_5on100.csh b/run_EIC_batch_5on100.csh new file mode 100755 index 0000000..8a54230 --- /dev/null +++ b/run_EIC_batch_5on100.csh @@ -0,0 +1,15 @@ +#!/bin/csh + +set FileNum=$1 +set NumEvents=$2 +set RandomSeed=$3 +echo "Running target polarisation up, FF setting for file $FileNum with $NumEvents events per file using random seed $RandomSeed" +cp Config_EIC.json Config_EICC_5on100_$FileNum.json +sed -i 's/"file_name" \:.*/"file_name" \: "DEMPGen_5on100_'$NumEvents'_'$FileNum'",/' Config_EICC_5on100_$FileNum.json +sed -i 's/"n_events" \:.*/"n_events" \: '$NumEvents',/' Config_EICC_5on100_$FileNum.json +sed -i 's/"generator_seed"\:.*/"generator_seed" \: '$RandomSeed',/' Config_EICC_5on100_$FileNum.json +cd data/ +./../build/DEMPgen ../Config_EICC_5on100_$FileNum.json +sleep 5 +mv "LundFiles/eic_input_DEMPGen_5on100_"$NumEvents"_"$FileNum".dat" "LundFiles/eic_DEMPGen_5on100_"$NumEvents"_"$FileNum".lund" +rm -rf ../Config_EICC_5on100_$FileNum.json diff --git a/run_EIC_batch_5on41.csh b/run_EIC_batch_5on41.csh new file mode 100755 index 0000000..95be7e1 --- /dev/null +++ b/run_EIC_batch_5on41.csh @@ -0,0 +1,15 @@ +#!/bin/csh + +set FileNum=$1 +set NumEvents=$2 +set RandomSeed=$3 +echo "Running target polarisation up, FF setting for file $FileNum with $NumEvents events per file using random seed $RandomSeed" +cp Config_EIC.json Config_EIC_5on41_$FileNum.json +sed -i 's/"file_name" \:.*/"file_name" \: "DEMPGen_5on41_'$NumEvents'_'$FileNum'",/' Config_EICC_5on41_$FileNum.json +sed -i 's/"n_events" \:.*/"n_events" \: '$NumEvents',/' Config_EICC_5on41_$FileNum.json +sed -i 's/"generator_seed"\:.*/"generator_seed" \: '$RandomSeed',/' Config_EICC_5on41_$FileNum.json +cd data/ +./../build/DEMPgen ../Config_EICC_5on41_$FileNum.json +sleep 5 +mv "LundFiles/eic_input_DEMPGen_5on41_"$NumEvents"_"$FileNum".dat" "LundFiles/eic_DEMPGen_5on41_"$NumEvents"_"$FileNum".lund" +rm -rf ../Config_EICC_5on41_$FileNum.json diff --git a/sjdkay_Job.txt b/sjdkay_Job.txt new file mode 100644 index 0000000..98b2ecc --- /dev/null +++ b/sjdkay_Job.txt @@ -0,0 +1,12 @@ +#!/bin/csh +#PBS -N DEMPGen_1000000000_100 +#PBS -m abe +#PBS -M sjdkay@jlab.org +#PBS -r n +#PBS -o /home/sjdkay/trq_output/DEMPGen_1000000000_100.out +#PBS -e /home/sjdkay/trq_output/DEMPGen_1000000000_100.err +date +cd /home/apps/DEMPgen/ +./run_EIC_batch.csh 100 1000000000 +date +exit diff --git a/sjdkay_notes b/sjdkay_notes new file mode 100644 index 0000000..d06999c --- /dev/null +++ b/sjdkay_notes @@ -0,0 +1,35 @@ +Stephen JD Kay - University of Regina +stephen.kay@uregina.ca +26/11/20 + +######################################################################################################################################## + +Some notes on where to change or modify certain things to tweak the generator output as needed for different EIC/detector configurations + +######################################################################################################################################## + +Beam Energy - Tweak the energy of each beam (e/p) on line 224/225 of eic_pim.cc in src/eic_evgen +Luminosity - Adjust the luminosity on line 129 of eic_pim.cc in src/eic_evgen +Beam Crossing Angle - Adjust line 665 of PiPlus_prod.cc in src/eic_evgen/process_routine + +######################################################################################################################################## +######################################################## Q2/W/t thresholds ############################################################# +######################################################################################################################################## + +Lines that may be present in the .json file are ONLY for SoLID event generation + +Change these for EIC running in src/eic_evgen/process_routine/PiPlus_prod.cc + +Relevant lines in src/eic_evgen/process_routine/PiPlus_prod.cc are as follows - + +Q2 - Line 256, Line 819 for comment in output file +W - Line 387, Line 817 for comment in output file +t - Line 484, Line 820 for comment in output file + +######################################################################################################################################## +##################################################### Comments/Future Changes ########################################################## +######################################################################################################################################## + +Can't tweak any of these variables for EIC runs in the .json file which is a bit odd. +These are all variables that are likely to be changed so it might be nice to modify the generator so that these are read in as items from +the config file. \ No newline at end of file diff --git a/src/CustomRand.cxx b/src/CustomRand.cxx index fcc81d2..eef85b9 100644 --- a/src/CustomRand.cxx +++ b/src/CustomRand.cxx @@ -15,9 +15,15 @@ CustomRand::CustomRand(const char * fname, double ThetaRange[2], double PhiRange[2]) { + extern int Gen_seed; + PartSet = true; int seed = 0; + + cout << "Seed setting: " << Gen_seed << endl; + +// exit(0); if(gRandom) delete gRandom; gRandom = new TRandom3(0); @@ -43,6 +49,51 @@ CustomRand::CustomRand(const char * fname, } +/*--------------------------------------------------*/ + +CustomRand::CustomRand(const char * fname, + double ERange[2], + double ThetaRange[2], + double PhiRange[2], + int demp_seed) +{ + PartSet = true; + + int seed = demp_seed; + + if(gRandom) delete gRandom; + gRandom = new TRandom3(0); + + gRandom -> SetSeed(seed); + + char PhiName[100] = "Phi_"; + strcat(PhiName, fname); + PhiRand = new TF1(PhiName, "1", PhiRange[0], PhiRange[1]); + + char ThetaName[100] = "Theta_"; + strcat(ThetaName, fname); + + // ThetaRand = new TF1(ThetaName, "1", + // TMath::Cos(ThetaRange[0]), + // TMath::Cos(ThetaRange[1])); + + ThetaRand = new TF1(ThetaName, "0.5*sin(x)", ThetaRange[0], ThetaRange[1]); + + char EName[100] = "E_%c"; + std::sprintf(EName, EName, fname); + ERand = new TF1(EName, "1", ERange[0], ERange[1]); +} + + + + +/*--------------------------------------------------*/ + + + + + + double CustomRand::Phi() { return PhiRand->GetRandom(); diff --git a/src/eic_evgen/README b/src/eic_evgen/README index 1b206e1..5dd540a 100644 --- a/src/eic_evgen/README +++ b/src/eic_evgen/README @@ -96,7 +96,7 @@ source ./runEIC.csh Note 1: fEventWeight is a negative number because of the phase space of scattered -elecgron. +electron. Note 2: Lets say you generate "N" dat files and then generate "N" root files using diff --git a/src/eic_evgen/README.md b/src/eic_evgen/README.md index 1ed8131..da46698 100644 --- a/src/eic_evgen/README.md +++ b/src/eic_evgen/README.md @@ -97,7 +97,7 @@ source ./runEIC.csh Note 1: fEventWeight is a negative number because of the phase space of scattered -elecgron. +electron. Note 2: Lets say you generate "N" dat files and then generate "N" root files using diff --git a/src/eic_evgen/eic b/src/eic_evgen/eic deleted file mode 100755 index 2f7b7b2..0000000 Binary files a/src/eic_evgen/eic and /dev/null differ diff --git a/src/eic_evgen/eic.cc b/src/eic_evgen/eic.cc index 22a67bd..5eeb66e 100644 --- a/src/eic_evgen/eic.cc +++ b/src/eic_evgen/eic.cc @@ -31,11 +31,9 @@ using namespace std; // return 0; //} - - void eic() { - Int_t target_direction, kinematics_type; + Int_t target_direction, kinematics_type; cout << "Target Direction (1->Up, 2->Down): "; cin >> target_direction; cout << endl; cout << "Kinematics type (1->FF, 2->TSSA): "; cin >> kinematics_type; cout << endl; @@ -46,736 +44,223 @@ void eic() { } +/*--------------------------------------------------*/ +void eic(int event_number, int target_direction, int kinematics_type, TString file_name, int fEIC_seed, TString particle, TString det_location) { -void eic(int event_number, int target_direction, int kinematics_type, TString file_name) { + TString targetname; + TString charge; + if( target_direction == 1 ) targetname = "up"; + if( target_direction == 2 ) targetname = "down"; + + gKinematics_type = kinematics_type; + gfile_name = file_name; fNFile = 1; fNEvents = event_number; - cout << "event_number: " << event_number << endl; + fSeed = fEIC_seed; + + pim* myPim = new pim(fSeed); + myPim->Initilize(); + +// TDatime dsTime; +// cout << "Start Time: " << dsTime.GetHour() << ":" << dsTime.GetMinute() << endl; + + particle = ExtractParticle(particle); + charge = ExtractCharge(particle); + +// if (particle == "pi") { +// Exclusive_Pion_Prodoction(*myPim); +// } else if (particle == "omega") { +// Exclusive_Omega_Prodoction(*myPim); +// } else { +// cerr << "Choice of particle is not recognized." << endl; +// exit(0); +// } + +// TDatime dsTime; +// cout << "Start Time: " << dsTime.GetHour() << ":" << dsTime.GetMinute() << endl; + +// TStopwatch tTime; +// tTime.Start(); +// +// Exclusive_Pion_Prodoction(*myPim); +// +// tTime.Stop(); +// tTime.Print(); + + Reaction* r1 = new Reaction(particle); + r1->process_reaction(); + delete r1; + +} + +/*--------------------------------------------------*/ +/*--------------------------------------------------*/ + +void eic(Json::Value obj) { TString targetname; + TString charge; + + int target_direction = obj["Targ_dir"].asInt(); + gKinematics_type = obj["Kinematics_type"].asInt(); if( target_direction == 1 ) targetname = "up"; - if( target_direction == 2 ) targetname = "down"; + if( target_direction == 2 ) targetname = "down"; + gfile_name = obj["file_name"].asString(); + + gPi0_decay = obj["pi0_decay"].asBool(); + fNFile = 1; +// fNEvents = obj["n_events"].asInt(); + fNEvents = obj["n_events"].asUInt64(); - double cos_t, sin_t; - pim myPim; - myPim.Initilize(); - - TDatime dsTime; - cout << "Start Time: " << dsTime.GetHour() << ":" << dsTime.GetMinute() << endl; + fSeed = obj["generator_seed"].asInt(); - TStopwatch tTime; - tTime.Start(); + pim* myPim = new pim(fSeed); + myPim->Initilize(); - // kCalcFermi = true; - +// TDatime dsTime; +// cout << "Start Time: " << dsTime.GetHour() << ":" << dsTime.GetMinute() << endl; + TString particle = obj["particle"].asString(); + particle = ExtractParticle(particle); + charge = ExtractCharge(particle); + ///*--------------------------------------------------*/ + /// The detector selection is determined here + /// The incidence proton phi angle is + + gDet_location = obj["det_location"].asString(); + + if (gDet_location == "ip8") { + + fProton_incidence_phi = 0.0; + + } else if (gDet_location == "ip6") { + + fProton_incidence_phi = fPi; + + } else { + + fProton_incidence_phi = 0.0; + cout << "The interaction point not recognized!" << endl; + cout << "Therefore default opition ip6 is used." << endl; + + } + - string sTFile; - sTFile = Form("./LundFiles/eic_%s.txt", file_name.Data()); - string sRFile; - sRFile = Form("./RootFiles/eic_%s.root", file_name.Data()); - string sLFile; - sLFile= Form("./LundFiles/eic_input_%s.dat", file_name.Data()); - - ofstream ppiOut ( sLFile.c_str() ); - ofstream ppiDetails ( sTFile.c_str() ); - - myPim.setrootfile( sRFile ); - - int qsq_ev = 0, t_ev = 0, w_neg_ev = 0, w_ev = 0; - double lpar0 = 0., lpar1 = 0., lpar2 = 0., lpar3 = 0., lpar4 = 0., lpar5 = 0., lpar6 = 0.; - double tpar0 = 0., tpar1 = 0., tpar2 = 0., tpar3 = 0., tpar4 = 0.; - - t1->SetDirectory( f ); - t1->SetAutoSave( 1000000000 ); - - long long int i; - for ( i = 0; i < fNEvents; i++ ) { - - TDatime dFractTime; - - fNGenerated ++; - - if ( i % ( fNEvents / 10 ) == 0 ) { - cout << "Event: " << setw(8) << i - << " % of events " << setw(4) << ((1.0*i)/(1.0*fNEvents))*100.0 - << " Day: " << dFractTime.GetDay() - << " Time: " << dFractTime.GetHour() - << ":" << dFractTime.GetMinute() - << ":" << dFractTime.GetSecond() - << endl; - } - - // ---------------------------------------------------- - // Proton in lab (collider) frame - // ---------------------------------------------------- - - fProton_Theta_Col = 50.0e-3; - fProton_Phi_Col = fPi; - fProton_Mom_Col = fPBeam * 1e3; - fVertex_X = 0.; - fVertex_Y = 0.; - fVertex_Z = 0.; - - if ( kCalcFermi ) { - fProton_Mom_Col = fProton_Mom_Col + myPim.fermiMomentum(); - fProton_Theta_Col = acos( fRandom->Uniform( cos(0.0) , cos(fPi) ) ); - fProton_Phi_Col = fRandom->Uniform( 0 , 360 ); - } - - TLorentzVector lproton( fProton_Mom_Col * sin(fProton_Theta_Col) * cos(fProton_Phi_Col), - fProton_Mom_Col * sin(fProton_Theta_Col) * sin(fProton_Phi_Col), - fProton_Mom_Col * cos(fProton_Theta_Col), - sqrt( pow( fProton_Mom_Col , 2 ) + pow( fProton_Mass , 2 ) ) ); - - TLorentzVector lprotong; - lprotong = lproton * fm; - - // ---------------------------------------------------- - // Boost vector from lab to protons rest frame - // ---------------------------------------------------- - - TVector3 beta_col_rf; - beta_col_rf = lproton.BoostVector(); - fGamma_Col_RF = 1.0/sqrt( 1 - pow( beta_col_rf.Mag() , 2 ) ); - - // ---------------------------------------------------- - // Electron in lab (collider) frame - // ---------------------------------------------------- - fElectron_Energy_Col = fElectron_Kin_Col; - fElectron_Mom_Col = sqrt( pow(fElectron_Energy_Col , 2) - pow(fElectron_Mass , 2) ); - fElectron_Theta_Col = fPi; - fElectron_Phi_Col = 0.0; - fElectron_MomZ_Col = fElectron_Mom_Col * cos(fElectron_Theta_Col); - fElectron_MomX_Col = fElectron_Mom_Col * sin(fElectron_Theta_Col) * cos(fElectron_Phi_Col); - fElectron_MomY_Col = fElectron_Mom_Col * sin(fElectron_Theta_Col) * sin(fElectron_Phi_Col); - - TLorentzVector lelectron( fElectron_MomX_Col, fElectron_MomY_Col, fElectron_MomZ_Col, fElectron_Energy_Col); - TLorentzVector lelectrong; - lelectrong = lelectron * fm; - - // --------------------------------------------------------------------- - // Specify the energy and solid angle of scatterd electron in lab frame - // --------------------------------------------------------------------- - fScatElec_Theta_Col = acos( fRandom->Uniform( cos( fScatElec_Theta_I ) , cos( fScatElec_Theta_F ) ) ); - fScatElec_Phi_Col = fRandom->Uniform( 0 , 2.0 * fPi); - fScatElec_Energy_Col = fRandom->Uniform( fScatElec_E_Lo * fElectron_Energy_Col , fScatElec_E_Hi * fElectron_Energy_Col ); - fPion_Theta_Col = acos( fRandom->Uniform( cos(fPion_Theta_I ) , cos(fPion_Theta_F ) ) ); - fPion_Phi_Col = fRandom->Uniform( 0 , 2.0 * fPi ); - - // fScatElec_Theta_Col = 146.356*fDEG2RAD; - // fScatElec_Phi_Col = 11.8325*fDEG2RAD; - // fScatElec_Energy_Col = 5.25281*1000.0; - // fPion_Theta_Col = 14.5869*fDEG2RAD; - // fPion_Phi_Col = -168.57*fDEG2RAD; - - fScatElec_Mom_Col = sqrt( pow( fScatElec_Energy_Col,2) - pow( fElectron_Mass , 2) ); - fScatElec_MomZ_Col = ( fScatElec_Mom_Col * cos(fScatElec_Theta_Col) ); - fScatElec_MomX_Col = ( fScatElec_Mom_Col * sin(fScatElec_Theta_Col) * cos(fScatElec_Phi_Col) ); - fScatElec_MomY_Col = ( fScatElec_Mom_Col * sin(fScatElec_Theta_Col) * sin(fScatElec_Phi_Col) ); - - TLorentzVector lscatelec( fScatElec_MomX_Col, fScatElec_MomY_Col, fScatElec_MomZ_Col, fScatElec_Energy_Col); - TLorentzVector lscatelecg; - lscatelecg = lscatelec * fm; - - // ---------------------------------------------------- - // Photon in lab frame and Qsq - // ---------------------------------------------------- - - TLorentzVector lphoton; - lphoton = lelectron - lscatelec; - TLorentzVector lphotong; - lphotong = lelectrong - lscatelecg; - - fQsq_GeV = -1.*lphotong.Mag2(); - - if ( fQsq_GeV < 5.0 ) { - qsq_ev++; - continue; - } - - // ---------------------------------------------------- - // W square, Invariant Mass (P_g + P_p)^2 - // ---------------------------------------------------- - - TLorentzVector lwg; - lwg = lprotong + lphotong; - fW_GeV = lwg.Mag(); - fWSq_GeV = lwg.Mag2(); - - if ( fWSq_GeV < 0 ) { - w_neg_ev++; - continue; - } - - // ---------------------------------------------------- - // Pion in Col frame - // ---------------------------------------------------- - // fPion_Theta_Col = acos( fRandom->Uniform( cos(fPion_Theta_I ) , cos(fPion_Theta_F ) ) ); - // fPion_Phi_Col = fRandom->Uniform( 0 , 360 ); - - // --------------------------------------------------------- - // Pion momentum in collider frame, analytic solution starts - // --------------------------------------------------------- - - double fupx = sin( fPion_Theta_Col ) * cos( fPion_Phi_Col ); - double fupy = sin( fPion_Theta_Col ) * sin( fPion_Phi_Col ); - double fupz = cos( fPion_Theta_Col ); - - double fuqx = sin( lphoton.Theta() ) * cos( lphoton.Phi() ); - double fuqy = sin( lphoton.Theta() ) * sin( lphoton.Phi() ); - double fuqz = cos( lphoton.Theta() ); - - double fa = -(lphoton.Vect()).Mag() * ( fupx * fuqx + fupy * fuqy + fupz * fuqz ); - double fb = pow ( (lphoton.Vect()).Mag() , 2 ); - double fc = lphoton.E() + fProton_Mass; - - fa = ( fa - std::abs( (lproton.Vect()).Mag() ) * ( ( ( lproton.X() / (lproton.Vect()).Mag() ) * fupx ) + - ( ( lproton.Y() / (lproton.Vect()).Mag() ) * fupy ) + - ( ( lproton.Z() / (lproton.Vect()).Mag() ) * fupz ) ) ); - - double factor = ( pow( (lproton.Vect()).Mag() , 2 ) + 2.0 * (lphoton.Vect()).Mag() * (lproton.Vect()).Mag() * - ( ( ( lproton.X() / (lproton.Vect()).Mag() ) * fuqx ) + - ( ( lproton.Y() / (lproton.Vect()).Mag() ) * fuqy ) + - ( ( lproton.Z() / (lproton.Vect()).Mag() ) * fuqz ) ) ); - - fb = fb + factor; - fc = lphoton.E() + lproton.E(); - - double ft = fc * fc - fb + fPion_Mass * fPion_Mass - fProton_Mass * fProton_Mass; - - double fQA = 4.0 * ( fa * fa - fc * fc ); - double fQB = 4.0 * fc * ft; - double fQC = -4.0 * fa * fa * fPion_Mass * fPion_Mass - ft * ft; - - fradical = fQB * fQB - 4.0 * fQA * fQC; - - fepi1 = ( -fQB - sqrt( fradical ) ) / ( 2.0 * fQA ); - fepi2 = ( -fQB + sqrt( fradical ) ) / ( 2.0 * fQA ); - - fPion_Mom_Same = 0; - if ( std::abs(fepi1 - fepi2) < fDiff ){ fPion_Mom_Same = 1; } - - // --------------------------------------------------------- - // Pion momentum in collider frame, analytic solution ends - // --------------------------------------------------------- - - TLorentzVector lpion( ( sqrt( pow( fepi1 , 2) - pow(fPion_Mass , 2) ) ) * sin(fPion_Theta_Col) * cos(fPion_Phi_Col), - ( sqrt( pow( fepi1 , 2) - pow(fPion_Mass , 2) ) ) * sin(fPion_Theta_Col) * sin(fPion_Phi_Col), - ( sqrt( pow( fepi1 , 2) - pow(fPion_Mass , 2) ) ) * cos(fPion_Theta_Col), - fepi1 ); - - TLorentzVector lpiong; - lpiong = lpion * fm; - - TLorentzVector lneutron( ( lproton + lelectron - lscatelec - lpion ).X(), - ( lproton + lelectron - lscatelec - lpion ).Y(), - ( lproton + lelectron - lscatelec - lpion ).Z(), - sqrt( pow( ( ( ( lproton + lelectron - lscatelec - lpion ).Vect() ).Mag()),2) + - pow( fNeutron_Mass ,2 ) ) ); - TLorentzVector lneutrong; - lneutrong = lneutron * fm; - - fNeutron_Mom_Col_GeV = (lneutrong.Vect()).Mag(); - fNeutron_MomZ_Col_GeV = lneutrong.Z(); - fNeutron_MomX_Col_GeV = lneutrong.X(); - fNeutron_MomY_Col_GeV = lneutrong.Y(); - fNeutron_Energy_Col_GeV = lneutrong.E(); - - // --------------------------------------------------------------------------------------------------------------------------------------- - // --------------------------------------------------------------------------------------------------------------------------------------- - // Calculate w = (proton + photon)^2 - // --------------------------------------------------------------------------------------------------------------------------------------- - // --------------------------------------------------------------------------------------------------------------------------------------- - - // cout << fW_GeV << endl; - if ( fW_GeV < 3.0 || fW_GeV > 10.6 ) { - w_ev++; - continue; - } - - TLorentzVector lw; - lw = lproton + lphoton; - fW = lw.Mag(); - - // -------------------------------------------------------------------------------------------------------------------------------- - // -------------------------------------------------------------------------------------------------------------------------------- - // Calculate w prime w' = (proton + photon - pion)^2 - // --------------------------------------------------------------------------------------------------------------------------------------- - // --------------------------------------------------------------------------------------------------------------------------------------- - - TLorentzVector lwp = lprotong + lphotong - lpiong; - fW_Prime_GeV = lwp.Mag(); - - TLorentzVector fsini; - fsini = lelectron + lproton; - TLorentzVector fsfin; - fsfin = lscatelec + lpion + lneutron; - - TLorentzVector fsinig; - fsinig = fsini * fm; - TLorentzVector fsfing; - fsfing = fsfin * fm; - - fMandSConserve = std::abs( fsinig.Mag() - fsfing.Mag() ); - - kSConserve = false; - if( std::abs( fsinig.Mag() - fsfing.Mag() ) < fDiff ) { - kSConserve = true; - } - - if ( myPim.CheckLaws( lelectron, lproton, lscatelec, lpion, lneutron ) != 1 ) - continue; - - - - - - ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - // // - // Start // - // // - // Transformation of e', pi- and recoil proton to target's rest frmae without energy loss // - // // - // // - ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - TLorentzVector lproton_rf; - lproton_rf = lproton; - lproton_rf.Boost(-beta_col_rf); - TLorentzVector lproton_rfg; - lproton_rfg = lproton_rf * fm; - - TLorentzVector lelectron_rf; - lelectron_rf = lelectron; - lelectron_rf.Boost(-beta_col_rf); - TLorentzVector lelectron_rfg; - lelectron_rfg = lelectron_rf * fm; - - TLorentzVector lscatelec_rf; - lscatelec_rf = lscatelec; - lscatelec_rf.Boost(-beta_col_rf); - TLorentzVector lscatelec_rfg; - lscatelec_rfg = lscatelec_rf * fm; - - TLorentzVector lphoton_rf; - lphoton_rf = lphoton; - lphoton_rf.Boost(-beta_col_rf); - TLorentzVector lphoton_rfg; - lphoton_rfg = lphoton_rf * fm; - - TLorentzVector lpion_rf; - lpion_rf = lpion; - lpion_rf.Boost(-beta_col_rf); - TLorentzVector lpion_rfg; - lpion_rfg = lpion_rf * fm; - - TLorentzVector lneutron_rf; - lneutron_rf = lneutron; - lneutron_rf.Boost(-beta_col_rf); - TLorentzVector lneutron_rfg; - lneutron_rfg = lneutron_rf * fm; - - ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - // // - // End // - // // - // Transformation of e', pi- and recoil proton to target's rest frmae without energy loss // - // // - // // - ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - // fElectron_Energy_RF_GeV = lelectron_rf.E() / 1000.0; - // fElectron_Mom_RF_GeV = (lelectron_rf.Vect()).Mag() / 1000.0; - // fElectron_MomX_RF_GeV = lelectron_rf.X() / 1000.0; - // fElectron_MomY_RF_GeV = lelectron_rf.Y() / 1000.0; - // fElectron_MomZ_RF_GeV = lelectron_rf.Z() / 1000.0; - - fScatElec_Energy_RF_GeV = lscatelec_rf.E() / 1000.0; - fScatElec_Mom_RF_GeV = (lscatelec_rf.Vect()).Mag() / 1000.0; - fScatElec_MomX_RF_GeV = lscatelec_rf.X() / 1000.0; - fScatElec_MomY_RF_GeV = lscatelec_rf.Y() / 1000.0; - fScatElec_MomZ_RF_GeV = lscatelec_rf.Z() / 1000.0; - - fPion_Energy_RF_GeV = lpion_rf.E() / 1000.0; - fPion_Mom_RF_GeV = (lpion_rf.Vect()).Mag() / 1000.0; - fPion_MomX_RF_GeV = lpion_rf.X() / 1000.0; - fPion_MomY_RF_GeV = lpion_rf.Y() / 1000.0; - fPion_MomZ_RF_GeV = lpion_rf.Z() / 1000.0; - - fNeutron_Energy_RF_GeV = lneutron_rf.E() / 1000.0; - fNeutron_Mom_RF_GeV = (lneutron_rf.Vect()).Mag() / 1000.0; - fNeutron_MomX_RF_GeV = lneutron_rf.X() / 1000.0; - fNeutron_MomY_RF_GeV = lneutron_rf.Y() / 1000.0; - fNeutron_MomZ_RF_GeV = lneutron_rf.Z() / 1000.0; - - // if ( myPim.CheckLaws( lelectron_rf, lproton_rf, lscatelec_rf, lpion_rf, lneutron_rf ) != 1 ) - // continue; - - // -------------------------------------------------------------------------------------------------------------------------------- - // -------------------------------------------------------------------------------------------------------------------------------- - // Calculate -t - // --------------------------------------------------------------------------------------------------------------------------------------- - // --------------------------------------------------------------------------------------------------------------------------------------- - - fBeta_CM_RF = (lphoton_rf.Vect()).Mag() / ( lphoton_rf.E() + fProton_Mass ); - fGamma_CM_RF = ( lphoton_rf.E() + fProton_Mass ) / fW; - fPion_Energy_CM = ( pow( fW , 2) + pow(fPion_Mass , 2) - pow(fNeutron_Mass , 2) ) / ( 2.0 * fW); - fPion_Mom_CM = sqrt( pow(fPion_Energy_CM , 2) - pow(fPion_Mass , 2)); - fPion_Energy_CM_GeV = fPion_Energy_CM / 1000.0; - fPion_Mom_CM_GeV = fPion_Mom_CM / 1000.0; - - // this equation is valid for parallel kinematics only! - fT_Para = ( pow(((lphoton.Vect()).Mag() - (lpion.Vect()).Mag()),2) - pow((lphoton.E() - lpion.E()),2)); - fT_Para_GeV = fT_Para/1000000.0; - - TLorentzVector lt; - lt = lphoton - lpion; - TLorentzVector ltg; - ltg = lt * fm; - - fT = -1.*lt.Mag2(); - fT_GeV = -1.*ltg.Mag2(); - - if ( kinematics_type == 1 && fT_GeV > 0.5 ) { - t_ev++; - continue; - } - - if ( kinematics_type == 2 && fT_GeV > 1.3 ) { - t_ev++; - continue; - } - - fx = fQsq_GeV / ( 2.0 * lprotong.Dot( lphotong ) ); - fy = lprotong.Dot( lphotong ) / lprotong.Dot( lelectrong ); - fz = lpion.E()/lphoton.E(); - - // ------------------------------------------------------------------------------------------------------------------------------- - // ------------------------------------------------------------------------------------------------------------------------------- - - // ------------------------------------------------------------------------------------------------------- - // Calculation of Phi ( azimuthal angle of pion momentum w.r.t lepton plane in target's rest frame) - // Calculation of PhiS ( azimuthal angle of target polarization w.r.t lepton plane in target's rest frame) - // ------------------------------------------------------------------------------------------------------- - - TVector3 v3Photon; v3Photon.SetX( lphoton_rfg.X() ); v3Photon.SetY( lphoton_rfg.Y() ); v3Photon.SetZ( lphoton_rfg.Z() ); - TVector3 v3Electron; v3Electron.SetX( lelectron_rfg.X() ); v3Electron.SetY( lelectron_rfg.Y() ); v3Electron.SetZ( lelectron_rfg.Z() ); - TVector3 v3Pion; v3Pion.SetX( lpion_rfg.X() ) ; v3Pion.SetY( lpion_rfg.Y() ) ; v3Pion.SetZ( lpion_rfg.Z() ); - TVector3 v3S; v3S.SetX( -1 ); v3S.SetY( 0 ); v3S.SetZ( 0 ); - TVector3 v3PhotonUnit = v3Photon.Unit(); - TVector3 v3QxL = v3Photon.Cross(v3Electron); - TVector3 v3QxP = v3Photon.Cross(v3Pion); - TVector3 v3QxS = v3Photon.Cross(v3S); - TVector3 v3LxP = v3Electron.Cross(v3Pion); - TVector3 v3LxS = v3Electron.Cross(v3S); - TVector3 v3PxL = v3Pion.Cross(v3Electron); - TVector3 v3QUnitxL = v3PhotonUnit.Cross(v3Electron); - TVector3 v3QUnitxP = v3PhotonUnit.Cross(v3Pion); - TVector3 v3QUnitxS = v3PhotonUnit.Cross(v3S); - - fCos_Phi_Pion_LeptonPlane_RF = ( ( v3QUnitxL.Dot( v3QUnitxP ) ) / ( v3QUnitxL.Mag() * v3QUnitxP.Mag() ) ); // hep-ph/0410050v2 - fSin_Phi_Pion_LeptonPlane_RF = ( ( v3LxP.Dot( v3PhotonUnit ) ) / ( v3QUnitxL.Mag() * v3QUnitxP.Mag() ) ); // hep-ph/0410050v2 - if ( fSin_Phi_Pion_LeptonPlane_RF >= 0 ) - fPhi_Pion_LeptonPlane_RF = fRAD2DEG * acos( ( v3QUnitxL.Dot( v3QUnitxP ) ) / ( v3QUnitxL.Mag() * v3QUnitxP.Mag() ) ); - if ( fSin_Phi_Pion_LeptonPlane_RF < 0 ) - fPhi_Pion_LeptonPlane_RF = 360.0 - std::abs( fRAD2DEG * acos( ( v3QUnitxL.Dot( v3QUnitxP ) ) / ( v3QUnitxL.Mag() * v3QUnitxP.Mag() ) ) ); - - fCos_Phi_TargPol_LeptonPlane_RF = ( ( v3QUnitxL.Dot( v3QUnitxS ) ) / ( v3QUnitxL.Mag() * v3QUnitxS.Mag() ) ); // hep-ph/0410050v2 - fSin_Phi_TargPol_LeptonPlane_RF = ( ( v3LxS.Dot( v3PhotonUnit ) ) / ( v3QUnitxL.Mag() * v3QUnitxS.Mag() ) ); // hep-ph/0410050v2 - if ( fSin_Phi_TargPol_LeptonPlane_RF >= 0 ) - fPhi_TargPol_LeptonPlane_RF = fRAD2DEG * acos( ( v3QUnitxL.Dot( v3QUnitxS ) ) / ( v3QUnitxL.Mag() * v3QUnitxS.Mag() ) ); - if ( fSin_Phi_TargPol_LeptonPlane_RF < 0 ) - fPhi_TargPol_LeptonPlane_RF = 360.0 - std::abs( fRAD2DEG * acos( ( v3QUnitxL.Dot( v3QUnitxS ) ) / ( v3QUnitxL.Mag() * v3QUnitxS.Mag() ) ) ); - - fTheta_Pion_Photon_RF = fRAD2DEG * acos( ( v3Photon.Dot( v3Pion ) ) / ( v3Photon.Mag() * v3Pion.Mag() ) ); - if ( fTheta_Pion_Photon_RF < 0 ) { fTheta_Pion_Photon_RF = 180.0 + fTheta_Pion_Photon_RF; } - - fPhi = fPhi_Pion_LeptonPlane_RF; - fPhiS = fPhi_TargPol_LeptonPlane_RF; - - // ----------------------------------------------------------------------------------- - // If we have fermi momentum then epsilon should be in rest frame - // The theta angle of scattered angle used in expression of epsilon is the angle - // with respect to direction of incoming electron in the rest frame of target nucleon - // epsilon=1./(1.+ 2.*(pgam_restg**2)/q2g * *(tand(thscat_rest/2.))**2) - // ----------------------------------------------------------------------------------- - - double fTheta_EEp = (lelectron_rf.Vect()).Angle(lscatelec_rf.Vect()); - - fEpsilon = 1.0 / ( 1.0 + 2.0 * ( pow( (lphoton_rfg.Vect()).Mag(),2)/fQsq_GeV ) * pow( tan( fTheta_EEp / 2 ) , 2 ) ); - - // ---------------------------------------------------- - // Virtual Photon flux factor in units of 1/(GeV*Sr) - // ---------------------------------------------------- - fFlux_Factor_Col = (fAlpha/(2.0*pow(fPi,2))) * (lscatelecg.E() / lelectrong.E()) * - ( pow(fW_GeV,2) - pow(fProton_Mass_GeV,2) ) / (2.0*fProton_Mass_GeV*fQsq_GeV*(1.0 - fEpsilon)); - - fFlux_Factor_RF = ( fAlpha / ( 2.0 * pow( fPi , 2 ) ) ) * ( lscatelec_rfg.E() / lelectron_rfg.E() ) * - ( pow( fW_GeV , 2 ) - pow( fProton_Mass_GeV , 2 ) ) / - ( 2.0 * fProton_Mass_GeV * fQsq_GeV * ( 1.0 - fEpsilon ) ); - - // ---------------------------------------------------- - // Jacobian dt/dcos(theta*)dphi in units of GeV2/sr - // ---------------------------------------------------- - fJacobian_CM = ( (lphoton_rfg.Vect()).Mag() - fBeta_CM_RF * lphoton_rfg.E() ) / ( fGamma_CM_RF * ( 1.0 - pow(fBeta_CM_RF,2) ) ); - - fA = fJacobian_CM * fPion_Mom_CM_GeV / fPi; - - // ---------------------------------------------------- - // Jacobian dOmega* / dOmega dimensionless - // ---------------------------------------------------- - fJacobian_CM_RF = ( pow((lpion_rf.Vect()).Mag(),2)*fW) / - ( fPion_Mom_CM * std::abs( ( fProton_Mass + lphoton_rf.E()) * (lpion_rf.Vect()).Mag() - - ( lpion_rf.E() * (lphoton_rf.Vect()).Mag() * cos( lpion_rf.Theta() ) ) ) ); - - fJacobian_CM_Col = ( ( pow((lpion.Vect()).Mag(),2) * fW ) / - ( fPion_Mom_CM * std::abs( ( fProton_Mass + lphoton.E() ) * (lpion.Vect()).Mag() - - ( lpion.E() * (lphoton.Vect()).Mag() * cos( lpion.Theta() ) ) ) ) ); - - // ----------------------------------------------------------------------------------------------------------------------------- - // CKY sigma L and T starts - // ----------------------------------------------------------------------------------------------------------------------------- - - lpar0 = 0.; lpar1 = 0.; lpar2 = 0.; lpar3 = 0.; lpar4 = 0.; lpar5 = 0.; lpar6 = 0.; - tpar0 = 0.; tpar1 = 0.; tpar2 = 0.; tpar3 = 0.; tpar4 = 0.; - - fSig_L = 0; - fSig_T = 0; - - if ( ( fT_GeV > 0. ) && ( fT_GeV < 0.15 ) ) { - eicSigmaL( fW_GeV, fQsq_GeV, lpar0, lpar1, lpar2 , lpar3 , lpar4 , lpar5 , lpar6 ); - TF1 *fitCKYLonglandau = new TF1("sigmaL","landau", 0.0 , 0.15 ); - fitCKYLonglandau->FixParameter( 0 , lpar0 ); - fitCKYLonglandau->FixParameter( 1 , lpar1 ); - fitCKYLonglandau->FixParameter( 2 , lpar2 ); - fSig_L = fitCKYLonglandau->Eval(fT_GeV); - if ( lpar0 == 0 || lpar1 == 0 || lpar2 == 0 ) - fSig_L = 0; - fitCKYLonglandau = NULL; - delete fitCKYLonglandau; - } - else if ( ( fT_GeV > 0.15 ) && ( fT_GeV < 0.5 ) ) { - eicSigmaL( fW_GeV, fQsq_GeV, lpar0, lpar1, lpar2 , lpar3 , lpar4 , lpar5 , lpar6 ); - TF1 *fitCKYLongexpo1 = new TF1("sigmaL","expo", 0.15 , 0.5 ); - fitCKYLongexpo1->FixParameter( 0 , lpar3 ); - fitCKYLongexpo1->FixParameter( 1 , lpar4 ); - fSig_L = fitCKYLongexpo1->Eval(fT_GeV); - if ( lpar3 == 0 || lpar4 == 0 ) - fSig_L = 0; - fitCKYLongexpo1 = NULL; - delete fitCKYLongexpo1; - } - else if ( ( fT_GeV > 0.5 ) && ( fT_GeV < 1.3 ) ) { - eicSigmaL( fW_GeV, fQsq_GeV, lpar0, lpar1, lpar2 , lpar3 , lpar4 , lpar5 , lpar6 ); - TF1 *fitCKYLongexpo2 = new TF1("sigmaL","expo", 0.5 , 1.3 ); - fitCKYLongexpo2->FixParameter( 0 , lpar5 ); - fitCKYLongexpo2->FixParameter( 1 , lpar6 ); - fSig_L = fitCKYLongexpo2->Eval(fT_GeV); - if ( lpar5 == 0 || lpar6 == 0 ) - fSig_L = 0; - fitCKYLongexpo2 = NULL; - delete fitCKYLongexpo2; - } - else { - fSig_L = 0; - } - - // ------------------------------------------------------------------------------------------- - - if ( ( fT_GeV > 0.0 ) && ( fT_GeV < 0.15 ) ) { - eicSigmaT( fW_GeV, fQsq_GeV, tpar0, tpar1, tpar2 , tpar3 , tpar4 ); - TF1 *fitCKYTranspol2 = new TF1("sigmaL","pol2", 0.0 , 0.2 ); - fitCKYTranspol2->FixParameter( 0 , tpar0 ); - fitCKYTranspol2->FixParameter( 1 , tpar1 ); - fitCKYTranspol2->FixParameter( 2 , tpar2 ); - fSig_T = fitCKYTranspol2->Eval(fT_GeV); - if ( tpar0 == 0 || tpar1 == 0 || tpar2 == 0 ) - fSig_T = 0; - fitCKYTranspol2 = NULL; - delete fitCKYTranspol2; - } - else if ( ( fT_GeV > 0.2 ) && ( fT_GeV < 1.3 ) ) { - eicSigmaT( fW_GeV, fQsq_GeV, tpar0, tpar1, tpar2 , tpar3 , tpar4 ); - TF1 *fitCKYTransexpo = new TF1("sigmaL","expo", 0.2 , 1.3 ); - fitCKYTransexpo->FixParameter( 0 , tpar3 ); - fitCKYTransexpo->FixParameter( 1 , tpar4 ); - fSig_T = fitCKYTransexpo->Eval(fT_GeV); - if ( tpar3 == 0 || tpar4 == 0 ) - fSig_T = 0; - fitCKYTransexpo = NULL; - delete fitCKYTransexpo; - } - - // ------------------------------------------------------------------------------------------- - - fSig_VR = fSig_T + fEpsilon * fSig_L; - - // ----------------------------------------------------------------------------------------------------------------------------- - // CKY sigma L and T ends - // ----------------------------------------------------------------------------------------------------------------------------- - - fSigma_Col = fSig_VR * fFlux_Factor_Col * fA * fJacobian_CM_Col; - - // cout << endl; - // cout << setw(12) << "Qsq" << setw(12) << "-t" << setw(12) << "W" - // << setw(12) << "x" << setw(12) << "y" << setw(12) << "z" - // << setw(12) << "epsilon" << setw(12) << "phi" << setw(12) << "phis" - // << setw(12) << "sig" - // << endl; - // cout << setw(12) << fQsq_GeV << setw(12) << fT_GeV << setw(12) << fW_GeV - // << setw(12) << fx << setw(12) << fy << setw(12) << fz - // << setw(12) << fEpsilon << setw(12) << fPhi << setw(12) << fPhiS - // << setw(12) << fSigma_Col - // << endl; - - // cout << endl; - // cout << setw(12) << "Particle" << setw(12) << "Px" << setw(12) << "Py" << setw(12) << "Pz" << setw(12) << "Energy" << endl; - // cout << setw(12) << "Pion" - // << setw(12) << lpiong.X() - // << setw(12) << lpiong.Y() - // << setw(12) << lpiong.Z() - // << setw(12) << lpiong.E() - // << endl; - // cout << setw(12) << "Elec" - // << setw(12) << lscatelecg.X() - // << setw(12) << lscatelecg.Y() - // << setw(12) << lscatelecg.Z() - // << setw(12) << lscatelecg.E() - // << endl; - // cout << setw(12) << "Neutron" - // << setw(12) << lneutrong.X() - // << setw(12) << lneutrong.Y() - // << setw(12) << lneutrong.Z() - // << setw(12) << lneutrong.E() - // << endl; - - if ( ( fSigma_Col <= 0 ) || std::isnan( fSigma_Col ) ) { - fNSigmaNeg ++; - continue; - } - - // ------------------------------------------------------------------------------------------------------------------------------ - // ------------------------------------------------------------------------------------------------------------------------------ - // Lab cross section Phase Space Conversion Luminosity Total events tried - // Hz = ub / ( sr^2 * GeV ) * GeV * sr^2 * ( cm^2 / ub ) * ( # / ( cm^2 * sec ) ) / ( # ) - - fEventWeight = fSigma_Col * fPSF * fuBcm2 * fLumi / fNEvents; // in Hz - - fNRecorded ++; - fLundRecorded++; - fRatio = fNRecorded / fNGenerated; - - t1->Fill(); - ppiOut << "3" - << " \t " << fPhi // var 1 - << " \t " << fPhiS // var 2 - << " \t " << fx // var 3 - << " \t " << "1" - << " \t " << fQsq_GeV // var 4 - << " \t " << fT_GeV // var 5 - << " \t " << fW_GeV // var 6 - << " \t " << fEpsilon // var 7 - << " \t " << fEventWeight // var 8 - << endl; - - // Pion - - ppiOut << setw(10) << "1" - << setw(10) << "1" - << setw(10) << "1" - << setw(10) << "211" - << setw(10) << "0" - << setw(10) << "0" - << setw(16) << lpiong.X() - << setw(16) << lpiong.Y() - << setw(16) << lpiong.Z() - << setw(16) << lpiong.E() - << setw(16) << fPion_Mass_GeV - << setw(16) << fVertex_X - << setw(16) << fVertex_Y - << setw(16) << fVertex_Z - << endl; - - // Electron - ppiOut << setw(10) << "2" - << setw(10) << "-1" - << setw(10) << "1" - << setw(10) << "11" - << setw(10) << "0" - << setw(10) << "0" - << setw(16) << lscatelecg.X() - << setw(16) << lscatelecg.Y() - << setw(16) << lscatelecg.Z() - << setw(16) << lscatelecg.E() - << setw(16) << fElectron_Mass_GeV - << setw(16) << fVertex_X - << setw(16) << fVertex_Y - << setw(16) << fVertex_Z - << endl; - - // Neutron - ppiOut << setw(10) << "3" - << setw(10) << "1" - << setw(10) << "1" - << setw(10) << "2112" - << setw(10) << "0" - << setw(10) << "0" - << setw(16) << lneutrong.X() - << setw(16) << lneutrong.Y() - << setw(16) << lneutrong.Z() - << setw(16) << lneutrong.E() - << setw(16) << fNeutron_Mass_GeV - << setw(16) << fVertex_X - << setw(16) << fVertex_Y - << setw(16) << fVertex_Z - << endl; - - - // break; - - // } - } // This is the loop over total events. - - ppiOut.close(); - - t1->Write(); - - tTime.Stop(); - tTime.Print(); - // f->Close(); - TDatime deTime; - cout << "End Time: " << deTime.GetHour() << ":" << deTime.GetMinute() << endl; - - ppiDetails << "Total events tried " << setw(50) << fNGenerated << endl; - ppiDetails << "Total events recorded " << setw(50) << fNRecorded << endl; - - ppiDetails << "Number of events with w more than 10.6 " << setw(50) << w_ev << endl; - ppiDetails << "Number of events with wsq negative " << setw(50) << w_neg_ev << endl; - ppiDetails << "Number of events with qsq less than 4 " << setw(50) << qsq_ev << endl; - ppiDetails << "Number of events with -t more than threshold " << setw(50) << t_ev << endl; - - ppiDetails << "Number of events with w less than threshold " << setw(50) << fWSqNeg << endl; - ppiDetails << "Number of events with mom not conserve " << setw(50) << fNMomConserve << endl; - ppiDetails << "Number of events with Sigma negative " << setw(50) << fNSigmaNeg << endl; - ppiDetails << "Number of lund events " << setw(50) << fLundRecorded << endl; - - ppiDetails.close(); +// if (particle == "pi") { +// Exclusive_Pion_Prodoction(*myPim); +// } else if (particle == "omega") { +// Exclusive_Omega_Prodoction(*myPim); +// } else { +// cerr << "Choice of particle is not recognized." << endl; +// exit(0); +// } + +// TDatime dsTime; +// cout << "Start Time: " << dsTime.GetHour() << ":" << dsTime.GetMinute() << endl; + +// TStopwatch tTime; +// tTime.Start(); +// +// Exclusive_Pion_Prodoction(*myPim); +// +// tTime.Stop(); +// tTime.Print(); + + Reaction* r1 = new Reaction(particle); + r1->process_reaction(); + delete r1; } +/*--------------------------------------------------*/ +/*--------------------------------------------------*/ + + + + + + + + + + + + +void SetEICSeed (int seed) { + fSeed = seed; +} + + + + +///*--------------------------------------------------*/ +///*--------------------------------------------------*/ +/// Some utility functions + + +///*--------------------------------------------------*/ +/// Extracting the particle type + +TString ExtractParticle(TString particle) { + + /// Make the input particle case insansitive + particle.ToLower(); + + if (particle.Contains("on")) { + particle.ReplaceAll("on", ""); + }; + + if (particle.Contains("plus")) { + particle.ReplaceAll("plus", "+"); + } + + if (particle.Contains("minus")) { + particle.ReplaceAll("minus", "-"); + } + + if (particle.Contains("zero")) { + particle.ReplaceAll("zero", "0"); + } + + particle[0] = toupper(particle[0]); + + cout << "Particle: " << particle << endl; + + return particle; + +} + +///*--------------------------------------------------*/ +/// Extracting the particle charge + +TString ExtractCharge(TString particle) { + + TString charge; + + if (particle.Contains("+") || particle.Contains("plus")) { + charge = "+"; + } else if (particle.Contains("-") || particle.Contains("minus")) { + charge = "-"; + } else { + charge = "0"; + } + + return charge; + +} diff --git a/src/eic_evgen/eic.h b/src/eic_evgen/eic.h index de5774c..9739a3e 100644 --- a/src/eic_evgen/eic.h +++ b/src/eic_evgen/eic.h @@ -1,7 +1,6 @@ # ifndef EIC_H # define EIC_H - #include #include "TRandom.h" #include "TRandom2.h" @@ -11,7 +10,6 @@ #include "TVector3.h" #include "TLorentzVector.h" - #include #include #include @@ -22,792 +20,34 @@ #include #include #include -#include -#include #include #include #include +#include #include - - #include "eic_pim.h" -//#include "tssa_sigL_Para.h" -//#include "tssa_sigT_Para.h" - #include "tssa_sig_Para.h" +#include "reaction_rountine.h" +#include "legacy.h" +#include "json/json.h" +#include "json/json-forwards.h" void eic(); -void eic(int, int, int, TString); - +//void eic(int, int, int, TString, int, TString); +void eic(int, int, int, TString, int, TString, TString); +void eic(Json::Value); -//using namespace std; +extern int fSeed; -// -------------------------------------------------------------------------------------- -//TRandom2 *fRandom; +void SetEICSeed(int); -//TFile *f; - -///**************************************** -/// Bill: t1 is switched from an object to a pointer -//TTree t1("t1","Pion Form Fator Study"); - -//TTree *t1; - -//bool print; -//bool allset; -//bool kCalcFermi; -//bool kCalcBremss; -//bool kCalcIon; -//bool kCalcBremssEle; -//bool kCalcIonEle; -//bool kSConserve; -//bool kFSI; -//bool kMSele; -//bool kMS; - -//int fWLessShell; -//int fWLess1P9; -//int fSDiff; -// -//long int fNEvents; -//long int fNRecorded; -//long int fNGenerated; -//long int fWSqNeg; -//long int fNMomConserve; -//long int fNSigmaNeg; -//long int fLundRecorded; -//long int fNFile; -// -//double fK; -//double fm; -//double fElectron_Kin_Col_GeV; -//double fElectron_Kin_Col; -//double fRand; -//double fLumi; -//double fuBcm2; -//double fPI; -//double fDEG2RAD; -//double fRAD2DEG; -//double fEBeam; -//double fPBeam; -//double fScatElec_Theta_I; -//double fScatElec_Theta_F; -//double fPion_Theta_I; -//double fPion_Theta_F; -//double fScatElec_E_Hi; -//double fScatElec_E_Lo; -//double fPSF; -// -//double fMandSConserve; -//double fTop_Pion_Mom; -//double fBot_Pion_Mom; -//double fPion_Mom_Same; -//double fEnergyConserve; -//double fXMomConserve; -//double fYMomConserve; -//double fZMomConserve; -//double fXMomConserve_RF; -//double fYMomConserve_RF; -//double fZMomConserve_RF; -//double fEnergyConserve_RF; -// -//double fDiff; -//double fRatio; -//double fPion_Alpha; -//double fPion_Beta; -//double fS_I_RF; -//double fS_F_RF; -//double fS_I_Col; -//double fS_F_Col; -//double fS_I_RF_GeV; -//double fS_F_RF_GeV; -//double fS_I_Col_GeV; -//double fS_F_Col_GeV; -// -//double fProton_Energy_Col; -//double fProton_Mom_Col; -//double fProton_Theta_Col; -//double fProton_Phi_Col; -//double fProton_MomZ_Col; -//double fProton_MomX_Col; -//double fProton_MomY_Col; -//double fProton_Energy_Col_GeV; -//double fProton_Mom_Col_GeV; -//double fProton_MomX_Col_GeV; -//double fProton_MomY_Col_GeV; -//double fProton_MomZ_Col_GeV; -// -//double fFSIProton_Energy_Col; -//double fFSIProton_Mom_Col; -//double fFSIProton_Theta_Col; -//double fFSIProton_Phi_Col; -//double fFSIProton_MomZ_Col; -//double fFSIProton_MomX_Col; -//double fFSIProton_MomY_Col; -//double fFSIProton_Energy_Col_GeV; -//double fFSIProton_Mom_Col_GeV; -//double fFSIProton_MomX_Col_GeV; -//double fFSIProton_MomY_Col_GeV; -//double fFSIProton_MomZ_Col_GeV; -// -//double fTarget_Energy_Col; -//double fTarget_Mom_Col; -//double fTarget_Theta_Col; -//double fTarget_Phi_Col; -//double fTarget_MomZ_Col; -//double fTarget_MomX_Col; -//double fTarget_MomY_Col; -//double fTarget_Energy_Col_GeV; -//double fTarget_Mom_Col_GeV; -//double fTarget_MomX_Col_GeV; -//double fTarget_MomY_Col_GeV; -//double fTarget_MomZ_Col_GeV; -// -//double fTarget_Pol0_Col; -//double fTarget_PolX_Col; -//double fTarget_PolY_Col; -//double fTarget_PolZ_Col; -//double fTarget_Pol0_RF; -//double fTarget_PolX_RF; -//double fTarget_PolY_RF; -//double fTarget_PolZ_RF; -// -//double fBetaX_Col_RF; -//double fBetaY_Col_RF; -//double fBetaZ_Col_RF; -//double fBeta_Col_RF; -//double fGamma_Col_RF; -// -//double fProton_MomX_RF; -//double fProton_MomY_RF; -//double fProton_MomZ_RF; -//double fProton_Mom_RF; -//double fProton_Energy_RF; -//double fProton_MomX_RF_GeV; -//double fProton_MomY_RF_GeV; -//double fProton_MomZ_RF_GeV; -//double fProton_Mom_RF_GeV; -//double fProton_Energy_RF_GeV; -// -//double fScatElec_Angle; -//double fScatElec_Alpha_RF; -//double fScatElec_Beta_RF; -// -//double fVertex_X; -//double fVertex_Y; -//double fVertex_Z; -//double fProton_Kin_Col_GeV; -//double fElectron_Mass; -//double fElectron_Mass_GeV; -//double fProton_Mass; -//double fProton_Mass_GeV; -//double fNeutron_Mass; -//double fNeutron_Mass_GeV; -//double fPion_Mass; -//double fPion_Mass_GeV; -//double fPiion_Phi; -//double fAlpha; -//double fPi; -//double fMom_Ratio; -//double fMom_Dif; -//double fPionEnergyCMLess; -//double fSNotEqual; -//double fMode_Epsi; -//double fRecoilProton_Mass; -//double fRecoilProton_Mass_GeV; -// -//double fElectron_Energy_Col; -//double fElectron_MomZ_Col; -//double fElectron_MomX_Col; -//double fElectron_MomY_Col; -//double fElectron_Theta_Col; -//double fElectron_Phi_Col; -//double fElectron_Mom_Col; -// -//double fElectron_MS_Energy_Col; -//double fElectron_MS_MomZ_Col; -//double fElectron_MS_MomX_Col; -//double fElectron_MS_MomY_Col; -//double fElectron_MS_Theta_Col; -//double fElectron_MS_Phi_Col; -//double fElectron_MS_Mom_Col; -// -//double fElectron_Energy_Col_GeV; -//double fElectron_Mom_Col_GeV; -//double fElectron_MomX_Col_GeV; -//double fElectron_MomY_Col_GeV; -//double fElectron_MomZ_Col_GeV; -//double fElectronEnergyLess; -//double fElectronThetaLess; -//double fRadiation_Lenght_Air; -// -//double fElectron_Targ_Thickness; -//double fElectron_Targ_Thickness_RadLen; -//double fElectron_Targ_BT; -//double fElectron_Targ_Bremss_Loss; -//double fElectron_Targ_Ion_Loss; -//double fElectron_TargWindow_Bremss_Loss; -//double fElectron_TargWindow_Ion_Loss; -// -//double fElectron_Air_Thickness; -//double fElectron_Air_Thickness_RadLen; -//double fElectron_Air_BT; -//double fElectron_Air_Bremss_Loss; -//double fElectron_Air_Ion_Loss; -//double fElectron_Corrected_Energy_Col; -//double fElectron_Corrected_Mom_Col; -//double fElectron_Corrected_MomX_Col; -//double fElectron_Corrected_MomY_Col; -//double fElectron_Corrected_MomZ_Col; -//double fElectron_Corrected_Theta_Col; -//double fElectron_Corrected_Phi_Col; -//double fElectron_Delta_Mom_Col; -//double fElectron_Corrected_Energy_Col_GeV; -//double fElectron_Corrected_Mom_Col_GeV; -//double fElectron_Corrected_MomX_Col_GeV; -//double fElectron_Corrected_MomY_Col_GeV; -//double fElectron_Corrected_MomZ_Col_GeV; -//double fElectron_Delta_Mom_Col_GeV; -// -//double fScatElec_MS_Energy_Col; -//double fScatElec_MS_MomZ_Col; -//double fScatElec_MS_MomX_Col; -//double fScatElec_MS_MomY_Col; -//double fScatElec_MS_Theta_Col; -//double fScatElec_MS_Phi_Col; -//double fScatElec_MS_Mom_Col; -// -//double fScatElec_Energy_Col; -//double fScatElec_MomZ_Col; -//double fScatElec_MomX_Col; -//double fScatElec_MomY_Col; -//double fScatElec_Theta_Col; -//double fScatElec_Phi_Col; -//double fScatElec_Mom_Col; -//double fScatElec_Energy_Col_GeV; -//double fScatElec_Mom_Col_GeV; -//double fScatElec_MomX_Col_GeV; -//double fScatElec_MomY_Col_GeV; -//double fScatElec_MomZ_Col_GeV; -//double fScatElecEnergyLess; -//double fScatElecThetaLess; -//double fScatElec_Targ_Thickness; -//double fScatElec_Targ_Thickness_RadLen; -//double fScatElec_Targ_BT; -//double fScatElec_Targ_Bremss_Loss; -//double fScatElec_Targ_Ion_Loss; -//double fScatElec_Air_Thickness; -//double fScatElec_Air_Thickness_RadLen; -//double fScatElec_Air_BT; -//double fScatElec_Air_Bremss_Loss; -//double fScatElec_Air_Ion_Loss; -//double fScatElec_Corrected_Energy_Col; -//double fScatElec_Corrected_Mom_Col; -//double fScatElec_Corrected_MomX_Col; -//double fScatElec_Corrected_MomY_Col; -//double fScatElec_Corrected_MomZ_Col; -//double fScatElec_Corrected_Theta_Col; -//double fScatElec_Corrected_Phi_Col; -//double fScatElec_Delta_Mom_Col; -//double fScatElec_Corrected_Energy_Col_GeV; -//double fScatElec_Corrected_Mom_Col_GeV; -//double fScatElec_Corrected_MomX_Col_GeV; -//double fScatElec_Corrected_MomY_Col_GeV; -//double fScatElec_Corrected_MomZ_Col_GeV; -//double fScatElec_Delta_Mom_Col_GeV; -//double fScatElec_TargWindow_Bremss_Loss; -//double fScatElec_TargWindow_Ion_Loss; -//double fTargWindow_Thickness; -//double fTargWindow_Thickness_RadLen; -//double fTargWindow_BT; -// -//double fPion_TargWindow_Ion_Loss; -//double fPion_Targ_Thickness; -//double fPion_Targ_Thickness_RadLen; -//double fPion_Targ_BT; -//double fPion_Targ_Bremss_Loss; -//double fPion_Targ_Ion_Loss; -//double fPion_Air_Thickness; -//double fPion_Air_Thickness_RadLen; -//double fPion_Air_BT; -//double fPion_Air_Bremss_Loss; -//double fPion_Air_Ion_Loss; -// -//double fPion_MS_Energy_Col; -//double fPion_MS_MomZ_Col; -//double fPion_MS_MomX_Col; -//double fPion_MS_MomY_Col; -//double fPion_MS_Theta_Col; -//double fPion_MS_Phi_Col; -//double fPion_MS_Mom_Col; -// -//double fPion_Theta_Col; -//double fPion_Phi_Col; -//double fPion_Energy_Col; -//double fPion_Mom_Col; -//double fPion_MomZ_Col; -//double fPion_MomX_Col; -//double fPion_MomY_Col; -//double fPion_Energy_Col_GeV; -//double fPion_Mom_Col_GeV; -//double fPion_MomX_Col_GeV; -//double fPion_MomY_Col_GeV; -//double fPion_MomZ_Col_GeV; -// -//double fPion_FSI_Theta_Col; -//double fPion_FSI_Phi_Col; -//double fPion_FSI_Energy_Col; -//double fPion_FSI_Mom_Col; -//double fPion_FSI_MomZ_Col; -//double fPion_FSI_MomX_Col; -//double fPion_FSI_MomY_Col; -//double fPion_FSI_Energy_Col_GeV; -//double fPion_FSI_Mom_Col_GeV; -//double fPion_FSI_MomX_Col_GeV; -//double fPion_FSI_MomY_Col_GeV; -//double fPion_FSI_MomZ_Col_GeV; -// -//double fPion_Corrected_Theta_Col; -//double fPion_Corrected_Phi_Col; -//double fPion_Corrected_Energy_Col; -//double fPion_Corrected_Mom_Col; -//double fPion_Corrected_MomX_Col; -//double fPion_Corrected_MomY_Col; -//double fPion_Corrected_MomZ_Col; -//double fPion_Delta_Mom_Col; -//double fPion_Corrected_Energy_Col_GeV; -//double fPion_Corrected_Mom_Col_GeV; -//double fPion_Corrected_MomX_Col_GeV; -//double fPion_Corrected_MomY_Col_GeV; -//double fPion_Corrected_MomZ_Col_GeV; -//double fPion_Delta_Mom_Col_GeV; -// -//double fNeutron_MS_Energy_Col; -//double fNeutron_MS_MomZ_Col; -//double fNeutron_MS_MomX_Col; -//double fNeutron_MS_MomY_Col; -//double fNeutron_MS_Theta_Col; -//double fNeutron_MS_Phi_Col; -//double fNeutron_MS_Mom_Col; -// -//double fNeutron_TargWindow_Ion_Loss; -//double fNeutron_Targ_Thickness; -//double fNeutron_Targ_Thickness_RadLen; -//double fNeutron_Targ_BT; -//double fNeutron_Targ_Bremss_Loss; -//double fNeutron_Targ_Ion_Loss; -//double fNeutron_Air_Thickness; -//double fNeutron_Air_Thickness_RadLen; -//double fNeutron_Air_BT; -//double fNeutron_Air_Bremss_Loss; -//double fNeutron_Air_Ion_Loss; -//double fNeutron_Theta_Col; -//double fNeutron_Phi_Col; -//double fNeutron_Energy_Col; -//double fNeutron_Mom_Col; -//double fNeutron_MomZ_Col; -//double fNeutron_MomX_Col; -//double fNeutron_MomY_Col; -//double fNeutron_Energy_Col_GeV; -//double fNeutron_Mom_Col_GeV; -//double fNeutron_MomX_Col_GeV; -//double fNeutron_MomY_Col_GeV; -//double fNeutron_MomZ_Col_GeV; -//double fNeutron_Corrected_Theta_Col; -//double fNeutron_Corrected_Phi_Col; -//double fNeutron_Corrected_Energy_Col; -//double fNeutron_Corrected_Mom_Col; -//double fNeutron_Corrected_MomX_Col; -//double fNeutron_Corrected_MomY_Col; -//double fNeutron_Corrected_MomZ_Col; -//double fNeutron_Delta_Mom_Col; -//double fNeutron_Corrected_Energy_Col_GeV; -//double fNeutron_Corrected_Mom_Col_GeV; -//double fNeutron_Corrected_MomX_Col_GeV; -//double fNeutron_Corrected_MomY_Col_GeV; -//double fNeutron_Corrected_MomZ_Col_GeV; -//double fNeutron_Delta_Mom_Col_GeV; -// -//double fRecoilProton_Energy_RF; -//double fRecoilProton_Mom_RF; -//double fRecoilProton_MomX_RF; -//double fRecoilProton_MomY_RF; -//double fRecoilProton_MomZ_RF; -//double fRecoilProton_Energy_RF_GeV; -//double fRecoilProton_Mom_RF_GeV; -//double fRecoilProton_MomX_RF_GeV; -//double fRecoilProton_MomY_RF_GeV; -//double fRecoilProton_MomZ_RF_GeV; -//double fRecoilProton_Theta_RF; -//double fRecoilProton_Phi_RF; -// -//double fRecoilProton_Targ_Thickness; -//double fRecoilProton_Targ_Thickness_RadLen; -//double fRecoilProton_Targ_BT; -//double fRecoilProton_Targ_Bremss_Loss; -//double fRecoilProton_Targ_Ion_Loss; -//double fRecoilProton_Air_Thickness; -//double fRecoilProton_Air_Thickness_RadLen; -//double fRecoilProton_Air_BT; -//double fRecoilProton_Air_Bremss_Loss; -//double fRecoilProton_Air_Ion_Loss; -//double fRecoilProton_Theta_Col; -//double fRecoilProton_Phi_Col; -//double fRecoilProton_Energy_Col; -//double fRecoilProton_Mom_Col; -//double fRecoilProton_MomZ_Col; -//double fRecoilProton_MomX_Col; -//double fRecoilProton_MomY_Col; -//double fRecoilProton_Energy_Col_GeV; -//double fRecoilProton_Mom_Col_GeV; -//double fRecoilProton_MomX_Col_GeV; -//double fRecoilProton_MomY_Col_GeV; -//double fRecoilProton_MomZ_Col_GeV; -//double fRecoilProton_Corrected_Theta_Col; -//double fRecoilProton_Corrected_Phi_Col; -//double fRecoilProton_Corrected_Energy_Col; -//double fRecoilProton_Corrected_Mom_Col; -//double fRecoilProton_Corrected_MomX_Col; -//double fRecoilProton_Corrected_MomY_Col; -//double fRecoilProton_Corrected_MomZ_Col; -//double fRecoilProton_Delta_Mom_Col; -//double fRecoilProton_Corrected_Energy_Col_GeV; -//double fRecoilProton_Corrected_Mom_Col_GeV; -//double fRecoilProton_Corrected_MomX_Col_GeV; -//double fRecoilProton_Corrected_MomY_Col_GeV; -//double fRecoilProton_Corrected_MomZ_Col_GeV; -//double fRecoilProton_Delta_Mom_Col_GeV; -// -//double fSSAsym; -//double fSineAsym; -//double fInvariantDif; -//double fT_GeV; -//double fProton_Kin_Col; -//double fQsq_Value; -//double fQsq_Dif; -//double fQsq_GeV; -//double fQsq; -//double fW_GeV_Col; -//double fW_Col; -//double fW; -//double fW_GeV; -//double fW_Prime_GeV; -//double fW_Corrected_Prime_GeV; -//double fWSq; -//double fWSq_GeV; -//double fWSq_PiN; -//double fWSq_PiN_GeV; -//double fWSq_Top_PiN_GeV; -//double fWSq_Bot_PiN_GeV; -// -//double fElec_ScatElec_Theta_RF; -//double fScatElec_Cone_Phi_RF; -//double fScatElec_Theta_RF; -//double fScatElec_Phi_RF; -//double fScatElec_Mom_RF; -//double fScatElec_Energy_RF; -//double fScatElec_MomX_RF; -//double fScatElec_MomZ_RF; -//double fScatElec_MomY_RF; -//double fScatElec_Energy_RF_GeV; -//double fScatElec_Mom_RF_GeV; -//double fScatElec_MomX_RF_GeV; -//double fScatElec_MomY_RF_GeV; -//double fScatElec_MomZ_RF_GeV; -// -//double fElectron_Theta_RF; -//double fElectron_Phi_RF; -//double fElectron_Energy_RF; -//double fElectron_Mom_RF; -//double fElectron_MomX_RF; -//double fElectron_MomZ_RF; -//double fElectron_MomY_RF; -//double fElectron_Energy_RF_GeV; -//double fElectron_Mom_RF_GeV; -//double fElectron_MomX_RF_GeV; -//double fElectron_MomZ_RF_GeV; -//double fElectron_MomY_RF_GeV; -// -//double fPhoton_Energy_RF_GeV; -//double fPhoton_Mom_RF_GeV; -//double fPhoton_Energy_RF; -//double fPhoton_Mom_RF; -// -//double fProton_Energy_CM; -//double fProton_Mom_CM; -//double fProton_Energy_CM_GeV; -//double fProton_Mom_CM_GeV; -//double fPhoton_Energy_CM; -//double fPhoton_Mom_CM; -//double fPhoton_Energy_CM_GeV; -//double fPhoton_Mom_CM_GeV; -//double fPion_Theta_CM; -//double fPion_Phi_CM; -//double fPion_Energy_CM; -//double fPion_Mom_CM; -//double fPion_Energy_CM_GeV; -//double fPion_Mom_CM_GeV; -//double fNeutron_Theta_CM; -//double fNeutron_Phi_CM; -//double fNeutron_Energy_CM; -//double fNeutron_Energy_CM_GeV; -//double fNeutron_Mom_CM; -//double fNeutron_Mom_CM_GeV; -// -//double fBeta_CM_RF; -//double fGamma_CM_RF; -// -//double fPhoton_MomZ_RF; -//double fPhoton_MomX_RF; -//double fPhoton_MomY_RF; -//double fPhoton_Theta_RF; -//double fPhoton_Phi_RF; -//double fPion_Energy_RF; -//double fPion_Energy_RF_GeV; -//double fPiqVec_Theta_RF; -//double fPion_Mom_RF; -//double fPion_Mom_RF_GeV; -//double fPion_MomX_RF; -//double fPion_MomY_RF; -//double fPion_MomZ_RF; -//double fPion_Theta_RF; -//double fPion_Phi_RF; -//double fPion_MomX_RF_GeV; -//double fPion_MomY_RF_GeV; -//double fPion_MomZ_RF_GeV; -// -// -//double fT_Para; -//double fT_Para_GeV; -//double fT; -//double fEpsilon; -//double fx; -//double fy; -//double fz; -//double fNeutron_Energy_RF; -//double fNeutron_Energy_RF_GeV; -//double fNeutron_Mom_RF; -//double fNeutron_Mom_RF_GeV; -//double fNeutron_qVec_Theta_RF; -//double fNeutron_MomX_RF; -//double fNeutron_MomY_RF; -//double fNeutron_MomZ_RF; -//double fNeutron_Theta_RF; -//double fNeutron_Phi_RF; -//double fPhoton_MomX_RF_GeV; -//double fPhoton_MomY_RF_GeV; -//double fPhoton_MomZ_RF_GeV; -//double fNeutron_MomX_RF_GeV; -//double fNeutron_MomY_RF_GeV; -//double fNeutron_MomZ_RF_GeV; -// -//double fPhoton_Theta_Col; -//double fPhoton_Phi_Col; -//double fPhoton_Energy_Col; -//double fPhoton_Mom_Col; -//double fPhoton_MomX_Col; -//double fPhoton_MomZ_Col; -//double fPhoton_MomY_Col; -//double fPhoton_Energy_Col_GeV; -//double fPhoton_Mom_Col_GeV; -//double fPhoton_MomX_Col_GeV; -//double fPhoton_MomZ_Col_GeV; -//double fPhoton_MomY_Col_GeV; -// -//double fPhoton_Corrected_Theta_Col; -//double fPhoton_Corrected_Phi_Col; -//double fPhoton_Corrected_Energy_Col; -//double fPhoton_Corrected_Mom_Col; -//double fPhoton_Corrected_MomX_Col; -//double fPhoton_Corrected_MomZ_Col; -//double fPhoton_Corrected_MomY_Col; -//double fPhoton_Corrected_Energy_Col_GeV; -//double fPhoton_Corrected_Mom_Col_GeV; -//double fPhoton_Corrected_MomX_Col_GeV; -//double fPhoton_Corrected_MomZ_Col_GeV; -//double fPhoton_Corrected_MomY_Col_GeV; -// -//double fQsq_Corrected_GeV; -//double fQsq_Corrected; -//double fW_Corrected; -//double fW_Corrected_GeV; -//double fT_Corrected; -//double fT_Corrected_GeV; -//double fx_Corrected; -//double fy_Corrected; -//double fz_Corrected; -// -//double fWFactor; -//double fA; -//double fFlux_Factor_Col; -//double fFlux_Factor_RF; -//double fJacobian_CM; -//double fJacobian_CM_RF; -//double fJacobian_CM_Col; -//double fZASig_T; -//double fZASig_L; -//double fZASig_LT; -//double fZASig_TT; -//double ftestsig; -//double fZASig_L2; -// -//double fZASigma_UU; -//double fRorySigma_UT; -//double fSigma_Col; -//double fSigma_UUPara; -//double fSig_VR; -//double fSig_L; -//double fSig_T; -// -//double fSigmaPhiS; -//double fSigmaPhi_Minus_PhiS; -//double fSigma2Phi_Minus_PhiS; -//double fSigma3Phi_Minus_PhiS; -//double fSigmaPhi_Plus_PhiS; -//double fSigma2Phi_Plus_PhiS; -//double fSig_Phi_Minus_PhiS; -//double fSig_PhiS; -//double fSig_2Phi_Minus_PhiS; -//double fSig_Phi_Plus_PhiS; -//double fSig_3Phi_Minus_PhiS; -//double fSig_2Phi_Plus_PhiS; -//double fEventWeight; -//double fEventWeightMax; -//double fZAWFactor; -//double fRR; -//double fPhaseSpaceWeight; -//double fPhaseShiftWeight; -//double fWilliamsWeight; -//double fDedrickWeight; -//double fCatchenWeight; -//double fPhi; -//double fPhiS; -//double fPhi_Corrected; -//double fPhiS_Corrected; -// -//double fElectron_Mom_Sq_RF; -//double fElectron_Mom_Sq_Col; -//double fProton_Mom_Sq_Col; -//double fProton_Mom_Sq_CM; -//double fProton_Mom_Sq_RF; -//double fPhoton_Mom_Sq_Col; -//double fPhoton_Mom_Sq_CM; -//double fPhoton_Mom_Sq_RF; -//double fPion_Mom_Sq_Col; -//double fPion_Mom_Sq_CM; -//double fPion_Mom_Sq_RF; -//double fNeutron_Mom_Sq_Col; -//double fNeutron_Mom_Sq_CM; -//double fNeutron_Mom_Sq_RF; -//double fScatElec_Mom_Sq_Col; -//double fScatElec_Mom_Sq_RF; -// -//double fAsymPhiMinusPhi_S; -//double fAsymPhi_S; -//double fAsym2PhiMinusPhi_S; -//double fAsymPhiPlusPhi_S; -//double fAsym3PhiMinusPhi_S; -//double fAsym2PhiPlusPhi_S; -// -//double fTerm_PhiMinusPhi_S; -//double fTerm_Phi_S; -//double fTerm_2PhiMinusPhi_S; -//double fTerm_PhiPlusPhi_S; -//double fTerm_3PhiMinusPhi_S; -//double fTerm_2PhiPlusPhi_S; -// -//double fAsymPhiMinusPhi_S_Col; -//double fAsymPhi_S_Col; -//double fAsym2PhiMinusPhi_S_Col; -//double fAsymPhiPlusPhi_S_Col; -//double fAsym3PhiMinusPhi_S_Col; -//double fAsym2PhiPlusPhi_S_Col; -// -//double fTerm_PhiMinusPhi_S_Col; -//double fTerm_Phi_S_Col; -//double fTerm_2PhiMinusPhi_S_Col; -//double fTerm_PhiPlusPhi_S_Col; -//double fTerm_3PhiMinusPhi_S_Col; -//double fTerm_2PhiPlusPhi_S_Col; -// -//double fPhi_Pion_LeptonPlane_RF; -//double fCos_Phi_Pion_LeptonPlane_RF; -//double fSin_Phi_Pion_LeptonPlane_RF; -//double fPhi_TargPol_LeptonPlane_RF; -//double fCos_Phi_TargPol_LeptonPlane_RF; -//double fSin_Phi_TargPol_LeptonPlane_RF; -//double fTheta_Pion_Photon_RF; -//double fPhi_Pion_LeptonPlane_Col; -//double fCos_Phi_Pion_LeptonPlane_Col; -//double fSin_Phi_Pion_LeptonPlane_Col; -//double fPhi_TargPol_LeptonPlane_Col; -//double fCos_Phi_TargPol_LeptonPlane_Col; -//double fSin_Phi_TargPol_LeptonPlane_Col; -//double fTheta_Pion_Photon_Col; -// -//double fZASigma_UU_Col; -//double fRorySigma_UT_Col; -//double fSig_Phi_Minus_PhiS_Col; -//double fSig_PhiS_Col; -//double fSig_2Phi_Minus_PhiS_Col; -//double fSig_Phi_Plus_PhiS_Col; -//double fSig_3Phi_Minus_PhiS_Col; -//double fSig_2Phi_Plus_PhiS_Col; -// -//double fepi1; -//double fepi2; -//double fradical; -// -//double fMomentum[300]; -//double fProb[300] = { -//6.03456, 6.02429, 6.01155, 5.99636, 5.97873, 5.95869, 5.93626, 5.91147, 5.88435, 5.85493, -//5.82325, 5.78935, 5.75326, 5.71504, 5.67472, 5.63235, 5.58799, 5.54169, 5.4935, 5.44347, -//5.39167, 5.33816, 5.28299, 5.22623, 5.16794, 5.10818, 5.04703, 4.98455, 4.92081, 4.85588, -//4.78982, 4.71692, 4.63621, 4.55583, 4.47582, 4.39621, 4.31702, 4.23828, 4.16002, 4.08227, -//4.00506, 3.9284, 3.85233, 3.77686, 3.70202, 3.62783, 3.55432, 3.48149, 3.40937, 3.33798, -//3.26733, 3.19745, 3.12834, 3.06002, 2.99251, 2.92581, 2.85995, 2.79493, 2.73075, 2.66744, -//2.605, 2.54344, 2.48276, 2.41728, 2.35244, 2.28922, 2.22759, 2.16751, 2.10895, 2.05186, -//1.99621, 1.94198, 1.88913, 1.83762, 1.78743, 1.73851, 1.69086, 1.64442, 1.59918, 1.55511, -//1.51217, 1.47035, 1.42961, 1.38993, 1.35128, 1.31364, 1.27698, 1.24129, 1.20653, 1.17269, -//1.13973, 1.10765, 1.07642, 1.04601, 1.01626, 0.986934, 0.958443, 0.930759, 0.903861, 0.877727, -//0.852335, 0.827665, 0.803696, 0.780409, 0.757785, 0.735806, 0.714452, 0.693708, 0.673555, 0.653978, -//0.63496, 0.616485, 0.598538, 0.581105, 0.56417, 0.547721, 0.531743, 0.516223, 0.501148, 0.486506, -//0.472284, 0.45847, 0.445054, 0.432024, 0.419368, 0.407077, 0.395125, 0.383513, 0.372237, 0.361289, -//0.350658, 0.340336, 0.330314, 0.320583, 0.311135, 0.301962, 0.293056, 0.284409, 0.276014, 0.267863, -//0.25995, 0.252268, 0.244809, 0.237569, 0.230539, 0.223715, 0.217091, 0.21066, 0.204417, 0.198357, -//0.192474, 0.186763, 0.181219, 0.175838, 0.170615, 0.165545, 0.160623, 0.155843, 0.151185, 0.146666, -//0.142282, 0.138028, 0.133902, 0.129898, 0.126013, 0.122245, 0.118588, 0.115041, 0.111599, 0.108261, -//0.105021, 0.101879, 0.0988298, 0.0958719, 0.0930022, 0.0902182, 0.0875173, 0.084897, 0.0823549, 0.0798886, -//0.0774961, 0.0751749, 0.0729231, 0.0707385, 0.0686192, 0.0665631, 0.0645685, 0.0626335, 0.0607563, 0.0589545, -//0.057219, 0.0555322, 0.053893, 0.0523001, 0.0507522, 0.0492481, 0.0477867, 0.0463667, 0.0449872, 0.0436468, -//0.0423448, 0.0410798, 0.0398511, 0.0386576, 0.0374982, 0.0363722, 0.0352785, 0.0342164, 0.0331849, 0.0321831, -//0.0312104, 0.0302658, 0.0293486, 0.0284581, 0.0275935, 0.026754, 0.0259391, 0.0251479, 0.0243799, 0.0236344, -//0.0229107, 0.0221901, 0.0214923, 0.0208167, 0.0201626, 0.0195293, 0.0189162, 0.0183226, 0.0177478, 0.0171913, -//0.0166525, 0.0161308, 0.0156257, 0.0151366, 0.0146629, 0.0142044, 0.0137603, 0.0133303, 0.0129139, 0.0125107, -//0.0121203, 0.0117421, 0.011376, 0.0110214, 0.010678, 0.0103455, 0.0100234, 0.00971153, 0.00940947, 0.00911693, -//0.00883361, 0.0085592, 0.00829385, 0.00803735, 0.00778883, 0.00754804, 0.00731474, 0.0070887, 0.00686967, 0.00665746, -//0.00645184, 0.00625261, 0.00605957, 0.00587252, 0.00569128, 0.00551567, 0.00534551, 0.00518063, 0.00502086, 0.00486605, -//0.00471604, 0.00457069, 0.00442984, 0.00429336, 0.0041611, 0.00403295, 0.00390877, 0.00378843, 0.00367182, 0.00355882, -//0.00344932, 0.00334321, 0.00324038, 0.00314073, 0.00304505, 0.0029524, 0.00286252, 0.00277533, 0.00269076, 0.00260872, -//0.00252913, 0.00245194, 0.00237706, 0.00230444, 0.00223399, 0.00216566, 0.00209939, 0.00203512, 0.00197277, 0.00191231 }; -// - -//class pim { -// -// public: -// double test(); -// void Initilize(); -// int CheckLaws(TLorentzVector P_E0, TLorentzVector P_t, TLorentzVector P_e, TLorentzVector P_pim, TLorentzVector P_pro); -// void setrootfile( string myRootFile ); -// double fermiMomentum(); -// /* double correctedPhi(); */ -// /* double correctedPhiS(); */ -// -//}; +TString ExtractParticle(TString); +TString ExtractCharge(TString) ; #endif + diff --git a/src/eic_evgen/eic.o b/src/eic_evgen/eic.o index 26a7b6b..c17bcb6 100644 Binary files a/src/eic_evgen/eic.o and b/src/eic_evgen/eic.o differ diff --git a/src/eic_evgen/eic_pim.cc b/src/eic_evgen/eic_pim.cc index b523bb4..0458377 100644 --- a/src/eic_evgen/eic_pim.cc +++ b/src/eic_evgen/eic_pim.cc @@ -11,26 +11,38 @@ /// Comment: Feb 24, 2020: all declearation of the global variables // and all functions for pim class are moved there - - - - #include "eic_pim.h" using namespace std; - -TRandom2 *fRandom; +//TRandom2 *fRandom; +TRandom3 *fRandom; TFile *f; TTree *t1; +int gKinematics_type; +bool gPi0_decay; +string gDet_location; +float fProton_incidence_phi; + +TString gfile_name; + +int fSeed; + bool allset, print, kCalcFermi, kCalcBremss, kCalcIon, kCalcBremssEle, kCalcIonEle, kSConserve, kFSI, kMSele, kMS; int fWLessShell, fWLess1P9, fSDiff; -long int fNEvents, fNRecorded, fNGenerated, fWSqNeg, fNMomConserve, fNSigmaNeg, fLundRecorded, fNFile; + +//long int fNEvents, fNRecorded, fNGenerated, fWSqNeg, fNMomConserve, fNSigmaNeg, fNWeightUnphys, fNWeightReject, fLundRecorded, fNFile; + +unsigned long long int fNEvents, fNRecorded, fNGenerated, fWSqNeg, fNMomConserve, fNSigmaNeg, fNWeightUnphys, fNWeightReject, fLundRecorded, fNFile; double fK, fm, fElectron_Kin_Col_GeV, fElectron_Kin_Col, fRand, fLumi, fuBcm2, fPI, fDEG2RAD, fRAD2DEG, fEBeam, fPBeam, fScatElec_Theta_I, fScatElec_Theta_F, fPion_Theta_I, fPion_Theta_F, fScatElec_E_Hi, fScatElec_E_Lo, fPSF; + +double fOmega_Theta_I, fOmega_Theta_F, fOmega_Theta_Col, fOmega_Phi_Col; + + double fMandSConserve, fTop_Pion_Mom, fBot_Pion_Mom, fPion_Mom_Same, fEnergyConserve, fXMomConserve, fYMomConserve, fZMomConserve, fXMomConserve_RF, fYMomConserve_RF, fZMomConserve_RF, fEnergyConserve_RF; double fDiff, fRatio, fPion_Alpha, fPion_Beta, fS_I_RF, fS_F_RF, fS_I_Col, fS_F_Col, fS_I_RF_GeV, fS_F_RF_GeV, fS_I_Col_GeV, fS_F_Col_GeV; @@ -51,6 +63,8 @@ double fScatElec_Angle, fScatElec_Alpha_RF, fScatElec_Beta_RF; double fVertex_X, fVertex_Y, fVertex_Z, fProton_Kin_Col_GeV, fElectron_Mass, fElectron_Mass_GeV, fProton_Mass, fProton_Mass_GeV, fNeutron_Mass, fNeutron_Mass_GeV, fPion_Mass, fPion_Mass_GeV, fPiion_Phi, fAlpha, fPi, fMom_Ratio, fMom_Dif, fPionEnergyCMLess, fSNotEqual, fMode_Epsi, fRecoilProton_Mass, fRecoilProton_Mass_GeV; +double fOmega_Mass, fOmega_Mass_GeV; + double fElectron_Energy_Col, fElectron_MomZ_Col, fElectron_MomX_Col, fElectron_MomY_Col, fElectron_Theta_Col, fElectron_Phi_Col, fElectron_Mom_Col; double fElectron_MS_Energy_Col, fElectron_MS_MomZ_Col, fElectron_MS_MomX_Col, fElectron_MS_MomY_Col, fElectron_MS_Theta_Col, fElectron_MS_Phi_Col, fElectron_MS_Mom_Col; @@ -110,7 +124,9 @@ double fWFactor, fA, fFlux_Factor_Col, fFlux_Factor_RF, fJacobian_CM, fJacobian_ double fZASigma_UU, fRorySigma_UT, fSigma_Col, fSigma_UUPara, fSig_VR, fSig_L, fSig_T; -double fSigmaPhiS, fSigmaPhi_Minus_PhiS, fSigma2Phi_Minus_PhiS, fSigma3Phi_Minus_PhiS, fSigmaPhi_Plus_PhiS, fSigma2Phi_Plus_PhiS, fSig_Phi_Minus_PhiS, fSig_PhiS, fSig_2Phi_Minus_PhiS, fSig_Phi_Plus_PhiS, fSig_3Phi_Minus_PhiS, fSig_2Phi_Plus_PhiS, fEventWeight, fEventWeightMax, fZAWFactor, fRR, fPhaseSpaceWeight, fPhaseShiftWeight, fWilliamsWeight, fDedrickWeight, fCatchenWeight, fPhi, fPhiS, fPhi_Corrected, fPhiS_Corrected; +double fSig_fpi_6GeV; + +double fSigmaPhiS, fSigmaPhi_Minus_PhiS, fSigma2Phi_Minus_PhiS, fSigma3Phi_Minus_PhiS, fSigmaPhi_Plus_PhiS, fSigma2Phi_Plus_PhiS, fSig_Phi_Minus_PhiS, fSig_PhiS, fSig_2Phi_Minus_PhiS, fSig_Phi_Plus_PhiS, fSig_3Phi_Minus_PhiS, fSig_2Phi_Plus_PhiS, fEventWeight, fEventWeightMax, fEventWeightCeil, fEventWeightRn, fZAWFactor, fRR, fPhaseSpaceWeight, fPhaseShiftWeight, fWilliamsWeight, fDedrickWeight, fCatchenWeight, fPhi, fPhiS, fPhi_Corrected, fPhiS_Corrected; double fElectron_Mom_Sq_RF, fElectron_Mom_Sq_Col, fProton_Mom_Sq_Col, fProton_Mom_Sq_CM, fProton_Mom_Sq_RF, fPhoton_Mom_Sq_Col, fPhoton_Mom_Sq_CM, fPhoton_Mom_Sq_RF, fPion_Mom_Sq_Col, fPion_Mom_Sq_CM, fPion_Mom_Sq_RF, fNeutron_Mom_Sq_Col, fNeutron_Mom_Sq_CM, fNeutron_Mom_Sq_RF, fScatElec_Mom_Sq_Col, fScatElec_Mom_Sq_RF; @@ -124,10 +140,16 @@ double fTerm_PhiMinusPhi_S_Col, fTerm_Phi_S_Col, fTerm_2PhiMinusPhi_S_Col, fTerm double fPhi_Pion_LeptonPlane_RF, fCos_Phi_Pion_LeptonPlane_RF, fSin_Phi_Pion_LeptonPlane_RF, fPhi_TargPol_LeptonPlane_RF, fCos_Phi_TargPol_LeptonPlane_RF, fSin_Phi_TargPol_LeptonPlane_RF, fTheta_Pion_Photon_RF, fPhi_Pion_LeptonPlane_Col, fCos_Phi_Pion_LeptonPlane_Col, fSin_Phi_Pion_LeptonPlane_Col, fPhi_TargPol_LeptonPlane_Col, fCos_Phi_TargPol_LeptonPlane_Col, fSin_Phi_TargPol_LeptonPlane_Col, fTheta_Pion_Photon_Col; +double fPhi_Omega_LeptonPlane_RF, fCos_Phi_Omega_LeptonPlane_RF, fSin_Phi_Omega_LeptonPlane_RF, fTheta_Omega_Photon_RF; + double fZASigma_UU_Col, fRorySigma_UT_Col, fSig_Phi_Minus_PhiS_Col, fSig_PhiS_Col, fSig_2Phi_Minus_PhiS_Col, fSig_Phi_Plus_PhiS_Col, fSig_3Phi_Minus_PhiS_Col, fSig_2Phi_Plus_PhiS_Col; double fepi1, fepi2, fradical; +double fOmega_Energy_CM, fOmega_Mom_CM, fOmega_Energy_CM_GeV, fOmega_Mom_CM_GeV; + + + double fMomentum[300]; @@ -164,6 +186,18 @@ double fProb[300] = { 0.00252913, 0.00245194, 0.00237706, 0.00230444, 0.00223399, 0.00216566, 0.00209939, 0.00203512, 0.00197277, 0.00191231 }; +pim::pim() { +} + + + +pim::pim(int aaa) { + + gen_seed = aaa; + +} + + /*--------------------------------------------------*/ /*--------------------------------------------------*/ @@ -171,8 +205,21 @@ double fProb[300] = { void pim::Initilize() { - fRandom = new TRandom2(0); - fRandom->GetSeed(); +// fRandom = new TRandom2(0); +// fRandom->GetSeed(); +// fRandom->SetSeed(gen_seed); + + + fRandom = new TRandom3(); + + fRandom->SetSeed(gen_seed); + +// cout << fRandom->GetSeed() << endl; +// cout << "Seed Used: " << gen_seed << endl; + + +// exit(0); + allset = false; kCalcFermi = false; @@ -183,20 +230,28 @@ void pim::Initilize() { kFSI = false; kMSele = false; kMS = false; - - fLumi = 0.374e33; // https://eic.jlab.org/wiki/index.php/EIC_luminosity +// fLumi = 0.374e33; // Jlab design + fLumi = 1e34; // https://eic.jlab.org/wiki/index.php/EIC_luminosity fuBcm2 = 1.0e-30; fPI = 3.1415926; fDEG2RAD = fPI/180.0; fRAD2DEG = 180.0/fPI; - fEBeam = 5.0; // GeV + fEBeam = 5; // GeV fPBeam = 100; // 49.9912; // GeV +// fPBeam = 140; // 49.9912; // GeV + fScatElec_Theta_I = 60.0 * fDEG2RAD; fScatElec_Theta_F = 175.0 * fDEG2RAD; fScatElec_E_Lo = 0.5; // % of beam energy fScatElec_E_Hi = 2.5; // % of beam energy fPion_Theta_I = 0.0 * fDEG2RAD; fPion_Theta_F = 50.0 * fDEG2RAD; + + fOmega_Theta_I = 0.0 * fDEG2RAD; + fOmega_Theta_F = 360.0 * fDEG2RAD; + + + fPSF = ( fEBeam * ( fScatElec_E_Hi - fScatElec_E_Lo ) * ( sin( fScatElec_Theta_F ) - sin( fScatElec_Theta_I ) ) * 2 * fPI * ( sin( fPion_Theta_F ) - sin( fPion_Theta_I ) ) * 2 * fPI ); @@ -210,8 +265,12 @@ void pim::Initilize() { fNeutron_Mass_GeV = fNeutron_Mass/1000.0; fRecoilProton_Mass = 938.27; fRecoilProton_Mass_GeV = fRecoilProton_Mass/1000.0; - fPion_Mass = 139.57; + fPion_Mass = 139.57018; fPion_Mass_GeV = fPion_Mass/1000.0; + + fOmega_Mass = 782.65; + fOmega_Mass_GeV = fOmega_Mass/1000.0; + fDiff = 0.5; fElectron_Kin_Col_GeV = fEBeam; fElectron_Kin_Col = fElectron_Kin_Col_GeV * 1000.0; @@ -250,6 +309,8 @@ void pim::Initilize() { fWSqNeg = 0; fNSigmaNeg = 0; fNMomConserve = 0; + fNWeightUnphys = 0; + fNWeightReject = 0; fSDiff = 0; fScatElecEnergyLess = 0; fScatElecThetaLess = 0; @@ -702,6 +763,9 @@ void pim::Initilize() { fSigma_Col = 0; fSigma_UUPara = 0; fSig_VR = 0; + + fSig_fpi_6GeV = 0; + fSig_L = 0; fSig_T = 0; fSigmaPhiS = 0; @@ -718,6 +782,8 @@ void pim::Initilize() { fSig_2Phi_Plus_PhiS = 0; fEventWeight = 0; fEventWeightMax = 0; + fEventWeightCeil = 0; // SJDK 11/05/21 - This is the maximum value found with the old method that is used to get the new unit weight + fEventWeightRn = 0; // SJDK 11/05/21 -Random number to compare determined weight to fWilliamsWeight = 0; fDedrickWeight = 0; fCatchenWeight = 0; @@ -789,6 +855,20 @@ void pim::Initilize() { fPhi_Pion_LeptonPlane_RF = 0; fCos_Phi_Pion_LeptonPlane_RF = 0; fSin_Phi_Pion_LeptonPlane_RF = 0; + + fPhi_Omega_LeptonPlane_RF = 0; + fCos_Phi_Omega_LeptonPlane_RF = 0; + fSin_Phi_Omega_LeptonPlane_RF = 0; + fTheta_Omega_Photon_RF = 0; + + fOmega_Energy_CM = 0; + fOmega_Mom_CM = 0; + fOmega_Energy_CM_GeV = 0; + fOmega_Mom_CM_GeV = 0; + + + + fPhi_TargPol_LeptonPlane_RF = 0; fCos_Phi_TargPol_LeptonPlane_RF = 0; fSin_Phi_TargPol_LeptonPlane_RF = 0; @@ -830,6 +910,8 @@ double pim::fermiMomentum() { kFermi = false; } } + + cout << "Fermi momentum check: " << fMom << endl; return fMom; } diff --git a/src/eic_evgen/eic_pim.h b/src/eic_evgen/eic_pim.h index d3d0e41..9900ee6 100644 --- a/src/eic_evgen/eic_pim.h +++ b/src/eic_evgen/eic_pim.h @@ -5,19 +5,31 @@ #include #include "TFile.h" -#include +#include "TLorentzVector.h" #include "TTree.h" #include "TRandom.h" #include "TRandom2.h" +#include "TRandom3.h" class pim { public: - void Initilize(); - int CheckLaws(TLorentzVector P_E0, TLorentzVector P_t, TLorentzVector P_e, TLorentzVector P_pim, TLorentzVector P_pro); - void setrootfile(std::string myRootFile ); - double fermiMomentum(); + pim(); + pim(int); + + void Initilize(); + int CheckLaws(TLorentzVector P_E0, TLorentzVector P_t, TLorentzVector P_e, TLorentzVector P_pim, TLorentzVector P_pro); + void setrootfile(std::string myRootFile ); + double fermiMomentum(); + + private: + Int_t gen_seed = 0; + + std::string pParticle; + std::string pcharge; + + /* double correctedPhi(); */ /* double correctedPhiS(); */ @@ -26,12 +38,23 @@ class pim { -extern TRandom2 *fRandom; +//extern TRandom2 *fRandom; + +extern TRandom3 *fRandom; extern TFile *f; extern TTree *t1; +extern int gKinematics_type; +extern TString gfile_name; +extern TString gParticle; +extern bool gPi0_decay; +extern std::string gDet_location; +extern float fProton_incidence_phi; + +extern int fSeed; + extern bool allset; extern bool kCalcFermi; extern bool kCalcBremss; @@ -43,18 +66,43 @@ extern bool kFSI; extern bool kMSele; extern bool kMS; +extern double fOmega_Mass; +extern double fOmega_Mass_GeV; + +extern double fOmega_Theta_Col; +extern double fOmega_Phi_Col; + +extern double fOmega_Theta_I; +extern double fOmega_Theta_F; + +extern double fOmega_Energy_CM; +extern double fOmega_Mom_CM; +extern double fOmega_Energy_CM_GeV; +extern double fOmega_Mom_CM_GeV; + +extern double fPhi_Omega_LeptonPlane_RF; +extern double fCos_Phi_Omega_LeptonPlane_RF; +extern double fSin_Phi_Omega_LeptonPlane_RF; +extern double fTheta_Omega_Photon_RF; + extern int fWLessShell; extern int fWLess1P9; extern int fSDiff; -extern long int fNEvents; -extern long int fNRecorded; -extern long int fNGenerated; -extern long int fWSqNeg; -extern long int fNMomConserve; -extern long int fNSigmaNeg; -extern long int fLundRecorded; -extern long int fNFile; +//extern long int fNEvents; + +extern unsigned long long int fNEvents; +extern unsigned long long int fNRecorded; +extern unsigned long long int fNGenerated; +extern unsigned long long int fWSqNeg; +extern unsigned long long int fNMomConserve; +extern unsigned long long int fNSigmaNeg; + +extern unsigned long long int fNWeightUnphys; +extern unsigned long long int fNWeightReject; + +extern unsigned long long int fLundRecorded; +extern unsigned long long int fNFile; extern double fK; extern double fm; @@ -637,6 +685,8 @@ extern double fSig_VR; extern double fSig_L; extern double fSig_T; +extern double fSig_fpi_6GeV; + extern double fSigmaPhiS; extern double fSigmaPhi_Minus_PhiS; extern double fSigma2Phi_Minus_PhiS; @@ -651,6 +701,8 @@ extern double fSig_3Phi_Minus_PhiS; extern double fSig_2Phi_Plus_PhiS; extern double fEventWeight; extern double fEventWeightMax; +extern double fEventWeightCeil; // SJDK 11/05/21 - This is the maximum value found with the old method that is used to get the new unit weight +extern double fEventWeightRn; // SJDK 11/05/21 - Random number to compare determined weight to extern double fZAWFactor; extern double fRR; extern double fPhaseSpaceWeight; diff --git a/src/eic_evgen/eic_pim.o b/src/eic_evgen/eic_pim.o index 4918424..0b780be 100644 Binary files a/src/eic_evgen/eic_pim.o and b/src/eic_evgen/eic_pim.o differ diff --git a/src/eic_evgen/gvim b/src/eic_evgen/gvim deleted file mode 100644 index 3e29f22..0000000 --- a/src/eic_evgen/gvim +++ /dev/null @@ -1,18 +0,0 @@ - - - -class pim { - - public: - double test(); - void Initilize(); - int CheckLaws(TLorentzVector P_E0, TLorentzVector P_t, TLorentzVector P_e, TLorentzVector P_pim, TLorentzVector P_pro); - void setrootfile( string myRootFile ); - double fermiMomentum(); - /* double correctedPhi(); */ - /* double correctedPhiS(); */ - -}; - - - diff --git a/src/eic_evgen/legacy.h b/src/eic_evgen/legacy.h new file mode 100644 index 0000000..a1fcc47 --- /dev/null +++ b/src/eic_evgen/legacy.h @@ -0,0 +1,21 @@ +# ifndef legacy_H +# define legacy_H + +#include +#include +#include + +#include "eic_pim.h" + +#include "TString.h" +#include "TF1.h" +#include "tssa_sig_Para.h" + +void Exclusive_Pion_Prodoction(pim); +void Exclusive_Omega_Prodoction(pim); + +double fSig_fpi_sigT (double, double); +double fSig_fpi_sigL (double, double); + +#endif + diff --git a/src/eic_evgen/legacy_function.cc b/src/eic_evgen/legacy_function.cc new file mode 100644 index 0000000..2850e29 --- /dev/null +++ b/src/eic_evgen/legacy_function.cc @@ -0,0 +1,1513 @@ +/*--------------------------------------------------*/ +// Author: Z. Ahmed +// Date: 2016 +// Pi Plus function + +#include "legacy_function.h" + + +using namespace std; + +void Exclusive_Pion_Prodoction(pim myPim) { + + ///*--------------------------------------------------*/ + /// Setting seed for generation and initiation + + +// kCalcFermi = true; + + string sTFile; + sTFile = Form("./LundFiles/eic_%s.txt", gfile_name.Data()); + +// string sRFile; +// sRFile = Form("./RootFiles/eic_%s.root", file_name.Data()); + + string sLFile; + sLFile= Form("./LundFiles/eic_input_%s.dat", gfile_name.Data()); + + ofstream ppiOut ( sLFile.c_str() ); + ofstream ppiDetails ( sTFile.c_str() ); + + // myPim.setrootfile( sRFile ); + + int qsq_ev = 0, t_ev = 0, w_neg_ev = 0, w_ev = 0; + double lpar0 = 0., lpar1 = 0., lpar2 = 0., lpar3 = 0., lpar4 = 0., lpar5 = 0., lpar6 = 0.; + double tpar0 = 0., tpar1 = 0., tpar2 = 0., tpar3 = 0., tpar4 = 0.; + +// t1->SetDirectory( f ); +// t1->SetAutoSave( 1000000000 ); + + long long int i; + for ( i = 0; i < fNEvents; i++ ) { + + TDatime dFractTime; + + fNGenerated ++; + + if ( i % ( fNEvents / 10 ) == 0 ) { + cout << "Event: " << setw(8) << i + << " % of events " << setw(4) << ((1.0*i)/(1.0*fNEvents))*100.0 + << " Day: " << dFractTime.GetDay() + << " Time: " << dFractTime.GetHour() + << ":" << dFractTime.GetMinute() + << ":" << dFractTime.GetSecond() + << endl; + } + + // ---------------------------------------------------- + // Proton in collider (lab) frame + // ---------------------------------------------------- + + fProton_Theta_Col = 50.0e-3; + fProton_Phi_Col = fPi; + fProton_Mom_Col = fPBeam * 1e3; + fVertex_X = 0.; + fVertex_Y = 0.; + fVertex_Z = 0.; + + if ( kCalcFermi ) { + fProton_Mom_Col = fProton_Mom_Col + myPim.fermiMomentum(); + fProton_Theta_Col = acos( fRandom->Uniform( cos(0.0) , cos(fPi) ) ); + fProton_Phi_Col = fRandom->Uniform( 0 , 360 ); + } + + TLorentzVector lproton( fProton_Mom_Col * sin(fProton_Theta_Col) * cos(fProton_Phi_Col), + fProton_Mom_Col * sin(fProton_Theta_Col) * sin(fProton_Phi_Col), + fProton_Mom_Col * cos(fProton_Theta_Col), + sqrt( pow( fProton_Mom_Col , 2 ) + pow( fProton_Mass , 2 ) ) ); + + TLorentzVector lprotong; + lprotong = lproton * fm; + + // ---------------------------------------------------- + // Boost vector from collider (lab) frame to protons rest frame (Fix target) + // ---------------------------------------------------- + + TVector3 beta_col_rf; + beta_col_rf = lproton.BoostVector(); + fGamma_Col_RF = 1.0/sqrt( 1 - pow( beta_col_rf.Mag() , 2 ) ); + + // ---------------------------------------------------- + // Electron in collider (lab) frame + // ---------------------------------------------------- + fElectron_Energy_Col = fElectron_Kin_Col; + fElectron_Mom_Col = sqrt( pow(fElectron_Energy_Col , 2) - pow(fElectron_Mass , 2) ); + fElectron_Theta_Col = fPi; + fElectron_Phi_Col = 0.0; + fElectron_MomZ_Col = fElectron_Mom_Col * cos(fElectron_Theta_Col); + fElectron_MomX_Col = fElectron_Mom_Col * sin(fElectron_Theta_Col) * cos(fElectron_Phi_Col); + fElectron_MomY_Col = fElectron_Mom_Col * sin(fElectron_Theta_Col) * sin(fElectron_Phi_Col); + + TLorentzVector lelectron( fElectron_MomX_Col, fElectron_MomY_Col, fElectron_MomZ_Col, fElectron_Energy_Col); + TLorentzVector lelectrong; + lelectrong = lelectron * fm; + + // --------------------------------------------------------------------- + // Specify the energy and solid angle of scatterd electron in Collider (lab) frame + // --------------------------------------------------------------------- + fScatElec_Theta_Col = acos( fRandom->Uniform( cos( fScatElec_Theta_I ) , cos( fScatElec_Theta_F ) ) ); + fScatElec_Phi_Col = fRandom->Uniform( 0 , 2.0 * fPi); + fScatElec_Energy_Col = fRandom->Uniform( fScatElec_E_Lo * fElectron_Energy_Col , fScatElec_E_Hi * fElectron_Energy_Col ); + fPion_Theta_Col = acos( fRandom->Uniform( cos(fPion_Theta_I ) , cos(fPion_Theta_F ) ) ); + fPion_Phi_Col = fRandom->Uniform( 0 , 2.0 * fPi ); + + +// fScatElec_Theta_Col = 2.42585; +// fScatElec_Phi_Col = 1.73913; +// fScatElec_Energy_Col = 5473.08; +// +// fPion_Theta_Col = 0.232649; +// fPion_Phi_Col = 4.68068; + + +// cout << fScatElec_Theta_Col << " " << fScatElec_Phi_Col << " " << fScatElec_Energy_Col << " " << fPion_Theta_Col << " " << fPion_Phi_Col << endl; + + + + // fScatElec_Theta_Col = 146.356*fDEG2RAD; + // fScatElec_Phi_Col = 11.8325*fDEG2RAD; + // fScatElec_Energy_Col = 5.25281*1000.0; + // fPion_Theta_Col = 14.5869*fDEG2RAD; + // fPion_Phi_Col = -168.57*fDEG2RAD; + + fScatElec_Mom_Col = sqrt( pow( fScatElec_Energy_Col,2) - pow( fElectron_Mass , 2) ); + fScatElec_MomZ_Col = ( fScatElec_Mom_Col * cos(fScatElec_Theta_Col) ); + fScatElec_MomX_Col = ( fScatElec_Mom_Col * sin(fScatElec_Theta_Col) * cos(fScatElec_Phi_Col) ); + fScatElec_MomY_Col = ( fScatElec_Mom_Col * sin(fScatElec_Theta_Col) * sin(fScatElec_Phi_Col) ); + + TLorentzVector lscatelec( fScatElec_MomX_Col, fScatElec_MomY_Col, fScatElec_MomZ_Col, fScatElec_Energy_Col); + TLorentzVector lscatelecg; + lscatelecg = lscatelec * fm; + + // ---------------------------------------------------- + // Photon in collider (lab) frame and Qsq + // ---------------------------------------------------- + + TLorentzVector lphoton; + lphoton = lelectron - lscatelec; + TLorentzVector lphotong; + lphotong = lelectrong - lscatelecg; + +// cout << "Check check Original: " << endl; +// +// cout << lphoton.Px() << " " << lphoton.Py() << " " << lphoton.Pz() << " " << lphoton.E() << endl; +// cout << lelectron.Px() << " " << lelectron.Py() << " " << lelectron.Pz() << " " << lelectron.E() << endl; +// cout << lscatelec.Px() << " " << lscatelec.Py() << " " << lscatelec.Pz() << " " << lscatelec.E() << endl; + +// exit(0); + + + + + + fQsq_GeV = -1.*lphotong.Mag2(); + + if ( fQsq_GeV < 5.0 ) { + qsq_ev++; + continue; + } + + // ---------------------------------------------------- + // W square, Invariant Mass (P_g + P_p)^2 + // ---------------------------------------------------- + + TLorentzVector lwg; + lwg = lprotong + lphotong; + fW_GeV = lwg.Mag(); + fWSq_GeV = lwg.Mag2(); + +// cout << lprotong.Px() << " " << lprotong.Py() << " " << lprotong.Pz() << " " << lprotong.E() << endl; +// cout << lphotong.Px() << " " << lphotong.Py() << " " << lphotong.Pz() << " " << lphotong.E() << endl; +// +// cout << "Org : " << fQsq_GeV << " " << fW_GeV << " "<< fWSq_GeV << endl; + + + if ( fWSq_GeV < 0 ) { + w_neg_ev++; + continue; + } + + // ---------------------------------------------------- + // Pion in Collider frame + // ---------------------------------------------------- + // fPion_Theta_Col = acos( fRandom->Uniform( cos(fPion_Theta_I ) , cos(fPion_Theta_F ) ) ); + // fPion_Phi_Col = fRandom->Uniform( 0 , 360 ); + + // --------------------------------------------------------- + // Pion momentum in collider frame, analytic solution starts + // --------------------------------------------------------- + + double fupx = sin( fPion_Theta_Col ) * cos( fPion_Phi_Col ); + double fupy = sin( fPion_Theta_Col ) * sin( fPion_Phi_Col ); + double fupz = cos( fPion_Theta_Col ); + + double fuqx = sin( lphoton.Theta() ) * cos( lphoton.Phi() ); + double fuqy = sin( lphoton.Theta() ) * sin( lphoton.Phi() ); + double fuqz = cos( lphoton.Theta() ); + + double fa = -(lphoton.Vect()).Mag() * ( fupx * fuqx + fupy * fuqy + fupz * fuqz ); + double fb = pow ( (lphoton.Vect()).Mag() , 2 ); + double fc = lphoton.E() + fProton_Mass; + +// cout.precision(10); +// cout << lphoton.Vect().X() << " " << lphoton.Vect().Y() << " " << lphoton.Vect().Z() << endl; +// cout << "AAAAAAAAAAABBBBBBBCCCCCCCCC " << fa << " " << fb << " " << fc << endl; + + + fa = ( fa - std::abs( (lproton.Vect()).Mag() ) * ( ( ( lproton.X() / (lproton.Vect()).Mag() ) * fupx ) + + ( ( lproton.Y() / (lproton.Vect()).Mag() ) * fupy ) + + ( ( lproton.Z() / (lproton.Vect()).Mag() ) * fupz ) ) ); + + double factor = ( pow( (lproton.Vect()).Mag() , 2 ) + 2.0 * (lphoton.Vect()).Mag() * (lproton.Vect()).Mag() * + ( ( ( lproton.X() / (lproton.Vect()).Mag() ) * fuqx ) + + ( ( lproton.Y() / (lproton.Vect()).Mag() ) * fuqy ) + + ( ( lproton.Z() / (lproton.Vect()).Mag() ) * fuqz ) ) ); + + fb = fb + factor; + fc = lphoton.E() + lproton.E(); + + double ft = fc * fc - fb + fPion_Mass * fPion_Mass - fProton_Mass * fProton_Mass; + + double fQA = 4.0 * ( fa * fa - fc * fc ); + double fQB = 4.0 * fc * ft; + double fQC = -4.0 * fa * fa * fPion_Mass * fPion_Mass - ft * ft; + + fradical = fQB * fQB - 4.0 * fQA * fQC; + + fepi1 = ( -fQB - sqrt( fradical ) ) / ( 2.0 * fQA ); + fepi2 = ( -fQB + sqrt( fradical ) ) / ( 2.0 * fQA ); + +// cout.precision(10); +// +// cout << fc*fc << " " << 99531.3*99531.3 << endl; +// cout << fb << " " << 9.83386e+09 << endl; +// +// cout << fc*fc - fb << " " << 99531.3*99531.3 - 9.83386e+09 << endl; +// +// cout << fc * fc << " " << fc * fc -fb << " " << 99531.3*99531.3 - 9.83386e+09 << endl; +// +// cout << "abc: " << fa << " " << fb << " " << fc << " " << ft << " " << fPion_Mass << " " << fProton_Mass << endl; +// +// cout << "epi: " << fQB << " " << fradical << " " << fQA << endl; +// +// cout << "org: " << factor << " " << fepi1 << " " << fepi2 << endl; +// +// +// cout << "X diagnose: " << fPion_Mass << " " << fepi1 << " " << fPion_Theta_Col << " " << fPion_Phi_Col << endl; + + + fPion_Mom_Same = 0; + if ( std::abs(fepi1 - fepi2) < fDiff ){ fPion_Mom_Same = 1; } + + // --------------------------------------------------------- + // Pion momentum in collider frame, analytic solution ends + // --------------------------------------------------------- + + TLorentzVector lpion( ( sqrt( pow( fepi1 , 2) - pow(fPion_Mass , 2) ) ) * sin(fPion_Theta_Col) * cos(fPion_Phi_Col), + ( sqrt( pow( fepi1 , 2) - pow(fPion_Mass , 2) ) ) * sin(fPion_Theta_Col) * sin(fPion_Phi_Col), + ( sqrt( pow( fepi1 , 2) - pow(fPion_Mass , 2) ) ) * cos(fPion_Theta_Col), + fepi1 ); + + TLorentzVector lpiong; + lpiong = lpion * fm; + + TLorentzVector lneutron( ( lproton + lelectron - lscatelec - lpion ).X(), + ( lproton + lelectron - lscatelec - lpion ).Y(), + ( lproton + lelectron - lscatelec - lpion ).Z(), + sqrt( pow( ( ( ( lproton + lelectron - lscatelec - lpion ).Vect() ).Mag()),2) + + pow( fNeutron_Mass ,2 ) ) ); + TLorentzVector lneutrong; + lneutrong = lneutron * fm; + + fNeutron_Mom_Col_GeV = (lneutrong.Vect()).Mag(); + fNeutron_MomZ_Col_GeV = lneutrong.Z(); + fNeutron_MomX_Col_GeV = lneutrong.X(); + fNeutron_MomY_Col_GeV = lneutrong.Y(); + fNeutron_Energy_Col_GeV = lneutrong.E(); + + +// cout << fW_GeV << endl; +// exit(0); + + // ------------------------------------------------------------------------------------------------- + // ------------------------------------------------------------------------------------------------- + // Calculate w = (proton + photon)^2 + // ------------------------------------------------------------------------------------------------- + // ------------------------------------------------------------------------------------------------- + + // cout << fW_GeV << endl; + if ( fW_GeV < 3.0 || fW_GeV > 10.6 ) { + w_ev++; + continue; + } + +// cout << fScatElec_Theta_Col << " " << fScatElec_Phi_Col << " " << fScatElec_Energy_Col << " " << fPion_Theta_Col << " " << fPion_Phi_Col << endl; + +// cout << fW_GeV << endl; + + + + + + + + + TLorentzVector lw; + lw = lproton + lphoton; + fW = lw.Mag(); + + // ------------------------------------------------------------------------------------------------- + // ------------------------------------------------------------------------------------------------- + // Calculate w prime w' = (proton + photon - pion)^2 + // ------------------------------------------------------------------------------------------------- + // ------------------------------------------------------------------------------------------------- + + TLorentzVector lwp = lprotong + lphotong - lpiong; + fW_Prime_GeV = lwp.Mag(); + + TLorentzVector fsini; + fsini = lelectron + lproton; + TLorentzVector fsfin; + fsfin = lscatelec + lpion + lneutron; + + TLorentzVector fsinig; + fsinig = fsini * fm; + TLorentzVector fsfing; + fsfing = fsfin * fm; + + fMandSConserve = std::abs( fsinig.Mag() - fsfing.Mag() ); + +// cout << fW_GeV << " " << fsinig.Mag() << " " << fsfing.Mag() << " " << fMandSConserve << endl; + +// cout << "E: " << lscatelec.Px() << " " << lscatelec.Py() << " " << lscatelec.Pz() << " " << lscatelec.E() << endl; +// cout << "X: " << lpion.Px() << " " << lpion.Py() << " " << lpion.Pz() << " " << lpion.E() << endl; +// cout << "N: " << lneutron.Px() << " " << lneutron.Py() << " " << lneutron.Pz() << " " << lneutron.E() << endl; + +// cout << fW_GeV << " " << fsinig.Mag() << " " << fsfing.Mag() << " " << fMandSConserve << endl; +// exit(0); + + + kSConserve = false; + if( std::abs( fsinig.Mag() - fsfing.Mag() ) < fDiff ) { + kSConserve = true; + } + + if ( myPim.CheckLaws( lelectron, lproton, lscatelec, lpion, lneutron ) != 1 ) + continue; + + + + + + //////////////////////////////////////////////////////////////////////////////////////////// + // Start // + // Transformation of e', pi- and recoil proton to target's rest frmae without energy loss // + //////////////////////////////////////////////////////////////////////////////////////////// + + TLorentzVector lproton_rf; + lproton_rf = lproton; + lproton_rf.Boost(-beta_col_rf); + TLorentzVector lproton_rfg; + lproton_rfg = lproton_rf * fm; + + TLorentzVector lelectron_rf; + lelectron_rf = lelectron; + lelectron_rf.Boost(-beta_col_rf); + TLorentzVector lelectron_rfg; + lelectron_rfg = lelectron_rf * fm; + + TLorentzVector lscatelec_rf; + lscatelec_rf = lscatelec; + lscatelec_rf.Boost(-beta_col_rf); + TLorentzVector lscatelec_rfg; + lscatelec_rfg = lscatelec_rf * fm; + + TLorentzVector lphoton_rf; + lphoton_rf = lphoton; + lphoton_rf.Boost(-beta_col_rf); + TLorentzVector lphoton_rfg; + lphoton_rfg = lphoton_rf * fm; + + TLorentzVector lpion_rf; + lpion_rf = lpion; + lpion_rf.Boost(-beta_col_rf); + TLorentzVector lpion_rfg; + lpion_rfg = lpion_rf * fm; + + TLorentzVector lneutron_rf; + lneutron_rf = lneutron; + lneutron_rf.Boost(-beta_col_rf); + TLorentzVector lneutron_rfg; + lneutron_rfg = lneutron_rf * fm; + + //////////////////////////////////////////////////////////////////////////////////////////// + // End // + // Transformation of e', pi- and recoil proton to target's rest frmae without energy loss // + //////////////////////////////////////////////////////////////////////////////////////////// + + // fElectron_Energy_RF_GeV = lelectron_rf.E() / 1000.0; + // fElectron_Mom_RF_GeV = (lelectron_rf.Vect()).Mag() / 1000.0; + // fElectron_MomX_RF_GeV = lelectron_rf.X() / 1000.0; + // fElectron_MomY_RF_GeV = lelectron_rf.Y() / 1000.0; + // fElectron_MomZ_RF_GeV = lelectron_rf.Z() / 1000.0; + + fScatElec_Energy_RF_GeV = lscatelec_rf.E() / 1000.0; + fScatElec_Mom_RF_GeV = (lscatelec_rf.Vect()).Mag() / 1000.0; + fScatElec_MomX_RF_GeV = lscatelec_rf.X() / 1000.0; + fScatElec_MomY_RF_GeV = lscatelec_rf.Y() / 1000.0; + fScatElec_MomZ_RF_GeV = lscatelec_rf.Z() / 1000.0; + + fPion_Energy_RF_GeV = lpion_rf.E() / 1000.0; + fPion_Mom_RF_GeV = (lpion_rf.Vect()).Mag() / 1000.0; + fPion_MomX_RF_GeV = lpion_rf.X() / 1000.0; + fPion_MomY_RF_GeV = lpion_rf.Y() / 1000.0; + fPion_MomZ_RF_GeV = lpion_rf.Z() / 1000.0; + + fNeutron_Energy_RF_GeV = lneutron_rf.E() / 1000.0; + fNeutron_Mom_RF_GeV = (lneutron_rf.Vect()).Mag() / 1000.0; + fNeutron_MomX_RF_GeV = lneutron_rf.X() / 1000.0; + fNeutron_MomY_RF_GeV = lneutron_rf.Y() / 1000.0; + fNeutron_MomZ_RF_GeV = lneutron_rf.Z() / 1000.0; + + // if ( myPim.CheckLaws( lelectron_rf, lproton_rf, lscatelec_rf, lpion_rf, lneutron_rf ) != 1 ) + // continue; + + // ---------------------------------------------------------------------------------------------------- + // ---------------------------------------------------------------------------------------------------- + // Calculate -t + // ---------------------------------------------------------------------------------------------------- + // ---------------------------------------------------------------------------------------------------- + + fBeta_CM_RF = (lphoton_rf.Vect()).Mag() / ( lphoton_rf.E() + fProton_Mass ); + fGamma_CM_RF = ( lphoton_rf.E() + fProton_Mass ) / fW; + fPion_Energy_CM = ( pow( fW , 2) + pow(fPion_Mass , 2) - pow(fNeutron_Mass , 2) ) / ( 2.0 * fW); + fPion_Mom_CM = sqrt( pow(fPion_Energy_CM , 2) - pow(fPion_Mass , 2)); + fPion_Energy_CM_GeV = fPion_Energy_CM / 1000.0; + fPion_Mom_CM_GeV = fPion_Mom_CM / 1000.0; + + // this equation is valid for parallel kinematics only! + fT_Para = ( pow(((lphoton.Vect()).Mag() - (lpion.Vect()).Mag()),2) - pow((lphoton.E() - lpion.E()),2)); + fT_Para_GeV = fT_Para/1000000.0; + + TLorentzVector lt; + lt = lphoton - lpion; + TLorentzVector ltg; + ltg = lt * fm; + + fT = -1.*lt.Mag2(); + fT_GeV = -1.*ltg.Mag2(); + + + + + if ( gKinematics_type == 1 && fT_GeV > 0.5 ) { + t_ev++; + continue; + } + + if ( gKinematics_type == 2 && fT_GeV > 1.3 ) { + t_ev++; + continue; + } + + + +// cout << "Parameter: " << fScatElec_Theta_Col << " " << fScatElec_Phi_Col << " " << fScatElec_Energy_Col << " " << fPion_Theta_Col << " " << fPion_Phi_Col << endl; + +// cout << fT_GeV << endl; + +// exit(0); + + + fx = fQsq_GeV / ( 2.0 * lprotong.Dot( lphotong ) ); + fy = lprotong.Dot( lphotong ) / lprotong.Dot( lelectrong ); + fz = lpion.E()/lphoton.E(); + + // ------------------------------------------------------------------------------------------------------- + // ------------------------------------------------------------------------------------------------------- + + // ------------------------------------------------------------------------------------------------------- + // Calculation of Phi ( azimuthal angle of pion momentum w.r.t lepton plane in target's rest frame) + // Calculation of PhiS ( azimuthal angle of target polarization w.r.t lepton plane in target's rest frame) + // ------------------------------------------------------------------------------------------------------- + + TVector3 v3Photon; v3Photon.SetX( lphoton_rfg.X() ); v3Photon.SetY( lphoton_rfg.Y() ); v3Photon.SetZ( lphoton_rfg.Z() ); + TVector3 v3Electron; v3Electron.SetX( lelectron_rfg.X() ); v3Electron.SetY( lelectron_rfg.Y() ); v3Electron.SetZ( lelectron_rfg.Z() ); + TVector3 v3Pion; v3Pion.SetX( lpion_rfg.X() ) ; v3Pion.SetY( lpion_rfg.Y() ) ; v3Pion.SetZ( lpion_rfg.Z() ); + TVector3 v3S; v3S.SetX( -1 ); v3S.SetY( 0 ); v3S.SetZ( 0 ); + TVector3 v3PhotonUnit = v3Photon.Unit(); + TVector3 v3QxL = v3Photon.Cross(v3Electron); + TVector3 v3QxP = v3Photon.Cross(v3Pion); + TVector3 v3QxS = v3Photon.Cross(v3S); + TVector3 v3LxP = v3Electron.Cross(v3Pion); + TVector3 v3LxS = v3Electron.Cross(v3S); + TVector3 v3PxL = v3Pion.Cross(v3Electron); + TVector3 v3QUnitxL = v3PhotonUnit.Cross(v3Electron); + TVector3 v3QUnitxP = v3PhotonUnit.Cross(v3Pion); + TVector3 v3QUnitxS = v3PhotonUnit.Cross(v3S); + + fCos_Phi_Pion_LeptonPlane_RF = ( ( v3QUnitxL.Dot( v3QUnitxP ) ) / ( v3QUnitxL.Mag() * v3QUnitxP.Mag() ) ); // hep-ph/0410050v2 + fSin_Phi_Pion_LeptonPlane_RF = ( ( v3LxP.Dot( v3PhotonUnit ) ) / ( v3QUnitxL.Mag() * v3QUnitxP.Mag() ) ); // hep-ph/0410050v2 + if ( fSin_Phi_Pion_LeptonPlane_RF >= 0 ) + fPhi_Pion_LeptonPlane_RF = fRAD2DEG * acos( ( v3QUnitxL.Dot( v3QUnitxP ) ) / ( v3QUnitxL.Mag() * v3QUnitxP.Mag() ) ); + if ( fSin_Phi_Pion_LeptonPlane_RF < 0 ) + fPhi_Pion_LeptonPlane_RF = 360.0 - std::abs( fRAD2DEG * acos( ( v3QUnitxL.Dot( v3QUnitxP ) ) / ( v3QUnitxL.Mag() * v3QUnitxP.Mag() ) ) ); + + fCos_Phi_TargPol_LeptonPlane_RF = ( ( v3QUnitxL.Dot( v3QUnitxS ) ) / ( v3QUnitxL.Mag() * v3QUnitxS.Mag() ) ); // hep-ph/0410050v2 + fSin_Phi_TargPol_LeptonPlane_RF = ( ( v3LxS.Dot( v3PhotonUnit ) ) / ( v3QUnitxL.Mag() * v3QUnitxS.Mag() ) ); // hep-ph/0410050v2 + if ( fSin_Phi_TargPol_LeptonPlane_RF >= 0 ) + fPhi_TargPol_LeptonPlane_RF = fRAD2DEG * acos( ( v3QUnitxL.Dot( v3QUnitxS ) ) / ( v3QUnitxL.Mag() * v3QUnitxS.Mag() ) ); + if ( fSin_Phi_TargPol_LeptonPlane_RF < 0 ) + fPhi_TargPol_LeptonPlane_RF = 360.0 - std::abs( fRAD2DEG * acos( ( v3QUnitxL.Dot( v3QUnitxS ) ) / ( v3QUnitxL.Mag() * v3QUnitxS.Mag() ) ) ); + + fTheta_Pion_Photon_RF = fRAD2DEG * acos( ( v3Photon.Dot( v3Pion ) ) / ( v3Photon.Mag() * v3Pion.Mag() ) ); + if ( fTheta_Pion_Photon_RF < 0 ) { fTheta_Pion_Photon_RF = 180.0 + fTheta_Pion_Photon_RF; } + + fPhi = fPhi_Pion_LeptonPlane_RF; + fPhiS = fPhi_TargPol_LeptonPlane_RF; + + // ----------------------------------------------------------------------------------- + // If we have fermi momentum then epsilon should be in rest frame + // The theta angle of scattered angle used in expression of epsilon is the angle + // with respect to direction of incoming electron in the rest frame of target nucleon + // epsilon=1./(1.+ 2.*(pgam_restg**2)/q2g * *(tand(thscat_rest/2.))**2) + // ----------------------------------------------------------------------------------- + + double fTheta_EEp = (lelectron_rf.Vect()).Angle(lscatelec_rf.Vect()); + + fEpsilon = 1.0 / ( 1.0 + 2.0 * ( pow( (lphoton_rfg.Vect()).Mag(),2)/fQsq_GeV ) * pow( tan( fTheta_EEp / 2 ) , 2 ) ); + + // ---------------------------------------------------- + // Virtual Photon flux factor in units of 1/(GeV*Sr) + // ---------------------------------------------------- + fFlux_Factor_Col = (fAlpha/(2.0*pow(fPi,2))) * (lscatelecg.E() / lelectrong.E()) * + ( pow(fW_GeV,2) - pow(fProton_Mass_GeV,2) ) / (2.0*fProton_Mass_GeV*fQsq_GeV*(1.0 - fEpsilon)); + + fFlux_Factor_RF = ( fAlpha / ( 2.0 * pow( fPi , 2 ) ) ) * ( lscatelec_rfg.E() / lelectron_rfg.E() ) * + ( pow( fW_GeV , 2 ) - pow( fProton_Mass_GeV , 2 ) ) / + ( 2.0 * fProton_Mass_GeV * fQsq_GeV * ( 1.0 - fEpsilon ) ); + + // ---------------------------------------------------- + // Jacobian dt/dcos(theta*)dphi in units of GeV2/sr + // ---------------------------------------------------- + fJacobian_CM = ( (lphoton_rfg.Vect()).Mag() - fBeta_CM_RF * lphoton_rfg.E() ) / ( fGamma_CM_RF * ( 1.0 - pow(fBeta_CM_RF,2) ) ); + + fA = fJacobian_CM * fPion_Mom_CM_GeV / fPi; + + // ---------------------------------------------------- + // Jacobian dOmega* / dOmega dimensionless + // ---------------------------------------------------- + fJacobian_CM_RF = ( pow((lpion_rf.Vect()).Mag(),2)*fW) / + ( fPion_Mom_CM * std::abs( ( fProton_Mass + lphoton_rf.E()) * (lpion_rf.Vect()).Mag() - + ( lpion_rf.E() * (lphoton_rf.Vect()).Mag() * cos( lpion_rf.Theta() ) ) ) ); + + fJacobian_CM_Col = ( ( pow((lpion.Vect()).Mag(),2) * fW ) / + ( fPion_Mom_CM * std::abs( ( fProton_Mass + lphoton.E() ) * (lpion.Vect()).Mag() - + ( lpion.E() * (lphoton.Vect()).Mag() * cos( lpion.Theta() ) ) ) ) ); + + +// cout << fJacobian_CM_RF << " " << fJacobian_CM_Col << endl; + +// exit(0); + + + + // -------------------------------------------------------------------------------------------------- + // CKY sigma L and T starts + // -------------------------------------------------------------------------------------------------- + + lpar0 = 0.; lpar1 = 0.; lpar2 = 0.; lpar3 = 0.; lpar4 = 0.; lpar5 = 0.; lpar6 = 0.; + tpar0 = 0.; tpar1 = 0.; tpar2 = 0.; tpar3 = 0.; tpar4 = 0.; + + fSig_L = 0; + fSig_T = 0; + + if ( ( fT_GeV > 0. ) && ( fT_GeV < 0.15 ) ) { + eicSigmaL( fW_GeV, fQsq_GeV, lpar0, lpar1, lpar2 , lpar3 , lpar4 , lpar5 , lpar6 ); + TF1 *fitCKYLonglandau = new TF1("sigmaL","landau", 0.0 , 0.15 ); + fitCKYLonglandau->FixParameter( 0 , lpar0 ); + fitCKYLonglandau->FixParameter( 1 , lpar1 ); + fitCKYLonglandau->FixParameter( 2 , lpar2 ); + fSig_L = fitCKYLonglandau->Eval(fT_GeV); + if ( lpar0 == 0 || lpar1 == 0 || lpar2 == 0 ) + fSig_L = 0; + fitCKYLonglandau = NULL; + delete fitCKYLonglandau; + } + else if ( ( fT_GeV > 0.15 ) && ( fT_GeV < 0.5 ) ) { + eicSigmaL( fW_GeV, fQsq_GeV, lpar0, lpar1, lpar2 , lpar3 , lpar4 , lpar5 , lpar6 ); + TF1 *fitCKYLongexpo1 = new TF1("sigmaL","expo", 0.15 , 0.5 ); + fitCKYLongexpo1->FixParameter( 0 , lpar3 ); + fitCKYLongexpo1->FixParameter( 1 , lpar4 ); + fSig_L = fitCKYLongexpo1->Eval(fT_GeV); + if ( lpar3 == 0 || lpar4 == 0 ) + fSig_L = 0; + fitCKYLongexpo1 = NULL; + delete fitCKYLongexpo1; + } + else if ( ( fT_GeV > 0.5 ) && ( fT_GeV < 1.3 ) ) { + eicSigmaL( fW_GeV, fQsq_GeV, lpar0, lpar1, lpar2 , lpar3 , lpar4 , lpar5 , lpar6 ); + TF1 *fitCKYLongexpo2 = new TF1("sigmaL","expo", 0.5 , 1.3 ); + fitCKYLongexpo2->FixParameter( 0 , lpar5 ); + fitCKYLongexpo2->FixParameter( 1 , lpar6 ); + fSig_L = fitCKYLongexpo2->Eval(fT_GeV); + if ( lpar5 == 0 || lpar6 == 0 ) + fSig_L = 0; + fitCKYLongexpo2 = NULL; + delete fitCKYLongexpo2; + } + else { + fSig_L = 0; + } + + // ------------------------------------------------------------------------------------------- + + if ( ( fT_GeV > 0.0 ) && ( fT_GeV < 0.15 ) ) { + eicSigmaT( fW_GeV, fQsq_GeV, tpar0, tpar1, tpar2 , tpar3 , tpar4 ); + TF1 *fitCKYTranspol2 = new TF1("sigmaL","pol2", 0.0 , 0.2 ); + fitCKYTranspol2->FixParameter( 0 , tpar0 ); + fitCKYTranspol2->FixParameter( 1 , tpar1 ); + fitCKYTranspol2->FixParameter( 2 , tpar2 ); + fSig_T = fitCKYTranspol2->Eval(fT_GeV); + if ( tpar0 == 0 || tpar1 == 0 || tpar2 == 0 ) + fSig_T = 0; + fitCKYTranspol2 = NULL; + delete fitCKYTranspol2; + } + else if ( ( fT_GeV > 0.2 ) && ( fT_GeV < 1.3 ) ) { + eicSigmaT( fW_GeV, fQsq_GeV, tpar0, tpar1, tpar2 , tpar3 , tpar4 ); + TF1 *fitCKYTransexpo = new TF1("sigmaL","expo", 0.2 , 1.3 ); + fitCKYTransexpo->FixParameter( 0 , tpar3 ); + fitCKYTransexpo->FixParameter( 1 , tpar4 ); + fSig_T = fitCKYTransexpo->Eval(fT_GeV); + if ( tpar3 == 0 || tpar4 == 0 ) + fSig_T = 0; + fitCKYTransexpo = NULL; + delete fitCKYTransexpo; + } + + // ------------------------------------------------------------------------------------------- + + fSig_VR = fSig_T + fEpsilon * fSig_L; + + // ------------------------------------------------------------------------------------------- + // CKY sigma L and T ends + // ------------------------------------------------------------------------------------------- + + fSigma_Col = fSig_VR * fFlux_Factor_Col * fA * fJacobian_CM_Col; + + // cout << endl; + // cout << setw(12) << "Qsq" << setw(12) << "-t" << setw(12) << "W" + // << setw(12) << "x" << setw(12) << "y" << setw(12) << "z" + // << setw(12) << "epsilon" << setw(12) << "phi" << setw(12) << "phis" + // << setw(12) << "sig" + // << endl; + // cout << setw(12) << fQsq_GeV << setw(12) << fT_GeV << setw(12) << fW_GeV + // << setw(12) << fx << setw(12) << fy << setw(12) << fz + // << setw(12) << fEpsilon << setw(12) << fPhi << setw(12) << fPhiS + // << setw(12) << fSigma_Col + // << endl; + + // cout << endl; + // cout << setw(12) << "Particle" << setw(12) << "Px" << setw(12) << "Py" << setw(12) << "Pz" << setw(12) << "Energy" << endl; + // cout << setw(12) << "Pion" + // << setw(12) << lpiong.X() + // << setw(12) << lpiong.Y() + // << setw(12) << lpiong.Z() + // << setw(12) << lpiong.E() + // << endl; + // cout << setw(12) << "Elec" + // << setw(12) << lscatelecg.X() + // << setw(12) << lscatelecg.Y() + // << setw(12) << lscatelecg.Z() + // << setw(12) << lscatelecg.E() + // << endl; + // cout << setw(12) << "Neutron" + // << setw(12) << lneutrong.X() + // << setw(12) << lneutrong.Y() + // << setw(12) << lneutrong.Z() + // << setw(12) << lneutrong.E() + // << endl; + + if ( ( fSigma_Col <= 0 ) || std::isnan( fSigma_Col ) ) { + fNSigmaNeg ++; + continue; + } + + // -------------------------------------------------------------------------------------------------- + // -------------------------------------------------------------------------------------------------- + // Lab cross section Phase Space Conversion Luminosity Total events tried + // Hz = ub / ( sr^2 * GeV ) * GeV * sr^2 * ( cm^2 / ub ) * ( # / ( cm^2 * sec ) ) / ( # ) + + fEventWeight = fSigma_Col * fPSF * fuBcm2 * fLumi / fNEvents; // in Hz + + fNRecorded ++; + fLundRecorded++; + fRatio = fNRecorded / fNGenerated; + + +// cout << "Sigma: " << fSigma_Col << " " << fEventWeight << endl; +// exit(0); + + + + ////*-------------------------------------------------- + /// Outputing to LUND file +// t1->Fill(); + + ppiOut << "3" + << " \t " << fPhi // var 1 + << " \t " << fPhiS // var 2 + << " \t " << fx // var 3 + << " \t " << "1" + << " \t " << fQsq_GeV // var 4 + << " \t " << fT_GeV // var 5 + << " \t " << fW_GeV // var 6 + << " \t " << fEpsilon // var 7 + << " \t " << fEventWeight // var 8 + << endl; + + // Pion - + ppiOut << setw(10) << "1" + << setw(10) << "1" + << setw(10) << "1" + << setw(10) << "211" + << setw(10) << "0" + << setw(10) << "0" + << setw(16) << lpiong.X() + << setw(16) << lpiong.Y() + << setw(16) << lpiong.Z() + << setw(16) << lpiong.E() + << setw(16) << fPion_Mass_GeV + << setw(16) << fVertex_X + << setw(16) << fVertex_Y + << setw(16) << fVertex_Z + << endl; + + // Electron + ppiOut << setw(10) << "2" + << setw(10) << "-1" + << setw(10) << "1" + << setw(10) << "11" + << setw(10) << "0" + << setw(10) << "0" + << setw(16) << lscatelecg.X() + << setw(16) << lscatelecg.Y() + << setw(16) << lscatelecg.Z() + << setw(16) << lscatelecg.E() + << setw(16) << fElectron_Mass_GeV + << setw(16) << fVertex_X + << setw(16) << fVertex_Y + << setw(16) << fVertex_Z + << endl; + + // Neutron + ppiOut << setw(10) << "3" + << setw(10) << "1" + << setw(10) << "1" + << setw(10) << "2112" + << setw(10) << "0" + << setw(10) << "0" + << setw(16) << lneutrong.X() + << setw(16) << lneutrong.Y() + << setw(16) << lneutrong.Z() + << setw(16) << lneutrong.E() + << setw(16) << fNeutron_Mass_GeV + << setw(16) << fVertex_X + << setw(16) << fVertex_Y + << setw(16) << fVertex_Z + << endl; + + + // break; + + // } + } // This is the loop over total events. + + ppiOut.close(); + + ppiDetails << "Total events tried " << setw(50) << fNGenerated << endl; + ppiDetails << "Total events recorded " << setw(50) << fNRecorded << endl; + + ppiDetails << "Seed used for the Random Number Generator " << setw(50) << fSeed << endl; + + ppiDetails << "Number of events with w more than 10.6 " << setw(50) << w_ev << endl; + ppiDetails << "Number of events with wsq negative " << setw(50) << w_neg_ev << endl; + ppiDetails << "Number of events with qsq less than 4 " << setw(50) << qsq_ev << endl; + ppiDetails << "Number of events with -t more than threshold " << setw(50) << t_ev << endl; + + ppiDetails << "Number of events with w less than threshold " << setw(50) << fWSqNeg << endl; + ppiDetails << "Number of events with mom not conserve " << setw(50) << fNMomConserve << endl; + ppiDetails << "Number of events with Sigma negative " << setw(50) << fNSigmaNeg << endl; + ppiDetails << "Number of lund events " << setw(50) << fLundRecorded << endl; + + ppiDetails.close(); + +} + + + +/*--------------------------------------------------*/ +/*--------------------------------------------------*/ +/*--------------------------------------------------*/ +/*--------------------------------------------------*/ +/// Omega Function +/// Author: Wenliang (Bill) Li +/// Date: March 08, 2020 +/// Comment: this is not completed and untested, the physics model is not implemented + + +void Exclusive_Omega_Prodoction(pim myPim) { + + cout << "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" << endl; + cout << "~ Omega electroproduction is chosen. ~" << endl; + + ///*--------------------------------------------------*/ + /// Setting seed for generation and initiation + + // kCalcFermi = true; + + string sTFile; + sTFile = Form("./LundFiles/eic_%s.txt", gfile_name.Data()); + +// string sRFile; +// sRFile = Form("./RootFiles/eic_%s.root", file_name.Data()); + + string sLFile; + sLFile= Form("./LundFiles/eic_input_%s.dat", gfile_name.Data()); + + ofstream ppiOut ( sLFile.c_str() ); + ofstream ppiDetails ( sTFile.c_str() ); + + // myPim.setrootfile( sRFile ); + + int qsq_ev = 0, t_ev = 0, w_neg_ev = 0, w_ev = 0; + +// t1->SetDirectory( f ); +// t1->SetAutoSave( 1000000000 ); + + long long int i; + for ( i = 0; i < fNEvents; i++ ) { + + TDatime dFractTime; + + fNGenerated ++; + + if ( i % ( fNEvents / 10 ) == 0 ) { + cout << "Event: " << setw(8) << i + << " % of events " << setw(4) << ((1.0*i)/(1.0*fNEvents))*100.0 + << " Day: " << dFractTime.GetDay() + << " Time: " << dFractTime.GetHour() + << ":" << dFractTime.GetMinute() + << ":" << dFractTime.GetSecond() + << endl; + } + + // ---------------------------------------------------- + // Proton in collider (lab) frame + // ---------------------------------------------------- + + fProton_Theta_Col = 50.0e-3; + fProton_Phi_Col = fPi; + fProton_Mom_Col = fPBeam * 1e3; + fVertex_X = 0.; + fVertex_Y = 0.; + fVertex_Z = 0.; + + if ( kCalcFermi ) { + fProton_Mom_Col = fProton_Mom_Col + myPim.fermiMomentum(); + fProton_Theta_Col = acos( fRandom->Uniform( cos(0.0) , cos(fPi) ) ); + fProton_Phi_Col = fRandom->Uniform( 0 , 360 ); + } + + TLorentzVector lproton( fProton_Mom_Col * sin(fProton_Theta_Col) * cos(fProton_Phi_Col), + fProton_Mom_Col * sin(fProton_Theta_Col) * sin(fProton_Phi_Col), + fProton_Mom_Col * cos(fProton_Theta_Col), + sqrt( pow( fProton_Mom_Col , 2 ) + pow( fProton_Mass , 2 ) ) ); + + TLorentzVector lprotong; + lprotong = lproton * fm; + + // ---------------------------------------------------- + // Boost vector from collider (lab) frame to protons rest frame (Fix target) + // ---------------------------------------------------- + + TVector3 beta_col_rf; + beta_col_rf = lproton.BoostVector(); + fGamma_Col_RF = 1.0/sqrt( 1 - pow( beta_col_rf.Mag() , 2 ) ); + + // ---------------------------------------------------- + // Electron in collider (lab) frame + // ---------------------------------------------------- + fElectron_Energy_Col = fElectron_Kin_Col; + fElectron_Mom_Col = sqrt( pow(fElectron_Energy_Col , 2) - pow(fElectron_Mass , 2) ); + fElectron_Theta_Col = fPi; + fElectron_Phi_Col = 0.0; + fElectron_MomZ_Col = fElectron_Mom_Col * cos(fElectron_Theta_Col); + fElectron_MomX_Col = fElectron_Mom_Col * sin(fElectron_Theta_Col) * cos(fElectron_Phi_Col); + fElectron_MomY_Col = fElectron_Mom_Col * sin(fElectron_Theta_Col) * sin(fElectron_Phi_Col); + + TLorentzVector lelectron( fElectron_MomX_Col, fElectron_MomY_Col, fElectron_MomZ_Col, fElectron_Energy_Col); + TLorentzVector lelectrong; + lelectrong = lelectron * fm; + + // --------------------------------------------------------------------- + // Specify the energy and solid angle of scatterd electron in Collider (lab) frame + // --------------------------------------------------------------------- + fScatElec_Theta_Col = acos( fRandom->Uniform( cos( fScatElec_Theta_I ) , cos( fScatElec_Theta_F ) ) ); + fScatElec_Phi_Col = fRandom->Uniform( 0 , 2.0 * fPi); + fScatElec_Energy_Col = fRandom->Uniform( fScatElec_E_Lo * fElectron_Energy_Col , fScatElec_E_Hi * fElectron_Energy_Col ); + +// fPion_Theta_Col = acos( fRandom->Uniform( cos(fPion_Theta_I ) , cos(fPion_Theta_F ) ) ); +// fPion_Phi_Col = fRandom->Uniform( 0 , 2.0 * fPi ); + + fOmega_Theta_Col = acos( fRandom->Uniform( cos(fOmega_Theta_I ) , cos(fOmega_Theta_F ) ) ); + fOmega_Phi_Col = fRandom->Uniform( 0 , 2.0 * fPi ); + + + + // fScatElec_Theta_Col = 146.356*fDEG2RAD; + // fScatElec_Phi_Col = 11.8325*fDEG2RAD; + // fScatElec_Energy_Col = 5.25281*1000.0; + // fPion_Theta_Col = 14.5869*fDEG2RAD; + // fPion_Phi_Col = -168.57*fDEG2RAD; + + fScatElec_Mom_Col = sqrt( pow( fScatElec_Energy_Col,2) - pow( fElectron_Mass , 2) ); + fScatElec_MomZ_Col = ( fScatElec_Mom_Col * cos(fScatElec_Theta_Col) ); + fScatElec_MomX_Col = ( fScatElec_Mom_Col * sin(fScatElec_Theta_Col) * cos(fScatElec_Phi_Col) ); + fScatElec_MomY_Col = ( fScatElec_Mom_Col * sin(fScatElec_Theta_Col) * sin(fScatElec_Phi_Col) ); + + TLorentzVector lscatelec( fScatElec_MomX_Col, fScatElec_MomY_Col, fScatElec_MomZ_Col, fScatElec_Energy_Col); + TLorentzVector lscatelecg; + lscatelecg = lscatelec * fm; + + // ---------------------------------------------------- + // Photon in collider (lab) frame and Qsq + // ---------------------------------------------------- + + TLorentzVector lphoton; + lphoton = lelectron - lscatelec; + TLorentzVector lphotong; + lphotong = lelectrong - lscatelecg; + + fQsq_GeV = -1.*lphotong.Mag2(); + + if ( fQsq_GeV < 5.0 ) { + qsq_ev++; + continue; + } + + // ---------------------------------------------------- + // W square, Invariant Mass (P_g + P_p)^2 + // ---------------------------------------------------- + + TLorentzVector lwg; + lwg = lprotong + lphotong; + fW_GeV = lwg.Mag(); + fWSq_GeV = lwg.Mag2(); + + if ( fWSq_GeV < 0 ) { + w_neg_ev++; + continue; + } + + // ---------------------------------------------------- + // Pion in Collider frame + // ---------------------------------------------------- + // fPion_Theta_Col = acos( fRandom->Uniform( cos(fPion_Theta_I ) , cos(fPion_Theta_F ) ) ); + // fPion_Phi_Col = fRandom->Uniform( 0 , 360 ); + + // --------------------------------------------------------- + // Pion momentum in collider frame, analytic solution starts + // --------------------------------------------------------- + + double fupx = sin( fOmega_Theta_Col ) * cos( fOmega_Phi_Col ); + double fupy = sin( fOmega_Theta_Col ) * sin( fOmega_Phi_Col ); + double fupz = cos( fOmega_Theta_Col ); + + double fuqx = sin( lphoton.Theta() ) * cos( lphoton.Phi() ); + double fuqy = sin( lphoton.Theta() ) * sin( lphoton.Phi() ); + double fuqz = cos( lphoton.Theta() ); + + double fa = -(lphoton.Vect()).Mag() * ( fupx * fuqx + fupy * fuqy + fupz * fuqz ); + double fb = pow ( (lphoton.Vect()).Mag() , 2 ); + double fc = lphoton.E() + fProton_Mass; + + fa = ( fa - std::abs( (lproton.Vect()).Mag() ) * ( ( ( lproton.X() / (lproton.Vect()).Mag() ) * fupx ) + + ( ( lproton.Y() / (lproton.Vect()).Mag() ) * fupy ) + + ( ( lproton.Z() / (lproton.Vect()).Mag() ) * fupz ) ) ); + + double factor = ( pow( (lproton.Vect()).Mag() , 2 ) + 2.0 * (lphoton.Vect()).Mag() * (lproton.Vect()).Mag() * + ( ( ( lproton.X() / (lproton.Vect()).Mag() ) * fuqx ) + + ( ( lproton.Y() / (lproton.Vect()).Mag() ) * fuqy ) + + ( ( lproton.Z() / (lproton.Vect()).Mag() ) * fuqz ) ) ); + + fb = fb + factor; + fc = lphoton.E() + lproton.E(); + +// double ft = fc * fc - fb + fPion_Mass * fPion_Mass - fProton_Mass * fProton_Mass; + double ft = fc * fc - fb + fOmega_Mass * fOmega_Mass - fProton_Mass * fProton_Mass; + + double fQA = 4.0 * ( fa * fa - fc * fc ); + double fQB = 4.0 * fc * ft; + +// double fQC = -4.0 * fa * fa * fPion_Mass * fPion_Mass - ft * ft; + double fQC = -4.0 * fa * fa * fOmega_Mass * fOmega_Mass - ft * ft; + + fradical = fQB * fQB - 4.0 * fQA * fQC; + + fepi1 = ( -fQB - sqrt( fradical ) ) / ( 2.0 * fQA ); + fepi2 = ( -fQB + sqrt( fradical ) ) / ( 2.0 * fQA ); + +// fPion_Mom_Same = 0; +// if ( std::abs(fepi1 - fepi2) < fDiff ){ fPion_Mom_Same = 1; } + + // --------------------------------------------------------- + // Pion momentum in collider frame, analytic solution ends + // --------------------------------------------------------- + + TLorentzVector lomega( ( sqrt( pow( fepi1 , 2) - pow(fOmega_Mass , 2) ) ) * sin(fOmega_Theta_Col) * cos(fOmega_Phi_Col), + ( sqrt( pow( fepi1 , 2) - pow(fOmega_Mass , 2) ) ) * sin(fOmega_Theta_Col) * sin(fOmega_Phi_Col), + ( sqrt( pow( fepi1 , 2) - pow(fOmega_Mass , 2) ) ) * cos(fOmega_Theta_Col), + fepi1 ); + + TLorentzVector lomega_g; + lomega_g = lomega * fm; + + TLorentzVector l_scat_proton( ( lproton + lelectron - lscatelec - lomega ).X(), + ( lproton + lelectron - lscatelec - lomega ).Y(), + ( lproton + lelectron - lscatelec - lomega ).Z(), + sqrt( pow( ( ( ( lproton + lelectron - lscatelec - lomega ).Vect() ).Mag()),2) + + pow( fProton_Mass ,2 ) ) ); + TLorentzVector l_scat_proton_g; + l_scat_proton_g = l_scat_proton * fm; + +// fNeutron_Mom_Col_GeV = (lneutrong.Vect()).Mag(); +// fNeutron_MomZ_Col_GeV = lneutrong.Z(); +// fNeutron_MomX_Col_GeV = lneutrong.X(); +// fNeutron_MomY_Col_GeV = lneutrong.Y(); +// fNeutron_Energy_Col_GeV = lneutrong.E(); + + + + + // -------------------------------------------------------------------------------------------------------- + // -------------------------------------------------------------------------------------------------------- + // Calculate w = (proton + photon)^2 + // -------------------------------------------------------------------------------------------------------- + // -------------------------------------------------------------------------------------------------------- + + // cout << fW_GeV << endl; + if ( fW_GeV < 3.0 || fW_GeV > 10.6 ) { + w_ev++; + continue; + } + + TLorentzVector lw; + lw = lproton + lphoton; + fW = lw.Mag(); + + // -------------------------------------------------------------------------------------------------------- + // -------------------------------------------------------------------------------------------------------- + // Calculate w prime w' = (proton + photon - pion)^2 + // -------------------------------------------------------------------------------------------------------- + // -------------------------------------------------------------------------------------------------------- + + TLorentzVector lwp = lprotong + lphotong - lomega_g; + fW_Prime_GeV = lwp.Mag(); + + TLorentzVector fsini; + fsini = lelectron + lproton; + TLorentzVector fsfin; + fsfin = lscatelec + lomega + l_scat_proton; + + TLorentzVector fsinig; + fsinig = fsini * fm; + TLorentzVector fsfing; + fsfing = fsfin * fm; + + fMandSConserve = std::abs( fsinig.Mag() - fsfing.Mag() ); + + kSConserve = false; + if( std::abs( fsinig.Mag() - fsfing.Mag() ) < fDiff ) { + kSConserve = true; + } + + if ( myPim.CheckLaws( lelectron, lproton, lscatelec, lomega, l_scat_proton) != 1 ) + continue; + + + + + + //////////////////////////////////////////////////////////////////////////////////////////// + // Start // + // Transformation of e', pi- and recoil proton to target's rest frmae without energy loss // + //////////////////////////////////////////////////////////////////////////////////////////// + + TLorentzVector lproton_rf; + lproton_rf = lproton; + lproton_rf.Boost(-beta_col_rf); + TLorentzVector lproton_rfg; + lproton_rfg = lproton_rf * fm; + + TLorentzVector lelectron_rf; + lelectron_rf = lelectron; + lelectron_rf.Boost(-beta_col_rf); + TLorentzVector lelectron_rfg; + lelectron_rfg = lelectron_rf * fm; + + TLorentzVector lscatelec_rf; + lscatelec_rf = lscatelec; + lscatelec_rf.Boost(-beta_col_rf); + TLorentzVector lscatelec_rfg; + lscatelec_rfg = lscatelec_rf * fm; + + TLorentzVector lphoton_rf; + lphoton_rf = lphoton; + lphoton_rf.Boost(-beta_col_rf); + TLorentzVector lphoton_rfg; + lphoton_rfg = lphoton_rf * fm; + + TLorentzVector lomega_rf; + lomega_rf = lomega; + lomega_rf.Boost(-beta_col_rf); + TLorentzVector lomega_rfg; + lomega_rfg = lomega_rf * fm; + + TLorentzVector l_scat_proton_rf; + l_scat_proton_rf = l_scat_proton; + l_scat_proton_rf.Boost(-beta_col_rf); + TLorentzVector l_scat_proton_rf_g; + l_scat_proton_rf_g = l_scat_proton_rf * fm; + + //////////////////////////////////////////////////////////////////////////////////////////// + // End // + // Transformation of e', pi- and recoil proton to target's rest frmae without energy loss // + //////////////////////////////////////////////////////////////////////////////////////////// + + // fElectron_Energy_RF_GeV = lelectron_rf.E() / 1000.0; + // fElectron_Mom_RF_GeV = (lelectron_rf.Vect()).Mag() / 1000.0; + // fElectron_MomX_RF_GeV = lelectron_rf.X() / 1000.0; + // fElectron_MomY_RF_GeV = lelectron_rf.Y() / 1000.0; + // fElectron_MomZ_RF_GeV = lelectron_rf.Z() / 1000.0; + +// fScatElec_Energy_RF_GeV = lscatelec_rf.E() / 1000.0; +// fScatElec_Mom_RF_GeV = (lscatelec_rf.Vect()).Mag() / 1000.0; +// fScatElec_MomX_RF_GeV = lscatelec_rf.X() / 1000.0; +// fScatElec_MomY_RF_GeV = lscatelec_rf.Y() / 1000.0; +// fScatElec_MomZ_RF_GeV = lscatelec_rf.Z() / 1000.0; + +// fPion_Energy_RF_GeV = lpion_rf.E() / 1000.0; +// fPion_Mom_RF_GeV = (lpion_rf.Vect()).Mag() / 1000.0; +// fPion_MomX_RF_GeV = lpion_rf.X() / 1000.0; +// fPion_MomY_RF_GeV = lpion_rf.Y() / 1000.0; +// fPion_MomZ_RF_GeV = lpion_rf.Z() / 1000.0; +// +// fNeutron_Energy_RF_GeV = lneutron_rf.E() / 1000.0; +// fNeutron_Mom_RF_GeV = (lneutron_rf.Vect()).Mag() / 1000.0; +// fNeutron_MomX_RF_GeV = lneutron_rf.X() / 1000.0; +// fNeutron_MomY_RF_GeV = lneutron_rf.Y() / 1000.0; +// fNeutron_MomZ_RF_GeV = lneutron_rf.Z() / 1000.0; + + // if ( myPim.CheckLaws( lelectron_rf, lproton_rf, lscatelec_rf, lpion_rf, lneutron_rf ) != 1 ) + // continue; + + // ----------------------------------------------------------------------------------------------------- + // ----------------------------------------------------------------------------------------------------- + // Calculate -t + // ----------------------------------------------------------------------------------------------------- + // ----------------------------------------------------------------------------------------------------- + +// fBeta_CM_RF = (lphoton_rf.Vect()).Mag() / ( lphoton_rf.E() + fProton_Mass ); +// fGamma_CM_RF = ( lphoton_rf.E() + fProton_Mass ) / fW; +// fPion_Energy_CM = ( pow( fW , 2) + pow(fPion_Mass , 2) - pow(fNeutron_Mass , 2) ) / ( 2.0 * fW); +// fPion_Mom_CM = sqrt( pow(fPion_Energy_CM , 2) - pow(fPion_Mass , 2)); +// fPion_Energy_CM_GeV = fPion_Energy_CM / 1000.0; +// fPion_Mom_CM_GeV = fPion_Mom_CM / 1000.0; + + + + fBeta_CM_RF = (lphoton_rf.Vect()).Mag() / ( lphoton_rf.E() + fProton_Mass ); + fGamma_CM_RF = ( lphoton_rf.E() + fProton_Mass ) / fW; + fOmega_Energy_CM = ( pow( fW , 2) + pow(fOmega_Mass , 2) - pow(fProton_Mass , 2) ) / ( 2.0 * fW); + fOmega_Mom_CM = sqrt( pow(fOmega_Energy_CM , 2) - pow(fOmega_Mass , 2)); + fOmega_Energy_CM_GeV = fOmega_Energy_CM / 1000.0; + fOmega_Mom_CM_GeV = fOmega_Mom_CM / 1000.0; + + + // this equation is valid for parallel kinematics only! + fT_Para = ( pow(((lphoton.Vect()).Mag() - (lomega.Vect()).Mag()),2) - pow((lphoton.E() - lomega.E()),2)); + fT_Para_GeV = fT_Para/1000000.0; + + TLorentzVector lt; + lt = lphoton - lomega; + TLorentzVector ltg; + ltg = lt * fm; + + fT = -1.*lt.Mag2(); + fT_GeV = -1.*ltg.Mag2(); + + if ( gKinematics_type == 1 && fT_GeV > 0.5 ) { + t_ev++; + continue; + } + + if ( gKinematics_type == 2 && fT_GeV > 1.3 ) { + t_ev++; + continue; + } + + fx = fQsq_GeV / ( 2.0 * lprotong.Dot( lphotong ) ); + fy = lprotong.Dot( lphotong ) / lprotong.Dot( lelectrong ); + fz = lomega.E()/lphoton.E(); + + // ------------------------------------------------------------------------------------------------------- + // ------------------------------------------------------------------------------------------------------- + + // ------------------------------------------------------------------------------------------------------- + // Calculation of Phi ( azimuthal angle of pion momentum w.r.t lepton plane in target's rest frame) + // Calculation of PhiS ( azimuthal angle of target polarization w.r.t lepton plane in target's rest frame) + // ------------------------------------------------------------------------------------------------------- + + TVector3 v3Photon; v3Photon.SetX( lphoton_rfg.X() ); v3Photon.SetY( lphoton_rfg.Y() ); v3Photon.SetZ( lphoton_rfg.Z() ); + TVector3 v3Electron; v3Electron.SetX( lelectron_rfg.X() ); v3Electron.SetY( lelectron_rfg.Y() ); v3Electron.SetZ( lelectron_rfg.Z() ); + TVector3 v3Omega; v3Omega.SetX( lomega_rfg.X() ) ; v3Omega.SetY( lomega_rfg.Y() ) ; v3Omega.SetZ( lomega_rfg.Z() ); + TVector3 v3S; v3S.SetX( -1 ); v3S.SetY( 0 ); v3S.SetZ( 0 ); + TVector3 v3PhotonUnit = v3Photon.Unit(); + TVector3 v3QxL = v3Photon.Cross(v3Electron); + TVector3 v3QxP = v3Photon.Cross(v3Omega); + TVector3 v3QxS = v3Photon.Cross(v3S); + TVector3 v3LxP = v3Electron.Cross(v3Omega); + TVector3 v3LxS = v3Electron.Cross(v3S); + TVector3 v3PxL = v3Omega.Cross(v3Electron); + TVector3 v3QUnitxL = v3PhotonUnit.Cross(v3Electron); + TVector3 v3QUnitxP = v3PhotonUnit.Cross(v3Omega); + TVector3 v3QUnitxS = v3PhotonUnit.Cross(v3S); + + fCos_Phi_Omega_LeptonPlane_RF = ( ( v3QUnitxL.Dot( v3QUnitxP ) ) / ( v3QUnitxL.Mag() * v3QUnitxP.Mag() ) ); // hep-ph/0410050v2 + fSin_Phi_Omega_LeptonPlane_RF = ( ( v3LxP.Dot( v3PhotonUnit ) ) / ( v3QUnitxL.Mag() * v3QUnitxP.Mag() ) ); // hep-ph/0410050v2 + if ( fSin_Phi_Omega_LeptonPlane_RF >= 0 ) + fPhi_Omega_LeptonPlane_RF = fRAD2DEG * acos( ( v3QUnitxL.Dot( v3QUnitxP ) ) / ( v3QUnitxL.Mag() * v3QUnitxP.Mag() ) ); + if ( fSin_Phi_Omega_LeptonPlane_RF < 0 ) + fPhi_Omega_LeptonPlane_RF = 360.0 - std::abs( fRAD2DEG * acos( ( v3QUnitxL.Dot( v3QUnitxP ) ) / ( v3QUnitxL.Mag() * v3QUnitxP.Mag() ) ) ); + + fCos_Phi_TargPol_LeptonPlane_RF = ( ( v3QUnitxL.Dot( v3QUnitxS ) ) / ( v3QUnitxL.Mag() * v3QUnitxS.Mag() ) ); // hep-ph/0410050v2 + fSin_Phi_TargPol_LeptonPlane_RF = ( ( v3LxS.Dot( v3PhotonUnit ) ) / ( v3QUnitxL.Mag() * v3QUnitxS.Mag() ) ); // hep-ph/0410050v2 + if ( fSin_Phi_TargPol_LeptonPlane_RF >= 0 ) + fPhi_TargPol_LeptonPlane_RF = fRAD2DEG * acos( ( v3QUnitxL.Dot( v3QUnitxS ) ) / ( v3QUnitxL.Mag() * v3QUnitxS.Mag() ) ); + if ( fSin_Phi_TargPol_LeptonPlane_RF < 0 ) + fPhi_TargPol_LeptonPlane_RF = 360.0 - std::abs( fRAD2DEG * acos( ( v3QUnitxL.Dot( v3QUnitxS ) ) / ( v3QUnitxL.Mag() * v3QUnitxS.Mag() ) ) ); + + fTheta_Omega_Photon_RF = fRAD2DEG * acos( ( v3Photon.Dot( v3Omega ) ) / ( v3Photon.Mag() * v3Omega.Mag() ) ); + if ( fTheta_Omega_Photon_RF < 0 ) { fTheta_Omega_Photon_RF = 180.0 + fTheta_Omega_Photon_RF; } + + fPhi = fPhi_Omega_LeptonPlane_RF; + fPhiS = fPhi_TargPol_LeptonPlane_RF; + + // ----------------------------------------------------------------------------------- + // If we have fermi momentum then epsilon should be in rest frame + // The theta angle of scattered angle used in expression of epsilon is the angle + // with respect to direction of incoming electron in the rest frame of target nucleon + // epsilon=1./(1.+ 2.*(pgam_restg**2)/q2g * *(tand(thscat_rest/2.))**2) + // ----------------------------------------------------------------------------------- + + double fTheta_EEp = (lelectron_rf.Vect()).Angle(lscatelec_rf.Vect()); + + fEpsilon = 1.0 / ( 1.0 + 2.0 * ( pow( (lphoton_rfg.Vect()).Mag(),2)/fQsq_GeV ) * pow( tan( fTheta_EEp / 2 ) , 2 ) ); + + // ---------------------------------------------------- + // Virtual Photon flux factor in units of 1/(GeV*Sr) + // ---------------------------------------------------- + fFlux_Factor_Col = (fAlpha/(2.0*pow(fPi,2))) * (lscatelecg.E() / lelectrong.E()) * + ( pow(fW_GeV,2) - pow(fProton_Mass_GeV,2) ) / (2.0*fProton_Mass_GeV*fQsq_GeV*(1.0 - fEpsilon)); + + fFlux_Factor_RF = ( fAlpha / ( 2.0 * pow( fPi , 2 ) ) ) * ( lscatelec_rfg.E() / lelectron_rfg.E() ) * + ( pow( fW_GeV , 2 ) - pow( fProton_Mass_GeV , 2 ) ) / + ( 2.0 * fProton_Mass_GeV * fQsq_GeV * ( 1.0 - fEpsilon ) ); + + // ---------------------------------------------------- + // Jacobian dt/dcos(theta*)dphi in units of GeV2/sr + // ---------------------------------------------------- + fJacobian_CM = ( (lphoton_rfg.Vect()).Mag() - fBeta_CM_RF * lphoton_rfg.E() ) / ( fGamma_CM_RF * ( 1.0 - pow(fBeta_CM_RF,2) ) ); + + fA = fJacobian_CM * fOmega_Mom_CM_GeV / fPi; + + // ---------------------------------------------------- + // Jacobian dOmega* / dOmega dimensionless + // ---------------------------------------------------- + fJacobian_CM_RF = ( pow((lomega_rf.Vect()).Mag(),2)*fW) / + ( fOmega_Mom_CM * std::abs( ( fProton_Mass + lphoton_rf.E()) * (lomega_rf.Vect()).Mag() - + ( lomega_rf.E() * (lphoton_rf.Vect()).Mag() * cos( lomega_rf.Theta() ) ) ) ); + + fJacobian_CM_Col = ( ( pow((lomega.Vect()).Mag(),2) * fW ) / + ( fOmega_Mom_CM * std::abs( ( fProton_Mass + lphoton.E() ) * (lomega.Vect()).Mag() - + ( lomega.E() * (lphoton.Vect()).Mag() * cos( lomega.Theta() ) ) ) ) ); + + + // ------------------------------------------------------------------------------------------- + // CKY sigma L and T starts + // ------------------------------------------------------------------------------------------- + + fSig_T = 1; + fSig_L = 1; + + // ------------------------------------------------------------------------------------------- + + fSig_fpi_6GeV = fSig_T + fEpsilon * fSig_L; + + // ------------------------------------------------------------------------------------------- + // CKY sigma L and T ends + // ------------------------------------------------------------------------------------------- + + fSigma_Col = fSig_fpi_6GeV * fFlux_Factor_Col * fA * fJacobian_CM_Col; + + // cout << endl; + // cout << setw(12) << "Qsq" << setw(12) << "-t" << setw(12) << "W" + // << setw(12) << "x" << setw(12) << "y" << setw(12) << "z" + // << setw(12) << "epsilon" << setw(12) << "phi" << setw(12) << "phis" + // << setw(12) << "sig" + // << endl; + // cout << setw(12) << fQsq_GeV << setw(12) << fT_GeV << setw(12) << fW_GeV + // << setw(12) << fx << setw(12) << fy << setw(12) << fz + // << setw(12) << fEpsilon << setw(12) << fPhi << setw(12) << fPhiS + // << setw(12) << fSigma_Col + // << endl; + + // cout << endl; + // cout << setw(12) << "Particle" << setw(12) << "Px" << setw(12) << "Py" << setw(12) << "Pz" << setw(12) << "Energy" << endl; + // cout << setw(12) << "Pion" + // << setw(12) << lpiong.X() + // << setw(12) << lpiong.Y() + // << setw(12) << lpiong.Z() + // << setw(12) << lpiong.E() + // << endl; + // cout << setw(12) << "Elec" + // << setw(12) << lscatelecg.X() + // << setw(12) << lscatelecg.Y() + // << setw(12) << lscatelecg.Z() + // << setw(12) << lscatelecg.E() + // << endl; + // cout << setw(12) << "Neutron" + // << setw(12) << lneutrong.X() + // << setw(12) << lneutrong.Y() + // << setw(12) << lneutrong.Z() + // << setw(12) << lneutrong.E() + // << endl; + + if ( ( fSigma_Col <= 0 ) || std::isnan( fSigma_Col ) ) { + fNSigmaNeg ++; + continue; + } + + // ----------------------------------------------------------------------------------------------------------- + // ----------------------------------------------------------------------------------------------------------- + // Lab cross section Phase Space Conversion Luminosity Total events tried + // Hz = ub / ( sr^2 * GeV ) * GeV * sr^2 * ( cm^2 / ub ) * ( # / ( cm^2 * sec ) ) / ( # ) + + fEventWeight = fSigma_Col * fPSF * fuBcm2 * fLumi / fNEvents; // in Hz + + fNRecorded ++; + fLundRecorded++; + fRatio = fNRecorded / fNGenerated; + + + + + ////*-------------------------------------------------- + /// Outputing to LUND file +// t1->Fill(); + + ppiOut << "3" + << " \t " << fPhi // var 1 + << " \t " << fPhiS // var 2 + << " \t " << fx // var 3 + << " \t " << "1" + << " \t " << fQsq_GeV // var 4 + << " \t " << fT_GeV // var 5 + << " \t " << fW_GeV // var 6 + << " \t " << fEpsilon // var 7 + << " \t " << fEventWeight // var 8 + << endl; + + // Pion - + ppiOut << setw(10) << "1" + << setw(10) << "1" + << setw(10) << "1" + << setw(10) << "211" + << setw(10) << "0" + << setw(10) << "0" + << setw(16) << lomega_g.X() + << setw(16) << lomega_g.Y() + << setw(16) << lomega_g.Z() + << setw(16) << lomega_g.E() + << setw(16) << fPion_Mass_GeV + << setw(16) << fVertex_X + << setw(16) << fVertex_Y + << setw(16) << fVertex_Z + << endl; + + // Electron + ppiOut << setw(10) << "2" + << setw(10) << "-1" + << setw(10) << "1" + << setw(10) << "11" + << setw(10) << "0" + << setw(10) << "0" + << setw(16) << lscatelecg.X() + << setw(16) << lscatelecg.Y() + << setw(16) << lscatelecg.Z() + << setw(16) << lscatelecg.E() + << setw(16) << fElectron_Mass_GeV + << setw(16) << fVertex_X + << setw(16) << fVertex_Y + << setw(16) << fVertex_Z + << endl; + + // Neutron + ppiOut << setw(10) << "3" + << setw(10) << "1" + << setw(10) << "1" + << setw(10) << "2112" + << setw(10) << "0" + << setw(10) << "0" + << setw(16) << l_scat_proton.X() + << setw(16) << l_scat_proton.Y() + << setw(16) << l_scat_proton.Z() + << setw(16) << l_scat_proton.E() + << setw(16) << fProton_Mass_GeV + << setw(16) << fVertex_X + << setw(16) << fVertex_Y + << setw(16) << fVertex_Z + << endl; + + + // break; + + } // This is the loop over total events. + + ppiOut.close(); + + ppiDetails << "Total events tried " << setw(50) << fNGenerated << endl; + ppiDetails << "Total events recorded " << setw(50) << fNRecorded << endl; + + ppiDetails << "Seed used for the Random Number Generator " << setw(50) << fSeed << endl; + + ppiDetails << "Number of events with w more than 10.6 " << setw(50) << w_ev << endl; + ppiDetails << "Number of events with wsq negative " << setw(50) << w_neg_ev << endl; + ppiDetails << "Number of events with qsq less than 4 " << setw(50) << qsq_ev << endl; + ppiDetails << "Number of events with -t more than threshold " << setw(50) << t_ev << endl; + + ppiDetails << "Number of events with w less than threshold " << setw(50) << fWSqNeg << endl; + ppiDetails << "Number of events with mom not conserve " << setw(50) << fNMomConserve << endl; + ppiDetails << "Number of events with Sigma negative " << setw(50) << fNSigmaNeg << endl; + ppiDetails << "Number of lund events " << setw(50) << fLundRecorded << endl; + + ppiDetails.close(); + +} + + +/*--------------------------------------------------*/ +/*--------------------------------------------------*/ +/*--------------------------------------------------*/ +/*--------------------------------------------------*/ +/*--------------------------------------------------*/ + +// Transverse Sigma model from 6 GeV Lab data + +double fSig_fpi_sigT (double q2_gev, double up) { + + double sigt; + + double t0 = 7.0; + double t1 = -6; + + sigt = t0/sqrt(q2_gev) + t1*up/sqrt(q2_gev); + +// wfactor= 1 / ((w_gev**2-m_p**2)**2) + + return sigt; + +} + + +/*--------------------------------------------------*/ +/*--------------------------------------------------*/ +// Transverse Sigma model from 6 GeV Lab data + + +double fSig_fpi_sigL (double q2_gev, double up) { + + double sigl; + + double l0 = 12; + double l1 = -40; + + sigl = l0/(q2_gev*q2_gev) + l1*up/(q2_gev*q2_gev); + return sigl; + +// wfactor= 1 / ((w_gev**2-m_p**2)**2) + +} + diff --git a/src/eic_evgen/legacy_function.h b/src/eic_evgen/legacy_function.h new file mode 100644 index 0000000..a1fcc47 --- /dev/null +++ b/src/eic_evgen/legacy_function.h @@ -0,0 +1,21 @@ +# ifndef legacy_H +# define legacy_H + +#include +#include +#include + +#include "eic_pim.h" + +#include "TString.h" +#include "TF1.h" +#include "tssa_sig_Para.h" + +void Exclusive_Pion_Prodoction(pim); +void Exclusive_Omega_Prodoction(pim); + +double fSig_fpi_sigT (double, double); +double fSig_fpi_sigL (double, double); + +#endif + diff --git a/src/eic_evgen/main.o b/src/eic_evgen/main.o index b8e4fac..4c622e3 100644 Binary files a/src/eic_evgen/main.o and b/src/eic_evgen/main.o differ diff --git a/src/eic_evgen/particleType.h b/src/eic_evgen/particleType.h new file mode 100644 index 0000000..dd8e46f --- /dev/null +++ b/src/eic_evgen/particleType.h @@ -0,0 +1,2906 @@ +/* + * particleType.h +*/ + +#ifndef particleTypeH_INCLUDED +#define particleTypeH_INCLUDED + +#include +#include +#include + +typedef enum { + + /* An extensive list of the GEANT3 particle + * codes can be found here: + * http://wwwasdoc.web.cern.ch/wwwasdoc/geant/node72.html + */ + + Unknown = 0, + Gamma = 1, + Positron = 2, + Electron = 3, + Neutrino = 4, + MuonPlus = 5, + MuonMinus = 6, + Pi0 = 7, + PiPlus = 8, + PiMinus = 9, + KLong = 10, + KPlus = 11, + KMinus = 12, + Neutron = 13, + Proton = 14, + AntiProton = 15, + KShort = 16, + Eta = 17, + Lambda = 18, + SigmaPlus = 19, + Sigma0 = 20, + SigmaMinus = 21, + Xi0 = 22, + XiMinus = 23, + OmegaMinus = 24, + AntiNeutron = 25, + AntiLambda = 26, + AntiSigmaMinus = 27, + AntiSigma0 = 28, + AntiSigmaPlus = 29, + AntiXi0 = 30, + AntiXiPlus = 31, + AntiOmegaPlus = 32, + Deuteron = 45, + Triton = 46, + Helium = 47, + Geantino = 48, + He3 = 49, + + Li6 = 61, + Li7 = 62, + Be7 = 63, + Be9 = 64, + B10 = 65, + B11 = 66, + C12 = 67, + N14 = 68, + O16 = 69, + F19 = 70, + Ne20 = 71, + Na23 = 72, + Mg24 = 73, + Al27 = 74, + Si28 = 75, + P31 = 76, + S32 = 77, + Cl35 = 78, + Ar36 = 79, + K39 = 80, + Ca40 = 81, + Sc45 = 82, + Ti48 = 83, + V51 = 84, + Cr52 = 85, + Mn55 = 86, + Fe56 = 87, + Co59 = 88, + Ni58 = 89, + Cu63 = 90, + Zn64 = 91, + Ge74 = 92, + Se80 = 93, + Kr84 = 94, + Sr88 = 95, + Zr90 = 96, + Mo98 = 97, + Pd106 = 98, + Cd114 = 99, + Sn120 = 100, + Xe132 = 101, + Ba138 = 102, + Ce140 = 103, + Sm152 = 104, + Dy164 = 105, + Yb174 = 106, + W184 = 107, + Pt194 = 108, + Au197 = 109, + Hg202 = 110, + Pb208 = 111, + U238 = 112, + + /* the constants defined by GEANT end here */ + + /* + * Several particle codes are added below which did + * not overlap with the original GEANT particle list. + * However, the link above has several other particle + * codes added which do actually overlap. Because of + * this, each of the values below was increased by + * 100 so that they don't overlap with any of the new + * codes and they can be used. + */ + + + /* These are E852-defined constants */ + Rho0 = 44, // was 157 + RhoPlus = 42, // was 158 + RhoMinus = 43, // was 159 + omega = 33, // was 160 + phiMeson = 34, // was 162 + EtaPrime = 35, // was 161 + //Rho0 = 157, + //RhoPlus = 158, + //RhoMinus = 159, + //omega = 160, + //EtaPrime = 161, + //phiMeson = 162, + a0_980 = 163, + f0_980 = 164, + + /* These are GlueX-defined constants */ + + KStar_892_0 = 165, + KStar_892_Plus = 166, + KStar_892_Minus = 167, + AntiKStar_892_0 = 168, + + K1_1400_Plus = 169, + K1_1400_Minus = 170, + + b1_1235_Plus = 171, + Sigma_1385_Minus = 172, + Sigma_1385_0 = 173, + Sigma_1385_Plus = 174, + + Jpsi = 183, + Eta_c = 184, + Chi_c0 = 185, + Chi_c1 = 186, + Chi_c2 = 187, + Psi2s = 188, + D0 = 189, + DPlus = 190, + Dstar0 = 191, + DstarPlus = 192, + Lambda_c = 193, + AntiD0 = 194, + + /* These are defined in pythia-geant.map in bggen */ + + //Rho0 = 80, // already defined above (44) + //omega = 81, // already defined above (33) + DeltaPlusPlus = 182 + + +} Particle_t; + +static inline Particle_t RemapParticleID(Particle_t p) +{ + // bggen defines these in pythia-geant.dat. However, + // they are not the same as the definitions used from + // E-852 in the enum above. Remap them using this routine + // which is called from several of the routines below. + //if(p==80) return Rho0; + //if(p==81) return omega; + return p; +} + +inline static int IsLepton(Particle_t p) +{ + return ((p == Electron) || (p == Positron) || (p == MuonPlus) || (p == MuonMinus) || (p == Neutrino)); +} + +inline static char* ParticleType(Particle_t p) +{ + p = RemapParticleID(p); + + switch (p) { + case Unknown: + return (char*)"Unknown"; + case Gamma: + return (char*)"Photon"; + case Positron: + return (char*)"Positron"; + case Electron: + return (char*)"Electron"; + case Neutrino: + return (char*)"Neutrino"; + case MuonPlus: + return (char*)"Muon+"; + case MuonMinus: + return (char*)"Muon-"; + case Pi0: + return (char*)"Pi0"; + case PiPlus: + return (char*)"Pi+"; + case PiMinus: + return (char*)"Pi-"; + case KLong: + return (char*)"KLong"; + case KPlus: + return (char*)"K+"; + case KMinus: + return (char*)"K-"; + case Neutron: + return (char*)"Neutron"; + case Proton: + return (char*)"Proton"; + case AntiProton: + return (char*)"AntiProton"; + case KShort: + return (char*)"KShort"; + case Eta: + return (char*)"Eta"; + case Lambda: + return (char*)"Lambda"; + case SigmaPlus: + return (char*)"Sigma+"; + case Sigma0: + return (char*)"Sigma0"; + case SigmaMinus: + return (char*)"Sigma-"; + case Xi0: + return (char*)"Xi0"; + case XiMinus: + return (char*)"Xi-"; + case OmegaMinus: + return (char*)"Omega-"; + case AntiNeutron: + return (char*)"AntiNeutron"; + case AntiLambda: + return (char*)"AntiLambda"; + case AntiSigmaMinus: + return (char*)"AntiSigma-"; + case AntiSigma0: + return (char*)"AntiSigma0"; + case AntiSigmaPlus: + return (char*)"AntiSigma+"; + case AntiXi0: + return (char*)"AntiXi0"; + case AntiXiPlus: + return (char*)"AntiXi+"; + case AntiOmegaPlus: + return (char*)"AntiOmega+"; + case Geantino: + return (char*)"Geantino"; + case Rho0: + return (char*)"Rho0"; + case RhoPlus: + return (char*)"Rho+"; + case RhoMinus: + return (char*)"Rho-"; + case omega: + return (char*)"Omega"; + case EtaPrime: + return (char*)"EtaPrime"; + case phiMeson: + return (char*)"Phi"; + case a0_980: + return (char*)"a0(980)"; + case f0_980: + return (char*)"f0(980)"; + case KStar_892_0: + return (char*)"K*(892)0"; + case KStar_892_Plus: + return (char*)"K*(892)+"; + case KStar_892_Minus: + return (char*)"K*(892)-"; + case AntiKStar_892_0: + return (char*)"antiK*(892)0"; + case K1_1400_Plus: + return (char*)"K1(1400)+"; + case K1_1400_Minus: + return (char*)"K1(1400)-"; + case b1_1235_Plus: + return (char*)"b1(1235)+"; + case Sigma_1385_Minus: + return (char*)"Sigma(1385)-"; + case Sigma_1385_0: + return (char*)"Sigma(1385)0"; + case Sigma_1385_Plus: + return (char*)"Sigma(1385)+"; + case Deuteron: + return (char*)"Deuteron"; + case Triton: + return (char*)"Triton"; + case Helium: + return (char*)"Helium"; + case He3: + return (char*)"Helium-3"; + case Li6: + return (char*)"Lithium-6"; + case Li7: + return (char*)"Lithium-7"; + case Be7: + return (char*)"Beryllium-7"; + case Be9: + return (char*)"Beryllium-9"; + case B10: + return (char*)"Boron-10"; + case B11: + return (char*)"Boron-11"; + case C12: + return (char*)"Carbon"; + case N14: + return (char*)"Nitrogen"; + case O16: + return (char*)"Oxygen"; + case F19: + return (char*)"Fluorine"; + case Ne20: + return (char*)"Neon"; + case Na23: + return (char*)"Sodium"; + case Mg24: + return (char*)"Magnesium"; + case Al27: + return (char*)"Aluminum"; + case Si28: + return (char*)"Silicon"; + case P31: + return (char*)"Phosphorous"; + case S32: + return (char*)"Sulphur"; + case Cl35: + return (char*)"Chlorine"; + case Ar36: + return (char*)"Argon"; + case K39: + return (char*)"Potassium"; + case Ca40: + return (char*)"Calcium"; + case Sc45: + return (char*)"Scandium"; + case Ti48: + return (char*)"Titanium"; + case V51: + return (char*)"Vanadium"; + case Cr52: + return (char*)"Chromium"; + case Mn55: + return (char*)"Manganese"; + case Fe56: + return (char*)"Iron"; + case Co59: + return (char*)"Cobalt"; + case Ni58: + return (char*)"Nickel"; + case Cu63: + return (char*)"Copper"; + case Zn64: + return (char*)"Zinc"; + case Ge74: + return (char*)"Germanium"; + case Se80: + return (char*)"Selenium"; + case Kr84: + return (char*)"Krypton"; + case Sr88: + return (char*)"Strontium"; + case Zr90: + return (char*)"Zirconium"; + case Mo98: + return (char*)"Molybdenum"; + case Pd106: + return (char*)"Palladium"; + case Cd114: + return (char*)"Cadmium"; + case Sn120: + return (char*)"Tin"; + case Xe132: + return (char*)"Xenon"; + case Ba138: + return (char*)"Barium"; + case Ce140: + return (char*)"Cesium"; + case Sm152: + return (char*)"Samerium"; + case Dy164: + return (char*)"Dysprosium"; + case Yb174: + return (char*)"Ytterbium"; + case W184: + return (char*)"Tungsten"; + case Pt194: + return (char*)"Platium"; + case Au197: + return (char*)"Gold"; + case Hg202: + return (char*)"Mercury"; + case Pb208: + return (char*)"Lead"; + case U238: + return (char*)"Uranium"; + case DeltaPlusPlus: + return (char*)"Delta++"; + case Jpsi: + return (char*)"Jpsi"; + case Eta_c: + return (char*)"EtaC"; + case Chi_c0: + return (char*)"ChiC0"; + case Chi_c1: + return (char*)"ChiC1"; + case Chi_c2: + return (char*)"ChiC2"; + case Psi2s: + return (char*)"Psi(2S)"; + case D0: + return (char*)"D0"; + case AntiD0: + return (char*)"AntiD0"; + case DPlus: + return (char*)"D+"; + case Dstar0: + return (char*)"D*0"; + case DstarPlus: + return (char*)"D*+"; + case Lambda_c: + return (char*)"LambdaC"; + default: + return (char*)"Unknown"; + } +} + +inline static char* EnumString(Particle_t p) +{ + //returns string that is exact match to enum name. for auto-generating code + p = RemapParticleID(p); + + switch (p) { + case Unknown: + return (char*)"Unknown"; + case Gamma: + return (char*)"Gamma"; + case Positron: + return (char*)"Positron"; + case Electron: + return (char*)"Electron"; + case Neutrino: + return (char*)"Neutrino"; + case MuonPlus: + return (char*)"MuonPlus"; + case MuonMinus: + return (char*)"MuonMinus"; + case Pi0: + return (char*)"Pi0"; + case PiPlus: + return (char*)"PiPlus"; + case PiMinus: + return (char*)"PiMinus"; + case KLong: + return (char*)"KLong"; + case KPlus: + return (char*)"KPlus"; + case KMinus: + return (char*)"KMinus"; + case Neutron: + return (char*)"Neutron"; + case Proton: + return (char*)"Proton"; + case AntiProton: + return (char*)"AntiProton"; + case KShort: + return (char*)"KShort"; + case Eta: + return (char*)"Eta"; + case Lambda: + return (char*)"Lambda"; + case SigmaPlus: + return (char*)"SigmaPlus"; + case Sigma0: + return (char*)"Sigma0"; + case SigmaMinus: + return (char*)"SigmaMinus"; + case Xi0: + return (char*)"Xi0"; + case XiMinus: + return (char*)"XiMinus"; + case OmegaMinus: + return (char*)"OmegaMinus"; + case AntiNeutron: + return (char*)"AntiNeutron"; + case AntiLambda: + return (char*)"AntiLambda"; + case AntiSigmaMinus: + return (char*)"AntiSigmaMinus"; + case AntiSigma0: + return (char*)"AntiSigma0"; + case AntiSigmaPlus: + return (char*)"AntiSigmaPlus"; + case AntiXi0: + return (char*)"AntiXi0"; + case AntiXiPlus: + return (char*)"AntiXiPlus"; + case AntiOmegaPlus: + return (char*)"AntiOmegaPlus"; + case Geantino: + return (char*)"Geantino"; + case Rho0: + return (char*)"Rho0"; + case RhoPlus: + return (char*)"RhoPlus"; + case RhoMinus: + return (char*)"RhoMinus"; + case omega: + return (char*)"omega"; + case EtaPrime: + return (char*)"EtaPrime"; + case phiMeson: + return (char*)"phiMeson"; + case a0_980: + return (char*)"a0_980"; + case f0_980: + return (char*)"f0_980"; + case KStar_892_0: + return (char*)"KStar_892_0"; + case KStar_892_Plus: + return (char*)"KStar_892_Plus"; + case KStar_892_Minus: + return (char*)"KStar_892_Minus"; + case AntiKStar_892_0: + return (char*)"AntiKStar_892_0"; + case K1_1400_Plus: + return (char*)"K1_1400_Plus"; + case K1_1400_Minus: + return (char*)"K1_1400_Minus"; + case b1_1235_Plus: + return (char*)"b1_1235_Plus"; + case Sigma_1385_Minus: + return (char*)"Sigma_1385_Minus"; + case Sigma_1385_0: + return (char*)"Sigma_1385_0"; + case Sigma_1385_Plus: + return (char*)"Sigma_1385_Plus"; + case Deuteron: + return (char*)"Deuteron"; + case Triton: + return (char*)"Triton"; + case Helium: + return (char*)"Helium"; + case He3: + return (char*)"Helium-3"; + case Li6: + return (char*)"Lithium-6"; + case Li7: + return (char*)"Lithium-7"; + case Be7: + return (char*)"Beryllium-7"; + case Be9: + return (char*)"Beryllium-9"; + case B10: + return (char*)"Boron-10"; + case B11: + return (char*)"Boron-11"; + case C12: + return (char*)"Carbon"; + case N14: + return (char*)"Nitrogen"; + case O16: + return (char*)"Oxygen"; + case F19: + return (char*)"Fluorine"; + case Ne20: + return (char*)"Neon"; + case Na23: + return (char*)"Sodium"; + case Mg24: + return (char*)"Magnesium"; + case Al27: + return (char*)"Aluminum"; + case Si28: + return (char*)"Silicon"; + case P31: + return (char*)"Phosphorous"; + case S32: + return (char*)"Sulphur"; + case Cl35: + return (char*)"Chlorine"; + case Ar36: + return (char*)"Argon"; + case K39: + return (char*)"Potassium"; + case Ca40: + return (char*)"Calcium"; + case Sc45: + return (char*)"Scandium"; + case Ti48: + return (char*)"Titanium"; + case V51: + return (char*)"Vanadium"; + case Cr52: + return (char*)"Chromium"; + case Mn55: + return (char*)"Manganese"; + case Fe56: + return (char*)"Iron"; + case Co59: + return (char*)"Cobalt"; + case Ni58: + return (char*)"Nickel"; + case Cu63: + return (char*)"Copper"; + case Zn64: + return (char*)"Zinc"; + case Ge74: + return (char*)"Germanium"; + case Se80: + return (char*)"Selenium"; + case Kr84: + return (char*)"Krypton"; + case Sr88: + return (char*)"Strontium"; + case Zr90: + return (char*)"Zirconium"; + case Mo98: + return (char*)"Molybdenum"; + case Pd106: + return (char*)"Palladium"; + case Cd114: + return (char*)"Cadmium"; + case Sn120: + return (char*)"Tin"; + case Xe132: + return (char*)"Xenon"; + case Ba138: + return (char*)"Barium"; + case Ce140: + return (char*)"Cesium"; + case Sm152: + return (char*)"Samerium"; + case Dy164: + return (char*)"Dysprosium"; + case Yb174: + return (char*)"Ytterbium"; + case W184: + return (char*)"Tungsten"; + case Pt194: + return (char*)"Platium"; + case Au197: + return (char*)"Gold"; + case Hg202: + return (char*)"Mercury"; + case Pb208: + return (char*)"Lead"; + case U238: + return (char*)"Uranium"; + case DeltaPlusPlus: + return (char*)"DeltaPlusPlus"; + case Jpsi: + return (char*)"Jpsi"; + case Eta_c: + return (char*)"Eta_c"; + case Chi_c0: + return (char*)"Chi_c0"; + case Chi_c1: + return (char*)"Chi_c1"; + case Chi_c2: + return (char*)"Chi_c2"; + case Psi2s: + return (char*)"Psi2s"; + case D0: + return (char*)"D0"; + case AntiD0: + return (char*)"AntiD0"; + case DPlus: + return (char*)"DPlus"; + case Dstar0: + return (char*)"Dstar0"; + case DstarPlus: + return (char*)"DstarPlus"; + case Lambda_c: + return (char*)"Lambda_c"; + default: + return (char*)"Unknown"; + } +} + +inline static char* EvtGenString(Particle_t p) +{ + //returns string that is exact match to enum name. for auto-generating code + p = RemapParticleID(p); + + switch (p) { + case Unknown: + return (char*)"Unknown"; + case Gamma: + return (char*)"gamma"; + case Positron: + return (char*)"e+"; + case Electron: + return (char*)"e-"; + case Neutrino: + return (char*)"nu_e"; + case MuonPlus: + return (char*)"mu+"; + case MuonMinus: + return (char*)"mu-"; + case Pi0: + return (char*)"pi0"; + case PiPlus: + return (char*)"pi+"; + case PiMinus: + return (char*)"pi-"; + case KLong: + return (char*)"K_L0"; + case KPlus: + return (char*)"K+"; + case KMinus: + return (char*)"K-"; + case Neutron: + return (char*)"n0"; + case Proton: + return (char*)"p+"; + case AntiProton: + return (char*)"anti-p-"; + case KShort: + return (char*)"K_S0"; + case Eta: + return (char*)"eta"; + case Lambda: + return (char*)"Lambda0"; + case SigmaPlus: + return (char*)"Sigma+"; + case Sigma0: + return (char*)"Sigma0"; + case SigmaMinus: + return (char*)"Sigma-"; + case Xi0: + return (char*)"Xi0"; + case XiMinus: + return (char*)"Xi-"; + case OmegaMinus: + return (char*)"Omega-"; + case AntiNeutron: + return (char*)"anti-n0"; + case AntiLambda: + return (char*)"anti-Lambda0"; + case AntiSigmaMinus: + return (char*)"anti-Sigma-"; + case AntiSigma0: + return (char*)"anti-Sigma0"; + case AntiSigmaPlus: + return (char*)"anti-Sigma+"; + case AntiXi0: + return (char*)"anti-Xi0"; + case AntiXiPlus: + return (char*)"anti-Xi+"; + case AntiOmegaPlus: + return (char*)"anti-Omega+"; + case Geantino: + return (char*)"geantino"; + case Rho0: + return (char*)"rho0"; + case RhoPlus: + return (char*)"rho+"; + case RhoMinus: + return (char*)"rho-"; + case omega: + return (char*)"omega"; + case EtaPrime: + return (char*)"eta'"; + case phiMeson: + return (char*)"phi"; + case a0_980: + return (char*)"a_0"; + case f0_980: + return (char*)"f_0"; + case KStar_892_0: + return (char*)"K*0"; + case KStar_892_Plus: + return (char*)"K*+"; + case KStar_892_Minus: + return (char*)"K*-"; + case AntiKStar_892_0: + return (char*)"anti-K*0"; + case K1_1400_Plus: + return (char*)"K'_1+"; + case K1_1400_Minus: + return (char*)"K'_1-"; + case b1_1235_Plus: + return (char*)"b_1+"; + case Sigma_1385_Minus: + return (char*)"Sigma_1385_Minus"; + case Sigma_1385_0: + return (char*)"Sigma_1385_0"; + case Sigma_1385_Plus: + return (char*)"Sigma_1385_Plus"; + case Deuteron: + return (char*)"deuteron"; + case Triton: + return (char*)"Triton"; // FIX + case Helium: + return (char*)"Helium"; // FIX + case He3: + return (char*)"He3"; + case Li6: + return (char*)"Lithium-6"; + case Li7: + return (char*)"Lithium-7"; + case Be7: + return (char*)"Beryllium-7"; + case Be9: + return (char*)"Beryllium-9"; + case B10: + return (char*)"Boron-10"; + case B11: + return (char*)"Boron-11"; + case C12: + return (char*)"Carbon"; + case N14: + return (char*)"Nitrogen"; + case O16: + return (char*)"Oxygen"; + case F19: + return (char*)"Fluorine"; + case Ne20: + return (char*)"Neon"; + case Na23: + return (char*)"Sodium"; + case Mg24: + return (char*)"Magnesium"; + case Al27: + return (char*)"Aluminum"; + case Si28: + return (char*)"Silicon"; + case P31: + return (char*)"Phosphorous"; + case S32: + return (char*)"Sulphur"; + case Cl35: + return (char*)"Chlorine"; + case Ar36: + return (char*)"Argon"; + case K39: + return (char*)"Potassium"; + case Ca40: + return (char*)"Calcium"; + case Sc45: + return (char*)"Scandium"; + case Ti48: + return (char*)"Titanium"; + case V51: + return (char*)"Vanadium"; + case Cr52: + return (char*)"Chromium"; + case Mn55: + return (char*)"Manganese"; + case Fe56: + return (char*)"Iron"; + case Co59: + return (char*)"Cobalt"; + case Ni58: + return (char*)"Nickel"; + case Cu63: + return (char*)"Copper"; + case Zn64: + return (char*)"Zinc"; + case Ge74: + return (char*)"Germanium"; + case Se80: + return (char*)"Selenium"; + case Kr84: + return (char*)"Krypton"; + case Sr88: + return (char*)"Strontium"; + case Zr90: + return (char*)"Zirconium"; + case Mo98: + return (char*)"Molybdenum"; + case Pd106: + return (char*)"Palladium"; + case Cd114: + return (char*)"Cadmium"; + case Sn120: + return (char*)"Tin"; + case Xe132: + return (char*)"Xenon"; + case Ba138: + return (char*)"Barium"; + case Ce140: + return (char*)"Cesium"; + case Sm152: + return (char*)"Samerium"; + case Dy164: + return (char*)"Dysprosium"; + case Yb174: + return (char*)"Ytterbium"; + case W184: + return (char*)"Tungsten"; + case Pt194: + return (char*)"Platium"; + case Au197: + return (char*)"Gold"; + case Hg202: + return (char*)"Mercury"; + case Pb208: + return (char*)"Lead"; + case U238: + return (char*)"Uranium"; + case DeltaPlusPlus: + return (char*)"Delta++"; + case Jpsi: + return (char*)"J/psi"; + case Eta_c: + return (char*)"eta_c"; + case Chi_c0: + return (char*)"chi_c0"; + case Chi_c1: + return (char*)"chi_c1"; + case Chi_c2: + return (char*)"chi_c2"; + case Psi2s: + return (char*)"psi(2S)"; + case D0: + return (char*)"D0"; + case AntiD0: + return (char*)"anti-D0"; + case DPlus: + return (char*)"D+"; + case Dstar0: + return (char*)"D*0"; + case DstarPlus: + return (char*)"D*+"; + case Lambda_c: + return (char*)"Lambda_c0"; + default: + return (char*)"Unknown"; + } +} + +inline static char* ShortName(Particle_t locPID) +{ + //returns string that is exact match to enum name. for auto-generating code + locPID = RemapParticleID(locPID); + + switch (locPID) { + case Unknown: + return (char*)"x"; + case Gamma: + return (char*)"g"; + case Positron: + return (char*)"ep"; + case Electron: + return (char*)"em"; + case Neutrino: + return (char*)"nu"; + case MuonPlus: + return (char*)"mup"; + case MuonMinus: + return (char*)"mum"; + case Pi0: + return (char*)"pi0"; + case PiPlus: + return (char*)"pip"; + case PiMinus: + return (char*)"pim"; + case KLong: + return (char*)"kl"; + case KPlus: + return (char*)"kp"; + case KMinus: + return (char*)"km"; + case Neutron: + return (char*)"n"; + case Proton: + return (char*)"prot"; + case AntiProton: + return (char*)"antip"; + case KShort: + return (char*)"ks"; + case Eta: + return (char*)"eta"; + case Lambda: + return (char*)"lamb"; + case SigmaPlus: + return (char*)"sigp"; + case Sigma0: + return (char*)"sig0"; + case SigmaMinus: + return (char*)"sigm"; + case Xi0: + return (char*)"xi0"; + case XiMinus: + return (char*)"xim"; + case OmegaMinus: + return (char*)"omegam"; + case AntiNeutron: + return (char*)"antin"; + case AntiLambda: + return (char*)"antilamb"; + case AntiSigmaMinus: + return (char*)"antisigm"; + case AntiSigma0: + return (char*)"antisig0"; + case AntiSigmaPlus: + return (char*)"antisigp"; + case AntiXi0: + return (char*)"antixi0"; + case AntiXiPlus: + return (char*)"antixip"; + case AntiOmegaPlus: + return (char*)"antiomegap"; + case Geantino: + return (char*)"geant"; + case omega: + return (char*)"omega"; + case EtaPrime: + return (char*)"etapr"; + case phiMeson: + return (char*)"phi"; + case Deuteron: + return (char*)"d"; + case Triton: + return (char*)"tri"; + case Helium: + return (char*)"he"; + case He3: + return (char*)"he3"; + case Li6: + return (char*)"li6"; + case Li7: + return (char*)"li7"; + case Be7: + return (char*)"be7"; + case Be9: + return (char*)"be9"; + case B10: + return (char*)"b10"; + case B11: + return (char*)"b11"; + case C12: + return (char*)"c12"; + case N14: + return (char*)"n14"; + case O16: + return (char*)"o16"; + case F19: + return (char*)"f19"; + case Ne20: + return (char*)"ne20"; + case Na23: + return (char*)"na23"; + case Mg24: + return (char*)"mg24"; + case Al27: + return (char*)"al27"; + case Si28: + return (char*)"si28"; + case P31: + return (char*)"p31"; + case S32: + return (char*)"s32"; + case Cl35: + return (char*)"cl35"; + case Ar36: + return (char*)"ar36"; + case K39: + return (char*)"k39"; + case Ca40: + return (char*)"ca40"; + case Sc45: + return (char*)"sc45"; + case Ti48: + return (char*)"ti48"; + case V51: + return (char*)"v51"; + case Cr52: + return (char*)"cr52"; + case Mn55: + return (char*)"mn55"; + case Fe56: + return (char*)"fe56"; + case Co59: + return (char*)"co59"; + case Ni58: + return (char*)"ni58"; + case Cu63: + return (char*)"cu63"; + case Zn64: + return (char*)"zn64"; + case Ge74: + return (char*)"ge74"; + case Se80: + return (char*)"se80"; + case Kr84: + return (char*)"kr84"; + case Sr88: + return (char*)"sr88"; + case Zr90: + return (char*)"zr90"; + case Mo98: + return (char*)"mo98"; + case Pd106: + return (char*)"pd106"; + case Cd114: + return (char*)"cd114"; + case Sn120: + return (char*)"sn120"; + case Xe132: + return (char*)"xe132"; + case Ba138: + return (char*)"ba138"; + case Ce140: + return (char*)"ce140"; + case Sm152: + return (char*)"sm152"; + case Dy164: + return (char*)"dy164"; + case Yb174: + return (char*)"yb174"; + case W184: + return (char*)"w184"; + case Pt194: + return (char*)"pt194"; + case Au197: + return (char*)"au197"; + case Hg202: + return (char*)"hg202"; + case Pb208: + return (char*)"pb208"; + case U238: + return (char*)"u238"; + case Jpsi: + return (char*)"jpsi"; + case Eta_c: + return (char*)"etac"; + case Chi_c0: + return (char*)"chic0"; + case Chi_c1: + return (char*)"chic1"; + case Chi_c2: + return (char*)"chic2"; + case Psi2s: + return (char*)"psi2s"; + case D0: + return (char*)"d0"; + case AntiD0: + return (char*)"antid0"; + case DPlus: + return (char*)"dp"; + case Dstar0: + return (char*)"ds0"; + case DstarPlus: + return (char*)"dsp"; + case Lambda_c: + return (char*)"lambc"; + + //not really supported + case Rho0: + return (char*)"Rho0"; + case RhoPlus: + return (char*)"RhoPlus"; + case RhoMinus: + return (char*)"RhoMinus"; + case a0_980: + return (char*)"a0_980"; + case f0_980: + return (char*)"f0_980"; + case KStar_892_0: + return (char*)"KStar_892_0"; + case KStar_892_Plus: + return (char*)"KStar_892_Plus"; + case KStar_892_Minus: + return (char*)"KStar_892_Minus"; + case AntiKStar_892_0: + return (char*)"AntiKStar_892_0"; + case K1_1400_Plus: + return (char*)"K1_1400_Plus"; + case K1_1400_Minus: + return (char*)"K1_1400_Minus"; + case b1_1235_Plus: + return (char*)"b1_1235_Plus"; + case Sigma_1385_Minus: + return (char*)"Sigma_1385_Minus"; + case Sigma_1385_0: + return (char*)"Sigma_1385_0"; + case Sigma_1385_Plus: + return (char*)"Sigma_1385_Plus"; + case DeltaPlusPlus: + return (char*)"DeltaPlusPlus"; + + default: + return (char*)"x"; + } +} + +inline static Particle_t ParticleEnum(const char* locParticleName) +{ + if(strcmp(locParticleName, "Unknown") == 0) + return Unknown; + else if(strcmp(locParticleName, "Photon") == 0) + return Gamma; + else if(strcmp(locParticleName, "Positron") == 0) + return Positron; + else if(strcmp(locParticleName, "Electron") == 0) + return Electron; + else if(strcmp(locParticleName, "Neutrino") == 0) + return Neutrino; + else if(strcmp(locParticleName, "Muon+") == 0) + return MuonPlus; + else if(strcmp(locParticleName, "Muon-") == 0) + return MuonMinus; + else if(strcmp(locParticleName, "Pi0") == 0) + return Pi0; + else if(strcmp(locParticleName, "Pi+") == 0) + return PiPlus; + else if(strcmp(locParticleName, "Pi-") == 0) + return PiMinus; + else if(strcmp(locParticleName, "KLong") == 0) + return KLong; + else if(strcmp(locParticleName, "K+") == 0) + return KPlus; + else if(strcmp(locParticleName, "K-") == 0) + return KMinus; + else if(strcmp(locParticleName, "Neutron") == 0) + return Neutron; + else if(strcmp(locParticleName, "Proton") == 0) + return Proton; + else if(strcmp(locParticleName, "AntiProton") == 0) + return AntiProton; + else if(strcmp(locParticleName, "KShort") == 0) + return KShort; + else if(strcmp(locParticleName, "Eta") == 0) + return Eta; + else if(strcmp(locParticleName, "Lambda") == 0) + return Lambda; + else if(strcmp(locParticleName, "Sigma+") == 0) + return SigmaPlus; + else if(strcmp(locParticleName, "Sigma0") == 0) + return Sigma0; + else if(strcmp(locParticleName, "Sigma-") == 0) + return SigmaMinus; + else if(strcmp(locParticleName, "Xi0") == 0) + return Xi0; + else if(strcmp(locParticleName, "Xi-") == 0) + return XiMinus; + else if(strcmp(locParticleName, "Omega-") == 0) + return OmegaMinus; + else if(strcmp(locParticleName, "AntiNeutron") == 0) + return AntiNeutron; + else if(strcmp(locParticleName, "AntiLambda") == 0) + return AntiLambda; + else if(strcmp(locParticleName, "AntiSigma-") == 0) + return AntiSigmaMinus; + else if(strcmp(locParticleName, "AntiSigma0") == 0) + return AntiSigma0; + else if(strcmp(locParticleName, "AntiSigma+") == 0) + return AntiSigmaPlus; + else if(strcmp(locParticleName, "AntiXi0") == 0) + return AntiXi0; + else if(strcmp(locParticleName, "AntiXi+") == 0) + return AntiXiPlus; + else if(strcmp(locParticleName, "AntiOmega+") == 0) + return AntiOmegaPlus; + else if(strcmp(locParticleName, "Geantino") == 0) + return Geantino; + else if(strcmp(locParticleName, "Rho0") == 0) + return Rho0; + else if(strcmp(locParticleName, "Rho+") == 0) + return RhoPlus; + else if(strcmp(locParticleName, "Rho-") == 0) + return RhoMinus; + else if(strcmp(locParticleName, "Omega") == 0) + return omega; + else if(strcmp(locParticleName, "EtaPrime") == 0) + return EtaPrime; + else if(strcmp(locParticleName, "Phi") == 0) + return phiMeson; + else if(strcmp(locParticleName, "a0(980)") == 0) + return a0_980; + else if(strcmp(locParticleName, "f0(980)") == 0) + return f0_980; + else if(strcmp(locParticleName, "K*(892)0") == 0) + return KStar_892_0; + else if(strcmp(locParticleName, "K*(892)+") == 0) + return KStar_892_Plus; + else if(strcmp(locParticleName, "K*(892)-") == 0) + return KStar_892_Minus; + else if(strcmp(locParticleName, "antiK*(892)0") == 0) + return AntiKStar_892_0; + else if(strcmp(locParticleName, "K1(1400)+") == 0) + return K1_1400_Plus; + else if(strcmp(locParticleName, "K1(1400)-") == 0) + return K1_1400_Minus; + else if(strcmp(locParticleName, "b1(1235)+") == 0) + return b1_1235_Plus; + else if(strcmp(locParticleName, "Sigma(1385)-") == 0) + return Sigma_1385_Minus; + else if(strcmp(locParticleName, "Sigma(1385)0") == 0) + return Sigma_1385_0; + else if(strcmp(locParticleName, "Sigma(1385)+") == 0) + return Sigma_1385_Plus; + else if(strcmp(locParticleName, "Deuteron") == 0) + return Deuteron; + else if(strcmp(locParticleName, "Triton") == 0) + return Triton; + else if(strcmp(locParticleName, "Helium") == 0) + return Helium; + else if(strcmp(locParticleName, "Helium-3") == 0) + return He3; + else if(strcmp(locParticleName, "Lithium-6") == 0) + return Li6; + else if(strcmp(locParticleName, "Lithium-7") == 0) + return Li7; + else if(strcmp(locParticleName, "Beryllium-7") == 0) + return Be7; + else if(strcmp(locParticleName, "Beryllium-9") == 0) + return Be9; + else if(strcmp(locParticleName, "Boron-10") == 0) + return B10; + else if(strcmp(locParticleName, "Boron-11") == 0) + return B11; + else if(strcmp(locParticleName, "Carbon") == 0) + return C12; + else if(strcmp(locParticleName, "Nitrogen") == 0) + return N14; + else if(strcmp(locParticleName, "Oxygen") == 0) + return O16; + else if(strcmp(locParticleName, "Fluorine") == 0) + return F19; + else if(strcmp(locParticleName, "Neon") == 0) + return Ne20; + else if(strcmp(locParticleName, "Sodium") == 0) + return Na23; + else if(strcmp(locParticleName, "Magnesium") == 0) + return Mg24; + else if(strcmp(locParticleName, "Aluminum") == 0) + return Al27; + else if(strcmp(locParticleName, "Silicon") == 0) + return Si28; + else if(strcmp(locParticleName, "Phosphorous") == 0) + return P31; + else if(strcmp(locParticleName, "Sulphur") == 0) + return S32; + else if(strcmp(locParticleName, "Chlorine") == 0) + return Cl35; + else if(strcmp(locParticleName, "Argon") == 0) + return Ar36; + else if(strcmp(locParticleName, "Potassium") == 0) + return K39; + else if(strcmp(locParticleName, "Calcium") == 0) + return Ca40; + else if(strcmp(locParticleName, "Scandium") == 0) + return Sc45; + else if(strcmp(locParticleName, "Titanium") == 0) + return Ti48; + else if(strcmp(locParticleName, "Vanadium") == 0) + return V51; + else if(strcmp(locParticleName, "Chromium") == 0) + return Cr52; + else if(strcmp(locParticleName, "Manganese") == 0) + return Mn55; + else if(strcmp(locParticleName, "Iron") == 0) + return Fe56; + else if(strcmp(locParticleName, "Cobalt") == 0) + return Co59; + else if(strcmp(locParticleName, "Nickel") == 0) + return Ni58; + else if(strcmp(locParticleName, "Copper") == 0) + return Cu63; + else if(strcmp(locParticleName, "Zinc") == 0) + return Zn64; + else if(strcmp(locParticleName, "Germanium") == 0) + return Ge74; + else if(strcmp(locParticleName, "Selenium") == 0) + return Se80; + else if(strcmp(locParticleName, "Krypton") == 0) + return Kr84; + else if(strcmp(locParticleName, "Strontium") == 0) + return Sr88; + else if(strcmp(locParticleName, "Zirconium") == 0) + return Zr90; + else if(strcmp(locParticleName, "Molybdenum") == 0) + return Mo98; + else if(strcmp(locParticleName, "Palladium") == 0) + return Pd106; + else if(strcmp(locParticleName, "Cadmium") == 0) + return Cd114; + else if(strcmp(locParticleName, "Tin") == 0) + return Sn120; + else if(strcmp(locParticleName, "Xenon") == 0) + return Xe132; + else if(strcmp(locParticleName, "Barium") == 0) + return Ba138; + else if(strcmp(locParticleName, "Cesium") == 0) + return Ce140; + else if(strcmp(locParticleName, "Samerium") == 0) + return Sm152; + else if(strcmp(locParticleName, "Dysprosium") == 0) + return Dy164; + else if(strcmp(locParticleName, "Ytterbium") == 0) + return Yb174; + else if(strcmp(locParticleName, "Tungsten") == 0) + return W184; + else if(strcmp(locParticleName, "Platium") == 0) + return Pt194; + else if(strcmp(locParticleName, "Gold") == 0) + return Au197; + else if(strcmp(locParticleName, "Mercury") == 0) + return Hg202; + else if(strcmp(locParticleName, "Lead") == 0) + return Pb208; + else if(strcmp(locParticleName, "Uranium") == 0) + return U238; + else if(strcmp(locParticleName, "Delta++") == 0) + return DeltaPlusPlus; + else if(strcmp(locParticleName, "Jpsi") == 0) + return Jpsi; + else if(strcmp(locParticleName, "EtaC") == 0) + return Eta_c; + else if(strcmp(locParticleName, "ChiC0") == 0) + return Chi_c0; + else if(strcmp(locParticleName, "ChiC1") == 0) + return Chi_c1; + else if(strcmp(locParticleName, "ChiC2") == 0) + return Chi_c2; + else if(strcmp(locParticleName, "Psi(2S)") == 0) + return Psi2s; + else if(strcmp(locParticleName, "D0") == 0) + return D0; + else if(strcmp(locParticleName, "AntiD0") == 0) + return AntiD0; + else if(strcmp(locParticleName, "D+") == 0) + return DPlus; + else if(strcmp(locParticleName, "D*0") == 0) + return Dstar0; + else if(strcmp(locParticleName, "D*+") == 0) + return DstarPlus; + else if(strcmp(locParticleName, "LambdaC") == 0) + return Lambda_c; + else + return Unknown; +} + +inline static unsigned short int IsFixedMass(Particle_t p) +{ + switch (p) + { + case Gamma: return 1; + case Positron: return 1; + case Electron: return 1; + case Neutrino: return 1; + case MuonPlus: return 1; + case MuonMinus: return 1; + case Pi0: return 1; + case PiPlus: return 1; + case PiMinus: return 1; + case KShort: return 1; + case KLong: return 1; + case KPlus: return 1; + case KMinus: return 1; + case Neutron: return 1; + case Proton: return 1; + case AntiProton: return 1; + case Eta: return 1; + case Lambda: return 1; + case SigmaPlus: return 1; + case Sigma0: return 1; + case SigmaMinus: return 1; + case Xi0: return 1; + case XiMinus: return 1; + case OmegaMinus: return 1; + case AntiNeutron: return 1; + case AntiLambda: return 1; + case AntiSigmaMinus: return 1; + case AntiSigma0: return 1; + case AntiSigmaPlus: return 1; + case AntiXi0: return 1; + case AntiXiPlus: return 1; + case AntiOmegaPlus: return 1; + case Geantino: return 1; + case EtaPrime: return 1; + case Deuteron: return 1; + case Triton: return 1; + case Helium: return 1; + case He3: return 1; + case Li6: return 1; + case Li7: return 1; + case Be7: return 1; + case Be9: return 1; + case B10: return 1; + case B11: return 1; + case C12: return 1; + case N14: return 1; + case O16: return 1; + case F19: return 1; + case Ne20: return 1; + case Na23: return 1; + case Mg24: return 1; + case Al27: return 1; + case Si28: return 1; + case P31: return 1; + case S32: return 1; + case Cl35: return 1; + case Ar36: return 1; + case K39: return 1; + case Ca40: return 1; + case Sc45: return 1; + case Ti48: return 1; + case V51: return 1; + case Cr52: return 1; + case Mn55: return 1; + case Fe56: return 1; + case Co59: return 1; + case Ni58: return 1; + case Cu63: return 1; + case Zn64: return 1; + case Ge74: return 1; + case Se80: return 1; + case Kr84: return 1; + case Sr88: return 1; + case Zr90: return 1; + case Mo98: return 1; + case Pd106: return 1; + case Cd114: return 1; + case Sn120: return 1; + case Xe132: return 1; + case Ba138: return 1; + case Ce140: return 1; + case Sm152: return 1; + case Dy164: return 1; + case Yb174: return 1; + case W184: return 1; + case Pt194: return 1; + case Au197: return 1; + case Hg202: return 1; + case Pb208: return 1; + case U238: return 1; + case Jpsi: return 1; + //case eta_c: return 1; + //case chi_c0: return 1; + case Chi_c1: return 1; + case Chi_c2: return 1; + case Psi2s: return 1; + case D0: return 1; + case AntiD0: return 1; + case DPlus: return 1; + case Dstar0: return 1; + case DstarPlus: return 1; + case Lambda_c: return 1; + default: return 0; + } +} + +inline static unsigned short int IsResonance(Particle_t p) +{ + p = RemapParticleID(p); + + if(IsFixedMass(p) == 1) + return 0; + if(p == Unknown) + return 0; + if(p == phiMeson) + return 0; + if(p == omega) + return 0; + return 1; +} + +inline static unsigned short int IsDetachedVertex(Particle_t p) +{ + switch (p) + { + case MuonPlus: return 1; + case MuonMinus: return 1; + case PiPlus: return 1; + case PiMinus: return 1; + case KShort: return 1; + case KLong: return 1; + case KPlus: return 1; + case KMinus: return 1; + case Neutron: return 1; + case Lambda: return 1; + case SigmaPlus: return 1; + case SigmaMinus: return 1; + case Xi0: return 1; + case XiMinus: return 1; + case OmegaMinus: return 1; + case AntiNeutron: return 1; + case AntiLambda: return 1; + case AntiSigmaMinus: return 1; + case AntiSigmaPlus: return 1; + case AntiXi0: return 1; + case AntiXiPlus: return 1; + case AntiOmegaPlus: return 1; + case Deuteron: return 1; + case Triton: return 1; + case Helium: return 1; + case He3: return 1; + default: return 0; + } +} + +inline static char* ParticleName_ROOT(Particle_t p) +{ + p = RemapParticleID(p); + + switch (p) { + case Unknown: + return (char*)"X"; + case Gamma: + return (char*)"#gamma"; + case Positron: + return (char*)"e^{#plus}"; + case Electron: + return (char*)"e^{#minus}"; + case Neutrino: + return (char*)"#nu"; + case MuonPlus: + return (char*)"#mu^{#plus}"; + case MuonMinus: + return (char*)"#mu^{#minus}"; + case Pi0: + return (char*)"#pi^{0}"; + case PiPlus: + return (char*)"#pi^{#plus}"; + case PiMinus: + return (char*)"#pi^{#minus}"; + case KLong: + return (char*)"K^{0}_{L}"; + case KPlus: + return (char*)"K^{#plus}"; + case KMinus: + return (char*)"K^{#minus}"; + case Neutron: + return (char*)"n"; + case Proton: + return (char*)"p"; + case AntiProton: + return (char*)"#bar{p}"; + case KShort: + return (char*)"K^{0}_{S}"; + case Eta: + return (char*)"#eta"; + case Lambda: + return (char*)"#Lambda"; + case SigmaPlus: + return (char*)"#Sigma^{#plus}"; + case Sigma0: + return (char*)"#Sigma^{0}"; + case SigmaMinus: + return (char*)"#Sigma^{#minus}"; + case Xi0: + return (char*)"#Xi^{0}"; + case XiMinus: + return (char*)"#Xi^{#minus}"; + case OmegaMinus: + return (char*)"#Omega^{#minus}"; + case AntiNeutron: + return (char*)"#bar^{n}"; + case AntiLambda: + return (char*)"#bar^{#Lambda}"; + case AntiSigmaMinus: + return (char*)"#bar{#Sigma}^{#minus}"; + case AntiSigma0: + return (char*)"#bar{#Sigma}^{0}"; + case AntiSigmaPlus: + return (char*)"#bar{#Sigma}^{#plus}"; + case AntiXi0: + return (char*)"#bar{#Xi}^{0}"; + case AntiXiPlus: + return (char*)"#bar{#Xi}^{#plus}"; + case AntiOmegaPlus: + return (char*)"#bar{#Omega}^{#plus}"; + case Geantino: + return (char*)"geantino"; + case Rho0: + return (char*)"#rho^{0}"; + case RhoPlus: + return (char*)"#rho^{#plus}"; + case RhoMinus: + return (char*)"#rho^{#minus}"; + case omega: + return (char*)"#omega"; + case EtaPrime: + return (char*)"#eta'"; + case phiMeson: + return (char*)"#phi"; + case a0_980: + return (char*)"a_{0}(980)"; + case f0_980: + return (char*)"f_{0}(980)"; + case KStar_892_0: + return (char*)"K*(892)^{0}"; + case KStar_892_Plus: + return (char*)"K*(892)^{#plus}"; + case KStar_892_Minus: + return (char*)"K*(892)^{#minus}"; + case AntiKStar_892_0: + return (char*)"#bar{K*}(892)^{0}"; + case K1_1400_Plus: + return (char*)"K_{1}(1400)^{#plus}"; + case K1_1400_Minus: + return (char*)"K_{1}(1400)^{#minus}"; + case b1_1235_Plus: + return (char*)"b_{1}(1235)^{#plus}"; + case Deuteron: + return (char*)"d"; + case Triton: + return (char*)"t"; + case Helium: + return (char*)"He"; + case He3: + return (char*)"^{3}He"; + case Li6: + return (char*)"^{6}Li"; + case Li7: + return (char*)"^{7}Li"; + case Be7: + return (char*)"^{7}Be"; + case Be9: + return (char*)"^{9}Be"; + case B10: + return (char*)"^{10}B"; + case B11: + return (char*)"^{11}B"; + case C12: + return (char*)"^{12}C"; + case N14: + return (char*)"^{14}N"; + case O16: + return (char*)"^{16}O"; + case F19: + return (char*)"^{19}F"; + case Ne20: + return (char*)"^{20}Ne"; + case Na23: + return (char*)"^{23}Na"; + case Mg24: + return (char*)"^{24}Mg"; + case Al27: + return (char*)"^{27}Al"; + case Si28: + return (char*)"^{28}Si"; + case P31: + return (char*)"^{31}P"; + case S32: + return (char*)"^{32}S"; + case Cl35: + return (char*)"^{35}Cl"; + case Ar36: + return (char*)"^{36}Ar"; + case K39: + return (char*)"^{39}K"; + case Ca40: + return (char*)"^{40}Ca"; + case Sc45: + return (char*)"^{45}Sc"; + case Ti48: + return (char*)"^{48}Ti"; + case V51: + return (char*)"^{51}V"; + case Cr52: + return (char*)"^{52}Cr"; + case Mn55: + return (char*)"^{55}Mn"; + case Fe56: + return (char*)"^{56}Fe"; + case Co59: + return (char*)"^{59}Co"; + case Ni58: + return (char*)"^{58}Ni"; + case Cu63: + return (char*)"^{63}Cu"; + case Zn64: + return (char*)"^{64}Zn"; + case Ge74: + return (char*)"^{74}Ge"; + case Se80: + return (char*)"^{80}Se"; + case Kr84: + return (char*)"^{84}Kr"; + case Sr88: + return (char*)"^{88}Sr"; + case Zr90: + return (char*)"^{90}Zr"; + case Mo98: + return (char*)"^{98}Mo"; + case Pd106: + return (char*)"^{106}Pd"; + case Cd114: + return (char*)"^{114}Cd"; + case Sn120: + return (char*)"^{120}Sn"; + case Xe132: + return (char*)"^{132}Xe"; + case Ba138: + return (char*)"^{138}Ba"; + case Ce140: + return (char*)"^{140}Ce"; + case Sm152: + return (char*)"^{152}Sm"; + case Dy164: + return (char*)"^{164}Dy"; + case Yb174: + return (char*)"^{174}Yb"; + case W184: + return (char*)"^{184}W"; + case Pt194: + return (char*)"^{194}Pt"; + case Au197: + return (char*)"^{197}Au"; + case Hg202: + return (char*)"^{202}Hg"; + case Pb208: + return (char*)"^{208}Pb"; + case U238: + return (char*)"^{238}U"; + case Sigma_1385_Minus: + return (char*)"#Sigma(1385)^{#minus}"; + case Sigma_1385_0: + return (char*)"#Sigma(1385)^{0}"; + case Sigma_1385_Plus: + return (char*)"#Sigma(1385)^{#plus}"; + case DeltaPlusPlus: + return (char*)"#Delta(1232)^{#plus#plus}"; + case Jpsi: + return (char*)"J/#psi"; + case Eta_c: + return (char*)"#eta_{c}"; + case Chi_c0: + return (char*)"#chi_{c0}"; + case Chi_c1: + return (char*)"#chi_{c1}"; + case Chi_c2: + return (char*)"#chi_{c2}"; + case Psi2s: + return (char*)"#psi(2S)"; + case D0: + return (char*)"D^{0}"; + case AntiD0: + return (char*)"#bar{D^{0}}"; + case DPlus: + return (char*)"D{^+}"; + case Dstar0: + return (char*)"D^{*0}"; + case DstarPlus: + return (char*)"D^{*+}"; + case Lambda_c: + return (char*)"#Lambda_{c}"; + + default: + return (char*)"X"; + } +} + +inline static double ParticleMass(Particle_t p) +{ + p = RemapParticleID(p); + + switch (p) { + case Unknown: return HUGE_VAL; + case Gamma: return 0; + case Positron: return 0.000510998928; + case Electron: return 0.000510998928; + case Neutrino: return 0; + case MuonPlus: return 0.1056583715; + case MuonMinus: return 0.1056583715; + case Pi0: return 0.1349766; + case PiPlus: return 0.13957018; + case PiMinus: return 0.13957018; + case KShort: return 0.497614; + case KLong: return 0.497614; + case KPlus: return 0.493677; + case KMinus: return 0.493677; + case Neutron: return 0.939565379; + case Proton: return 0.938272046; + case AntiProton: return 0.938272046; + case Eta: return 0.547862; + case Lambda: return 1.115683; + case SigmaPlus: return 1.18937; + case Sigma0: return 1.192642; + case SigmaMinus: return 1.197449; + case Xi0: return 1.31486; + case XiMinus: return 1.32171; + case OmegaMinus: return 1.67245; + case AntiNeutron: return 0.939565379; + case AntiLambda: return 1.115683; + case AntiSigmaMinus: return 1.18937; + case AntiSigma0: return 1.192642; + case AntiSigmaPlus: return 1.197449; + case AntiXi0: return 1.31486; + case AntiXiPlus: return 1.32171; + case AntiOmegaPlus: return 1.67245; + case Geantino: return 0.0; + case Rho0: return 0.7690; // neutral only, photoproduced and other reactions. e+ e- gives 775.26 + case RhoPlus: return 0.7665; // charged only, hadroproduced. tau decays and e+ e- gives 775.11 + case RhoMinus: return 0.7665; + case omega: return 0.78265; + case EtaPrime: return 0.95778; + case phiMeson: return 1.019455; + case a0_980: return 0.980; + case f0_980: return 0.990; + case KStar_892_0: return 0.89581; // neutral only + case KStar_892_Plus: return 0.89166; // charged only, hadroproduced + case KStar_892_Minus: return 0.89166; // charged only, hadroproduced + case AntiKStar_892_0: return 0.89581; // neutral only + case K1_1400_Plus: return 1.403; + case K1_1400_Minus: return 1.403; + case b1_1235_Plus: return 1.2295; + case Deuteron: return 1.875612859; // from NIST + case Triton: return 2.808921004; // from NIST 5.00735630 x 10^-27 kg + case Helium: return 3.727379238; // from NIST 6.64465675 x 10-27 kg + case He3: return 2.809413498; + case Li6: return 5.60305; + case Li7: return 6.53536; + case Be7: return 6.53622; + case Be9: return 8.39479; + case B10: return 9.32699; + case B11: return 10.25510; + case C12: return 11.17793; + case N14: return 13.04378; + case O16: return 14.89917; + case F19: return 17.69690; + case Ne20: return 18.62284; + case Na23: return 21.41483; + case Mg24: return 22.34193; + case Al27: return 25.13314; + case Si28: return 26.06034; + case P31: return 28.85188; + case S32: return 29.78180; + case Cl35: return 32.57328; + case Ar36: return 33.50356; + case K39: return 36.29447; + case Ca40: return 37.22492; + case Sc45: return 41.87617; + case Ti48: return 44.66324; + case V51: return 47.45401; + case Cr52: return 48.38228; + case Mn55: return 51.17447; + case Fe56: return 52.10307; + case Co59: return 54.89593; + case Ni58: return 53.96644; + case Cu63: return 58.61856; + case Zn64: return 59.54963; + case Ge74: return 68.85715; + case Se80: return 74.44178; + case Kr84: return 78.16309; + case Sr88: return 81.88358; + case Zr90: return 83.74571; + case Mo98: return 91.19832; + case Pd106: return 98.64997; + case Cd114: return 106.10997; + case Sn120: return 111.68821; + case Xe132: return 122.86796; + case Ba138: return 128.45793; + case Ce140: return 130.32111; + case Sm152: return 141.51236; + case Dy164: return 152.69909; + case Yb174: return 162.02245; + case W184: return 171.34924; + case Pt194: return 180.67513; + case Au197: return 183.47324; + case Hg202: return 188.13451; + case Pb208: return 193.72899; // NIST gives 207.976627 AMU + case U238: return 221.74295; + case Sigma_1385_Minus: return 1.3872; + case Sigma_1385_0: return 1.3837; + case Sigma_1385_Plus: return 1.38280; + case DeltaPlusPlus: return 1.232; + case Jpsi: return 3.069916; + case Eta_c: return 2.9836; + case Chi_c0: return 3.41475; + case Chi_c1: return 3.51066; + case Chi_c2: return 3.55620; + case Psi2s: return 3.686109; + case D0: return 1.86484; + case AntiD0: return 1.86484; + case DPlus: return 1.86961; + case Dstar0: return 2.01026; + case DstarPlus: return 2.00696; + case Lambda_c: return 2.28646; + default: + fprintf(stderr,"ParticleMass: Error: Unknown particle type %d,",p); + fprintf(stderr," returning HUGE_VAL...\n"); + return HUGE_VAL; + } +} + +inline static int ParticleCharge(Particle_t p) +{ + p = RemapParticleID(p); + + switch (p) { + case Unknown: return 0; + case Gamma: return 0; + case Positron: return +1; + case Electron: return -1; + case Neutrino: return 0; + case MuonPlus: return +1; + case MuonMinus: return -1; + case Pi0: return 0; + case PiPlus: return +1; + case PiMinus: return -1; + case KShort: return 0; + case KLong: return 0; + case KPlus: return +1; + case KMinus: return -1; + case Neutron: return 0; + case Proton: return +1; + case AntiProton: return -1; + case Eta: return 0; + case Lambda: return 0; + case SigmaPlus: return +1; + case Sigma0: return 0; + case SigmaMinus: return -1; + case Xi0: return 0; + case XiMinus: return -1; + case OmegaMinus: return -1; + case AntiNeutron: return 0; + case AntiLambda: return 0; + case AntiSigmaMinus: return -1; + case AntiSigma0: return 0; + case AntiSigmaPlus: return +1; + case AntiXi0: return 0; + case AntiXiPlus: return +1; + case AntiOmegaPlus: return +1; + case Geantino: return 0; + case Rho0: return 0; + case RhoPlus: return +1; + case RhoMinus: return -1; + case omega: return 0; + case EtaPrime: return 0; + case phiMeson: return 0; + case a0_980: return 0; + case f0_980: return 0; + case KStar_892_0: return 0; + case KStar_892_Plus: return 1; + case KStar_892_Minus: return -1; + case AntiKStar_892_0: return 0; + case K1_1400_Plus: return 1; + case K1_1400_Minus: return -1; + case b1_1235_Plus: return 1; + case Deuteron: return 1; + case Triton: return 1; + case Helium: return 2; + case He3: return 2; + case Li6: return 3; + case Li7: return 3; + case Be7: return 4; + case Be9: return 4; + case B10: return 5; + case B11: return 5; + case C12: return 6; + case N14: return 7; + case O16: return 8; + case F19: return 9; + case Ne20: return 10; + case Na23: return 11; + case Mg24: return 12; + case Al27: return 13; + case Si28: return 14; + case P31: return 15; + case S32: return 16; + case Cl35: return 17; + case Ar36: return 18; + case K39: return 19; + case Ca40: return 20; + case Sc45: return 21; + case Ti48: return 22; + case V51: return 23; + case Cr52: return 24; + case Mn55: return 25; + case Fe56: return 26; + case Co59: return 27; + case Ni58: return 28; + case Cu63: return 29; + case Zn64: return 30; + case Ge74: return 32; + case Se80: return 34; + case Kr84: return 36; + case Sr88: return 38; + case Zr90: return 40; + case Mo98: return 42; + case Pd106: return 46; + case Cd114: return 48; + case Sn120: return 50; + case Xe132: return 54; + case Ba138: return 56; + case Ce140: return 58; + case Sm152: return 62; + case Dy164: return 66; + case Yb174: return 70; + case W184: return 74; + case Pt194: return 78; + case Au197: return 79; + case Hg202: return 80; + case Pb208: return 82; + case U238: return 92; + case Sigma_1385_Minus: return -1; + case Sigma_1385_0: return 0; + case Sigma_1385_Plus: return 1; + case DeltaPlusPlus: return 2; + case Jpsi: return 0; + case Eta_c: return 0; + case Chi_c0: return 0; + case Chi_c1: return 0; + case Chi_c2: return 0; + case Psi2s: return 0; + case D0: return 0; + case AntiD0: return 0; + case DPlus: return 1; + case Dstar0: return 0; + case DstarPlus: return 1; + case Lambda_c: return 1; + + default: + fprintf(stderr,"ParticleCharge: Error: Unknown particle type %d,",p); + fprintf(stderr," returning 0...\n"); + return 0; + } +} + +inline static int PDGtype(Particle_t p) +{ + p = RemapParticleID(p); + + switch (p) { + case Unknown: return 0; + case Gamma: return 22; + case Positron: return -11; + case Electron: return 11; + case Neutrino: return 121416; + case MuonPlus: return -13; + case MuonMinus: return 13; + case Pi0: return 111; + case PiPlus: return 211; + case PiMinus: return -211; + case KShort: return 310; + case KLong: return 130; + case KPlus: return 321; + case KMinus: return -321; + case Neutron: return 2112; + case Proton: return 2212; + case AntiProton: return -2212; + case Eta: return 221; + case Lambda: return 3122; + case SigmaPlus: return 3222; + case Sigma0: return 3212; + case SigmaMinus: return 3112; + case Xi0: return 3322; + case XiMinus: return 3312; + case OmegaMinus: return 3334; + case AntiNeutron: return -2112; + case AntiLambda: return -3122; + case AntiSigmaMinus: return -3112; + case AntiSigma0: return -3212; + case AntiSigmaPlus: return -3222; + case AntiXi0: return -3322; + case AntiXiPlus: return -3312; + case AntiOmegaPlus: return -3334; + case Geantino: return 0; + case Rho0: return 113; + case RhoPlus: return 213; + case RhoMinus: return -213; + case omega: return 223; + case EtaPrime: return 331; + case phiMeson: return 333; + case a0_980: return 9000110; + case f0_980: return 9010221; + case KStar_892_0: return 313; + case AntiKStar_892_0: return -313; + case KStar_892_Plus: return 323; + case KStar_892_Minus: return -323; + case K1_1400_Plus: return 20323; + case K1_1400_Minus: return -20323; + case b1_1235_Plus: return 10213; + case Deuteron: return 45; + case Triton: return 46; + case Helium: return 47; + case He3: return 49; + case Sigma_1385_Minus: return 3114; + case Sigma_1385_0: return 3214; + case Sigma_1385_Plus: return 3224; + case Li6: return 1000030060; + case Li7: return 1000030070; + case Be7: return 1000040070; + case Be9: return 1000040090; + case B10: return 1000050100; + case B11: return 1000050110; + case C12: return 1000060120; + case N14: return 1000070140; + case O16: return 1000080160; + case F19: return 1000090190; + case Ne20: return 1000100200; + case Na23: return 1000110230; + case Mg24: return 1000120240; + case Al27: return 1000130270; + case Si28: return 1000140280; + case P31: return 1000150310; + case S32: return 1000160320; + case Cl35: return 1000170350; + case Ar36: return 1000180360; + case K39: return 1000190390; + case Ca40: return 1000200400; + case Sc45: return 1000210450; + case Ti48: return 1000220480; + case V51: return 1000230510; + case Cr52: return 1000240520; + case Mn55: return 1000250550; + case Fe56: return 1000260560; + case Co59: return 1000270590; + case Ni58: return 1000280580; + case Cu63: return 1000290630; + case Zn64: return 1000300640; + case Ge74: return 1000320740; + case Se80: return 1000340800; + case Kr84: return 1000360840; + case Sr88: return 1000380880; + case Zr90: return 1000400900; + case Mo98: return 1000420980; + case Pd106: return 1000461060; + case Cd114: return 1000481140; + case Sn120: return 1000501200; + case Xe132: return 1000541320; + case Ba138: return 1000561380; + case Ce140: return 1000581400; + case Sm152: return 1000621520; + case Dy164: return 1000661640; + case Yb174: return 1000701740; + case W184: return 1000741840; + case Pt194: return 1000781940; + case Au197: return 1000791970; + case Hg202: return 1000802020; + case Pb208: return 1000822080; + case U238: return 1000922380; + case DeltaPlusPlus: return 2224; + case Jpsi: return 443; + case Eta_c: return 441; + case Chi_c0: return 10441; + case Chi_c1: return 20443; + case Chi_c2: return 445; + case Psi2s: return 100443; + case D0: return 421; + case AntiD0: return -421; //FIX!! + case DPlus: return 411; + case Dstar0: return 423; + case DstarPlus: return 413; + case Lambda_c: return 4122; + default: return 0; + } +} + +inline static Particle_t PDGtoPType(int locPDG_PID) +{ + switch (locPDG_PID) { + case 0: return Unknown; + case 22: return Gamma; + case -11: return Positron; + case 11: return Electron; + case 121416: return Neutrino; + case -13: return MuonPlus; + case 13: return MuonMinus; + case 111: return Pi0; + case 211: return PiPlus; + case -211: return PiMinus; + case 310: return KShort; + case 130: return KLong; + case 321: return KPlus; + case -321: return KMinus; + case 2112: return Neutron; + case 2212: return Proton; + case -2212: return AntiProton; + case 221: return Eta; + case 3122: return Lambda; + case 3222: return SigmaPlus; + case 3212: return Sigma0; + case 3112: return SigmaMinus; + case 3322: return Xi0; + case 3312: return XiMinus; + case 3334: return OmegaMinus; + case -2112: return AntiNeutron; + case -3122: return AntiLambda; + case -3112: return AntiSigmaMinus; + case -3212: return AntiSigma0; + case -3222: return AntiSigmaPlus; + case -3322: return AntiXi0; + case -3312: return AntiXiPlus; + case -3334: return AntiOmegaPlus; + case 113: return Rho0; + case 213: return RhoPlus; + case -213: return RhoMinus; + case 223: return omega; + case 331: return EtaPrime; + case 333: return phiMeson; + case 9000110: return a0_980; + case 9010221: return f0_980; + case 313: return KStar_892_0; + case -313: return AntiKStar_892_0; + case 323: return KStar_892_Plus; + case -323: return KStar_892_Minus; + case 20323: return K1_1400_Plus; + case -20323: return K1_1400_Minus; + case 10213: return b1_1235_Plus; + case 45: return Deuteron; + case 46: return Triton; + case 47: return Helium; + case 49: return He3; + case 3114: return Sigma_1385_Minus; + case 3214: return Sigma_1385_0; + case 3224: return Sigma_1385_Plus; + case 1000030060: return Li6; + case 1000030070: return Li7; + case 1000040070: return Be7; + case 1000040090: return Be9; + case 1000050100: return B10; + case 1000050110: return B11; + case 1000060120: return C12; + case 1000070140: return N14; + case 1000080160: return O16; + case 1000090190: return F19; + case 1000100200: return Ne20; + case 1000110230: return Na23; + case 1000120240: return Mg24; + case 1000130270: return Al27; + case 1000140280: return Si28; + case 1000150310: return P31; + case 1000160320: return S32; + case 1000170350: return Cl35; + case 1000180360: return Ar36; + case 1000190390: return K39; + case 1000200400: return Ca40; + case 1000210450: return Sc45; + case 1000220480: return Ti48; + case 1000230510: return V51; + case 1000240520: return Cr52; + case 1000250550: return Mn55; + case 1000260560: return Fe56; + case 1000270590: return Co59; + case 1000280580: return Ni58; + case 1000290630: return Cu63; + case 1000300640: return Zn64; + case 1000320740: return Ge74; + case 1000340800: return Se80; + case 1000360840: return Kr84; + case 1000380880: return Sr88; + case 1000400900: return Zr90; + case 1000420980: return Mo98; + case 1000461060: return Pd106; + case 1000481140: return Cd114; + case 1000501200: return Sn120; + case 1000541320: return Xe132; + case 1000561380: return Ba138; + case 1000581400: return Ce140; + case 1000621520: return Sm152; + case 1000661640: return Dy164; + case 1000701740: return Yb174; + case 1000741840: return W184; + case 1000781940: return Pt194; + case 1000791970: return Au197; + case 1000802020: return Hg202; + case 1000822080: return Pb208; + case 1000922380: return U238; + case 2224: return DeltaPlusPlus; + case 443: return Jpsi; + case 441: return Eta_c; + case 10441: return Chi_c0; + case 20443: return Chi_c1; + case 445: return Chi_c2; + case 100443: return Psi2s; + case 421: return D0; + case -421: return AntiD0; + case 411: return DPlus; + case 423: return Dstar0; + case 413: return DstarPlus; + case 4122: return Lambda_c; + default: return Unknown; + } +} + +inline static int Is_FinalStateParticle(Particle_t locPID) +{ + switch(locPID) + { + case Gamma: return 1; + case Positron: return 1; + case Electron: return 1; + case Neutrino: return 1; + case MuonPlus: return 1; + case MuonMinus: return 1; + case PiPlus: return 1; + case PiMinus: return 1; + case KLong: return 1; + case KPlus: return 1; + case KMinus: return 1; + case Neutron: return 1; + case Proton: return 1; + case AntiProton: return 1; + case AntiNeutron: return 1; + case Deuteron: return 1; + case Triton: return 1; + case Helium: return 1; + case He3: return 1; + case Li6: return 1; + case Li7: return 1; + case Be7: return 1; + case Be9: return 1; + case B10: return 1; + case B11: return 1; + case C12: return 1; + case N14: return 1; + case O16: return 1; + case F19: return 1; + case Ne20: return 1; + case Na23: return 1; + case Mg24: return 1; + case Al27: return 1; + case Si28: return 1; + case P31: return 1; + case S32: return 1; + case Cl35: return 1; + case Ar36: return 1; + case K39: return 1; + case Ca40: return 1; + case Sc45: return 1; + case Ti48: return 1; + case V51: return 1; + case Cr52: return 1; + case Mn55: return 1; + case Fe56: return 1; + case Co59: return 1; + case Ni58: return 1; + case Cu63: return 1; + case Zn64: return 1; + case Ge74: return 1; + case Se80: return 1; + case Kr84: return 1; + case Sr88: return 1; + case Zr90: return 1; + case Mo98: return 1; + case Pd106: return 1; + case Cd114: return 1; + case Sn120: return 1; + case Xe132: return 1; + case Ba138: return 1; + case Ce140: return 1; + case Sm152: return 1; + case Dy164: return 1; + case Yb174: return 1; + case W184: return 1; + case Pt194: return 1; + case Au197: return 1; + case Hg202: return 1; + case Pb208: return 1; + case U238: return 1; + default: return 0; //decaying + } +} + +inline static char* Get_ShortName(Particle_t locPID) +{ + switch (locPID) { + case Gamma: + return (char*)"g"; + case Positron: + return (char*)"ep"; + case Electron: + return (char*)"em"; + case Neutrino: + return (char*)"neut"; + case MuonPlus: + return (char*)"mup"; + case MuonMinus: + return (char*)"mum"; + case Pi0: + return (char*)"pi0"; + case PiPlus: + return (char*)"pip"; + case PiMinus: + return (char*)"pim"; + case KLong: + return (char*)"kl"; + case KPlus: + return (char*)"kp"; + case KMinus: + return (char*)"km"; + case Neutron: + return (char*)"n"; + case Proton: + return (char*)"p"; + case AntiProton: + return (char*)"pbar"; + case KShort: + return (char*)"ks"; + case Eta: + return (char*)"eta"; + + case Lambda: + return (char*)"lamb"; + case SigmaPlus: + return (char*)"sigp"; + case Sigma0: + return (char*)"sig0"; + case SigmaMinus: + return (char*)"sigm"; + case Xi0: + return (char*)"xi0"; + case XiMinus: + return (char*)"xim"; + case OmegaMinus: + return (char*)"omgm"; + + case AntiNeutron: + return (char*)"nbar"; + case AntiLambda: + return (char*)"lbar"; + case AntiSigmaMinus: + return (char*)"sigmbar"; + case AntiSigma0: + return (char*)"sig0bar"; + case AntiSigmaPlus: + return (char*)"sigpbar"; + case AntiXi0: + return (char*)"xi0bar"; + case AntiXiPlus: + return (char*)"xipbar"; + case AntiOmegaPlus: + return (char*)"omgpbar"; + + case omega: + return (char*)"omg"; + case EtaPrime: + return (char*)"etap"; + case phiMeson: + return (char*)"phi"; + + case Deuteron: + return (char*)"d"; + case Triton: + return (char*)"tri"; + case Helium: + return (char*)"he"; + case He3: + return (char*)"he3"; + case Li6: + return (char*)"li6"; + case Li7: + return (char*)"li7"; + case Be7: + return (char*)"be7"; + case Be9: + return (char*)"be9"; + case B10: + return (char*)"b10"; + case B11: + return (char*)"b11"; + case C12: + return (char*)"c12"; + case N14: + return (char*)"n14"; + case O16: + return (char*)"o16"; + case F19: + return (char*)"f19"; + case Ne20: + return (char*)"ne20"; + case Na23: + return (char*)"na23"; + case Mg24: + return (char*)"mg24"; + case Al27: + return (char*)"al27"; + case Si28: + return (char*)"si28"; + case P31: + return (char*)"p31"; + case S32: + return (char*)"s32"; + case Cl35: + return (char*)"cl35"; + case Ar36: + return (char*)"ar36"; + case K39: + return (char*)"k39"; + case Ca40: + return (char*)"ca40"; + case Sc45: + return (char*)"sc45"; + case Ti48: + return (char*)"ti48"; + case V51: + return (char*)"v51"; + case Cr52: + return (char*)"cr52"; + case Mn55: + return (char*)"mn55"; + case Fe56: + return (char*)"fe56"; + case Co59: + return (char*)"co59"; + case Ni58: + return (char*)"ni58"; + case Cu63: + return (char*)"cu63"; + case Zn64: + return (char*)"zn64"; + case Ge74: + return (char*)"ge74"; + case Se80: + return (char*)"se80"; + case Kr84: + return (char*)"kr84"; + case Sr88: + return (char*)"sr88"; + case Zr90: + return (char*)"zr90"; + case Mo98: + return (char*)"mo98"; + case Pd106: + return (char*)"pd106"; + case Cd114: + return (char*)"cd114"; + case Sn120: + return (char*)"sn120"; + case Xe132: + return (char*)"xe132"; + case Ba138: + return (char*)"ba138"; + case Ce140: + return (char*)"ce140"; + case Sm152: + return (char*)"sm152"; + case Dy164: + return (char*)"dy164"; + case Yb174: + return (char*)"yb174"; + case W184: + return (char*)"w184"; + case Pt194: + return (char*)"pt194"; + case Au197: + return (char*)"au197"; + case Hg202: + return (char*)"hg202"; + case Pb208: + return (char*)"pb208"; + case U238: + return (char*)"u238"; + case Jpsi: + return (char*)"jpsi"; + case Eta_c: + return (char*)"etac"; + case Chi_c0: + return (char*)"chic0"; + case Chi_c1: + return (char*)"chic1"; + case Chi_c2: + return (char*)"chic2"; + case Psi2s: + return (char*)"psi2S"; + case D0: + return (char*)"d0"; + case AntiD0: + return (char*)"d0bar"; + case DPlus: + return (char*)"dp"; + case Lambda_c: + return (char*)"lambc"; + + default: + return (char*)"Unknown"; + } +} + +inline static int ParticleMultiplexPower(Particle_t locPID) +{ + locPID = RemapParticleID(locPID); + + switch(locPID) + { + //FINAL-STATE PARTICLES (+ pi0) (decimal: 10^power): + case Gamma: return 0; + case Positron: return 1; + case Electron: return 2; + case Neutrino: return 3; + case MuonPlus: return 4; + case MuonMinus: return 5; + case Pi0: return 6; + case PiPlus: return 7; + case PiMinus: return 8; + case KLong: return 9; + case KPlus: return 10; + case KMinus: return 11; + case Neutron: return 12; + case Proton: return 13; + case AntiProton: return 14; + case AntiNeutron: return 15; + + //DECAYING PARTICLES (- pi0): (binary: 2^power) + case KShort: return 0; + case Eta: return 1; + case Lambda: return 2; + case SigmaPlus: return 3; + case Sigma0: return 4; + case SigmaMinus: return 5; + case Xi0: return 6; + case XiMinus: return 7; + case OmegaMinus: return 8; + case AntiLambda: return 9; + case AntiSigmaMinus: return 10; + case AntiSigma0: return 11; + case AntiSigmaPlus: return 12; + case AntiXi0: return 13; + case AntiXiPlus: return 14; + case AntiOmegaPlus: return 15; + case Deuteron: return 16; + case Rho0: return 17; + case RhoPlus: return 18; + case RhoMinus: return 19; + case omega: return 20; + case EtaPrime: return 21; + case phiMeson: return 22; + case a0_980: return 23; + case f0_980: return 24; + case KStar_892_0: return 25; + case KStar_892_Plus: return 26; + case KStar_892_Minus: return 27; + case AntiKStar_892_0: return 28; + case K1_1400_Plus: return 29; + case K1_1400_Minus: return 30; + case b1_1235_Plus: return 31; + case Sigma_1385_Minus: return 32; + case Sigma_1385_0: return 33; + case Sigma_1385_Plus: return 34; + case DeltaPlusPlus: return 35; + case Jpsi: return 36; + case Eta_c: return 37; + case Chi_c0: return 38; + case Chi_c1: return 39; + case Chi_c2: return 40; + case Psi2s: return 41; + case D0: return 42; + case DPlus: return 43; + case Dstar0: return 44; + case DstarPlus: return 45; + case Lambda_c: return 46; + case AntiD0: return 47; + default: return -1; + } +} + +inline static Particle_t DemultiplexPID(int locBit, int locIsDecayingFlag) +{ + //FINAL-STATE PARTICLES (+ pi0) (decimal: 10^power): + if(locIsDecayingFlag == 0) + { + switch(locBit) + { + case 0: return Gamma; + case 1: return Positron; + case 2: return Electron; + case 3: return Neutrino; + case 4: return MuonPlus; + case 5: return MuonMinus; + case 6: return Pi0; + case 7: return PiPlus; + case 8: return PiMinus; + case 9: return KLong; + case 10: return KPlus; + case 11: return KMinus; + case 12: return Neutron; + case 13: return Proton; + case 14: return AntiProton; + case 15: return AntiNeutron; + default: return Unknown; + } + } + + //DECAYING PARTICLES (- pi0): (binary: 2^power) + switch(locBit) + { + case 0: return KShort; + case 1: return Eta; + case 2: return Lambda; + case 3: return SigmaPlus; + case 4: return Sigma0; + case 5: return SigmaMinus; + case 6: return Xi0; + case 7: return XiMinus; + case 8: return OmegaMinus; + case 9: return AntiLambda; + case 10: return AntiSigmaMinus; + case 11: return AntiSigma0; + case 12: return AntiSigmaPlus; + case 13: return AntiXi0; + case 14: return AntiXiPlus; + case 15: return AntiOmegaPlus; + case 16: return Deuteron; + case 17: return Rho0; + case 18: return RhoPlus; + case 19: return RhoMinus; + case 20: return omega; + case 21: return EtaPrime; + case 22: return phiMeson; + case 23: return a0_980; + case 24: return f0_980; + case 25: return KStar_892_0; + case 26: return KStar_892_Plus; + case 27: return KStar_892_Minus; + case 28: return AntiKStar_892_0; + case 29: return K1_1400_Plus; + case 30: return K1_1400_Minus; + case 31: return b1_1235_Plus; + case 32: return Sigma_1385_Minus; + case 33: return Sigma_1385_0; + case 34: return Sigma_1385_Plus; + case 35: return DeltaPlusPlus; + case 36: return Jpsi; + case 37: return Eta_c; + case 38: return Chi_c0; + case 39: return Chi_c1; + case 40: return Chi_c2; + case 41: return Psi2s; + case 42: return D0; + case 43: return DPlus; + case 44: return Dstar0; + case 45: return DstarPlus; + case 46: return Lambda_c; + case 47: return AntiD0; + default: return Unknown; + } +} + +typedef enum +{ + d_Charged, + d_Positive, + d_Negative, + d_Neutral, + d_AllCharges +} Charge_t; + +inline static int Is_CorrectCharge(Particle_t locPID, Charge_t locCharge) +{ + if(locPID == Unknown) + return (locCharge == d_AllCharges); + int locIntCharge = ParticleCharge(locPID); + switch(locCharge) + { + case d_Neutral: + return (locIntCharge == 0); + case d_Positive: + return (locIntCharge > 0); + case d_Negative: + return (locIntCharge < 0); + case d_Charged: + return (locIntCharge != 0); + case d_AllCharges: + return 1; + default: + return 0; + } +} + +// Deduce particle type from charge and mass +inline static Particle_t IDTrack(float locCharge, float locMass) +{ + float locMassTolerance = 0.010; + if (locCharge > 0.1) // Positive particles + { + if (fabs(locMass - ParticleMass(Triton)) < locMassTolerance) return Triton; + if (fabs(locMass - ParticleMass(Deuteron)) < locMassTolerance) return Deuteron; + if (fabs(locMass - ParticleMass(Proton)) < locMassTolerance) return Proton; + if (fabs(locMass - ParticleMass(PiPlus)) < locMassTolerance) return PiPlus; + if (fabs(locMass - ParticleMass(KPlus)) < locMassTolerance) return KPlus; + if (fabs(locMass - ParticleMass(Positron)) < locMassTolerance) return Positron; + if (fabs(locMass - ParticleMass(MuonPlus)) < locMassTolerance) return MuonPlus; + } + else if(locCharge < -0.1) // Negative particles + { + if (fabs(locMass - ParticleMass(PiMinus)) < locMassTolerance) return PiMinus; + if (fabs(locMass - ParticleMass(KMinus)) < locMassTolerance) return KMinus; + if (fabs(locMass - ParticleMass(MuonMinus)) < locMassTolerance) return MuonMinus; + if (fabs(locMass - ParticleMass(Electron)) < locMassTolerance) return Electron; + if (fabs(locMass - ParticleMass(AntiProton)) < locMassTolerance) return AntiProton; + } + else //Neutral Track + { + if (fabs(locMass - ParticleMass(Gamma)) < locMassTolerance) return Gamma; + if (fabs(locMass - ParticleMass(Neutron)) < locMassTolerance) return Neutron; + } + return Unknown; +} + + +#endif diff --git a/src/eic_evgen/process_routine/Pi0_prod.cc b/src/eic_evgen/process_routine/Pi0_prod.cc new file mode 100644 index 0000000..89485f8 --- /dev/null +++ b/src/eic_evgen/process_routine/Pi0_prod.cc @@ -0,0 +1,1673 @@ +#include "reaction_rountine.h" +#include "eic.h" +#include "particleType.h" + +using namespace std; + +Pi0_Production::Pi0_Production() { + + cout << "Program Start" << endl; + + +} + +/*--------------------------------------------------*/ +/// Pi0_Production + +Pi0_Production::Pi0_Production(TString particle_str) { + + rParticle = particle_str; + +// cout << rParticle << endl; +// exit(0); + + Init(); + Pi0_Decay_Pythia6_Out_Init(); + +} + +/*--------------------------------------------------*/ + +Pi0_Production::~Pi0_Production() { + +// delete rRand; + +// cout << "File closed!" << endl; + + ppiOut.close(); + ppiDetails.close(); + +} + +/*--------------------------------------------------*/ + +void Pi0_Production::process_reaction() { + + if_pi0_decay = gPi0_decay; + + polar_out.open("test.txt", ofstream::out); + + for( long long int i = 0; i < rNEvents; i++ ) { + + rNEvent_itt = i; + fNGenerated ++; + + Progress_Report(); // This is happens at each 10% of the total event is processed + Processing_Event(); + + } + + polar_out.close(); + + Detail_Output(); + +} + +/*--------------------------------------------------*/ + +void Pi0_Production::Processing_Event() { + + + // ---------------------------------------------------- + // Considering Fermi momentum for the proton + // ---------------------------------------------------- + + if( kCalcFermi ) { + Consider_Proton_Fermi_Momentum(); + } + + // ---------------------------------------------------- + // Boost vector from collider (lab) frame to protons rest frame (Fix target) + // ---------------------------------------------------- + + beta_col_rf = r_lproton.BoostVector(); + fGamma_Col_RF = 1.0/sqrt( 1 - pow( beta_col_rf.Mag() , 2 ) ); + + + // --------------------------------------------------------------------- + // Specify the energy and solid angle of scatterd electron in Collider (lab) frame + // --------------------------------------------------------------------- +// fScatElec_Theta_Col = acos( rRand->Uniform( cos( fScatElec_Theta_I ) , cos( fScatElec_Theta_F ) ) ); +// fScatElec_Phi_Col = rRand->Uniform( 0 , 2.0 * fPi); + +// fScatElec_Phi_Col = fRandom->Uniform( 0 , 2.0 * fPi); +// fScatElec_Energy_Col = rRand->Uniform( fScatElec_E_Lo * fElectron_Energy_Col , fScatElec_E_Hi * fElectron_Energy_Col ); +// fScatElec_Energy_Col = fRandom->Uniform( fScatElec_E_Lo * fElectron_Energy_Col , fScatElec_E_Hi * fElectron_Energy_Col ); + +// fScatElec_Theta_Col = acos( rRand->Uniform( cos( 120 *fPi /180) , cos( 180 *fPi /180 ) ) ); + +// fScatElec_Theta_Col = rRand->Uniform(fPi/2, fPi); +// fScatElec_Energy_Col = rRand->Uniform(5000, 6500); + + + /*--------------------------------------------------*/ + /*--------------------------------------------------*/ + /// Random gen +// fScatElec_Theta_Col = fRandom->Uniform(fPi/2, fPi); +// fScatElec_Energy_Col = fRandom->Uniform(5000, 6200); +// fScatElec_Phi_Col = fRandom->Uniform(fProton_Phi_Col - fPi/6.0, fProton_Phi_Col + fPi/6.0); + +// cout << "Seed check: " << fRandom->GetSeed() << endl; + +// exit(0); + +// fScatElec_Theta_Col = 134 * fPi /180; +// fScatElec_Energy_Col = 5911; + +/*--------------------------------------------------*/ +/// 6 GeV +// fScatElec_Theta_Col = 152 * fPi /180; +// fScatElec_Energy_Col = 5303; + +//// + +// fScatElec_Theta_Col = 152 * fPi /180; +// fScatElec_Energy_Col = 5336; + + +// fScatElec_Theta_Col = 152 * fPi /180; +// fScatElec_Energy_Col = 5330; + + +/*--------------------------------------------------*/ +/// 7 GeV +// fScatElec_Theta_Col = 150 * fPi /180; +// fScatElec_Energy_Col = 5350; + +/*--------------------------------------------------*/ +/// 8 GeV +// fScatElec_Theta_Col = 148 * fPi /180; +// fScatElec_Energy_Col = 5403; + + fScatElec_Theta_Col = 148 * fPi /180; + fScatElec_Energy_Col = 5360; + + + + +/*--------------------------------------------------*/ +/// 9 GeV +// fScatElec_Theta_Col = 146 * fPi /180; +// fScatElec_Energy_Col = 5458; + +/*--------------------------------------------------*/ +/// 10.5 GeV +// fScatElec_Theta_Col = 144 * fPi /180; +// fScatElec_Energy_Col = 5518; + +/*--------------------------------------------------*/ +// Q2=10.5 GeV, S=25 +// fScatElec_Theta_Col = 144 * fPi /180; +// fScatElec_Energy_Col = 5477; + + +///*--------------------------------------------------*/ +// For special testing only +// fScatElec_Phi_Col = fPi; +// fScatElec_Phi_Col = 0.0; + fScatElec_Phi_Col = fProton_Phi_Col; + +// cout << "Initial and final angle: " << fScatElec_Theta_I*180/fPi << " " << fScatElec_Theta_F*180/fPi << " " << fScatElec_Theta_Col*180/fPi << " " << fScatElec_Energy_Col << " " << fElectron_Energy_Col << " " << fScatElec_E_Lo * fElectron_Energy_Col << " " << fScatElec_E_Hi * fElectron_Energy_Col << endl; +// +// +// cout << " electron::: " << fScatElec_Phi_Col*180/fPi << endl; + + + // ---------------------------------------------------- + // Produced Particle X in Collider frame + // ---------------------------------------------------- + + /// The generic produced particle in the exclusive reaction is labelled as X + // fX_Theta_Col = acos( rRand->Uniform( cos(fX_Theta_I), cos(fX_Theta_F ) ) ); + + //fX_Theta_Col = acos( rRand->Uniform( cos(fX_Theta_I), cos(fX_Theta_F ) ) ); + // fX_Phi_Col = fRandom->Uniform( 0 , 2.0 * fPi); + + + //fX_Phi_Col = fRandom->Uniform( 0 , 2.0 * fPi); + //fX_Phi_Col = fRandom->Uniform( 0 , 2.0 * fPi); + + /// ---------------------------------------------------- + /// ---------------------------------------------------- + /// Random number generation + + // fX_Phi_Col = fRandom->Uniform( fProton_Phi_Col - fPi/6, fProton_Phi_Col + fPi/6); + // fX_Theta_Col = fRandom->Uniform( 0.01, 0.04); + +// fX_Phi_Col = fPi; +// fX_Phi_Col = 0; + + ///*--------------------------------------------------*/ + // For special testing only + + //fX_Theta_Col = 0.01; // 0.5729 degree + //fX_Theta_Col = 0.02; // 0.5729 degree + //fX_Theta_Col = 0.0; // 0.5729 degree + //fX_Theta_Col = 0.025; // Proton incidence angle + + fX_Theta_Col = 0.0; // Proton incidence angle +// fX_Theta_Col = 0.025; // Proton incidence angle +// fX_Theta_Col = 0.05; // Proton incidence angle + +// fX_Phi_Col = 0.0; +// fX_Phi_Col = fPi; + fX_Phi_Col = fProton_Phi_Col; + + /*--------------------------------------------------*/ + + +// cout << "Angle check: " << fX_Theta_Col*180/fPi << " " << fX_Theta_I*180/fPi << " "<< fX_Theta_F*180/fPi << endl; +// +// +// +// cout << "proton phi " << r_lproton.Vect().Theta() << " " << r_lproton.Vect().Phi() << endl; +// +// cout << "10m radians: " << 0.01*180/fPi << endl; + +// exit(0); + + + // --------------------------------------------------------------------- + // Specify the energy and solid angle of scatterd electron in Collider (lab) frame + // --------------------------------------------------------------------- + + fScatElec_Mom_Col = sqrt( pow( fScatElec_Energy_Col,2) - pow( fElectron_Mass , 2) ); + fScatElec_MomZ_Col = ( fScatElec_Mom_Col * cos(fScatElec_Theta_Col) ); + fScatElec_MomX_Col = ( fScatElec_Mom_Col * sin(fScatElec_Theta_Col) * cos(fScatElec_Phi_Col) ); + fScatElec_MomY_Col = ( fScatElec_Mom_Col * sin(fScatElec_Theta_Col) * sin(fScatElec_Phi_Col) ); + + r_lscatelec.SetPxPyPzE( fScatElec_MomX_Col, fScatElec_MomY_Col, fScatElec_MomZ_Col, fScatElec_Energy_Col); + + r_lscatelecg = r_lscatelec * fm; + + // ---------------------------------------------------- + // Photon in collider (lab) frame and Qsq + // ---------------------------------------------------- + + r_lphoton = r_lelectron - r_lscatelec; + r_lphotong = r_lelectrong - r_lscatelecg; + + fQsq_GeV = -1.* r_lphotong.Mag2(); + +// cout << "e: " << r_lelectron.Px() << " " << r_lelectron.Py() << " " << r_lelectron.Pz() << " " << r_lelectron.E() << endl; +// cout << "Scattered e: " << r_lscatelec.Px() << " " << r_lscatelec.Py() << " " << r_lscatelec.Pz() << " " << r_lscatelec.E() << endl; +// +// cout << "Q2 check: " << fQsq_GeV << endl; +// +// exit(0); + + + + +// if ( fQsq_GeV < 5.0 ) { +// qsq_ev++; +// return; +// } + + // ---------------------------------------------------- + // W square, Invariant Mass (P_g + P_p)^2 + // ---------------------------------------------------- + + TLorentzVector lwg; + lwg = r_lprotong + r_lphotong; + fW_GeV = lwg.Mag(); + fWSq_GeV = lwg.Mag2(); + +// cout << endl << endl; +// cout << "W: " << fW_GeV << " s: " << fW_GeV*fW_GeV << " " << "Q2: " << fQsq_GeV << endl; +// cout << endl << endl; +// exit(0); + + + + if ( fWSq_GeV < 0 ) { + w_neg_ev++; + return; + } + + + if (fW_GeV < 0 || fW_GeV > 40) { + cout << "W out of range of interests" << endl; + return; + } + + + + + + + + // --------------------------------------------------------- + // Pion momentum in collider frame, analytic solution starts + // --------------------------------------------------------- + + double fupx = sin( fX_Theta_Col ) * cos( fX_Phi_Col ); + double fupy = sin( fX_Theta_Col ) * sin( fX_Phi_Col ); + double fupz = cos( fX_Theta_Col ); + + double fuqx = sin( r_lphoton.Theta() ) * cos( r_lphoton.Phi() ); + double fuqy = sin( r_lphoton.Theta() ) * sin( r_lphoton.Phi() ); + double fuqz = cos( r_lphoton.Theta() ); + + double fa = -(r_lphoton.Vect()).Mag() * ( fupx * fuqx + fupy * fuqy + fupz * fuqz ); + double fb = pow ( (r_lphoton.Vect()).Mag() , 2 ); + double fc = r_lphoton.E() + fProton_Mass; + + fa = ( fa - std::abs( (r_lproton.Vect()).Mag() ) * ( ( ( r_lproton.X() / (r_lproton.Vect()).Mag() ) * fupx ) + + ( ( r_lproton.Y() / (r_lproton.Vect()).Mag() ) * fupy ) + + ( ( r_lproton.Z() / (r_lproton.Vect()).Mag() ) * fupz ) ) ); + + double factor = ( pow( (r_lproton.Vect()).Mag() , 2 ) + 2.0 * (r_lphoton.Vect()).Mag() * (r_lproton.Vect()).Mag() * + ( ( ( r_lproton.X() / (r_lproton.Vect()).Mag() ) * fuqx ) + + ( ( r_lproton.Y() / (r_lproton.Vect()).Mag() ) * fuqy ) + + ( ( r_lproton.Z() / (r_lproton.Vect()).Mag() ) * fuqz ) ) ); + + fb = fb + factor; + fc = r_lphoton.E() + r_lproton.E(); + +// double ft = fc * fc - fb + fPion_Mass * fPion_Mass - fProton_Mass * fProton_Mass; +// t_min = -qsq + mass**2 -2.*(e_pi0CM*e_photCM -sqrt( (e_pi0CM**2-mass**2)*(e_photCM**2+qsq) )) +// t_max = -qsq + mass**2 -2.*(e_pi0CM*e_photCM +sqrt((e_pi0CM**2-mass**2)*(e_photCM**2+qsq))) +// u_min = -qsq + m_psq -2.*(e_pCM*e_photCM -sqrt( (e_pCM**2-m_psq)*(e_photCM**2+qsq) )) + + + double e_X_rf = lX_rf.E(); + double e_photon_rf = lphoton_rf.E(); + +// double e_photon_rf = lproton_rf.E(); + +// fu_min = -fQsq + pow(f_Scat_Nucleon_Mass, 2) -2.*(e_pi0CM*e_photCM -sqrt( (e_pi0CM**2-mass**2)*(e_photCM**2+qsq) )) + + double ft = fc * fc - fb + fX_Mass * fX_Mass - fProton_Mass * fProton_Mass; + + double fu = lproton_rf.Dot(lproton_rf) + lX_rf.Dot(lX_rf) - lproton_rf.Dot(lX_rf); + + + +// double fttt = lproton_rfg * lproton_rfg - 2* lproton_rfg * l_scat_nucleon_rf_g + l_scat_nucleon_rf_g * l_scat_nucleon_rf_g; +// double fuuu = lproton_rfg * lproton_rfg - 2* lproton_rfg * lX_rfg + lX_rfg * lX_rfg; + + + + + + ft_min = -fQsq_GeV + pow(fX_Mass, 2) -2.*(e_X_rf*e_photon_rf -sqrt( (pow(e_X_rf, 2) - pow(fX_Mass, 2)) * (pow(e_photon_rf,2)+fQsq) )); + + fu_min = -fQsq_GeV + pow(f_Scat_Nucleon_Mass, 2) -2.*(e_X_rf*e_photon_rf -sqrt( (pow(e_X_rf, 2) - pow(f_Scat_Nucleon_Mass , 2))*(pow(e_photon_rf,2)+fQsq) )); + + +// cout << "asd: " << ft_min << " " << fu_min << f_Scat_Nucleon_Mass << " " << fX_Mass << " " << fProton_Mass << " "<< fQsq << " " << e_photon_rf << " photon photon: " << lphoton_rf.E() << " " << fm << " " << r_lphoton.E() << " " << beta_col_rf.Mag() << endl; +// +// +// cout << r_lprotong.Px() << " " << r_lprotong.Py() << " " << r_lprotong.Pz() << " " << r_lprotong.E() << endl; +// cout << lproton_rfg.Px() << " " << lproton_rfg.Py() << " " << lproton_rfg.Pz() << " " << lproton_rfg.E() << endl; +// cout << beta_col_rf.Px() << " " << beta_col_rf.Py() << " " << beta_col_rf.Pz() << endl; + +// exit(0); + + + double fQA = 4.0 * ( fa * fa - fc * fc ); + double fQB = 4.0 * fc * ft; + +// double fQC = -4.0 * fa * fa * fPion_Mass * fPion_Mass - ft * ft; + double fQC = -4.0 * fa * fa * fX_Mass * fX_Mass - ft * ft; + + fradical = fQB * fQB - 4.0 * fQA * fQC; + + fepi1 = ( -fQB - sqrt( fradical ) ) / ( 2.0 * fQA ); + fepi2 = ( -fQB + sqrt( fradical ) ) / ( 2.0 * fQA ); + + // --------------------------------------------------------- + // Particle X momentum in collider frame, analytic solution ends + // --------------------------------------------------------- + + r_lX.SetPxPyPzE( (sqrt( pow( fepi1 , 2) - pow(fX_Mass , 2) ) ) * sin(fX_Theta_Col) * cos(fX_Phi_Col), + ( sqrt( pow( fepi1 , 2) - pow(fX_Mass , 2) ) ) * sin(fX_Theta_Col) * sin(fX_Phi_Col), + ( sqrt( pow( fepi1 , 2) - pow(fX_Mass , 2) ) ) * cos(fX_Theta_Col), + fepi1 ); + + r_lX_g = r_lX * fm; + + // ---------------------------------------------------- + // Scattered nucleon collider (lab) frame + + r_l_scat_nucleon.SetPxPyPzE( ( r_lproton + r_lelectron - r_lscatelec - r_lX).X(), + ( r_lproton + r_lelectron - r_lscatelec - r_lX ).Y(), + ( r_lproton + r_lelectron - r_lscatelec - r_lX ).Z(), + sqrt( pow( ( ( ( r_lproton + r_lelectron - r_lscatelec - r_lX ).Vect() ).Mag()),2) + + pow( f_Scat_Nucleon_Mass ,2 ) ) ); + + r_l_scat_nucleon_g = r_l_scat_nucleon * fm; + +// cout << "Proton Momentum: " << r_l_scat_nucleon_g.Vect().Mag() << " " << r_l_scat_nucleon_g.Vect().Theta() << " Angle: "<< r_l_scat_nucleon_g.Vect().Theta() *180/fPi << endl; +// cout << "X Momentum: " << r_lX_g.Vect().Mag() << " Angle: " << r_lX_g.Vect().Theta() << " " << r_lX_g.Vect().Theta() *180/fPi<< endl ; + +// cout << "Proton-X Angle: " << r_lX_g.Vect().Angle(r_l_scat_nucleon_g.Vect())*180/fPi << endl ; + + // ---------------------------------------------------------------------------------------------- + // ---------------------------------------------------------------------------------------------- + // Calculate w = (proton + photon)^2 + // ---------------------------------------------------------------------------------------------- + // ---------------------------------------------------------------------------------------------- + +// // cout << fW_GeV << endl; +// if ( fW_GeV < 3.0 || fW_GeV > 10.6 ) { +// w_ev++; +// return; +// } + + r_lw = r_lproton + r_lphoton; + fW = r_lw.Mag(); + + // ---------------------------------------------------------------------------------------------- + // ---------------------------------------------------------------------------------------------- + // Calculate w prime w' = (proton + photon - pion)^2 + // ---------------------------------------------------------------------------------------------- + // ---------------------------------------------------------------------------------------------- + + lwp = r_lprotong + r_lphotong - r_lX_g; + fW_Prime_GeV = lwp.Mag(); + + fsini = r_lelectron + r_lproton; + fsfin = r_lscatelec + r_lX + r_l_scat_nucleon; + + fsinig = fsini * fm; + fsfing = fsfin * fm; + + fMandSConserve = std::abs( fsinig.Mag() - fsfing.Mag() ); + + kSConserve = false; + if( std::abs( fsinig.Mag() - fsfing.Mag() ) < fDiff ) { + kSConserve = true; + } + + if ( pd->CheckLaws( r_lelectron, r_lproton, r_lscatelec, r_lX, r_l_scat_nucleon) != 1 ) + return; + + + //////////////////////////////////////////////////////////////////////////////////////////// + // Start // + // Transformation of e', pi- and recoil proton to target's rest frmae without energy loss // + //////////////////////////////////////////////////////////////////////////////////////////// + + lproton_rf = r_lproton; + lproton_rf.Boost(-beta_col_rf); + lproton_rfg = lproton_rf * fm; + + lelectron_rf = r_lelectron; + lelectron_rf.Boost(-beta_col_rf); + lelectron_rfg = lelectron_rf * fm; + + lscatelec_rf = r_lscatelec; + lscatelec_rf.Boost(-beta_col_rf); + lscatelec_rfg = lscatelec_rf * fm; + + lphoton_rf = r_lphoton; + lphoton_rf.Boost(-beta_col_rf); + lphoton_rfg = lphoton_rf * fm; + + lX_rf = r_lX; + lX_rf.Boost(-beta_col_rf); + lX_rfg = lX_rf * fm; + + l_scat_nucleon_rf = r_l_scat_nucleon; + l_scat_nucleon_rf.Boost(-beta_col_rf); + l_scat_nucleon_rf_g = l_scat_nucleon_rf * fm; + + + + ///*--------------------------------------------------*/ + /// Doing pi0 decay + + if (if_pi0_decay) { + Pi0_decay(r_lX); + } + + + //////////////////////////////////////////////////////////////////////////////////////////// + // End // + // Transformation of e', pi- and recoil proton to target's rest frmae without energy loss // + //////////////////////////////////////////////////////////////////////////////////////////// + +/*--------------------------------------------------*/ +/*--------------------------------------------------*/ +/*--------------------------------------------------*/ +/*--------------------------------------------------*/ +/// Polar output + + if (fQsq_GeV > 5 && fQsq_GeV < 12 && fWSq_GeV > 8 && fWSq_GeV < 12) { + +// cout << fQsq_GeV << " " << fWSq_GeV << " "; +// +// cout << r_lscatelecg.Vect().Theta() << " " << r_lscatelecg.Vect().Mag() << " " +// << r_l_scat_nucleon_g.Vect().Theta() << " " << r_l_scat_nucleon_g.Vect().Mag() << " " +// << r_lX_g.Vect().Theta() << " " << r_lX_g.Vect().Mag() +// << endl; + + polar_out << fQsq_GeV << " " << fWSq_GeV << " "; + + polar_out << r_lscatelecg.Vect().Theta() << " " << r_lscatelecg.Vect().Mag() << " " + << r_l_scat_nucleon_g.Vect().Theta() << " " << r_l_scat_nucleon_g.Vect().Mag() << " " + << r_lX_g.Vect().Theta() << " " << r_lX_g.Vect().Mag() << " " + << l_photon_1.Vect().Theta() << " " << l_photon_1.Vect().Mag() << " " + << l_photon_2.Vect().Theta() << " " << l_photon_2.Vect().Mag() + << endl; + + } + +// exit(0); +// return; + + +/*--------------------------------------------------*/ +/*--------------------------------------------------*/ +/*--------------------------------------------------*/ +/*--------------------------------------------------*/ + + + + + + + + + + + + + + + + + + + + + + + + + e_X_rf = lX_rf.E(); + + double e_p_rf = lproton_rf.E(); + + e_photon_rf = lphoton_rf.E(); + + // e_photCM = (Wsq - qsq - m_psq)/invm/2. + // e_omCM = (Wsq + mass**2 - m_psq)/invm/2. + // e_pCM = (Wsq + m_psq - mass**2)/invm/2. + + + + +// double e_photCM = (fWSq_GeV - fQsq_GeV - pow(fProton_Mass/1000, 2))/fW_GeV/2.; + + double e_photCM = (fWSq_GeV - fQsq_GeV - pow(fProton_Mass/1000, 2))/fW_GeV/2.; + double e_pCM = (fWSq_GeV + pow(fProton_Mass/1000, 2) - pow(f_Scat_Nucleon_Mass/1000, 2))/fW_GeV/2.; + +// cout << "*********: " << e_photCM << " " << e_pCM << endl; +// cout << "*********: " << e_photon_rf << " "<< e_p_rf << endl; + + + + ft_min = -fQsq_GeV + pow(fX_Mass/1000, 2) -2.*(e_X_rf/1000*e_photon_rf/1000 -sqrt( (pow(e_X_rf/1000, 2) - pow(fX_Mass/1000, 2)) * (pow(e_photon_rf/1000,2)+fQsq_GeV) )); + + +// u_min = -qsq + m_psq -2.*(e_pCM*e_photCM -sqrt( (e_pCM**2-m_psq)*(e_photCM**2+qsq) )) + +// fu_min = -fQsq_GeV + pow(fProton_Mass/1000, 2) -2.*(e_p_rf/1000*e_photon_rf/1000 -sqrt( fabs(pow(e_p_rf/1000, 2) - pow(fProton_Mass/1000 , 2))*(pow(e_photon_rf/1000,2)+fQsq_GeV) )); + + fu_min = -fQsq_GeV + pow(fProton_Mass/1000, 2) -2.*(e_pCM*e_photCM -sqrt( (pow(e_pCM/1000, 2) - pow(fProton_Mass/1000 , 2))*(pow(e_photCM/1000,2)+fQsq_GeV) )); + + +// cout << fQsq_GeV << " " << "AAAA " << (pow(e_p_rf/1000, 2) - pow(f_Scat_Nucleon_Mass/1000 , 2))*(pow(e_photon_rf/1000,2)+fQsq_GeV) << " :::: " << (pow(e_p_rf/1000, 2) - pow(fProton_Mass/1000 , 2)) << " " << (pow(e_photon_rf/1000,2)+fQsq_GeV) << " " << pow(e_p_rf/1000, 2) << " " << pow(fProton_Mass/1000 , 2) << " " << e_p_rf/1000*e_photon_rf/1000 << endl; +// +// cout << endl; +// cout << endl; +// cout << endl; +// +// +// cout << "asd: " << ft_min << " " << fu_min << " " << f_Scat_Nucleon_Mass << " " << fX_Mass << " " << fProton_Mass << " "<< fQsq << " " << e_photon_rf << " photon photon: " << lphoton_rf.E() << " " << fm << " " << r_lphoton.E() << " " << beta_col_rf.Mag() << endl; +// +// +// cout << "Photon energy: " << e_X_rf << " " << e_photon_rf << endl; +// +// cout << r_lprotong.Px() << " " << r_lprotong.Py() << " " << r_lprotong.Pz() << " " << r_lprotong.E() << endl; +// cout << lproton_rfg.Px() << " " << lproton_rfg.Py() << " " << lproton_rfg.Pz() << " " << lproton_rfg.E() << endl; +// cout << "aaa " << beta_col_rf.Px() << " " << beta_col_rf.Py() << " " << beta_col_rf.Pz() << endl; +// +// exit(0); + + // ----------------------------------------------------------------------------------------- + // ----------------------------------------------------------------------------------------- + // Calculate -t + // ----------------------------------------------------------------------------------------- + // ----------------------------------------------------------------------------------------- + + fBeta_CM_RF = (lphoton_rf.Vect()).Mag() / ( lphoton_rf.E() + fProton_Mass ); + fGamma_CM_RF = ( lphoton_rf.E() + fProton_Mass ) / fW; + fX_Energy_CM = ( pow( fW , 2) + pow(fX_Mass , 2) - pow(f_Scat_Nucleon_Mass , 2) ) / ( 2.0 * fW); + fX_Mom_CM = sqrt( pow(fX_Energy_CM , 2) - pow(fX_Mass , 2)); + fX_Energy_CM_GeV = fX_Energy_CM / 1000.0; + fX_Mom_CM_GeV = fX_Mom_CM / 1000.0; + + // this equation is valid for parallel kinematics only! + fT_Para = ( pow(((r_lphoton.Vect()).Mag() - (r_lX.Vect()).Mag()),2) - pow((r_lphoton.E() - r_lX.E()),2)); + fT_Para_GeV = fT_Para/1000000.0; + + lt = r_lphoton - r_lX; + ltg = lt * fm; + + fT = -1.*lt.Mag2(); + fT_GeV = -1.*ltg.Mag2(); + + +// cout << "ttt: " << fT_GeV << endl; + + + + //if ( gKinematics_type == 1 && fT_GeV > 0.5 ) { + // t_ev++; + // return; + //} + // + //if ( gKinematics_type == 2 && fT_GeV > 1.3 ) { + // t_ev++; + // return; + //} + + fx = fQsq_GeV / ( 2.0 * r_lprotong.Dot( r_lphotong ) ); + fy = r_lprotong.Dot( r_lphotong ) / r_lprotong.Dot( r_lelectrong ); + fz = r_lX.E()/r_lphoton.E(); + + // ------------------------------------------------------------------------------------------------------- + // Calculation of Phi ( azimuthal angle of pion momentum w.r.t lepton plane in target's rest frame) + // Calculation of PhiS ( azimuthal angle of target polarization w.r.t lepton plane in target's rest frame) + // ------------------------------------------------------------------------------------------------------- + + v3Photon.SetX( lphoton_rfg.X() ); + v3Photon.SetY( lphoton_rfg.Y() ); + v3Photon.SetZ( lphoton_rfg.Z() ); + + v3Electron.SetX( lelectron_rfg.X() ); + v3Electron.SetY( lelectron_rfg.Y() ); + v3Electron.SetZ( lelectron_rfg.Z() ); + + v3X.SetX( lX_rfg.X() ) ; + v3X.SetY( lX_rfg.Y() ) ; + v3X.SetZ( lX_rfg.Z() ); + + v3S.SetX( -1 ); + v3S.SetY( 0 ); + v3S.SetZ( 0 ); + + v3PhotonUnit = v3Photon.Unit(); + v3QxL = v3Photon.Cross(v3Electron); + v3QxP = v3Photon.Cross(v3X); + v3QxS = v3Photon.Cross(v3S); + v3LxP = v3Electron.Cross(v3X); + v3LxS = v3Electron.Cross(v3S); + v3PxL = v3X.Cross(v3Electron); + v3QUnitxL = v3PhotonUnit.Cross(v3Electron); + v3QUnitxP = v3PhotonUnit.Cross(v3X); + v3QUnitxS = v3PhotonUnit.Cross(v3S); + + /*--------------------------------------------------*/ + // Get the Phi scattering angle with respect to the electron scattering plane + fPhi = Get_Phi_X_LeptonPlane_RF (); + + /*--------------------------------------------------*/ + // Get the Phi scattering angle between the target polarization plane and the electron scattering plane + fPhiS = Get_Phi_TargPol_LeptonPlane_RF(); + + fTheta_X_Photon_RF = fRAD2DEG * acos( ( v3Photon.Dot( v3X ) ) / ( v3Photon.Mag() * v3X.Mag() ) ); + if ( fTheta_X_Photon_RF < 0 ) { fTheta_X_Photon_RF = 180.0 + fTheta_X_Photon_RF; } + + // ----------------------------------------------------------------------------------- + // If we have fermi momentum then epsilon should be in rest frame + // The theta angle of scattered angle used in expression of epsilon is the angle + // with respect to direction of incoming electron in the rest frame of target nucleon + // epsilon=1./(1.+ 2.*(pgam_restg**2)/q2g * *(tand(thscat_rest/2.))**2) + // ----------------------------------------------------------------------------------- + + double fTheta_EEp = (lelectron_rf.Vect()).Angle(lscatelec_rf.Vect()); + + fEpsilon = 1.0 / ( 1.0 + 2.0 * ( pow( (lphoton_rfg.Vect()).Mag(),2)/fQsq_GeV ) * pow( tan( fTheta_EEp / 2 ) , 2 ) ); + + /// meson produced angle with respect to the Q-vector + + theta_X_rf = (lX_rf.Vect()).Angle(lphoton_rf.Vect()); + + + // ---------------------------------------------------- + // Virtual Photon flux factor in units of 1/(GeV*Sr) + // ---------------------------------------------------- + fFlux_Factor_Col = (fAlpha/(2.0*pow(fPi,2))) * (r_lscatelecg.E() / r_lelectrong.E()) * + ( pow(fW_GeV,2) - pow(fProton_Mass_GeV,2) ) / (2.0*fProton_Mass_GeV*fQsq_GeV*(1.0 - fEpsilon)); + + fFlux_Factor_RF = ( fAlpha / ( 2.0 * pow( fPi , 2 ) ) ) * ( lscatelec_rfg.E() / lelectron_rfg.E() ) * + ( pow( fW_GeV , 2 ) - pow( fProton_Mass_GeV , 2 ) ) / + ( 2.0 * fProton_Mass_GeV * fQsq_GeV * ( 1.0 - fEpsilon ) ); + + + // ---------------------------------------------------- + // Jacobian dt/dcos(theta*)dphi in units of GeV2/sr + // ---------------------------------------------------- + fJacobian_CM = ( (lphoton_rfg.Vect()).Mag() - fBeta_CM_RF * lphoton_rfg.E() ) / ( fGamma_CM_RF * ( 1.0 - pow(fBeta_CM_RF,2) ) ); + + fA = fJacobian_CM * fX_Mom_CM_GeV / fPi; + +// cout << "LXXXX check: " << ( r_lproton + r_lelectron - r_lscatelec - r_lX).X() << " " << ( r_lproton + r_lelectron - r_lscatelec - r_lX ).Y() << " " << ( r_lproton + r_lelectron - r_lscatelec - r_lX ).Z() << " " << sqrt( pow( ( ( ( r_lproton + r_lelectron - r_lscatelec - r_lX ).Vect() ).Mag()),2) + pow( f_Scat_Nucleon_Mass ,2 ) ) << endl; + + + double fttt = r_lprotong * r_lprotong - 2 * r_lprotong * r_l_scat_nucleon_g + r_l_scat_nucleon_g * r_l_scat_nucleon_g; + double fuuu = r_lprotong * r_lprotong - 2 * r_lprotong * r_lX_g + r_lX_g * r_lX_g; + +// cout << "check this: " << r_lprotong * r_lprotong << " " << r_l_scat_nucleon_g * r_l_scat_nucleon_g << " " << r_lX_g * r_lX_g << endl; +// +// cout << "t: " << ft << " " << fttt << " u: " << fu << " " << fuuu << endl; +// +// cout << "Angle aaa : " << r_lproton.Vect().Angle(r_lX.Vect()) << endl; +// +// +// exit(0); + + // ---------------------------------------------------- + // Jacobian dOmega* / dOmega dimensionless + // ---------------------------------------------------- + fJacobian_CM_RF = ( pow((lX_rf.Vect()).Mag(),2)*fW) / + ( fX_Mom_CM * std::abs( ( fProton_Mass + lphoton_rf.E()) * (lX_rf.Vect()).Mag() - + ( lX_rf.E() * (lphoton_rf.Vect()).Mag() * cos( lX_rf.Theta() ) ) ) ); + + fJacobian_CM_Col = ( ( pow((r_lX.Vect()).Mag(),2) * fW ) / + ( fX_Mom_CM * std::abs( ( fProton_Mass + r_lphoton.E() ) * (r_lX.Vect()).Mag() - + ( r_lX.E() * (r_lphoton.Vect()).Mag() * cos( r_lX.Theta() ) ) ) ) ); + + // ----------------------------------------------------------------------------------------------------------- + // CKY sigma L and T starts + // ----------------------------------------------------------------------------------------------------------- + // ------------------------------------------------------------------------------------------- + + r_fSig = Get_CrossSection(); + + // ----------------------------------------------------------------------------------------------------------- + // CKY sigma L and T ends + // ----------------------------------------------------------------------------------------------------------- + + fSigma_Col = r_fSig * fFlux_Factor_Col * fA * fJacobian_CM_Col; + + + if ( ( fSigma_Col <= 0 ) || std::isnan( fSigma_Col ) ) { + fNSigmaNeg ++; + return; + } + + // ----------------------------------------------------------------------------------------------------------- + // ----------------------------------------------------------------------------------------------------------- + // Lab cross section Phase Space Conversion Luminosity Total events tried + // Hz = ub / ( sr^2 * GeV ) * GeV * sr^2 * ( cm^2 / ub ) * ( # / ( cm^2 * sec ) ) / ( # ) + + fEventWeight = fSigma_Col * fPSF * fuBcm2 * fLumi / fNEvents; // in Hz + + + fNRecorded ++; + fLundRecorded++; + fRatio = fNRecorded / fNGenerated; + +// cout << if_pi0_decay << endl; + +// if (if_pi0_decay) { +// Pi0_Decay_Lund_Output(); +// } else { +// Pi0_Lund_Output(); +// } +// cout << "AAAAAAAAAAAAAA" << endl; + + Pi0_Decay_Pythia6_Output(); + + +// exit(0); + +} + +/*--------------------------------------------------*/ + +void Pi0_Production::Detail_Output() { + + ppiDetails << "Total events tried " << setw(50) << fNGenerated << endl; + ppiDetails << "Total events recorded " << setw(50) << fNRecorded << endl; + + ppiDetails << "Seed used for the Random Number Generator " << setw(50) << fSeed << endl; + ppiDetails << "Number of lund events " << setw(50) << fLundRecorded << endl; + +} + + +/*--------------------------------------------------*/ +/*--------------------------------------------------*/ + +void Pi0_Production::Pi0_Lund_Output() { + + + ppiOut << "5" + << " \t " << fPhi // var 1 + << " \t " << fPhiS // var 2 + << " \t " << fx // var 3 + << " \t " << "1" + << " \t " << fQsq_GeV // var 4 + << " \t " << fT_GeV // var 5 + << " \t " << fW_GeV // var 6 + << " \t " << fEpsilon // var 7 + << " \t " << fEventWeight // var 8 + << endl; + + ///*--------------------------------------------------*/ + // Initial State + + ppiOut << setw(10) << "1" + << setw(10) << "-1" + << setw(10) << "0" + << setw(10) << "11" + << setw(10) << "0" + << setw(10) << "0" + << setw(16) << r_lelectrong.X() + << setw(16) << r_lelectrong.Y() + << setw(16) << r_lelectrong.Z() + << setw(16) << r_lelectrong.E() + << setw(16) << fElectron_Mass_GeV + << setw(16) << fVertex_X + << setw(16) << fVertex_Y + << setw(16) << fVertex_Z + << endl; + + ppiOut << setw(10) << "2" + << setw(10) << "1" + << setw(10) << "0" + << setw(10) << "2212" + << setw(10) << "0" + << setw(10) << "0" + << setw(16) << r_lprotong.X() + << setw(16) << r_lprotong.Y() + << setw(16) << r_lprotong.Z() + << setw(16) << r_lprotong.E() + << setw(16) << fProton_Mass_GeV + << setw(16) << fVertex_X + << setw(16) << fVertex_Y + << setw(16) << fVertex_Z + << endl; + + + + ///*--------------------------------------------------*/ + // Final State + + // Produced Particle X + ppiOut << setw(10) << "3" + << setw(10) << "1" + << setw(10) << "1" + << setw(10) << PDGtype(produced_X) + << setw(10) << "0" + << setw(10) << "0" + << setw(16) << r_lX_g.X() + << setw(16) << r_lX_g.Y() + << setw(16) << r_lX_g.Z() + << setw(16) << r_lX_g.E() + << setw(16) << fX_Mass_GeV + << setw(16) << fVertex_X + << setw(16) << fVertex_Y + << setw(16) << fVertex_Z + << endl; + + // Scattered electron + ppiOut << setw(10) << "4" + << setw(10) << "-1" + << setw(10) << "1" + << setw(10) << "11" + << setw(10) << "0" + << setw(10) << "0" + << setw(16) << r_lscatelecg.X() + << setw(16) << r_lscatelecg.Y() + << setw(16) << r_lscatelecg.Z() + << setw(16) << r_lscatelecg.E() + << setw(16) << fElectron_Mass_GeV + << setw(16) << fVertex_X + << setw(16) << fVertex_Y + << setw(16) << fVertex_Z + << endl; + + // Recoiled neutron + ppiOut << setw(10) << "5" + << setw(10) << "1" + << setw(10) << "1" + << setw(10) << PDGtype(recoil_nucleon) + << setw(10) << "0" + << setw(10) << "0" + << setw(16) << r_l_scat_nucleon_g.X() + << setw(16) << r_l_scat_nucleon_g.Y() + << setw(16) << r_l_scat_nucleon_g.Z() + << setw(16) << r_l_scat_nucleon_g.E() + << setw(16) << f_Scat_Nucleon_Mass_GeV + << setw(16) << fVertex_X + << setw(16) << fVertex_Y + << setw(16) << fVertex_Z + << endl; + + +// cout << "Particle check: " << PDGtype(produced_X) << " " << PDGtype(recoil_nucleon) << endl; + + + + + +// ///*--------------------------------------------------*/ +// +// ppiOut << "3" +// << " \t " << fPhi // var 1 +// << " \t " << fPhiS // var 2 +// << " \t " << fx // var 3 +// << " \t " << "1" +// << " \t " << fQsq_GeV // var 4 +// << " \t " << fT_GeV // var 5 +// << " \t " << fW_GeV // var 6 +// << " \t " << fEpsilon // var 7 +// << " \t " << fEventWeight // var 8 +// << endl; +// +// ///*--------------------------------------------------*/ +// // Final State +// +// // Produced Particle X +// ppiOut << setw(10) << "1" +// << setw(10) << "1" +// << setw(10) << "1" +// << setw(10) << PDGtype(produced_X) +// << setw(10) << "0" +// << setw(10) << "0" +// << setw(16) << r_lX_g.X() +// << setw(16) << r_lX_g.Y() +// << setw(16) << r_lX_g.Z() +// << setw(16) << r_lX_g.E() +// << setw(16) << fX_Mass_GeV +// << setw(16) << fVertex_X +// << setw(16) << fVertex_Y +// << setw(16) << fVertex_Z +// << endl; +// +// // Scattered electron +// ppiOut << setw(10) << "2" +// << setw(10) << "-1" +// << setw(10) << "1" +// << setw(10) << "11" +// << setw(10) << "0" +// << setw(10) << "0" +// << setw(16) << r_lscatelecg.X() +// << setw(16) << r_lscatelecg.Y() +// << setw(16) << r_lscatelecg.Z() +// << setw(16) << r_lscatelecg.E() +// << setw(16) << fElectron_Mass_GeV +// << setw(16) << fVertex_X +// << setw(16) << fVertex_Y +// << setw(16) << fVertex_Z +// << endl; +// +// // Recoiled neutron +// ppiOut << setw(10) << "3" +// << setw(10) << "1" +// << setw(10) << "1" +// << setw(10) << PDGtype(recoil_nucleon) +// << setw(10) << "0" +// << setw(10) << "0" +// << setw(16) << r_l_scat_nucleon_g.X() +// << setw(16) << r_l_scat_nucleon_g.Y() +// << setw(16) << r_l_scat_nucleon_g.Z() +// << setw(16) << r_l_scat_nucleon_g.E() +// << setw(16) << f_Scat_Nucleon_Mass_GeV +// << setw(16) << fVertex_X +// << setw(16) << fVertex_Y +// << setw(16) << fVertex_Z +// << endl; +// +// +// cout << "Particle check: " << PDGtype(produced_X) << " " << PDGtype(recoil_nucleon) << endl; +// + + +} + +/*--------------------------------------------------*/ +/*--------------------------------------------------*/ + +void Pi0_Production::Pi0_Decay_Lund_Output() { + +// cout << rNEvents << endl; +// cout << "-----------+++++++++++++-------------------" << endl; +// exit(0); + + + + + ppiOut << "4" + << " \t " << fPhi // var 1 + << " \t " << fPhiS // var 2 + << " \t " << fx // var 3 + << " \t " << "1" + << " \t " << fQsq_GeV // var 4 + << " \t " << fT_GeV // var 5 + << " \t " << fW_GeV // var 6 + << " \t " << fEpsilon // var 7 + << " \t " << fEventWeight // var 8 + << endl; + +// // Produced Particle X +// ppiOut << setw(10) << "1" +// << setw(10) << "1" +// << setw(10) << "1" +// << setw(10) << PDGtype(produced_X) +// << setw(10) << "0" +// << setw(10) << "0" +// << setw(16) << r_lX_g.X() +// << setw(16) << r_lX_g.Y() +// << setw(16) << r_lX_g.Z() +// << setw(16) << r_lX_g.E() +// << setw(16) << fX_Mass_GeV +// << setw(16) << fVertex_X +// << setw(16) << fVertex_Y +// << setw(16) << fVertex_Z +// << endl; + + // Scattered electron + ppiOut << setw(10) << "2" + << setw(10) << "-1" + << setw(10) << "1" + << setw(10) << "11" + << setw(10) << "0" + << setw(10) << "0" + << setw(16) << r_lscatelecg.X() + << setw(16) << r_lscatelecg.Y() + << setw(16) << r_lscatelecg.Z() + << setw(16) << r_lscatelecg.E() + << setw(16) << fElectron_Mass_GeV + << setw(16) << fVertex_X + << setw(16) << fVertex_Y + << setw(16) << fVertex_Z + << endl; + + // Recoiled neutron + ppiOut << setw(10) << "3" + << setw(10) << "1" + << setw(10) << "1" + << setw(10) << PDGtype(recoil_nucleon) + << setw(10) << "0" + << setw(10) << "0" + << setw(16) << r_l_scat_nucleon_g.X() + << setw(16) << r_l_scat_nucleon_g.Y() + << setw(16) << r_l_scat_nucleon_g.Z() + << setw(16) << r_l_scat_nucleon_g.E() + << setw(16) << f_Scat_Nucleon_Mass_GeV + << setw(16) << fVertex_X + << setw(16) << fVertex_Y + << setw(16) << fVertex_Z + << endl; + + // Photon 1 + ppiOut << setw(10) << "3" + << setw(10) << "1" + << setw(10) << "1" + << setw(10) << "22" + << setw(10) << "0" + << setw(10) << "0" + << setw(16) << l_photon_1.X() + << setw(16) << l_photon_1.Y() + << setw(16) << l_photon_1.Z() + << setw(16) << l_photon_1.E() + << setw(16) << "0" + << setw(16) << fVertex_X + << setw(16) << fVertex_Y + << setw(16) << fVertex_Z + << endl; + + // Photon 2 + ppiOut << setw(10) << "4" + << setw(10) << "1" + << setw(10) << "1" + << setw(10) << "22" + << setw(10) << "0" + << setw(10) << "0" + << setw(16) << l_photon_2.X() + << setw(16) << l_photon_2.Y() + << setw(16) << l_photon_2.Z() + << setw(16) << l_photon_2.E() + << setw(16) << "0" + << setw(16) << fVertex_X + << setw(16) << fVertex_Y + << setw(16) << fVertex_Z + << endl; + +} + + + + +/*--------------------------------------------------*/ +/*--------------------------------------------------*/ +/*--------------------------------------------------*/ + +void Pi0_Production::Pi0_Decay_Pythia6_Out_Init() { + + + print_itt = 0; + +// ppiOut << "PYTHIA EVENT FILE" << endl; + ppiOut << "SIMPLE Event FILE" << endl; + ppiOut << "============================================" << endl; + ppiOut << "I, ievent, nParticles" << endl; + ppiOut << "============================================" << endl; + ppiOut << "I K(I,1) K(I,2) K(I,3) K(I,4) K(I,5) P(I,1) P(I,2) P(I,3) P(I,4) P(I,5) V(I,1) V(I,2) V(I,3)" << endl; + ppiOut << "============================================" << endl; + +} + +/*--------------------------------------------------*/ + +void Pi0_Production::Pi0_Decay_Pythia6_Output() { + + + +// ppiOut << "4" +// << " \t " << fPhi // var 1 +// << " \t " << fPhiS // var 2 +// << " \t " << fx // var 3 +// << " \t " << "1" +// << " \t " << fQsq_GeV // var 4 +// << " \t " << fT_GeV // var 5 +// << " \t " << fW_GeV // var 6 +// << " \t " << fEpsilon // var 7 +// << " \t " << fEventWeight // var 8 +// << endl; + + + ppiOut << "0" << " \t\t\t\ " << print_itt << " \t\t\t " << "1" << endl; // var 1 + + print_itt++; + + ppiOut << "============================================" << endl; + + ///*--------------------------------------------------*/ + // Initial State + + ppiOut << "1" + << setw(6) << "21" + << setw(6) << "11" + << setw(6) << "0" + << setw(6) << "3" + << setw(6) << "4" + + << setw(14) << r_lelectrong.X() + << setw(14) << r_lelectrong.Y() + << setw(14) << r_lelectrong.Z() + << setw(14) << r_lelectrong.E() + << setw(14) << fElectron_Mass_GeV + << setw(6) << fVertex_X + << setw(6) << fVertex_Y + << setw(6) << fVertex_Z + << endl; + + ppiOut << "2" + << setw(6) << "21" + << setw(6) << "2212" + << setw(6) << "0" + << setw(6) << "5" + << setw(6) << "6" + + << setw(14) << r_lprotong.X() + << setw(14) << r_lprotong.Y() + << setw(14) << r_lprotong.Z() + << setw(14) << r_lprotong.E() + << setw(14) << fProton_Mass_GeV + << setw(6) << fVertex_X + << setw(6) << fVertex_Y + << setw(6) << fVertex_Z + << endl; + + ppiOut << "3" + << setw(6) << "21" + << setw(6) << "22" + << setw(6) << "1" + << setw(6) << "0" + << setw(6) << "0" + + << setw(14) << r_lphotong.X() + << setw(14) << r_lphotong.Y() + << setw(14) << r_lphotong.Z() + << setw(14) << r_lphotong.E() + << setw(14) << r_lphotong.M() + << setw(6) << fVertex_X + << setw(6) << fVertex_Y + << setw(6) << fVertex_Z + << endl; + + + ///*--------------------------------------------------*/ + // Final State + + // Scattered electron + ppiOut << "4" + << setw(6) << "1" + << setw(6) << "11" + << setw(6) << "1" + << setw(6) << "0" + << setw(6) << "0" + + << setw(14) << r_lscatelecg.X() + << setw(14) << r_lscatelecg.Y() + << setw(14) << r_lscatelecg.Z() + << setw(14) << r_lscatelecg.E() + << setw(14) << fElectron_Mass_GeV + << setw(6) << fVertex_X + << setw(6) << fVertex_Y + << setw(6) << fVertex_Z + << endl; + + // Recoiled nucleon + ppiOut << "5" + << setw(6) << "1" + << setw(6) << PDGtype(recoil_nucleon) + << setw(6) << "2" + << setw(6) << "0" + << setw(6) << "0" + + << setw(14) << r_l_scat_nucleon_g.X() + << setw(14) << r_l_scat_nucleon_g.Y() + << setw(14) << r_l_scat_nucleon_g.Z() + << setw(14) << r_l_scat_nucleon_g.E() + << setw(14) << f_Scat_Nucleon_Mass_GeV + << setw(6) << fVertex_X + << setw(6) << fVertex_Y + << setw(6) << fVertex_Z + << endl; + + // Produced Particle X + ppiOut << "6" + << setw(6) << "1" + << setw(6) << PDGtype(produced_X) + << setw(6) << "2" + << setw(6) << "0" + << setw(6) << "0" + + << setw(14) << r_lX_g.X() + << setw(14) << r_lX_g.Y() + << setw(14) << r_lX_g.Z() + << setw(14) << r_lX_g.E() + << setw(14) << fX_Mass_GeV + << setw(6) << fVertex_X + << setw(6) << fVertex_Y + << setw(6) << fVertex_Z + << endl; + + ppiOut << "=============== Event finished ===============" << endl; + +} + + + +/*--------------------------------------------------*/ +/// Cross section model: Based on 12 GeV Hall C u-channel pi0 proposal +/// Author: Garth Huber +/// Date: April 1st, 2020 + +Double_t Pi0_Production::Get_CrossSection(){ + + double_t sig_total; + + // use fit parameters for xB=0.36 data+model (nb/GeV2) + Double_t Q2tab[4] = {1.75, 3.00, 4.00, 5.50}; + Double_t Wtab[4] = {2.00, 2.46, 2.83, 3.26}; + + // sigT is parameterized in the form p1+p2/(-t) + Double_t p1T[4] = {1577., 168., 67.4, 24.7}; + Double_t p2T[4] = {-125., -11.1, -4.6, -1.66}; + + // sigL is simply constant vs t + Double_t p1L[4] = {0., 2.77, 1.16, 0.43}; + + // sigTT p1+p2/(-t) + Double_t p1TT[4] = {-674., -141., -57.6, -21.3}; + Double_t p2TT[4] = { 102., 25.4, 10.4, 3.82}; + + // sigLT p1+p2/(-t) + Double_t p1LT[4] = { 156., 12.57, 5.17, 1.97}; + Double_t p2LT[4] = {-60.0, -2.08, -0.85, -0.32}; + + double sigThi, sigTlo, sigLhi, sigLlo; + double sigTThi, sigTTlo, sigLThi, sigLTlo; + double tmin, tprime; + double umin, uprime; + Int_t Q2count =0; + + double thetacm = theta_X_rf; + + double eps = fEpsilon; + double phicm = fPhi; + + double Q2hi=0.; + double Q2lo=0.; + double delQ2=1.; + + double Whi, Wlo; + + double Q2tmp = fQsq_GeV; + double m_p = fProton_Mass; + double W_gev = fW_GeV; + + double pi = fPi; + + int ndat=4; + + tprime = ft-ft_min; + uprime = fu-fu_min; + + if( Q2tmp < Q2tab[0] ) { + + Q2count = 0; + Q2hi = Q2tab[1]; + Whi = Wtab[1]; + Q2lo = Q2tab[0]; + Wlo = Wtab[0]; + delQ2 = (Q2hi - Q2lo); + + } else { + + for(int Q2c=0; Q2c <= ndat-2; Q2c++){ + +// cout << Q2c << endl; + if( (Q2tmp >= Q2tab[Q2c] && Q2tmp < Q2tab[Q2c+1]) || Q2tmp >= Q2tab[Q2c+1] ) { + + Q2count = Q2c ; + Q2hi = Q2tab[Q2count+1]; + Whi = Wtab[Q2count+1]; + Q2lo = Q2tab[Q2count]; + Wlo = Wtab[Q2count]; + delQ2 = (Q2hi - Q2lo); + +// cout << "check this: " << Q2count << " "<< Q2tmp << " " << Q2tab[Q2c] << " "<< Q2tab[Q2c+1] << endl; + + } + + +// do Q2c=1,(ndat-1) +// if( (Q2tmp.ge.Q2tab(Q2c)).and. (Q2tmp.lt.Q2tab(Q2c+1) ) +// 1 .or. Q2tmp.ge.Q2tab(Q2c+1) ) then +// Q2count = Q2c +// Q2hi = Q2tab(Q2count+1) +// Whi = Wtab(Q2count+1) +// Q2lo = Q2tab(Q2count) +// Wlo = Wtab(Q2count) +// delQ2 = (Q2hi - Q2lo) +// endif !Q2 check +// enddo !Q2 + } + } + + + + + ///*--------------------------------------------------*/ + // t-channel + if ( thetacm > pi/2.) { + + sigThi = p1T[Q2count+1] + p2T[Q2count+1]/(tprime+fabs(tmin)); + sigTlo = p1T[Q2count] + p2T[Q2count]/(tprime+fabs(tmin)); + sigLhi = p1L[Q2count+1]; + sigLlo = p1L[Q2count]; + + sigTThi = p1TT[Q2count+1]+p2TT[Q2count+1]/(tprime+fabs(tmin)); + sigTTlo = p1TT[Q2count] +p2TT[Q2count]/(tprime+fabs(tmin)); + sigLThi = p1LT[Q2count+1]+p2LT[Q2count+1]/(tprime+fabs(tmin)); + sigLTlo = p1LT[Q2count] +p2LT[Q2count]/(tprime+fabs(tmin)); + + } else { +// + ///*--------------------------------------------------*/ + // u-channel +// christian weiss recommends the following change for u-channel: +// switch u-slope for t-slope, then divide by 10, since back angle peak +// is ~10% of forward angle peak (at least for omega electroproduction) + + sigThi = (p1T[Q2count+1]+p2T[Q2count+1]/(uprime+fabs(tmin)))/10.; + sigTlo = (p1T[Q2count] +p2T[Q2count]/(uprime+fabs(tmin)))/10. ; + sigLhi = p1L[Q2count+1]/10.; + sigLlo = p1L[Q2count]/10.; + sigTThi = (p1TT[Q2count+1]+p2TT[Q2count+1]/(uprime+fabs(tmin)))/10.; + sigTTlo = (p1TT[Q2count] +p2TT[Q2count]/(uprime+fabs(tmin)))/10.; + sigLThi = (p1LT[Q2count+1]+p2LT[Q2count+1]/(uprime+fabs(tmin)))/10.; + sigLTlo = (p1LT[Q2count] +p2LT[Q2count]/(uprime+fabs(tmin)))/10.; + + } + +// double Wfac_hi= ((Whi**2 - m_p**2)**2) / ((W_gev**2-m_p**2)**2); +// double Wfac_lo= ((Wlo**2 - m_p**2)**2) / ((W_gev**2-m_p**2)**2); + + double Wfac_hi = pow(pow(Whi, 2) - pow(m_p, 2), 2) / pow( pow(W_gev,2)- pow(m_p, 2), 2); + double Wfac_lo = pow(pow(Wlo, 2) - pow(m_p, 2), 2) / pow( pow(W_gev,2)- pow(m_p, 2), 2); + + double sigThiW = sigThi*Wfac_hi; + + if (sigThiW <0) { +// cout << pizero: sigThiW<0 ',sigThiW,uprime, abs(tmin) + sigThiW=0.; + } + + double sigTloW = sigTlo*Wfac_lo; + + if (sigTloW < 0) { +// write(6,*)' pizero: sigTloW<0 ',sigTloW,uprime,abs(tmin) + sigTloW=0.; + } + + double sigLhiW = sigLhi*Wfac_hi; + + if (sigLhiW < 0) { +// write(6,*)' pizero: sigLhiW<0 ',sigLhiW,uprime,abs(tmin) + sigLhiW=0.; + } + + double sigLloW = sigLlo*Wfac_lo; + + if (sigLloW < 0) { +// write(6,*)' pizero: sigLloW<0 ',sigLloW,uprime,abs(tmin) + sigLloW=0.; + } + + double sigTThiW = sigTThi*Wfac_hi; + double sigTTloW; + double sigLThiW; + double sigLTloW; + + double sig, sigL, sigT, sigLT, sigTT; + + if (abs(sigTThiW) < sigThiW) { + sigTThiW=Sign(sigThiW, sigTThiW); + } + sigTTloW = sigTTlo*Wfac_lo; + + if (abs(sigTTloW) < sigTloW) { + sigTTloW = Sign(sigTloW,sigTTloW); + } + sigLThiW = sigLThi*Wfac_hi; + + if (abs(sigLThiW) < sigThiW) { + sigLThiW = Sign(sigThiW,sigLThiW); + } + sigLTloW = sigLTlo*Wfac_lo; + + if (abs(sigLTloW) < sigTloW) { + sigLTloW = Sign(sigTloW,sigLTloW); + } + + /*--------------------------------------------------*/ + + if( Q2count <= (ndat-2) && Q2tmp >= Q2tab[Q2count] && Q2tmp < Q2tab[Q2count+1] ) { + + sigT = ( sigTloW*(Q2hi-Q2tmp) + sigThiW*(Q2tmp-Q2lo))/delQ2; + sigL = ( sigLloW*(Q2hi-Q2tmp) + sigLhiW*(Q2tmp-Q2lo))/delQ2; + sigTT = (sigTTloW*(Q2hi-Q2tmp) + sigTThiW*(Q2tmp-Q2lo))/delQ2; + sigLT = (sigLTloW*(Q2hi-Q2tmp) + sigLThiW*(Q2tmp-Q2lo))/delQ2; + + } else if (Q2tmp >= Q2tab[ndat-1]) { + + sigT = sigThiW + (sigThiW-sigTloW) /delQ2; + sigL = sigLhiW + (sigLhiW-sigLloW) /delQ2; + sigTT = sigTThiW + (sigTThiW-sigTTloW)/delQ2; + sigLT = sigLThiW + (sigLThiW-sigLTloW)/delQ2; + + } else if (Q2tmp <= Q2tab[1] ) { + + sigT = sigTloW - (sigThiW-sigTloW) /delQ2; + sigL = sigLloW - (sigLhiW-sigLloW) /delQ2; + sigTT = sigTTloW - (sigTThiW-sigTTloW)/delQ2; + sigLT = sigLTloW - (sigLThiW-sigLTloW)/delQ2; + + } else { + +// write(6,*)' Q2tmp error ',Q2tmp,Q2count + } +// endif + + + + sig = sigT + eps*sigL +eps*cos(2.*phicm)*sigTT +sqrt(2.*eps*(1.+eps))*cos(phicm)*sigLT; + + double sig_pi0gmh = sig/2./pi*1.e-09; //dsig/dtdphicm in microbarns/MeV^2/rad + + return sig_total; +} + + + + +///*--------------------------------------------------*/ +// Pi0 decay subroutine + +void Pi0_Production::Pi0_decay(TLorentzVector pi0_vec) { + +// TH1D *h1 = new TH1D("h1", "h1", 100, -100, 100); +// TH1D *h2 = new TH1D("h2", "h2", 100, -100, 100); +// TH1D *h3 = new TH1D("h3", "h3", 100, -100, 100); + +// TH2D *photon_2d = new TH2D("photon_2d", "photon_2d", 600, -30, 30, 600, -30, 30); + + TVector3 beta_col_rf_pi0; + + beta_col_rf_pi0 = pi0_vec.BoostVector(); + + Double_t fGamma_Col_pi0_RF = 1.0/sqrt( 1 - pow( beta_col_rf_pi0.Mag() , 2 ) ); + + TLorentzVector l_photon_1_rf; + TLorentzVector l_photon_2_rf; + +// TLorentzVector pi0_vec; + TLorentzVector pi0_vec_rf; + TLorentzVector pi0_vec_rf_g; + + pi0_vec_rf = pi0_vec; + + pi0_vec_rf.Boost(-beta_col_rf_pi0); + pi0_vec_rf_g = pi0_vec_rf * fm; + + double photon_1_E = pi0_vec_rf_g.E()/2; + double photon_2_E = pi0_vec_rf_g.E()/2; + +// double photon_1_theta = rRand->Uniform( 0, 2.0 * fPi ); +// double photon_1_phi = rRand->Uniform( 0 , 2.0 * fPi ); + +// for (int i =0; i<=100000; i++) { + +// double photon_1_theta = fPi/4; + +// double photon_1_theta = fPi/1000 *i; +// double photon_1_phi = fPi/2; + +// double photon_1_theta = rRand->Uniform( 0, fPi ); +// double photon_1_phi = rRand->Uniform( 0, 2.0 * fPi); + + double photon_1_theta = fRandom->Uniform( 0, fPi ); + double photon_1_phi = fRandom->Uniform( 0, 2.0 * fPi); + + double photon_1_Mom_Col = photon_1_E; + double photon_1_MomZ_Col = ( photon_1_Mom_Col * cos(photon_1_theta) ); + double photon_1_MomX_Col = ( photon_1_Mom_Col * sin(photon_1_theta) * cos(photon_1_phi) ); + double photon_1_MomY_Col = ( photon_1_Mom_Col * sin(photon_1_theta) * sin(photon_1_phi) ); + + l_photon_1_rf.SetPxPyPzE( photon_1_MomX_Col, photon_1_MomY_Col, photon_1_MomZ_Col, photon_1_E ); + +// photon_2_theta = photon_1_theta - fPi; +// photon_2_phi = photon_1_phi - fPi; + + l_photon_2_rf.SetPxPyPzE( -photon_1_MomX_Col, -photon_1_MomY_Col, -photon_1_MomZ_Col, photon_1_E ); + + l_photon_1 = l_photon_1_rf; + l_photon_2 = l_photon_2_rf; + + // TVector3 beta_col_rf_pi0; + // beta_col_rf_pi0 = pi0_vec.BoostVector(); + + TVector3 beta_col_rf_pi0_inverse = -pi0_vec.BoostVector(); + + l_photon_1.Boost(beta_col_rf_pi0); + l_photon_2.Boost(beta_col_rf_pi0); + +// cout << "/*--------------------------------------------------*/" << endl; +// cout << "pi0 decay" << endl; +// cout << "pi0 decay" +// cout << "gamma " << fGamma_Col_pi0_RF << " " << pi0_vec.Gamma() << endl; +// cout << "beta " << pi0_vec.Beta()<< endl; +// cout << "pion energy: " << pi0_vec.E() * fm << " " << pi0_vec.P() * fm << " " << l_photon_1_rf.E() << " " << pi0_vec_rf_g.E() << endl; +// cout << "Photon energy 1: " << l_photon_1_rf.E() << " P: " << l_photon_1_rf.P() << " After transformation " << l_photon_1.E() << " " << l_photon_1.P() << endl; +// cout << "Photon energy 2: " << l_photon_2_rf.E() << " P: " << l_photon_2_rf.P() << " After transformation " << l_photon_2.E() << " " << l_photon_2.P() << endl; +// cout << "angle: " << l_photon_1_rf.Vect().Angle(l_photon_2_rf.Vect()) * 180.0/fPi +// << " " << l_photon_1.Vect().Angle(l_photon_2.Vect()) * 180.0/fPi << endl; +// exit(0); + + double photons_1_sep = (tan(l_photon_1.Vect().Angle(pi0_vec.Vect())) * 32)*100; + double photons_2_sep = (tan(l_photon_2.Vect().Angle(pi0_vec.Vect())) * 32)*100; + + double photons_seperation = photons_1_sep + photons_2_sep; + +// cout << "pi0_vec: " << pi0_vec.Vect().Theta() << " " << pi0_vec.Vect().Theta() << endl; +// cout << "Photon 1: " << l_photon_1.Vect().Theta() << " " << l_photon_1.Vect().Phi() << endl; +// cout << "Photon 2: " << l_photon_2.Vect().Theta() << " " << l_photon_2.Vect().Phi() << endl; +// cout << "photon prjecton at 32 meters: " << sin(l_photon_1.Vect().Angle(pi0_vec.Vect())) * 32 +// << " " << sin(l_photon_2.Vect().Angle(pi0_vec.Vect())) * 32 << " " +// << photons_seperation << endl; +// exit(0); + + ///*--------------------------------------------------*/ + /// Max angle formula: sin(theta) = m_pi/(2*E_gamma) + // + // Decay at 7.8m + // 2.6033 ± 0.0005 × 10−8 life time + + /// ZDC is at 30 down stream + // Pi0 drift is 22.2 meters + + // cout << "Maximum angle: " << pi0_vec_rf_g.E() << " " << pi0_vec.E()*fm << " Angle in deg: " << asin(pi0_vec_rf_g.E()/(pi0_vec.E() * fm)) * 180/fPi << endl; + + // 2.6*3 = 7.8m before decay + + TLorentzVector photon_1_diff = l_photon_1 - pi0_vec*fm; + +// cout << "aa" << endl; +// cout << pi0_vec.Px() *fm << " " << pi0_vec.Py() *fm<< " " << pi0_vec.Pz() *fm<< " " << pi0_vec.E() *fm<< endl; +// cout << l_photon_1.Px() << " " << l_photon_1.Py() << " " << l_photon_1.Pz() << " " << l_photon_1.E() << endl; +// cout << photon_1_diff.Px() << " " << photon_1_diff.Py() << " " << photon_1_diff.Pz() << " " << photon_1_diff.E() << endl; + + + double angle = atan(l_photon_1.Px()/l_photon_1.Py()); + +// h1->Fill(photons_seperation); +// h2->Fill(photons_1_sep); +// h3->Fill(-photons_2_sep); + +// cout << photons_1_sep << " " << l_photon_1.Vect().Phi() << " " << photons_2_sep << endl; + +// photon_2d->Fill(photons_1_sep *sin(l_photon_1.Vect().Angle(pi0_vec.Vect())) * cos(l_photon_1.Vect().Phi()), photons_1_sep* sin(l_photon_1.Vect().Angle(pi0_vec.Vect())) *sin(l_photon_1.Vect().Phi()) ); +// photon_2d->Fill(photons_2_sep *cos(l_photon_2.Vect().Phi()), photons_2_sep*sin(l_photon_2.Vect().Phi())); + +//photons_2_sep, l_photon_2.Vect().Phi() + +// cout << l_photon_1.Vect().Phi() << " " << l_photon_2.Vect().Phi() << endl; +// cout <<"check: " << photons_1_sep*sin(angle) << " " << photons_1_sep*cos(angle) << " " << angle << endl; +// photon_2d->Fill(l_photon_1.Vect().Phi(), l_photon_2.Vect().Phi()); +// cout << l_photon_1.Px() << " " << l_photon_1.Py() << endl; +// cout << photon_1.Gamma() << endl; +// cout << l_photon_1.Px()**1.1e-7 << " " << l_photon_1.Py()**1.1e-7 << endl; +// photon_2d->Fill(l_photon_1.Px()/0.134/l_photon_1.Gamma()*1.1e-7, l_photon_1.Py()/0.134/l_photon_1.Gamma()*1.1e-7); +// } + +// TCanvas* c1 = new TCanvas(); +// +// h3->SetFillColor(2); +// h3->SetLineColor(2); +// +// h2->SetFillColor(3); +// h2->SetLineColor(3); +// +// // h1->SetFillColor(4); +// h1->SetLineColor(4); +// +// h1->Draw("hist"); +// h2->Draw("same"); +// h3->Draw("same"); +// +// h1->Draw("same"); +// +// c1->Print("seperation.png"); +// photon_2d->Draw("colz"); +// c1->Print("seperation_aaa.png"); +// cout << "/*--------------------------------------------------*/" << endl; +// exit(0); + + + +} + diff --git a/src/eic_evgen/process_routine/PiPlus_prod.cc b/src/eic_evgen/process_routine/PiPlus_prod.cc new file mode 100644 index 0000000..431f8ee --- /dev/null +++ b/src/eic_evgen/process_routine/PiPlus_prod.cc @@ -0,0 +1,1152 @@ +#include "reaction_rountine.h" +#include "eic.h" + +using namespace std; + +PiPlus_Production::PiPlus_Production() { + + cout << "Program Start" << endl; + +} + +/*--------------------------------------------------*/ +/// PiPlus_Production + + +PiPlus_Production::PiPlus_Production(TString particle_str) { + + rParticle = particle_str; + + // Particle_t g = omega; + // cout << g << " " << ParticleMass(omega) << " " << ParticleEnum("Omega") << " " << ParticleMass(ParticleEnum("Omega")) << endl; + // exit(0); + // + // cout << "Produced particle is: " << GetParticle() << endl; + // cout << "Generated process: e + p -> e' + p' + " << GetParticle() << endl; + // + // tTime.Start(); + // + // cout << "/*--------------------------------------------------*/" << endl; + // cout << "Starting setting up process" << endl; + // cout << endl; + // + // TDatime dsTime; + // cout << "Start Time: " << dsTime.GetHour() << ":" << dsTime.GetMinute() << endl; + +} + +PiPlus_Production::~PiPlus_Production() { + + ppiOut.close(); + ppiDetails.close(); + + // delete rRand; + + // cout << endl; + // cout << "Ending the process" << endl; + // cout << "/*--------------------------------------------------*/" << endl; + // + // tTime.Stop(); + // tTime.Print(); + // + // TDatime deTime; + // cout << "End Time: " << deTime.GetHour() << ":" << deTime.GetMinute() << endl; + +} + +/*--------------------------------------------------*/ +/// + +void PiPlus_Production::process_reaction() { + + Init(); + + PiPlus_Pythia6_Out_Init(); + + + for( long long int i = 0; i < rNEvents; i++ ) { + + rNEvent_itt = i; + fNGenerated ++; + + Progress_Report(); // This is happens at each 10% of the total event is processed + Processing_Event(); + } + + Detail_Output(); + +} + +/*--------------------------------------------------*/ + +void PiPlus_Production::Init() { + + pim* myPim; + + pd = dynamic_cast(myPim); + + rParticle_charge = ExtractCharge(rParticle); + + // rRand = new TRandom2(); + // rRand->SetSeed(fSeed); + + sTFile = Form("./LundFiles/eic_%s.txt", gfile_name.Data()); + sLFile= Form("./LundFiles/eic_input_%s.dat", gfile_name.Data()); + + ppiOut.open( sLFile.c_str() ); + ppiDetails.open( sTFile.c_str() ); + + qsq_ev = 0, t_ev = 0, w_neg_ev = 0, w_ev = 0; + rNEvents = fNEvents; + rNEvent_itt = 0; + + // cout << rNEvents << " " << fNEvents << endl; + + rFermiMomentum = pd->fermiMomentum(); + + // ---------------------------------------------------- + // Proton in collider (lab) frame + + r_lproton = GetProtonVector_lab(); + r_lprotong = GetProtonVector_lab() * fm; + + //cout << "Init check :: " << r_lprotong.E() << endl; + // ---------------------------------------------------- + // Electron in collider (lab) frame + + cout << "Fermi momentum: " << rFermiMomentum << endl; + + r_lelectron = GetElectronVector_lab(); + r_lelectrong = r_lelectron * fm; + + ///*--------------------------------------------------*/ + /// Getting the particle mass from the data base + + produced_X = ParticleEnum(rParticle); + + fX_Mass = ParticleMass(produced_X)*1000; //MeV + fX_Mass_GeV = fX_Mass/1000; //GeV + + cout << rParticle << " " << produced_X << " " << fX_Mass_GeV << endl; + cout << rParticle_charge << endl; + + // exit(0); + + ///*--------------------------------------------------*/ + /// This rParticle_charge is referring to the charge of the preduced meson + + if (rParticle_charge == "+" ) { + rParticle_scat_nucleon = "Neutron"; + recoil_nucleon = Neutron; + f_Scat_Nucleon_Mass = fNeutron_Mass; + f_Scat_Nucleon_Mass_GeV = f_Scat_Nucleon_Mass/1000; + } + else if (rParticle_charge == "0" ) { + rParticle_scat_nucleon = "Proton"; + recoil_nucleon = Proton; + f_Scat_Nucleon_Mass = fProton_Mass; + f_Scat_Nucleon_Mass_GeV = f_Scat_Nucleon_Mass/1000; + } + else { + cerr << "Is the overall charge of the reaction conserved? " << endl; + cerr << "Please double check the input file and processes!" << endl; + cerr << "Exiting the program!" << endl; + exit(0); + } + + // cout << rParticle_scat_nucleon << endl; + // exit(0); + + rDEG2RAD = fPI/180.0; + + fX_Theta_I = 0.0 * rDEG2RAD ; + fX_Theta_F = 50.0 * rDEG2RAD; + + + cout << "Produced particle in exclusive production: " << rParticle << "; with mass: " << fX_Mass << " MeV "<< endl; + cout << fEBeam << " GeV electrons on " << fPBeam << " GeV ions" << endl; + // Depending upon beam energy combination, set the value for the max weight from the non normalised version to then generate unit weights + // The values were determined from a set of 100 x 1B events thrown runs, the weight has to be scaled by the number thrown in the current calculation + // fEventWeight is now independent of the number of events thrown + if ((fEBeam == 5.0 ) && (fPBeam == 41.0) ){ + fEventWeightCeil = 0.0221836 * (1000000000); + } + + else if ((fEBeam == 5.0 ) && (fPBeam == 100.0) ){ + fEventWeightCeil = 0.30281 * (1000000000); + } + + else if ((fEBeam == 10.0 ) && (fPBeam == 100.0) ){ + fEventWeightCeil = 1.77775 * (1000000000); + } + else { + fEventWeightCeil = 1.0 * (100000000); + cout << endl << "!!!!! WARNING !!!!!" << endl; + cout << "Beam energy combination not recognised, weight ceiling set to 1." << endl; + cout << "!!!!! WARNING !!!!!" << endl << endl; + } + + // cout << fPI << " " << fX_Theta_I << " " << fX_Theta_F << endl; + + // exit(0); + +} + +/*--------------------------------------------------*/ + +void PiPlus_Production::Processing_Event() { + + // ---------------------------------------------------- + // Considering Fermi momentum for the proton + // ---------------------------------------------------- + + if( kCalcFermi ) { + Consider_Proton_Fermi_Momentum(); + + } + + // ---------------------------------------------------- + // Boost vector from collider (lab) frame to protons rest frame (Fix target) + // ---------------------------------------------------- + + beta_col_rf = r_lproton.BoostVector(); + fGamma_Col_RF = 1.0/sqrt( 1 - pow( beta_col_rf.Mag() , 2 ) ); + + // --------------------------------------------------------------------- + // Specify the energy and solid angle of scatterd electron in Collider (lab) frame + // --------------------------------------------------------------------- + fScatElec_Theta_Col = acos( fRandom->Uniform( cos( fScatElec_Theta_I ) , cos( fScatElec_Theta_F ) ) ); + fScatElec_Phi_Col = fRandom->Uniform( 0 , 2.0 * fPi); + fScatElec_Energy_Col = fRandom->Uniform( fScatElec_E_Lo * fElectron_Energy_Col , fScatElec_E_Hi * fElectron_Energy_Col ); + + // ---------------------------------------------------- + // Produced Particle X in Collider frame + // ---------------------------------------------------- + + + /// The generic produced particle in the exclusive reaction is labelled as X + fX_Theta_Col = acos( fRandom->Uniform( cos(fX_Theta_I), cos(fX_Theta_F ) ) ); + fX_Phi_Col = fRandom->Uniform( 0 , 2.0 * fPi ); + + // fScatElec_Theta_Col = 2.42585; + // fScatElec_Phi_Col = 1.73913; + // fScatElec_Energy_Col = 5473.08; + // + // fX_Theta_Col = 0.232649; + // fX_Phi_Col = 4.68068; + + // cout << fScatElec_Theta_Col << " " << fScatElec_Phi_Col << " " << fScatElec_Energy_Col << " " << fX_Theta_Col << " " << fX_Phi_Col << endl; + + // exit(0); + + // --------------------------------------------------------------------- + // Specify the energy and solid angle of scatterd electron in Collider (lab) frame + // --------------------------------------------------------------------- + + fScatElec_Mom_Col = sqrt( pow( fScatElec_Energy_Col,2) - pow( fElectron_Mass , 2) ); + fScatElec_MomZ_Col = ( fScatElec_Mom_Col * cos(fScatElec_Theta_Col) ); + fScatElec_MomX_Col = ( fScatElec_Mom_Col * sin(fScatElec_Theta_Col) * cos(fScatElec_Phi_Col) ); + fScatElec_MomY_Col = ( fScatElec_Mom_Col * sin(fScatElec_Theta_Col) * sin(fScatElec_Phi_Col) ); + + r_lscatelec.SetPxPyPzE( fScatElec_MomX_Col, fScatElec_MomY_Col, fScatElec_MomZ_Col, fScatElec_Energy_Col); + + r_lscatelecg = r_lscatelec * fm; + + // ---------------------------------------------------- + // Photon in collider (lab) frame and Qsq + // ---------------------------------------------------- + + r_lphoton = r_lelectron - r_lscatelec; + r_lphotong = r_lelectrong - r_lscatelecg; + + // cout << "Check check : " << endl; + // + // cout << r_lphoton.Px() << " " << r_lphoton.Py() << " " << r_lphoton.Pz() << " " << r_lphoton.E() << endl; + // cout << r_lelectron.Px() << " " << r_lelectron.Py() << " " << r_lelectron.Pz() << " " << r_lelectron.E() << endl; + // cout << r_lscatelec.Px() << " " << r_lscatelec.Py() << " " << r_lscatelec.Pz() << " " << r_lscatelec.E() << endl; + + // exit(0); + + fQsq_GeV = -1.* r_lphotong.Mag2(); + + if ( fQsq_GeV < 5.0 ) { + qsq_ev++; + return; + } + + // ---------------------------------------------------- + // W square, Invariant Mass (P_g + P_p)^2 + // ---------------------------------------------------- + + TLorentzVector lwg; + lwg = r_lprotong + r_lphotong; + fW_GeV = lwg.Mag(); + fWSq_GeV = lwg.Mag2(); + + // cout << r_lprotong.Px() << " " << r_lprotong.Py() << " " << r_lprotong.Pz() << " " << r_lprotong.E() << endl; + // cout << r_lphotong.Px() << " " << r_lphotong.Py() << " " << r_lphotong.Pz() << " " << r_lphotong.E() << endl; + // cout << fQsq_GeV << " " << fW_GeV << " "<< fWSq_GeV << endl; + + // cout << "Here????? " << endl; + + if ( fWSq_GeV < 0 ) { + w_neg_ev++; + return; + } + + // --------------------------------------------------------- + // Pion momentum in collider frame, analytic solution starts + // --------------------------------------------------------- + + double fupx = sin( fX_Theta_Col ) * cos( fX_Phi_Col ); + double fupy = sin( fX_Theta_Col ) * sin( fX_Phi_Col ); + double fupz = cos( fX_Theta_Col ); + + double fuqx = sin( r_lphoton.Theta() ) * cos( r_lphoton.Phi() ); + double fuqy = sin( r_lphoton.Theta() ) * sin( r_lphoton.Phi() ); + double fuqz = cos( r_lphoton.Theta() ); + + double fa = -(r_lphoton.Vect()).Mag() * ( fupx * fuqx + fupy * fuqy + fupz * fuqz ); + double fb = pow ( (r_lphoton.Vect()).Mag() , 2 ); + double fc = r_lphoton.E() + fProton_Mass; + + // cout.precision(10); + // cout << r_lphoton.Vect().X() << " " << r_lphoton.Vect().Y() << " " << r_lphoton.Vect().Z() << endl; + // cout << "AAAAAAAAAAABBBBBBBCCCCCCCCC " << fa << " " << fb << " " << fc << endl; + + fa = ( fa - std::abs( (r_lproton.Vect()).Mag() ) * ( ( ( r_lproton.X() / (r_lproton.Vect()).Mag() ) * fupx ) + + ( ( r_lproton.Y() / (r_lproton.Vect()).Mag() ) * fupy ) + + ( ( r_lproton.Z() / (r_lproton.Vect()).Mag() ) * fupz ) ) ); + + double factor = ( pow( (r_lproton.Vect()).Mag() , 2 ) + 2.0 * (r_lphoton.Vect()).Mag() * (r_lproton.Vect()).Mag() * + ( ( ( r_lproton.X() / (r_lproton.Vect()).Mag() ) * fuqx ) + + ( ( r_lproton.Y() / (r_lproton.Vect()).Mag() ) * fuqy ) + + ( ( r_lproton.Z() / (r_lproton.Vect()).Mag() ) * fuqz ) ) ); + + fb = fb + factor; + fc = r_lphoton.E() + r_lproton.E(); + + // double ft = fc * fc - fb + fPion_Mass * fPion_Mass - fProton_Mass * fProton_Mass; + double ft = fc * fc - fb + fX_Mass * fX_Mass - fProton_Mass * fProton_Mass; + + // cout << r_lprotong.Px() << " " << r_lprotong.Py() << " " << r_lprotong.Pz() << " " << r_lprotong.E() << endl; + // cout << lproton_rfg.Px() << " " << lproton_rfg.Py() << " " << lproton_rfg.Pz() << " " << lproton_rfg.E() << endl; + // cout << beta_col_rf.Px() << " " << beta_col_rf.Py() << " " << beta_col_rf.Pz() << endl; + + //exit(0); + + double fQA = 4.0 * ( fa * fa - fc * fc ); + double fQB = 4.0 * fc * ft; + + // double fQC = -4.0 * fa * fa * fPion_Mass * fPion_Mass - ft * ft; + double fQC = -4.0 * fa * fa * fX_Mass * fX_Mass - ft * ft; + + fradical = fQB * fQB - 4.0 * fQA * fQC; + + fepi1 = ( -fQB - sqrt( fradical ) ) / ( 2.0 * fQA ); + fepi2 = ( -fQB + sqrt( fradical ) ) / ( 2.0 * fQA ); + + // cout << fc*fc << " " << 99531.3*99531.3 << endl; + // cout << fb << " " << 9.83386e+09 << endl; + // cout << fc*fc - fb << " " << 99531.3*99531.3 - 9.83386e+09 << endl; + + // exit(0); + + // cout << "abc: " << fa << " " << fb << " " << fc << " " << ft << " " << fX_Mass << " " << fProton_Mass << endl; + // cout << "epi: " << fQB << " " << fradical << " " << fQA << endl; + // cout << factor << " " << fepi1 << " " << fepi2 << endl; + // cout << "X diagnose: " << fPion_Mass << " " << fepi1 << " " << fX_Theta_Col << " " << fX_Phi_Col << endl; + // fPion_Mom_Same = 0; + // if ( std::abs(fepi1 - fepi2) < fDiff ){ fPion_Mom_Same = 1; } + + // --------------------------------------------------------- + // Particle X momentum in collider frame, analytic solution ends + // --------------------------------------------------------- + + r_lX.SetPxPyPzE( (sqrt( pow( fepi1 , 2) - pow(fX_Mass , 2) ) ) * sin(fX_Theta_Col) * cos(fX_Phi_Col), + ( sqrt( pow( fepi1 , 2) - pow(fX_Mass , 2) ) ) * sin(fX_Theta_Col) * sin(fX_Phi_Col), + ( sqrt( pow( fepi1 , 2) - pow(fX_Mass , 2) ) ) * cos(fX_Theta_Col), + fepi1 ); + + r_lX_g = r_lX * fm; + + // ---------------------------------------------------- + // Scattered proton collider (lab) frame + + r_l_scat_nucleon.SetPxPyPzE( ( r_lproton + r_lelectron - r_lscatelec - r_lX).X(), + ( r_lproton + r_lelectron - r_lscatelec - r_lX ).Y(), + ( r_lproton + r_lelectron - r_lscatelec - r_lX ).Z(), + sqrt( pow( ( ( ( r_lproton + r_lelectron - r_lscatelec - r_lX ).Vect() ).Mag()),2) + + pow( f_Scat_Nucleon_Mass ,2 ) ) ); + + r_l_scat_nucleon_g = r_l_scat_nucleon * fm; + + // ---------------------------------------------------------------------------------------------- + // ---------------------------------------------------------------------------------------------- + // Calculate w = (proton + photon)^2 + // ---------------------------------------------------------------------------------------------- + // ---------------------------------------------------------------------------------------------- + + // cout << fW_GeV << endl; + if ( fW_GeV < 3.0 || fW_GeV > 10.6 ) { + w_ev++; + return; + } + + r_lw = r_lproton + r_lphoton; + fW = r_lw.Mag(); + + // ---------------------------------------------------------------------------------------------- + // ---------------------------------------------------------------------------------------------- + // Calculate w prime w' = (proton + photon - pion)^2 + // ---------------------------------------------------------------------------------------------- + // ---------------------------------------------------------------------------------------------- + + lwp = r_lprotong + r_lphotong - r_lX_g; + fW_Prime_GeV = lwp.Mag(); + + fsini = r_lelectron + r_lproton; + fsfin = r_lscatelec + r_lX + r_l_scat_nucleon; + + fsinig = fsini * fm; + fsfing = fsfin * fm; + + fMandSConserve = std::abs( fsinig.Mag() - fsfing.Mag() ); + + // cout << fW_GeV << " " << fsinig.Mag() << " " << fsfing.Mag() << " " << fMandSConserve << endl; + // + // cout << "E: " << r_lscatelec.Px() << " " << r_lscatelec.Py() << " " << r_lscatelec.Pz() << " " << r_lscatelec.E() << endl; + // cout << "X: " << r_lX.Px() << " " << r_lX.Py() << " " << r_lX.Pz() << " " << r_lX.E() << endl; + // cout << "N: " << r_l_scat_nucleon.Px() << " " << r_l_scat_nucleon.Py() << " " << r_l_scat_nucleon.Pz() << " " << r_l_scat_nucleon.E() << endl; + + kSConserve = false; + if( std::abs( fsinig.Mag() - fsfing.Mag() ) < fDiff ) { + kSConserve = true; + } + + if ( pd->CheckLaws( r_lelectron, r_lproton, r_lscatelec, r_lX, r_l_scat_nucleon) != 1 ) + return; + + //////////////////////////////////////////////////////////////////////////////////////////// + // Start // + // Transformation of e', pi- and recoil proton to target's rest frmae without energy loss // + //////////////////////////////////////////////////////////////////////////////////////////// + + lproton_rf = r_lproton; + lproton_rf.Boost(-beta_col_rf); + lproton_rfg = lproton_rf * fm; + + lelectron_rf = r_lelectron; + lelectron_rf.Boost(-beta_col_rf); + lelectron_rfg = lelectron_rf * fm; + + lscatelec_rf = r_lscatelec; + lscatelec_rf.Boost(-beta_col_rf); + lscatelec_rfg = lscatelec_rf * fm; + + lphoton_rf = r_lphoton; + lphoton_rf.Boost(-beta_col_rf); + lphoton_rfg = lphoton_rf * fm; + + lX_rf = r_lX; + lX_rf.Boost(-beta_col_rf); + lX_rfg = lX_rf * fm; + + l_scat_nucleon_rf = r_l_scat_nucleon; + l_scat_nucleon_rf.Boost(-beta_col_rf); + l_scat_nucleon_rf_g = l_scat_nucleon_rf * fm; + + //////////////////////////////////////////////////////////////////////////////////////////// + // End // + // Transformation of e', pi- and recoil proton to target's rest frmae without energy loss // + //////////////////////////////////////////////////////////////////////////////////////////// + + + // ----------------------------------------------------------------------------------------- + // ----------------------------------------------------------------------------------------- + // Calculate -t + // ----------------------------------------------------------------------------------------- + // ----------------------------------------------------------------------------------------- + + fBeta_CM_RF = (lphoton_rf.Vect()).Mag() / ( lphoton_rf.E() + fProton_Mass ); + fGamma_CM_RF = ( lphoton_rf.E() + fProton_Mass ) / fW; + fX_Energy_CM = ( pow( fW , 2) + pow(fX_Mass , 2) - pow(f_Scat_Nucleon_Mass , 2) ) / ( 2.0 * fW); + fX_Mom_CM = sqrt( pow(fX_Energy_CM , 2) - pow(fX_Mass , 2)); + fX_Energy_CM_GeV = fX_Energy_CM / 1000.0; + fX_Mom_CM_GeV = fX_Mom_CM / 1000.0; + + // this equation is valid for parallel kinematics only! + fT_Para = ( pow(((r_lphoton.Vect()).Mag() - (r_lX.Vect()).Mag()),2) - pow((r_lphoton.E() - r_lX.E()),2)); + fT_Para_GeV = fT_Para/1000000.0; + + lt = r_lphoton - r_lX; + ltg = lt * fm; + + fT = -1.*lt.Mag2(); + fT_GeV = -1.*ltg.Mag2(); + + if ( gKinematics_type == 1 && fT_GeV > 0.5 ) { + t_ev++; + return; + } + + if ( gKinematics_type == 2 && fT_GeV > 1.3 ) { + t_ev++; + return; + } + + // cout << fT_GeV << endl; + + // exit(0); + + fx = fQsq_GeV / ( 2.0 * r_lprotong.Dot( r_lphotong ) ); + fy = r_lprotong.Dot( r_lphotong ) / r_lprotong.Dot( r_lelectrong ); + fz = r_lX.E()/r_lphoton.E(); + + // ------------------------------------------------------------------------------------------------------- + // Calculation of Phi ( azimuthal angle of pion momentum w.r.t lepton plane in target's rest frame) + // Calculation of PhiS ( azimuthal angle of target polarization w.r.t lepton plane in target's rest frame) + // ------------------------------------------------------------------------------------------------------- + + v3Photon.SetX( lphoton_rfg.X() ); + v3Photon.SetY( lphoton_rfg.Y() ); + v3Photon.SetZ( lphoton_rfg.Z() ); + + v3Electron.SetX( lelectron_rfg.X() ); + v3Electron.SetY( lelectron_rfg.Y() ); + v3Electron.SetZ( lelectron_rfg.Z() ); + + v3X.SetX( lX_rfg.X() ) ; + v3X.SetY( lX_rfg.Y() ) ; + v3X.SetZ( lX_rfg.Z() ); + + v3S.SetX( -1 ); + v3S.SetY( 0 ); + v3S.SetZ( 0 ); + + v3PhotonUnit = v3Photon.Unit(); + v3QxL = v3Photon.Cross(v3Electron); + v3QxP = v3Photon.Cross(v3X); + v3QxS = v3Photon.Cross(v3S); + v3LxP = v3Electron.Cross(v3X); + v3LxS = v3Electron.Cross(v3S); + v3PxL = v3X.Cross(v3Electron); + v3QUnitxL = v3PhotonUnit.Cross(v3Electron); + v3QUnitxP = v3PhotonUnit.Cross(v3X); + v3QUnitxS = v3PhotonUnit.Cross(v3S); + + /*--------------------------------------------------*/ + // Get the Phi scattering angle with respect to the electron scattering plane + fPhi = Get_Phi_X_LeptonPlane_RF (); + + /*--------------------------------------------------*/ + // Get the Phi scattering angle with respect to the electron scattering plane + fPhiS = Get_Phi_TargPol_LeptonPlane_RF(); + + fTheta_X_Photon_RF = fRAD2DEG * acos( ( v3Photon.Dot( v3X ) ) / ( v3Photon.Mag() * v3X.Mag() ) ); + if ( fTheta_X_Photon_RF < 0 ) { fTheta_X_Photon_RF = 180.0 + fTheta_X_Photon_RF; } + + // ----------------------------------------------------------------------------------- + // If we have fermi momentum then epsilon should be in rest frame + // The theta angle of scattered angle used in expression of epsilon is the angle + // with respect to direction of incoming electron in the rest frame of target nucleon + // epsilon=1./(1.+ 2.*(pgam_restg**2)/q2g * *(tand(thscat_rest/2.))**2) + // ----------------------------------------------------------------------------------- + + double fTheta_EEp = (lelectron_rf.Vect()).Angle(lscatelec_rf.Vect()); + + fEpsilon = 1.0 / ( 1.0 + 2.0 * ( pow( (lphoton_rfg.Vect()).Mag(),2)/fQsq_GeV ) * pow( tan( fTheta_EEp / 2 ) , 2 ) ); + + // ---------------------------------------------------- + // Virtual Photon flux factor in units of 1/(GeV*Sr) + // ---------------------------------------------------- + fFlux_Factor_Col = (fAlpha/(2.0*pow(fPi,2))) * (r_lscatelecg.E() / r_lelectrong.E()) * + ( pow(fW_GeV,2) - pow(fProton_Mass_GeV,2) ) / (2.0*fProton_Mass_GeV*fQsq_GeV*(1.0 - fEpsilon)); + + fFlux_Factor_RF = ( fAlpha / ( 2.0 * pow( fPi , 2 ) ) ) * ( lscatelec_rfg.E() / lelectron_rfg.E() ) * + ( pow( fW_GeV , 2 ) - pow( fProton_Mass_GeV , 2 ) ) / + ( 2.0 * fProton_Mass_GeV * fQsq_GeV * ( 1.0 - fEpsilon ) ); + + // ---------------------------------------------------- + // Jacobian dt/dcos(theta*)dphi in units of GeV2/sr + // ---------------------------------------------------- + fJacobian_CM = ( (lphoton_rfg.Vect()).Mag() - fBeta_CM_RF * lphoton_rfg.E() ) / ( fGamma_CM_RF * ( 1.0 - pow(fBeta_CM_RF,2) ) ); + + fA = fJacobian_CM * fX_Mom_CM_GeV / fPi; + + // ---------------------------------------------------- + // Jacobian dOmega* / dOmega dimensionless + // ---------------------------------------------------- + fJacobian_CM_RF = ( pow((lX_rf.Vect()).Mag(),2)*fW) / + ( fX_Mom_CM * std::abs( ( fProton_Mass + lphoton_rf.E()) * (lX_rf.Vect()).Mag() - + ( lX_rf.E() * (lphoton_rf.Vect()).Mag() * cos( lX_rf.Theta() ) ) ) ); + + fJacobian_CM_Col = ( ( pow((r_lX.Vect()).Mag(),2) * fW ) / + ( fX_Mom_CM * std::abs( ( fProton_Mass + r_lphoton.E() ) * (r_lX.Vect()).Mag() - + ( r_lX.E() * (r_lphoton.Vect()).Mag() * cos( r_lX.Theta() ) ) ) ) ); + + + // cout << lX_rf.Vect().Mag() << " " << << << << << << << << endl; + // cout << fJacobian_CM_RF << " " << fJacobian_CM_Col << endl; + + // ----------------------------------------------------------------------------------------------------------- + // CKY sigma L and T starts + // ----------------------------------------------------------------------------------------------------------- + + // r_fSig_T = 1; + // r_fSig_L = 1; + // + // ------------------------------------------------------------------------------------------- + + r_fSig = Get_Total_Cross_Section(); + + // ----------------------------------------------------------------------------------------------------------- + // CKY sigma L and T ends + // ----------------------------------------------------------------------------------------------------------- + + fSigma_Col = r_fSig * fFlux_Factor_Col * fA * fJacobian_CM_Col; + + if ( ( fSigma_Col <= 0 ) || std::isnan( fSigma_Col ) ) { + fNSigmaNeg ++; + return; + } + + // ----------------------------------------------------------------------------------------------------------- + // ----------------------------------------------------------------------------------------------------------- + // Lab cross section Phase Space Conversion Luminosity Total events tried + // Hz = ub / ( sr^2 * GeV ) * GeV * sr^2 * ( cm^2 / ub ) * ( # / ( cm^2 * sec ) ) / ( # ) + + // SJDK 11/05/21 - This is the previous non unit weight + // fEventWeight = fSigma_Col * fPSF * fuBcm2 * fLumi / fNEvents; // in Hz + // SJDK 11/05/21 - New weight calculation, division by ceiling weight value to attempt to get a "unit" value + fEventWeight = abs(fSigma_Col * fPSF * fuBcm2 * fLumi )/fEventWeightCeil; + if ( (fEventWeight > 1) || (fEventWeight <= 0) ){ + fNWeightUnphys ++; + return; + } + fEventWeightRn = fRandom->Uniform( 0, 1.0); + if ( fEventWeight > fEventWeightRn ){ + fNWeightReject ++; + return; + } + fNRecorded ++; + fLundRecorded++; + fRatio = fNRecorded / fNGenerated; + + // Lund_Output(); + + PiPlus_Pythia6_Output(); + + +} + +/*--------------------------------------------------*/ + +void PiPlus_Production::Progress_Report() { + + dFractTime = time(0); + + if ( rNEvent_itt % ( rNEvents / 10 ) == 0 ) { + cout << "Event: " << setw(8) << rNEvent_itt + << " % of events " << setw(4) << ((1.0*rNEvent_itt)/(1.0*rNEvents))*100.0 + << " Day: " << dFractTime.GetDay() + << " Time: " << dFractTime.GetHour() + << ":" << dFractTime.GetMinute() + << ":" << dFractTime.GetSecond() + << endl; + } +} + +/*--------------------------------------------------*/ + +TLorentzVector PiPlus_Production::GetProtonVector_lab() { + + // Crossing angle + // fProton_Theta_Col = 0.050; + // fProton_Theta_Col = 0.025; + // Set crossing angle to 0 for fun4all + fProton_Theta_Col = 0.0; + + ///*--------------------------------------------------*/ + /// The + // fProton_Phi_Col = fPi; + fProton_Phi_Col = fProton_incidence_phi; + + fProton_Mom_Col = fPBeam * 1e3; + fVertex_X = 0.; + fVertex_Y = 0.; + fVertex_Z = 0.; + + + TLorentzVector lproton( fProton_Mom_Col * sin(fProton_Theta_Col) * cos(fProton_Phi_Col), + fProton_Mom_Col * sin(fProton_Theta_Col) * sin(fProton_Phi_Col), + fProton_Mom_Col * cos(fProton_Theta_Col), + sqrt( pow( fProton_Mom_Col , 2 ) + pow( fProton_Mass , 2 ) ) ); + + // cout << lproton.X() << " " << lproton.Y() << " " << lproton.Z() << endl; + // exit(0); + + return lproton; + +} + +/*--------------------------------------------------*/ + +//*--------------------------------------------------*/ +// Proton in collider (lab) frame +// ---------------------------------------------------- + +void PiPlus_Production::Consider_Proton_Fermi_Momentum() { + + fProton_Mom_Col = fProton_Mom_Col + rFermiMomentum; + fProton_Theta_Col = acos( fRandom->Uniform( cos(0.0) , cos(fPi) ) ); + fProton_Phi_Col = fRandom->Uniform( 0 , 360 ); + + double px, py, pz, e; + + px = fProton_Mom_Col * sin(fProton_Theta_Col) * cos(fProton_Phi_Col); + py = fProton_Mom_Col * sin(fProton_Theta_Col) * sin(fProton_Phi_Col); + pz = fProton_Mom_Col * cos(fProton_Theta_Col); + e = sqrt( pow( fProton_Mom_Col , 2 ) + pow( fProton_Mass , 2 ) ); + + r_lproton.SetPxPyPzE(px,py,pz,e); + + r_lprotong = r_lproton*fm; + +} + +/*--------------------------------------------------*/ + +// ---------------------------------------------------- +// Electron in collider (lab) frame +// ---------------------------------------------------- + +TLorentzVector PiPlus_Production::GetElectronVector_lab() { + + fElectron_Energy_Col = fElectron_Kin_Col; + fElectron_Mom_Col = sqrt( pow(fElectron_Energy_Col , 2) - pow(fElectron_Mass , 2) ); + fElectron_Theta_Col = fPi; + fElectron_Phi_Col = 0.0; + fElectron_MomZ_Col = fElectron_Mom_Col * cos(fElectron_Theta_Col); + fElectron_MomX_Col = fElectron_Mom_Col * sin(fElectron_Theta_Col) * cos(fElectron_Phi_Col); + fElectron_MomY_Col = fElectron_Mom_Col * sin(fElectron_Theta_Col) * sin(fElectron_Phi_Col); + + cout << "Define: " << fElectron_MomZ_Col << " "<< fElectron_Mom_Col << " " << cos(fElectron_Theta_Col) << endl; + + TLorentzVector lelectron( fElectron_MomX_Col, fElectron_MomY_Col, fElectron_MomZ_Col, fElectron_Energy_Col); + + return lelectron; + +} + +////*-------------------------------------------------- +/// Outputing to LUND file + +void PiPlus_Production::Lund_Output() { + + ppiOut << "3" + << " \t " << fPhi // var 1 + << " \t " << fPhiS // var 2 + << " \t " << fx // var 3 + << " \t " << "1" + << " \t " << fQsq_GeV // var 4 + << " \t " << fT_GeV // var 5 + << " \t " << fW_GeV // var 6 + << " \t " << fEpsilon // var 7 + << " \t " << fEventWeight // var 8 + << endl; + + // Produced Particle X + ppiOut << setw(10) << "1" + << setw(10) << "1" + << setw(10) << "1" + // << setw(10) << "11111111111" + << setw(10) << PDGtype(produced_X) + << setw(10) << "0" + << setw(10) << "0" + << setw(16) << r_lX_g.X() + << setw(16) << r_lX_g.Y() + << setw(16) << r_lX_g.Z() + << setw(16) << r_lX_g.E() + << setw(16) << fX_Mass_GeV + << setw(16) << fVertex_X + << setw(16) << fVertex_Y + << setw(16) << fVertex_Z + << endl; + + // Scattered electron + ppiOut << setw(10) << "2" + << setw(10) << "-1" + << setw(10) << "1" + << setw(10) << "11" + << setw(10) << "0" + << setw(10) << "0" + << setw(16) << r_lscatelecg.X() + << setw(16) << r_lscatelecg.Y() + << setw(16) << r_lscatelecg.Z() + << setw(16) << r_lscatelecg.E() + << setw(16) << fElectron_Mass_GeV + << setw(16) << fVertex_X + << setw(16) << fVertex_Y + << setw(16) << fVertex_Z + << endl; + + // Recoiled neutron + ppiOut << setw(10) << "3" + << setw(10) << "1" + << setw(10) << "1" + << setw(10) << PDGtype(recoil_nucleon) + << setw(10) << "0" + << setw(10) << "0" + << setw(16) << r_l_scat_nucleon_g.X() + << setw(16) << r_l_scat_nucleon_g.Y() + << setw(16) << r_l_scat_nucleon_g.Z() + << setw(16) << r_l_scat_nucleon_g.E() + << setw(16) << f_Scat_Nucleon_Mass_GeV + << setw(16) << fVertex_X + << setw(16) << fVertex_Y + << setw(16) << fVertex_Z + << endl; +} + +/*--------------------------------------------------*/ +/// Output generator detail + +void PiPlus_Production::Detail_Output() { + + ppiDetails << "Total events tried " << setw(20) << fNGenerated << endl; + ppiDetails << "Total events recorded " << setw(20) << fNRecorded << endl; + ppiDetails << "Max weight value " << setw(20) << fEventWeightCeil << endl; + + ppiDetails << "Number of events with w more than 10.6 " << setw(20) << w_ev << endl; + ppiDetails << "Number of events with wsq negative " << setw(20) << w_neg_ev << endl; + ppiDetails << "Number of events with qsq less than 5 " << setw(20) << qsq_ev << endl; + ppiDetails << "Number of events with -t more than threshold " << setw(20) << t_ev << endl; + ppiDetails << "Number of events with unit weight outside of 0 to 1 " << setw(20) << fNWeightUnphys << endl; + ppiDetails << "Number of events with unit weight greater than random number " << setw(20) << fNWeightReject << endl; + + ppiDetails << "Number of events with w less than threshold " << setw(20) << fWSqNeg << endl; + ppiDetails << "Number of events with mom not conserve " << setw(20) << fNMomConserve << endl; + ppiDetails << "Number of events with Sigma negative " << setw(20) << fNSigmaNeg << endl; + ppiDetails << "Number of lund events " << setw(20) << fLundRecorded << endl; + + ppiDetails << "Seed used for the Random Number Generator " << setw(20) << fSeed << endl; + +} + +/*--------------------------------------------------*/ + +Double_t PiPlus_Production::Get_Phi_X_LeptonPlane_RF () { + + fCos_Phi_X_LeptonPlane_RF = ( ( v3QUnitxL.Dot( v3QUnitxP ) ) / ( v3QUnitxL.Mag() * v3QUnitxP.Mag() ) ); // hep-ph/0410050v2 + fSin_Phi_X_LeptonPlane_RF = ( ( v3LxP.Dot( v3PhotonUnit ) ) / ( v3QUnitxL.Mag() * v3QUnitxP.Mag() ) ); // hep-ph/0410050v2 + if ( fSin_Phi_X_LeptonPlane_RF >= 0 ) + fPhi_X_LeptonPlane_RF = fRAD2DEG * acos( ( v3QUnitxL.Dot( v3QUnitxP ) ) / ( v3QUnitxL.Mag() * v3QUnitxP.Mag() ) ); + if ( fSin_Phi_X_LeptonPlane_RF < 0 ) + fPhi_X_LeptonPlane_RF = 360.0 - std::abs( fRAD2DEG * acos( ( v3QUnitxL.Dot( v3QUnitxP ) ) / ( v3QUnitxL.Mag() * v3QUnitxP.Mag() ) ) ); + + return fPhi_X_LeptonPlane_RF; + +} + +/*--------------------------------------------------*/ + +Double_t PiPlus_Production::Get_Phi_TargPol_LeptonPlane_RF () { + + fCos_Phi_TargPol_LeptonPlane_RF = ( ( v3QUnitxL.Dot( v3QUnitxS ) ) / ( v3QUnitxL.Mag() * v3QUnitxS.Mag() ) ); // hep-ph/0410050v2 + fSin_Phi_TargPol_LeptonPlane_RF = ( ( v3LxS.Dot( v3PhotonUnit ) ) / ( v3QUnitxL.Mag() * v3QUnitxS.Mag() ) ); // hep-ph/0410050v2 + if ( fSin_Phi_TargPol_LeptonPlane_RF >= 0 ) + fPhi_TargPol_LeptonPlane_RF = fRAD2DEG * acos( ( v3QUnitxL.Dot( v3QUnitxS ) ) / ( v3QUnitxL.Mag() * v3QUnitxS.Mag() ) ); + if ( fSin_Phi_TargPol_LeptonPlane_RF < 0 ) + fPhi_TargPol_LeptonPlane_RF = 360.0 - std::abs( fRAD2DEG * acos( ( v3QUnitxL.Dot( v3QUnitxS ) ) / ( v3QUnitxL.Mag() * v3QUnitxS.Mag() ) ) ); + + return fPhi_TargPol_LeptonPlane_RF; + +} + +/*--------------------------------------------------*/ + +Double_t PiPlus_Production::Get_Total_Cross_Section() { + + Double_t total_sig; + + Particle_t p = ParticleEnum(rParticle); + + switch (p) { + + case Pi0: total_sig = GetPi0_CrossSection(); + case PiPlus: total_sig = GetPiPlus_CrossSection(); + // case Omega: total_sig = ...; + + } + + return total_sig; + +} + +/*--------------------------------------------------*/ + +Double_t PiPlus_Production::GetPi0_CrossSection() { + + double_t sig_total; + return sig_total; + +} + +/*--------------------------------------------------*/ +/// Charged Pi+ moduel: +/// Author: Z. Ahmed +/// Date: 2017 + + +Double_t PiPlus_Production::GetPiPlus_CrossSection(){ + + double_t sig_total; + + // -------------------------------------------------------------------------------------------------- + // CKY sigma L and T starts + // -------------------------------------------------------------------------------------------------- + double lpar0 = 0., lpar1 = 0., lpar2 = 0., lpar3 = 0., lpar4 = 0., lpar5 = 0., lpar6 = 0.; + double tpar0 = 0., tpar1 = 0., tpar2 = 0., tpar3 = 0., tpar4 = 0.; + + + lpar0 = 0.; lpar1 = 0.; lpar2 = 0.; lpar3 = 0.; lpar4 = 0.; lpar5 = 0.; lpar6 = 0.; + tpar0 = 0.; tpar1 = 0.; tpar2 = 0.; tpar3 = 0.; tpar4 = 0.; + + fSig_L = 0; + fSig_T = 0; + + if ( ( fT_GeV > 0. ) && ( fT_GeV < 0.15 ) ) { + eicSigmaL( fW_GeV, fQsq_GeV, lpar0, lpar1, lpar2 , lpar3 , lpar4 , lpar5 , lpar6 ); + TF1 *fitCKYLonglandau = new TF1("sigmaL","landau", 0.0 , 0.15 ); + fitCKYLonglandau->FixParameter( 0 , lpar0 ); + fitCKYLonglandau->FixParameter( 1 , lpar1 ); + fitCKYLonglandau->FixParameter( 2 , lpar2 ); + fSig_L = fitCKYLonglandau->Eval(fT_GeV); + if ( lpar0 == 0 || lpar1 == 0 || lpar2 == 0 ) + fSig_L = 0; + fitCKYLonglandau = NULL; + delete fitCKYLonglandau; + } + else if ( ( fT_GeV > 0.15 ) && ( fT_GeV < 0.5 ) ) { + eicSigmaL( fW_GeV, fQsq_GeV, lpar0, lpar1, lpar2 , lpar3 , lpar4 , lpar5 , lpar6 ); + TF1 *fitCKYLongexpo1 = new TF1("sigmaL","expo", 0.15 , 0.5 ); + fitCKYLongexpo1->FixParameter( 0 , lpar3 ); + fitCKYLongexpo1->FixParameter( 1 , lpar4 ); + fSig_L = fitCKYLongexpo1->Eval(fT_GeV); + if ( lpar3 == 0 || lpar4 == 0 ) + fSig_L = 0; + fitCKYLongexpo1 = NULL; + delete fitCKYLongexpo1; + } + else if ( ( fT_GeV > 0.5 ) && ( fT_GeV < 1.3 ) ) { + eicSigmaL( fW_GeV, fQsq_GeV, lpar0, lpar1, lpar2 , lpar3 , lpar4 , lpar5 , lpar6 ); + TF1 *fitCKYLongexpo2 = new TF1("sigmaL","expo", 0.5 , 1.3 ); + fitCKYLongexpo2->FixParameter( 0 , lpar5 ); + fitCKYLongexpo2->FixParameter( 1 , lpar6 ); + fSig_L = fitCKYLongexpo2->Eval(fT_GeV); + if ( lpar5 == 0 || lpar6 == 0 ) + fSig_L = 0; + fitCKYLongexpo2 = NULL; + delete fitCKYLongexpo2; + } + else { + fSig_L = 0; + } + + // ------------------------------------------------------------------------------------------- + + if ( ( fT_GeV > 0.0 ) && ( fT_GeV < 0.15 ) ) { + eicSigmaT( fW_GeV, fQsq_GeV, tpar0, tpar1, tpar2 , tpar3 , tpar4 ); + TF1 *fitCKYTranspol2 = new TF1("sigmaL","pol2", 0.0 , 0.2 ); + fitCKYTranspol2->FixParameter( 0 , tpar0 ); + fitCKYTranspol2->FixParameter( 1 , tpar1 ); + fitCKYTranspol2->FixParameter( 2 , tpar2 ); + fSig_T = fitCKYTranspol2->Eval(fT_GeV); + if ( tpar0 == 0 || tpar1 == 0 || tpar2 == 0 ) + fSig_T = 0; + fitCKYTranspol2 = NULL; + delete fitCKYTranspol2; + } + else if ( ( fT_GeV > 0.2 ) && ( fT_GeV < 1.3 ) ) { + eicSigmaT( fW_GeV, fQsq_GeV, tpar0, tpar1, tpar2 , tpar3 , tpar4 ); + TF1 *fitCKYTransexpo = new TF1("sigmaL","expo", 0.2 , 1.3 ); + fitCKYTransexpo->FixParameter( 0 , tpar3 ); + fitCKYTransexpo->FixParameter( 1 , tpar4 ); + fSig_T = fitCKYTransexpo->Eval(fT_GeV); + if ( tpar3 == 0 || tpar4 == 0 ) + fSig_T = 0; + fitCKYTransexpo = NULL; + delete fitCKYTransexpo; + } + + // ------------------------------------------------------------------------------------------- + + fSig_VR = fSig_T + fEpsilon * fSig_L; + + sig_total = fSig_VR; + + return sig_total; +} + + + +/*--------------------------------------------------*/ +/*--------------------------------------------------*/ +/*--------------------------------------------------*/ + +void PiPlus_Production::PiPlus_Pythia6_Out_Init() { + + + print_itt = 0; + +// ppiOut << "PYTHIA EVENT FILE" << endl; + ppiOut << "SIMPLE Event FILE" << endl; + ppiOut << "============================================" << endl; + ppiOut << "I, ievent, nParticles" << endl; + ppiOut << "============================================" << endl; + ppiOut << "I K(I,1) K(I,2) K(I,3) K(I,4) K(I,5) P(I,1) P(I,2) P(I,3) P(I,4) P(I,5) V(I,1) V(I,2) V(I,3)" << endl; + ppiOut << "============================================" << endl; + +} + +/*--------------------------------------------------*/ + +void PiPlus_Production::PiPlus_Pythia6_Output() { + + + +// ppiOut << "4" +// << " \t " << fPhi // var 1 +// << " \t " << fPhiS // var 2 +// << " \t " << fx // var 3 +// << " \t " << "1" +// << " \t " << fQsq_GeV // var 4 +// << " \t " << fT_GeV // var 5 +// << " \t " << fW_GeV // var 6 +// << " \t " << fEpsilon // var 7 +// << " \t " << fEventWeight // var 8 +// << endl; + + + ppiOut << "0" << " \t\t\t\ " << print_itt << " \t\t\t " << "1" << endl; // var 1 + + print_itt++; + + ppiOut << "============================================" << endl; + + ///*--------------------------------------------------*/ + // Initial State + + ppiOut << "1" + << setw(6) << "21" + << setw(6) << "11" + << setw(6) << "0" + << setw(6) << "3" + << setw(6) << "4" + + << setw(14) << r_lelectrong.X() + << setw(14) << r_lelectrong.Y() + << setw(14) << r_lelectrong.Z() + << setw(14) << r_lelectrong.E() + << setw(14) << fElectron_Mass_GeV + << setw(6) << fVertex_X + << setw(6) << fVertex_Y + << setw(6) << fVertex_Z + << endl; + + ppiOut << "2" + << setw(6) << "21" + << setw(6) << "2212" + << setw(6) << "0" + << setw(6) << "5" + << setw(6) << "6" + + << setw(14) << r_lprotong.X() + << setw(14) << r_lprotong.Y() + << setw(14) << r_lprotong.Z() + << setw(14) << r_lprotong.E() + << setw(14) << fProton_Mass_GeV + << setw(6) << fVertex_X + << setw(6) << fVertex_Y + << setw(6) << fVertex_Z + << endl; + + ppiOut << "3" + << setw(6) << "21" + << setw(6) << "22" + << setw(6) << "1" + << setw(6) << "0" + << setw(6) << "0" + + << setw(14) << r_lphotong.X() + << setw(14) << r_lphotong.Y() + << setw(14) << r_lphotong.Z() + << setw(14) << r_lphotong.E() + << setw(14) << r_lphotong.M() + << setw(6) << fVertex_X + << setw(6) << fVertex_Y + << setw(6) << fVertex_Z + << endl; + + + ///*--------------------------------------------------*/ + // Final State + + // Scattered electron + ppiOut << "4" + << setw(6) << "1" + << setw(6) << "11" + << setw(6) << "1" + << setw(6) << "0" + << setw(6) << "0" + + << setw(14) << r_lscatelecg.X() + << setw(14) << r_lscatelecg.Y() + << setw(14) << r_lscatelecg.Z() + << setw(14) << r_lscatelecg.E() + << setw(14) << fElectron_Mass_GeV + << setw(6) << fVertex_X + << setw(6) << fVertex_Y + << setw(6) << fVertex_Z + << endl; + + // Recoiled nucleon + ppiOut << "5" + << setw(6) << "1" + << setw(6) << PDGtype(recoil_nucleon) + << setw(6) << "2" + << setw(6) << "0" + << setw(6) << "0" + + << setw(14) << r_l_scat_nucleon_g.X() + << setw(14) << r_l_scat_nucleon_g.Y() + << setw(14) << r_l_scat_nucleon_g.Z() + << setw(14) << r_l_scat_nucleon_g.E() + << setw(14) << f_Scat_Nucleon_Mass_GeV + << setw(6) << fVertex_X + << setw(6) << fVertex_Y + << setw(6) << fVertex_Z + << endl; + + // Produced Particle X + ppiOut << "6" + << setw(6) << "1" + << setw(6) << PDGtype(produced_X) + << setw(6) << "2" + << setw(6) << "0" + << setw(6) << "0" + + << setw(14) << r_lX_g.X() + << setw(14) << r_lX_g.Y() + << setw(14) << r_lX_g.Z() + << setw(14) << r_lX_g.E() + << setw(14) << fX_Mass_GeV + << setw(6) << fVertex_X + << setw(6) << fVertex_Y + << setw(6) << fVertex_Z + << endl; + + ppiOut << "=============== Event finished ===============" << endl; + +} diff --git a/src/eic_evgen/reaction_rountine.cc b/src/eic_evgen/reaction_rountine.cc new file mode 100644 index 0000000..04da501 --- /dev/null +++ b/src/eic_evgen/reaction_rountine.cc @@ -0,0 +1,994 @@ +///*--------------------------------------------------*/ +/// Reaction_routine.cc +/// +/// Creator: Wenliang (Bill) Li +/// Date: Mar 12 2020 +/// Email: wenliang.billlee@gmail.com +/// +/// Comment: Mar 12, 2020: Subroutine Exclusive_Omega_Prodoction is created +/// modeled off the Exclusive_Omega_Prodoction rountine written by +/// A. Zafar +/// + +#include "reaction_rountine.h" +#include "eic.h" +#include "particleType.h" + +using namespace std; + + +/*--------------------------------------------------*/ +/// Reaction + + +Reaction::Reaction(TString particle_str) { + + rParticle = particle_str; + + // Particle_t g = omega; + // cout << g << " " << ParticleMass(omega) << " " << ParticleEnum("Omega") << " " << ParticleMass(ParticleEnum("Omega")) << endl; + // exit(0); + + cout << "Produced particle is: " << GetParticle() << endl; + cout << "Generated process: e + p -> e' + p' + " << GetParticle() << endl; + + tTime.Start(); + + cout << "/*--------------------------------------------------*/" << endl; + cout << "Starting setting up process" << endl; + cout << endl; + + TDatime dsTime; + cout << "Start Time: " << dsTime.GetHour() << ":" << dsTime.GetMinute() << endl; + +} + + +Reaction::Reaction(){}; + +Reaction::~Reaction() { + +// ppiOut.close(); +// ppiDetails.close(); + + cout << endl; + cout << "Ending the process" << endl; + cout << "/*--------------------------------------------------*/" << endl; + + tTime.Stop(); + tTime.Print(); + + TDatime deTime; + cout << "End Time: " << deTime.GetHour() << ":" << deTime.GetMinute() << endl; + +} + +/*--------------------------------------------------*/ +/// + +void Reaction::process_reaction() { + + + + if (rParticle == "Pi+") { + +// cout << "here? " << endl; + + PiPlus_Production* rr1 = new PiPlus_Production(rParticle); + rr1->process_reaction(); + delete rr1; + + } else if (rParticle == "Pi0") { + +// Pi0_Production* r1 = new Pi0_Production("Eta"); + Pi0_Production* rr1 = new Pi0_Production(rParticle); + rr1->process_reaction(); + + delete rr1; +// exit(0); + + } + + +// // +// // Init(); +// // +// // for( long long int i = 0; i < rNEvents; i++ ) { +// // +// // rNEvent_itt = i; +// // fNGenerated ++; +// // +// // Progress_Report(); // This is happens at each 10% of the total event is processed +// // Processing_Event(); +// // } +// // +// // Detail_Output(); +// // +// +// PiPlus_Production PiPlus; +// +// cout << "11111111111 " << endl; +// +// PiPlus.Lund_Output(); +// PiPlus::Reaction.Lund_Output(); +// +} + +// +// /*--------------------------------------------------*/ +// +// void Reaction::Init() { +// +// pim* myPim; +// +// pd = dynamic_cast(myPim); +// +// rParticle_charge = ExtractCharge(rParticle); +// +// +// sTFile = Form("./LundFiles/eic_%s.txt", gfile_name.Data()); +// sLFile= Form("./LundFiles/eic_input_%s.dat", gfile_name.Data()); +// +// ppiOut.open( sLFile.c_str() ); +// ppiDetails.open( sTFile.c_str() ); +// +// qsq_ev = 0, t_ev = 0, w_neg_ev = 0, w_ev = 0; +// rNEvents = fNEvents; +// rNEvent_itt = 0; +// +// rFermiMomentum = pd->fermiMomentum(); +// +// // ---------------------------------------------------- +// // Proton in collider (lab) frame +// +// r_lproton = GetProtonVector_lab(); +// r_lprotong = GetProtonVector_lab() * fm; +// +// // ---------------------------------------------------- +// // Electron in collider (lab) frame +// cout << "Fermi momentum: " << rFermiMomentum << endl; +// +// r_lelectron = GetElectronVector_lab(); +// r_lelectrong = r_lelectron * fm; +// +// ///*--------------------------------------------------*/ +// /// Getting the particle mass from the data base +// +// fX_Mass = ParticleMass(ParticleEnum(rParticle))*1000; //MeV +// fX_Mass_GeV = fX_Mass/1000; //GeV +// +// if (rParticle_charge = "+" ) { +// +// rParticle_scat_nucleon = "neutron"; +// +// f_Scat_Nucleon_Mass = fNeutron_Mass; +// f_Scat_Nucleon_Mass_GeV = f_Scat_Nucleon_Mass/1000; +// +// } else if (rParticle_charge = "0" ) { +// +// rParticle_scat_nucleon = "proton"; +// +// f_Scat_Nucleon_Mass = fProton_Mass; +// f_Scat_Nucleon_Mass_GeV = f_Scat_Nucleon_Mass/1000; +// +// } else { +// +// cerr << "Is the overall charge of the reaction conserved? " << endl; +// cerr << "Please double check the input file and processes!" << endl; +// cerr << "Exiting the program!" << endl; +// exit(0); +// } +// +// +// rDEG2RAD = fPI/180.0; +// +// fX_Theta_I = 0.0 * rDEG2RAD ; +// fX_Theta_F = 50.0 * rDEG2RAD; +// +// cout << "Produced particle in exclusive production: " << rParticle << "; with mass: " << fX_Mass << " MeV "<< endl; +// +// +// // cout << fPI << " " << fX_Theta_I << " " << fX_Theta_F << endl; +// +// // exit(0); +// +// } +// +// +// +// /*--------------------------------------------------*/ +// +// void Reaction::Processing_Event() { +// +// // ---------------------------------------------------- +// // Considering Fermi momentum for the proton +// // ---------------------------------------------------- +// +// if( kCalcFermi ) { +// Consider_Proton_Fermi_Momentum(); +// +// } +// +// // ---------------------------------------------------- +// // Boost vector from collider (lab) frame to protons rest frame (Fix target) +// // ---------------------------------------------------- +// +// beta_col_rf = r_lproton.BoostVector(); +// fGamma_Col_RF = 1.0/sqrt( 1 - pow( beta_col_rf.Mag() , 2 ) ); +// +// // --------------------------------------------------------------------- +// // Specify the energy and solid angle of scatterd electron in Collider (lab) frame +// // --------------------------------------------------------------------- +// fScatElec_Theta_Col = acos( fRandom->Uniform( cos( fScatElec_Theta_I ) , cos( fScatElec_Theta_F ) ) ); +// fScatElec_Phi_Col = fRandom->Uniform( 0 , 2.0 * fPi); +// fScatElec_Energy_Col = fRandom->Uniform( fScatElec_E_Lo * fElectron_Energy_Col , fScatElec_E_Hi * fElectron_Energy_Col ); +// +// // ---------------------------------------------------- +// // Produced Particle X in Collider frame +// // ---------------------------------------------------- +// +// /// The generic produced particle in the exclusive reaction is labelled as X +// fX_Theta_Col = acos( fRandom->Uniform( cos(fX_Theta_I), cos(fX_Theta_F ) ) ); +// fX_Phi_Col = fRandom->Uniform( 0 , 2.0 * fPi ); +// +// // fScatElec_Theta_Col = 2.42585; +// // fScatElec_Phi_Col = 1.73913; +// // fScatElec_Energy_Col = 5473.08; +// // +// // fX_Theta_Col = 0.232649; +// // fX_Phi_Col = 4.68068; +// +// // cout << fScatElec_Theta_Col << " " << fScatElec_Phi_Col << " " << fScatElec_Energy_Col << " " << fX_Theta_Col << " " << fX_Phi_Col << endl; +// +// // exit(0); +// +// // --------------------------------------------------------------------- +// // Specify the energy and solid angle of scatterd electron in Collider (lab) frame +// // --------------------------------------------------------------------- +// +// fScatElec_Mom_Col = sqrt( pow( fScatElec_Energy_Col,2) - pow( fElectron_Mass , 2) ); +// fScatElec_MomZ_Col = ( fScatElec_Mom_Col * cos(fScatElec_Theta_Col) ); +// fScatElec_MomX_Col = ( fScatElec_Mom_Col * sin(fScatElec_Theta_Col) * cos(fScatElec_Phi_Col) ); +// fScatElec_MomY_Col = ( fScatElec_Mom_Col * sin(fScatElec_Theta_Col) * sin(fScatElec_Phi_Col) ); +// +// r_lscatelec.SetPxPyPzE( fScatElec_MomX_Col, fScatElec_MomY_Col, fScatElec_MomZ_Col, fScatElec_Energy_Col); +// +// r_lscatelecg = r_lscatelec * fm; +// +// // ---------------------------------------------------- +// // Photon in collider (lab) frame and Qsq +// // ---------------------------------------------------- +// +// r_lphoton = r_lelectron - r_lscatelec; +// r_lphotong = r_lelectrong - r_lscatelecg; +// +// // cout << "Check check : " << endl; +// // +// // cout << r_lphoton.Px() << " " << r_lphoton.Py() << " " << r_lphoton.Pz() << " " << r_lphoton.E() << endl; +// // cout << r_lelectron.Px() << " " << r_lelectron.Py() << " " << r_lelectron.Pz() << " " << r_lelectron.E() << endl; +// // cout << r_lscatelec.Px() << " " << r_lscatelec.Py() << " " << r_lscatelec.Pz() << " " << r_lscatelec.E() << endl; +// +// // exit(0); +// +// fQsq_GeV = -1.* r_lphotong.Mag2(); +// +// if ( fQsq_GeV < 5.0 ) { +// qsq_ev++; +// return; +// } +// +// // ---------------------------------------------------- +// // W square, Invariant Mass (P_g + P_p)^2 +// // ---------------------------------------------------- +// +// TLorentzVector lwg; +// lwg = r_lprotong + r_lphotong; +// fW_GeV = lwg.Mag(); +// fWSq_GeV = lwg.Mag2(); +// +// +// // cout << r_lprotong.Px() << " " << r_lprotong.Py() << " " << r_lprotong.Pz() << " " << r_lprotong.E() << endl; +// // cout << r_lphotong.Px() << " " << r_lphotong.Py() << " " << r_lphotong.Pz() << " " << r_lphotong.E() << endl; +// // cout << fQsq_GeV << " " << fW_GeV << " "<< fWSq_GeV << endl; +// +// +// +// // cout << "Here????? " << endl; +// +// +// +// if ( fWSq_GeV < 0 ) { +// w_neg_ev++; +// return; +// } +// +// // --------------------------------------------------------- +// // Pion momentum in collider frame, analytic solution starts +// // --------------------------------------------------------- +// +// +// double fupx = sin( fX_Theta_Col ) * cos( fX_Phi_Col ); +// double fupy = sin( fX_Theta_Col ) * sin( fX_Phi_Col ); +// double fupz = cos( fX_Theta_Col ); +// +// double fuqx = sin( r_lphoton.Theta() ) * cos( r_lphoton.Phi() ); +// double fuqy = sin( r_lphoton.Theta() ) * sin( r_lphoton.Phi() ); +// double fuqz = cos( r_lphoton.Theta() ); +// +// double fa = -(r_lphoton.Vect()).Mag() * ( fupx * fuqx + fupy * fuqy + fupz * fuqz ); +// double fb = pow ( (r_lphoton.Vect()).Mag() , 2 ); +// double fc = r_lphoton.E() + fProton_Mass; +// +// +// // cout.precision(10); +// // cout << r_lphoton.Vect().X() << " " << r_lphoton.Vect().Y() << " " << r_lphoton.Vect().Z() << endl; +// // cout << "AAAAAAAAAAABBBBBBBCCCCCCCCC " << fa << " " << fb << " " << fc << endl; +// +// +// fa = ( fa - std::abs( (r_lproton.Vect()).Mag() ) * ( ( ( r_lproton.X() / (r_lproton.Vect()).Mag() ) * fupx ) + +// ( ( r_lproton.Y() / (r_lproton.Vect()).Mag() ) * fupy ) + +// ( ( r_lproton.Z() / (r_lproton.Vect()).Mag() ) * fupz ) ) ); +// +// double factor = ( pow( (r_lproton.Vect()).Mag() , 2 ) + 2.0 * (r_lphoton.Vect()).Mag() * (r_lproton.Vect()).Mag() * +// ( ( ( r_lproton.X() / (r_lproton.Vect()).Mag() ) * fuqx ) + +// ( ( r_lproton.Y() / (r_lproton.Vect()).Mag() ) * fuqy ) + +// ( ( r_lproton.Z() / (r_lproton.Vect()).Mag() ) * fuqz ) ) ); +// +// fb = fb + factor; +// fc = r_lphoton.E() + r_lproton.E(); +// +// // double ft = fc * fc - fb + fPion_Mass * fPion_Mass - fProton_Mass * fProton_Mass; +// double ft = fc * fc - fb + fX_Mass * fX_Mass - fProton_Mass * fProton_Mass; +// +// double fQA = 4.0 * ( fa * fa - fc * fc ); +// double fQB = 4.0 * fc * ft; +// +// // double fQC = -4.0 * fa * fa * fPion_Mass * fPion_Mass - ft * ft; +// double fQC = -4.0 * fa * fa * fX_Mass * fX_Mass - ft * ft; +// +// fradical = fQB * fQB - 4.0 * fQA * fQC; +// +// fepi1 = ( -fQB - sqrt( fradical ) ) / ( 2.0 * fQA ); +// fepi2 = ( -fQB + sqrt( fradical ) ) / ( 2.0 * fQA ); +// +// // cout << fc*fc << " " << 99531.3*99531.3 << endl; +// // cout << fb << " " << 9.83386e+09 << endl; +// // cout << fc*fc - fb << " " << 99531.3*99531.3 - 9.83386e+09 << endl; +// +// // exit(0); +// +// // cout << "abc: " << fa << " " << fb << " " << fc << " " << ft << " " << fX_Mass << " " << fProton_Mass << endl; +// +// // cout << "epi: " << fQB << " " << fradical << " " << fQA << endl; +// +// // cout << factor << " " << fepi1 << " " << fepi2 << endl; +// +// // cout << "X diagnose: " << fPion_Mass << " " << fepi1 << " " << fX_Theta_Col << " " << fX_Phi_Col << endl; +// +// // fPion_Mom_Same = 0; +// // if ( std::abs(fepi1 - fepi2) < fDiff ){ fPion_Mom_Same = 1; } +// +// // --------------------------------------------------------- +// // Particle X momentum in collider frame, analytic solution ends +// // --------------------------------------------------------- +// +// r_lX.SetPxPyPzE( (sqrt( pow( fepi1 , 2) - pow(fX_Mass , 2) ) ) * sin(fX_Theta_Col) * cos(fX_Phi_Col), +// ( sqrt( pow( fepi1 , 2) - pow(fX_Mass , 2) ) ) * sin(fX_Theta_Col) * sin(fX_Phi_Col), +// ( sqrt( pow( fepi1 , 2) - pow(fX_Mass , 2) ) ) * cos(fX_Theta_Col), +// fepi1 ); +// +// r_lX_g = r_lX * fm; +// +// // ---------------------------------------------------- +// // Scattered proton collider (lab) frame +// +// r_l_scat_nucleon.SetPxPyPzE( ( r_lproton + r_lelectron - r_lscatelec - r_lX).X(), +// ( r_lproton + r_lelectron - r_lscatelec - r_lX ).Y(), +// ( r_lproton + r_lelectron - r_lscatelec - r_lX ).Z(), +// sqrt( pow( ( ( ( r_lproton + r_lelectron - r_lscatelec - r_lX ).Vect() ).Mag()),2) + +// pow( f_Scat_Nucleon_Mass ,2 ) ) ); +// +// r_l_scat_nucleon_g = r_l_scat_nucleon * fm; +// +// // ---------------------------------------------------------------------------------------------- +// // ---------------------------------------------------------------------------------------------- +// // Calculate w = (proton + photon)^2 +// // ---------------------------------------------------------------------------------------------- +// // ---------------------------------------------------------------------------------------------- +// +// // cout << fW_GeV << endl; +// if ( fW_GeV < 3.0 || fW_GeV > 10.6 ) { +// w_ev++; +// return; +// } +// +// r_lw = r_lproton + r_lphoton; +// fW = r_lw.Mag(); +// +// // ---------------------------------------------------------------------------------------------- +// // ---------------------------------------------------------------------------------------------- +// // Calculate w prime w' = (proton + photon - pion)^2 +// // ---------------------------------------------------------------------------------------------- +// // ---------------------------------------------------------------------------------------------- +// +// lwp = r_lprotong + r_lphotong - r_lX_g; +// fW_Prime_GeV = lwp.Mag(); +// +// fsini = r_lelectron + r_lproton; +// fsfin = r_lscatelec + r_lX + r_l_scat_nucleon; +// +// fsinig = fsini * fm; +// fsfing = fsfin * fm; +// +// fMandSConserve = std::abs( fsinig.Mag() - fsfing.Mag() ); +// +// // cout << fW_GeV << " " << fsinig.Mag() << " " << fsfing.Mag() << " " << fMandSConserve << endl; +// // +// // cout << "E: " << r_lscatelec.Px() << " " << r_lscatelec.Py() << " " << r_lscatelec.Pz() << " " << r_lscatelec.E() << endl; +// // cout << "X: " << r_lX.Px() << " " << r_lX.Py() << " " << r_lX.Pz() << " " << r_lX.E() << endl; +// // cout << "N: " << r_l_scat_nucleon.Px() << " " << r_l_scat_nucleon.Py() << " " << r_l_scat_nucleon.Pz() << " " << r_l_scat_nucleon.E() << endl; +// +// kSConserve = false; +// if( std::abs( fsinig.Mag() - fsfing.Mag() ) < fDiff ) { +// kSConserve = true; +// } +// +// if ( pd->CheckLaws( r_lelectron, r_lproton, r_lscatelec, r_lX, r_l_scat_nucleon) != 1 ) +// return; +// +// //////////////////////////////////////////////////////////////////////////////////////////// +// // Start // +// // Transformation of e', pi- and recoil proton to target's rest frmae without energy loss // +// //////////////////////////////////////////////////////////////////////////////////////////// +// +// lproton_rf = r_lproton; +// lproton_rf.Boost(-beta_col_rf); +// lproton_rfg = lproton_rf * fm; +// +// lelectron_rf = r_lelectron; +// lelectron_rf.Boost(-beta_col_rf); +// lelectron_rfg = lelectron_rf * fm; +// +// lscatelec_rf = r_lscatelec; +// lscatelec_rf.Boost(-beta_col_rf); +// lscatelec_rfg = lscatelec_rf * fm; +// +// lphoton_rf = r_lphoton; +// lphoton_rf.Boost(-beta_col_rf); +// lphoton_rfg = lphoton_rf * fm; +// +// lX_rf = r_lX; +// lX_rf.Boost(-beta_col_rf); +// lX_rfg = lX_rf * fm; +// +// l_scat_nucleon_rf = r_l_scat_nucleon; +// l_scat_nucleon_rf.Boost(-beta_col_rf); +// l_scat_nucleon_rf_g = l_scat_nucleon_rf * fm; +// +// //////////////////////////////////////////////////////////////////////////////////////////// +// // End // +// // Transformation of e', pi- and recoil proton to target's rest frmae without energy loss // +// //////////////////////////////////////////////////////////////////////////////////////////// +// +// +// // ----------------------------------------------------------------------------------------- +// // ----------------------------------------------------------------------------------------- +// // Calculate -t +// // ----------------------------------------------------------------------------------------- +// // ----------------------------------------------------------------------------------------- +// +// fBeta_CM_RF = (lphoton_rf.Vect()).Mag() / ( lphoton_rf.E() + fProton_Mass ); +// fGamma_CM_RF = ( lphoton_rf.E() + fProton_Mass ) / fW; +// fX_Energy_CM = ( pow( fW , 2) + pow(fX_Mass , 2) - pow(f_Scat_Nucleon_Mass , 2) ) / ( 2.0 * fW); +// fX_Mom_CM = sqrt( pow(fX_Energy_CM , 2) - pow(fX_Mass , 2)); +// fX_Energy_CM_GeV = fX_Energy_CM / 1000.0; +// fX_Mom_CM_GeV = fX_Mom_CM / 1000.0; +// +// // this equation is valid for parallel kinematics only! +// fT_Para = ( pow(((r_lphoton.Vect()).Mag() - (r_lX.Vect()).Mag()),2) - pow((r_lphoton.E() - r_lX.E()),2)); +// fT_Para_GeV = fT_Para/1000000.0; +// +// lt = r_lphoton - r_lX; +// ltg = lt * fm; +// +// fT = -1.*lt.Mag2(); +// fT_GeV = -1.*ltg.Mag2(); +// +// if ( gKinematics_type == 1 && fT_GeV > 0.5 ) { +// t_ev++; +// return; +// } +// +// if ( gKinematics_type == 2 && fT_GeV > 1.3 ) { +// t_ev++; +// return; +// } +// +// // cout << fT_GeV << endl; +// +// // exit(0); +// +// fx = fQsq_GeV / ( 2.0 * r_lprotong.Dot( r_lphotong ) ); +// fy = r_lprotong.Dot( r_lphotong ) / r_lprotong.Dot( r_lelectrong ); +// fz = r_lX.E()/r_lphoton.E(); +// +// // ------------------------------------------------------------------------------------------------------- +// // Calculation of Phi ( azimuthal angle of pion momentum w.r.t lepton plane in target's rest frame) +// // Calculation of PhiS ( azimuthal angle of target polarization w.r.t lepton plane in target's rest frame) +// // ------------------------------------------------------------------------------------------------------- +// +// v3Photon.SetX( lphoton_rfg.X() ); +// v3Photon.SetY( lphoton_rfg.Y() ); +// v3Photon.SetZ( lphoton_rfg.Z() ); +// +// v3Electron.SetX( lelectron_rfg.X() ); +// v3Electron.SetY( lelectron_rfg.Y() ); +// v3Electron.SetZ( lelectron_rfg.Z() ); +// +// v3X.SetX( lX_rfg.X() ) ; +// v3X.SetY( lX_rfg.Y() ) ; +// v3X.SetZ( lX_rfg.Z() ); +// +// v3S.SetX( -1 ); +// v3S.SetY( 0 ); +// v3S.SetZ( 0 ); +// +// v3PhotonUnit = v3Photon.Unit(); +// v3QxL = v3Photon.Cross(v3Electron); +// v3QxP = v3Photon.Cross(v3X); +// v3QxS = v3Photon.Cross(v3S); +// v3LxP = v3Electron.Cross(v3X); +// v3LxS = v3Electron.Cross(v3S); +// v3PxL = v3X.Cross(v3Electron); +// v3QUnitxL = v3PhotonUnit.Cross(v3Electron); +// v3QUnitxP = v3PhotonUnit.Cross(v3X); +// v3QUnitxS = v3PhotonUnit.Cross(v3S); +// +// /*--------------------------------------------------*/ +// // Get the Phi scattering angle with respect to the electron scattering plane +// fPhi = Get_Phi_X_LeptonPlane_RF (); +// +// /*--------------------------------------------------*/ +// // Get the Phi scattering angle with respect to the electron scattering plane +// fPhiS = Get_Phi_TargPol_LeptonPlane_RF(); +// +// fTheta_X_Photon_RF = fRAD2DEG * acos( ( v3Photon.Dot( v3X ) ) / ( v3Photon.Mag() * v3X.Mag() ) ); +// if ( fTheta_X_Photon_RF < 0 ) { fTheta_X_Photon_RF = 180.0 + fTheta_X_Photon_RF; } +// +// // ----------------------------------------------------------------------------------- +// // If we have fermi momentum then epsilon should be in rest frame +// // The theta angle of scattered angle used in expression of epsilon is the angle +// // with respect to direction of incoming electron in the rest frame of target nucleon +// // epsilon=1./(1.+ 2.*(pgam_restg**2)/q2g * *(tand(thscat_rest/2.))**2) +// // ----------------------------------------------------------------------------------- +// +// double fTheta_EEp = (lelectron_rf.Vect()).Angle(lscatelec_rf.Vect()); +// +// fEpsilon = 1.0 / ( 1.0 + 2.0 * ( pow( (lphoton_rfg.Vect()).Mag(),2)/fQsq_GeV ) * pow( tan( fTheta_EEp / 2 ) , 2 ) ); +// +// // ---------------------------------------------------- +// // Virtual Photon flux factor in units of 1/(GeV*Sr) +// // ---------------------------------------------------- +// fFlux_Factor_Col = (fAlpha/(2.0*pow(fPi,2))) * (r_lscatelecg.E() / r_lelectrong.E()) * +// ( pow(fW_GeV,2) - pow(fProton_Mass_GeV,2) ) / (2.0*fProton_Mass_GeV*fQsq_GeV*(1.0 - fEpsilon)); +// +// fFlux_Factor_RF = ( fAlpha / ( 2.0 * pow( fPi , 2 ) ) ) * ( lscatelec_rfg.E() / lelectron_rfg.E() ) * +// ( pow( fW_GeV , 2 ) - pow( fProton_Mass_GeV , 2 ) ) / +// ( 2.0 * fProton_Mass_GeV * fQsq_GeV * ( 1.0 - fEpsilon ) ); +// +// +// // ---------------------------------------------------- +// // Jacobian dt/dcos(theta*)dphi in units of GeV2/sr +// // ---------------------------------------------------- +// fJacobian_CM = ( (lphoton_rfg.Vect()).Mag() - fBeta_CM_RF * lphoton_rfg.E() ) / ( fGamma_CM_RF * ( 1.0 - pow(fBeta_CM_RF,2) ) ); +// +// fA = fJacobian_CM * fX_Mom_CM_GeV / fPi; +// +// // ---------------------------------------------------- +// // Jacobian dOmega* / dOmega dimensionless +// // ---------------------------------------------------- +// fJacobian_CM_RF = ( pow((lX_rf.Vect()).Mag(),2)*fW) / +// ( fX_Mom_CM * std::abs( ( fProton_Mass + lphoton_rf.E()) * (lX_rf.Vect()).Mag() - +// ( lX_rf.E() * (lphoton_rf.Vect()).Mag() * cos( lX_rf.Theta() ) ) ) ); +// +// fJacobian_CM_Col = ( ( pow((r_lX.Vect()).Mag(),2) * fW ) / +// ( fX_Mom_CM * std::abs( ( fProton_Mass + r_lphoton.E() ) * (r_lX.Vect()).Mag() - +// ( r_lX.E() * (r_lphoton.Vect()).Mag() * cos( r_lX.Theta() ) ) ) ) ); +// +// +// // cout << lX_rf.Vect().Mag() << " " << << << << << << << << endl; +// // cout << fJacobian_CM_RF << " " << fJacobian_CM_Col << endl; +// +// +// +// // ----------------------------------------------------------------------------------------------------------- +// // CKY sigma L and T starts +// // ----------------------------------------------------------------------------------------------------------- +// +// // r_fSig_T = 1; +// // r_fSig_L = 1; +// // +// // ------------------------------------------------------------------------------------------- +// +// r_fSig = Get_Total_Cross_Section(); +// +// // ----------------------------------------------------------------------------------------------------------- +// // CKY sigma L and T ends +// // ----------------------------------------------------------------------------------------------------------- +// +// fSigma_Col = r_fSig * fFlux_Factor_Col * fA * fJacobian_CM_Col; +// +// +// if ( ( fSigma_Col <= 0 ) || std::isnan( fSigma_Col ) ) { +// fNSigmaNeg ++; +// return; +// } +// +// // ----------------------------------------------------------------------------------------------------------- +// // ----------------------------------------------------------------------------------------------------------- +// // Lab cross section Phase Space Conversion Luminosity Total events tried +// // Hz = ub / ( sr^2 * GeV ) * GeV * sr^2 * ( cm^2 / ub ) * ( # / ( cm^2 * sec ) ) / ( # ) +// +// fEventWeight = fSigma_Col * fPSF * fuBcm2 * fLumi / fNEvents; // in Hz +// +// +// fNRecorded ++; +// fLundRecorded++; +// fRatio = fNRecorded / fNGenerated; +// +// +// +// // cout << fSigma_Col << " " << fEventWeight << endl; +// // exit(0); +// +// +// Lund_Output(); +// +// } +// +// +// /*--------------------------------------------------*/ +// +// void Reaction::Progress_Report() { +// +// dFractTime = time(0); +// +// if ( rNEvent_itt % ( rNEvents / 10 ) == 0 ) { +// cout << "Event: " << setw(8) << rNEvent_itt +// << " % of events " << setw(4) << ((1.0*rNEvent_itt)/(1.0*rNEvents))*100.0 +// << " Day: " << dFractTime.GetDay() +// << " Time: " << dFractTime.GetHour() +// << ":" << dFractTime.GetMinute() +// << ":" << dFractTime.GetSecond() +// << endl; +// } +// } +// +// +// /*--------------------------------------------------*/ +// +// TLorentzVector Reaction::GetProtonVector_lab() { +// +// fProton_Theta_Col = 50.0e-3; +// fProton_Phi_Col = fPi; +// fProton_Mom_Col = fPBeam * 1e3; +// fVertex_X = 0.; +// fVertex_Y = 0.; +// fVertex_Z = 0.; +// +// +// TLorentzVector lproton( fProton_Mom_Col * sin(fProton_Theta_Col) * cos(fProton_Phi_Col), +// fProton_Mom_Col * sin(fProton_Theta_Col) * sin(fProton_Phi_Col), +// fProton_Mom_Col * cos(fProton_Theta_Col), +// sqrt( pow( fProton_Mom_Col , 2 ) + pow( fProton_Mass , 2 ) ) ); +// +// return lproton; +// +// } +// +// +// /*--------------------------------------------------*/ +// +// //*--------------------------------------------------*/ +// // Proton in collider (lab) frame +// // ---------------------------------------------------- +// +// void Reaction::Consider_Proton_Fermi_Momentum() { +// +// fProton_Mom_Col = fProton_Mom_Col + rFermiMomentum; +// fProton_Theta_Col = acos( fRandom->Uniform( cos(0.0) , cos(fPi) ) ); +// fProton_Phi_Col = fRandom->Uniform( 0 , 360 ); +// +// double px, py, pz, e; +// +// px = fProton_Mom_Col * sin(fProton_Theta_Col) * cos(fProton_Phi_Col); +// py = fProton_Mom_Col * sin(fProton_Theta_Col) * sin(fProton_Phi_Col); +// pz = fProton_Mom_Col * cos(fProton_Theta_Col); +// e = sqrt( pow( fProton_Mom_Col , 2 ) + pow( fProton_Mass , 2 ) ); +// +// +// r_lproton.SetPxPyPzE(px,py,pz,e); +// +// r_lprotong = r_lproton*fm; +// +// } +// +// /*--------------------------------------------------*/ +// +// // ---------------------------------------------------- +// // Electron in collider (lab) frame +// // ---------------------------------------------------- +// +// TLorentzVector Reaction::GetElectronVector_lab() { +// +// fElectron_Energy_Col = fElectron_Kin_Col; +// fElectron_Mom_Col = sqrt( pow(fElectron_Energy_Col , 2) - pow(fElectron_Mass , 2) ); +// fElectron_Theta_Col = fPi; +// fElectron_Phi_Col = 0.0; +// fElectron_MomZ_Col = fElectron_Mom_Col * cos(fElectron_Theta_Col); +// fElectron_MomX_Col = fElectron_Mom_Col * sin(fElectron_Theta_Col) * cos(fElectron_Phi_Col); +// fElectron_MomY_Col = fElectron_Mom_Col * sin(fElectron_Theta_Col) * sin(fElectron_Phi_Col); +// +// TLorentzVector lelectron( fElectron_MomX_Col, fElectron_MomY_Col, fElectron_MomZ_Col, fElectron_Energy_Col); +// +// return lelectron; +// +// } +// +// +// +// +// +// ////*-------------------------------------------------- +// /// Outputing to LUND file +// +// void Reaction::Lund_Output() { +// +// ppiOut << "3" +// << " \t " << fPhi // var 1 +// << " \t " << fPhiS // var 2 +// << " \t " << fx // var 3 +// << " \t " << "1" +// << " \t " << fQsq_GeV // var 4 +// << " \t " << fT_GeV // var 5 +// << " \t " << fW_GeV // var 6 +// << " \t " << fEpsilon // var 7 +// << " \t " << fEventWeight // var 8 +// << endl; +// +// // Produced Particle X +// ppiOut << setw(10) << "1" +// << setw(10) << "1" +// << setw(10) << "1" +// << setw(10) << "211" +// << setw(10) << "0" +// << setw(10) << "0" +// << setw(16) << r_lX_g.X() +// << setw(16) << r_lX_g.Y() +// << setw(16) << r_lX_g.Z() +// << setw(16) << r_lX_g.E() +// << setw(16) << fX_Mass_GeV +// << setw(16) << fVertex_X +// << setw(16) << fVertex_Y +// << setw(16) << fVertex_Z +// << endl; +// +// // Scattered electron +// ppiOut << setw(10) << "2" +// << setw(10) << "-1" +// << setw(10) << "1" +// << setw(10) << "11" +// << setw(10) << "0" +// << setw(10) << "0" +// << setw(16) << r_lscatelecg.X() +// << setw(16) << r_lscatelecg.Y() +// << setw(16) << r_lscatelecg.Z() +// << setw(16) << r_lscatelecg.E() +// << setw(16) << fElectron_Mass_GeV +// << setw(16) << fVertex_X +// << setw(16) << fVertex_Y +// << setw(16) << fVertex_Z +// << endl; +// +// // Recoiled neutron +// ppiOut << setw(10) << "3" +// << setw(10) << "1" +// << setw(10) << "1" +// << setw(10) << "2112" +// << setw(10) << "0" +// << setw(10) << "0" +// << setw(16) << r_l_scat_nucleon.X() +// << setw(16) << r_l_scat_nucleon.Y() +// << setw(16) << r_l_scat_nucleon.Z() +// << setw(16) << r_l_scat_nucleon.E() +// << setw(16) << f_Scat_Nucleon_Mass_GeV +// << setw(16) << fVertex_X +// << setw(16) << fVertex_Y +// << setw(16) << fVertex_Z +// << endl; +// +// } +// +// /*--------------------------------------------------*/ +// /// Output generator detail +// +// void Reaction::Detail_Output() { +// +// ppiDetails << "Total events tried " << setw(50) << fNGenerated << endl; +// ppiDetails << "Total events recorded " << setw(50) << fNRecorded << endl; +// +// ppiDetails << "Seed used for the Random Number Generator " << setw(50) << fSeed << endl; +// +// ppiDetails << "Number of events with w more than 10.6 " << setw(50) << w_ev << endl; +// ppiDetails << "Number of events with wsq negative " << setw(50) << w_neg_ev << endl; +// ppiDetails << "Number of events with qsq less than 4 " << setw(50) << qsq_ev << endl; +// ppiDetails << "Number of events with -t more than threshold " << setw(50) << t_ev << endl; +// +// ppiDetails << "Number of events with w less than threshold " << setw(50) << fWSqNeg << endl; +// ppiDetails << "Number of events with mom not conserve " << setw(50) << fNMomConserve << endl; +// ppiDetails << "Number of events with Sigma negative " << setw(50) << fNSigmaNeg << endl; +// ppiDetails << "Number of lund events " << setw(50) << fLundRecorded << endl; +// +// } +// +// /*--------------------------------------------------*/ +// +// Double_t Reaction::Get_Phi_X_LeptonPlane_RF () { +// +// fCos_Phi_X_LeptonPlane_RF = ( ( v3QUnitxL.Dot( v3QUnitxP ) ) / ( v3QUnitxL.Mag() * v3QUnitxP.Mag() ) ); // hep-ph/0410050v2 +// fSin_Phi_X_LeptonPlane_RF = ( ( v3LxP.Dot( v3PhotonUnit ) ) / ( v3QUnitxL.Mag() * v3QUnitxP.Mag() ) ); // hep-ph/0410050v2 +// if ( fSin_Phi_X_LeptonPlane_RF >= 0 ) +// fPhi_X_LeptonPlane_RF = fRAD2DEG * acos( ( v3QUnitxL.Dot( v3QUnitxP ) ) / ( v3QUnitxL.Mag() * v3QUnitxP.Mag() ) ); +// if ( fSin_Phi_X_LeptonPlane_RF < 0 ) +// fPhi_X_LeptonPlane_RF = 360.0 - std::abs( fRAD2DEG * acos( ( v3QUnitxL.Dot( v3QUnitxP ) ) / ( v3QUnitxL.Mag() * v3QUnitxP.Mag() ) ) ); +// +// return fPhi_X_LeptonPlane_RF; +// +// } +// +// /*--------------------------------------------------*/ +// +// Double_t Reaction::Get_Phi_TargPol_LeptonPlane_RF () { +// +// fCos_Phi_TargPol_LeptonPlane_RF = ( ( v3QUnitxL.Dot( v3QUnitxS ) ) / ( v3QUnitxL.Mag() * v3QUnitxS.Mag() ) ); // hep-ph/0410050v2 +// fSin_Phi_TargPol_LeptonPlane_RF = ( ( v3LxS.Dot( v3PhotonUnit ) ) / ( v3QUnitxL.Mag() * v3QUnitxS.Mag() ) ); // hep-ph/0410050v2 +// if ( fSin_Phi_TargPol_LeptonPlane_RF >= 0 ) +// fPhi_TargPol_LeptonPlane_RF = fRAD2DEG * acos( ( v3QUnitxL.Dot( v3QUnitxS ) ) / ( v3QUnitxL.Mag() * v3QUnitxS.Mag() ) ); +// if ( fSin_Phi_TargPol_LeptonPlane_RF < 0 ) +// fPhi_TargPol_LeptonPlane_RF = 360.0 - std::abs( fRAD2DEG * acos( ( v3QUnitxL.Dot( v3QUnitxS ) ) / ( v3QUnitxL.Mag() * v3QUnitxS.Mag() ) ) ); +// +// return fPhi_TargPol_LeptonPlane_RF; +// +// } +// +// /*--------------------------------------------------*/ +// +// Double_t Reaction::Get_Total_Cross_Section() { +// +// Double_t total_sig; +// +// Particle_t p = ParticleEnum(rParticle); +// +// switch (p) { +// +// case Pi0: total_sig = GetPi0_CrossSection(); +// case PiPlus: total_sig = GetPiPlus_CrossSection(); +// // case Omega: total_sig = ...; +// +// } +// +// return total_sig; +// +// } +// +// +// +// /*--------------------------------------------------*/ +// +// Double_t Reaction::GetPi0_CrossSection() { +// +// double_t sig_total; +// +// +// return sig_total; +// +// } +// +// +// +// +// /*--------------------------------------------------*/ +// /// Charged Pi+ moduel: +// /// Author: Z. Ahmed +// /// Date: 2017 +// +// +// Double_t Reaction::GetPiPlus_CrossSection(){ +// +// double_t sig_total; +// +// // -------------------------------------------------------------------------------------------------- +// // CKY sigma L and T starts +// // -------------------------------------------------------------------------------------------------- +// double lpar0 = 0., lpar1 = 0., lpar2 = 0., lpar3 = 0., lpar4 = 0., lpar5 = 0., lpar6 = 0.; +// double tpar0 = 0., tpar1 = 0., tpar2 = 0., tpar3 = 0., tpar4 = 0.; +// +// +// lpar0 = 0.; lpar1 = 0.; lpar2 = 0.; lpar3 = 0.; lpar4 = 0.; lpar5 = 0.; lpar6 = 0.; +// tpar0 = 0.; tpar1 = 0.; tpar2 = 0.; tpar3 = 0.; tpar4 = 0.; +// +// fSig_L = 0; +// fSig_T = 0; +// +// if ( ( fT_GeV > 0. ) && ( fT_GeV < 0.15 ) ) { +// eicSigmaL( fW_GeV, fQsq_GeV, lpar0, lpar1, lpar2 , lpar3 , lpar4 , lpar5 , lpar6 ); +// TF1 *fitCKYLonglandau = new TF1("sigmaL","landau", 0.0 , 0.15 ); +// fitCKYLonglandau->FixParameter( 0 , lpar0 ); +// fitCKYLonglandau->FixParameter( 1 , lpar1 ); +// fitCKYLonglandau->FixParameter( 2 , lpar2 ); +// fSig_L = fitCKYLonglandau->Eval(fT_GeV); +// if ( lpar0 == 0 || lpar1 == 0 || lpar2 == 0 ) +// fSig_L = 0; +// fitCKYLonglandau = NULL; +// delete fitCKYLonglandau; +// } +// else if ( ( fT_GeV > 0.15 ) && ( fT_GeV < 0.5 ) ) { +// eicSigmaL( fW_GeV, fQsq_GeV, lpar0, lpar1, lpar2 , lpar3 , lpar4 , lpar5 , lpar6 ); +// TF1 *fitCKYLongexpo1 = new TF1("sigmaL","expo", 0.15 , 0.5 ); +// fitCKYLongexpo1->FixParameter( 0 , lpar3 ); +// fitCKYLongexpo1->FixParameter( 1 , lpar4 ); +// fSig_L = fitCKYLongexpo1->Eval(fT_GeV); +// if ( lpar3 == 0 || lpar4 == 0 ) +// fSig_L = 0; +// fitCKYLongexpo1 = NULL; +// delete fitCKYLongexpo1; +// } +// else if ( ( fT_GeV > 0.5 ) && ( fT_GeV < 1.3 ) ) { +// eicSigmaL( fW_GeV, fQsq_GeV, lpar0, lpar1, lpar2 , lpar3 , lpar4 , lpar5 , lpar6 ); +// TF1 *fitCKYLongexpo2 = new TF1("sigmaL","expo", 0.5 , 1.3 ); +// fitCKYLongexpo2->FixParameter( 0 , lpar5 ); +// fitCKYLongexpo2->FixParameter( 1 , lpar6 ); +// fSig_L = fitCKYLongexpo2->Eval(fT_GeV); +// if ( lpar5 == 0 || lpar6 == 0 ) +// fSig_L = 0; +// fitCKYLongexpo2 = NULL; +// delete fitCKYLongexpo2; +// } +// else { +// fSig_L = 0; +// } +// +// // ------------------------------------------------------------------------------------------- +// +// if ( ( fT_GeV > 0.0 ) && ( fT_GeV < 0.15 ) ) { +// eicSigmaT( fW_GeV, fQsq_GeV, tpar0, tpar1, tpar2 , tpar3 , tpar4 ); +// TF1 *fitCKYTranspol2 = new TF1("sigmaL","pol2", 0.0 , 0.2 ); +// fitCKYTranspol2->FixParameter( 0 , tpar0 ); +// fitCKYTranspol2->FixParameter( 1 , tpar1 ); +// fitCKYTranspol2->FixParameter( 2 , tpar2 ); +// fSig_T = fitCKYTranspol2->Eval(fT_GeV); +// if ( tpar0 == 0 || tpar1 == 0 || tpar2 == 0 ) +// fSig_T = 0; +// fitCKYTranspol2 = NULL; +// delete fitCKYTranspol2; +// } +// else if ( ( fT_GeV > 0.2 ) && ( fT_GeV < 1.3 ) ) { +// eicSigmaT( fW_GeV, fQsq_GeV, tpar0, tpar1, tpar2 , tpar3 , tpar4 ); +// TF1 *fitCKYTransexpo = new TF1("sigmaL","expo", 0.2 , 1.3 ); +// fitCKYTransexpo->FixParameter( 0 , tpar3 ); +// fitCKYTransexpo->FixParameter( 1 , tpar4 ); +// fSig_T = fitCKYTransexpo->Eval(fT_GeV); +// if ( tpar3 == 0 || tpar4 == 0 ) +// fSig_T = 0; +// fitCKYTransexpo = NULL; +// delete fitCKYTransexpo; +// } +// +// // ------------------------------------------------------------------------------------------- +// +// fSig_VR = fSig_T + fEpsilon * fSig_L; +// +// sig_total = fSig_VR; +// +// return sig_total; +// } diff --git a/src/eic_evgen/reaction_rountine.h b/src/eic_evgen/reaction_rountine.h new file mode 100644 index 0000000..0c23774 --- /dev/null +++ b/src/eic_evgen/reaction_rountine.h @@ -0,0 +1,280 @@ +# ifndef REACTION_ROUNTINE_CC +# define REACTION_ROUNTINE_CC + +#include "eic_pim.h" + +#include +#include + +#include +#include + +#include "TF1.h" +#include "TLorentzVector.h" + +#include "particleType.h" + +#include "TCanvas.h" + +class Reaction{ + + public: + Reaction(); + Reaction(TString); + ~Reaction(); + + void process_reaction(); + TString GetParticle() {return rParticle;}; + + protected: + TStopwatch tTime; + TString rParticle; + +}; + + +class PiPlus_Production { + + public: + PiPlus_Production(); + PiPlus_Production(TString); + ~PiPlus_Production(); + + void process_reaction(); + TString GetParticle() {return rParticle;}; + + protected: + + void Init(); + void Processing_Event(); + void Progress_Report(); + void Detail_Output(); + void Lund_Output(); + + TRandom2* rRand; + + Particle_t recoil_nucleon; + Particle_t produced_X; + + Double_t Get_Phi_X_LeptonPlane_RF(); + Double_t Get_Phi_TargPol_LeptonPlane_RF(); + + Double_t Get_Total_Cross_Section(); + + Double_t GetPi0_CrossSection(); + Double_t GetPiPlus_CrossSection(); + + /*--------------------------------------------------*/ + // Parameters + + TStopwatch tTime; + TString rParticle; + TString rParticle_charge; + TString rParticle_scat_nucleon; + + std::string sTFile; /// Generator output files. For documentation and monitoring purposes + std::string sLFile; /// Lund input file into the EIC simulation + + std::ofstream ppiOut; + std::ofstream ppiDetails; + + int qsq_ev, t_ev, w_neg_ev, w_ev; + + long long int rNEvents; + long long int rNEvent_itt; + TDatime dFractTime; + + double rDEG2RAD; + + double fX_Theta_I, fX_Theta_F; + + TLorentzVector GetProtonVector_lab(); + TLorentzVector GetElectronVector_lab(); + + TLorentzVector r_lproton; // Proton in collider (lab) frame + TLorentzVector r_lprotong; + + TLorentzVector r_lelectron; // Electron in collider (lab) frame + TLorentzVector r_lelectrong; + + TVector3 beta_col_rf; // Boost vector from collider (lab) frame to protons rest frame (Fix target) + + void Consider_Proton_Fermi_Momentum(); + + Double_t rFermiMomentum; + + Double_t fX_Theta_Col, fX_Phi_Col; + + TLorentzVector r_lscatelec; + TLorentzVector r_lscatelecg; + + TLorentzVector r_lphoton; + TLorentzVector r_lphotong; + + TLorentzVector r_lX; + TLorentzVector r_lX_g; + + double fX_Mass; + double fX_Mass_GeV; + + double f_Scat_Nucleon_Mass; + double f_Scat_Nucleon_Mass_GeV; + + TLorentzVector r_l_scat_nucleon; + TLorentzVector r_l_scat_nucleon_g; + + TLorentzVector r_lw; + + TLorentzVector lwp; + + TLorentzVector fsini; + TLorentzVector fsfin; + TLorentzVector fsinig; + TLorentzVector fsfing; + + pim* pd; + + /////////////////////////////////////////// + //Transformation of e', pi- and recoil proton to target's rest frmae without energy loss + + TLorentzVector lproton_rf; + TLorentzVector lproton_rfg; + + TLorentzVector lelectron_rf; + TLorentzVector lelectron_rfg; + + TLorentzVector lscatelec_rf; + TLorentzVector lscatelec_rfg; + + TLorentzVector lphoton_rf; + TLorentzVector lphoton_rfg; + + TLorentzVector lX_rf; + TLorentzVector lX_rfg; + + TLorentzVector l_scat_nucleon_rf; + TLorentzVector l_scat_nucleon_rf_g; + + + /////////////////////////////////////////// + /// Center of Mass parameters for particle X + + double fBeta_CM_RF, fGamma_CM_RF, fX_Energy_CM, fX_Mom_CM, fX_Energy_CM_GeV, fX_Mom_CM_GeV; + + TLorentzVector lt; + TLorentzVector ltg; + + + /////////////////////////////////////////// + + TVector3 v3Photon; + TVector3 v3Electron; + TVector3 v3X; + TVector3 v3S; + TVector3 v3PhotonUnit; + TVector3 v3QxL; + TVector3 v3QxP; + TVector3 v3QxS; + TVector3 v3LxP; + TVector3 v3LxS; + TVector3 v3PxL; + TVector3 v3QUnitxL; + TVector3 v3QUnitxP; + TVector3 v3QUnitxS; + + double fCos_Phi_X_LeptonPlane_RF, fSin_Phi_X_LeptonPlane_RF, fTheta_X_Photon_RF, fPhi_X_LeptonPlane_RF; + + + Double_t r_fSig; + Double_t r_fSig_T; + Double_t r_fSig_L; + + void PiPlus_Pythia6_Out_Init(); + void PiPlus_Pythia6_Output(); + + unsigned long long int print_itt; + +}; + + + + +// +//class PiPlus_Production: public virtual Reaction{ +// +// public: +// PiPlus_Production(); +// PiPlus_Production(TString); +// ~PiPlus_Production(); +// +// void process_reaction(); +// void Lund_Output(); +// +// protected: +// +// void Init(); +// void Processing_Event(); +// void Progress_Report(); +// void Detail_Output(); +// +// +// +// +//// } +// + +class Pi0_Production:PiPlus_Production{ + + public: + Pi0_Production(); + Pi0_Production(TString); + ~Pi0_Production(); + + void process_reaction(); + void Detail_Output(); + void Processing_Event(); + Double_t Get_CrossSection(); + + void Pi0_decay(TLorentzVector); + + bool if_pi0_decay; + + void Pi0_Decay_Pythia6_Out_Init(); + void Pi0_Decay_Pythia6_Output(); + + unsigned long long int print_itt; + + private: + + Double_t theta_X_rf; + + Double_t ft_min; + Double_t fu_min; + + Double_t ft; + Double_t fu; + + std::ofstream polar_out; + + TLorentzVector l_photon_1; + TLorentzVector l_photon_2; + + void Pi0_Lund_Output(); + void Pi0_Decay_Lund_Output(); + +// template +// inline int +// sgn(T val) { +// return (T(0) < val) - (val < T(0)); +// } + + template + T Sign (T a, T b) { + return (a < b) - (b < a); + } + +}; + + + +# endif diff --git a/src/eic_evgen/tssa_sig_Para.o b/src/eic_evgen/tssa_sig_Para.o index f8ff453..92fe4ea 100644 Binary files a/src/eic_evgen/tssa_sig_Para.o and b/src/eic_evgen/tssa_sig_Para.o differ diff --git a/src/main.cxx b/src/main.cxx index a6edd02..66275d8 100644 --- a/src/main.cxx +++ b/src/main.cxx @@ -50,6 +50,7 @@ #include "eic_evgen/eic.h" + using namespace std; using namespace constants; @@ -59,6 +60,7 @@ Json::Value obj; //Declared here for global access string get_date(void); +int Gen_seed; int main(int argc, char** argv){ @@ -68,7 +70,9 @@ int main(int argc, char** argv){ Json::Reader reader; reader.parse(ifs, obj); - int nEvents = obj["n_events"].asInt(); +// int nEvents = obj["n_events"].asInt(); +// int nEvents = obj["n_events"].asUInt64(); + unsigned long long int nEvents = obj["n_events"].asUInt64(); cout << "Generating "<< nEvents << " events."<