void run_CbmIonGenerator(Int_t nEvents = 1) { // ======================================================================== // Adjust this part according to your requirements // Input file //TString inPath = "/d/cbm03/urqmd/auau/25gev/centr/"; //TString inFile = inPath + "urqmd.auau.25gev.centr.0000.ftn14"; // Output file TString outFile = Form("sts.mc.root",nEvents); // Parameter file TString parFile = Form("params.root",nEvents); // Cave geometry TString caveGeom = "cave.geo"; // Target geometry TString targetGeom = "target_au_250mu.geo"; // Beam pipe geometry TString pipeGeom = "pipe_standard.geo"; // Magnet geometry and field map TString magnetGeom = "passive/magnet_v09e.geo"; TString fieldMap = "field_v10e"; Double_t fieldZ = 50.; // z position of field centre Double_t fieldScale = 1.; // field scaling factor // MVD geometry TString mvdGeom = "mvd/mvd_v07a.geo"; // STS geometry TString stsGeom = "sts/sts_v11a.geo"; //STS geometry for the same z position of all sensors //TString stsGeom = "sts_same_z.geo"; targetGeom = ""; magnetGeom = ""; stsGeom = ""; mvdGeom = ""; // In general, the following parts need not be touched // ======================================================================== // ---- Debug option ------------------------------------------------- gDebug = 0; // ------------------------------------------------------------------------ // ----- Timer -------------------------------------------------------- TStopwatch timer; timer.Start(); // ------------------------------------------------------------------------ // ---- Load libraries ------------------------------------------------- gROOT->LoadMacro("$VMCWORKDIR/gconfig/basiclibs.C"); basiclibs(); gSystem->Load("libGeoBase"); gSystem->Load("libParBase"); gSystem->Load("libBase"); gSystem->Load("libCbmBase"); gSystem->Load("libCbmData"); gSystem->Load("libField"); gSystem->Load("libGen"); gSystem->Load("libPassive"); gSystem->Load("libMvd"); gSystem->Load("libSts"); gSystem->Load("libCbmGenerators"); // for CbmIonGenerator // ------------------------------------------------------------------------ // ----- Create simulation run ---------------------------------------- FairRunSim* run = new FairRunSim(); run->SetName("TGeant3"); // Transport engine run->SetOutputFile(outFile); // Output file FairRuntimeDb* rtdb = run->GetRuntimeDb(); // ------------------------------------------------------------------------ // ----- Create media ------------------------------------------------- run->SetMaterials("media.geo"); // Materials // ------------------------------------------------------------------------ // ----- Create geometry ---------------------------------------------- FairModule* cave= new CbmCave("CAVE"); cave->SetGeometryFileName(caveGeom); run->AddModule(cave); FairModule* pipe= new CbmPipe("PIPE"); pipe->SetGeometryFileName(pipeGeom); run->AddModule(pipe); if( targetGeom != "") { FairModule* target= new CbmTarget("Target"); target->SetGeometryFileName(targetGeom); run->AddModule(target); } if( magnetGeom != "") { FairModule* magnet= new CbmMagnet("MAGNET"); magnet->SetGeometryFileName(magnetGeom); run->AddModule(magnet); } if( mvdGeom != ""){ FairDetector* mvd= new CbmMvd("MVD", kTRUE); mvd->SetGeometryFileName(mvdGeom); run->AddModule(mvd); } if( stsGeom != "") { FairDetector* sts= new CbmSts("STS", kTRUE); sts->SetGeometryFileName(stsGeom); run->AddModule(sts); } // ------------------------------------------------------------------------ // ----- Create magnetic field ---------------------------------------- if(magnetGeom!="") { CbmFieldMap* magField = new CbmFieldMapSym2(fieldMap); magField->SetPosition(0., 0., fieldZ); magField->SetScale(fieldScale); run->SetField(magField); } // ------------------------------------------------------------------------ // ----- Create PrimaryGenerator -------------------------------------- FairPrimaryGenerator* primGen = new FairPrimaryGenerator(); //FairUrqmdGenerator* urqmdGen = new FairUrqmdGenerator(inFile); //primGen->AddGenerator(urqmdGen); // CbmIonGenerator - check in Load libraries: gSystem->Load("libCbmGenerators"); Int_t nions=10; // number of ions/event cout<<"@@@@@> CbmIonGenerator is ON with "<<nions<<" ion(s)/event !!!"<<endl; Int_t z=79, a=197, q=79; // Au-ion Double_t p=8.; // in AGeV/c Double_t vz=-0.0126; // in cm - z-pos. of vertex Double_t meanX=0.3; // in cm - spatial distr. (XOY) Double_t meanY=-0.2; // in cm Double_t sigmaX = 0.078; // in cm - spatial distr. (XOY) Double_t sigmaY = 0.032; // in cm Double_t sigmatX = 0.00117885; // in rad (Px/P) - angular distr. (mean=0) Double_t sigmatY = 0.00094955; // in rad (Py/P) // Parameters of the trapezoid are set with respect to mean of Gaussian, NOT necesseraly in absolute coordinates. // x1 < x2 < 0 < x3 < x4 Double_t x1=-0.10452, x2=-0.06942, x3=0.06942, x4=0.10452; // in cm - trapezoid distr. Double_t y1=-0.04448, y2=-0.02688, y3=0.02688, y4=0.04448; // in cm Double_t tX1=-0.00157966, tX2=-0.001049177, tX3=0.001049177, tX4=0.00157966; // in rad Double_t tY1=-0.00131987, tY2=-0.000797622, tY3=0.000797622, tY4=0.00131987; // in rad // CbmIonGenerator *IonGen = new CbmIonGenerator(z, a, q, nions, p, sigmaX, sigmaY, sigmatX, sigmatY); // CbmIonGenerator *IonGen = new CbmIonGenerator(z, a, q, nions, p, sigmaX, sigmaY, sigmatX, sigmatY, meanX, meanY, vz); CbmIonGenerator *IonGen = new CbmIonGenerator(z, a, q, nions, p, sigmaX, sigmaY, sigmatX, sigmatY, meanX, meanY, vz, x1, x2, x3, x4, y1, y2, y3, y4, tX1, tX2, tX3, tX4, tY1, tY2, tY3, tY4); primGen->AddGenerator(IonGen); run->SetGenerator(primGen); // ------------------------------------------------------------------------ // run->SetStoreTraj(kTRUE); // ----- Initialize simulation run ------------------------------------ run->Init(); // ------------------------------------------------------------------------ // ----- Runtime database --------------------------------------------- if(magnetGeom!="") { CbmFieldPar* fieldPar = (CbmFieldPar*) rtdb->getContainer("CbmFieldPar"); fieldPar->SetParameters(magField); fieldPar->setChanged(); fieldPar->setInputVersion(run->GetRunId(),1); } Bool_t kParameterMerged = kTRUE; FairParRootFileIo* parOut = new FairParRootFileIo(kParameterMerged); parOut->open(parFile.Data()); rtdb->setOutput(parOut); rtdb->saveOutput(); rtdb->print(); // ------------------------------------------------------------------------ // ----- Start run ---------------------------------------------------- run->Run(nEvents); // ------------------------------------------------------------------------ //run->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; exit(0); }
void run_sim(Int_t gen=1, Int_t nEvents = 1, Int_t fileNum = 100) { TString rootVersion = "feb16"; const char* setup = "sis100_electron"; TString sfileNum = ""; sfileNum += fileNum; // ======================================================================== // Adjust this part according to your requirements // ----- Paths and file names -------------------------------------------- TString inDir = "/hera/cbm/users/klochkov/cbm/data/input/au10au/shield/test_10k/"; TString inFile = inDir + "au10au_" + sfileNum + ".root"; TString outDir = "/hera/cbm/users/klochkov/cbm/data/au10au_10k_test_1/"; TString outFile = outDir + "sim/mc_" + sfileNum + ".root"; TString parFile = outDir + "sim/params_" + sfileNum + ".root"; TString geoFileNamePsd = outDir + "geo/psd_geo_xy_" + sfileNum + ".txt"; TString geoFileName = outDir + "geo/geofile_" + sfileNum + ".root"; TString SourceDir = gSystem->Getenv("VMCWORKDIR"); TString setupFile = SourceDir + "/geometry/setup/sis100_electron_setup.C"; //TODO TString setupFunct = setup; setupFunct += "_setup()"; gROOT->LoadMacro(setupFile); gInterpreter->ProcessLine(setupFunct); // Function needed for CTest runtime dependency // TString depFile = Remove_CTest_Dependency_File(outDir, "run_sim" , setup); // --- Logger settings ---------------------------------------------------- TString logLevel = "INFO"; // "DEBUG"; TString logVerbosity = "LOW"; // ------------------------------------------------------------------------ // --- Define the target geometry ----------------------------------------- // // The target is not part of the setup, since one and the same setup can // and will be used with different targets. // The target is constructed as a tube in z direction with the specified // diameter (in x and y) and thickness (in z). It will be placed at the // specified position as daughter volume of the volume present there. It is // in the responsibility of the user that no overlaps or extrusions are // created by the placement of the target. // TString targetElement = "Gold"; Double_t targetThickness = 0.025; // full thickness in cm Double_t targetDiameter = 2.5; // diameter in cm Double_t targetPosX = 0.; // target x position in global c.s. [cm] Double_t targetPosY = 0.; // target y position in global c.s. [cm] Double_t targetPosZ = 0.; // target z position in global c.s. [cm] Double_t targetRotY = 0.; // target rotation angle around the y axis [deg] // ------------------------------------------------------------------------ // --- Define the creation of the primary vertex ------------------------ // // By default, the primary vertex point is sampled from a Gaussian // distribution in both x and y with the specified beam profile width, // and from a flat distribution in z over the extension of the target. // By setting the respective flags to kFALSE, the primary vertex will always // at the (0., 0.) in x and y and in the z centre of the target, respectively. // Bool_t smearVertexXY = kTRUE; Bool_t smearVertexZ = kTRUE; Double_t beamWidthX = 1.; // Gaussian sigma of the beam profile in x [cm] Double_t beamWidthY = 1.; // Gaussian sigma of the beam profile in y [cm] // ------------------------------------------------------------------------ // In general, the following parts need not be touched // ======================================================================== cout << "[INFO ] Setup: " << setup << endl; // ---- Debug option ------------------------------------------------- gDebug = 0; // ------------------------------------------------------------------------ // ----- Timer -------------------------------------------------------- TStopwatch timer; timer.Start(); // ------------------------------------------------------------------------ // ----- Create simulation run ---------------------------------------- FairRunSim* run = new FairRunSim(); run->SetName("TGeant4"); // Transport engine run->SetOutputFile(outFile); // Output file run->SetGenerateRunInfo(kTRUE); // Create FairRunInfo file FairRuntimeDb* rtdb = run->GetRuntimeDb(); // ------------------------------------------------------------------------ // ----- Logger settings ---------------------------------------------- gLogger->SetLogScreenLevel(logLevel.Data()); gLogger->SetLogVerbosityLevel(logVerbosity.Data()); // ------------------------------------------------------------------------ // ----- Create media ------------------------------------------------- run->SetMaterials("media.geo"); // Materials // ------------------------------------------------------------------------ // ----- Create detectors and passive volumes ------------------------- if ( caveGeom != "" ) { FairModule* cave = new CbmCave("CAVE"); cave->SetGeometryFileName(caveGeom); run->AddModule(cave); } if ( pipeGeom != "" ) { FairModule* pipe = new CbmPipe("PIPE"); pipe->SetGeometryFileName(pipeGeom); run->AddModule(pipe); } // --- Target CbmTarget* target = new CbmTarget(targetElement.Data(), targetThickness, targetDiameter); target->SetPosition(targetPosX, targetPosY, targetPosZ); target->SetRotation(targetRotY); run->AddModule(target); if ( magnetGeom != "" ) { FairModule* magnet = new CbmMagnet("MAGNET"); magnet->SetGeometryFileName(magnetGeom); run->AddModule(magnet); } if ( platformGeom != "" ) { FairModule* platform = new CbmPlatform("PLATFORM"); platform->SetGeometryFileName(platformGeom); run->AddModule(platform); } if ( mvdGeom != "" ) { FairDetector* mvd = new CbmMvd("MVD", kTRUE); mvd->SetGeometryFileName(mvdGeom); mvd->SetMotherVolume("pipevac1"); run->AddModule(mvd); } if ( stsGeom != "" ) { FairDetector* sts = new CbmStsMC(kTRUE); sts->SetGeometryFileName(stsGeom); run->AddModule(sts); } if ( richGeom != "" ) { FairDetector* rich = new CbmRich("RICH", kTRUE); rich->SetGeometryFileName(richGeom); run->AddModule(rich); } if ( muchGeom != "" ) { FairDetector* much = new CbmMuch("MUCH", kTRUE); much->SetGeometryFileName(muchGeom); run->AddModule(much); } if ( shieldGeom != "" ) { FairModule* shield = new CbmShield("SHIELD"); shield->SetGeometryFileName(shieldGeom); run->AddModule(shield); } if ( trdGeom != "" ) { FairDetector* trd = new CbmTrd("TRD",kTRUE ); trd->SetGeometryFileName(trdGeom); run->AddModule(trd); } if ( tofGeom != "" ) { FairDetector* tof = new CbmTof("TOF", kTRUE); tof->SetGeometryFileName(tofGeom); run->AddModule(tof); } if ( ecalGeom != "" ) { FairDetector* ecal = new CbmEcal("ECAL", kTRUE, ecalGeom.Data()); run->AddModule(ecal); } // if ( psdGeom != "" ) { TString geoFileNamePsd = outDir + "geo/psd_geo_xy_" + sfileNum + ".txt"; cout << "Constructing PSD" << endl; // CbmPsdv1* psd= new CbmPsdv1("PSD", kTRUE); CbmPsdTest* psd= new CbmPsdTest("PSD", kTRUE); psd->SetZposition(psdZpos); // in cm psd->SetXshift(psdXpos); // in cm psd->SetGeoFile(geoFileNamePsd); psd->SetHoleSize(6); run->AddModule(psd); // } // ------------------------------------------------------------------------ // ----- Create magnetic field ---------------------------------------- CbmFieldMap* magField = NULL; if ( 2 == fieldSymType ) { magField = new CbmFieldMapSym2(fieldMap); } else if ( 3 == fieldSymType ) { magField = new CbmFieldMapSym3(fieldMap); } magField->SetPosition(0., 0., fieldZ); magField->SetScale(fieldScale); run->SetField(magField); // ------------------------------------------------------------------------ // ----- Create PrimaryGenerator -------------------------------------- FairPrimaryGenerator* primGen = new FairPrimaryGenerator(); // --- Uniform distribution of event plane angle // primGen->SetEventPlane(0., 2. * TMath::Pi()); //TODO (ask Vitaly) check event plane // --- Get target parameters Double_t tX = 0.; Double_t tY = 0.; Double_t tZ = 0.; Double_t tDz = 0.; if ( target ) { target->GetPosition(tX, tY, tZ); tDz = target->GetThickness(); } primGen->SetTarget(tZ, tDz); primGen->SetBeam(0., 0., beamWidthX, beamWidthY); primGen->SmearGausVertexXY(smearVertexXY); primGen->SmearVertexZ(smearVertexZ); // // TODO: Currently, there is no guaranteed consistency of the beam profile // and the transversal target dimension, i.e., that the sampled primary // vertex falls into the target volume. This would require changes // in the FairPrimaryGenerator class. // ------------------------------------------------------------------------ // Use the CbmUnigenGenrator for the input if (gen == 0) { CbmUnigenGenerator* urqmdGen = new CbmUnigenGenerator(inFile); urqmdGen->SetEventPlane(-TMath::Pi(), TMath::Pi()); primGen->AddGenerator(urqmdGen); } if (gen == 1) { CbmShieldGeneratorNew* shieldGen = new CbmShieldGeneratorNew (inFile); primGen->AddGenerator(shieldGen); } run->SetGenerator(primGen); // ------------------------------------------------------------------------ // Visualisation of trajectories (TGeoManager Only) // Switch this on if you want to visualise tracks in the event display. // This is normally switch off, because of the huge files created // when it is switched on. run->SetStoreTraj(kFALSE); // ----- Run initialisation ------------------------------------------- run->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(); if ( trajFilter ) { 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(run->GetRunId(),1); Bool_t kParameterMerged = kTRUE; FairParRootFileIo* parOut = new FairParRootFileIo(kParameterMerged); parOut->open(parFile.Data()); rtdb->setOutput(parOut); rtdb->saveOutput(); rtdb->print(); // ------------------------------------------------------------------------ // ----- Start run ---------------------------------------------------- run->Run(nEvents); // ------------------------------------------------------------------------ run->CreateGeometryFile(geoFileName); // ----- Finish ------------------------------------------------------- timer.Stop(); Double_t rtime = timer.RealTime(); Double_t ctime = timer.CpuTime(); std::cout << std::endl << std::endl; std::cout << "Macro finished successfully." << std::endl; std::cout << "Output file is " << outFile << std::endl; std::cout << "Parameter file is " << parFile << std::endl; std::cout << "Real time " << rtime << " s, CPU time " << ctime << "s" << std::endl << std::endl; // ------------------------------------------------------------------------ std::cout << " Test passed" << std::endl; std::cout << " All ok " << std::endl; // Function needed for CTest runtime dependency // Generate_CTest_Dependency_File(depFile); }
void sim(Int_t file_nr=0, Int_t nEvents=1, Int_t s=0, Int_t seed=1){ Char_t filenr[4]; sprintf(filenr,"%04d",file_nr); printf("Filenr: %s\n", filenr); TString signal; if (s!=3312 && s!=3334) signal = "la"; else if (s==3312) signal = "xi"; else if (s==3334) signal = "om"; // ----- Paths and file names -------------------------------------------- TString inDir = gSystem->Getenv("URQMD_INPUT_PATH"); TString inFile = inDir + "/urqmd.auau.25gev.centr." + filenr + ".ftn14"; TString outDir= TString(filenr); outDir+= "/"; gSystem->mkdir(outDir.Data()); TString outFile = outDir+signal+".mc.root"; TString parFile = outDir+signal+".par.root"; // ----- Geometries ----------------------------------------------------- TString caveGeom = "cave.geo"; TString pipeGeom = "pipe_standard.geo"; TString targetGeom = "target_au_250mu.geo"; TString magnetGeom = "magnet_standard.geo"; TString stsGeom = "sts_Standard_s3055AAFK5.SecD.geo"; // ----- Magnetic field ----------------------------------------------- TString fieldMap = "FieldMuonMagnet"; // name of field map Double_t fieldZ = 50.; // field centre z position Double_t fieldScale = 1.; // field scaling factor gDebug = 0; gRandom->SetSeed(seed); // ---- Load libraries ------------------------------------------------- cout << endl << "=== much_sim.C : Loading libraries ..." << endl; gROOT->LoadMacro("$VMCWORKDIR/gconfig/basiclibs.C"); basiclibs(); gROOT->LoadMacro("$VMCWORKDIR/analysis/hyperon/analysislibs.C"); analysislibs(); FairRunSim* fRun = new FairRunSim(); fRun->SetName("TGeant3"); fRun->SetOutputFile(outFile.Data()); FairRuntimeDb* rtdb = fRun->GetRuntimeDb(); fRun->SetMaterials("media.geo"); // ----- Create detectors and passive volumes ------------------------- cout << endl << "=== much_sim.C : Create geeometry ..." << endl; if ( caveGeom != "" ) { FairModule* cave = new CbmCave("CAVE"); cave->SetGeometryFileName(caveGeom); fRun->AddModule(cave); cout << " --- " << caveGeom << endl; } if ( pipeGeom != "" ) { FairModule* pipe = new CbmPipe("PIPE"); pipe->SetGeometryFileName(pipeGeom); fRun->AddModule(pipe); cout << " --- " << pipeGeom << endl; } if ( targetGeom != "" ) { FairModule* target = new CbmTarget("Target"); target->SetGeometryFileName(targetGeom); fRun->AddModule(target); cout << " --- " << targetGeom << endl; } if ( magnetGeom != "" ) { FairModule* magnet = new CbmMagnet("MAGNET"); magnet->SetGeometryFileName(magnetGeom); fRun->AddModule(magnet); cout << " --- " << magnetGeom << endl; } if ( stsGeom != "" ) { FairDetector* sts = new CbmSts("STS", kTRUE); sts->SetGeometryFileName(stsGeom); cout << " --- " << stsGeom << endl; fRun->AddModule(sts); } // ----- Create magnetic field ---------------------------------------- cout << endl << "=== much_sim.C : Create magnetic field ..." << endl; CbmFieldMap* magField = NULL; if ( fieldMap == "FieldActive" || fieldMap == "FieldIron") magField = new CbmFieldMapSym3(fieldMap); else if ( fieldMap == "FieldAlligator" ) magField = new CbmFieldMapSym2(fieldMap); else if ( fieldMap == "FieldMuonMagnet" ) magField = new CbmFieldMapSym3(fieldMap); else { cout << "===> ERROR: Field map " << fieldMap << " unknown! " << endl; exit; } magField->SetPosition(0., 0., fieldZ); magField->SetScale(fieldScale); fRun->SetField(magField); // ----- Create PrimaryGenerator -------------------------------------- cout << endl << "=== much_sim.C : Create generators ..." << endl; FairPrimaryGenerator* primGen = new FairPrimaryGenerator(); if (signal=="om"){ delete gRandom; gRandom = new TRandom3(); CbmAnaHypYPtGenerator* gen = new CbmAnaHypYPtGenerator(3334); gen->SetDistributionPt(0.1603); // 6 GeV gen->SetDistributionY(1.277,0.412); // 6 GeV //gen->SetDistributionPt(0.149808); // 25 GeV //gen->SetDistributionY(1.9875,0.546669); // 25 GeV gen->Init(); primGen->AddGenerator(gen); } else if (signal=="xi"){ delete gRandom; gRandom = new TRandom3(); CbmAnaHypYPtGenerator* gen = new CbmAnaHypYPtGenerator(3312); gen->SetDistributionPt(0.1603); // 6 GeV gen->SetDistributionY(1.277,0.412); // 6 GeV //gen->SetDistributionPt(0.154319); // 25 GeV //gen->SetDistributionY(1.98604,0.617173); // 25 GeV gen->Init(); primGen->AddGenerator(gen); } FairUrqmdGenerator* urqmdGen = new FairUrqmdGenerator(inFile.Data()); primGen->AddGenerator(urqmdGen); fRun->SetGenerator(primGen); // ------------------------------------------------------------------------ fRun->Init(); // ------------------------------------------------------------------------ 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); rtdb->setOutput(parOut); rtdb->saveOutput(); rtdb->print(); // ------------------------------------------------------------------------ TStopwatch timer; timer.Start(); fRun->Run(nEvents); // ----- Finish ------------------------------------------------------- timer.Stop(); Double_t rtime = timer.RealTime(); Double_t ctime = timer.CpuTime(); cout << endl << endl; cout << "=== sim.C : Macro finished successfully." << endl; cout << "=== sim.C : Output file is " << outFile << endl; cout << "=== sim.C : Real time used: " << rtime << "s " << endl; cout << "=== sim.C : CPU time used : " << ctime << "s " << endl; cout << endl << endl; // ------------------------------------------------------------------------ }
void global_sim(Int_t nEvents = 10, Int_t seed = 555) { gRandom->SetSeed(seed); TString script = TString(gSystem->Getenv("LIT_SCRIPT")); // Files // TString urqmdFile = "/Users/andrey/Development/cbm/d/urqmd/auau/25gev/centr/urqmd.auau.25gev.centr.0000.ftn14"; // input UrQMD file TString urqmdFile = "../../input/urqmd.auau.25gev.centr.0000.ftn14"; // input UrQMD file TString dir = "data/"; // Directory for output simulation files TString mcFile = dir + "mc.0000.root"; //MC file name TString parFile = dir + "param.0000.root"; //Parameter file name // Geometry TString caveGeom = "cave.geo"; TString targetGeom = "target_au_250mu.geo"; TString pipeGeom = "pipe_standard.geo"; TString stsGeom = "sts/sts_v12b.geo.root"; TString richGeom = "rich/rich_v08a.geo"; TString tofGeom = "tof/tof_V13b.geo"; TString fieldMap = "field_v12a"; TString magnetGeom = "passive/magnet_v12a.geo"; // If SCRIPT environment variable is set to "yes", i.e. macro is run via script if (script == "yes") { urqmdFile = TString(gSystem->Getenv("LIT_URQMD_FILE")); mcFile = TString(gSystem->Getenv("LIT_MC_FILE")); parFile = TString(gSystem->Getenv("LIT_PAR_FILE")); } // ----- Magnetic field ----------------------------------------------- Double_t fieldZ = 50.; // field center z position Double_t fieldScale = 1.; // field scaling factor TStopwatch timer; timer.Start(); gROOT->LoadMacro("$VMCWORKDIR/macro/littrack/loadlibs.C"); loadlibs(); FairRunSim* fRun = new FairRunSim(); fRun->SetName("TGeant3"); // Transport engine fRun->SetOutputFile(mcFile); // Output file FairRuntimeDb* rtdb = fRun->GetRuntimeDb(); fRun->SetMaterials("media.geo"); // Materials // fRun->SetStoreTraj(kTRUE); if ( caveGeom != "" ) { FairModule* cave = new CbmCave("CAVE"); cave->SetGeometryFileName(caveGeom); fRun->AddModule(cave); cout << " --- " << caveGeom << endl; } if ( pipeGeom != "" ) { FairModule* pipe = new CbmPipe("PIPE"); pipe->SetGeometryFileName(pipeGeom); fRun->AddModule(pipe); cout << " --- " << pipeGeom << endl; } if ( targetGeom != "" ) { FairModule* target = new CbmTarget("Target"); target->SetGeometryFileName(targetGeom); fRun->AddModule(target); cout << " --- " << targetGeom << endl; } if ( magnetGeom != "" ) { FairModule* magnet = new CbmMagnet("MAGNET"); magnet->SetGeometryFileName(magnetGeom); fRun->AddModule(magnet); cout << " --- " << magnetGeom << endl; } if ( stsGeom != "" ) { FairDetector* sts = new CbmSts("STS", kTRUE); sts->SetGeometryFileName(stsGeom); fRun->AddModule(sts); cout << " --- " << stsGeom << endl; } if ( richGeom != "" ) { FairDetector* rich = new CbmRich("RICH", kTRUE); rich->SetGeometryFileName(richGeom); fRun->AddModule(rich); } if ( tofGeom != "" ) { FairDetector* tof = new CbmTof("TOF", kTRUE); tof->SetGeometryFileName(tofGeom); fRun->AddModule(tof); cout << " --- " << tofGeom << endl; } // ------------------------------------------------------------------------ // ----- Create magnetic field ---------------------------------------- CbmFieldMap* magField = new CbmFieldMapSym2(fieldMap); magField->SetPosition(0., 0., fieldZ); magField->SetScale(fieldScale); fRun->SetField(magField); // ------------------------------------------------------------------------ CbmMCEventHeader* mcHeader = new CbmMCEventHeader(); fRun->SetMCEventHeader(mcHeader); // ------------------------------------------------------------------------ FairPrimaryGenerator* primGen = new FairPrimaryGenerator(); // CbmUnigenGenerator* urqmdGen = new CbmUnigenGenerator(urqmdFile); CbmUrqmdGenerator* urqmdGen = new CbmUrqmdGenerator(urqmdFile); primGen->AddGenerator(urqmdGen); fRun->SetGenerator(primGen); 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); // ------------------------------------------------------------------------ // ----- Finish ------------------------------------------------------- timer.Stop(); Double_t rtime = timer.RealTime(); Double_t ctime = timer.CpuTime(); cout << endl << endl; cout << "Macro finished successfully." << endl; cout << "Test passed"<< endl; cout << " All ok " << endl; cout << "Output file is " << mcFile << endl; cout << "Real time used: " << rtime << "s " << endl; cout << "CPU time used : " << ctime << "s " << endl << endl << endl; // ------------------------------------------------------------------------ }
checkFieldMap() { // Choose field map TString fieldName = "field_v12b"; TString psFile = "check." + fieldName + ".ps"; Double_t fzref1 = 0.; // Origin plane Double_t fzref2 = 170.; // RICH entrance Double_t fzref3 = 180.; // RICH PM // ---> Regions of interest for the field Double_t fxmin = -200.; // along x axis Double_t fxmax = 200.; Double_t fymin = -200.; // along y axis Double_t fymax = 200.; Double_t fzmin = -300.; // along z axis Double_t fzmax = 300.; // ---> Target location Double_t targX = 0.; Double_t targY = 0.; Double_t targZ = 0.; // ------- Get magnetic field ----------------------------------------- CbmFieldMap* field = NULL; if ( fieldName == "field_v12b" ) field = new CbmFieldMapSym3(fieldName.Data()); else if ( fieldName == "field_v12a" ) field = new CbmFieldMapSym2(fieldName.Data()); else { cout << "=====> ERROR: Field map " << fieldName << " unknown!" << endl; exit; } field->Init(); field->Print(); Int_t type = field->GetType(); if ( type >=1 && type <= 3) const char* mapFile = field->GetFileName(); // ---------------------------------------------------------------------- // ------- Create graphs and histograms ------------------------------- Int_t fnx = TMath::Nint( (fxmax-fxmin) * 3. ); Int_t fny = TMath::Nint( (fymax-fymin) * 3. ); Int_t fnz = TMath::Nint( (fzmax-fzmin) * 3. ); Int_t fmx = TMath::Nint( (fxmax-fxmin) * 3. / 10. ); Int_t fmy = TMath::Nint( (fymax-fymin) * 3. / 10. ); TGraph hBy1(fnz+1); TGraph hBy2(fnz+1); TGraph hBt1(fnz+1); TGraph hBt2(fnz+1); TH2F hB1("hB1", "B at z_{target}", fmx, fxmin, fxmax, fmy, fymin, fymax); TH2F hB2("hB1", "B at RICH entrance", fmx, fxmin, fxmax, fmy, fymin, fymax); TH2F hB3("hB2", "B at RICH PM", fmx, fxmin, fxmax, fmy, fymin, fymax); // ---------------------------------------------------------------------- // ------- Get field and fill graphs and histograms ------------------- cout << endl; cout << "=====> Filling histograms..." << endl; Double_t x, y, z; Double_t bx, by, bz, bt, b; Double_t fdx = (fxmax-fxmin) / Double_t(fnx); Double_t fdy = (fymax-fymin) / Double_t(fny); Double_t fdz = (fzmax-fzmin) / Double_t(fnz); // ---> Loop over z axis (x=y=0) cout << " ... z axis 1" << endl; x = y = 0.; for (Int_t iz=0; iz<=fnz; iz++) { z = fzmin + Double_t(iz) * fdz; bx = field->GetBx(x,y,z) / 10.; by = field->GetBy(x,y,z) / 10.; bz = field->GetBz(x,y,z) / 10.; bt = TMath::Sqrt(bx*bx + bz*bz); hBy1.SetPoint(iz, z, by); hBt1.SetPoint(iz, z, bt); } // ---> Loop over z axis (x=y=20) cout << " ... z axis 2" << endl; x = y = 20.; for (Int_t iz=0; iz<=fnz; iz++) { z = fzmin + Double_t(iz) * fdz; bx = field->GetBx(x,y,z) / 10.; by = field->GetBy(x,y,z) / 10.; bz = field->GetBz(x,y,z) / 10.; bt = TMath::Sqrt(bx*bx + bz*bz); hBy2.SetPoint(iz, z, by); hBt2.SetPoint(iz, z, bt); } // ---> Double loop over z (target) plane cout << " ... target plane" << endl; fdx = (fxmax-fxmin) / Double_t(fmx); fdy = (fymax-fymin) / Double_t(fmy); z = fzref1; for (Int_t ix=0; ix<fmx; ix++) { x = fxmin + (Double_t(ix)+0.5) * fdx; for (Int_t iy=0; iy<fmy; iy++) { y = fymin + (Double_t(iy)+0.5) * fdy; bx = field->GetBx(x,y,z) / 10.; by = field->GetBy(x,y,z) / 10.; bz = field->GetBz(x,y,z) / 10.; b = TMath::Sqrt(bx*bx + by*by + bz*bz); hB1.SetBinContent(ix, iy, b); } } // ---> Double loop over z (RICH entrance) plane cout << " ... RICH entrance plane" << endl; fdx = (fxmax-fxmin) / Double_t(fmx); fdy = (fymax-fymin) / Double_t(fmy); z = fzref2; for (Int_t ix=0; ix<fmx; ix++) { x = fxmin + (Double_t(ix)+0.5) * fdx; for (Int_t iy=0; iy<fmy; iy++) { y = fymin + (Double_t(iy)+0.5) * fdy; bx = field->GetBx(x,y,z) / 10.; by = field->GetBy(x,y,z) / 10.; bz = field->GetBz(x,y,z) / 10.; b = TMath::Sqrt(bx*bx + by*by + bz*bz); hB2.SetBinContent(ix, iy, b); } } // ---> Double loop over z (RICH PM) plane cout << " ... RICH PM plane" << endl; fdx = (fxmax-fxmin) / Double_t(fmx); fdy = (fymax-fymin) / Double_t(fmy); z = fzref3; for (Int_t ix=0; ix<fmx; ix++) { x = fxmin + (Double_t(ix)+0.5) * fdx; for (Int_t iy=0; iy<fmy; iy++) { y = fymin + (Double_t(iy)+0.5) * fdy; bx = field->GetBx(x,y,z) / 10.; by = field->GetBy(x,y,z) / 10.; bz = field->GetBz(x,y,z) / 10.; b = TMath::Sqrt(bx*bx + by*by + bz*bz); hB3.SetBinContent(ix, iy, b); } } // ---------------------------------------------------------------------- // -------- Calculate field integral along z axis ------------------- Double_t zint1 = -400.; Double_t zint2 = 400.; Int_t nz = Int_t(zint2-zint1); Double_t bint = 0; z = zint1 - 1.; for (Int_t iz=0; iz<=nz; iz++) { z += 1; by = field->GetBy(targX, targY, z) / 10.; bint += by * 0.01; } // ---------------------------------------------------------------------- // ------- Draw graphs and histogram --------------------------------- cout << endl << "=====> Drawing..." << endl; gROOT->SetStyle("Plain"); gStyle->SetOptStat(0000); gStyle->SetPalette(1,0); gStyle->SetTitleW(0.5); gStyle->SetTitleAlign(13); gStyle->SetTitleBorderSize(0.); gStyle->SetTitleOffset(2.,"y"); gStyle->SetOptDate(2); gStyle->GetAttDate()->SetTextSize(0.02); TPostScript* ps = new TPostScript(psFile, -111); ps->Range(20,30); TCanvas* c1 = new TCanvas("c1", "canvas", 768, 1152); TPad* master = new TPad("master","", 0.10, 0.05, 0.95, 0.95); master->Draw(); master->cd(); TPad* padinf = new TPad("padinf", "", 0.12, 0.80, 0.88, 0.90); TPad* pad1 = new TPad("pad1", "", 0.05, 0.60, 0.48, 0.78); TPad* pad2 = new TPad("pad2", "", 0.52, 0.60, 0.95, 0.78); TPad* pad3 = new TPad("pad3", "", 0.05, 0.41, 0.48, 0.59); TPad* pad4 = new TPad("pad4", "", 0.52, 0.41, 0.95, 0.59); TPad* pad5 = new TPad("pad5", "", 0.30, 0.22, 0.70, 0.40); TPad* pad6 = new TPad("pad6", "", 0.10, 0.02, 0.47, 0.20); TPad* pad7 = new TPad("pad7", "", 0.53, 0.02, 0.90, 0.20); padinf->Draw(); pad1->Draw(); pad2->Draw(); pad3->Draw(); pad4->Draw(); pad5->Draw(); pad6->Draw(); pad7->Draw(); Double_t max, min; pad1->cd(); gPad->SetFillColor(10); gPad->SetLeftMargin(0.15); hBy1.SetLineColor(4); hBy1.SetLineWidth(2); hBy1.SetTitle("x = y = 0"); hBy1.GetXaxis()->SetTitle("z [cm]"); hBy1.GetYaxis()->SetTitle("B_{y} [T]"); hBy1.Draw("AC"); max = hBy1.GetHistogram()->GetMaximum(); min = hBy1.GetHistogram()->GetMinimum(); TLine l1(targZ, min, targZ, max); l1.Draw(); pad2->cd(); gPad->SetFillColor(10); gPad->SetLeftMargin(0.15); hBy2.SetLineColor(4); hBy2.SetLineWidth(2); hBy2.SetTitle("x = y = 20 cm"); hBy2.GetXaxis()->SetTitle("z [cm]"); hBy2.GetYaxis()->SetTitle("B_{y} [T]"); hBy2.Draw("AC"); max = hBy2.GetHistogram()->GetMaximum(); min = hBy2.GetHistogram()->GetMinimum(); TLine l2(targZ, min, targZ, max); l2.Draw(); pad3->cd(); gPad->SetFillColor(10); gPad->SetLeftMargin(0.15); hBt1.SetLineColor(2); hBt1.SetLineWidth(2); hBt1.SetTitle("x = y = 0"); hBt1.GetXaxis()->SetTitle("z [cm]"); hBt1.GetYaxis()->SetTitle("B_{xz} [T]"); hBt1.Draw("AC"); max = hBt1.GetHistogram()->GetMaximum(); min = hBt1.GetHistogram()->GetMinimum(); TLine l3(targZ, min, targZ, max); l3.Draw(); pad4->cd(); gPad->SetFillColor(10); gPad->SetLeftMargin(0.15); hBt2.SetLineColor(2); hBt2.SetLineWidth(2); hBt2.SetTitle("x = y = 20 cm"); hBt2.GetXaxis()->SetTitle("z [cm]"); hBt2.GetYaxis()->SetTitle("B_{xz} [T]"); hBt2.Draw("AC"); max = hBt2.GetHistogram()->GetMaximum(); min = hBt2.GetHistogram()->GetMinimum(); TLine l4(targZ, min, targZ, max); l4.Draw(); pad5->cd(); gPad->SetLeftMargin(0.15); gPad->SetFillColor(10); hB1.UseCurrentStyle(); hB1.GetXaxis()->SetTitle("x [cm]"); hB1.GetYaxis()->SetTitle("y [cm]"); char t[100]; sprintf(t,"B [T] at z= 0",fzref1); hB1.SetTitle(t); hB1.Draw("COLZ"); pad6->cd(); gPad->SetFillColor(10); gPad->SetLeftMargin(0.15); hB2.UseCurrentStyle(); hB2.GetXaxis()->SetTitle("x [cm]"); hB2.GetYaxis()->SetTitle("y [cm]"); char t[100]; sprintf(t,"B [T] at RICH entrance (z=%8.2f cm)",fzref2); hB2->SetTitle(t); hB2.Draw("COLZ"); pad7->cd(); gPad->SetFillColor(10); gPad->SetLeftMargin(0.15); hB3.UseCurrentStyle(); hB3.GetXaxis()->SetTitle("x [cm]"); hB3.GetYaxis()->SetTitle("y [cm]"); sprintf(t,"B [T] at RICH PM plane (z=%8.2f cm)",fzref3); hB3.SetTitle(t); hB3.Draw("COLZ"); TString fieldType = ""; if ( type == 0 ) fieldType = "Constant field"; else if ( type == 1 ) fieldType = "Field map"; else if ( type == 2 ) fieldType = "Field Map Sym2"; else if ( type == 3 ) fieldType = "Field Map Sym3"; char t1[300]; padinf->cd(); TPaveText info(0.1,0.1,0.9,0.9); info.SetFillColor(10); info.SetBorderSize(0); info.SetTextAlign(2); sprintf(t1,"Field name: %s, type: %s",field->GetName(),fieldType.Data()); info.AddText(0.05, 0.9, t1); Double_t bx = field->GetBx(0.,0.,0.) / 10.; Double_t by = field->GetBy(0.,0.,0.) / 10.; Double_t bz = field->GetBz(0.,0.,0.) / 10.; sprintf(t1,"Field at origin is (%7.4f, %7.4f, %7.4f) T",bx,by,bz); cout << t1 << endl; info.AddText(0.05, 0.7, t1); if ( type >= 1 && type <=3 ) { sprintf(t1, "Map file: %s",mapFile); cout << t1 << endl; info.AddText(0.05, 0.5, t1); Double_t xp = field->GetPositionX(); Double_t yp = field->GetPositionY(); Double_t zp = field->GetPositionZ(); sprintf(t1,"Centre position (%.2f, %.2f, %.2f) cm",xp,yp,zp); info->AddText(0.05, 0.3, t1); Double_t scale = field->GetScale(); sprintf(t1,"Scaling factor %.2f, Field integral along z = %.4f Tm", scale,bint); info->AddText(0.05, 0.1, t1); } info.Draw(); master->cd(); sprintf(t1,"Field check for %s", field->GetName()); TPaveLabel label(0.20, 0.92, 0.88, 0.97, t1); label->Draw(); /* c1->cd(); const char* wrkdir = getenv("VMCWORKDIR"); TString logo = TString(wrkdir) + "/input/cbmlogo.gif"; TImage* cbm = TImage::Open(logo); TPad* padimg = new TPad("padimg", "", 0.05, 0.80, 0.20, 0.95); padimg->Draw(); padimg->cd(); cbm->Draw(); */ ps->Close(); }
void run_sim(Int_t nEvents = 2) { // ======================================================================== // 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 + "/test.mc.root"; TString parFile = outDir + "/params.root"; TString HsdFile = "./jpsiHsd.auau25gev.000"; // ----- Geometries ----------------------------------------------------- TString caveGeom = "cave.geo"; TString targetGeom = "target_au_250mu.geo"; TString pipeGeom = "pipe_standard.geo"; TString magnetGeom = "passive/magnet_v09e.geo"; TString mvdGeom = "mvd/mvd_v07a.geo"; TString stsGeom = "sts/sts_v11a.geo"; TString richGeom = "rich/rich_v08a.geo"; TString trdGeom = "trd/trd_v11c.geo"; TString tofGeom = "tof/tof_v07a.geo"; // TString ecalGeom = "ecal/ecal_v08a.geo"; // ----- 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(); // ------------------------------------------------------------------------ // ---- Load libraries ------------------------------------------------- gROOT->LoadMacro("$VMCWORKDIR/gconfig/basiclibs.C"); basiclibs(); gSystem->Load("libGeoBase"); gSystem->Load("libParBase"); gSystem->Load("libBase"); gSystem->Load("libCbmBase"); gSystem->Load("libCbmData"); gSystem->Load("libField"); gSystem->Load("libGen"); gSystem->Load("libCbmGenerators"); gSystem->Load("libPassive"); gSystem->Load("libEcal"); gSystem->Load("libKF"); gSystem->Load("libMvd"); gSystem->Load("libSts"); gSystem->Load("libRich"); gSystem->Load("libTrd"); gSystem->Load("libTof"); // ----------------------------------------------------------------------- // ----- 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 CbmSts("STS", 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); } /* if ( ecalGeom != "" ) { FairDetector* ecal = new CbmEcal("ECAL", kTRUE, ecalGeom.Data()); fRun->AddModule(ecal); } */ // ------------------------------------------------------------------------ // ----- Create magnetic field ---------------------------------------- CbmFieldMap* magField = new CbmFieldMapSym2(fieldMap); magField->SetPosition(0., 0., fieldZ); magField->SetScale(fieldScale); fRun->SetField(magField); // ------------------------------------------------------------------------ // ----- Create PrimaryGenerator -------------------------------------- FairPrimaryGenerator* primGen = new FairPrimaryGenerator(); FairUrqmdGenerator* urqmdGen = new FairUrqmdGenerator(inFile); primGen->AddGenerator(urqmdGen); CbmHsdGenerator* hsdGen = new CbmHsdGenerator(HsdFile,"Jpsi"); primGen->AddGenerator(hsdGen); fRun->SetGenerator(primGen); // ------------------------------------------------------------------------ // Decay J/Psi using Pythia fRun->SetPythiaDecayer("./DecayConfig.C"); // -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; }
void run_sim(Int_t nEvents = 2) { TTree::SetMaxTreeSize(90000000000); Int_t iVerbose = 0; TString script = TString(gSystem->Getenv("SCRIPT")); TString parDir = TString(gSystem->Getenv("VMCWORKDIR")) + TString("/parameters"); //gRandom->SetSeed(10); TString inFile = "/Users/slebedev/Development/cbm/data/urqmd/auau/25gev/centr/urqmd.auau.25gev.centr.00001.root"; TString parFile = "/Users/slebedev/Development/cbm/data/simulations/rich/richreco/param.0001.root"; TString outFile = "/Users/slebedev/Development/cbm/data/simulations/rich/richreco/mc.0001.root"; TString caveGeom = "cave.geo"; TString pipeGeom = "pipe/pipe_standard.geo"; TString magnetGeom = "magnet/magnet_v12a.geo"; TString mvdGeom = ""; TString stsGeom = "sts/sts_v13d.geo.root"; TString richGeom= "rich/rich_v13c_pipe_1_al_1.root"; TString trdGeom = "trd/trd_v13g.geo.root"; TString tofGeom = "tof/tof_v13b.geo.root"; TString ecalGeom = ""; TString fieldMap = "field_v12a"; TString electrons = "yes"; // If "yes" than primary electrons will be generated Int_t NELECTRONS = 5; // number of e- to be generated Int_t NPOSITRONS = 5; // number of e+ to be generated TString urqmd = "yes"; // If "yes" than UrQMD will be used as background TString pluto = "no"; // If "yes" PLUTO particles will be embedded TString plutoFile = ""; TString plutoParticle = ""; Double_t fieldZ = 50.; // field center z position Double_t fieldScale = 1.0; // field scaling factor if (script == "yes") { inFile = TString(gSystem->Getenv("IN_FILE")); outFile = TString(gSystem->Getenv("MC_FILE")); parFile = TString(gSystem->Getenv("PAR_FILE")); caveGeom = TString(gSystem->Getenv("CAVE_GEOM")); pipeGeom = TString(gSystem->Getenv("PIPE_GEOM")); mvdGeom = TString(gSystem->Getenv("MVD_GEOM")); stsGeom = TString(gSystem->Getenv("STS_GEOM")); richGeom = TString(gSystem->Getenv("RICH_GEOM")); trdGeom = TString(gSystem->Getenv("TRD_GEOM")); tofGeom = TString(gSystem->Getenv("TOF_GEOM")); ecalGeom = TString(gSystem->Getenv("ECAL_GEOM")); fieldMap = TString(gSystem->Getenv("FIELD_MAP")); magnetGeom = TString(gSystem->Getenv("MAGNET_GEOM")); NELECTRONS = TString(gSystem->Getenv("NELECTRONS")).Atoi(); NPOSITRONS = TString(gSystem->Getenv("NPOSITRONS")).Atoi(); electrons = TString(gSystem->Getenv("ELECTRONS")); urqmd = TString(gSystem->Getenv("URQMD")); pluto = TString(gSystem->Getenv("PLUTO")); plutoFile = TString(gSystem->Getenv("PLUTO_FILE")); plutoParticle = TString(gSystem->Getenv("PLUTO_PARTICLE")); fieldScale = TString(gSystem->Getenv("FIELD_MAP_SCALE")).Atof(); } gDebug = 0; TStopwatch timer; timer.Start(); gROOT->LoadMacro("$VMCWORKDIR/macro/littrack/loadlibs.C"); loadlibs(); FairRunSim* fRun = new FairRunSim(); fRun->SetName("TGeant3"); // Transport engine fRun->SetOutputFile(outFile); FairRuntimeDb* rtdb = fRun->GetRuntimeDb(); //fRun->SetStoreTraj(kTRUE); fRun->SetMaterials("media.geo"); // Materials 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); } CbmTarget* target = new CbmTarget("Gold", 0.025); // 250 mum 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 ---------------------------------------- CbmFieldMap* magField = NULL; magField = new CbmFieldMapSym2(fieldMap); magField->SetPosition(0., 0., fieldZ); magField->SetScale(fieldScale); fRun->SetField(magField); // ----- Create PrimaryGenerator -------------------------------------- FairPrimaryGenerator* primGen = new FairPrimaryGenerator(); if (urqmd == "yes"){ //CbmUrqmdGenerator* urqmdGen = new CbmUrqmdGenerator(inFile); CbmUnigenGenerator* urqmdGen = new CbmUnigenGenerator(inFile); urqmdGen->SetEventPlane(0. , 360.); primGen->AddGenerator(urqmdGen); } //add electrons if (electrons == "yes"){ FairBoxGenerator* boxGen1 = new FairBoxGenerator(11, NPOSITRONS); boxGen1->SetPtRange(0.,3.); boxGen1->SetPhiRange(0.,360.); boxGen1->SetThetaRange(2.5,25.); boxGen1->SetCosTheta(); boxGen1->Init(); primGen->AddGenerator(boxGen1); FairBoxGenerator* boxGen2 = new FairBoxGenerator(-11, NELECTRONS); boxGen2->SetPtRange(0.,3.); boxGen2->SetPhiRange(0.,360.); boxGen2->SetThetaRange(2.5,25.); boxGen2->SetCosTheta(); boxGen2->Init(); primGen->AddGenerator(boxGen2); // CbmLitPolarizedGenerator *polGen; // polGen = new CbmLitPolarizedGenerator(443, NELECTRONS); // polGen->SetDistributionPt(0.176); // 25 GeV // polGen->SetDistributionY(1.9875,0.228); // 25 GeV // polGen->SetRangePt(0.,3.); // polGen->SetRangeY(1.,3.); // polGen->SetBox(0); // polGen->SetRefFrame(CbmLitPolarizedGenerator::kHelicity); // polGen->SetDecayMode(CbmLitPolarizedGenerator::kDiElectron); // polGen->SetAlpha(0); // polGen->Init(); // primGen->AddGenerator(polGen); } if (pluto == "yes") { FairPlutoGenerator *plutoGen= new FairPlutoGenerator(plutoFile); primGen->AddGenerator(plutoGen); } fRun->SetGenerator(primGen); 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(); fRun->Run(nEvents); 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; }