-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adding function to read input parameters from the RML, and some renaming #72
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -45,34 +45,36 @@ class TRestRawSignalChannelActivityProcess : public TRestEventProcess { | |
TRestDetectorReadout* fReadout; //! | ||
#endif | ||
|
||
void InitFromConfigFile() override; | ||
|
||
void Initialize() override; | ||
|
||
void LoadDefaultConfig(); | ||
|
||
protected: | ||
/// The value of the lower signal threshold to add it to the histogram | ||
Double_t fLowThreshold = 25; | ||
Double_t fLowThreshold; | ||
|
||
/// The value of the higher signal threshold to add it to the histogram | ||
Double_t fHighThreshold = 50; | ||
Double_t fHighThreshold; | ||
|
||
/// The number of bins at the daq channels histogram | ||
Int_t fDaqChannels = 300; | ||
Int_t fDaqHistogramChannels; | ||
|
||
/// The number of bins at the readout channels histogram | ||
Int_t fReadoutChannels = 128; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It is fine to rename the metadata members althought I would avoid to do that frequently. But, in order to apply proper class versioning, i.e. ROOT schema evolution, it is required to increase the I.e. the last line in this file
should be updated to
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, I think it is better to put the original names again. They are still appropriate names and we would avoid any issues with past versions. Do you agree? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, I agree with both choices, still changing names should be not be a big deal as soon as the class version is increased. |
||
Int_t fReadoutHistogramChannels; | ||
|
||
/// The first channel at the daq channels histogram | ||
Int_t fDaqStartChannel = 4320; | ||
Int_t fDaqStartChannel; | ||
|
||
/// The last channel at the daq channels histogram | ||
Int_t fDaqEndChannel = 4620; | ||
Int_t fDaqEndChannel; | ||
|
||
/// The first channel at the readout channels histogram | ||
Int_t fReadoutStartChannel = 0; | ||
Int_t fReadoutStartChannel; | ||
|
||
/// The last channel at the readout channels histogram | ||
Int_t fReadoutEndChannel = 128; | ||
Int_t fReadoutEndChannel; | ||
|
||
/// The daq channels histogram | ||
TH1D* fDaqChannelsHisto; //! | ||
|
@@ -121,12 +123,12 @@ class TRestRawSignalChannelActivityProcess : public TRestEventProcess { | |
RESTMetadata << "Low signal threshold activity : " << fLowThreshold << RESTendl; | ||
RESTMetadata << "High signal threshold activity : " << fHighThreshold << RESTendl; | ||
|
||
RESTMetadata << "Number of daq histogram channels : " << fDaqChannels << RESTendl; | ||
RESTMetadata << "Number of daq histogram channels : " << fDaqHistogramChannels << RESTendl; | ||
RESTMetadata << "Start daq channel : " << fDaqStartChannel << RESTendl; | ||
RESTMetadata << "End daq channel : " << fDaqEndChannel << RESTendl; | ||
|
||
#ifdef REST_DetectorLib | ||
RESTMetadata << "Number of readout histogram channels : " << fReadoutChannels << RESTendl; | ||
RESTMetadata << "Number of readout histogram channels : " << fReadoutHistogramChannels << RESTendl; | ||
RESTMetadata << "Start readout channel : " << fReadoutStartChannel << RESTendl; | ||
RESTMetadata << "End readout channel : " << fReadoutEndChannel << RESTendl; | ||
#else | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -175,40 +175,43 @@ void TRestRawSignalChannelActivityProcess::InitProcess() { | |
#ifdef REST_DetectorLib | ||
fReadout = GetMetadata<TRestDetectorReadout>(); | ||
|
||
RESTDebug << "TRestRawSignalChannelActivityProcess::InitProcess. Readout pointer : " << fReadout << RESTendl; | ||
if (GetVerboseLevel() >= TRestStringOutput::REST_Verbose_Level::REST_Info && fReadout) fReadout->PrintMetadata(); | ||
RESTDebug << "TRestRawSignalChannelActivityProcess::InitProcess. Readout pointer : " << fReadout | ||
<< RESTendl; | ||
if (GetVerboseLevel() >= TRestStringOutput::REST_Verbose_Level::REST_Info && fReadout) | ||
fReadout->PrintMetadata(); | ||
#endif | ||
|
||
if (!fReadOnly) { | ||
fDaqChannelsHisto = new TH1D("daqChannelActivityRaw", "daqChannelActivityRaw", fDaqChannels, | ||
fDaqChannelsHisto = new TH1D("daqChannelActivityRaw", "daqChannelActivityRaw", fDaqHistogramChannels, | ||
fDaqStartChannel, fDaqEndChannel); | ||
#ifdef REST_DetectorLib | ||
if (fReadout) { | ||
fReadoutChannelsHisto = new TH1D("rChannelActivityRaw", "readoutChannelActivity", | ||
fReadoutChannels, fReadoutStartChannel, fReadoutEndChannel); | ||
fReadoutChannelsHisto = | ||
new TH1D("rChannelActivityRaw", "readoutChannelActivity", fReadoutHistogramChannels, | ||
fReadoutStartChannel, fReadoutEndChannel); | ||
fReadoutChannelsHisto_OneSignal = | ||
new TH1D("rChannelActivityRaw_1", "readoutChannelActivity", fReadoutChannels, | ||
new TH1D("rChannelActivityRaw_1", "readoutChannelActivity", fReadoutHistogramChannels, | ||
fReadoutStartChannel, fReadoutEndChannel); | ||
fReadoutChannelsHisto_OneSignal_High = | ||
new TH1D("rChannelActivityRaw_1H", "readoutChannelActivity", fReadoutChannels, | ||
new TH1D("rChannelActivityRaw_1H", "readoutChannelActivity", fReadoutHistogramChannels, | ||
fReadoutStartChannel, fReadoutEndChannel); | ||
fReadoutChannelsHisto_TwoSignals = | ||
new TH1D("rChannelActivityRaw_2", "readoutChannelActivity", fReadoutChannels, | ||
new TH1D("rChannelActivityRaw_2", "readoutChannelActivity", fReadoutHistogramChannels, | ||
fReadoutStartChannel, fReadoutEndChannel); | ||
fReadoutChannelsHisto_TwoSignals_High = | ||
new TH1D("rChannelActivityRaw_2H", "readoutChannelActivity", fReadoutChannels, | ||
new TH1D("rChannelActivityRaw_2H", "readoutChannelActivity", fReadoutHistogramChannels, | ||
fReadoutStartChannel, fReadoutEndChannel); | ||
fReadoutChannelsHisto_ThreeSignals = | ||
new TH1D("rChannelActivityRaw_3", "readoutChannelActivity", fReadoutChannels, | ||
new TH1D("rChannelActivityRaw_3", "readoutChannelActivity", fReadoutHistogramChannels, | ||
fReadoutStartChannel, fReadoutEndChannel); | ||
fReadoutChannelsHisto_ThreeSignals_High = | ||
new TH1D("rChannelActivityRaw_3H", "readoutChannelActivity", fReadoutChannels, | ||
new TH1D("rChannelActivityRaw_3H", "readoutChannelActivity", fReadoutHistogramChannels, | ||
fReadoutStartChannel, fReadoutEndChannel); | ||
fReadoutChannelsHisto_MultiSignals = | ||
new TH1D("rChannelActivityRaw_M", "readoutChannelActivity", fReadoutChannels, | ||
new TH1D("rChannelActivityRaw_M", "readoutChannelActivity", fReadoutHistogramChannels, | ||
fReadoutStartChannel, fReadoutEndChannel); | ||
fReadoutChannelsHisto_MultiSignals_High = | ||
new TH1D("rChannelActivityRaw_MH", "readoutChannelActivity", fReadoutChannels, | ||
new TH1D("rChannelActivityRaw_MH", "readoutChannelActivity", fReadoutHistogramChannels, | ||
fReadoutStartChannel, fReadoutEndChannel); | ||
} | ||
#endif | ||
|
@@ -263,7 +266,8 @@ TRestEvent* TRestRawSignalChannelActivityProcess::ProcessEvent(TRestEvent* input | |
} | ||
} | ||
|
||
if (GetVerboseLevel() >= TRestStringOutput::REST_Verbose_Level::REST_Debug) fAnalysisTree->PrintObservables(); | ||
if (GetVerboseLevel() >= TRestStringOutput::REST_Verbose_Level::REST_Debug) | ||
fAnalysisTree->PrintObservables(); | ||
|
||
return fSignalEvent; | ||
} | ||
|
@@ -293,3 +297,19 @@ void TRestRawSignalChannelActivityProcess::EndProcess() { | |
#endif | ||
} | ||
} | ||
|
||
/////////////////////////////////////////////// | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should avoid implementation of The present There is an additional problem, for example, in the implementation of If this method is not reimplemented, then the naming convention will follow: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok, if There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I found a problem but I don't know how to solve it... Using the default values, it all works: But if I introduce values manually in the RML, e.g.
then all the values are wrongly read and/or applied to the wrong variable, and some are taken from the default: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @jgalan do you know why this might be happening? |
||
/// \brief Function to read input parameters from the RML | ||
/// TRestRawSignalChannelActivityProcess metadata section | ||
/// | ||
void TRestRawSignalChannelActivityProcess::InitFromConfigFile() { | ||
fLowThreshold = StringToDouble(GetParameter("lowThreshold", "25")); | ||
fHighThreshold = StringToDouble(GetParameter("highThreshold", "50")); | ||
|
||
fDaqHistogramChannels = StringToInteger(GetParameter("daqChannels", "300")); | ||
fDaqStartChannel = StringToInteger(GetParameter("daqStartCh", "4320")); | ||
fDaqEndChannel = StringToInteger(GetParameter("daqEndCh", "4620")); | ||
fReadoutHistogramChannels = StringToInteger(GetParameter("readoutChannels", "128")); | ||
fReadoutStartChannel = StringToInteger(GetParameter("readoutStartCh", "0")); | ||
fReadoutEndChannel = StringToInteger(GetParameter("readoutEndCh", "128")); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why to remove the default values from header? Providing the default value on the headers is now the stardard way.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I removed them because I had defined them in the .cxx file, to keep coherence with
TRestDetectorSignalChannelActivityProcess
. But I am going to put them back here if it is the standard way now. Should I then also change the cxx, so that the default values are not defined in two places?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should completely remove
InitFromConfigFile
implementation. No need to implementGetParameter
for basic parameters, in case it is necessary, you should make a call toTRestEventProcess::InitFromConfigFile
orTRestMetadata::InitFromConfigFile
.See for example the following implementation of
TRestAxionOptics::InitFromConfigFile
.https://github.com/rest-for-physics/axionlib/blob/master/src/TRestAxionOptics.cxx
The line
TRestMetadata::InitFromConfigFile
on the previous file will be responsible to read all the parameters, following the patternfVarName
tovarName
and it will initialise it with the default value if not given in the RML.In your case I believe you dont need to implement
InitFromConfigFile
. If it is not implemented, then the default is that an instance will callTRestEventProcess::InitFromConfigFile
method.