From 7c868f652fb77c5bb1e986b8587c8c7cb708331c Mon Sep 17 00:00:00 2001
From: Savannah Rose Shively <savannah.rose.shively@cern.ch>
Date: Thu, 1 Oct 2020 15:17:04 +0200
Subject: [PATCH] SimHitAlg practice

---
 .vscode/c_cpp_properties.json                 | 17 ++++++
 .../SimHitExample/CMakeLists.txt              |  2 +-
 .../SimHitExample/src/SimHitAlg.cxx           | 53 ++++++++++++++-----
 .../SimHitExample/src/SimHitAlg.h             |  6 +++
 4 files changed, 65 insertions(+), 13 deletions(-)
 create mode 100644 .vscode/c_cpp_properties.json

diff --git a/.vscode/c_cpp_properties.json b/.vscode/c_cpp_properties.json
new file mode 100644
index 00000000..0653a28a
--- /dev/null
+++ b/.vscode/c_cpp_properties.json
@@ -0,0 +1,17 @@
+{
+    "configurations": [
+        {
+            "name": "Linux",
+            "includePath": [
+                "${workspaceFolder}/**"
+            ],
+            "defines": [],
+            "compilerPath": "/cvmfs/sft.cern.ch/lcg/releases/gcc/8.3.0-cebb0/x86_64-centos7/bin/gcc",
+            "cStandard": "c99",
+            "cppStandard": "c++17",
+            "intelliSenseMode": "clang-x64",
+            "compileCommands": "${workspaceFolder}/build/compile_commands.json"
+        }
+    ],
+    "version": 4
+}
\ No newline at end of file
diff --git a/Control/CalypsoExample/SimHitExample/CMakeLists.txt b/Control/CalypsoExample/SimHitExample/CMakeLists.txt
index cf8ec563..69c640d5 100644
--- a/Control/CalypsoExample/SimHitExample/CMakeLists.txt
+++ b/Control/CalypsoExample/SimHitExample/CMakeLists.txt
@@ -3,7 +3,7 @@ atlas_subdir( SimHitExample )
 atlas_add_component( SimHitExample
                     src/SimHitAlg.cxx
                     src/components/SimHitExample_entries.cxx
-                    LINK_LIBRARIES AthenaBaseComps GeneratorObjects TrackerSimEvent
+                    LINK_LIBRARIES AthenaBaseComps GeneratorObjects TrackerSimEvent ScintSimEvent
         )
 
 atlas_install_joboptions( share/*.py )
\ No newline at end of file
diff --git a/Control/CalypsoExample/SimHitExample/src/SimHitAlg.cxx b/Control/CalypsoExample/SimHitExample/src/SimHitAlg.cxx
index 1f7888a5..fc396381 100644
--- a/Control/CalypsoExample/SimHitExample/src/SimHitAlg.cxx
+++ b/Control/CalypsoExample/SimHitExample/src/SimHitAlg.cxx
@@ -18,11 +18,16 @@ StatusCode SimHitAlg::initialize()
     ATH_CHECK(histSvc()->regHist("/HIST/modulesSide1", m_moduleSide1));
     ATH_CHECK(histSvc()->regHist("/HIST/modulesSide2", m_moduleSide2));
 
+    m_plate = new TH2D("plate", "Scint Hit Plate", 3, -1.5, 1.5, 4, -0.5, 3.5 );
+    ATH_CHECK(histSvc()->regHist("/HIST/plates", m_plate));
+
     // initialize data handle keys
     ATH_CHECK( m_mcEventKey.initialize() );
     ATH_CHECK( m_faserSiHitKey.initialize() );
+    ATH_CHECK( m_scintHitKey.initialize() );
     ATH_MSG_INFO( "Using GenEvent collection with key " << m_mcEventKey.key());
     ATH_MSG_INFO( "Using Faser SiHit collection with key " << m_faserSiHitKey.key());
+    ATH_MSG_INFO( "Using ScintHit collection with key " << m_scintHitKey.key());
     return StatusCode::SUCCESS;
 }
 
@@ -36,6 +41,9 @@ StatusCode SimHitAlg::execute()
     SG::ReadHandle<FaserSiHitCollection> h_siHits(m_faserSiHitKey);
     ATH_MSG_INFO("Read FaserSiHitCollection with " << h_siHits->size() << " hits");
 
+    SG::ReadHandle<ScintHitCollection> h_scintHits(m_scintHitKey);
+    ATH_MSG_INFO("Read ScintHitCollection with " << h_scintHits->size() << " hits");
+
     // Since we have no pile-up, there should always be a single GenEvent in the container
     const HepMC::GenEvent* ev = (*h_mcEvents)[0];
     if (ev == nullptr) 
@@ -47,22 +55,43 @@ StatusCode SimHitAlg::execute()
 
     // The hit container might be empty because particles missed the wafers
     if (h_siHits->size() == 0) return StatusCode::SUCCESS;
-    
-    // Loop over all hits; print and fill histogram
-    for (const FaserSiHit& hit : *h_siHits)
-    {
-        hit.print();
-        m_hist->Fill( hit.energyLoss() );
-        m_module->Fill( hit.getModule(), hit.getRow() );
-        if (hit.getSensor() == 0)
+    else{
+        // Loop over all hits; print and fill histogram
+        for (const FaserSiHit& hit : *h_siHits)
         {
-            m_moduleSide1->Fill( hit.getModule(), hit.getRow());
+            hit.print();
+            m_hist->Fill( hit.energyLoss() );
+            m_module->Fill( hit.getModule(), hit.getRow() );
+            if (hit.getSensor() == 0)
+            {
+                m_moduleSide1->Fill( hit.getModule(), hit.getRow());
+            }
+            else
+            {
+                m_moduleSide2->Fill( hit.getModule(), hit.getRow());
+            }
+
         }
-        else
+    }
+    
+
+
+    if (h_scintHits->size()!=0){
+        for (const ScintHit& hit : *h_scintHits)
         {
-            m_moduleSide2->Fill( hit.getModule(), hit.getRow());
-        }
+            hit.print();
+            m_hist->Fill( hit.energyLoss() );
+            m_plate->Fill( hit.getStation(), hit.getPlate() );
+            /*if (hit.getSensor() == 0)
+            {
+                m_moduleSide1->Fill( hit.getModule(), hit.getRow());
+            }
+            else
+            {
+                m_moduleSide2->Fill( hit.getModule(), hit.getRow());
+            }*/
 
+        }
     }
 
     return StatusCode::SUCCESS;
