~christopher-hunt08/maus/maus_integrated_kalman

« back to all changes in this revision

Viewing changes to src/common_cpp/Recon/Global/PIDVarD.cc

merging in changes in merge branch

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* This file is part of MAUS: http://  micewww.pp.rl.ac.uk:8080/projects/maus
 
2
 * 
 
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.
 
7
 * 
 
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.
 
12
 * 
 
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/>.
 
15
 */
 
16
 
 
17
#include <string>
 
18
#include <vector>
 
19
#include "Recon/Global/PIDVarD.hh"
 
20
#include "Utils/Exception.hh"
 
21
 
 
22
namespace MAUS {
 
23
namespace recon {
 
24
namespace global {
 
25
 
 
26
  const std::string PIDVarD::VARIABLE = "KLADCChargeProduct";
 
27
 
 
28
  PIDVarD::PIDVarD(std::string hypothesis, std::string unique_identifier)
 
29
    : PIDBase1D(VARIABLE, hypothesis, unique_identifier, minBinD, maxBinD,
 
30
                numBins) {
 
31
    _nonZeroHistEntries = true;
 
32
  }
 
33
 
 
34
  PIDVarD::PIDVarD(TFile* file, std::string hypothesis, int minD, int maxD)
 
35
    : PIDBase1D(file, VARIABLE, hypothesis, minD, maxD, minBinD, maxBinD) {
 
36
  }
 
37
 
 
38
  PIDVarD::~PIDVarD() {}
 
39
 
 
40
  std::pair<double, double> PIDVarD::Calc_Var(MAUS::DataStructure::Global::Track* track) {
 
41
    int total_ADC_charge_product = 0;
 
42
    MAUS::DataStructure::Global::DetectorPoint KL_DP =
 
43
      MAUS::DataStructure::Global::kCalorimeter;
 
44
    // Get trackpoint array from track
 
45
    global_track_points = track->GetTrackPoints();
 
46
    std::vector<const MAUS::DataStructure::Global::TrackPoint*>
 
47
      ::iterator eachTP;
 
48
    for (eachTP = global_track_points.begin();
 
49
         eachTP != global_track_points.end(); ++eachTP) {
 
50
      if (!(*eachTP)) continue;
 
51
      if ((*eachTP)->get_mapper_name() == "MapCppGlobalTrackMatching-Through") {
 
52
        if ((*eachTP)->get_detector() == KL_DP) {
 
53
          kl_track_points.push_back(*eachTP);
 
54
        } else {
 
55
          continue;
 
56
        }
 
57
      }
 
58
    }
 
59
    if (kl_track_points.size() < 1) {
 
60
      Squeak::mout(Squeak::debug) << "Global track contained no KL" <<
 
61
        " trackpoints, Recon::Global::PIDVarD::Calc_Var()" << std::endl;
 
62
      kl_track_points.clear();
 
63
      return std::make_pair(-1, 0);
 
64
    } else {
 
65
      for (size_t i = 0; i < kl_track_points.size(); i++) {
 
66
        total_ADC_charge_product += kl_track_points[i]->get_ADC_charge_product();
 
67
      }
 
68
      kl_track_points.clear();
 
69
      if ( minBinD > (total_ADC_charge_product) || (total_ADC_charge_product) > maxBinD ) {
 
70
        Squeak::mout(Squeak::debug) << "KL ADC charge product " <<
 
71
          "outside of PDF range, Recon::Global::PIDVarD::Calc_Var()" <<
 
72
          std::endl;
 
73
        return std::make_pair(total_ADC_charge_product, 0);
 
74
      } else {
 
75
        return std::make_pair(total_ADC_charge_product, 0);
 
76
      }
 
77
    }
 
78
  }
 
79
}
 
80
}
 
81
}
 
82
 
 
83