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/>.
20
#include "Recon/Global/PIDVarC.hh"
21
#include "Utils/Exception.hh"
27
const std::string PIDVarC::VARIABLE = "KLChargeProdvsDSTrackerMom";
29
PIDVarC::PIDVarC(std::string hypothesis, std::string unique_identifier)
30
: PIDBase2D(VARIABLE, hypothesis, unique_identifier,
31
XminBin, XmaxBin, XnumBins, YminBin, YmaxBin, YnumBins) {
32
_nonZeroHistEntries = true;
35
PIDVarC::PIDVarC(TFile* file, std::string hypothesis)
36
: PIDBase2D(file, VARIABLE, hypothesis) {
39
PIDVarC::~PIDVarC() {}
41
std::pair<double, double> PIDVarC::Calc_Var(MAUS::DataStructure::Global::Track* track) {
42
int total_ADC_charge_product = 0;
43
MAUS::DataStructure::Global::DetectorPoint KL_DP =
44
MAUS::DataStructure::Global::kCalorimeter;
45
// Get trackpoint array from track
46
global_track_points = track->GetTrackPoints();
47
std::vector<const MAUS::DataStructure::Global::TrackPoint*>
49
for (eachTP = global_track_points.begin();
50
eachTP != global_track_points.end(); ++eachTP) {
51
if (!(*eachTP)) continue;
52
if ((*eachTP)->get_mapper_name() == "MapCppGlobalTrackMatching") {
53
if ((*eachTP)->get_detector() == KL_DP) {
54
kl_track_points.push_back(*eachTP);
55
} else if ((*eachTP)->get_detector() >=
56
MAUS::DataStructure::Global::kTracker1_1 &&
57
(*eachTP)->get_detector() <=
58
MAUS::DataStructure::Global::kTracker1_5) {
59
tracker1_track_points.push_back(*eachTP);
65
if (kl_track_points.size() < 1) {
66
Squeak::mout(Squeak::debug) << "Global track contained no KL" <<
67
" trackpoints, Recon::Global::PIDVarC::Calc_Var()" << std::endl;
68
kl_track_points.clear();
69
return std::make_pair(-1, 0);
70
} else if (tracker1_track_points.size() < 1) {
71
Squeak::mout(Squeak::debug) << "Global track contained no downstream" <<
72
" tracker trackpoints, Recon::Global::PIDVarC::Calc_Var()" << std::endl;
73
tracker1_track_points.clear();
74
kl_track_points.clear();
75
return std::make_pair(-1, 0);
77
for (size_t i = 0; i < kl_track_points.size(); i++) {
78
total_ADC_charge_product += kl_track_points[i]->get_ADC_charge_product();
80
if ( YminBin > (total_ADC_charge_product) || (total_ADC_charge_product) > YmaxBin ) {
81
Squeak::mout(Squeak::debug) << "KL ADC charge product " <<
82
"outside of allowed range, Recon::Global::PIDVarC::Calc_Var()" <<
84
kl_track_points.clear();
85
tracker1_track_points.clear();
86
return std::make_pair(-1, 0);
88
double tracker1_trackpoint_mom = 0;
89
int tracker1_tp_count = 0;
90
double tracker1_momentum = 0;
91
const MAUS::DataStructure::Global::TrackPoint* tracker1_trackpoint;
92
for (size_t i = 0; i < tracker1_track_points.size(); i++) {
93
tracker1_trackpoint = tracker1_track_points[i];
94
if (tracker1_trackpoint) {
95
TLorentzVector trackpoint_4mom = tracker1_trackpoint->get_momentum();
96
tracker1_trackpoint_mom +=
97
sqrt(trackpoint_4mom.Px()*trackpoint_4mom.Px() +
98
trackpoint_4mom.Py()*trackpoint_4mom.Py() +
99
trackpoint_4mom.Pz()*trackpoint_4mom.Pz());
105
kl_track_points.clear();
106
tracker1_track_points.clear();
107
tracker1_momentum = tracker1_trackpoint_mom/tracker1_tp_count;
108
if ( XminBin > tracker1_momentum || tracker1_momentum > XmaxBin ) {
109
Squeak::mout(Squeak::debug) << "Momentum for tracker 1 is outside " <<
110
"of range, Recon::Global::PIDVarC::Calc_Var()" << std::endl;
111
return std::make_pair(0, -1);
113
return std::make_pair(tracker1_momentum, (total_ADC_charge_product));