7 if(configfile!=
"") m_variables.Initialise(configfile);
14 bool use_stopwatch =
false;
15 m_variables.Get(
"use_stopwatch", use_stopwatch);
26 Log(
"FATAL: BONSAI library not found. Ensure the BONSAI library exists at $BONSAIDIR/libWCSimBonsai.so. For more information about BONSAI, see https://github.com/hyperk/hk-BONSAI",
FATAL,
m_verbose);
35 WCSimRootGeom * geo = 0;
36 m_data->WCSimGeomTree->SetBranchAddress(
"wcsimrootgeom", &geo);
37 m_data->WCSimGeomTree->GetEntry(0);
39 m_data->WCSimGeomTree->ResetBranchAddresses();
55 float out_vertex[4], out_direction[6], out_maxlike[3];
57 double dout_vertex[3], dout_direction[3], dout_cone[2];
60 for (
int itrigger = 0; itrigger < m_data->IDTriggers.m_num_triggers; itrigger++) {
66 bool found_first_time =
false;
70 for(std::vector<SubSample>::iterator is = m_data->IDSamples.begin(); is != m_data->IDSamples.end(); ++is){
74 const size_t nhits_in_subsample = is->m_time.size();
77 for(
size_t ihit = is->m_first_unique; ihit < nhits_in_subsample; ihit++) {
79 if(std::find(is->m_trigger_readout_windows[ihit].begin(),
80 is->m_trigger_readout_windows[ihit].end(),
81 itrigger) == is->m_trigger_readout_windows[ihit].end())
85 if(!found_first_time) {
86 first_time = is->m_time[ihit];
87 found_first_time =
true;
91 m_ss <<
"DEBUG: Hit " << ihit <<
" at time " << is->m_time[ihit];
95 m_in_Ts ->push_back(is->m_time[ihit] - first_time);
96 m_in_Qs ->push_back(is->m_charge[ihit]);
104 if(m_in_nhits < m_nhits_min || m_in_nhits >
m_nhits_max) {
105 m_ss <<
"INFO: " <<
m_in_nhits <<
" hits in current trigger. Not running BONSAI";
112 m_ss <<
"DEBUG: First hit time relative to sample: " <<
m_in_Ts->at(0) + first_time;
131 + m_data->IDSamples[0].m_timestamp;
133 if(m_data->IDSamples.size() > 1) {
134 Log(
"WARN: You have multiple SubSamples. Absolute time of BONSAI reconstruction could be wrong. This will be fixed in parallel framework",
WARN,
m_verbose);
137 m_ss <<
"DEBUG: Vertex reconstructed at x, y, z, t:";
138 for(
int i = 0; i < 3; i++) {
139 m_ss <<
" " << out_vertex[i] <<
",";
141 m_ss <<
" " << vertex_time;
146 for(
int i = 0; i < 3; i++) {
147 dout_vertex[i] = out_vertex[i];
148 dout_direction[i] = out_direction[i];
150 for(
int i = 0; i < 2; i++)
151 dout_cone[i] = out_direction[i+3];
154 m_data->RecoInfo.AddRecon(
kReconBONSAI, itrigger, m_in_nhits,
155 vertex_time, &(dout_vertex[0]), out_maxlike[2], out_maxlike[1],
156 &(dout_direction[0]), &(dout_cone[0]), out_direction[5]);
WCSimBonsai * m_bonsai
This is the class that runs the BONSAI low-energy reconstruction algorithm.
std::string Result(std::string method_name, std::string output_file="")
int m_verbose
Verbosity level, as defined in tool parameter file.
void Start()
Start the stopwatch.
util::Stopwatch * m_stopwatch
The stopwatch, if we're using one.
StopwatchTimes Stop()
Stop the stopwatch, returning the CPU time.
std::vector< float > * m_in_Ts
Times of hits in a trigger.
void StreamToLog(int level)
int m_in_nhits
Number of hits in a trigger.
std::vector< int > * m_in_PMTIDs
PMT IDs of hits in a trigger.
unsigned int m_nhits_min
Below this number of hits in a trigger, don't run BONSAI. Equality is run. Set in config file...
std::stringstream m_ss
For easy formatting of Log messages.
std::vector< float > * m_in_Qs
Charges of hits in a trigger.
static const TimeDelta ns
TimeDelta of 1 ns.
void Log(const std::string &message, const int message_level)
Format messages in the same way as for tools.
std::string m_stopwatch_file
Image filename to save the histogram to, if required.
unsigned int m_nhits_max
Above this number of hits in a trigger, don't run BONSAI. Equality is run. Set in config file...
bool FileExists(std::string pathname, std::string filename)
Check if a file exists.
bool Initialise(std::string configfile, DataModel &data)