Skip to content

Commit

Permalink
feat: digitizer benchmark
Browse files Browse the repository at this point in the history
  • Loading branch information
c-dilks committed Jan 23, 2023
1 parent eb1a6d6 commit 2b77f40
Show file tree
Hide file tree
Showing 10 changed files with 197 additions and 17 deletions.
2 changes: 1 addition & 1 deletion src/algorithms/digi/PhotoMultiplierHitDigi.cc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: LGPL-3.0-or-later
// Copyright (C) 2022 Chao Peng
// Copyright (C) 2023 Chao Peng, Christopher Dilks

/* General PhotoMultiplier Digitization
*
Expand Down
2 changes: 1 addition & 1 deletion src/algorithms/digi/PhotoMultiplierHitDigi.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: LGPL-3.0-or-later
// Copyright (C) 2022 Chao Peng
// Copyright (C) 2023 Chao Peng, Christopher Dilks

/* General PhotoMultiplier Digitization
*
Expand Down
48 changes: 48 additions & 0 deletions src/algorithms/digi/PhotoMultiplierHitDigiAnalysis.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
// Copyright 2023, Christopher Dilks
// Subject to the terms in the LICENSE file found in the top-level directory.

#include "PhotoMultiplierHitDigiAnalysis.h"

// AlgorithmInit
//---------------------------------------------------------------------------
void eicrecon::PhotoMultiplierHitDigiAnalysis::AlgorithmInit(std::shared_ptr<spdlog::logger>& logger) {
m_log = logger;

// define histograms
m_adc_dist = new TH1D("adc_dist", "ADC Distribution;counts", adc_max, 0, adc_max);
m_tdc_dist = new TH1D("tdc_dist", "TDC Distribution;counts", tdc_max, 0, tdc_max);
m_tdc_vs_adc = new TH2D("tdc_vs_adc", "TDC vs. ADC;ADC counts;TDC counts",
adc_max/2, 0, adc_max/2,
tdc_max/2, 0, tdc_max/2
);

// format histograms
auto format1D = [] (auto h) {
h->SetLineColor(kBlack);
h->SetFillColor(kBlack);
};
format1D(m_adc_dist);
format1D(m_tdc_dist);
}


// AlgorithmProcess
//---------------------------------------------------------------------------
void eicrecon::PhotoMultiplierHitDigiAnalysis::AlgorithmProcess(std::vector<const edm4eic::RawPMTHit*> hits) {
m_log->trace("{:=^70}"," call PhotoMultiplierHitDigiAnalysis::AlgorithmProcess ");

// loop over `CherenkovParticleID` objects
for(const auto& hit : hits) {
auto adc = hit->getIntegral();
auto tdc = hit->getTimeStamp();
m_adc_dist->Fill(adc);
m_tdc_dist->Fill(tdc);
m_tdc_vs_adc->Fill(adc,tdc);
}
}


// AlgorithmFinish
//---------------------------------------------------------------------------
void eicrecon::PhotoMultiplierHitDigiAnalysis::AlgorithmFinish() {
}
46 changes: 46 additions & 0 deletions src/algorithms/digi/PhotoMultiplierHitDigiAnalysis.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
// Copyright 2023, Christopher Dilks
// Subject to the terms in the LICENSE file found in the top-level directory.

#pragma once

// ROOT
#include <TH1D.h>
#include <TH2D.h>
#include <TMath.h>

// data model
#include <edm4eic/RawPMTHitCollection.h>

// EICrecon
#include <spdlog/spdlog.h>

namespace eicrecon {

class PhotoMultiplierHitDigiAnalysis {

private:

// binning
const int adc_max = std::pow(2,10);
const int tdc_max = std::pow(2,10);

// histograms
TH1D *m_adc_dist;
TH1D *m_tdc_dist;
TH2D *m_tdc_vs_adc;

public:
PhotoMultiplierHitDigiAnalysis() = default;
~PhotoMultiplierHitDigiAnalysis() {}

// algorithm methods
void AlgorithmInit(std::shared_ptr<spdlog::logger>& logger);
void AlgorithmProcess(std::vector<const edm4eic::RawPMTHit*> hits);
void AlgorithmFinish();

private:
std::shared_ptr<spdlog::logger> m_log;

};

}
2 changes: 1 addition & 1 deletion src/benchmarks/reconstruction/pid/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ plugin_glob_all(${PLUGIN_NAME})

# Add libraries
# (same as target_include_directories but for both plugin and library)
plugin_link_libraries(${PLUGIN_NAME} algorithms_pid_library)
plugin_link_libraries(${PLUGIN_NAME} algorithms_digi_library algorithms_pid_library)
40 changes: 40 additions & 0 deletions src/benchmarks/reconstruction/pid/Digitizer_processor.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
// Copyright 2022, Christopher Dilks
// Subject to the terms in the LICENSE file found in the top-level directory.

#include "Digitizer_processor.h"

//-------------------------------------------
// InitWithGlobalRootLock
//-------------------------------------------
void eicrecon::Digitizer_processor::InitWithGlobalRootLock() {
auto app = GetApplication();

// input tags
auto plugin_name = eicrecon::str::ReplaceAll(GetPluginName(), ".so", "");

// set logger
InitLogger(plugin_name, "info");
m_log->debug("Initializing plugin {}",plugin_name);

// set ROOT TDirectory
auto rootfile_svc = app->GetService<RootFile_service>();
auto rootfile = rootfile_svc->GetHistFile();
rootfile->mkdir("pid_digi")->cd();

// initialize underlying algorithms
m_analysis_algo.AlgorithmInit(m_log);
}

//-------------------------------------------
// ProcessSequential
//-------------------------------------------
void eicrecon::Digitizer_processor::ProcessSequential(const std::shared_ptr<const JEvent>& event) {
m_analysis_algo.AlgorithmProcess(m_digi_hits());
}

//-------------------------------------------
// FinishWithGlobalRootLock
//-------------------------------------------
void eicrecon::Digitizer_processor::FinishWithGlobalRootLock() {
m_analysis_algo.AlgorithmFinish();
}
44 changes: 44 additions & 0 deletions src/benchmarks/reconstruction/pid/Digitizer_processor.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
// Copyright 2022, Christopher Dilks
// Subject to the terms in the LICENSE file found in the top-level directory.

#pragma once

// JANA
#include <JANA/JEventProcessorSequentialRoot.h>

// data model
#include <edm4eic/CherenkovParticleID.h>

// algorithms
#include <algorithms/digi/PhotoMultiplierHitDigiAnalysis.h>

// services
#include <services/rootfile/RootFile_service.h>
#include <services/log/Log_service.h>
#include <extensions/spdlog/SpdlogExtensions.h>
#include <extensions/spdlog/SpdlogMixin.h>
#include <extensions/string/StringHelpers.h>

namespace eicrecon {
class Digitizer_processor :
public JEventProcessorSequentialRoot,
public SpdlogMixin<Digitizer_processor>
{

public:

Digitizer_processor() { SetTypeName(NAME_OF_THIS); }
void InitWithGlobalRootLock() override;
void ProcessSequential(const std::shared_ptr<const JEvent>& event) override;
void FinishWithGlobalRootLock() override;

private:

// input collections // FIXME: generalize for other RICHes
PrefetchT<edm4eic::RawPMTHit> m_digi_hits = {this, "DRICHRawHits"};

// underlying algorithms
eicrecon::PhotoMultiplierHitDigiAnalysis m_analysis_algo;

};
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
// Copyright 2022, Christopher Dilks
// Subject to the terms in the LICENSE file found in the top-level directory.

#include "BenchmarksPID_processor.h"
#include "IrtCherenkovParticleID_processor.h"

//-------------------------------------------
// InitWithGlobalRootLock
//-------------------------------------------
void eicrecon::BenchmarksPID_processor::InitWithGlobalRootLock() {
void eicrecon::IrtCherenkovParticleID_processor::InitWithGlobalRootLock() {
auto app = GetApplication();

// input tags
Expand All @@ -19,22 +19,22 @@ void eicrecon::BenchmarksPID_processor::InitWithGlobalRootLock() {
// set ROOT TDirectory
auto rootfile_svc = app->GetService<RootFile_service>();
auto rootfile = rootfile_svc->GetHistFile();
rootfile->mkdir("pid")->cd();
rootfile->mkdir("pid_irt")->cd();

// initialize underlying algorithm
// initialize underlying algorithms
m_analysis_algo.AlgorithmInit(m_log);
}

//-------------------------------------------
// ProcessSequential
//-------------------------------------------
void eicrecon::BenchmarksPID_processor::ProcessSequential(const std::shared_ptr<const JEvent>& event) {
void eicrecon::IrtCherenkovParticleID_processor::ProcessSequential(const std::shared_ptr<const JEvent>& event) {
m_analysis_algo.AlgorithmProcess(m_cherenkov_pids());
}

//-------------------------------------------
// FinishWithGlobalRootLock
//-------------------------------------------
void eicrecon::BenchmarksPID_processor::FinishWithGlobalRootLock() {
void eicrecon::IrtCherenkovParticleID_processor::FinishWithGlobalRootLock() {
m_analysis_algo.AlgorithmFinish();
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,24 +20,24 @@
#include <extensions/string/StringHelpers.h>

namespace eicrecon {
class BenchmarksPID_processor :
class IrtCherenkovParticleID_processor :
public JEventProcessorSequentialRoot,
public SpdlogMixin<BenchmarksPID_processor>
public SpdlogMixin<IrtCherenkovParticleID_processor>
{

public:

BenchmarksPID_processor() { SetTypeName(NAME_OF_THIS); }
IrtCherenkovParticleID_processor() { SetTypeName(NAME_OF_THIS); }
void InitWithGlobalRootLock() override;
void ProcessSequential(const std::shared_ptr<const JEvent>& event) override;
void FinishWithGlobalRootLock() override;

private:

// input collections
PrefetchT<edm4eic::CherenkovParticleID> m_cherenkov_pids = {this, "DRICHIrtCherenkovParticleID"}; // FIXME: generalize for other RICHes
// input collections // FIXME: generalize for other RICHes
PrefetchT<edm4eic::CherenkovParticleID> m_cherenkov_pids = {this, "DRICHIrtCherenkovParticleID"};

// underlying algorithm
// underlying algorithms
eicrecon::IrtCherenkovParticleIDAnalysis m_analysis_algo;

};
Expand Down
6 changes: 4 additions & 2 deletions src/benchmarks/reconstruction/pid/benchmarks_pid.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@
#include <JANA/JApplication.h>
#include <JANA/JFactoryGenerator.h>

#include "BenchmarksPID_processor.h"
#include "Digitizer_processor.h"
#include "IrtCherenkovParticleID_processor.h"

extern "C" {
void InitPlugin(JApplication *app) {
InitJANAPlugin(app);
app->Add(new eicrecon::BenchmarksPID_processor);
app->Add(new eicrecon::Digitizer_processor);
// app->Add(new eicrecon::IrtCherenkovParticleID_processor);
}
}

0 comments on commit 2b77f40

Please sign in to comment.