Commit 07327e1a authored by Jolie Roiseux's avatar Jolie Roiseux
Browse files

Merge branch 'feature/efficiency' into 'develop'

Feature/event_efficiency

See merge request !59
parents b78bdb0e 2e98ac12
Pipeline #53580 passed with stages
in 5 minutes and 50 seconds
......@@ -20,7 +20,7 @@ obj/pulse_analysis/Exp2Gaus1.o obj/pulse_analysis/Exp2Gaus2.o obj/pulse_analysis
obj/pulse_analysis/PulseAnalysisProcessor.o obj/StepRunManager.o obj/baseline_processing/BaselineProcessor.o \
obj/filtering/TirangleFilter.o obj/filtering/ExpFilter.o obj/filtering/MeanFilter.o obj/filtering/MatchedFilter.o \
obj/filtering/ConvolutionFilterStrategy.o obj/filtering/FilterProcessor.o obj/baseline_processing/MostProbBaselineStrategy.o \
obj/event_analysis/LOLXEventProcessor.o obj/filtering/ExpMatchFilter.o
obj/event_analysis/LOLXEventProcessor.o obj/filtering/ExpMatchFilter.o obj/event_analysis/EventEfficiency.o
all: lib bin/vanwftk bin/EventViewer
......
#include "RunManager.h"
#include "baseline_processing/BaselineProcessor.h"
#include "event_analysis/EventEfficiency.h"
#include "event_analysis/LOLXEventProcessor.h"
#include "filtering/FilterProcessor.h"
#include "pulse_analysis/PulseAnalysisProcessor.h"
......@@ -56,6 +57,8 @@ IEventProcessor *RunManager::createEventProcessor() {
if (channelConfigs[0].eventStrategy == "LOLX") {
ep = new LOLXEventProcessor();
} else if (channelConfigs[0].eventStrategy == "Efficiency") {
ep = new EventEfficiency(channelConfigs);
} else if (channelConfigs[0].eventStrategy == "NA") {
ep = nullptr;
} else {
......@@ -107,6 +110,9 @@ void RunManager::processEvents() {
}
}
if (ep != nullptr)
ep->final();
wrProcessor.write();
std::cout << "\n\n"
......
#include "EventEfficiency.h"
EventEfficiency::EventEfficiency(std::vector<ChannelConfig> &channelConfigs) {
for (auto cc = channelConfigs.begin(); cc != channelConfigs.end(); cc++)
vars.push_back(cc->vars);
num_events = 0;
numEffPulsesFound = 0;
numFalPulsesFound = 0;
}
int EventEfficiency::processEvent(Event *event) {
int i = 0;
for (auto channel = event->getChannels()->begin();
channel != event->getChannels()->end(); channel++) {
double *window = new double[2];
window[0] = vars[i]["WindowStart"].asDouble();
window[1] = vars[i]["WindowEnd"].asDouble();
if (vars[i]["isTrigger"].asInt() == 1)
continue;
num_events++;
int found_pulse = 0;
for (auto pulse = channel->getPulses()->begin();
pulse != channel->getPulses()->end(); pulse++) {
if (pulse->time > window[0] && pulse->time < window[1]) {
found_pulse++;
} else if (pulse->time < window[0]) {
numFalPulsesFound++;
}
}
if (found_pulse == 0)
numEffPulsesFound++;
i++;
}
}
void EventEfficiency::final() {
// TODO: make a better output
std::cout << std::endl
<< "Pulse efficiency in window is "
<< ((double)numEffPulsesFound) / num_events << std::endl;
std::cout << "Pulse purity in window is "
<< ((double)numFalPulsesFound) / num_events << std::endl;
}
\ No newline at end of file
#ifndef __EFFICIENCYEVENTPROCESSOR_H_
#define __EFFICIENCYEVENTPROCESSOR_H_
#include "EventProcessor.h"
class EventEfficiency : public IEventProcessor {
public:
EventEfficiency(std::vector<ChannelConfig> &channelConfigs);
int processEvent(Event *event) override;
void final() override;
int num_events;
int numEffPulsesFound;
int numFalPulsesFound;
std::vector<Json::Value> vars;
};
#endif // __EFFICIENCYEVENTPROCESSOR_H_
\ No newline at end of file
......@@ -32,6 +32,7 @@ struct ChannelConfig {
class IEventProcessor {
public:
virtual int processEvent(Event *event) = 0;
virtual void final(){}; // TODO: maybe a better name
virtual ~IEventProcessor() {}
};
......
{
"EventLimit": 1000,
"EventLimit": 20000,
"DataSource": {
"FilePath": "./ntp/DS-WAV/LF_TILE15_77K_73V_9VoV_2.wav",
"Device": "LNGS-WAV",
......@@ -8,13 +8,16 @@
},
"ChannelConfigs": [
{
"FilterStrategy": "ExpMatch",
"FilterStrategy": "Mean",
"PulseFindingStrategy": "PFSProminence",
"PulseAnalysisStrategy": "AdditiveChi2RefitExp2Gaus1",
"BaselineStrategy": "MostProbable",
"WritingStrategy": "TTreeWriter",
"EventProcessor": "Efficiency",
"Variables": {
"__Comment0__": "Pulse Shape",
"WindowStart": 17500,
"WindowEnd": 20000,
"Noise": 21,
"RiseTimeSigma": 1.12,
"FallTimeTau": 700,
......@@ -60,6 +63,7 @@
"BaselineStrategy": "MostProbable",
"WritingStrategy": "TTreeWriter",
"Variables": {
"isTrigger": 1,
"__Comment0__": "Pulse Shape",
"Noise": 21,
"RiseTimeSigma": 1.12,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment