/* *MM MM UU UU PPPPPPPPPPP AAAAAAAAAA GGGGGGGGGG EEEEEEEEEEEE *MMM MMM UU UU PPPPPPPPPPPP AAAAAAAAAAAA GGGGGGGGGGGG EEEEEEEEEEEE *MMMM MMMM UU UU PP PP AA AA GG GG EE *MM MM MM MM UU UU PP PP AA AA GG EE *MM MMMM MM UU UU PP PP AA AA GG EE *MM MM MM UU UU PPPPPPPPPPPP AAAAAAAAAAAA GG EEEEEEEE *MM MM UU UU PPPPPPPPPPP AAAAAAAAAAAA GG GGGGG EEEEEEEE *MM MM UU UU PP AA AA GG GGGGG EE *MM MM UU UU PP AA AA GG GG EE *MM MM UU UU PP AA AA GG GG EE *MM MM UUUUUUUUUUUU PP AA AA GGGGGGGGGGGG EEEEEEEEEEEE *MM MM UUUUUUUUUU PP AA AA GGGGGGGGGG EEEEEEEEEEEE * *@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ * * Author: G.Carminati * Version: v3r5 - 16th April 2010 * */ #include #include #include #include #include #include #include #include #include "Parameters.hh" #include "Date.hh" #include "Muons.hh" #include "Decode.hh" //#include "TRandom3.h" #ifdef HAVE_IOGCC #include "io_gcc.hh" /* by J.Brunner */ #endif #ifdef HAVE_DETECTOR #include "ReadDetector.hh" #endif //#ifndef STOC_BASE #include "../RandomC/randomc.h" //enables random number generators (1) // #include "../RandomC/mersenne.cpp" //Mersenne Twister random number generator (1) // #define STOC_BASE CRandomMersenne // base class random number generator (1) #include "../RandomC/stocc.h" // define random library classes // #include "../RandomC/stoc1.cpp" // random library source code // #include "../RandomC/userintf.cpp" // define system specific user interface // #define RANDOM_GENERATOR TRandomMersenne // defines the generator to use; 'Mersenne Twister' //#endif using namespace std; int main(int argc, char** argv) { /* information for execution */ lib_io = true; lib_det = false; histo = false; Decode dec; int nerr = dec.CommandLine(argc, argv); if(nerr < 0) { std::cout << dec.ErrorCommandLine(); exit(3); } int nerror = 0; nerror = dec.DecodeParameters(); if(nerror > 0) { std::cout << dec.ErrorDecoder(nerror); exit(2); } else if(nerror < 0) { std::cout << dec.ErrorOpenFiles(nerror); exit(1); } /* opening output files */ ofstream fout, livetime_fout; fout.open(OutputFileName.c_str(), std::ios::out); livetime_fout.open(LivetimeFileName.c_str(), std::ios::out); if (fout.fail() ) { nerror = -98; std::cout << dec.ErrorOpenFiles(nerror); exit(1); } if (livetime_fout.fail() ) { nerror = -97; std::cout << dec.ErrorOpenFiles(nerror); exit(1); } /* seeds definition */ if(seed == 0) seed = time(NULL); /* TRandom3 genphi(seed); TRandom3 genm(seed++); TRandom3 gentheta(seed+2); TRandom3 genu(seed+3); TRandom3 gen(seed+4); */ CRandomMersenne genphi(seed); CRandomMersenne genm(seed++); CRandomMersenne gentheta(seed+2); CRandomMersenne genu(seed+3); CRandomMersenne gen(seed+4); /* Load geometry data from the detector file */ if (lib_det) { #ifdef HAVE_DETECTOR ReadDetector detector(DetectorFileName); DEPTHmax = detector.surface_z * MeterToKm(); Vec3D cog = detector.compute_cg(); double z_min = 0.; double z_max = 0.; Vec2D z_det(z_min, z_max); double r_det = 0.; double OffSet = 0.; double h_can = 0.; double r_can = 0.; /* read from detector file the dimension of detector */ r_det = detector.compute_radius(cog); z_det = detector.compute_Z(cog); /* compute from detector file the minimum and the maximum value of CAN z-coordinate and compute the CAN radius */ OffSet = fabs(NAbsLength*AbsLength); z_min = max(detector.ground_z-cog.z, z_det.x-OffSet); z_max = min(detector.surface_z-cog.z, z_det.y+OffSet); h_can = z_max - z_min; r_can = r_det + OffSet; Zmin = z_min; Zmax = z_max; CANr = r_can; CANh = h_can; #endif } /* create parameters for the CAN */ Vec3D can(Zmin, Zmax, CANr); if(!lib_det) CANh = CANheight(); /* the CAN have to be enlarged to avoid losing events */ Vec3D enlargedCAN(can.x, can.y, can.z+EnlargedCANr); /* check on vertical depth values */ if (weDEPTHmin() < 1.5 || weDEPTHmin() > 5.) { nerror = 6; std::cout << dec.ErrorDecoder(nerror); exit(2); } if (weDEPTHmax() < 1.5 || weDEPTHmax() > 5.) { nerror = 7; std::cout << dec.ErrorDecoder(nerror); exit(2); } /* definition for io_gcc */ #ifdef HAVE_IOGCC event evt; /* set start-of-run condition */ int ierr = 0; unsigned int nrun = atoi(&numrun[0]); evt.defrun(nrun); unsigned int position = 20 + numrun.size(); unsigned int position2 = 0; /* set date and hour of execution */ Date d; std::string date_clock1; std::string dc = d.date_clock(date_clock1); #endif /* write start_run */ if(lib_io) { #ifdef HAVE_IOGCC std::string flag = "physics"; std::ostringstream inf; inf << setiosflags(std::ios::showpoint) << setiosflags(std::ios::fixed) << std::setprecision(3) << " HEMAS-DPM 07.01 \n" << "propag: MUSIC seawater 02.03\n" << "simul: MUPAGE "< j && thetaSG * RadToDeg() <= j+1) ++(ncounter[j]); } } /* WARNING: Accordling with the switching of the azimuthal angle, * the zenithal angle must be switched into * theta_mu = 180 degrees - zenith */ thetaDF = pi - thetaSG; /* in rad */ ctDF = cos(thetaDF); stDF = sin(thetaDF); muon.Set(thetaSG, phi, m, wedepthBundle); /* unit vector (i.e. direction cosines) of Bundle Axis */ double cf = cos(phi); double sf = sin(phi); Vec3D uBundle(stDF*cf, stDF*sf, ctDF); if (m == 1) /* single muons */ { const double t = 0.; /* compute the energy of single muon */ double e = muon.HoR_Energy_singlemu(); /* in TeV */ /* check if the generated energy is greater than the energy of threshold */ if (e >= Ethreshold) { /* write event in ANTARES format */ if (lib_io) { #ifdef HAVE_IOGCC std::ostringstream ch_bundle; ch_bundle << setiosflags(std::ios::showpoint) << setiosflags(std::ios::fixed) << std::setprecision(3) << std::setw(3) << m << std::setw(10) << posBundle.x << std::setw(10) << posBundle.y << std::setw(10) << posBundle.z << std::setiosflags(std::ios::fixed) << std::setprecision(6) << std::setw(12) << uBundle.x << std::setw(12) << uBundle.y << std::setw(12) << uBundle.z; std::ostringstream ch_track; ch_track << setiosflags(std::ios::showpoint) << setiosflags(std::ios::fixed) << std::setprecision(3) << std::setw(3) << m << std::setw(10) << posBundle.x << std::setw(10) << posBundle.y << std::setw(10) << posBundle.z << std::setiosflags(std::ios::fixed) << std::setprecision(6) << std::setw(12) << uBundle.x << std::setw(12) << uBundle.y << std::setw(12) << uBundle.z << setiosflags(std::ios::fixed) << std::setprecision(3) << std::setw(11) << e*TeVtoGeV() << std::setw(10) << t << std::setw(4) << GEANTid; evt.taga(bundle, ch_bundle.str() ); evt.taga(tag, ch_track.str()); ierr = evt.write(fout); if (ierr != 0) std::cout << "Error : Writing header event " << ierr << std::endl; #endif } else /* write event in a formatted ASCII table */ { fout.setf(std::ios::showpoint|std::ios::fixed); fout <= Ethreshold) { /* write event in ANTARES format */ if (lib_io) { #ifdef HAVE_IOGCC std::ostringstream ch_bundle; ch_bundle << setiosflags(std::ios::showpoint) << setiosflags(std::ios::fixed) << std::setprecision(3) << std::setw(3) << m << std::setw(10) << posBundle.x << std::setw(10) << posBundle.y << std::setw(10) << posBundle.z << std::setiosflags(std::ios::fixed) << std::setprecision(6) << std::setw(12) << uBundle.x << std::setw(12) << uBundle.y << std::setw(12) << uBundle.z; evt.taga(bundle, ch_bundle.str() ); int ierr = evt.write(fout); if (ierr != 0) std::cout << "Error : Writing header event " << ierr << std::endl; #endif } else /* write event in ASCII table */ { for (unsigned int ll = 0; ll < m; ++ll) { if((float)E[ll] != 0) { fout.setf(std::ios::showpoint|std::ios::fixed); fout <