From d7b5cf78446ccb64585f509c107d7d9eacfa7d58 Mon Sep 17 00:00:00 2001
From: "zhangyz@ihep.ac.cn" <zhangyz@ihep.ac.cn>
Date: Tue, 3 Dec 2024 10:16:42 +0800
Subject: [PATCH 1/9] add use costheta

---
 .vscode/settings.json       | 21 +++++++++++++++++++++
 Generator/src/GtGunTool.cpp | 18 ++++++++++++++++--
 Generator/src/GtGunTool.h   |  2 ++
 3 files changed, 39 insertions(+), 2 deletions(-)
 create mode 100644 .vscode/settings.json

diff --git a/.vscode/settings.json b/.vscode/settings.json
new file mode 100644
index 00000000..6ad48fa1
--- /dev/null
+++ b/.vscode/settings.json
@@ -0,0 +1,21 @@
+{
+    "files.associations": {
+        "*.sycl": "cpp",
+        "*.hpp": "cpp",
+        "*.h": "cpp",
+        "*.c": "cpp",
+        "*.cpp": "cpp",
+        "array": "cpp",
+        "bitset": "cpp",
+        "initializer_list": "cpp",
+        "list": "cpp",
+        "random": "cpp",
+        "type_traits": "cpp",
+        "vector": "cpp",
+        "xhash": "cpp",
+        "xstring": "cpp",
+        "xtree": "cpp",
+        "xutility": "cpp",
+        "cmath": "cpp"
+    }
+}
\ No newline at end of file
diff --git a/Generator/src/GtGunTool.cpp b/Generator/src/GtGunTool.cpp
index ad747984..71206ebf 100644
--- a/Generator/src/GtGunTool.cpp
+++ b/Generator/src/GtGunTool.cpp
@@ -95,6 +95,19 @@ GtGunTool::initialize() {
         return StatusCode::FAILURE;
     }
 
