// -------------------------------------------------------------------------- // // Macro for standard transport simulation using UrQMD input and GEANT3 // Standard CBM setup with MVD, STS, RICH, TRD, TOF and ECAL // // V. Friese 22/02/2007 // // -------------------------------------------------------------------------- void run_radlength(Int_t nEvents = 10000) { // ======================================================================== // Adjust this part according to your requirements // ----- Paths and file names -------------------------------------------- TString inDir = gSystem->Getenv("VMCWORKDIR"); TString inFile = inDir + "/input/urqmd.ftn14"; TString outDir = "data"; TString outFile = outDir + "/radlengthtest.mc.root"; TString parFile = outDir + "/params.root"; // ----- Geometries ----------------------------------------------------- TString caveGeom = "cave.geo"; TString targetGeom = ""; TString pipeGeom = ""; TString magnetGeom = ""; TString mvdGeom = ""; TString stsGeom = "sts/sts_v13d.geo.root"; TString richGeom = ""; TString trdGeom = ""; TString tofGeom = ""; // ----- Magnetic field ----------------------------------------------- TString fieldMap = "field_v10e"; // name of field map Double_t fieldZ = 50.; // field centre z position Double_t fieldScale = 1.; // field scaling factor // In general, the following parts need not be touched // ======================================================================== // ---- Debug option ------------------------------------------------- gDebug = 0; // ------------------------------------------------------------------------ // ----- Timer -------------------------------------------------------- TStopwatch timer; timer.Start(); // ------------------------------------------------------------------------ // ----- Create simulation run ---------------------------------------- FairRunSim* fRun = new FairRunSim(); fRun->SetName("TGeant3"); // Transport engine fRun->SetOutputFile(outFile); // Output file FairRuntimeDb* rtdb = fRun->GetRuntimeDb(); // ------------------------------------------------------------------------ // ----- Create media ------------------------------------------------- fRun->SetMaterials("media.geo"); // Materials // ------------------------------------------------------------------------ // ----- Create detectors and passive volumes ------------------------- if ( caveGeom != "" ) { FairModule* cave = new CbmCave("CAVE"); cave->SetGeometryFileName(caveGeom); fRun->AddModule(cave); } if ( pipeGeom != "" ) { FairModule* pipe = new CbmPipe("PIPE"); pipe->SetGeometryFileName(pipeGeom); fRun->AddModule(pipe); } if ( targetGeom != "" ) { FairModule* target = new CbmTarget("Target"); target->SetGeometryFileName(targetGeom); fRun->AddModule(target); } if ( magnetGeom != "" ) { FairModule* magnet = new CbmMagnet("MAGNET"); magnet->SetGeometryFileName(magnetGeom); fRun->AddModule(magnet); } if ( mvdGeom != "" ) { FairDetector* mvd = new CbmMvd("MVD", kTRUE); mvd->SetGeometryFileName(mvdGeom); fRun->AddModule(mvd); } if ( stsGeom != "" ) { FairDetector* sts = new CbmStsMC(kTRUE); sts->SetGeometryFileName(stsGeom); fRun->AddModule(sts); } if ( richGeom != "" ) { FairDetector* rich = new CbmRich("RICH", kTRUE); rich->SetGeometryFileName(richGeom); fRun->AddModule(rich); } if ( trdGeom != "" ) { FairDetector* trd = new CbmTrd("TRD",kTRUE ); trd->SetGeometryFileName(trdGeom); fRun->AddModule(trd); } if ( tofGeom != "" ) { FairDetector* tof = new CbmTof("TOF", kTRUE); tof->SetGeometryFileName(tofGeom); fRun->AddModule(tof); } // ------------------------------------------------------------------------ // ----- Create magnetic field ---------------------------------------- // Constant Field CbmFieldConst *magField=new CbmFieldConst(); magField->SetField(0, 0 ,0 ); // values are in kG // MinX=-75, MinY=-40,MinZ=-12 ,MaxX=75, MaxY=40 ,MaxZ=124 ); // values are in cm magField->SetFieldRegion(-74, -39 ,-22 , 74, 39 , 160 ); fRun->SetField(magField); // ----- Create PrimaryGenerator -------------------------------------- FairPrimaryGenerator* primGen = new FairPrimaryGenerator(); fRun->SetGenerator(primGen); //ROOTino FairBoxGenerator *fBox1 = new FairBoxGenerator(0, 1); fBox1->SetBoxXYZ(-10.,-10.,10.,10.,0.); fBox1->SetPRange(0.1,0.5); fBox1->SetThetaRange(0.,0.); fBox1->SetPhiRange(0.,360.); primGen->AddGenerator(fBox1); fRun->SetStoreTraj(kFALSE); fRun->SetRadLenRegister(kTRUE); // ------------------------------------------------------------------------ // ----- Run initialisation ------------------------------------------- fRun->Init(); // ------------------------------------------------------------------------ // ----- Runtime database --------------------------------------------- CbmFieldPar* fieldPar = (CbmFieldPar*) rtdb->getContainer("CbmFieldPar"); fieldPar->SetParameters(magField); fieldPar->setChanged(); fieldPar->setInputVersion(fRun->GetRunId(),1); Bool_t kParameterMerged = kTRUE; FairParRootFileIo* parOut = new FairParRootFileIo(kParameterMerged); parOut->open(parFile.Data()); rtdb->setOutput(parOut); rtdb->saveOutput(); rtdb->print(); // ------------------------------------------------------------------------ // ----- Start run ---------------------------------------------------- fRun->Run(nEvents); // ------------------------------------------------------------------------ fRun->CreateGeometryFile("data/geo_rad_full.root"); // ----- Finish ------------------------------------------------------- timer.Stop(); Double_t rtime = timer.RealTime(); Double_t ctime = timer.CpuTime(); cout << endl << endl; cout << "Macro finished succesfully." << endl; cout << "Output file is " << outFile << endl; cout << "Parameter file is " << parFile << endl; cout << "Real time " << rtime << " s, CPU time " << ctime << "s" << endl << endl; // ------------------------------------------------------------------------ cout << " Test passed" << endl; cout << " All ok " << endl; }