1
/* This file is part of MAUS: http:// micewww.pp.rl.ac.uk:8080/projects/maus
3
* MAUS is free software: you can redistribute it and/or modify
4
* it under the terms of the GNU General Public License as published by
5
* the Free Software Foundation, either version 3 of the License, or
6
* (at your option) any later version.
8
* MAUS is distributed in the hope that it will be useful,
9
* but WITHOUT ANY WARRANTY; without even the implied warranty of
10
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
* GNU General Public License for more details.
13
* You should have received a copy of the GNU General Public License
14
* along with MAUS. If not, see <http:// www.gnu.org/licenses/>.
19
#include "Recon/Global/PIDVarA.hh"
20
#include "Utils/Exception.hh"
26
const std::string PIDVarA::VARIABLE = "diffTOF1TOF0";
28
PIDVarA::PIDVarA(std::string hypothesis, std::string unique_identifier)
29
: PIDBase(minBin, maxBin, numBins, VARIABLE, hypothesis,
31
_nonZeroHistEntries = true;
34
PIDVarA::PIDVarA(TFile* file, std::string hypothesis)
35
: PIDBase(file, VARIABLE, hypothesis) {
38
PIDVarA::~PIDVarA() {}
40
double PIDVarA::Calc_Var(MAUS::DataStructure::Global::Track* track) {
45
std::vector<const MAUS::DataStructure::Global::TrackPoint*>
46
track_points = track->GetTrackPoints();
47
// TODO(Pidcott) check that right detector enums are used
48
MAUS::DataStructure::Global::DetectorPoint TOF0_DP =
49
MAUS::DataStructure::Global::kTOF0_1;
50
MAUS::DataStructure::Global::DetectorPoint TOF1_DP =
51
MAUS::DataStructure::Global::kTOF1_1;
52
std::vector<const MAUS::DataStructure::Global::TrackPoint*>
54
for (eachTP = track_points.begin(); eachTP != track_points.end();
56
if (!(*eachTP)) continue;
57
if ((*eachTP)->get_detector() == TOF0_DP) {
58
TOF0_t = (*eachTP)->get_position().T();
60
} else if ((*eachTP)->get_detector() == TOF1_DP) {
61
TOF1_t = (*eachTP)->get_position().T();
65
if (checkCount0 > 1 || checkCount1 > 1) {
66
Squeak::mout(Squeak::error) << "Multiple measurements for TOF0/TOF1" <<
67
" times, Recon::Global::PIDVarA::Calc_Var()" << std::endl;
69
} else if (checkCount0 == 0 ||
70
checkCount1 == 0 || (TOF1_t -TOF0_t) <= 0) {
71
Squeak::mout(Squeak::error) << "Missing/invalid measurements for " <<
72
"TOF0/TOF1 times, Recon::Global::PIDVarA::Calc_Var()" << std::endl;
74
} else if ( minBin > (TOF1_t - TOF0_t) || (TOF1_t - TOF0_t) > maxBin ) {
75
Squeak::mout(Squeak::error) << "Difference between TOF0 and TOF1 times" <<
76
" outside of range, Recon::Global::PIDVarA::Calc_Var()" << std::endl;
79
return (TOF1_t - TOF0_t);