+    if (m_usecostheta.value()) {
+        for (int i=0; i<m_thetamins.value().size(); ++i) {
+            if ((m_thetamins.value()[i] < -1) || (m_thetamins.value()[i] > 1)) {
+                error() << "UseCostheta: ThetaMins has values outside the range [-1, 1]." << endmsg;
+                return StatusCode::FAILURE;
+            }
+            if ((m_thetamaxs.value()[i] < -1) || (m_thetamaxs.value()[i] > 1)) {
+                error() << "UseCostheta: ThetaMaxs has values outside the range [-1, 1]." << endmsg;
+                return StatusCode::FAILURE;
+            }
+        }
+    }
+
     // Time
     if (m_times.value().size()==0){
       for(int i=0; i<m_particles.value().size(); i++) m_times.value().push_back(0);
@@ -246,13 +259,14 @@ GtGunTool::mutate(Gen::GenEvent& event) {
 
         double theta = m_thetamins.value()[i]==m_thetamaxs.value()[i] ? m_thetamins.value()[i] : CLHEP::RandFlat::shoot(m_thetamins.value()[i], m_thetamaxs.value()[i]);
         double phi =   m_phimins  .value()[i]==m_phimaxs  .value()[i] ? m_phimins  .value()[i] : CLHEP::RandFlat::shoot(m_phimins  .value()[i], m_phimaxs  .value()[i]);
-        double costheta = cos(theta*acos(-1)/180);
+
+        double costheta = (m_usecostheta.value()) ? theta : cos(theta*acos(-1)/180);
         double phi_  = phi*acos(-1)/180;
         double sintheta = sqrt(1.-costheta*costheta);
         double px = p*sintheta*cos(phi_);
         double py = p*sintheta*sin(phi_);
         double pz = p*costheta;
-        std::cout<<"GenGt p="<<p<<", px="<<px<<",py="<<py<<",pz="<<pz<<",theta="<<theta<<",phi="<<phi<<std::endl;
+        std::cout<<"GenGt p="<<p<<", px="<<px<<",py="<<py<<",pz="<<pz<<",theta="<< (m_usecostheta.value()) ? (acos(theta)/acos(-1)*180) : theta<<",phi="<<phi<<std::endl;
         mcp.setMomentum(edm4hep::Vector3f(px,py,pz));
         // mcp.setMomentumAtEndpoint();
         // mcp.setSpin();
diff --git a/Generator/src/GtGunTool.h b/Generator/src/GtGunTool.h
index bc1fcd58..ec193bdf 100644
--- a/Generator/src/GtGunTool.h
+++ b/Generator/src/GtGunTool.h
@@ -57,6 +57,8 @@ private:
     Gaudi::Property<std::vector<double>> m_phimins{this, "PhiMins"};
     Gaudi::Property<std::vector<double>> m_phimaxs{this, "PhiMaxs"};
 
+    Gaudi::Property<bool> m_usecostheta{this, "UseCostheta", false};
+    
     // For time
     Gaudi::Property<std::vector<double>> m_times{this, "Times"};
 
-- 
GitLab


From 98e0fcaaf4c546f9266f41839806c93d7394f395 Mon Sep 17 00:00:00 2001
From: "zhangyz@ihep.ac.cn" <zhangyz@ihep.ac.cn>
Date: Tue, 3 Dec 2024 10:58:55 +0800
Subject: [PATCH 2/9] add use costheta

---
 Generator/src/GtGunTool.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Generator/src/GtGunTool.cpp b/Generator/src/GtGunTool.cpp
index 71206ebf..198f1a5c 100644
--- a/Generator/src/GtGunTool.cpp
+++ b/Generator/src/GtGunTool.cpp
@@ -266,7 +266,7 @@ GtGunTool::mutate(Gen::GenEvent& event) {
         double px = p*sintheta*cos(phi_);
         double py = p*sintheta*sin(phi_);
         double pz = p*costheta;
-        std::cout<<"GenGt p="<<p<<", px="<<px<<",py="<<py<<",pz="<<pz<<",theta="<< (m_usecostheta.value()) ? (acos(theta)/acos(-1)*180) : theta<<",phi="<<phi<<std::endl;
+        std::cout<<"GenGt p="<<p<<", px="<<px<<",py="<<py<<",pz="<<pz<<",theta="<<theta<<",phi="<<phi<<std::endl;
         mcp.setMomentum(edm4hep::Vector3f(px,py,pz));
         // mcp.setMomentumAtEndpoint();
         // mcp.setSpin();
-- 
GitLab


From 4defa6d87a7792341b0b3bdaddf7318ae41234d1 Mon Sep 17 00:00:00 2001
From: "zhangyz@ihep.ac.cn" <zhangyz@ihep.ac.cn>
Date: Tue, 3 Dec 2024 11:57:20 +0800
Subject: [PATCH 3/9] add use costheta

---
 .gitignore | 1 +
 1 file changed, 1 insertion(+)

diff --git a/.gitignore b/.gitignore
index 4dd952a9..9f405dfe 100644
--- a/.gitignore
+++ b/.gitignore
@@ -4,5 +4,6 @@ spack*
 ./Generator/output/
 ./Generator/options/
 
+.vscode/
 InstallArea/
 venv
-- 
GitLab


From e57d5445b37f11293d2b2d5d593e3e6544416459 Mon Sep 17 00:00:00 2001
From: "zhangyz@ihep.ac.cn" <zhangyz@ihep.ac.cn>
Date: Tue, 3 Dec 2024 11:58:04 +0800
Subject: [PATCH 4/9] add use costheta

---
 .gitignore            |  1 -
 .vscode/settings.json | 21 ---------------------
 2 files changed, 22 deletions(-)
 delete mode 100644 .vscode/settings.json

diff --git a/.gitignore b/.gitignore
index 9f405dfe..4dd952a9 100644
--- a/.gitignore
+++ b/.gitignore
@@ -4,6 +4,5 @@ spack*
 ./Generator/output/
 ./Generator/options/
 
-.vscode/
 InstallArea/
 venv
diff --git a/.vscode/settings.json b/.vscode/settings.json
deleted file mode 100644
index 6ad48fa1..00000000
--- a/.vscode/settings.json
+++ /dev/null
@@ -1,21 +0,0 @@
-{
-    "files.associations": {
-        "*.sycl": "cpp",
-        "*.hpp": "cpp",
-        "*.h": "cpp",
-        "*.c": "cpp",
-        "*.cpp": "cpp",
-        "array": "cpp",
-        "bitset": "cpp",
-        "initializer_list": "cpp",
-        "list": "cpp",
-        "random": "cpp",
-        "type_traits": "cpp",
-        "vector": "cpp",
-        "xhash": "cpp",
-        "xstring": "cpp",
-        "xtree": "cpp",
-        "xutility": "cpp",
-        "cmath": "cpp"
-    }
-}
\ No newline at end of file
-- 
GitLab


From 0832639dfce3b11618aed65833e57aef19deceed Mon Sep 17 00:00:00 2001
From: "zhangyz@ihep.ac.cn" <zhangyz@ihep.ac.cn>
Date: Sun, 8 Dec 2024 12:46:15 +0800
Subject: [PATCH 5/9] add variables

---
 .vscode/settings.json       | 12 ++++++++++++
 Generator/src/GtGunTool.cpp | 39 ++++++++++++++++++++++++-------------
 Generator/src/GtGunTool.h   |  3 ++-
 3 files changed, 39 insertions(+), 15 deletions(-)
 create mode 100644 .vscode/settings.json

diff --git a/.vscode/settings.json b/.vscode/settings.json
new file mode 100644
index 00000000..3ade7b39
--- /dev/null
+++ b/.vscode/settings.json
@@ -0,0 +1,12 @@
+{
+    "files.associations": {
+        "*.sycl": "cpp",
+        "*.hpp": "cpp",
+        "*.h": "cpp",
+        "*.c": "cpp",
+        "*.cpp": "cpp",
+        "chrono": "cpp",
+        "optional": "cpp",
+        "system_error": "cpp"
+    }
+}
\ No newline at end of file
diff --git a/Generator/src/GtGunTool.cpp b/Generator/src/GtGunTool.cpp
index 198f1a5c..3c953f1b 100644
--- a/Generator/src/GtGunTool.cpp
+++ b/Generator/src/GtGunTool.cpp
@@ -73,17 +73,6 @@ GtGunTool::initialize() {
     }
     
     // others should be empty or specify
-    if (m_thetamins.value().size()
-        && m_thetamins.value().size() != m_particles.value().size()) {
-        error() << "Mismatched thetamins and particles." << endmsg;
-        return StatusCode::FAILURE;
-    }
-    if (m_thetamaxs.value().size()
-        && m_thetamaxs.value().size() != m_particles.value().size()) {
-        error() << "Mismatched thetamaxs and particles." << endmsg;
-        return StatusCode::FAILURE;
-    }
-
     if (m_phimins.value().size()
         && m_phimins.value().size() != m_particles.value().size()) {
         error() << "Mismatched phimins and particles." << endmsg;
@@ -96,6 +85,14 @@ GtGunTool::initialize() {
     }
 
     if (m_usecostheta.value()) {
+        if (m_costhetamins.value().size() != m_particles.value().size()) {
+            error() << "Mismatched CosthetaMins and particles." << endmsg;
+            return StatusCode::FAILURE;
+        }
+        if (m_costhetamaxs.value().size() != m_particles.value().size()) {
+            error() << "Mismatched CosthetaMaxs and particles." << endmsg;
+            return StatusCode::FAILURE;
+        }
         for (int i=0; i<m_thetamins.value().size(); ++i) {
             if ((m_thetamins.value()[i] < -1) || (m_thetamins.value()[i] > 1)) {
                 error() << "UseCostheta: ThetaMins has values outside the range [-1, 1]." << endmsg;
@@ -106,6 +103,17 @@ GtGunTool::initialize() {
                 return StatusCode::FAILURE;
             }
         }
+    } else {
+        if (m_thetamins.value().size()
+            && m_thetamins.value().size() != m_particles.value().size()) {
+            error() << "Mismatched thetamins and particles." << endmsg;
+            return StatusCode::FAILURE;
+        }
+        if (m_thetamaxs.value().size()
+            && m_thetamaxs.value().size() != m_particles.value().size()) {
+            error() << "Mismatched thetamaxs and particles." << endmsg;
+            return StatusCode::FAILURE;
+        }
     }
 
     // Time
@@ -256,11 +264,14 @@ GtGunTool::mutate(Gen::GenEvent& event) {
             return false;
         }
 
-
-        double theta = m_thetamins.value()[i]==m_thetamaxs.value()[i] ? m_thetamins.value()[i] : CLHEP::RandFlat::shoot(m_thetamins.value()[i], m_thetamaxs.value()[i]);
+        if (m_usecostheta.value()) {
+            double costheta = m_costhetamins.value()[i]==m_costhetamaxs.value()[i] ? m_costhetamins.value()[i] : CLHEP::RandFlat::shoot(m_costhetamins.value()[i], m_costhetamaxs.value()[i]);
+        } else {
+            double theta = m_thetamins.value()[i]==m_thetamaxs.value()[i] ? m_thetamins.value()[i] : CLHEP::RandFlat::shoot(m_thetamins.value()[i], m_thetamaxs.value()[i]);
+            double costheta = cos(theta*acos(-1)/180);
+        }
         double phi =   m_phimins  .value()[i]==m_phimaxs  .value()[i] ? m_phimins  .value()[i] : CLHEP::RandFlat::shoot(m_phimins  .value()[i], m_phimaxs  .value()[i]);
 
-        double costheta = (m_usecostheta.value()) ? theta : cos(theta*acos(-1)/180);
         double phi_  = phi*acos(-1)/180;
         double sintheta = sqrt(1.-costheta*costheta);
         double px = p*sintheta*cos(phi_);
diff --git a/Generator/src/GtGunTool.h b/Generator/src/GtGunTool.h
index ec193bdf..fb43164e 100644
--- a/Generator/src/GtGunTool.h
+++ b/Generator/src/GtGunTool.h
@@ -58,7 +58,8 @@ private:
     Gaudi::Property<std::vector<double>> m_phimaxs{this, "PhiMaxs"};
 
     Gaudi::Property<bool> m_usecostheta{this, "UseCostheta", false};
-    
+    Gaudi::Property<std::vector<double>> m_costhetamins{this, "CosthetaMins"};
+    Gaudi::Property<std::vector<double>> m_costhetamaxs{this, "CosthetaMaxs"};
     // For time
     Gaudi::Property<std::vector<double>> m_times{this, "Times"};
 
-- 
GitLab


From 94ca44c470766a5ab6ec1b2ac610a456584bfc93 Mon Sep 17 00:00:00 2001
From: "zhangyz@ihep.ac.cn" <zhangyz@ihep.ac.cn>
Date: Sun, 8 Dec 2024 12:49:48 +0800
Subject: [PATCH 6/9] add variables

---
 .vscode/settings.json | 12 ------------
 1 file changed, 12 deletions(-)
 delete mode 100644 .vscode/settings.json

diff --git a/.vscode/settings.json b/.vscode/settings.json
deleted file mode 100644
index 3ade7b39..00000000
--- a/.vscode/settings.json
+++ /dev/null
@@ -1,12 +0,0 @@
-{
-    "files.associations": {
-        "*.sycl": "cpp",
-        "*.hpp": "cpp",
-        "*.h": "cpp",
-        "*.c": "cpp",
-        "*.cpp": "cpp",
-        "chrono": "cpp",
-        "optional": "cpp",
-        "system_error": "cpp"
-    }
-}
\ No newline at end of file
-- 
GitLab


From da5637f74e6f5ab8780897784e2a3b996f765c5a Mon Sep 17 00:00:00 2001
From: "zhangyz@ihep.ac.cn" <zhangyz@ihep.ac.cn>
Date: Sun, 8 Dec 2024 12:56:29 +0800
Subject: [PATCH 7/9] add variables

---
 .vscode/settings.json       | 13 +++++++++++++
 Generator/src/GtGunTool.cpp | 16 +++++++++++-----
 2 files changed, 24 insertions(+), 5 deletions(-)
 create mode 100644 .vscode/settings.json

diff --git a/.vscode/settings.json b/.vscode/settings.json
new file mode 100644
index 00000000..257d1d17
--- /dev/null
+++ b/.vscode/settings.json
@@ -0,0 +1,13 @@
+{
+    "files.associations": {
+        "*.sycl": "cpp",
+        "*.hpp": "cpp",
+        "*.h": "cpp",
+        "*.c": "cpp",
+        "*.cpp": "cpp",
+        "cmath": "cpp",
+        "chrono": "cpp",
+        "optional": "cpp",
+        "system_error": "cpp"
+    }
+}
\ No newline at end of file
diff --git a/Generator/src/GtGunTool.cpp b/Generator/src/GtGunTool.cpp
index 3c953f1b..8ab4ce2e 100644
--- a/Generator/src/GtGunTool.cpp
+++ b/Generator/src/GtGunTool.cpp
@@ -264,20 +264,26 @@ GtGunTool::mutate(Gen::GenEvent& event) {
             return false;
         }
 
+        double costheta = 0;
+        double theta = 0;
         if (m_usecostheta.value()) {
-            double costheta = m_costhetamins.value()[i]==m_costhetamaxs.value()[i] ? m_costhetamins.value()[i] : CLHEP::RandFlat::shoot(m_costhetamins.value()[i], m_costhetamaxs.value()[i]);
+            costheta = m_costhetamins.value()[i]==m_costhetamaxs.value()[i] ? m_costhetamins.value()[i] : CLHEP::RandFlat::shoot(m_costhetamins.value()[i], m_costhetamaxs.value()[i]);
         } else {
-            double theta = m_thetamins.value()[i]==m_thetamaxs.value()[i] ? m_thetamins.value()[i] : CLHEP::RandFlat::shoot(m_thetamins.value()[i], m_thetamaxs.value()[i]);
-            double costheta = cos(theta*acos(-1)/180);
+            theta = m_thetamins.value()[i]==m_thetamaxs.value()[i] ? m_thetamins.value()[i] : CLHEP::RandFlat::shoot(m_thetamins.value()[i], m_thetamaxs.value()[i]);
+            costheta = cos(theta*acos(-1)/180);
         }
-        double phi =   m_phimins  .value()[i]==m_phimaxs  .value()[i] ? m_phimins  .value()[i] : CLHEP::RandFlat::shoot(m_phimins  .value()[i], m_phimaxs  .value()[i]);
+        double phi =   m_phimins.value()[i]==m_phimaxs.value()[i] ? m_phimins.value()[i] : CLHEP::RandFlat::shoot(m_phimins.value()[i], m_phimaxs.value()[i]);
 
         double phi_  = phi*acos(-1)/180;
         double sintheta = sqrt(1.-costheta*costheta);
         double px = p*sintheta*cos(phi_);
         double py = p*sintheta*sin(phi_);
         double pz = p*costheta;
-        std::cout<<"GenGt p="<<p<<", px="<<px<<",py="<<py<<",pz="<<pz<<",theta="<<theta<<",phi="<<phi<<std::endl;
+        if(m_usecostheta.value()) {
+            std::cout<<"GenGt p="<<p<<", px="<<px<<",py="<<py<<",pz="<<pz<<",costheta="<<costheta<<",phi="<<phi<<std::endl;
+        } else {
+            std::cout<<"GenGt p="<<p<<", px="<<px<<",py="<<py<<",pz="<<pz<<",theta="<<theta<<",phi="<<phi<<std::endl;
+        }
         mcp.setMomentum(edm4hep::Vector3f(px,py,pz));
         // mcp.setMomentumAtEndpoint();
         // mcp.setSpin();
-- 
GitLab


From 3f36769cd29dd6df3ebebb5756d29bf5ba9d6496 Mon Sep 17 00:00:00 2001
From: "zhangyz@ihep.ac.cn" <zhangyz@ihep.ac.cn>
Date: Sun, 8 Dec 2024 12:57:12 +0800
Subject: [PATCH 8/9] add variables

---
 .vscode/settings.json | 13 -------------
 1 file changed, 13 deletions(-)
 delete mode 100644 .vscode/settings.json

diff --git a/.vscode/settings.json b/.vscode/settings.json
deleted file mode 100644
index 257d1d17..00000000
--- a/.vscode/settings.json
+++ /dev/null
@@ -1,13 +0,0 @@
-{
-    "files.associations": {
-        "*.sycl": "cpp",
-        "*.hpp": "cpp",
-        "*.h": "cpp",
-        "*.c": "cpp",
-        "*.cpp": "cpp",
-        "cmath": "cpp",
-        "chrono": "cpp",
-        "optional": "cpp",
-        "system_error": "cpp"
-    }
-}
\ No newline at end of file
-- 
GitLab


From 557a0ebb063aef852d1839808bc16a3bf5bc1053 Mon Sep 17 00:00:00 2001
From: "zhangyz@ihep.ac.cn" <zhangyz@ihep.ac.cn>
Date: Thu, 9 Jan 2025 17:28:01 +0800
Subject: [PATCH 9/9] update material scan

---
 Analysis/MaterialScan/README.md            | 34 +++++-----------------
 Analysis/MaterialScan/src/ScanMaterial.cpp | 34 ++++++++++++++++++++++
 2 files changed, 42 insertions(+), 26 deletions(-)
 create mode 100644 Analysis/MaterialScan/src/ScanMaterial.cpp

diff --git a/Analysis/MaterialScan/README.md b/Analysis/MaterialScan/README.md
index 24cad961..de2cf9a3 100644
--- a/Analysis/MaterialScan/README.md
+++ b/Analysis/MaterialScan/README.md
@@ -5,39 +5,21 @@ Use DD4hep tool [materialScan](https://dd4hep.web.cern.ch/dd4hep/reference/mater
 
 ## Material Scan
 
-Select the dd4hep geometry files you wish to scan, and access the interactive interface of materialScan.
+Select the dd4hep geometry files you wish to scan, and run the given script.
 
 ```bash
-# Access to the interactive interface of materialScan
-materialScan ./Detector/DetCRD/compact/TDR_o1_v01/TDR_o1_v01.xml -interactive
+# Scan the material for a specific detector
+root -l 'src/ScanMaterial.cpp("input_file.xml", "output_file.txt", bins, world_size)'
 
-# if you want to scan the material for a specific detector, disable/enable the detectors in the xml file
-materialScan ./Detector/DetCRD/compact/TDR_o1_v01/TDR_o1_v01-onlyBeamPipe.xml -interactive
+# example: scan the material for the BeamPipe detector
+root -l 'src/ScanMaterial.cpp("Detector/DetCRD/compact/TDR_o1_v01/TDR_o1_v01-onlyBeamPipe.xml", "BeamPipe.txt", 100, 10000)'
 ```
 
-copy the following code to the interactive interface, and press enter.
-*bins* is the number of bins for theta and phi, *world_size* is the size of the scanning area (mm).
+The "FILE* outFile" truncates the "stdout" output stream to the output_file.txt ("MaterialScanLogs.txt" by default), so you can't see any output. Be patient and wait for the file to be created, it may take 1-2 minutes depending on the detectors & the number of bins.
 
-```bash
-FILE* outFile = freopen("MaterialScanLogs.txt", "w", stdout);
-int bins = 100;
-double world_size = 10000;
-for(int thetabin=0; thetabin<=bins; thetabin++){
-    double theta = thetabin * M_PI / bins;
-    double z = world_size*cos(theta);
-    double tranverse = world_size*sin(theta);
-    for(int phibin=-bins; phibin<=bins; phibin++){
-        double phi = phibin * M_PI / bins;
-        double x = tranverse*cos(phi);
-        double y = tranverse*sin(phi);
-        gMaterialScan->print(0,0,0,x,y,z);
-    }
-}
-```
-
-The "FILE* outFile" truncates the "stdout" output stream to the file "MaterialScanLogs.txt", so you can't see any output. Be patient and wait for the file to be created, it may take 1-2 minutes depending on the detectors & the number of bins.
+*bins* is the number of bins for theta and phi, *world_size* is the size of the scanning area (mm).
 
-The file "MaterialScanLogs.txt" contains all the material passing through for a straight line at the given angles with the size of bins of theta and phi.
+The output_file.txt contains all the material passing through for a straight line at the given angles with the size of bins of theta and phi.
 
 ## Draw the material budget for single xml file
 
diff --git a/Analysis/MaterialScan/src/ScanMaterial.cpp b/Analysis/MaterialScan/src/ScanMaterial.cpp
new file mode 100644
index 00000000..eb69cebe
--- /dev/null
+++ b/Analysis/MaterialScan/src/ScanMaterial.cpp
@@ -0,0 +1,34 @@
+#include <DD4hep/Detector.h>
+#include <DDRec/MaterialScan.h>
+#include <fstream>
+
+void ScanMaterial(string infile, string outfile="MaterialScanLogs.txt", int bins=100, double world_size=1000){
+    using namespace dd4hep;
+    using namespace dd4hep::rec;
+
+    if(infile.empty()){
+        cout << "Usage: root -l 'ScanMaterial.cpp(\"input_file.xml\", \"output_file.txt\", bins, world_size)' " << endl;
+        return;
+    }
+    
+    Detector& description = Detector::getInstance();
+    description.fromXML(infile.c_str());
+    MaterialScan scan(description);
+
+    std::ofstream clearFile(outfile.c_str(), std::ios::out | std::ios::trunc);
+    clearFile.close();
+    FILE* outFile = freopen(outfile.c_str(), "w", stdout);
+    for(int thetabin=0; thetabin<=bins; thetabin++){
+        double theta = thetabin * M_PI / bins;
+        double z = world_size*cos(theta);
+        double tranverse = world_size*sin(theta);
+        for(int phibin=-bins; phibin<=bins; phibin++){
+            double phi = phibin * M_PI / bins;
+            double x = tranverse*cos(phi);
+            double y = tranverse*sin(phi);
+            scan.print(0,0,0,x,y,z);
+        }
+    }
+    fclose(outFile);
+    return;
+}
\ No newline at end of file
-- 
GitLab