// edition 2.03.2012 A.Galoyan // main.cc,v 1.18 2004/03/04 15:09:11 ritman Exp $ // // C++ program to call DPM event generator for PBAP P interactions // Original author: A.Galoyan // change to TParticle output format J.Ritman May 2003 /* ------------------------------------------------------- */ #include #include #include #include #include "TROOT.h" #include "TFile.h" #include "TClonesArray.h" #include "TTree.h" #include "TStopwatch.h" #include "TParticle.h" #include extern struct { int n, k[2000]; float p[5000]; } lujets_; // n - number of produced particles, // k[] - Pythia particle identifiers // p[] - kinematical characteristics of particles // extern "C" int init1_(float* Plab, double* seed, float* Elastic, // float* tetmin); // to install DPM generator // extern "C" int dpm_gen__(float* Generator, double* seed); //to generate events extern "C" int init1_(double* Plab, double* seed, double* Elastic, double* tetmin); // to install DPM generator extern "C" int dpm_gen_(double* Generator, double* seed); //to generate events int convertStringToUInt(char *s, unsigned int &i) { char* p = s; errno = 0; i = strtoul(s, &p, 10); if (errno != 0) { std::cerr<<"conversion failed (EINVAL, ERANGE)\n"; return 1; } if (s == p) { std::cerr<<"conversion failed (no characters consumed)\n"; return 1; } if (*p != 0) { std::cerr<<"conversion failed (trailing data)\n"; return 1; } return 0; } int convertStringToDouble(char *s, double &d) { char* p = s; errno = 0; d = strtod(s, &p); if (errno != 0) { std::cerr<<"conversion failed (EINVAL, ERANGE)\n"; return 1; } if (s == p) { std::cerr<<"conversion failed (no characters consumed)\n"; return 1; } if (*p != 0) { std::cerr<<"conversion failed (trailing data)\n"; return 1; } return 0; } // int main() int main(int argc, char* argv[]) { // float Plab, Elastic, tetmin; // Plab - PBAP momentum in Lab.Sys. // double seed; // int ntot, Ieven, npart, i; // double Px[1000],Py[1000],Pz[1000],E[1000],Pm[1000],Wh[1000]; // int Id[1000]; double Plab, tetmin; // Plab - PBAP momentum in Lab.Sys. double seed; unsigned int ntot, Ieven, npart, i, Elastic; double Px[1000],Py[1000],Pz[1000],E[1000],Pm[1000],Wh[1000]; int Id[1000]; // Elastic=0.; // No elastic scattering, only inelastic Elastic=1. ; // Elastic and inelastic interactions // Elastic=2.; // Only elastic scattering, no inelastic one char rootfile_name[200] = "Background-micro.root"; // ok first of all parse arguments int seed_flag =0, mom_flag = 0, elastic_flag = 0, thetamin_flag = 0, num_flag = 0, file_flag = 0; int c; char *seed_value = NULL, *mom_value = NULL, *elastic_value = NULL, *thetamin_value = NULL, *num_value = NULL, *file_value = NULL; while ((c = getopt (argc, argv, "hs:m:e:t:n:f:")) != -1) { switch (c) { case 'h': // display help and exit std::cout<<"Following options are available: \n"; std::cout<<"-h flag: display this help "<Branch("Npart",&activeCnt,"Npart/I"); fTree->Branch("Weigth",&weight,"Weight/D"); fTree->Branch("Seed",&seed,"Weight/D"); fTree->Branch("Particles",&fEvt, 32000,99); // std::cout<<" Give as seed a large float number (eg. 123456.): "; // std::cin>>seed; // if (!seed){ // if the seed is 0 then take the time // Long_t Time = time(NULL); // int a = Time/100000; // seed = Time - a*100000 + a/100000.; // } // std::cout << " Enter P_lab(GeV/c), "; // std::cin >> Plab ; // std::cout << " Enter Elastic : 0., 1. or 2. " << "\n" << // "0. - No elastic scattering, only inelastic"<< "\n" << // "1. - Elastic and inelastic interactions" << "\n" << // "2. - Only elastic scattering, no inelastic one"<< "\n"; // std::cin >> Elastic ; // if((Elastic==1.) || (Elastic==2.)) // { // std::cout << " Teta_min (degree) "; // std::cin >> tetmin; // } // else {tetmin=0;} // init1_(&Plab,&seed,&Elastic, &tetmin); // installation of the DPM generator // std::cout << " Enter N_Events "; // std::cin >> ntot; if(!seed_flag) { std::cout<<" Give as seed a large float number (eg. 123456.): "; std::cin>>seed; } if (!seed){ // if the seed is 0 then take the time Long_t Time = time(NULL); int a = Time/100000; seed = Time - a*100000 + a/100000.; } if(!mom_flag) { std::cout << " Enter P_lab(GeV/c), "; std::cin >> Plab ; } if(!elastic_flag) { std::cout << " Enter Elastic : 0., 1. or 2. " << "\n" << "0. - No elastic scattering, only inelastic"<< "\n" << "1. - Elastic and inelastic interactions" << "\n" << "2. - Only elastic scattering, no inelastic one"<< "\n"; std::cin >> Elastic ; } if((Elastic==1) || (Elastic==2)) { if(!thetamin_flag) { std::cout << " Teta_min (degree) "; std::cin >> tetmin; } } else {tetmin=0;} double Plabf, Elasticf, tetminf; Plabf = (double)Plab; Elasticf = (double)Elastic; tetminf = (double)tetmin; if(!num_flag) { std::cout << " Enter N_Events "; std::cin >> ntot; } std::cout<<"Using following options: \n"; std::cout<<"-s flag: random seed number: "<Fill(); } timer.Stop(); std::cout << " ----- Realtime: "<