From a20a12ab21a5a43250a3be15fce6a5c6db8550e8 Mon Sep 17 00:00:00 2001
From: matta adrien <matta@lpccaen.in2p3.fr>
Date: Mon, 28 Nov 2016 17:39:26 +0100
Subject: [PATCH] * Adding project when running nptool-wizard

---
 .../DetectorSkeleton/Projects/Analysis.cxx    | 68 +++++++++++++++++++
 .../DetectorSkeleton/Projects/Analysis.h      | 42 ++++++++++++
 .../DetectorSkeleton/Projects/CMakeLists.txt  |  5 ++
 .../DETECTORNAME.detector                     |  0
 NPLib/scripts/nptool-wizard.sh                | 24 +++----
 5 files changed, 127 insertions(+), 12 deletions(-)
 create mode 100644 NPLib/ressources/DetectorSkeleton/Projects/Analysis.cxx
 create mode 100644 NPLib/ressources/DetectorSkeleton/Projects/Analysis.h
 create mode 100644 NPLib/ressources/DetectorSkeleton/Projects/CMakeLists.txt
 rename NPLib/ressources/DetectorSkeleton/{Inputs => Projects}/DETECTORNAME.detector (100%)

diff --git a/NPLib/ressources/DetectorSkeleton/Projects/Analysis.cxx b/NPLib/ressources/DetectorSkeleton/Projects/Analysis.cxx
new file mode 100644
index 000000000..0fe3f09fd
--- /dev/null
+++ b/NPLib/ressources/DetectorSkeleton/Projects/Analysis.cxx
@@ -0,0 +1,68 @@
+/*****************************************************************************
+ * Copyright (C) 2009-2016    this file is part of the NPTool Project        *
+ *                                                                           *
+ * For the licensing terms see $NPTOOL/Licence/NPTool_Licence                *
+ * For the list of contributors see $NPTOOL/Licence/Contributors             *
+ *****************************************************************************/
+
+/*****************************************************************************
+ * Original Author: XAUTHORX  contact address: XMAILX                        *
+ *                                                                           *
+ * Creation Date  : XMONTHX XYEARX                                           *
+ * Last update    :                                                          *
+ *---------------------------------------------------------------------------*
+ * Decription:                                                               *
+ *  This class describe  DETECTORNAME analysis project                       *
+ *                                                                           *
+ *---------------------------------------------------------------------------*
+ * Comment:                                                                  *
+ *                                                                           *
+ *****************************************************************************/
+
+#include<iostream>
+using namespace std;
+#include"Analysis.h"
+#include"NPAnalysisFactory.h"
+#include"NPDetectorManager.h"
+////////////////////////////////////////////////////////////////////////////////
+Analysis::Analysis(){
+}
+////////////////////////////////////////////////////////////////////////////////
+Analysis::~Analysis(){
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void Analysis::Init(){
+   DETECTORNAME= (TDETECTORNAMEPhysicsPhysics*) m_DetectorManager->GetDetector("DETECTORNAME");
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void Analysis::TreatEvent(){
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void Analysis::End(){
+}
+
+
+////////////////////////////////////////////////////////////////////////////////
+//            Construct Method to be pass to the DetectorFactory              //
+////////////////////////////////////////////////////////////////////////////////
+NPL::VAnalysis* Analysis::Construct(){
+  return (NPL::VAnalysis*) new Analysis();
+}
+
+////////////////////////////////////////////////////////////////////////////////
+//            Registering the construct method to the factory                 //
+////////////////////////////////////////////////////////////////////////////////
+extern "C"{
+class proxy{
+  public:
+    proxy(){
+      NPL::AnalysisFactory::getInstance()->SetConstructor(Analysis::Construct);
+    }
+};
+
+proxy p;
+}
+
diff --git a/NPLib/ressources/DetectorSkeleton/Projects/Analysis.h b/NPLib/ressources/DetectorSkeleton/Projects/Analysis.h
new file mode 100644
index 000000000..8cf0f1ef8
--- /dev/null
+++ b/NPLib/ressources/DetectorSkeleton/Projects/Analysis.h
@@ -0,0 +1,42 @@
+#ifndef Analysis_h 
+#define Analysis_h
+/*****************************************************************************
+ * Copyright (C) 2009-2016    this file is part of the NPTool Project        *
+ *                                                                           *
+ * For the licensing terms see $NPTOOL/Licence/NPTool_Licence                *
+ * For the list of contributors see $NPTOOL/Licence/Contributors             *
+ *****************************************************************************/
+
+/*****************************************************************************
+ * Original Author: XAUTHORX  contact address: XMAILX                        *
+ *                                                                           *
+ * Creation Date  : XMONTHX XYEARX                                           *
+ * Last update    :                                                          *
+ *---------------------------------------------------------------------------*
+ * Decription:                                                               *
+ *  This class describe  DETECTORNAME analysis project                       *
+ *                                                                           *
+ *---------------------------------------------------------------------------*
+ * Comment:                                                                  *
+ *                                                                           *
+ *****************************************************************************/
+
+#include"NPVAnalysis.h"
+#include"TDETECTORNAMEPhysics.h"
+class Analysis: public NPL::VAnalysis{
+  public:
+    Analysis();
+    ~Analysis();
+
+  public: 
+    void Init();
+    void TreatEvent();
+    void End();
+
+   static NPL::VAnalysis* Construct();
+
+  private:
+   TDETECTORNAMEPhysics* DETECTORNAME;
+
+};
+#endif
diff --git a/NPLib/ressources/DetectorSkeleton/Projects/CMakeLists.txt b/NPLib/ressources/DetectorSkeleton/Projects/CMakeLists.txt
new file mode 100644
index 000000000..22c74affd
--- /dev/null
+++ b/NPLib/ressources/DetectorSkeleton/Projects/CMakeLists.txt
@@ -0,0 +1,5 @@
+cmake_minimum_required (VERSION 2.8) 
+# Setting the policy to match Cmake version
+cmake_policy(VERSION ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION})
+# include the default NPAnalysis cmake file
+include("../../NPLib/ressources/CMake/NPAnalysis.cmake")
diff --git a/NPLib/ressources/DetectorSkeleton/Inputs/DETECTORNAME.detector b/NPLib/ressources/DetectorSkeleton/Projects/DETECTORNAME.detector
similarity index 100%
rename from NPLib/ressources/DetectorSkeleton/Inputs/DETECTORNAME.detector
rename to NPLib/ressources/DetectorSkeleton/Projects/DETECTORNAME.detector
diff --git a/NPLib/scripts/nptool-wizard.sh b/NPLib/scripts/nptool-wizard.sh
index 44046d17c..32d6d8797 100755
--- a/NPLib/scripts/nptool-wizard.sh
+++ b/NPLib/scripts/nptool-wizard.sh
@@ -4,7 +4,7 @@
 printf -v pathNPT $NPTOOL
 printf -v pathNPL $NPTOOL/NPLib/Detectors/
 printf -v pathNPS $NPTOOL/NPSimulation/Detectors/
-printf -v pathInputs $NPTOOL/Inputs/DetectorConfiguration/
+printf -v pathProjects $NPTOOL/Projects/
 printf -v path    $PWD
 
 #check for the force flag
@@ -49,12 +49,7 @@ if [[ $force == 0 ]]; then
     printf "\033[1;31m**** ERROR : A detector with similar name \033[1;36m${upperName}\033[1;31m already exist. use \033[1;36m-f\033[1;31m flag to force recreation.****\033[0m\n"
     exit 1
   fi
-  
 fi
-  
-
-
-
 
 printf  "\033[1;36m-> What is your name (firstname and surname)? \033[0m\n"
 read -e author 
@@ -109,13 +104,16 @@ mv ${pathNPL}${DetectorName}/TDETECTORNAMESpectra.cxx ${pathNPL}${DetectorName}/
   mv ${pathNPS}${DetectorName}/DETECTORNAME.hh ${pathNPS}${DetectorName}/${SimFile_h}
   mv ${pathNPS}${DetectorName}/DETECTORNAME.cc ${pathNPS}${DetectorName}/${SimFile_cxx}
 
-#Add input file
-  cp ${pathNPL}../ressources/DetectorSkeleton/Inputs/*.* ${pathInputs} > /dev/null 2> /dev/null
+# Create project folder
+  mkdir ${pathProjects}${DetectorName} > /dev/null 2> /dev/null
 
-  sed -i '' -e "s/DETECTORNAME/${DetectorName}/g" ${pathInputs}DETECTORNAME.detector > /dev/null 2> /dev/null
+#Add Project file
+  cp ${pathNPL}../ressources/DetectorSkeleton/Projects/*.* ${pathProjects}${DetectorName}/ > /dev/null 2> /dev/null
+
+  sed -i '' -e "s/DETECTORNAME/${DetectorName}/g" ${pathProjects}${DetectorName}/*.* > /dev/null 2> /dev/null
 
 #change files name
-  mv ${pathInputs}DETECTORNAME.detector ${pathInputs}${DetectorName}.detector
+  mv ${pathProjects}${DetectorName}/DETECTORNAME.detector ${pathProjects}${DetectorName}/${DetectorName}.detector
 
 # Provide a list of created file 
   printf "\t List of created files to\033[1;35m edit \033[0m:\n" 
@@ -127,14 +125,16 @@ mv ${pathNPL}${DetectorName}/TDETECTORNAMESpectra.cxx ${pathNPL}${DetectorName}/
   printf "\tNPSimulation :\n" 
   printf "\t\t -> Folder: Detectors/${DetectorName} \n"
   printf "\t\t -> Detector Class: \033[1;35m${SimFile_h}\033[0m and \033[1;35m${SimFile_cxx}\033[0m\n\n" 
-  printf "\tInputs :\n" 
+  printf "\tProjects :\n" 
+  printf "\t\t -> Folder: Detectors/${DetectorName} \n"
+  printf "\t\t -> Detector Analysis: \033[1;35m Analysis.h and Analysis.cxx\033[0m\n" 
   printf "\t\t -> Detector input file: \033[1;35m ${InputFile}\033[0m\n\n" 
 
 #Adding file to git
   printf "\033[1;36m-> Do you want to add those files to the nptool repository ? (y/n) \033[0m"
   read gitanswer
   if [[ $gitanswer =~ ^[Yy]$ ]];then 
-    git add -f ${pathNPL}${DetectorName}/CMakeLists.txt ${pathNPL}${DetectorName}/${DataFile_h} ${pathNPL}${DetectorName}/${DataFile_cxx} ${pathNPL}${DetectorName}/${PhysicsFile_h} ${pathNPL}${DetectorName}/${PhysicsFile_cxx} ${pathNPL}${DetectorName}/${SpectraFile_h} ${pathNPL}${DetectorName}/${SpectraFile_cxx} ${pathNPS}${DetectorName}/CMakeLists.txt ${pathNPS}${DetectorName}/${SimFile_h} ${pathNPS}${DetectorName}/${SimFile_cxx} ${pathInputs}${InputFile}
+    git add -f ${pathNPL}${DetectorName}/CMakeLists.txt ${pathNPL}${DetectorName}/${DataFile_h} ${pathNPL}${DetectorName}/${DataFile_cxx} ${pathNPL}${DetectorName}/${PhysicsFile_h} ${pathNPL}${DetectorName}/${PhysicsFile_cxx} ${pathNPL}${DetectorName}/${SpectraFile_h} ${pathNPL}${DetectorName}/${SpectraFile_cxx} ${pathNPS}${DetectorName}/CMakeLists.txt ${pathNPS}${DetectorName}/${SimFile_h} ${pathNPS}${DetectorName}/${SimFile_cxx} ${pathProjects}/${DetectorName}/${InputFile} ${pathProjects}/${DetectorName}/Analysis.h ${pathProjects}/${DetectorName}/Analysis.cxx ${pathProjects}/${DetectorName}/CMakeLists.txt
       printf "\033[1;32m**** Files added, use \033[1;36mgit commit -a \033[1;32m to commit them when ready ****\033[0m\n";
   fi
 #Display help message
-- 
GitLab