Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
.vscode
build-*/
install-*/
__pycache__/

*.o
*.swp
*.log
Expand All @@ -7,9 +11,7 @@ example/analysis
example/analysis_fullrec
example/data
example/*.root
leaf/DataModelRootDict*
leaf/HKAstroAnalysis.*
leaf/DataModel
DataManager/DataModelRootDict*
lib/*
job.sh
Config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
#include <array>
#include <string>

#include "HKObject.hpp"
#include "Enums/PMTType.hpp"
#include "HKObject.hpp"

/************************************************
* HKDarkNoise class definition
Expand All @@ -27,7 +27,7 @@ class HKDarkNoise : public HKObject {
*/
HKDarkNoise(HKDarkNoise* in);

virtual ~HKDarkNoise() = 0; //!< Destructor
virtual ~HKDarkNoise() = 0; //!< Destructor
virtual void Reset() = 0; //!< Reset function, called after each event
virtual unsigned int GetVersion() const = 0; //!< Return the class version number

Expand All @@ -41,44 +41,63 @@ class HKDarkNoise : public HKObject {

// v1 functions

//! Return average total number of dark noise hit in 1ns for a given PMT type
//! Initialize dark noise vector for a given PMT type
/*!
\param in PMTType. PMT type (ID, OD, mPMT)
\param number int. Number of PMTs
*/
virtual bool Initialize(PMTType in, int number) { return false; }

//! Return average total number of dark noise hit in 1ns for a given PMT type
//! Note: the value is ~ N_PMT * darknoise_per_PMT * 1e-9
/*!
\param in PMTType. PMT type (ID, OD, mPMT)
*/
virtual double GetAverageTotalDarkNoisePerNS(PMTType in) const {
return HKFormatError::ThrowErrorVersion<double>(__PRETTY_FUNCTION__, 0.0);
virtual double GetAverageTotalDarkNoisePerNS(PMTType in) const {
return HKFormatError::ThrowErrorVersion<double>(__PRETTY_FUNCTION__, 0.0);
}
//! Set average total number of dark noise hit in 1ns for a given PMT type

//! Set average total number of dark noise hit in 1ns for a given PMT type
//! Note: the value is ~ N_PMT * darknoise_per_PMT * 1e-9
/*!
\param in PMTType. PMT type (ID, OD, mPMT)
\param noise double. Average total dark noise hit
*/
virtual bool SetAverageTotalDarkNoisePerNS(PMTType in, double noise) {
return false;
}
virtual bool SetAverageTotalDarkNoisePerNS(PMTType in, double noise) { return false; }

//! Return dark noise rate for a given PMT in Hz
/*!
\param in PMTType. PMT type (ID, OD, mPMT)
\param num int. Channel number
\param num int. Channel number
*/
virtual double GetDarkNoiseHz(PMTType in, int num) const {
return HKFormatError::ThrowErrorVersion<double>(__PRETTY_FUNCTION__, 0.0);
virtual double GetDarkNoiseHz(PMTType in, int num) const {
return HKFormatError::ThrowErrorVersion<double>(__PRETTY_FUNCTION__, 0.0);
}

//! Set dark noise value for a given PMT type in Hz
/*!
\param in PMTType. PMT type (ID, OD, mPMT)
\param num int. Channel number
\param num int. Channel number
\param noise double. Dark noise value in Hz
*/
virtual bool SetDarkNoiseHz(PMTType in, int num, double noise) {
return false;
virtual bool SetDarkNoiseHz(PMTType in, int num, double noise) { return false; }

//! Return dark noise vector for a given PMT type
/*!
\param in PMTType. PMT type (ID, OD, mPMT)
\return std::vector<double>. Dark noise values in Hz
*/
virtual const std::vector<double> GetDarkNoiseVectorHz(PMTType in) const {
return HKFormatError::ThrowErrorVersion<std::vector<double>>(__PRETTY_FUNCTION__, std::vector<double>());
}

//! Set dark noise vector for a given PMT type
/*!
\param in PMTType. PMT type (ID, OD, mPMT)
\param noise std::vector<double>. Dark noise values in Hz
*/
virtual bool SetDarkNoiseVectorHz(PMTType in, const std::vector<double>& noise) { return false; }

ClassDef(HKDarkNoise, 1); //!< ROOT Class definition
};

Expand Down
35 changes: 35 additions & 0 deletions DataManager/DataModel-lite/HKDarkNoiseV1.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#include "HKDarkNoiseV1.hpp"

HKDarkNoiseV1::HKDarkNoiseV1() {
m_avg_dark_noise[static_cast<size_t>(PMTType::kID)] = 0.0;
m_avg_dark_noise[static_cast<size_t>(PMTType::kOD)] = 0.0;
m_avg_dark_noise[static_cast<size_t>(PMTType::kmPMT)] = 0.0;

this->Reset();
}

HKDarkNoiseV1::HKDarkNoiseV1(HKDarkNoise* in) {
// Load variable here:

// v1 copies
m_avg_dark_noise[static_cast<size_t>(PMTType::kID)] = in->GetAverageTotalDarkNoisePerNS(PMTType::kID);
m_avg_dark_noise[static_cast<size_t>(PMTType::kOD)] = in->GetAverageTotalDarkNoisePerNS(PMTType::kOD);
m_avg_dark_noise[static_cast<size_t>(PMTType::kmPMT)] = in->GetAverageTotalDarkNoisePerNS(PMTType::kmPMT);

m_dark_noise[static_cast<size_t>(PMTType::kID)] = in->GetDarkNoiseVectorHz(PMTType::kID);
m_dark_noise[static_cast<size_t>(PMTType::kOD)] = in->GetDarkNoiseVectorHz(PMTType::kOD);
m_dark_noise[static_cast<size_t>(PMTType::kmPMT)] = in->GetDarkNoiseVectorHz(PMTType::kmPMT);
}

HKDarkNoiseV1::~HKDarkNoiseV1() {
this->Reset();
}

void HKDarkNoiseV1::Reset() {
// Initialize variable here:
// Note, reset is called for every new event, so variables needing to be initialized
// once for a full file should be defined in the creator

// v1 resets
// m_a = 0;
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class HKDarkNoiseV1 : public HKDarkNoise {
HKDarkNoiseV1(HKDarkNoise* in);

~HKDarkNoiseV1() override; //!< Destructor
void Reset() override; //!< Reset function, called after each event. Use it to initialize variable
void Reset() override; //!< Reset function, called after each event. Use it to initialize variable

static constexpr unsigned int GetVersionStatic() {
return 1;
Expand All @@ -37,42 +37,73 @@ class HKDarkNoiseV1 : public HKDarkNoise {

// v1 functions

//! Return average total number of dark noise hit in 1ns for a given PMT type
//! Initialize dark noise vector for a given PMT type
/*!
\param in PMTType. PMT type (ID, OD, mPMT)
\param number int. Number of PMTs
*/
bool Initialize(PMTType in, int number) override {
m_dark_noise[static_cast<size_t>(in)].resize(number, 0.0);
return true;
}

//! Return average total number of dark noise hit in 1ns for a given PMT type
//! Note: the value is ~ N_PMT * darknoise_per_PMT * 1e-9
/*!
\param in PMTType. PMT type (ID, OD, mPMT)
*/
double GetAverageTotalDarkNoisePerNS(PMTType in) const override {
return HKFormatError::ThrowErrorVersion<double>(__PRETTY_FUNCTION__, 0.0);
double GetAverageTotalDarkNoisePerNS(PMTType in) const override {
return m_avg_dark_noise[static_cast<size_t>(in)];
}
//! Set average total number of dark noise hit in 1ns for a given PMT type

//! Set average total number of dark noise hit in 1ns for a given PMT type
//! Note: the value is ~ N_PMT * darknoise_per_PMT * 1e-9
/*!
\param in PMTType. PMT type (ID, OD, mPMT)
\param noise double. Average total dark noise hit
*/
bool SetAverageTotalDarkNoisePerNS(PMTType in, double noise) override {
return false;
m_avg_dark_noise[static_cast<size_t>(in)] = noise;
return true;
}

//! Return dark noise value for a given PMT in Hz
/*!
\param in PMTType. PMT type (ID, OD, mPMT)
\param num int. Channel number
\param num int. Channel number
*/
double GetDarkNoiseHz(PMTType in, int num) const override {
return HKFormatError::ThrowErrorVersion<double>(__PRETTY_FUNCTION__, 0.0);
double GetDarkNoiseHz(PMTType in, int num) const override {
return m_dark_noise[static_cast<size_t>(in)][num];
}

//! Set dark noise value for a given PMT type in Hz
/*!
\param in PMTType. PMT type (ID, OD, mPMT)
\param num int. Channel number
\param num int. Channel number
\param noise double. Dark noise value in Hz
*/
bool SetDarkNoiseHz(PMTType in, int num, double noise) override {
return false;
m_dark_noise[static_cast<size_t>(in)][num] = noise;
return true;
}

//! Return dark noise vector for a given PMT type
/*!
\param in PMTType. PMT type (ID, OD, mPMT)
\return std::vector<double>. Dark noise values in Hz
*/
const std::vector<double> GetDarkNoiseVectorHz(PMTType in) const override {
return m_dark_noise[static_cast<size_t>(in)];
}

//! Set dark noise vector for a given PMT type
/*!
\param in PMTType. PMT type (ID, OD, mPMT)
\param noise std::vector<double>. Dark noise values in Hz
*/
bool SetDarkNoiseVectorHz(PMTType in, const std::vector<double>& noise) override {
m_dark_noise[static_cast<size_t>(in)] = noise;
return true;
}

// define function here:
Expand All @@ -82,8 +113,10 @@ class HKDarkNoiseV1 : public HKDarkNoise {
private:

// v1 data members
std::array<double, static_cast<size_t>(PMTType::kNumPMTTypes)> m_avg_dark_noise; // Average dark noise for each PMT type (ID, OD, mPMT)
std::array<std::vector<double>, static_cast<size_t>(PMTType::kNumPMTTypes)> m_dark_noise; // Dark noise for each PMT (ID, OD, mPMT).
std::array<double, static_cast<size_t>(PMTType::kNumPMTTypes)>
m_avg_dark_noise; // Average dark noise for each PMT type (ID, OD, mPMT)
std::array<std::vector<double>, static_cast<size_t>(PMTType::kNumPMTTypes)>
m_dark_noise; // Dark noise for each PMT (ID, OD, mPMT).

ClassDefOverride(HKDarkNoiseV1, 1); //!< ROOT Class definition
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,10 +137,23 @@ class HKGeometryPMT : public HKObject {

//! Set PMT Orientation
/*!
\param x ROOT::Math::XYZVector
\param in ROOT::Math::XYZVector
\return `true` if successful, `false` if not
*/
virtual bool SetOrientation(UNUSED_PARAM ROOT::Math::XYZVector& in) { return false; }

//! Get PMT Bad flag
/*!
\return bool. Indicate if the PMT is bad or not
*/
virtual bool GetBadFlag() const { return false; }

//! Set PMT Bad flag
/*!
\param in bool
\return `true` if successful, `false` if not
*/
virtual bool SetPoSetOrientationsitionInCm(UNUSED_PARAM ROOT::Math::XYZVector& in) { return false; }
virtual bool SetBadFlag(UNUSED_PARAM bool in) { return false; }

ClassDef(HKGeometryPMT, 1); //!< ROOT Class definition
};
Expand Down Expand Up @@ -187,14 +200,15 @@ class HKGeometryPMTCollection : public HKObjectCollection {
return HKFormatError::ThrowErrorVersion<HKGeometryPMT*>(__PRETTY_FUNCTION__, NULL);
}


//! Wrapper for std::vector back()
virtual HKGeometryPMT* back() {
return HKFormatError::ThrowErrorVersion<HKGeometryPMT*>(__PRETTY_FUNCTION__, NULL);
}

//! Wrapper for std::vector size()
virtual size_t size() const { return HKFormatError::ThrowErrorVersion<size_t>(__PRETTY_FUNCTION__, 0); }
virtual size_t size() const {
return HKFormatError::ThrowErrorVersion<size_t>(__PRETTY_FUNCTION__, 0);
}

//! Wrapper for std::vector resize()
/*!
Expand Down Expand Up @@ -308,13 +322,11 @@ template<class T> class HKGeometryPMTCollectionT : public HKGeometryPMTCollectio
/*!
\param entries integer. Number of entries
*/
void resize(size_t entries) override {
contents->resize(entries);
#ifdef HK_USE_ROOT7
for (auto& ptr : *contents) { ptr = std::make_unique<T>(); }
#else
for (auto& ptr : *contents) { ptr = std::make_unique<HKGeometryPMT>(); }
#endif
void resize(size_t entries) override {
contents->resize(entries);
for(auto& ptr : *contents) {
ptr = std::make_unique<T>();
}
}

//! Wrapper for std::vector push_back()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ HKGeometryPMTV1::HKGeometryPMTV1() {
m_pmt_sub_id = 0;
m_pmt_position.SetXYZ(-9999., -9999., -9999.);
m_pmt_orientation.SetXYZ(-9999., -9999., -9999.);
m_pmt_bad_flag = false;

this->Reset();
}
Expand All @@ -18,6 +19,7 @@ HKGeometryPMTV1::HKGeometryPMTV1(HKGeometryPMT* in) {
m_pmt_sub_id = in->GetSubID();
m_pmt_position = in->GetPositionInCm();
m_pmt_orientation = in->GetOrientation();
m_pmt_bad_flag = in->GetBadFlag();
}

HKGeometryPMTV1::~HKGeometryPMTV1() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,11 +147,27 @@ class HKGeometryPMTV1 : public HKGeometryPMT {
\param x ROOT::Math::XYZVector
\return `true` if successful, `false` if not
*/
bool SetPoSetOrientationsitionInCm(ROOT::Math::XYZVector& in) override {
bool SetOrientation(ROOT::Math::XYZVector& in) override {
m_pmt_orientation = in;
return true;
}

//! Get PMT Bad flag
/*!
\return bool. Indicate if the PMT is bad or not
*/
bool GetBadFlag() const override { return m_pmt_bad_flag; }

//! Set PMT Bad flag
/*!
\param in bool
\return `true` if successful, `false` if not
*/
bool SetBadFlag(bool in) override {
m_pmt_bad_flag = in;
return true;
}

private:

// v1 data members
Expand All @@ -160,6 +176,7 @@ class HKGeometryPMTV1 : public HKGeometryPMT {
unsigned int m_pmt_sub_id; //!< PMT sub id (0 for 20" or OD PMT, 1-19 for mPMT's 3" PMTs)
ROOT::Math::XYZVector m_pmt_position; //!< Position in cm
ROOT::Math::XYZVector m_pmt_orientation; //!< Normalized orientation
bool m_pmt_bad_flag; //!< Whether the PMT is bad or not

ClassDefOverride(HKGeometryPMTV1, 1); //!< ROOT Class definition
};
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading