REST-for-Physics  v2.3
Rare Event Searches ToolKit for Physics
TRestDetectorSingleChannelAnalysisProcess.h
1
11
12#ifndef RestCore_TRestDetectorSingleChannelAnalysisProcess
13#define RestCore_TRestDetectorSingleChannelAnalysisProcess
14
15#include <TH1D.h>
16#include <TRestEventProcess.h>
17
18#include "TRestDetectorGainMap.h"
19#include "TRestDetectorGas.h"
20#include "TRestDetectorHitsEvent.h"
21#include "TRestDetectorReadout.h"
22#include "TRestDetectorSignalEvent.h"
23
25 private:
26 TRestDetectorSignalEvent* fSignalEvent;
27 TRestDetectorReadout* fReadout;
28 TRestDetectorGainMap* fCalib;
29
30 void InitFromConfigFile() override;
31
32 void Initialize() override;
33 // parameters
34 bool fApplyGainCorrection;
35 bool fCreateGainMap;
36 TVector2 fThrIntegralCutRange;
37 TVector2 fNGoodSignalsCutRange;
38 TVector2 fSpecFitRange;
39 std::string fCalibSave;
40
41 // analysis result
42 std::map<int, TH1D*> fChannelThrIntegral; //-> [channel id, sum]
43 std::map<int, double> fChannelFitMean; // [MM id, fitted position]
44 std::map<int, double> fChannelGain; // [MM id, channel gain]
45 std::map<int, double> fChannelGainError; // [MM id, channel gain error]
46
47 public:
48 RESTValue GetInputEvent() const override { return fSignalEvent; }
49 RESTValue GetOutputEvent() const override { return fSignalEvent; }
50
51 void FitChannelGain();
52 // See comments on CXX
53 void SaveGainMetadata(std::string filename);
54 void InitProcess() override;
55 TRestEvent* ProcessEvent(TRestEvent* inputEvent) override;
56 void EndProcess() override;
57 TH1D* GetChannelSpectrum(int id);
58 void PrintChannelSpectrums(std::string filename);
59
60 void PrintMetadata() override {
62
63 RESTMetadata << "the mode is:" << RESTendl;
64 RESTMetadata << (fApplyGainCorrection ? "> " : " ")
65 << "Apply channel correction std::map for spectrum " << RESTendl;
66 RESTMetadata << (fCreateGainMap ? "> " : " ")
67 << "Create new correction std::map for each channel" << RESTendl;
68 RESTMetadata << "output mapping file: " << fCalibSave << RESTendl;
69 RESTMetadata << "Energy cut for Threshold integral: " << RESTValue(fThrIntegralCutRange) << RESTendl;
70 RESTMetadata << "Energy cut for NGoodSignals: " << RESTValue(fNGoodSignalsCutRange) << RESTendl;
71 RESTMetadata << "Fit range for the spectra: " << RESTValue(fSpecFitRange) << RESTendl;
72
73 EndPrintProcess();
74 }
75
76 const char* GetProcessName() const override { return "readoutAnalysis"; }
77
78 // Constructor
80 TRestDetectorSingleChannelAnalysisProcess(const char* configFilename);
81 // Destructor
83
85};
86#endif
A metadata class to generate/store a readout description.
RESTValue GetInputEvent() const override
Get pointer to input event. Must be implemented in the derived class.
TRestEvent * ProcessEvent(TRestEvent *inputEvent) override
Process one event.
void EndProcess() override
To be executed at the end of the run (outside event loop)
void PrintMetadata() override
Implemented it in the derived metadata class to print out specific metadata information.
RESTValue GetOutputEvent() const override
Get pointer to output event. Must be implemented in the derived class.
void InitProcess() override
To be executed at the beginning of the run (outside event loop)
void InitFromConfigFile() override
To make settings from rml file. This method must be implemented in the derived class.
A base class for any REST event process.
void BeginPrintProcess()
[name, cut range]
A base class for any REST event.
Definition: TRestEvent.h:38
endl_t RESTendl
Termination flag object for TRestStringOutput.