diff --git a/Control/CalypsoExample/SimHitExample/src/SimHitAlg.h b/Control/CalypsoExample/SimHitExample/src/SimHitAlg.h
index ae775330..3c5929ce 100644
--- a/Control/CalypsoExample/SimHitExample/src/SimHitAlg.h
+++ b/Control/CalypsoExample/SimHitExample/src/SimHitAlg.h
@@ -1,8 +1,10 @@
 #include "AthenaBaseComps/AthHistogramAlgorithm.h"
 #include "GeneratorObjects/McEventCollection.h"
 #include "TrackerSimEvent/FaserSiHitCollection.h"
+#include "ScintSimEvent/ScintHitCollection.h" //New Sav
 #include <TH1.h>
 
+
 /* SimHit reading example - Ryan Rice-Smith, UC Irvine */
 
 class SimHitAlg : public AthHistogramAlgorithm
@@ -22,9 +24,13 @@ class SimHitAlg : public AthHistogramAlgorithm
     TH2* m_moduleSide1;
     TH2* m_moduleSide2;
 
+    //ScintHit Histograms
+    TH2* m_plate;
+
     // Read handle keys for data containers
     // Any other event data can be accessed identically
     // Note the key names ("GEN_EVENT" or "SCT_Hits") are Gaudi properties and can be configured at run-time
     SG::ReadHandleKey<McEventCollection> m_mcEventKey       { this, "McEventCollection", "GEN_EVENT" };
     SG::ReadHandleKey<FaserSiHitCollection> m_faserSiHitKey { this, "FaserSiHitCollection", "SCT_Hits" };
+    SG::ReadHandleKey<ScintHitCollection> m_scintHitKey { this, "ScintHitCollection", "Scint_Hits" };
 };
\ No newline at end of file
-- 
GitLab