From c3017df7611f756badb24d622b3d95d289e4368c Mon Sep 17 00:00:00 2001
From: Volker Friese <v.friese@gsi.de>
Date: Wed, 2 Sep 2020 11:18:25 +0200
Subject: [PATCH] Transport macros for mcbm, including transport of beam
 through setup.

---
 macro/mcbm/mcbm_digi_mixed.C | 120 +++++++++++++++++++++++++++++++++++
 macro/mcbm/mcbm_transport.C  |   2 +-
 2 files changed, 121 insertions(+), 1 deletion(-)
 create mode 100644 macro/mcbm/mcbm_digi_mixed.C

diff --git a/macro/mcbm/mcbm_digi_mixed.C b/macro/mcbm/mcbm_digi_mixed.C
new file mode 100644
index 0000000000..c08f4d936c
--- /dev/null
+++ b/macro/mcbm/mcbm_digi_mixed.C
@@ -0,0 +1,120 @@
+/** @file mcbm_digi_mixed.C
+ ** @author Volker Friese <v.friese@gsi.de>
+ ** @since 7 August 2020
+ **/
+
+
+
+// Includes needed for IDE
+#if !defined(__CLING__)
+#include "CbmDigitization.h"
+#include "FairSystemInfo.h"
+#endif
+
+/** @brief Macro for detector response simulation (digitisation)
+ ** with two different MC inputs at different rates
+ ** @author Volker Friese <v.friese@gsi.de>
+ ** @date 8 August 2020
+ **
+ ** The detector response produces a raw data file from the transport
+ ** data, which serves as input for reconstruction. Raw data will
+ ** be delivered in time-slice format (one tree entry per time-slice).
+ **
+ ** For options to modify the run settings, consult
+ ** the documentation of the CbmDigitization class.
+ **/
+void mcbm_digi_mixed()
+{
+
+  // ===> User settings
+
+  // --- Specify collision input (e.g., UrQMD)
+  TString collInput = "collision.tra.root";            // MC file name
+  Double_t collRate = 1.e7;                            // Collision rate [1/s]
+  ECbmTreeAccess collMode = ECbmTreeAccess::kRegular;  // Take events one after one
+
+  // --- Specify beam input
+  TString beamInput = "beam.tra.root";                 // MC file name
+  Double_t beamRate = 1.e9;                            // Beam rate [1/s]
+  ECbmTreeAccess beamMode = ECbmTreeAccess::kRandom;   // Take random events
+
+  // --- Specify parameter file
+  TString paramFile = "collision.par.root";
+
+  // --- Specify time-slice length [ns]
+  // --- Negative values mean that all data go into one time slice
+  Double_t tsLength = -1.;
+
+  // --- Specify output file
+  TString outFile = "combined.raw.root";
+
+  // <=== User settings
+
+
+
+  // --- Logger settings ----------------------------------------------------
+  FairLogger::GetLogger()->SetLogScreenLevel("INFO");
+  FairLogger::GetLogger()->SetLogVerbosityLevel("LOW");
+  // ------------------------------------------------------------------------
+
+
+  // -----   Allow overwriting of output file   -----------------------------
+  Bool_t overwrite = kTRUE;
+  // ------------------------------------------------------------------------
+
+
+  // -----   Timer   --------------------------------------------------------
+  TStopwatch timer;
+  timer.Start();
+  // ------------------------------------------------------------------------
+
+
+  // -----   Digitization run   ---------------------------------------------
+  CbmDigitization run;
+  run.AddInput(0, collInput, collRate, collMode);
+  run.AddInput(1, beamInput, beamRate, beamMode);
+  run.SetParameterRootFile(paramFile);
+  run.SetOutputFile(outFile, overwrite);
+  run.SetTimeSliceLength(tsLength);
+  run.Deactivate(ECbmModuleId::kTof);
+  run.Run();
+  // ------------------------------------------------------------------------
+
+
+  // -----   Finish   -------------------------------------------------------
+  timer.Stop();
+  Double_t rtime = timer.RealTime();
+  Double_t ctime = timer.CpuTime();
+  std::cout << std::endl;
+  std::cout << "Macro finished successfully." << std::endl;
+  std::cout << "Output file is " << outFile << std::endl;
+  std::cout << "Parameter file is " << paramFile << std::endl;
+  std::cout << "Real time " << rtime << " s, CPU time " << ctime << " s"
+            << std::endl
+            << std::endl;
+  // ------------------------------------------------------------------------
+
+
+  // -----   CTest resource monitoring   ------------------------------------
+  FairSystemInfo sysInfo;
+  Float_t maxMemory = sysInfo.GetMaxMemory();
+  std::cout << "<DartMeasurement name=\"MaxMemory\" type=\"numeric/double\">";
+  std::cout << maxMemory;
+  std::cout << "</DartMeasurement>" << std::endl;
+  std::cout << "<DartMeasurement name=\"WallTime\" type=\"numeric/double\">";
+  std::cout << rtime;
+  std::cout << "</DartMeasurement>" << std::endl;
+  Float_t cpuUsage = ctime / rtime;
+  std::cout << "<DartMeasurement name=\"CpuLoad\" type=\"numeric/double\">";
+  std::cout << cpuUsage;
+  std::cout << "</DartMeasurement>" << std::endl;
+  // ------------------------------------------------------------------------
+
+
+  // -----   Finish   -------------------------------------------------------
+  std::cout << " Test passed" << std::endl;
+  std::cout << " All ok " << std::endl;
+  // ------------------------------------------------------------------------
+
+
+}  // End of macro
diff --git a/macro/mcbm/mcbm_transport.C b/macro/mcbm/mcbm_transport.C
index 1db5c4673f..301504135e 100644
--- a/macro/mcbm/mcbm_transport.C
+++ b/macro/mcbm/mcbm_transport.C
@@ -164,7 +164,7 @@ void mcbm_transport(
                 targetRotY * TMath::DegToRad());
   run.SetBeamPosition(0., 0., 0.1, 0.1);  // Beam width 1 mm is assumed
   run.SetBeamAngle(beamRotY * TMath::DegToRad(), 0.);
-  run.StoreTrajectories();
+  //run.StoreTrajectories();
   run.Run(nEvents);
   // ------------------------------------------------------------------------
 
-- 
GitLab