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
4 changes: 3 additions & 1 deletion include/MGUIOptionsDEESMEX.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,10 @@ class MGUIOptionsDEESMEX : public MGUIOptions
TGCheckButton* m_StopAfter;
//! Entry field for the maximum number of accepted events
MGUIEEntry* m_MaximumAcceptedEvents;
//! ACS DEE energy correction file
//! Shield DEE energy correction file
MGUIEFileSelector* m_ShieldEnergyCorrectionFileSelector;
//! Shield DEE Readout energy calibration file
MGUIEFileSelector* m_ShieldReadoutFileSelector;
//! Select deadtime constants file
MGUIEFileSelector* m_DeadtimeFileSelector;

Expand Down
11 changes: 11 additions & 0 deletions include/MModuleDEESMEX.h
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,17 @@ class MModuleDEESMEX : public MModule
return m_ShieldEnergyCorrection.GetShieldEnergyCorrectionFileName();
}

//! Set shield energy calibration file name
void SetShieldReadoutFileName(const MString& FileName)
{
m_ShieldReadout.SetShieldReadoutFileName(FileName);
}
//! Get shield energy calibration file name
MString GetShieldReadoutFileName() const
{
return m_ShieldReadout.GetShieldReadoutFileName();
}

//! Set dead time file name
void SetDeadtimeFileName(const MString& FileName)
{
Expand Down
27 changes: 23 additions & 4 deletions include/MReadOutElementVoxel3D.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,18 @@
////////////////////////////////////////////////////////////////////////////////


//! The read-out element of a BGO voxel. It reads the detector name and the voxel x, y, z, ID
//! Read-out element identified by detector/crystal ID and optionally by 3D voxel IDs
class MReadOutElementVoxel3D : public MReadOutElement
{
// public interface:
public:
//! default constructor - Read out element of a voxel 3D
//! Default constructor
MReadOutElementVoxel3D();

//! full constructor - Read out element of a voxel 3D
//! Constructor for a crystal-only read-out element
MReadOutElementVoxel3D(const MString& DetectorID, unsigned int CrystalID);

//! Constructor for a fully specified 3D voxel read-out element
MReadOutElementVoxel3D(const MString& DetectorID, unsigned int CrystalID, unsigned int VoxelXID, unsigned int VoxelYID, unsigned int VoxelZID);

//! Simple default destructor
Expand All @@ -53,6 +56,9 @@ class MReadOutElementVoxel3D : public MReadOutElement
//! Compare two read-out elements
virtual bool operator==(const MReadOutElement& R) const;

//! Compare two voxel read-out elements for ordered containers
bool operator<(const MReadOutElementVoxel3D& R) const;

//! Return true if this read-out element is of the given type
virtual bool IsOfType(const MString& String) const;
//! Return the type of this read-out element
Expand Down Expand Up @@ -80,6 +86,18 @@ class MReadOutElementVoxel3D : public MReadOutElement
return m_CrystalID;
}

//! Return true if all voxel IDs are defined
bool HasVoxelIDs() const;

//! Return true if only detector and crystal IDs are defined
bool IsCrystalOnly() const;

//! Clear voxel IDs and keep only detector and crystal identification
void ClearVoxelIDs();

//! Set all voxel IDs
void SetVoxelIDs(unsigned int VoxelXID, unsigned int VoxelYID, unsigned int VoxelZID);

//! Set Voxel X ID as int
void SetVoxelXID(unsigned int VoxelXID)
{
Expand All @@ -96,7 +114,7 @@ class MReadOutElementVoxel3D : public MReadOutElement
{
m_VoxelYID = VoxelYID;
}
//! Set Voxel Y ID as int
//! Get Voxel Y ID as int
unsigned int GetVoxelYID() const
{
return m_VoxelYID;
Expand Down Expand Up @@ -157,3 +175,4 @@ ostream& operator<<(ostream& os, const MReadOutElementVoxel3D& R);


////////////////////////////////////////////////////////////////////////////////

69 changes: 63 additions & 6 deletions include/MSubModuleShieldReadout.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* MSubModuleShieldReadout.h
*
* Copyright (C) by Andreas Zoglauer.
* Copyright (C) by Andreas Zoglauer, Valentina Fioretti.
* All rights reserved.
*
* Please see the source-file for the copyright-notice.
Expand All @@ -17,12 +17,14 @@


// Standard libs:
#include <map>

// ROOT libs:

// MEGAlib libs:
#include "MGlobal.h"
#include "MSubModule.h"
#include "MReadOutElementVoxel3D.h"

// Forward declarations:

Expand All @@ -41,46 +43,100 @@ class MSubModuleShieldReadout : public MSubModule
MSubModuleShieldReadout(const MSubModuleShieldReadout&) = delete;
//! No copy assignment
MSubModuleShieldReadout& operator=(const MSubModuleShieldReadout&) = delete;
//! No move constructors
//! No move constructor
MSubModuleShieldReadout(MSubModuleShieldReadout&&) = delete;
//! No move operators
//! No move assignment
MSubModuleShieldReadout& operator=(MSubModuleShieldReadout&&) = delete;

//! Default destructor
virtual ~MSubModuleShieldReadout();

//! Set the shield readout calibration file name
void SetShieldReadoutFileName(const MString& FileName)
{
m_ShieldReadoutFileName = FileName;
}

//! Set the shield readout calibration file name - deprecated spelling kept for compatibility
void SetShieldRedoutFileName(const MString& FileName)
{
SetShieldReadoutFileName(FileName);
}

//! Return the shield readout calibration file name
MString GetShieldReadoutFileName() const
{
return m_ShieldReadoutFileName;
}

//! Initialize the module
virtual bool Initialize();

//! Clear event data from the module
virtual void Clear();

//! Main data analysis routine, which updates the event to a new level
//! Convert the shield hit energies into ADC values
virtual bool AnalyzeEvent(MReadOutAssembly* Event);

//! Finalize the module
virtual void Finalize();

//! Read the configuration data from an XML node
virtual bool ReadXmlConfiguration(MXmlNode* Node);

//! Create an XML node tree from the configuration
virtual MXmlNode* CreateXmlConfiguration(MXmlNode* Node);

// protected methods:
protected:
//! Read and parse the shield readout calibration CSV file
bool ParseShieldReadoutFile();

//! Compute ADC from the calibration ADC = A*Energy^2 + B*Energy + C
double GetADC(double Energy, const MString& DetectorID, unsigned int CrystalID);

// private methods:
private:



// protected members:
protected:

//! Shield readout calibration file name
MString m_ShieldReadoutFileName;

// private members:
private:
//! Calibration data for ADC = A*Energy^2 + B*Energy + C
struct ShieldCalibration
{
//! Quadratic coefficient A
double m_QuadraticCoefficient = 0.0;
//! Linear coefficient B
double m_LinearCoefficient = 0.0;
//! Constant coefficient C
double m_ConstantCoefficient = 0.0;
};

//! Calibration indexed by crystal-only MReadOutElementVoxel3D keys (detector ID + crystal ID)
std::map<MReadOutElementVoxel3D, ShieldCalibration> m_ADCCalibration;

//! Number of columns expected in the NRL shield calibration CSV
static constexpr unsigned int m_NumberOfCSVColumns = 16;

//! CSV column containing the detector/crystal identifier
static constexpr unsigned int m_ChannelIdentifierColumn = 2;

//! CSV column containing the quadratic calibration coefficient
static constexpr unsigned int m_QuadraticCoefficientColumn = 8;

//! CSV column containing the linear calibration coefficient
static constexpr unsigned int m_LinearCoefficientColumn = 10;

//! CSV column containing the constant calibration coefficient
static constexpr unsigned int m_ConstantCoefficientColumn = 12;

//! Maximum value of the 14-bit ADC
static constexpr double m_MaxADCRange = 16383.0;



Expand All @@ -95,3 +151,4 @@ class MSubModuleShieldReadout : public MSubModule


////////////////////////////////////////////////////////////////////////////////

26 changes: 26 additions & 0 deletions resource/dee/ShieldEnergyCalibration_NRL.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
Detector Meta Data,,,,,,,,ADC to Energy Fit Parameters (ax^2 + bx + c),,,,,,Resolution,
scb,gamma_channel,sipm_crystal,dac_id,cathod,asic,pannel,measured_cathod_voltage,a,a_err,b,b_err,c,c_err,Resolution @ 662 keV,Resolution Err @ 662 keV
A,8,Z1-0,2,5,0,Z1,27.5,-8.19E-05,5.84E-05,8.50E+00,4.42E-02,1.60E+03,3.47E+00,14.82,0.09
A,12,Z1-1,3,6,0,Z1,27.47,-3.68E-04,7.08E-04,9.53E+00,5.32E-01,1.52E+03,4.17E+01,14.8,0.67
A,16,Z1-2,4,7,0,Z1,27.52,1.21E-04,6.21E-04,8.48E+00,4.66E-01,1.57E+03,3.65E+01,14.61,0.61
A,20,Z1-3,5,8,0,Z1,27.43,-9.25E-05,3.58E-04,8.64E+00,2.69E-01,1.55E+03,2.10E+01,14.82,0.37
A,8,Z0-0,7,1,1,Z0,27.46,-2.39E-04,3.07E-04,8.87E+00,2.31E-01,1.63E+03,1.80E+01,14.86,0.31
A,12,Z0-1,6,2,1,Z0,27.47,-3.13E-04,8.99E-04,9.42E+00,6.75E-01,1.50E+03,5.28E+01,14.43,0.83
A,16,Z0-2,0,3,1,Z0,27.5,-8.08E-04,6.26E-04,1.05E+01,4.72E-01,1.49E+03,3.69E+01,14.77,0.57
A,20,Z0-3,1,4,1,Z0,27.48,-5.90E-04,8.38E-04,9.86E+00,6.31E-01,1.50E+03,4.94E+01,14.35,0.77
B,8,Y1-0,2,5,0,Y1,27.5,3.80E-05,2.38E-04,7.87E+00,1.78E-01,1.55E+03,1.40E+01,15.34,0.27
B,12,Y1-1,3,6,0,Y1,27.48,4.39E-04,3.85E-04,7.20E+00,2.88E-01,1.55E+03,2.27E+01,15.4,0.44
B,16,Y1-2,4,7,0,Y1,27.48,-8.41E-05,1.60E-04,8.32E+00,1.20E-01,1.45E+03,9.80E+00,15.34,0.18
B,20,Z1-4,5,8,0,Z1,27.51,-6.54E-04,4.75E-04,1.01E+01,3.60E-01,1.51E+03,2.96E+01,14.89,0.46
B,8,Y0-0,7,1,1,Y0,27.5,3.00E-04,5.72E-04,7.69E+00,4.31E-01,1.49E+03,4.23E+01,14.5,0.6
B,12,Y0-1,6,2,1,Y0,27.36,7.64E-04,7.81E-04,6.79E+00,5.87E-01,1.48E+03,5.26E+01,14.27,0.83
B,16,Y0-2,0,3,1,Y0,27.45,1.13E-04,1.99E-04,7.88E+00,1.49E-01,1.58E+03,1.26E+01,15.42,0.23
B,20,Z0-4,1,4,1,Z0,27.52,-6.31E-04,5.99E-04,9.85E+00,4.54E-01,1.64E+03,3.61E+01,15.15,0.59
C,8,X1-0,2,5,0,X1,27.49,2.86E-05,8.83E-05,7.75E+00,6.62E-02,1.50E+03,5.48E+00,15.34,0.12
C,12,X1-1,3,6,0,X1,27.49,2.27E-04,5.27E-04,7.56E+00,3.97E-01,1.46E+03,3.48E+01,15.1,0.58
C,16,X1-2,4,7,0,X1,27.49,-4.08E-04,6.27E-04,8.70E+00,4.74E-01,1.34E+03,4.44E+01,15.77,0.7
C,20,D1-0,5,8,0,D1,27.49,-2.94E-03,7.89E-04,1.45E+01,6.10E-01,1.27E+03,4.86E+01,17.01,0.78
C,8,X0-0,7,1,1,X0,27.46,-2.47E-03,1.69E-03,1.40E+01,1.34E+00,7.85E+02,1.05E+02,23.7,2.11
C,12,X0-1,6,2,1,X0,27.51,6.56E-05,1.05E-04,7.87E+00,7.84E-02,1.60E+03,6.11E+00,15.55,0.13
C,16,X0-2,0,3,1,X0,27.43,-2.11E-03,1.37E-03,1.34E+01,1.07E+00,9.44E+02,8.37E+01,22.13,1.62
C,20,D0-0,1,4,1,D0,27.42,-3.18E-03,3.46E-04,1.47E+01,3.10E-01,1.38E+03,2.74E+01,15.22,0.37
10 changes: 9 additions & 1 deletion src/MGUIOptionsDEESMEX.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,13 @@ void MGUIOptionsDEESMEX::Create()
m_ShieldEnergyCorrectionFileSelector->SetFileType("Shield DEE energy correction file", "*.csv");
m_OptionsFrame->AddFrame(m_ShieldEnergyCorrectionFileSelector, LabelLayout);

// shield energy calibration file
m_ShieldReadoutFileSelector = new MGUIEFileSelector(m_OptionsFrame,
"Please select an energy calibration file for the Shield DEE Readout:",
dynamic_cast<MModuleDEESMEX*>(m_Module)->GetShieldReadoutFileName());
m_ShieldReadoutFileSelector->SetFileType("Shield DEE Readout energy calibration file", "*.csv");
m_OptionsFrame->AddFrame(m_ShieldReadoutFileSelector, LabelLayout);

/*
m_ApplyFudgeFactorSelector = new TGCheckButton(m_OptionsFrame, "Apply fudge factor to better match fluxes", 1);
m_ApplyFudgeFactorSelector->SetOn(dynamic_cast<MModuleLoaderSimulationsSingleDet*>(m_Module)->GetApplyFudgeFactor());
Expand Down Expand Up @@ -211,7 +218,8 @@ bool MGUIOptionsDEESMEX::OnApply()

// Shield options:
dynamic_cast<MModuleDEESMEX*>(m_Module)->SetShieldEnergyCorrectionFileName(m_ShieldEnergyCorrectionFileSelector->GetFileName());

dynamic_cast<MModuleDEESMEX*>(m_Module)->SetShieldReadoutFileName(m_ShieldReadoutFileSelector->GetFileName());

// GeD options:
dynamic_cast<MModuleDEESMEX*>(m_Module)->SetEnergyCalibrationFileName(m_EnergyCalibrationFileSelector->GetFileName());
dynamic_cast<MModuleDEESMEX*>(m_Module)->SetDepthCoefficientsFileName(m_DepthCalibrationCoeffsFileSelector->GetFileName());
Expand Down
Loading
Loading