From b943b87bd3d95a235b2c175099c1ca6c119e91b1 Mon Sep 17 00:00:00 2001
From: Ivana Hrivnacova <Ivana.Hrivnacova@cern.ch>
Date: Fri, 13 Dec 2013 12:02:47 +0100
Subject: [PATCH] Update vmc for multi-threading & clean-up - Added new
 functions in TVirtualMCApplication for multi-threading applications - Removed
 default implementation of newly added functions in TVirtualMC

---
 montecarlo/doc/v534/index.html             | 19 +++++++++++-
 montecarlo/vmc/inc/TVirtualMC.h            | 35 +++-------------------
 montecarlo/vmc/inc/TVirtualMCApplication.h |  9 +++++-
 3 files changed, 30 insertions(+), 33 deletions(-)

diff --git a/montecarlo/doc/v534/index.html b/montecarlo/doc/v534/index.html
index 001dea8f552..7112e887370 100644
--- a/montecarlo/doc/v534/index.html
+++ b/montecarlo/doc/v534/index.html
@@ -8,7 +8,25 @@
 <li> 
 Update of the VMC interfaces for multi-threading: 
 TVirtualMC and TVirtualMCApplication instances are now declared thread local.
+Added new functions in TVirtualMCApplication for multi-threading applications
+with default implementation:
+<pre>
+  virtual TVirtualMCApplication* CloneForWorker() const { return 0;}
+  virtual void InitForWorker() const {}
+  virtual void BeginWorkerRun() const {}
+  virtual void FinishWorkerRun() const {}
+  virtual void Merge(TVirtualMCApplication* /*localMCApplication*/) {}
+</pre>
 </li>
+
+<li>
+Removed default implementation of newly added functions in TVirtualMC:
+<pre>
+  virtual Bool_t GetMaterial(Int_t imat, TString& name,...) = 0;
+  virtual Bool_t CurrentBoundaryNormal(..) = 0;
+</pre>
+</li>
+
 <li>
 Removed deprecated functions from TVirtualMC:
 <pre>
@@ -31,4 +49,3 @@ Removed deprecated functions from TVirtualMC:
 </pre>
 </li>
 </ul>
-
diff --git a/montecarlo/vmc/inc/TVirtualMC.h b/montecarlo/vmc/inc/TVirtualMC.h
index e7135d8930b..313363c80dd 100644
--- a/montecarlo/vmc/inc/TVirtualMC.h
+++ b/montecarlo/vmc/inc/TVirtualMC.h
@@ -368,10 +368,10 @@ public:
                          TString& shapeType, TArrayD& par) = 0;
 
    // Return the material parameters for the material specified by 
-   // the material Id - NEW
+   // the material Id
    virtual Bool_t GetMaterial(Int_t imat, TString& name,
                                Double_t& a, Double_t& z, Double_t& density,
-                               Double_t& radl, Double_t& inter, TArrayD& par);
+                               Double_t& radl, Double_t& inter, TArrayD& par) = 0;
 
    // Return the material parameters for the volume specified by
    // the volumeName.
@@ -636,9 +636,9 @@ public:
    virtual const char* CurrentVolPath() = 0;
    
    // If track is on a geometry boundary, fill the normal vector of the crossing
-   // volume surface and return true, return false otherwise - NEW
+   // volume surface and return true, return false otherwise
    virtual Bool_t   CurrentBoundaryNormal(
-                       Double_t &x, Double_t &y, Double_t &z) const;
+                       Double_t &x, Double_t &y, Double_t &z) const = 0;
 
    // Return the parameters of the current material during transport
    virtual Int_t    CurrentMaterial(Float_t &a, Float_t &z,
@@ -801,9 +801,6 @@ public:
    // Initialize MC
    virtual void Init() = 0;
 
-    // Initialize MC in a multi-threaded application
-   virtual void InitMT(Int_t threadRank);
-
   // Initialize MC physics
    virtual void BuildPhysics() = 0;
 
@@ -881,30 +878,6 @@ private:
    ClassDef(TVirtualMC,1)  //Interface to Monte Carlo
 };
 
-// new functions
-
-inline Bool_t TVirtualMC::CurrentBoundaryNormal(
-                     Double_t& /*x*/, Double_t& /*y*/, Double_t& /*z*/) const {
-   // If track is on a geometry boundary, fill the normal vector of the crossing 
-   // volume surface and return true, return false otherwise
-   Warning("CurrentBoundaryNormal", "New function - not yet implemented.");
-   return kFALSE;
-}
-
-inline Bool_t TVirtualMC::GetMaterial(Int_t /*imat*/, TString& /*name*/,
-                      Double_t& /*a*/, Double_t& /*z*/, Double_t& /*density*/,
-                      Double_t& /*radl*/, Double_t& /*inter*/, TArrayD& /*par*/) {
-   // Return the material parameters for the material specified by 
-   // the material Id
-   Warning("GetMaterial(Int_t imat, ...)", "New function - not yet implemented.");
-   return kFALSE;           
-}
-
-inline void TVirtualMC::InitMT(Int_t /*threadRank*/) {
-   // Initialize MC in a multi-threaded application
-   Warning("InitMT(Int_t threadRank)", "New function - not yet implemented.");
-}
-
 #if defined(__linux__) && !defined(__CINT__)
 R__EXTERN __thread TVirtualMC *gMC;
 #else
diff --git a/montecarlo/vmc/inc/TVirtualMCApplication.h b/montecarlo/vmc/inc/TVirtualMCApplication.h
index 9d12b5a3cd4..cb1727400e6 100644
--- a/montecarlo/vmc/inc/TVirtualMCApplication.h
+++ b/montecarlo/vmc/inc/TVirtualMCApplication.h
@@ -98,11 +98,18 @@ public:
    virtual Double_t TrackingZmax() const { return DBL_MAX; }
 
    // Calculate user field \a b at point \a x
-   virtual void     Field(const Double_t* x, Double_t* b) const;
+   virtual void Field(const Double_t* x, Double_t* b) const;
 
    // Define action at each step for Geane
    virtual void GeaneStepping() {;}
 
+   // New functions for multi-threading applications
+   virtual TVirtualMCApplication* CloneForWorker() const { return 0;}
+   virtual void InitForWorker() const {}
+   virtual void BeginWorkerRun() const {}
+   virtual void FinishWorkerRun() const {}
+   virtual void Merge(TVirtualMCApplication* /*localMCApplication*/) {}
+
 private:
    // static data members
 #if defined(__linux__) && !defined(__CINT__)
-- 
GitLab