2022-03-06 15:17:54 -05:00
|
|
|
/*
|
|
|
|
SPSAnalysisStage.cpp
|
|
|
|
Example of a user AnalysisStage. This one is based around the SE-SPS detector system in FoxLab at FSU.
|
|
|
|
|
|
|
|
GWM -- Feb 2022
|
|
|
|
*/
|
2022-02-05 13:20:45 -05:00
|
|
|
#include "SPSAnalysisStage.h"
|
|
|
|
|
|
|
|
namespace Navigator {
|
|
|
|
|
2022-03-06 15:17:54 -05:00
|
|
|
//Construct each NavParameter with their unique name. Then bind them to the SpectrumManager.
|
2022-02-05 13:20:45 -05:00
|
|
|
SPSAnalysisStage::SPSAnalysisStage() :
|
2022-02-22 20:11:08 -05:00
|
|
|
AnalysisStage("SPSAnalysis"), delayFLTime("delayFLTime"), delayFRTime("delayFRTime"), delayBLTime("delayBLTime"), delayBRTime("delayBRTime"), x1("x1"), x2("x2"), xavg("xavg"),
|
|
|
|
scintLeft("scintLeft"), anodeBack("anodeBack")
|
2022-02-05 13:20:45 -05:00
|
|
|
{
|
2022-02-20 22:19:33 -05:00
|
|
|
SpectrumManager& manager = SpectrumManager::GetInstance();
|
|
|
|
manager.BindParameter(delayFLTime);
|
|
|
|
manager.BindParameter(delayFRTime);
|
|
|
|
manager.BindParameter(delayBLTime);
|
|
|
|
manager.BindParameter(delayBRTime);
|
|
|
|
manager.BindParameter(x1);
|
|
|
|
manager.BindParameter(x2);
|
|
|
|
manager.BindParameter(xavg);
|
2022-02-22 20:11:08 -05:00
|
|
|
manager.BindParameter(scintLeft);
|
|
|
|
manager.BindParameter(anodeBack);
|
2022-02-05 13:20:45 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
SPSAnalysisStage::~SPSAnalysisStage() {}
|
|
|
|
|
2022-03-06 15:17:54 -05:00
|
|
|
//Do some physics!
|
2022-02-19 11:33:21 -05:00
|
|
|
void SPSAnalysisStage::AnalyzePhysicsEvent(const NavEvent& event)
|
2022-02-05 13:20:45 -05:00
|
|
|
{
|
|
|
|
|
2022-03-06 15:17:54 -05:00
|
|
|
//Most analysis stages will start kinda like this. Take the raw event data and
|
|
|
|
//put it into NavParameters using the hit id. Switches are perfect for this. Can also
|
|
|
|
//create mapping classes to use text-file-based id association (commonly called channel maps).
|
2022-02-05 13:20:45 -05:00
|
|
|
for(auto& hit : event)
|
|
|
|
{
|
2022-02-22 20:11:08 -05:00
|
|
|
switch (hit.id)
|
|
|
|
{
|
|
|
|
case 129:
|
|
|
|
scintLeft.SetValue(hit.longEnergy);
|
|
|
|
break;
|
|
|
|
case 136:
|
|
|
|
delayFLTime.SetValue(hit.timestamp / 1.0e3);
|
|
|
|
break;
|
|
|
|
case 137:
|
|
|
|
delayFRTime.SetValue(hit.timestamp / 1.0e3);
|
|
|
|
break;
|
|
|
|
case 138:
|
|
|
|
delayBLTime.SetValue(hit.timestamp / 1.0e3);
|
|
|
|
break;
|
|
|
|
case 139:
|
|
|
|
delayBRTime.SetValue(hit.timestamp / 1.0e3);
|
|
|
|
break;
|
|
|
|
case 143:
|
|
|
|
anodeBack.SetValue(hit.longEnergy);
|
|
|
|
break;
|
|
|
|
}
|
2022-02-05 13:20:45 -05:00
|
|
|
}
|
|
|
|
|
2022-03-06 15:17:54 -05:00
|
|
|
//If you want to use parameters to calculate another parameter, you
|
|
|
|
//need to check that the parameter is valid (set in this event)!
|
2022-02-05 13:20:45 -05:00
|
|
|
if(delayFLTime.IsValid() && delayFRTime.IsValid())
|
|
|
|
x1.SetValue((delayFLTime.GetValue() - delayFRTime.GetValue())*0.5);
|
|
|
|
|
|
|
|
if(delayBLTime.IsValid() && delayBRTime.IsValid())
|
2022-02-22 20:11:08 -05:00
|
|
|
x2.SetValue((delayBLTime.GetValue() - delayBRTime.GetValue())*0.5);
|
2022-02-05 13:20:45 -05:00
|
|
|
}
|
|
|
|
}
|