Int_t run(Int_t NoOfEvent=500) {// Use non default gconfig and geometry directories TString dir = getenv("VMCWORKDIR"); TString geomdir = dir + "/PndAnandDetector"; gSystem->Setenv("GEOMPATH",geomdir.Data()); //======================================================================================= FairRunSim* fRun = new FairRunSim(); // Create a simulation run fRun->SetName("TGeant3"); // Set MC engine fRun->SetOutputFile("data/testrun.root"); // Define an output file fRun->SetMaterials("media.geo"); // Set media file //======================================================================================= PndConstField *fMagField = new PndConstField(); // Constant Magnetic Field fMagField->SetField(0., 10. ,0. ); // values are in kG fMagField->SetFieldRegion(-50,50,-50,50,0,100); // values are in cm (xmin,xmax,ymin,ymax,zmin,zmax) fRun->SetField(fMagField); //======================================================================================= FairModule *Cave= new PndCave("CAVE"); // create the top node Cave->SetGeometryFileName("cave.geo"); // select geometry file fRun->AddModule(Cave); // add it to the Run FairDetector *Anand= new PndAnandDetector("ANAND", kTRUE); // if kFALSE, the material is there, Anand->SetGeometryFileName("detector.geo"); // but the ProcessHits() is not called fRun->AddModule(Anand); FairPrimaryGenerator* primGen = new FairPrimaryGenerator(); fRun->SetGenerator(primGen); // Box Generator FairBoxGenerator* boxGen = new FairBoxGenerator(2212, 3); // 2212 = proton; 3 = multipl. boxGen->SetPRange(2., 2.); // GeV/c //setPRange vs setPtRange boxGen->SetPhiRange(0, 360); // Azimuth angle range [degree] boxGen->SetThetaRange(3, 10); // Polar angle in lab system range [degree] boxGen->SetCosTheta(); // uniform generation on all the solid angle(default) // boxGen->SetXYZ(0., 0.37, 0.); // origin of the vertex primGen->AddGenerator(boxGen); // Add the particle generator to the primary generator // One can add many different generators fRun->SetStoreTraj(kTRUE); // Store particle trajectories in the whole detector, useful for visualisation fRun->Init(); // Initialize the simulation (VMC and detectors) //======================================================================================= FairRuntimeDb *rtdb=fRun->GetRuntimeDb(); Bool_t kParameterMerged=kTRUE; FairParRootFileIo* output=new FairParRootFileIo(kParameterMerged); output->open("data/testparams.root"); rtdb->setOutput(output); rtdb->saveOutput(); rtdb->print(); //======================================================================================= fRun->Run(NoOfEvent); // Run the Simulation fRun->CreateGeometryFile("data/geofile.root"); // Create a separate file with the TGeoManager (optional) }