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/ComPIDVarE.hh"
20
#include "Utils/Exception.hh"
26
const std::string ComPIDVarE::VARIABLE = "CommissioningEMRrangevsDiffTOF1TOF2";
28
ComPIDVarE::ComPIDVarE(std::string hypothesis, std::string unique_identifier)
29
: PIDBase2D(VARIABLE, hypothesis, unique_identifier, XminBinComE,
30
XmaxBinComE, XnumBins, YminBinComE, YmaxBinComE, YnumBins) {
31
_nonZeroHistEntries = true;
34
ComPIDVarE::ComPIDVarE(TFile* file, std::string hypothesis, int XminComE,
35
int XmaxComE, int YminComE, int YmaxComE)
36
: PIDBase2D(file, VARIABLE, hypothesis, XminComE, XmaxComE, YminComE,
37
YmaxComE, XminBinComE, XmaxBinComE, YminBinComE, YmaxBinComE) {
40
ComPIDVarE::~ComPIDVarE() {}
42
std::pair<double, double> ComPIDVarE::Calc_Var(MAUS::DataStructure::Global::Track* track) {
43
EMR_range = track->get_emr_range_primary();
44
if (EMR_range == 0.0) {
45
Squeak::mout(Squeak::debug) << "Global track records no range " <<
46
" of particle in EMR, Recon::Global::ComPIDVarE::Calc_Var()" << std::endl;
47
return std::make_pair(0, -1);
48
} else if ( YminBinComE > EMR_range || EMR_range > YmaxBinComE ) {
49
Squeak::mout(Squeak::debug) << "Range of particle in EMR " <<
50
"outside of PDF range, Recon::Global::ComPIDVarE::Calc_Var()" <<
52
return std::make_pair(0, -1);
58
std::vector<const MAUS::DataStructure::Global::TrackPoint*>
59
track_points = track->GetTrackPoints();
60
MAUS::DataStructure::Global::DetectorPoint TOF2_DP =
61
MAUS::DataStructure::Global::kTOF2;
62
MAUS::DataStructure::Global::DetectorPoint TOF1_DP =
63
MAUS::DataStructure::Global::kTOF1;
64
std::vector<const MAUS::DataStructure::Global::TrackPoint*>
66
for (eachTP = track_points.begin(); eachTP != track_points.end();
68
if (!(*eachTP)) continue;
69
if ((*eachTP)->get_mapper_name() == "MapCppGlobalTrackMatching-Through") {
70
if ((*eachTP)->get_detector() == TOF2_DP) {
71
TOF2_t = (*eachTP)->get_position().T();
73
} else if ((*eachTP)->get_detector() == TOF1_DP) {
74
TOF1_t = (*eachTP)->get_position().T();
81
if (checkCount2 > 1 || checkCount1 > 1) {
82
Squeak::mout(Squeak::debug) << "Multiple measurements for TOF2/TOF1" <<
83
" times, Recon::Global::ComPIDVarE::Calc_Var()" << std::endl;
84
return std::make_pair(-1, EMR_range);
85
} else if (checkCount2 == 0 ||
86
checkCount1 == 0 || (TOF2_t -TOF1_t) <= 0) {
87
Squeak::mout(Squeak::debug) << "Missing/invalid measurements for " <<
88
"TOF0/TOF1 times, Recon::Global::ComPIDVarE::Calc_Var()" << std::endl;
89
return std::make_pair(-1, EMR_range);
90
} else if ( XminBinComE > (TOF2_t - TOF1_t) ||
91
(TOF2_t - TOF1_t) > XmaxBinComE ) {
92
Squeak::mout(Squeak::debug) << "Difference between TOF1 & TOF2 times" <<
93
" out of PDF range, Recon::Global::ComPIDVarE::Calc_Var()" << std::endl;
94
return std::make_pair(-1, EMR_range);
96
return std::make_pair((TOF2_t - TOF1_t), EMR_range);