21 #include "cetlib/search_path.h" 25 #include "cetlib/pow.h" 34 cet::search_path sp(
"FW_SEARCH_PATH");
37 throw cet::exception(
"Chi2ParticleID") <<
"cannot find the root template file: \n" 54 std::bitset<8> thisBitset;
56 thisBitset.set(planeID.
Plane);
66 std::vector<anab::sParticleIDAlgScores> AlgScoresVec;
69 for (
size_t i_calo = 0; i_calo < calos.size(); i_calo++) {
74 else if (plid != calo->
PlaneID())
82 std::vector<double> vpida;
83 std::vector<float> trkdedx = calo->
dEdx();
89 for (
unsigned i = 0; i < trkdedx.size(); ++i) {
91 if (i == 0 || i == trkdedx.size() - 1)
continue;
93 double PIDAi = trkdedx[i] * pow(trkres[i], 0.42);
95 vpida.push_back(PIDAi);
98 if (trkdedx[i] > 1000)
continue;
100 if (bin >= 1 && bin <= nbins_dedx_range) {
102 if (bincpro < 1
e-6) {
122 if (binepro < 1
e-6) {
139 double errdedx = 0.04231 + 0.0001783 * trkdedx[i] * trkdedx[i];
140 errdedx *= trkdedx[i];
142 double errdedx_square = errdedx * errdedx;
143 chi2pro += cet::square(trkdedx[i] - bincpro) / (binepro * binepro + errdedx_square);
144 chi2ka += cet::square(trkdedx[i] - bincka) / (bineka * bineka + errdedx_square);
145 chi2pi += cet::square(trkdedx[i] - bincpi) / (binepi * binepi + errdedx_square);
146 chi2mu += cet::square(trkdedx[i] - bincmu) / (binemu * binemu + errdedx_square);
168 chi2proton.
fNdf = npt;
169 chi2proton.
fValue = chi2pro / npt;
177 chi2muon.
fValue = chi2mu / npt;
185 chi2kaon.
fValue = chi2ka / npt;
193 chi2pion.
fValue = chi2pi / npt;
195 AlgScoresVec.push_back(chi2proton);
196 AlgScoresVec.push_back(chi2muon);
197 AlgScoresVec.push_back(chi2kaon);
198 AlgScoresVec.push_back(chi2pion);
202 if (used_trkres > 0) {
204 pida_median.
fAlgName =
"PIDA_median";
207 pida_median.
fValue = TMath::Median(vpida.size(), &vpida[0]);
209 AlgScoresVec.push_back(pida_median);
215 pida_mean.
fValue = PIDA / used_trkres;
217 AlgScoresVec.push_back(pida_mean);
Chi2PIDAlg(fhicl::ParameterSet const &pset)
TProfile * dedx_range_mu
muon template
The data type to uniquely identify a Plane.
const geo::PlaneID & PlaneID() const
TProfile * dedx_range_pro
proton template
TProfile * dedx_range_pi
pion template
float fValue
Result of Particle ID algorithm/test.
const std::vector< float > & DeadWireResRC() const
std::bitset< 8 > fPlaneMask
Bitset for PlaneID used by algorithm, allowing for multiple planes and up to 8 total planes...
const std::vector< float > & ResidualRange() const
std::string fAlgName
< determined particle ID
auto vector(Vector const &v)
Returns a manipulator which will print the specified array.
int fNdf
Number of degrees of freedom used by algorithm, if applicable. Set to -9999 by default.
kTrackDir fTrackDir
Track direction enum: defined in ParticleID_VariableTypeEnums.h. Set to kNoDirection by default...
kVariableType fVariableType
Variable type enum: defined in ParticleID_VariableTypeEnums.h. Set to kNotSet by default.
T get(std::string const &key) const
std::bitset< 8 > GetBitset(geo::PlaneID planeID)
std::string fTemplateFile
PlaneID_t Plane
Index of the plane within its TPC.
const std::vector< float > & dEdx() const
anab::ParticleID DoParticleID(const std::vector< art::Ptr< anab::Calorimetry >> &calo)
TProfile * dedx_range_ka
kaon template
cet::coded_exception< error, detail::translate > exception
int fAssumedPdg
PDG of particle hypothesis assumed by algorithm, if applicable. Set to 0 by default.