CbmRoot
CbmTransport.cxx
Go to the documentation of this file.
1 
6 #include "CbmTransport.h"
7 
8 #include "TDatabasePDG.h"
9 #include "TG4RunConfiguration.h"
10 #include "TGeant3.h"
11 #include "TGeant3TGeo.h"
12 #include "TGeant4.h"
13 #include "TGeoManager.h"
14 #include "TPythia6Decayer.h"
15 #include "TROOT.h"
16 #include "TStopwatch.h"
17 #include "TString.h"
18 #include "TSystem.h"
19 #include "TVector3.h"
20 #include "TVirtualMC.h"
21 #include <array>
22 #include <boost/filesystem.hpp>
23 #include <cassert>
24 #include <iostream>
25 #include <sstream>
26 #include <string>
27 
28 #include "FairLogger.h"
29 #include "FairMonitor.h"
30 #include "FairParRootFileIo.h"
31 #include "FairRunSim.h"
32 #include "FairRuntimeDb.h"
33 #include "FairSystemInfo.h"
34 #include "FairUrqmdGenerator.h"
35 
36 #include "CbmBeamProfile.h"
37 #include "CbmEventGenerator.h"
38 #include "CbmFieldMap.h"
39 #include "CbmFieldPar.h"
40 #include "CbmPlutoGenerator.h"
41 #include "CbmSetup.h"
42 #include "CbmStack.h"
43 #include "CbmTarget.h"
44 #include "CbmUnigenGenerator.h"
45 
46 #include "CbmGeant3Settings.h"
47 #include "CbmGeant4Settings.h"
48 
49 using std::stringstream;
50 
51 
52 // ----- Constructor ----------------------------------------------------
54  : TNamed("CbmTransport", "Transport Run")
55  , fSetup(CbmSetup::Instance())
56  , fField(nullptr)
57  , fTarget()
58  , fEventGen(new CbmEventGenerator())
59  , fEventFilter(new CbmMCEventFilter())
60  , fRun(new FairRunSim())
61  , fOutFileName()
62  , fParFileName()
63  , fGeoFileName()
64  , fGenerators()
65  , fRealTimeInit(0.)
66  , fRealTimeRun(0.)
67  , fCpuTime(0.)
68  , fEngine(kGeant3)
69  , fStackFilter(new CbmStackFilter())
70  , fGenerateRunInfo(kFALSE)
71  , fStoreTrajectories(kFALSE) {
72  // TODO: I do not like instantiating FairRunSim from this constructor;
73  // It should be done in Run(). However, the presence of a FairRunSim
74  // is required by CbmUnigenGenerator. Not a good construction; should
75  // be done better.
76 
77  // Initialisation of the TDatabasePDG. This is done here because in the
78  // course of the run, new particles may be added. The method
79  // ReadPDGTable, however, is not executed from the constructor, but only
80  // from GetParticle(), if the particle list is not empty.
81  // So, if one adds particles before the first call to GetParticle(),
82  // the particle table is never loaded.
83  // TDatabasePDG is a singleton, but there is no way to check whether
84  // it has already read the particle table file, nor to see if there are
85  // any contents, nor to clean the particle list. A truly remarkable
86  // implementation.
87  auto pdgdb = TDatabasePDG::Instance();
88  pdgdb->ReadPDGTable();
89 
90  // By default, vertex smearing along the beam is activated
91  fEventGen->SmearVertexZ(kTRUE);
92  fRun->SetGenerator(fEventGen); // has to be available for some generators
93 }
94 // --------------------------------------------------------------------------
95 
96 
97 // ----- Destructor -----------------------------------------------------
99 // --------------------------------------------------------------------------
100 
101 
102 // ----- Add a file-based input -----------------------------------------
103 void CbmTransport::AddInput(const char* fileName, ECbmGenerator genType) {
104 
105  FairGenerator* generator = NULL;
106 
107  if (gSystem->AccessPathName(fileName)) {
108  LOG(fatal) << GetName() << ": Input file " << fileName << " not found!";
109  return;
110  }
111 
112  switch (genType) {
113  case kUnigen: generator = new CbmUnigenGenerator(TString(fileName)); break;
114  case kUrqmd: generator = new FairUrqmdGenerator(fileName); break;
115  case kPluto: generator = new CbmPlutoGenerator(fileName); break;
116  }
117 
118  assert(generator);
119  fEventGen->AddGenerator(generator);
120 }
121 // --------------------------------------------------------------------------
122 
123 
124 // ----- Add a generator-based input ------------------------------------
125 void CbmTransport::AddInput(FairGenerator* generator) {
126  assert(generator);
127  fEventGen->AddGenerator(generator);
128 }
129 // --------------------------------------------------------------------------
130 
131 
132 // ----- Configure the TVirtualMC ---------------------------------------
134 
135  std::cout << std::endl;
136  LOG(info) << GetName() << ": Configuring VMC...";
137  TVirtualMC* vmc = nullptr;
138 
139  if (fEngine == kGeant3) {
140  TString* gModel = fRun->GetGeoModel();
141  if (strncmp(gModel->Data(), "TGeo", 4) == 0) {
142  LOG(info) << GetName() << ": Create TGeant3TGeo";
143  vmc = new TGeant3TGeo("C++ Interface to Geant3 with TGeo");
144  } //? Geant3 with TGeo
145  else {
146  LOG(info) << GetName() << ": Create TGeant3";
147  vmc = new TGeant3("C++ Interface to Geant3");
148  } //? Native Geant3
150  fGeant3Settings->Init(vmc);
151  } //? Geant3
152 
153  else if (fEngine == kGeant4) {
154  LOG(info) << GetName() << ": Create TGeant4";
156  std::array<std::string, 3> runConfigSettings =
158  TG4RunConfiguration* runConfig = new TG4RunConfiguration(
159  runConfigSettings[0], runConfigSettings[1], runConfigSettings[2]);
160  vmc = new TGeant4("TGeant4", "C++ Interface to Geant4", runConfig);
161  fGeant4Settings->Init(vmc);
162  } //? Geant4
163 
164  else
165  LOG(fatal) << GetName() << ": unknown transport engine!";
166 
167  // Create stack
168  std::unique_ptr<CbmStack> stack(new CbmStack());
169  stack->SetFilter(fStackFilter);
170  if (vmc) vmc->SetStack(stack.release());
171 }
172 // --------------------------------------------------------------------------
173 
174 
175 // ----- Force creation of event vertex at a given z position -----------
176 void CbmTransport::ForceVertexAtZ(Double_t zVertex) {
177  assert(fEventGen);
178  fEventGen->ForceVertexAtZ(zVertex);
179 }
180 // --------------------------------------------------------------------------
181 
182 
183 // ----- Force creation of event vertex in the target -------------------
185  assert(fEventGen);
187 }
188 // --------------------------------------------------------------------------
189 
190 
191 // ----- Force user-defined single-mode decays --------------------------
193 
194  assert(gMC);
195  auto pdgdb = TDatabasePDG::Instance();
196 
197  // --- Setting user decays does not work with TGeant4
198  if ((!fDecayModes.empty()) && fEngine == kGeant4)
199  LOG(fatal) << GetName()
200  << ": Forcing decay modes is not possible with TGeant4!";
201 
202  for (auto& decay : fDecayModes) {
203 
204  Int_t pdg = decay.first;
205  UInt_t nDaughters = decay.second.size();
206  stringstream log;
207  log << GetName() << ": Force decay " << pdgdb->GetParticle(pdg)->GetName()
208  << " -> ";
209 
210  // First check whether VMC knows the particle. Not all particles
211  // in TDatabasePDG are necessarily defined in VMC.
212  // This check is there because the call to TVirtualMC::SetUserDecay
213  // has no return value signifying success. If the particle is not
214  // found, just an error message is printed, which most likely
215  // goes unnoticed by the user.
216  // The access to ParticleMCTpye seems to me the only way to check.
217  // No method like Bool_t CheckParticle(Int_t) is there, which any
218  // sensible programmer would have put.
219  if (gMC->ParticleMCType(pdg)
220  == kPTUndefined) { // At least TGeant3 delivers that
221  LOG(info) << log.str();
222  LOG(fatal) << GetName() << ": PDG " << pdg << " not in VMC!";
223  continue;
224  }
225 
226  // For up to three daughters, the native decayer is used
227  if (nDaughters <= 3) {
228  Float_t branch[6] = {100., 0., 0., 0., 0., 0.}; // branching ratios
229  Int_t mode[6][3] = {{0, 0, 0},
230  {0, 0, 0},
231  {0, 0, 0},
232  {0, 0, 0},
233  {0, 0, 0},
234  {0, 0, 0}}; // decay modes
235  for (UInt_t iDaughter = 0; iDaughter < nDaughters; iDaughter++) {
236  mode[0][iDaughter] = decay.second[iDaughter];
237  log << pdgdb->GetParticle(decay.second[iDaughter])->GetName() << " ";
238  }
239  Bool_t success = gMC->SetDecayMode(pdg, branch, mode);
240  if (!success) {
241  LOG(info) << log.str();
242  LOG(fatal) << GetName() << ": Setting decay mode failed!";
243  }
244  log << ", using native decayer.";
245  } //? not more than three daughters
246 
247  // For more than three daughters, we must use TPythia6 as external decayer
248  else {
249  auto p6decayer = TPythia6Decayer::Instance();
250  Int_t daughterPdg[nDaughters];
251  Int_t multiplicity[nDaughters];
252  for (UInt_t iDaughter = 0; iDaughter < nDaughters; iDaughter++) {
253  daughterPdg[iDaughter] = decay.second[iDaughter];
254  multiplicity[iDaughter] = 1;
255  log << pdgdb->GetParticle(decay.second[iDaughter])->GetName() << " ";
256  } //# daughters
257  p6decayer->ForceParticleDecay(pdg, daughterPdg, multiplicity, nDaughters);
258  // We have to tell the VMC to use the Pythia decayer for this particle
259  gMC->SetUserDecay(pdg);
260  } //? more than three daughters
261 
262  LOG(info) << log.str();
263  } //# user-defined decay modes
264 }
265 // --------------------------------------------------------------------------
266 
267 // ----- Initialisation of event generator ------------------------------
269 
270  // --- Set the target properties to the event generator
272 
273  // --- Log output
274  std::cout << std::endl;
275  LOG(info) << "----- Settings for event generator";
276  fEventGen->Print();
277  LOG(info) << "----- End settings for event generator";
278  std::cout << std::endl;
279 
280  // --- If a target is specified, check its consistency with the beam
281  // --- profile. The average beam must hit the target surface.
282  if (fTarget) {
284  LOG(fatal) << GetName()
285  << ": Beam profile is not consistent with target!";
286  } //? Target not consistent with beam
287  } //? Target specified
288 }
289 // --------------------------------------------------------------------------
290 
291 
292 // ----- Set the source the setup will be loaded from -------------------
294  fSetup->SetSetupSource(setupSource);
295 }
296 // --------------------------------------------------------------------------
297 
298 
299 // ----- Load a standard setup ------------------------------------------
300 void CbmTransport::LoadSetup(const char* setupName) {
301  fSetup->LoadSetup(setupName);
302 }
303 // --------------------------------------------------------------------------
304 
305 
306 // ----- Register ions to the TDatabsePDG -------------------------------
308 
309  // TODO: Better would be loading the additional particles from a text file.
310  // TDatabasePDG reads the particle definitions from pdg_table.txt
311  // (in $SIMPATH/share/root/etc). The method TDatabase::ReadPDGTable()
312  // is triggered on first call to TDatabasePDG::GetParticle(Int_t), if the
313  // database is still empty.
314  // We could call TDatabasePDG::ReadPDGTable(name_of_cbm_file) after the
315  // first initialisation of the database; the there defined particles would
316  // be added on top of the existing ones.
317 
318  // Particle database and variables
319  TDatabasePDG* pdgdb = TDatabasePDG::Instance();
320  const char* name = "";
321  Int_t code = 0;
322  Double_t mass = 0.;
323  Bool_t stable = kTRUE;
324  Double_t charge = 0.;
325 
326  // --- deuteron and anti-deuteron
327  name = "d+";
328  code = 1000010020;
329  mass = 1.876124;
330  stable = kTRUE;
331  charge = 1.;
332  pdgdb->AddParticle(name, name, mass, stable, 0., charge, "Ion", code);
333  pdgdb->AddAntiParticle("d-", -1 * code);
334 
335  // --- tritium and anti-tritium
336  name = "t+";
337  code = 1000010030;
338  mass = 2.809432;
339  stable = kTRUE;
340  charge = 1.;
341  pdgdb->AddParticle(name, name, mass, stable, 0., charge, "Ion", code);
342  pdgdb->AddAntiParticle("t-", -1 * code);
343 
344  // --- Helium_3 and its anti-nucleus
345  name = "He3+";
346  code = 1000020030;
347  mass = 2.809413;
348  stable = kTRUE;
349  charge = 2.;
350  pdgdb->AddParticle(name, name, mass, stable, 0., charge, "Ion", code);
351  pdgdb->AddAntiParticle("He3-", -1 * code);
352 
353  // --- Helium_4 and its anti-nucleus
354  name = "He4+";
355  code = 1000020040;
356  mass = 3.7284;
357  stable = kTRUE;
358  charge = 2.;
359  pdgdb->AddParticle(name, name, mass, stable, 0., charge, "Ion", code);
360  pdgdb->AddAntiParticle("He3-", -1 * code);
361 }
362 // --------------------------------------------------------------------------
363 
364 
365 // ----- Register radiation length --------------------------------------
366 void CbmTransport::RegisterRadLength(Bool_t choice) {
367  assert(fRun);
368  fRun->SetRadLenRegister(choice);
369  LOG(info) << GetName() << ": Radiation length register is enabled";
370 }
371 // --------------------------------------------------------------------------
372 
373 
374 // ----- Create and register the setup modules --------------------------
376 // --------------------------------------------------------------------------
377 
378 
379 // ----- Set correct decay modes for pi0 and eta ------------------------
380 void CbmTransport::PiAndEtaDecay(TVirtualMC* vmc) {
381 
382  assert(vmc);
383  LOG(info) << GetName() << ": Set decay modes for pi0 and eta";
384 
385  if (fEngine == kGeant4) {
386  std::cout << std::endl << std::endl;
387  LOG(warn) << "***********************************";
388  LOG(warn) << "***********************************";
389  LOG(warn) << GetName() << ": User decay modes cannot be set with TGeant4!";
390  LOG(warn) << GetName()
391  << ": Built-in decay modes for pi0 and eta will be used!";
392  LOG(warn) << "***********************************";
393  LOG(warn) << "***********************************";
394  std::cout << std::endl << std::endl;
395  return;
396  }
397 
398  TGeant3* gMC3 = static_cast<TGeant3*>(vmc);
399  assert(vmc);
400 
401  // Decay modes for eta mesons (PDG 2016)
402  Int_t modeEta[6]; // decay modes
403  Float_t brEta[6]; // branching ratios in %
404 
405  // --- eta -> gamma gamma
406  modeEta[0] = 101;
407  brEta[0] = 39.41;
408 
409  // --- eta -> pi0 pi0 pi0
410  modeEta[1] = 70707;
411  brEta[1] = 32.68;
412 
413  // --- eta -> pi+ pi- pi0
414  modeEta[2] = 80907;
415  brEta[2] = 22.92;
416 
417  // --- eta -> pi+ pi- gamma
418  modeEta[3] = 80901;
419  brEta[3] = 4.22;
420 
421  // --- eta -> e+ e- gamma
422  modeEta[4] = 30201;
423  brEta[4] = 0.69;
424 
425  // --- eta -> pi0 gamma gamma
426  modeEta[5] = 10107;
427  brEta[5] = 2.56e-2;
428 
429  // --- Set the eta decays
430  gMC3->Gsdk(17, brEta, modeEta);
431 
432  // --- Decay modes for pi0
433  Int_t modePi[6]; // decay modes
434  Float_t brPi[6]; // branching ratios in %
435 
436  // --- pi0 -> gamma gamma
437  modePi[0] = 101;
438  brPi[0] = 98.823;
439 
440  // --- pi0 -> e+ e- gamma
441  modePi[1] = 30201;
442  brPi[1] = 1.174;
443 
444  // --- No other channels for pi0
445  for (Int_t iMode = 2; iMode < 6; iMode++) {
446  modePi[iMode] = 0;
447  brPi[iMode] = 0.;
448  }
449 
450  // --- Set the pi0 decays
451  gMC3->Gsdk(7, brPi, modePi);
452 }
453 // --------------------------------------------------------------------------
454 
455 
456 // ----- Execute transport run ------------------------------------------
457 void CbmTransport::Run(Int_t nEvents) {
458 
459  // --- Timer
460  TStopwatch timer;
461 
462  // --- Check presence of required requisites
463  if (fOutFileName.IsNull())
464  LOG(fatal) << GetName() << ": No output file specified!";
465  if (fParFileName.IsNull())
466  LOG(fatal) << GetName() << ": No parameter file specified!";
467  std::cout << std::endl << std::endl;
468 
469 
470  // --- Add some required particles to the TDatabasePDG
471  RegisterIons();
472 
473 
474  // --- Set transport engine
475  const char* engineName = "";
476  switch (fEngine) {
477  case kGeant3: engineName = "TGeant3"; break;
478  case kGeant4: engineName = "TGeant4"; break;
479  default: {
480  LOG(warn) << GetName() << ": Unknown transport engine ";
481  engineName = "TGeant3";
482  break;
483  }
484  } //? engine
485  LOG(info) << GetName() << ": Using engine " << engineName;
486  fRun->SetName(engineName);
487 
488 
489  // --- Set output file name
490  fRun->SetOutputFile(fOutFileName);
491 
492  // --- Create and register the setup modules, field and media with FairRoot
493  RegisterSetup();
494 
495  // --- Create and register the target
496  if (fTarget) {
497  LOG(info) << fTarget->ToString();
498  fRun->AddModule(fTarget.get());
499  } else
500  LOG(warn) << GetName() << ": No target defined!";
501 
502 
503  // --- Create the magnetic field
504  LOG(info) << GetName() << ": Register magnetic field";
505  LOG(info) << fField;
506  if (!fField) fField = fSetup->CreateFieldMap();
507  fField->Print("");
508  fRun->SetField(fField);
509 
510 
511  // --- Initialise the event generator
513 
514 
515  // --- Trigger generation of run info
516  fRun->SetGenerateRunInfo(fGenerateRunInfo);
517 
518 
519  // --- Trigger storage of trajectories, if chosen
520  fRun->SetStoreTraj(fStoreTrajectories);
521 
522 
523  // --- Set VMC configuration
524  std::function<void()> f = std::bind(&CbmTransport::ConfigureVMC, this);
525  fRun->SetSimSetup(f);
526 
527 
528  // --- Set event filter task
529  fRun->AddTask(fEventFilter.get());
530 
531 
532  // --- Initialise run
533  fRun->Init();
534 
535 
536  // --- Force user-defined decays. This has to happen after FairRunSim::Init()
537  // because otherwise there seem to be no particles in GEANT.
538  ForceUserDecays();
539 
540 
541  // --- Set correct decay modes for pi0 and eta
542  // --- This is needed only when using Geant3
543  if (fEngine == kGeant3) PiAndEtaDecay(gMC);
544 
545 
546  // --- Runtime database
547  FairRuntimeDb* rtdb = fRun->GetRuntimeDb();
548  CbmFieldPar* fieldPar =
549  static_cast<CbmFieldPar*>(rtdb->getContainer("CbmFieldPar"));
550  fieldPar->SetParameters(fField);
551  fieldPar->setChanged();
552  FairParRootFileIo* parOut = new FairParRootFileIo(kTRUE);
553  parOut->open(fParFileName.Data());
554  rtdb->setOutput(parOut);
555  rtdb->saveOutput();
556  rtdb->print();
557 
558 
559  // --- Measure time for initialisation
560  timer.Stop();
561  fRealTimeInit = timer.RealTime();
562 
563  TFile* old = gFile;
564  TDirectory* oldDir = gDirectory;
565 
566  // Write Transport Settings to the output file
567  TFile* outfile = fRun->GetOutputFile();
568  outfile->cd();
569 
570  LOG(info) << "Here I am";
571  if (fEngine == kGeant3) {
572  LOG(info) << "Write Geant3Settings";
573  fGeant3Settings->Write();
574  } else if (fEngine == kGeant4) {
575  LOG(info) << "Write Geant4Settings";
576  fGeant4Settings->Write();
577  }
578  gFile = old;
579  gDirectory = oldDir;
580 
581  // --- Start run
582  timer.Start(kFALSE); // without reset
583  fRun->Run(nEvents);
584  timer.Stop();
585  fRealTimeRun = timer.RealTime() - fRealTimeInit;
586  fCpuTime = timer.CpuTime();
587 
588  // --- Create a geometry file if required
589  if (!fGeoFileName.IsNull()) fRun->CreateGeometryFile(fGeoFileName);
590 
591 
592  // --- Screen log
593  std::cout << std::endl;
594  LOG(info) << GetName() << ": Run finished successfully.";
595  LOG(info) << GetName() << ": Wall time for Init : " << fRealTimeInit << " s ";
596  LOG(info) << GetName() << ": Wall time for Run : " << fRealTimeRun << " s ("
597  << fRealTimeRun / fEventFilter->GetNofInputEvents()
598  << " s / event)";
599  LOG(info) << GetName() << ": Output file : " << fOutFileName;
600  LOG(info) << GetName() << ": Parameter file : " << fParFileName;
601  if (!fGeoFileName.IsNull())
602  LOG(info) << GetName() << ": Geometry file : " << fGeoFileName;
603  std::cout << std::endl << std::endl;
604 
605 
606  // --- Remove TGeoManager
607  // To avoid crashes when exiting. Reason for this behaviour is unknown.
608  if (gGeoManager) {
609  if (gROOT->GetVersionInt() >= 60602) {
610  gGeoManager->GetListOfVolumes()->Delete();
611  gGeoManager->GetListOfShapes()->Delete();
612  }
613  delete gGeoManager;
614  }
615 }
616 // --------------------------------------------------------------------------
617 
618 
619 // ----- Set the beam angle distribution --------------------------------
620 void CbmTransport::SetBeamAngle(Double_t x0,
621  Double_t y0,
622  Double_t sigmaX,
623  Double_t sigmaY) {
624  assert(fEventGen);
625  fEventGen->SetBeamAngle(x0, y0, sigmaX, sigmaY);
626 }
627 // --------------------------------------------------------------------------
628 
629 
630 // ----- Set the beam position ------------------------------------------
632  Double_t y0,
633  Double_t sigmaX,
634  Double_t sigmaY,
635  Double_t z) {
636  assert(fEventGen);
637  fEventGen->SetBeamPosition(x0, y0, sigmaX, sigmaY, z);
638 }
639 // --------------------------------------------------------------------------
640 
641 
642 // ----- Set a decay mode -----------------------------------------------
644  UInt_t nDaughters,
645  Int_t* daughterPdg) {
646 
647  if (fDecayModes.count(pdg) != 0) {
648  LOG(fatal) << GetName() << ": User decay mode for PDG " << pdg
649  << " is already defined!";
650  return;
651  }
652 
653  for (UInt_t iDaughter = 0; iDaughter < nDaughters; iDaughter++) {
654  fDecayModes[pdg].push_back(daughterPdg[iDaughter]);
655  }
656 }
657 // --------------------------------------------------------------------------
658 
659 
660 // ----- Set geometry file name -----------------------------------------
661 void CbmTransport::SetGeoFileName(TString fileName) {
662 
663  // Check for the directory
664  std::string name = fileName.Data();
665  Int_t found = name.find_last_of("/");
666  if (found >= 0) {
667  TString geoDir = name.substr(0, found);
668  if (gSystem->AccessPathName(geoDir.Data())) {
669  LOG(error) << GetName() << ": Directory for geometry file " << geoDir
670  << " does not exist; the file will not be created.";
671  return;
672  } //? Directory of geometry file does not exist
673  } //? File name contains directory path
674 
675  fGeoFileName = fileName;
676 }
677 // --------------------------------------------------------------------------
678 
679 
680 // ----- Set parameter file name ----------------------------------------
681 void CbmTransport::SetParFileName(TString fileName) {
682 
683  // --- If file does not exist, check the directory
684  if (gSystem->AccessPathName(fileName)) {
685  std::string name = fileName.Data();
686  Int_t found = name.find_last_of("/");
687  if (found >= 0) {
688  TString parDir = name.substr(0, found);
689  if (gSystem->AccessPathName(parDir.Data())) {
690  LOG(fatal) << GetName() << ": Parameter directory " << parDir
691  << " does not exist!";
692  return;
693  } //? Directory of parameter file does not exist
694  } //? File name contains directory path
695  } //? Parameter file does not exist
696 
697  fParFileName = fileName;
698 }
699 // --------------------------------------------------------------------------
700 
701 
702 // ----- Set random event plane generation ------------------------------
703 void CbmTransport::SetRandomEventPlane(Double_t phiMin, Double_t phiMax) {
704  fEventGen->SetEventPlane(phiMin, phiMax);
705 }
706 // --------------------------------------------------------------------------
707 
708 
709 // ----- Set output file name -------------------------------------------
710 void CbmTransport::SetOutFileName(TString fileName) {
711 
712  // Check for the directory
713  std::string name = fileName.Data();
714  Int_t found = name.find_last_of("/");
715  if (found >= 0) {
716  TString outDir = name.substr(0, found);
717  if (gSystem->AccessPathName(outDir.Data())) {
718  LOG(fatal) << GetName() << ": Output directory " << outDir
719  << " does not exist!";
720  return;
721  } //? Directory of output file does not exist
722  } //? File name contains directory path
723 
724  fOutFileName = fileName;
725 }
726 // --------------------------------------------------------------------------
727 
728 
729 // ----- Define the target ----------------------------------------------
730 void CbmTransport::SetTarget(const char* medium,
731  Double_t thickness,
732  Double_t diameter,
733  Double_t x,
734  Double_t y,
735  Double_t z,
736  Double_t angle) {
737 
738  fTarget.reset(new CbmTarget(medium, thickness, diameter));
739  fTarget->SetPosition(x, y, z);
740  fTarget->SetRotation(angle);
741 }
742 // --------------------------------------------------------------------------
743 
744 
745 // ----- Enable vertex distribution in x and y --------------------------
746 void CbmTransport::SetVertexSmearXY(Bool_t choice) {
747  assert(fEventGen);
748  fEventGen->SmearGausVertexXY(choice);
749 }
750 // --------------------------------------------------------------------------
751 
752 
753 // ----- Enable vertex distribution z -----------------------------------
754 void CbmTransport::SetVertexSmearZ(Bool_t choice) {
755  assert(fEventGen);
756  fEventGen->SmearVertexZ(choice);
757 }
758 // --------------------------------------------------------------------------
759 
CbmTransport::fDecayModes
std::map< Int_t, std::vector< Int_t > > fDecayModes
Definition: CbmTransport.h:379
CbmTransport::fEventFilter
std::unique_ptr< CbmMCEventFilter > fEventFilter
Definition: CbmTransport.h:365
CbmMCEventFilter
Class deciding whether to store an MC event.
Definition: CbmMCEventFilter.h:34
CbmTransport::SetSetupSource
void SetSetupSource(ECbmSetupSource setupSource)
Set the source the setup will be loaded from.
Definition: CbmTransport.cxx:293
CbmTransport::InitEventGenerator
void InitEventGenerator()
Event generator initialisation.
Definition: CbmTransport.cxx:268
f
float f
Definition: L1/vectors/P4_F32vec4.h:24
CbmTransport::fParFileName
TString fParFileName
Definition: CbmTransport.h:368
CbmStackFilter
Class for filtering the stack before writing.
Definition: CbmStackFilter.h:61
CbmTransport::SetRandomEventPlane
void SetRandomEventPlane(Double_t phiMin=0., Double_t phiMax=2. *TMath::Pi())
Activate random event plane.
Definition: CbmTransport.cxx:703
CbmTransport::fOutFileName
TString fOutFileName
Definition: CbmTransport.h:367
CbmBeamProfile.h
kUrqmd
@ kUrqmd
Definition: CbmTransport.h:30
CbmTransport::fEventGen
CbmEventGenerator * fEventGen
Definition: CbmTransport.h:364
CbmTransport::fGeant4Settings
CbmGeant4Settings * fGeant4Settings
Definition: CbmTransport.h:382
kPluto
@ kPluto
Definition: CbmTransport.h:30
CbmSetup::SetSetupSource
void SetSetupSource(ECbmSetupSource setupSource)
Set the source the setup will be loaded from.
Definition: CbmSetup.cxx:229
kGeant4
@ kGeant4
Definition: CbmTransport.h:32
CbmTransport::fEngine
ECbmEngine fEngine
Definition: CbmTransport.h:374
CbmTransport::fRealTimeInit
Double_t fRealTimeInit
Definition: CbmTransport.h:371
CbmUnigenGenerator
Generates input to transport simulation from files in Unigen format.
Definition: CbmUnigenGenerator.h:44
CbmTransport::fGeant3Settings
CbmGeant3Settings * fGeant3Settings
Definition: CbmTransport.h:381
CbmGeant3Settings::Init
void Init(TVirtualMC *)
Set all parameters defined in this class.
Definition: CbmGeant3Settings.cxx:8
CbmTransport::~CbmTransport
virtual ~CbmTransport()
Destructor
Definition: CbmTransport.cxx:98
CbmEventGenerator
CbmEventGenerator.
Definition: CbmEventGenerator.h:34
CbmTransport::fField
FairField * fField
Definition: CbmTransport.h:362
CbmPlutoGenerator.h
CbmTransport
User interface class for transport simulation.
Definition: CbmTransport.h:40
CbmEventGenerator::SetBeamAngle
void SetBeamAngle(Double_t meanThetaX, Double_t meanThetaY, Double_t sigmaThetaX=-1., Double_t sigmaThetaY=-1.)
Set the beam angle in the focal plane.
Definition: CbmEventGenerator.cxx:231
kUnigen
@ kUnigen
Definition: CbmTransport.h:30
CbmTarget
Class for constructing the geometry of the CBM target.
Definition: CbmTarget.h:31
CbmEventGenerator::SetBeamPosition
void SetBeamPosition(Double_t meanX, Double_t meanY, Double_t sigmaX=-1., Double_t sigmaY=-1., Double_t zF=0.)
Set the beam position in the focal plane.
Definition: CbmEventGenerator.cxx:241
CbmFieldPar::SetParameters
void SetParameters(FairField *field)
Definition: CbmFieldPar.cxx:160
CbmTransport::fSetup
CbmSetup * fSetup
Definition: CbmTransport.h:361
CbmSetup::CreateFieldMap
CbmFieldMap * CreateFieldMap()
Definition: CbmSetup.cxx:40
CbmStack.h
CbmPlutoGenerator
Definition: CbmPlutoGenerator.h:34
CbmTransport::SetBeamPosition
void SetBeamPosition(Double_t x0, Double_t y0, Double_t sigmaX=-1., Double_t sigmaY=-1., Double_t zF=0.)
Set the beam position.
Definition: CbmTransport.cxx:631
CbmTransport::RegisterIons
void RegisterIons()
Register ions.
Definition: CbmTransport.cxx:307
CbmEventGenerator::Print
virtual void Print(Option_t *opt="") const
Log output.
Definition: CbmEventGenerator.cxx:212
CbmEventGenerator::ForceVertexInTarget
void ForceVertexInTarget(Bool_t choice=kTRUE)
Enable or disable forcing the vertex to be in the target.
Definition: CbmEventGenerator.h:57
CbmTransport::AddInput
void AddInput(const char *fileName, ECbmGenerator generator=kUnigen)
Add an input by file name and generator type.
Definition: CbmTransport.cxx:103
CbmSetup
Definition: CbmSetup.h:31
CbmGeant3Settings.h
CbmSetup.h
CbmTransport::fRealTimeRun
Double_t fRealTimeRun
Definition: CbmTransport.h:372
CbmEventGenerator::ForceVertexAtZ
void ForceVertexAtZ(Double_t zVertex)
Force event vertex to be at a given z.
Definition: CbmEventGenerator.cxx:39
CbmTransport::SetVertexSmearZ
void SetVertexSmearZ(Bool_t choice=kTRUE)
Enable smearing of event vertex in z.
Definition: CbmTransport.cxx:754
CbmFieldPar.h
CbmTransport::CbmTransport
CbmTransport()
Constructor.
Definition: CbmTransport.cxx:53
CbmTransport::SetGeoFileName
void SetGeoFileName(TString name)
Define geometry file name (output)
Definition: CbmTransport.cxx:661
log
friend F32vec4 log(const F32vec4 &a)
Definition: L1/vectors/P4_F32vec4.h:135
CbmTransport::RegisterSetup
void RegisterSetup()
Create and register the setup modules.
Definition: CbmTransport.cxx:375
CbmTransport::ForceUserDecays
void ForceUserDecays()
Force user-defined single-mode decays.
Definition: CbmTransport.cxx:192
CbmTransport::fCpuTime
Double_t fCpuTime
Definition: CbmTransport.h:373
CbmEventGenerator::GetBeamProfile
const CbmBeamProfile & GetBeamProfile()
Beam profile.
Definition: CbmEventGenerator.h:65
CbmTransport::RegisterRadLength
void RegisterRadLength(Bool_t choice=kTRUE)
Enable registration of radiation length.
Definition: CbmTransport.cxx:366
CbmTransport::fGenerateRunInfo
Bool_t fGenerateRunInfo
Definition: CbmTransport.h:376
CbmGeant4Settings::Init
void Init(TVirtualMC *)
Set all parameters defined in this class.
Definition: CbmGeant4Settings.cxx:12
CbmTransport::ForceVertexInTarget
void ForceVertexInTarget(Bool_t choice=kTRUE)
Enable or disable forcing the vertex to be in the target.
Definition: CbmTransport.cxx:184
CbmTransport::ConfigureVMC
void ConfigureVMC()
Set the parameters for the TVirtualMC.
Definition: CbmTransport.cxx:133
CbmTransport::PiAndEtaDecay
void PiAndEtaDecay(TVirtualMC *vmc)
Correct decay modes for pi0 and eta.
Definition: CbmTransport.cxx:380
CbmTransport::fRun
FairRunSim * fRun
Definition: CbmTransport.h:366
CbmTransport::fStackFilter
std::unique_ptr< CbmStackFilter > fStackFilter
Definition: CbmTransport.h:375
CbmTransport::fStoreTrajectories
Bool_t fStoreTrajectories
Definition: CbmTransport.h:377
CbmTarget.h
CbmTransport::fGeoFileName
TString fGeoFileName
Definition: CbmTransport.h:369
CbmBeamProfile::CheckWithTarget
Bool_t CheckWithTarget(const CbmTarget &target) const
Check consistency with a target.
Definition: CbmBeamProfile.cxx:27
CbmUnigenGenerator.h
CbmGeant3Settings
User interface class to define the Geant3 simulation settings.
Definition: CbmGeant3Settings.h:19
CbmTransport::SetParFileName
void SetParFileName(TString name)
Define parameter file name.
Definition: CbmTransport.cxx:681
ECbmSetupSource
ECbmSetupSource
Definition: CbmSetup.h:25
CbmGeant4Settings
User interface class to define the Geant4 simulation settings.
Definition: CbmGeant4Settings.h:23
CbmTransport::Run
void Run(Int_t nEvents)
Execute transport run.
Definition: CbmTransport.cxx:457
ECbmGenerator
ECbmGenerator
Definition: CbmTransport.h:30
ClassImp
ClassImp(CbmTransport)
x
Double_t x
Definition: CbmMvdSensorDigiToHitTask.cxx:68
CbmTransport::SetDecayMode
void SetDecayMode(Int_t pdg, UInt_t nDaughters, Int_t *daughterPdg)
Set a decay mode for a particle.
Definition: CbmTransport.cxx:643
CbmEventGenerator::SetTarget
void SetTarget(std::shared_ptr< const CbmTarget > target)
Set target properties.
Definition: CbmEventGenerator.h:135
y
Double_t y
Definition: CbmMvdSensorDigiToHitTask.cxx:68
CbmSetup::RegisterSetup
void RegisterSetup()
Definition: CbmSetup.h:53
CbmTransport::ForceVertexAtZ
void ForceVertexAtZ(Double_t zVertex)
Force the event vertex to be at a given z position.
Definition: CbmTransport.cxx:176
CbmTransport::SetVertexSmearXY
void SetVertexSmearXY(Bool_t choice=kTRUE)
Enable smearing of event vertex in x and y.
Definition: CbmTransport.cxx:746
CbmGeant4Settings::GetG4RunConfig
std::array< std::string, 3 > GetG4RunConfig()
Get the Geant4 run configuration.
Definition: CbmGeant4Settings.h:53
kGeant3
@ kGeant3
Definition: CbmTransport.h:32
CbmTransport::LoadSetup
void LoadSetup(const char *setupName)
Use a standard setup.
Definition: CbmTransport.cxx:300
CbmFieldMap.h
CbmTransport::SetTarget
void SetTarget(const char *medium, Double_t thickness, Double_t diameter, Double_t x=0., Double_t y=0., Double_t z=0., Double_t rot=0.)
Define the target.
Definition: CbmTransport.cxx:730
CbmStack
Definition: CbmStack.h:45
CbmFieldPar
Definition: CbmFieldPar.h:31
CbmTransport.h
CbmSetup::LoadSetup
void LoadSetup(const char *setupName)
Definition: CbmSetup.h:48
CbmEventGenerator.h
CbmGeant4Settings.h
CbmTransport::SetBeamAngle
void SetBeamAngle(Double_t x0, Double_t y0, Double_t sigmaX=-1., Double_t sigmaY=-1.)
Set the beam angle (emittency at the beam position)
Definition: CbmTransport.cxx:620
CbmTransport::SetOutFileName
void SetOutFileName(TString name)
Define output file name.
Definition: CbmTransport.cxx:710
CbmTransport::fTarget
std::shared_ptr< CbmTarget > fTarget
Definition: CbmTransport.h:363