// -------------------------------------------------------------------------- // // 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 // // 20130605 - checked by DE // -------------------------------------------------------------------------- void run_sim_maf(Int_t nEvents = 1, Int_t urqmd = 0000, TString centrality = "mbias") { const char* setup = "sis300_electron"; // ======================================================================== // geometry selection for sim + reco by Cyrano // ======================================================================== ifstream whichTrdGeo; whichTrdGeo.open("whichTrdGeo",ios::in); TString selectGeo; if (whichTrdGeo) whichTrdGeo >> selectGeo; TString digipar = selectGeo(0,11); digipar.ReplaceAll(".ge",""); cout << "selected geometry : >> " << selectGeo << " << (to select a different geometry, edit macro/trd/whichTrdGeo file)" << endl; cout << "selected digipar : >> " << digipar << " << " << endl; whichTrdGeo.close(); if (digipar.Length() == 0) digipar = "trd_standard"; // ======================================================================== // Adjust this part according to your requirements // ----- Paths and file names -------------------------------------------- TString inDir = gSystem->Getenv("VMCWORKDIR"); // TString inFile = inDir + "/input/urqmd.ftn14"; TString fileName; fileName.Form("urqmd.auau.25gev.%s.%04i.ftn14",centrality.Data(),urqmd); TString inFile = inDir + "/input/" + fileName;//"/input/urqmd/urqmd.auau.25gev.centr.0000.ftn14"; TString outDir = "data/sim/"; fileName.Form("test.mc.%04i.root",urqmd); TString outFile = outDir + fileName;//"/test.mc.root"; fileName.Form("test.params.%04i.root",urqmd); TString parFile = outDir + fileName;//"/params.root"; // ----- Geometries ----------------------------------------------------- TString setupFile = inDir + "/geometry/setup/" + setup + "_setup.C"; TString setupFunct = setup; setupFunct += "_setup()"; gROOT->LoadMacro(setupFile); gInterpreter->ProcessLine(setupFunct); CbmTarget* target = new CbmTarget("Gold", 0.025); // ----- set our own TRD ----------------------------------------------------- // TString trdGeom = "trd/trd_v13o.root"; TString trdGeom = "trd/" + selectGeo; TString tofGeom = ""; TString psdGeom = ""; // 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 ( target ) fRun->AddModule(target); if ( magnetGeom != "" ) { FairModule* magnet = new CbmMagnet("MAGNET"); magnet->SetGeometryFileName(magnetGeom); fRun->AddModule(magnet); } if ( platformGeom != "" ) { FairModule* platform = new CbmPlatform("PLATFORM"); platform->SetGeometryFileName(platformGeom); fRun->AddModule(platform); } 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 ( muchGeom != "" ) { FairDetector* much = new CbmMuch("MUCH", kTRUE); much->SetGeometryFileName(muchGeom); fRun->AddModule(much); } if ( shieldGeom != "" ) { FairModule* shield = new CbmShield("SHIELD"); shield->SetGeometryFileName(shieldGeom); fRun->AddModule(shield); } 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); } if ( ecalGeom != "" ) { FairDetector* ecal = new CbmEcal("ECAL", kTRUE, ecalGeom.Data()); fRun->AddModule(ecal); } if ( psdGeom != "" ) { cout << "Constructing PSD" << endl; CbmPsdv1* psd= new CbmPsdv1("PSD", kTRUE); psd->SetZposition(psdZpos); // in cm psd->SetXshift(psdXpos); // in cm psd->SetGeoFile(psdGeom); fRun->AddModule(psd); } // ------------------------------------------------------------------------ // ----- Create magnetic field ---------------------------------------- if ( 2 == fieldSymType ) { CbmFieldMap* magField = new CbmFieldMapSym2(fieldMap); } else if ( 3 == fieldSymType ) { CbmFieldMap* magField = new CbmFieldMapSym3(fieldMap); } magField->SetPosition(0., 0., fieldZ); magField->SetScale(fieldScale); fRun->SetField(magField); // ------------------------------------------------------------------------ // Use theexperiment specific MC Event header instead of the default one // This one stores additional information about the reaction plane CbmMCEventHeader* mcHeader = new CbmMCEventHeader(); fRun->SetMCEventHeader(mcHeader); // ----- Create PrimaryGenerator -------------------------------------- FairPrimaryGenerator* primGen = new FairPrimaryGenerator(); // Use the CbmUrqmdGenrator which calculates a reaction plane and // rotate all particles accordingly CbmUrqmdGenerator* urqmdGen = new CbmUrqmdGenerator(inFile); urqmdGen->SetEventPlane(0. , 360.); primGen->AddGenerator(urqmdGen); fRun->SetGenerator(primGen); // ------------------------------------------------------------------------ // -Trajectories Visualization (TGeoManager Only ) // Switch this on if you want to visualize tracks in the // eventdisplay. // This is normally switch off, because of the huge files created // when it is switched on. fRun->SetStoreTraj(kTRUE); // ----- Run initialisation ------------------------------------------- fRun->Init(); // ------------------------------------------------------------------------ // Set cuts for storing the trajectories. // Switch this on only if trajectories are stored. // Choose this cuts according to your needs, but be aware // that the file size of the output file depends on these cuts FairTrajFilter* trajFilter = FairTrajFilter::Instance(); trajFilter->SetStepSizeCut(0.01); // 1 cm trajFilter->SetVertexCut(-2000., -2000., 4., 2000., 2000., 100.); trajFilter->SetMomentumCutP(10e-3); // p_lab > 10 MeV trajFilter->SetEnergyCut(0., 1.02); // 0 < Etot < 1.04 GeV trajFilter->SetStorePrimaries(kTRUE); trajFilter->SetStoreSecondaries(kTRUE); // ----- 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/geofile_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; }