From 343ec0e4a077468734ad79639bd7b71898af6709 Mon Sep 17 00:00:00 2001
From: "se.gorbunov" <se.gorbunov@gsi.de>
Date: Tue, 27 Jun 2023 12:58:03 +0000
Subject: [PATCH] bufix: set target position to -44cm in simulation macros

---
 macro/C2F/c2f_transport.C       | 12 ++++++++----
 macro/L1/run_reco_L1global.C    |  9 +++++++++
 macro/dimuon/dimuon_transport.C | 20 +++++++++++++++++++-
 macro/much/run_transport.C      | 22 +++++++++++++++++++++-
 macro/run/run_tra_file.C        |  5 +++--
 5 files changed, 60 insertions(+), 8 deletions(-)

diff --git a/macro/C2F/c2f_transport.C b/macro/C2F/c2f_transport.C
index 542e57d899..ea09f80147 100644
--- a/macro/C2F/c2f_transport.C
+++ b/macro/C2F/c2f_transport.C
@@ -71,15 +71,17 @@ void c2f_transport(Int_t nEvents = 2, const char* setupName = "sis100_electron",
   // in the responsibility of the user that no overlaps or extrusions are
   // created by the placement of the target.
   //
-  TString targetElement    = "Gold";
+  TString targetMaterial   = "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]
+  // The target is at -44 cm from the centre of the magnet.
+  Double_t targetPosZ = -44.;  // target z position in global c.s. [cm]
+  Double_t targetRotY = 0.;    // target rotation angle around the y axis [deg]
   // ------------------------------------------------------------------------
 
+  std::cout << "Target is at " << targetPosZ << "cm from origin" << std::endl;
 
   // --- Define the creation of the primary vertex   ------------------------
   //
@@ -158,13 +160,15 @@ void c2f_transport(Int_t nEvents = 2, const char* setupName = "sis100_electron",
 
 
   // -----   Create and register the target   -------------------------------
+
   std::cout << std::endl;
   std::cout << "-I- " << myName << ": Registering target" << std::endl;
-  CbmTarget* target = new CbmTarget(targetElement.Data(), targetThickness, targetDiameter);
+  CbmTarget* target = new CbmTarget(targetMaterial.Data(), targetThickness, targetDiameter);
   target->SetPosition(targetPosX, targetPosY, targetPosZ);
   target->SetRotation(targetRotY);
   std::cout << target->ToString() << std::endl;
   run->AddModule(target);
+
   // ------------------------------------------------------------------------
 
 
diff --git a/macro/L1/run_reco_L1global.C b/macro/L1/run_reco_L1global.C
index 2da150b42a..0d15ce7b10 100644
--- a/macro/L1/run_reco_L1global.C
+++ b/macro/L1/run_reco_L1global.C
@@ -75,6 +75,15 @@ void run_reco_L1global(TString input = "", Int_t nTimeSlices = -1, Int_t firstTi
 {
 
   // how to run it:
+  //
+  // mkdir data
+  //
+  // muon setup:
+  // root -l -q $VMCWORKDIR/macro/run/run_tra_file.C'("$VMCWORKDIR/input/urqmd.auau.10gev.mbias.root", 100, "./data/mu.10gev.mbias.eb", "sis100_muon_jpsi", kGeant3, 1, true)'
+  // root -l -q $VMCWORKDIR/macro/run/run_digi.C'("./data/mu.10gev.mbias.eb", -1, "", -1., -1)'
+  // root -l -q $VMCWORKDIR/macro/L1/run_reco_L1global.C'("./data/mu.10gev.mbias.eb", -1, 0, "", "", "sis100_muon_jpsi", "", true)'
+  //
+  // trd2d setup:
   // root -l -q $VMCWORKDIR/macro/L1/run_reco_L1global.C'("trd2d", -1, 0, "", "", "trd2d", "", true)'
 
   // ========================================================================
diff --git a/macro/dimuon/dimuon_transport.C b/macro/dimuon/dimuon_transport.C
index fed7502812..a78a7e5cc7 100644
--- a/macro/dimuon/dimuon_transport.C
+++ b/macro/dimuon/dimuon_transport.C
@@ -70,6 +70,18 @@ void dimuon_transport(Int_t nEvents = 1000, const char* setupName = "sis100_muon
   std::cout << "-I- " << myName << ": Using signal input file " << inFile << std::endl;
   // ------------------------------------------------------------------------
 
+  TString targetMaterial   = "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]
+  // The target is at -44 cm from the centre of the magnet.
+  Double_t targetPosZ = -44.;  // target z position in global c.s. [cm]
+  Double_t targetRotY = 0.;    // target rotation angle around the y axis [deg]
+  // ------------------------------------------------------------------------
+
+  std::cout << "Target is at " << targetPosZ << "cm from the origin" << std::endl;
+
 
   // -----   Timer   --------------------------------------------------------
   TStopwatch timer;
@@ -83,7 +95,13 @@ void dimuon_transport(Int_t nEvents = 1000, const char* setupName = "sis100_muon
   run.SetParFileName(parFile);
   run.SetGeoFileName(geoFile);
   run.LoadSetup(setupName);
-  run.SetTarget("Gold", 0.025, 2.5);
+
+  if (!(run.GetSetup())->IsActive(ECbmModuleId::kTarget)) {
+    std::cout << "Target being generated in tra macro" << std::endl;
+    run.SetTarget(targetMaterial.Data(), targetThickness, targetDiameter, targetPosX, targetPosY, targetPosZ,
+                  targetRotY);
+  };
+
   run.SetBeamPosition(0., 0., 0.1, 0.1);
   run.SetEngine(kGeant3);
   run.SetRandomSeed(randomSeed);
diff --git a/macro/much/run_transport.C b/macro/much/run_transport.C
index 750892210a..a2f510a4ec 100644
--- a/macro/much/run_transport.C
+++ b/macro/much/run_transport.C
@@ -72,6 +72,21 @@ void run_transport(Int_t nEvents = 3, const char* setupName = "sis100_muon_lmvm"
   // ------------------------------------------------------------------------
 
 
+  // -----   Target properties   --------------------------------------------
+  // For flexibility, the target volume is not part of the predefined
+  // geometry setup. It thus has to be specified in this macro. By default,
+  // a Gold target of 250 micrometer thickness and 2.5 cm diameter is used.
+  // The target shifts by 4 cm upstream by decision of the technical board
+  // in Apr 2020 which is 40 cm from center of magnet.
+  TString targetMaterial   = "Gold";
+  Double_t targetThickness = 0.025;  // in cm
+  Double_t targetDiameter  = 2.5;    // in cm
+  Double_t targetZpos      = -44.0;  // The target is at -44 cm from the centre of the magnet.
+
+  std::cout << "Target is at " << targetZpos << "cm from origin" << std::endl;
+  // ------------------------------------------------------------------------
+
+
   // -----   Timer   --------------------------------------------------------
   TStopwatch timer;
   timer.Start();
@@ -117,7 +132,12 @@ void run_transport(Int_t nEvents = 3, const char* setupName = "sis100_muon_lmvm"
   run.SetParFileName(parFile);
   run.SetGeoFileName(geoFile);
   run.LoadSetup(setupName);
-  run.SetTarget("Gold", 0.025, 2.5);
+
+  if (!(run.GetSetup())->IsActive(ECbmModuleId::kTarget)) {
+    std::cout << "Target being generated in tra macro" << std::endl;
+    run.SetTarget(targetMaterial.Data(), targetThickness, targetDiameter, 0, 0, targetZpos);
+  }
+
   run.SetBeamPosition(0., 0., 0.1, 0.1);
   run.SetEngine(kGeant3);
   run.SetRandomSeed(randomSeed);
diff --git a/macro/run/run_tra_file.C b/macro/run/run_tra_file.C
index ffd5b3deee..19c2625b92 100644
--- a/macro/run/run_tra_file.C
+++ b/macro/run/run_tra_file.C
@@ -108,7 +108,8 @@ void run_tra_file(const char* input = "", Int_t nEvents = 1, const char* output
   // a Gold target of 250 micrometer thickness and 2.5 cm diameter is used.
   // The target shifts by 4 cm upstream by decision of the technical board
   // in Apr 2020 which is 40 cm from center of magnet.
-  const char* targetMedium = "Gold";
+
+  TString  targetMaterial  = "Gold";
   Double_t targetThickness = 0.025;  // in cm
   Double_t targetDiameter  = 2.5;    // in cm
 
@@ -159,7 +160,7 @@ void run_tra_file(const char* input = "", Int_t nEvents = 1, const char* output
   run.LoadSetup(setup);
   if (!(run.GetSetup())->IsActive(ECbmModuleId::kTarget)) {
   std::cout << "Target being generated in tra macro" << std::endl;
-  run.SetTarget(targetMedium, targetThickness, targetDiameter, 0, 0, targetZpos);
+  run.SetTarget(targetMaterial.Data(), targetThickness, targetDiameter, 0, 0, targetZpos);
   };
   run.SetBeamPosition(beamPosX, beamPosY, beamSigmaX, beamSigmaY);
   if (rotateEvents) run.SetRandomEventPlane();
-- 
GitLab