Skip to content
Snippets Groups Projects
Commit 7c868f65 authored by Savannah Rose Shively's avatar Savannah Rose Shively
Browse files

SimHitAlg practice

parent 5a53d5df
No related branches found
No related tags found
No related merge requests found
{
"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
......@@ -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
......@@ -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;
......
#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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment