// Macro for running Panda simulation with Geant3 or Geant4 (M. Al-Turany) // This macro is supposed to run the full simulation of the panda detector // to run the macro: // root sim_complete.C or in root session root>.x sim_complete_stt.C // to run with different options:(e.g more events, different momentum, Geant4) // root sim_complete.C"(100, "TGeant4",2)" sim_complete(Int_t nEvents = 100, TString SimEngine ="TGeant3", Float_t mom = 6.231552) { //-----User Settings:----------------------------------------------- TString OutputFile = "sim_complete.root"; TString ParOutputfile = "simparams.root"; TString MediaFile = "media_pnd.geo"; gDebug = 0; TString digiFile = "all.par"; //The emc run the hit producer directly Bool_t UseBoxGenerator = kTRUE; Double_t BeamMomentum = 15.; // beam momentum ONLY for the scaling of the dipole field. //------------------------------------------------------------------ TStopwatch timer; timer.Start(); gRandom->SetSeed(); // Create the Simulation run manager-------------------------------- FairRunSim *fRun = new FairRunSim(); fRun->SetName(SimEngine.Data() ); fRun->SetOutputFile(OutputFile.Data()); fRun->SetWriteRunInfoFile(kFALSE); fRun->SetBeamMom(BeamMomentum); fRun->SetMaterials(MediaFile.Data()); FairRuntimeDb *rtdb=fRun->GetRuntimeDb(); // Set the parameters //------------------------------- TString allDigiFile = gSystem->Getenv("VMCWORKDIR"); allDigiFile += "/macro/params/"; allDigiFile += digiFile; // //-------Set the parameter output -------------------- // FairParAsciiFileIo* parIo1 = new FairParAsciiFileIo(); // parIo1->open(allDigiFile.Data(),"in"); // rtdb->setFirstInput(parIo1); //---------------------Set Parameter output ---------- Bool_t kParameterMerged=kTRUE; FairParRootFileIo* output=new FairParRootFileIo(kParameterMerged); output->open(ParOutputfile.Data()); rtdb->setOutput(output); // Create and add detectors //------------------------- CAVE ----------------- FairModule *Cave= new PndCave("CAVE"); Cave->SetGeometryFileName("pndcave.geo"); fRun->AddModule(Cave); //------------------------- STT ----------------- FairDetector *SttExp = new PndStt("STT", kTRUE); SttExp->SetGeometryFileName("straw_prototype_beam.geo"); fRun->AddModule(SttExp); // Create and Set Event Generator //------------------------------- FairPrimaryGenerator* primGen = new FairPrimaryGenerator(); fRun->SetGenerator(primGen); // Box Generator FairBoxGenerator* boxGen = new FairBoxGenerator(2212, 2); // 13 = muon; 1 = multipl. boxGen->SetPRange(1.); // GeV/c boxGen->SetPhiRange(0., 360.); // Azimuth angle range [degree] boxGen->SetThetaRange(-4.57,4.57); // Polar angle in lab system range [degree] 4.57 // boxGen->SetXYZ(0., 0., 0.); // cm boxGen->SetBoxXYZ(-1.5, -1.5, 1.5, 1.5, 0); primGen->AddGenerator(boxGen); fRun->SetStoreTraj(kTRUE); //------------------------- Initialize the RUN ----------------- fRun->Init(); //------------------------- Run the Simulation ----------------- fRun->Run(nEvents); //------------------------- Save the parameters ----------------- rtdb->saveOutput(); rtdb->print(); //------------------------Print some info and exit---------------- timer.Stop(); Double_t rtime = timer.RealTime(); Double_t ctime = timer.CpuTime(); printf("RealTime=%f seconds, CpuTime=%f seconds\n",rtime,ctime); }