Browse Source

Added exporting CPATH in setPicoDst.sh so now readPicoDst.C can be run both as a macro and compiled code via ROOT

PeterParfenov 2 years ago
parent
commit
d98dadfc88
4 changed files with 41 additions and 12 deletions
  1. 8 3
      CMakeLists.txt
  2. 11 3
      bin/PicoDstConfig.cpp
  3. 3 6
      include/PicoDstVersion.h.in
  4. 19 0
      macros/readPicoDst.C

+ 8 - 3
CMakeLists.txt

@@ -86,19 +86,23 @@ add_library(PicoDst SHARED ${PicoDst_cxx_files} G__PicoDst.cxx)
 target_link_libraries(PicoDst ${PICO_DST_INCLUDE_LIBRARIES})
 
 set(ENV{PICO_DST_BIN} "${CMAKE_CURRENT_BINARY_DIR}")
-set(ENV{PICO_DST_SRC} "${CMAKE_CURRENT_SOURCE_DIR}")
+set(ENV{PICO_DST_SRC} "${CMAKE_CURRENT_SOURCE_DIR}/src")
+set(ENV{PICO_DST_INC} "${CMAKE_CURRENT_SOURCE_DIR}/include")
 set(PICO_DST_BIN "${CMAKE_CURRENT_BINARY_DIR}")
-set(PICO_DST_SRC "${CMAKE_CURRENT_SOURCE_DIR}")
+set(PICO_DST_SRC "${CMAKE_CURRENT_SOURCE_DIR}/src")
+set(PICO_DST_INC "${CMAKE_CURRENT_SOURCE_DIR}/include")
 message(STATUS "PICO_DST_BIN: " $ENV{PICO_DST_BIN})
 message(STATUS "PICO_DST_SRC: " $ENV{PICO_DST_SRC})
-set(BASH "/bin/bash")
+set(BASH $ENV{SHELL})
 file( WRITE  ${CMAKE_BINARY_DIR}/setPicoDst.sh "#!${BASH}\n")
 file( APPEND ${CMAKE_BINARY_DIR}/setPicoDst.sh "\n")
 file( APPEND ${CMAKE_BINARY_DIR}/setPicoDst.sh "export PICO_DST_BIN=$ENV{PICO_DST_BIN}\n")
 file( APPEND ${CMAKE_BINARY_DIR}/setPicoDst.sh "export PICO_DST_SRC=$ENV{PICO_DST_SRC}\n")
+file( APPEND ${CMAKE_BINARY_DIR}/setPicoDst.sh "export PICO_DST_INC=$ENV{PICO_DST_INC}\n")
 file( APPEND ${CMAKE_BINARY_DIR}/setPicoDst.sh "\n")
 file( APPEND ${CMAKE_BINARY_DIR}/setPicoDst.sh "export LD_LIBRARY_PATH=$PICO_DST_BIN:$LD_LIBRARY_PATH\n")
 file( APPEND ${CMAKE_BINARY_DIR}/setPicoDst.sh "export PATH=$PICO_DST_BIN:$PATH\n")
+file( APPEND ${CMAKE_BINARY_DIR}/setPicoDst.sh "export CPATH=$PICO_DST_INC:$CPATH\n")
 
 
 add_definitions("-DGIT_COMMIT_HASH=${GIT_COMMIT_HASH}")
@@ -106,6 +110,7 @@ add_definitions("-DGIT_BRANCH=${GIT_BRANCH}")
 add_definitions("-DGIT_TAG_VERSION=${GIT_TAG_VERSION}")
 add_definitions("-DPICO_DST_BIN_DIR=${PICO_DST_BIN}")
 add_definitions("-DPICO_DST_SRC_DIR=${PICO_DST_SRC}")
+add_definitions("-DPICO_DST_INC_DIR=${PICO_DST_INC}")
 
 # Get the current working branch
 execute_process(

+ 11 - 3
bin/PicoDstConfig.cpp

@@ -5,9 +5,10 @@
 
 int main(int argc, char **argv)
 {
-  bool isVersion=false, isBin=false, isInc=false;
+  bool isVersion=false, isBin=false, isSrc=false, isInc=false;
   std::string strBin=TOSTRING(PICO_DST_BIN_DIR);
-  std::string strInc=TOSTRING(PICO_DST_SRC_DIR);
+  std::string strSrc=TOSTRING(PICO_DST_SRC_DIR);
+  std::string strInc=TOSTRING(PICO_DST_INC_DIR);
   std::string strVersion_tag=TOSTRING(GIT_TAG_VERSION);
   std::string strVersion_branch=TOSTRING(GIT_BRANCH);
   std::string strVersion_hash=TOSTRING(GIT_COMMIT_HASH);
@@ -15,7 +16,7 @@ int main(int argc, char **argv)
   std::string strOutput="";
   if (argc<2)
   {
-    std::cerr << "Usage: PicoDst-config [--bindir] [--incdir] [--version]" << std::endl;
+    std::cerr << "Usage: PicoDst-config [--bindir] [--srcdir] [--incdir] [--version]" << std::endl;
     return 1;
   }
 
@@ -23,6 +24,7 @@ int main(int argc, char **argv)
   {
     if (std::string(argv[i]) != "--version" &&
       std::string(argv[i]) != "--bindir" &&
+      std::string(argv[i]) != "--srcdir" &&
       std::string(argv[i]) != "--incdir")
     {
             std::cerr << "\n[ERROR]: Unknown parameter " << i << ": " << argv[i] << std::endl;
@@ -45,12 +47,18 @@ int main(int argc, char **argv)
         isInc = true;
         continue;
       }
+      if (std::string(argv[i]) == "--srcdir")
+      {
+        isSrc = true;
+        continue;
+      }
     }
   }
 
   if (isVersion) strOutput+=(strVersion+" ");
   if (isBin) strOutput+=(strBin+" ");
   if (isInc) strOutput+=(strInc+" ");
+  if (isSrc) strOutput+=(strSrc+" ");
 
   std::cout << strOutput << std::endl;
 

+ 3 - 6
include/PicoDstVersion.h.in

@@ -9,11 +9,8 @@
 #define GIT_BRANCH @GIT_BRANCH@
 #define GIT_COMMIT_HASH @GIT_COMMIT_HASH@
 
-#ifndef PICO_DST_BIN_DIR
-#define PICO_DST_BIN_DIR "@PICO_DST_BIN@"
-#endif
-#ifndef PICO_DST_SRC_DIR
-#define PICO_DST_SRC_DIR "@PICO_DST_SRC@"
-#endif
+#define PICO_DST_BIN_DIR @PICO_DST_BIN@
+#define PICO_DST_SRC_DIR @PICO_DST_SRC@
+#define PICO_DST_INC_DIR @PICO_DST_INC@
 
 #endif  /* VERSION_PICODST_H_ */

+ 19 - 0
macros/readPicoDst.C

@@ -1,5 +1,24 @@
 // Do not forget to source setPicoDst.sh script
 
+#include <iostream>
+
+#include <TStopwatch.h>
+#include <TChain.h>
+#include <TFile.h>
+#include <TClonesArray.h>
+#include <TH1F.h>
+#include <TH1I.h>
+#include <TH2F.h>
+#include <TMath.h>
+
+#include <PicoDstMCEvent.h>
+#include <PicoDstRecoEvent.h>
+#include <PicoDstMCTrack.h>
+#include <PicoDstRecoTrack.h>
+#include <PicoDstFHCal.h>
+
+// R__LOAD_LIBRARY(libPicoDst.so)
+
 void readPicoDst(TString inputFileName, TString outputFileName)
 {
   TStopwatch timer;