run_sim(Int_t nEvents=5000, Int_t pid=13, Float_t p1=1.0, Float_t p2=-1){ //2212 proton TStopwatch timer; timer.Start(); gDebug=0; // Load basic libraries // If it does not work, please check the path of the libs and put it by hands gROOT->LoadMacro("$VMCWORKDIR/gconfig/rootlogon.C"); rootlogon(); TString digiFile = "all.par"; TString parFile = "params.root"; FairRunSim *fRun = new FairRunSim(); // set the MC version used // ------------------------ fRun->SetName("TGeant3"); //fRun->SetName("TGeant4"); fRun->SetOutputFile("points.root"); // Set Material file Name //----------------------- fRun->SetMaterials("media_pnd.geo"); // Create and add detectors //------------------------- FairModule *Cave= new PndCave("CAVE"); Cave->SetGeometryFileName("pndcave.geo"); fRun->AddModule(Cave); FairDetector *Fts= new PndFts("FTS", kTRUE); Fts->SetGeometryFileName("fts.geo"); fRun->AddModule(Fts); // Create and Set Event Generator //------------------------------- FairPrimaryGenerator* primGen = new FairPrimaryGenerator(); fRun->SetGenerator(primGen); // Box Generator FairBoxGenerator* boxGen = new FairBoxGenerator(pid, 1); // 13 = muon; 1 = multipl. if (p2<0.) p2 = p1; boxGen->SetPRange(p1,p2); // GeV/c boxGen->SetPhiRange(0., 360.); // Azimuth angle range [degree] boxGen->SetThetaRange(1., 5.); // Polar angle in lab system range [degree] boxGen->SetXYZ(0., 0., 0.); // cm primGen->AddGenerator(boxGen); //fRun->SetStoreTraj(kTRUE); // to store particle trajectories // Create and Set Magnetic Field //------------------------------- fRun->SetBeamMom(15); PndMultiField *fField= new PndMultiField("FULL"); fRun->SetField(fField); // Set the parameters //------------------------------- TString allDigiFile = gSystem->Getenv("VMCWORKDIR"); allDigiFile += "/macro/params/"; allDigiFile += digiFile; FairRuntimeDb* rtdb = fRun->GetRuntimeDb(); FairParAsciiFileIo* parIo1 = new FairParAsciiFileIo(); parIo1->open(allDigiFile.Data(),"in"); rtdb->setFirstInput(parIo1); Bool_t kParameterMerged=kTRUE; FairParRootFileIo* output=new FairParRootFileIo(kParameterMerged); output->open(parFile); rtdb->setOutput(output); /**Initialize the session*/ fRun->Init(); rtdb->setOutput(output); rtdb->saveOutput(); rtdb->print(); // Transport nEvents // ----------------- fRun->Run(nEvents); Int_t nEvents = 10; fRun->Run(nEvents); timer.Stop(); Double_t rtime = timer.RealTime(); Double_t ctime = timer.CpuTime(); printf("RealTime=%f seconds, CpuTime=%f seconds\n",rtime,ctime); }