// Macro for running sim with Geant3 or Geant4 (M. Al-Turany , D. Bertini) void runMC(Double_t momentum = 1, Int_t nev = 50){ TStopwatch timer; timer.Start(); gDebug=0; // Load basic libraries gROOT->LoadMacro("$VMCWORKDIR/gconfig/rootlogon.C"); rootlogon(); FairRunSim *fRun = new FairRunSim(); // set the MC version used fRun->SetName("TGeant3"); // Base File name TString base="tst"; //Parameter file TString parFile = base+".param.root"; // Output file TString outFile = base+".root"; fRun->SetOutputFile(outFile); // 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); FairModule *Pipe= new PndPipe("PIPE"); Pipe->SetGeometryFileName("pipebeamtarget.geo"); fRun->AddModule(Pipe); FairModule *Magnet= new PndMagnet("MAGNET"); Magnet->SetGeometryFileName("PandaSolenoidV833.root"); fRun->AddModule(Magnet); FairModule *dipole= new PndMagnet("MAGNET"); dipole->SetGeometryFileName("dipole.geo"); fRun->AddModule(dipole); FairDetector *Dch = new PndDchDetector("DCH", kTRUE); Dch->SetGeometryFileName("dch.root"); Dch->SetVerboseLevel(1); fRun->AddModule(Dch); // FairDetector *Gem = new PndGemDetector("GEM", kTRUE); // Gem->SetGeometryFileName("gem_4Stations.root"); // Gem->SetVerboseLevel(0); // fRun->AddModule(Gem); // Create and Set Event Generator //------------------------------- FairPrimaryGenerator* primGen = new FairPrimaryGenerator(); fRun->SetGenerator(primGen); // Box Generator // gRandom->SetSeed(3523); FairBoxGenerator* boxGen = new FairBoxGenerator(13, 1); // 13=muon; 2212=proton 1 = multipl. boxGen->SetPRange(momentum,momentum); // GeV/c //setPRange vs setPtRange boxGen->SetPhiRange(0,360); // Azimuth angle range [degree] boxGen->SetThetaRange(3, 5); // Polar angle in lab system range [degree] boxGen->SetXYZ(0.,0.,0.); primGen->AddGenerator(boxGen); fRun->SetStoreTraj(kFALSE); fRun->SetBeamMom(15.); // Field Map Definition // -------------------- PndMultiField *fField= 0; fField = new PndMultiField(); PndTransMap *map_t= new PndTransMap("TransMap", "R"); PndSolenoidMap *map_s1= new PndSolenoidMap("SolenoidMap1", "R"); PndSolenoidMap *map_s2= new PndSolenoidMap("SolenoidMap2", "R"); PndSolenoidMap *map_s3= new PndSolenoidMap("SolenoidMap3", "R"); PndSolenoidMap *map_s4= new PndSolenoidMap("SolenoidMap4", "R"); PndDipoleMap *map_d1= new PndDipoleMap("DipoleMap1", "R"); PndDipoleMap *map_d2= new PndDipoleMap("DipoleMap2", "R"); fField->AddField(map_t); fField->AddField(map_s1); fField->AddField(map_s2); fField->AddField(map_s3); fField->AddField(map_s4); fField->AddField(map_d1); fField->AddField(map_d2); fRun->SetField(fField); //-----------end of Bfield stuff fRun->Init(); // Fill the Parameter containers for this run //------------------------------------------- FairRuntimeDb *rtdb=fRun->GetRuntimeDb(); Bool_t kParameterMerged=kTRUE; FairParRootFileIo* output=new FairParRootFileIo(kParameterMerged); output->open(parFile.Data()); rtdb->setOutput(output); PndMultiFieldPar* fieldPar = (PndMultiFieldPar*) rtdb->getContainer("PndMultiFieldPar"); if(fField) { fieldPar->SetParameters(fField); } fieldPar->setInputVersion(fRun->GetRunId(),1); fieldPar->setChanged(kTRUE); rtdb->saveOutput(); rtdb->print(); // Transport nEvents // ----------------- fRun->Run(nev); timer.Stop(); Double_t rtime = timer.RealTime(); Double_t ctime = timer.CpuTime(); printf("RealTime=%f seconds, CpuTime=%f seconds\n",rtime,ctime); //exit(0); // TGeoManager *geoMan = (TGeoManager*) gDirectory->Get("FAIRGeom"); // TCanvas* c1 = new TCanvas("c1", "", 100, 100, 800, 800); // c1->SetFillColor(10); // geoMan->SetVisLevel(3); // geoMan->GetMasterVolume()->Draw("same"); }