8 if(configfile!=
"") m_variables.Initialise(configfile);
15 bool use_stopwatch =
false;
16 m_variables.Get(
"use_stopwatch", use_stopwatch);
43 std::string weights_file, line;
44 m_variables.Get(
"weights_file", weights_file);
45 std::ifstream myfile(weights_file);
46 if (myfile.is_open()){
51 while (myfile >> logE >> _ >> weight){
73 float direction[3] = {0,0,1};
78 m_ss <<
"First pass: average over all events\n";
79 m_ss <<
"First pass SN neutrino direction x, y, z: " << direction[0] <<
", " << direction[1] <<
", " << direction[2];
86 m_ss <<
"Second pass: average over events w/ cos(theta) >= 0.0\n";
87 m_ss <<
"Second pass SN neutrino direction x, y, z: " << direction[0] <<
", " << direction[1] <<
", " << direction[2];
94 m_ss <<
"Third pass: average over events w/ cos(theta) >= 0.5\n";
95 m_ss <<
"Third pass SN neutrino direction x, y, z: " << direction[0] <<
", " << direction[1] <<
", " << direction[2];
136 double x = log10_energy;
139 return y0 + (y1 - y0) * (x - x0) / (x1 - x0);
144 double temp_direction[3] = {0,0,0};
145 double flat_density = 0.;
146 for(
int irecon = 0; irecon < N; irecon++) {
149 double dir_z = cos(dir.
theta);
150 double dir_y = sin(dir.
theta) * sin(dir.
phi);
151 double dir_x = sin(dir.
theta) * cos(dir.
phi);
159 double costheta = dir_x * direction[0] + dir_y * direction[1] + dir_z * direction[2];
160 if (costheta < costheta_cut){
162 flat_density += weight;
164 temp_direction[0] += dir_x * weight;
165 temp_direction[1] += dir_y * weight;
166 temp_direction[2] += dir_z * weight;
171 if (flat_density > 0) {
172 flat_density /= 2 * M_PI * (1.+costheta_cut);
176 double h = (1.-costheta_cut);
177 double expected = flat_density * (2.*M_PI*h) * (3*pow(2-h, 2)) / (4*(3-h));
178 temp_direction[0] -= direction[0] * expected;
179 temp_direction[1] -= direction[1] * expected;
180 temp_direction[2] -= direction[2] * expected;
184 double r = temp_direction[0]*temp_direction[0];
185 r += temp_direction[1]*temp_direction[1];
186 r += temp_direction[2]*temp_direction[2];
188 temp_direction[0] /= r;
189 temp_direction[1] /= r;
190 temp_direction[2] /= r;
191 direction[0] = temp_direction[0];
192 direction[1] = temp_direction[1];
193 direction[2] = temp_direction[2];
std::string Result(std::string method_name, std::string output_file="")
std::vector< double > m_log10_energy
Vector of log10(energy) for weight interpolation.
double GetEventWeight(double log10_energy)
Return the weight for the event.
DirectionEuler GetDirectionEuler(int irecon)
void Start()
Start the stopwatch.
StopwatchTimes Stop()
Stop the stopwatch, returning the CPU time.
std::stringstream m_ss
For easy formatting of Log messages.
void StreamToLog(int level)
std::vector< double > m_weight
Vector of weights for interpolation.
util::Stopwatch * m_stopwatch
The stopwatch, if we're using one.
int m_verbose
Verbosity level, as defined in tool parameter file.
void CalculateDirection(float direction[3], float costheta_cut)
std::string m_input_filter_name
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.
bool m_weight_events
Enable weighting of events.
double GetEnergy(int irecon)
SupernovaDirectionCalculator()
bool Initialise(std::string configfile, DataModel &data)