Skip to content

Commit

Permalink
Merge pull request #10 from JeffersonLab/develop
Browse files Browse the repository at this point in the history
Merge in Develop to Master
  • Loading branch information
billlee77 authored Jun 1, 2023
2 parents a357cfc + 68e18ce commit 835e48e
Show file tree
Hide file tree
Showing 47 changed files with 7,907 additions and 1,903 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ 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" "src/eic_evgen/reaction_routine.cc" "src/eic_evgen/legacy_function.cc" "src/eic_evgen/legacy_function.cc" "src/eic_evgen/process_routine/*")
file(GLOB SOURCES "src/*" "src/eic_evgen/eic.cc" "src/eic_evgen/eic_pim.cc" "src/eic_evgen/PiPlus_sig_Param.cc" "src/eic_evgen/reaction_routine.cc" "src/eic_evgen/PiPlus_sig.cc" "src/eic_evgen/KPlus_sig.cc" "src/eic_evgen/KPlus_sig_Scaling.cc" "src/eic_evgen/process_routine/*")
# file(GLOB SOURCES "src/*.cpp")

message("Root Include Dirs: " ${ROOT_INCLUDE_DIRS})
Expand Down
18 changes: 11 additions & 7 deletions Config_EIC.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,22 @@

"file_name" : "DEMPGen_EIC_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": "Pion+", // Choices: omega, pi+, pi0, K+
"hadron": "", // Choices: Empty OR Lambda or Sigma0 - For K+ production only!
"hadron": "neutron", // Choices: Neutron, proton, Lambda or Sigma0
"ebeam": 5, // Electron beam energy in GeV
"hbeam": 41, // Hadron beam energy in GeV
//"hbeam_part":"proton", // Hadron beam particle, proton, deut or helium3, work in progress, will need to be added to shell script later on as an argument
"det_location": "ip8", // choices: ip6 for STAR, ip8 for PHENIX
"OutputType": "Pythia6", // choices: LUND (Docker), Pythia6 (ECCE Fun4All) or HEPMC3 (Athena)
"hbeam": 100, // Hadron beam energy in GeV
"hbeam_part":"Proton", // Hadron beam particle, proton, deut or helium3, work in progress, will need to be added to shell script later on as an argument
"OutputType": "HEPMC3", // choices: LUND (Docker), Pythia6 (ECCE Fun4All) or HEPMC3 (Athena)
"det_location": "ip6", // choices: ip6 for STAR, ip8 for PHENIX
"Ee_Low": 0.5, // The minimum scattered electron energy that will be generated as a fraction of the electron beam energy
"Ee_High": 2.5, // The maximum scattered electron energy that will be generated as a fraction of the electron beam energy
"e_Theta_Low": 60.0, // The minimum scattered electron angle (theta) that will be generated in degrees
"e_Theta_High": 175.0, // The maximum scattered electron angle (theta) that will be generated in degrees
"EjectileX_Theta_Low": 0.0, // The minimum ejectile angle (theta) that will be generated in degrees
"EjectileX_Theta_High": 50.0, // The maximum ejectile angle (theta) that will be generated in degrees
}
33 changes: 33 additions & 0 deletions Config_SoLID.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
//Config
// All values should use units of MeV for energies and momenta,
// and degrees for angles.
// n_events indicates number of attempts
// SJDK 17/06/22 - This is an old .json I found from DEMPEvGen, I believe these are still valid options for DEMPGen
"experiment" : "solid",
"output_file" : "Test.root",
"n_events" : 10000,
"particle": "Pion+",
"beam_energy": 11000,
"targ_pol_x": 0.865,
"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
}
265 changes: 265 additions & 0 deletions HEPMC3_Converter.C
Original file line number Diff line number Diff line change
@@ -0,0 +1,265 @@
// Original file from Love Preet, University of Regina
// This file converts nEvents from an input HEPMC3 file (raw from DEMPGen or afterburned) into an output root tree.
// Modified on - 04/03/23 - by Stephen JD Kay University of Regina

#define HEPMC3_Converter_cxx

// Include relevant stuff
#include <TStyle.h>
#include <TCanvas.h>
#include <TLine.h>
#include <TMath.h>
#include <TPaveText.h>
#include <TGaxis.h>
#include <iostream>
#include <fstream>
#include <string>
#include <stdio.h>
#include <TSystem.h>
#include <TTree.h>

// SJDK - 04/03/23 - Read in a few things as arguments
void HEPMC3_Converter(Long_t nEvents = -1, string InputHEPMC3File = "", string OutputRootFile = "", string FileType = ""){

// 04/04/23 - SJDK - Explicitly set batch mode so it doesn't spam stuff to screen
gROOT->SetBatch(kTRUE);

// SJDK - 04/03/23 - Explicitly require 3 input arguments
if(nEvents == -1){
cout << "Enter a the number of events to convert: ";
cin >> nEvents;
if( nEvents<=0 ) return;
}

if(InputHEPMC3File == ""){
cout << "Enter a HEPMC3 file to convert: ";
cin >> InputHEPMC3File;
}

if(OutputRootFile == "") {
cout << "Enter a root file to write to: ";
cin >> OutputRootFile;
}
if(FileType == ""){
cout << "File type not specified, enter raw or AB. Raw for DEMPGen output, AB for afterburned files." << endl << "Defaulting to raw." << endl;
FileType = "raw";
}
else if (FileType != "raw" && FileType != "AB"){
cout << "Invalid file type specified, enter only raw or AB. Defaulting to raw." << endl;
FileType = "raw";
}

Long_t nSkip; // SJDK - 04/04/23 - Number of lines to skip, depends upon file type
if (FileType == "raw"){
nSkip = 2;
}
else if (FileType == "AB"){
nSkip = 21;
}

TString TInputHEPMC3File = InputHEPMC3File;
TString TOutputRootFile = OutputRootFile;

if (gSystem->AccessPathName(TInputHEPMC3File) == kTRUE){
cerr << "!!!!! ERROR !!!!! " << endl << TInputHEPMC3File << " not found" << endl << "!!!!! ERRROR !!!!!" << endl;
exit;
}

fstream HEPMC3In;
HEPMC3In.open(TInputHEPMC3File, ios::in);

//.............................................................................................................................................
// Stored the whole file in a vector
//.............................................................................................................................................
string s;
vector<string> v;
Long_t nLines = 0;
Long_t nEvents_read = 0;

for (Long_t i = 0; i <nSkip; i++){ // Skip the first 21 lines - NOTE - Only valid for afterburner!
getline(HEPMC3In,s);
}

while(getline(HEPMC3In,s)){
nLines++;
if (HEPMC3In.eof()) break;
v.push_back(s); // store all the file to the vector
}

if (FileType == "raw"){
nEvents_read = nLines/9; // 04/04/23 - Number of events in the file is the number of lines read divided by 9 (each event is 9 lines)
}

else if (FileType == "AB"){
nEvents_read = (nLines-2)/9; // 04/04/23 - Number of events in the file is the number of lines read (-2, AB has two tailing lines) divided by 9 (each event is 9 lines)
}

HEPMC3In.close();

// 04/04/23 - Check number of events doesn't exceed number in the file!
if (nEvents > nEvents_read){
cerr << "!!!!! ERROR !!!!! " << endl << "Requested to process more events - ("<< nEvents << ") than are actually in the file - (" << nEvents_read << ")" << endl << "Double check and try again!" << endl << "!!!!! ERRROR !!!!!" << endl;
exit;
}
else if (nEvents != nEvents_read){
cout << endl << "!!!!! NOTICE !!!!!" << endl << "Requested number of events to process is SMALLER than the number of events in the file, this is fine, but re-run if you want all events." << endl;
cout << "There are - " << nEvents_read << " in your input HEPMC3 file" << endl << "!!!!! NOTICE !!!!!" << endl << endl;
}

//.............................................................................................................................................
// Getting the values from the vector
//.............................................................................................................................................
vector<double> weight;
string w1,w2; // columns in the weight line
double w3,w4; // colums in the weight line

vector<double> e_px;
vector<double> e_py;
vector<double> e_pz;
vector<double> e_E;
string l_e; // columns in the outgoing electron line
double id_e,vid_e,pdg_e,px_e,py_e,pz_e,en_e,m_e,s_e; // columns in the outgoing electron line

vector<double> k_px;
vector<double> k_py;
vector<double> k_pz;
vector<double> k_E;
string l_k; // columns in the outgoing kaon line
double id_k,vid_k,pdg_k,px_k,py_k,pz_k,en_k,m_k,s_k; // columns in the outgoing kaon line

vector<double> l_px;
vector<double> l_py;
vector<double> l_pz;
vector<double> l_E;
string l_l; // columns in the outgoing lambda line
double id_l,vid_l,pdg_l,px_l,py_l,pz_l,en_l,m_l,s_l; // columns in the outgoing lambda line
if(nEvents <= nEvents_read){ // Only process if less than or equal to the # events in the file
for(int i=0; i<nEvents; i++){ // Loop over the number of events

//.............................................................................................................................................
int w=(2+(i*9)); // Accessing the weights line from the whole file
// cout<<v[2]<<" "<<endl;

stringstream weight_l; // Extract the doubles from the vector using stringstream (accessing the weight line for each event)

weight_l << v[w]; // store the vector to string stream

while (! weight_l.eof()) {

weight_l >>w1>>w3>>w2>>w4;
weight.push_back(w4);

}

int o_e=(6+(i*9)); // Accessing the outgoing particle(i.e.electron) line from the whole file

stringstream o_e_l; // Extract the doubles from the vector using stringstream (accessing the outgoing particle line for each event)


o_e_l << v[o_e]; // store the vector to string stream

//cout << o_e_l.str() <<endl;

while (! o_e_l.eof()) {

o_e_l>>l_e>>id_e>>vid_e>>pdg_e>>px_e>>py_e>>pz_e>>en_e>>m_e>>s_e;
//cout<<" "<<px_e<<endl;

e_px.push_back(px_e);
e_py.push_back(py_e);
e_pz.push_back(pz_e);
e_E.push_back(en_e);
}
//.............................................................................................................................................
int o_k=(7+(i*9)); // Accessing the outgoing particle(i.e.kaon) line from the whole file

stringstream o_k_l; // Extract the doubles from the vector using stringstream (accessing the outgoing particle line for each event)

o_k_l << v[o_k]; // store the vector to string stream

while (! o_k_l.eof()) {

o_k_l >>l_k>>id_k>>vid_k>>pdg_k>>px_k>>py_k>>pz_k>>en_k>>m_k>>s_k;
k_px.push_back(px_k);
k_py.push_back(py_k);
k_pz.push_back(pz_k);
k_E.push_back(en_k);
}
//.............................................................................................................................................
int o_l=(8+(i*9)); // Accessing the outgoing particle(i.e.lambda) line from the whole file

stringstream o_l_l; // Extract the doubles from the vector using stringstream (accessing the outgoing particle line for each event)

o_l_l << v[o_l]; // store the vector to string stream

while (! o_l_l.eof()) {

o_l_l >>l_l>>id_l>>vid_l>>pdg_l>>px_l>>py_l>>pz_l>>en_l>>m_l>>s_l;
l_px.push_back(px_l);
l_py.push_back(py_l);
l_pz.push_back(pz_l);
l_E.push_back(en_l);
}
}//-> End of for loop over the events

//.............................................................................................................................................
// Storing the weights in Root TTree
//.............................................................................................................................................

double w_gp,e_px_gp,e_py_gp,e_pz_gp,e_E_gp;
double k_px_gp,k_py_gp,k_pz_gp,k_E_gp;
double l_px_gp,l_py_gp,l_pz_gp,l_E_gp;

TFile *OutputFile = new TFile(TOutputRootFile,"RECREATE");

TTree *tree = new TTree("Truth_Events","Truth_Events");

tree->Branch("w_gp", &w_gp); // weights of generated particles

tree->Branch("e_px_gp", &e_px_gp); // momentum of generated particles (i.e. electrons)
tree->Branch("e_py_gp", &e_py_gp);
tree->Branch("e_pz_gp", &e_pz_gp);
tree->Branch("e_E_gp", &e_E_gp);

tree->Branch("k_px_gp", &k_px_gp); // momentum of generated particles (i.e. kaons)
tree->Branch("k_py_gp", &k_py_gp);
tree->Branch("k_pz_gp", &k_pz_gp);
tree->Branch("k_E_gp", &k_E_gp);

tree->Branch("l_px_gp", &l_px_gp); // momentum of generated particles (i.e. lambdas)
tree->Branch("l_py_gp", &l_py_gp);
tree->Branch("l_pz_gp", &l_pz_gp);
tree->Branch("l_E_gp", &l_E_gp);


for (int j=0; j<nEvents; j++) {

w_gp = weight[j];

e_px_gp = e_px[j];
e_py_gp = e_py[j];
e_pz_gp = e_pz[j];
e_E_gp = e_E[j];

k_px_gp = k_px[j];
k_py_gp = k_py[j];
k_pz_gp = k_pz[j];
k_E_gp = k_E[j];

l_px_gp = l_px[j];
l_py_gp = l_py[j];
l_pz_gp = l_pz[j];
l_E_gp = l_E[j];

tree->Fill();
}

//OutputFile->Print(); // 04/04/23 - Don't print to screen to prevent spam when running
OutputFile->Write();
OutputFile->Close();

cout << "Created output root file - " << TOutputRootFile << " - sucessfully." <<endl;
cout << "Bye!" << endl;
exit;
}
} //-> Main void End
6 changes: 2 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ Event generator for Deep Exclusive Meson Production

- cd data/
- ./../build/DEMPgen ../Config.json
- Data will be saved under data/OutputFiles/ , the default format is in HEMPC3 Ascii format.

### Building on the iFarm

Expand Down Expand Up @@ -154,9 +155,6 @@ The jobs the script creates and submits all execute the Process_EIC.csh script d

- This version should be used to submit jobs to the Farm batch queueing system (swif2)
- It uses the same arguments as Batch_Submission_EIC.sh
- Before running, ensure you have a folder or sym link for LundFiles
- data/LundFiles
- This must exist for output!
- You should also check the paths set throughout the script look ok (for example, in the COMMAND: ... line)
- By default, /eic/users/${USER}/DEMPGen is assumed

Expand All @@ -165,4 +163,4 @@ The jobs the script creates and submits all execute the Process_EIC.csh script d
- There were several .json files clogging up the main directory, many of these were very outdated. As such, I've moved them all to a subfolder -
- json_examples
- This folder has .json config files for a variety of different conditions.
- Due to several of them being quite outdated, the Config_EIC.json file in the main (the directory of this README) directory should be consulted to see the options that are actually availble.
- Due to several of them being quite outdated, the Config_EIC.json file in the main (the directory of this README) directory should be consulted to see the options that are actually available.
14 changes: 0 additions & 14 deletions data/performance_difference

This file was deleted.

8 changes: 0 additions & 8 deletions data/test.txt

This file was deleted.

2 changes: 1 addition & 1 deletion json_examples/Config.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"prod_pion_thetamin": 5.0,
"prod_pion_thetamax": 20.0,
"multiple_scattering": false,
"ionization": false,
"ionisation": false,
"bremsstrahlung": false,
"final_state_interaction": false,
"fermi_momentum": false,
Expand Down
Loading

0 comments on commit 835e48e

Please sign in to comment.