From 1116b5004fa7f18a88f90213e48eb9457bb1ff14 Mon Sep 17 00:00:00 2001
From: Alexander Kiselev <ayk@bnl.gov>
Date: Mon, 15 Nov 2021 05:55:47 -0500
Subject: [PATCH] Work in progress changes to IRT code

---
 detectors/src/ERich_geo.cpp     |  2 +-
 evaluation/CMakeLists.txt       | 37 +++++++++++++--------------------
 evaluation/source/evaluation.cc |  5 +++--
 evaluation/source/reader.cc     | 15 +++++++++----
 4 files changed, 30 insertions(+), 29 deletions(-)

diff --git a/detectors/src/ERich_geo.cpp b/detectors/src/ERich_geo.cpp
index 44b5764..784ae24 100644
--- a/detectors/src/ERich_geo.cpp
+++ b/detectors/src/ERich_geo.cpp
@@ -142,7 +142,7 @@ static Ref_t createDetector(Detector& desc, xml::Handle_t handle, SensitiveDetec
   // Get access to the readout structure decoder; may want to simply call desc.readout("DRICHHits");
   const auto &rdspecs = desc.readouts();
   if (rdspecs.size() != 1) {
-    printout(FATAL,"DRich_geo","Expect a single readout structure in XML file"); 
+    printout(FATAL,"ERich_geo","Expect a single readout structure in XML file"); 
     return det;
   } //if
   // Do not mess up with casting of (*desc.readouts().begin()).second; just call desc.readout();
diff --git a/evaluation/CMakeLists.txt b/evaluation/CMakeLists.txt
index 41e419e..0283a0b 100644
--- a/evaluation/CMakeLists.txt
+++ b/evaluation/CMakeLists.txt
@@ -3,49 +3,42 @@ cmake_minimum_required(VERSION 3.0.0 FATAL_ERROR)
 
 project(EVALUATION)
 
+set(IRTEVAL_LIB IRTEVAL)
+
 SET(READER_EXE reader)
-SET(DREADER_EXE dreader)
 SET(EVALUATION_EXE evaluation)
 
+SET( IRTEVAL_SRC
+  G__IRTEVAL.cxx
+)
+
 # Well, it is assumed that includes are available in /usr/local/include/dd4pod;
 SET( READER_SRC
   ${PROJECT_SOURCE_DIR}/source/reader.cc
-
-  G__evaluation.cxx
 )
 
-# FIXME: split the CINT library part off;
 SET( EVALUATION_SRC
   ${PROJECT_SOURCE_DIR}/source/evaluation.cc
-
-  G__evaluation.cxx
 )
 
-# FIXME: split the CINT library part off;
-SET( DREADER_SRC
-  ${PROJECT_SOURCE_DIR}/source/dreader.cc
+SET(EVALUATION_ROOTMAP ${CMAKE_CURRENT_BINARY_DIR}/lib${IRTEVAL_LIB}_rdict.pcm ${CMAKE_CURRENT_BINARY_DIR}/lib${IRTEVAL_LIB}.rootmap )
 
-  G__evaluation.cxx
-)
-
-SET(EVALUATION_ROOTMAP ${CMAKE_CURRENT_BINARY_DIR}/libevaluation_rdict.pcm ${CMAKE_CURRENT_BINARY_DIR}/libevaluation.rootmap )
-
-ROOT_GENERATE_DICTIONARY(G__evaluation eicd/CherenkovPdgHypothesis.h eicd/CherenkovParticleIDData.h dd4pod/PhotoMultiplierHitData.h dd4pod/Geant4ParticleData.h LINKDEF include/evaluationLinkDef.h)
+ROOT_GENERATE_DICTIONARY(G__${IRTEVAL_LIB} eicd/CherenkovPdgHypothesis.h eicd/CherenkovParticleIDData.h dd4pod/PhotoMultiplierHitData.h dd4pod/Geant4ParticleData.h LINKDEF include/evaluationLinkDef.h)
 
 SET(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
 ADD_EXECUTABLE( ${READER_EXE} ${READER_SRC} )
-TARGET_LINK_LIBRARIES(${READER_EXE} ${ROOT_LIBRARIES} DD4pod IRT)
-
-#ADD_EXECUTABLE( ${DREADER_EXE} ${DREADER_SRC} )
-#TARGET_LINK_LIBRARIES(${DREADER_EXE} ${ROOT_LIBRARIES} DD4pod IRT)
+TARGET_LINK_LIBRARIES(${READER_EXE} ${ROOT_LIBRARIES} DD4pod IRT IRTEVAL)
 
 ADD_EXECUTABLE( ${EVALUATION_EXE} ${EVALUATION_SRC} )
-TARGET_LINK_LIBRARIES(${EVALUATION_EXE} ${ROOT_LIBRARIES} DD4pod IRT)
+TARGET_LINK_LIBRARIES(${EVALUATION_EXE} ${ROOT_LIBRARIES} DD4pod IRT IRTEVAL)
+
+ADD_LIBRARY( ${IRTEVAL_LIB} SHARED ${IRTEVAL_SRC} G__evaluation.cxx)
+TARGET_LINK_LIBRARIES(${IRTEVAL_LIB} ${ROOT_LIBRARIES} DD4pod )
 
 #----------------------------------------------------------------------------
 
-INSTALL(FILES   ${EVALUATION_ROOTMAP} DESTINATION bin)
+INSTALL(FILES   ${EVALUATION_ROOTMAP} DESTINATION lib)
 install(TARGETS ${READER_EXE}         DESTINATION bin)
-#install(TARGETS ${DREADER_EXE}        DESTINATION bin)
 install(TARGETS ${EVALUATION_EXE}     DESTINATION bin)
+install(TARGETS ${IRTEVAL_LIB}        DESTINATION lib)
 
diff --git a/evaluation/source/evaluation.cc b/evaluation/source/evaluation.cc
index d2f4365..197ca89 100644
--- a/evaluation/source/evaluation.cc
+++ b/evaluation/source/evaluation.cc
@@ -95,9 +95,10 @@ int main(int argc, char** argv)
 	  if (abs(option.pdg) == 11) continue;
 
 	  if (!best || option.weight > best->weight) best = &option;
-	  printf("radiator %3d (pdg %5d): npe %5d, weight %7.2f\n", 
-		 option.radiator, option.pdg, option.npe, option.weight);
+	  printf("radiator %3d (pdg %5d): weight %7.2f, npe %7.2f\n", 
+		 option.radiator, option.pdg, option.weight, option.npe);
 	} //for
+	printf("\n");
 
 	// Check whether the true PDG got a highest score;
 	if (!best || best->pdg != mctrack.pdgID) false_assignment_stat++;
diff --git a/evaluation/source/reader.cc b/evaluation/source/reader.cc
index 3345747..56af387 100644
--- a/evaluation/source/reader.cc
+++ b/evaluation/source/reader.cc
@@ -1,5 +1,7 @@
 
 // ROOT
+//#include "TH1D.h"
+//#include <TCanvas.h>
 #include "TTree.h"
 #include "TFile.h"
 #include <TRandom.h>
@@ -13,8 +15,8 @@
 #include <CherenkovDetectorCollection.h>
 
 // Optionally: mimic low wave length cutoff and average QE x Geometric sensor efficiency;
-//#define _WAVE_LENGTH_CUTOFF_ (350.0)
-//#define _AVERAGE_PDE_        ( 0.30)
+#define _WAVE_LENGTH_CUTOFF_ (350.0)
+#define _AVERAGE_PDE_        ( 0.30)
 
 int main(int argc, char** argv) 
 {
@@ -53,12 +55,14 @@ int main(int argc, char** argv)
     exit(0);
   } //if
 
-  //auto gas      = detector->GetRadiator("GasVolume");
+  //auto np = new TH1D("np", "Photon count",            50,     0,    50);
+
+  auto gas      = detector->GetRadiator("GasVolume");
   auto aerogel  = detector->GetRadiator("Aerogel");
   //auto acrylic  = detector->GetRadiator("Filter");
   // Assume the reference value was close enough in ERich_geo.cpp; since QE was not accounted, 
   // this may not be true; 
-  //gas    ->m_AverageRefractiveIndex = gas    ->n();
+  gas    ->m_AverageRefractiveIndex = gas    ->n();
   aerogel->m_AverageRefractiveIndex = aerogel->n();
   //acrylic->m_AverageRefractiveIndex = acrylic->n();
 
@@ -178,5 +182,8 @@ int main(int argc, char** argv)
 
   printf("%d false out of %lld\n", false_assignment_stat, t->GetEntries());
 
+  //auto cv = new TCanvas("cv", "", 800, 600);
+  //cv->cd(1); np->Draw();
+
   return 0;
 } // main()
-- 
GitLab