21 #include "cetlib/search_path.h" 25 #include "cetlib/pow.h" 35 cet::search_path sp(
"FW_SEARCH_PATH");
38 throw cet::exception(
"Chi2ParticleID") <<
"cannot find the root template file: \n" 55 std::bitset<8> thisBitset;
57 thisBitset.set(planeID.
Plane);
67 std::vector<anab::sParticleIDAlgScores> AlgScoresVec;
70 for (
size_t i_calo = 0; i_calo < calos.size(); i_calo++) {
75 else if (plid != calo->
PlaneID())
83 std::vector<double> vpida;
84 std::vector<float> trkdedx = calo->
dEdx();
90 for (
unsigned i = 0; i < trkdedx.size(); ++i) {
92 if (i == 0 || i == trkdedx.size() - 1)
continue;
93 if (trkdedx[i] > 1000)
continue;
95 double PIDAi = trkdedx[i] * pow(trkres[i], 0.42);
98 vpida.push_back(PIDAi);
102 if (bin >= 1 && bin <= nbins_dedx_range) {
104 if (bincpro < 1
e-6) {
124 if (binepro < 1
e-6) {
141 double errdedx = 0.04231 + 0.0001783 * trkdedx[i] * trkdedx[i];
142 errdedx *= trkdedx[i];
144 double errdedx_square = errdedx * errdedx;
145 chi2pro += cet::square(trkdedx[i] - bincpro) / (binepro * binepro + errdedx_square);
146 chi2ka += cet::square(trkdedx[i] - bincka) / (bineka * bineka + errdedx_square);
147 chi2pi += cet::square(trkdedx[i] - bincpi) / (binepi * binepi + errdedx_square);
148 chi2mu += cet::square(trkdedx[i] - bincmu) / (binemu * binemu + errdedx_square);
170 chi2proton.
fNdf = npt;
171 chi2proton.
fValue = chi2pro / npt;
179 chi2muon.
fValue = chi2mu / npt;
187 chi2kaon.
fValue = chi2ka / npt;
195 chi2pion.
fValue = chi2pi / npt;
197 AlgScoresVec.push_back(chi2proton);
198 AlgScoresVec.push_back(chi2muon);
199 AlgScoresVec.push_back(chi2kaon);
200 AlgScoresVec.push_back(chi2pion);
204 if (used_trkres > 0) {
206 pida_median.
fAlgName =
"PIDA_median";
209 pida_median.
fValue = TMath::Median(vpida.size(), &vpida[0]);
211 pida_median.
fNdf = used_trkres;
212 AlgScoresVec.push_back(pida_median);
218 pida_mean.
fValue = PIDA / used_trkres;
220 pida_mean.
fNdf = used_trkres;
221 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
std::optional< double > fMaximumPIDA
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)
std::optional< T > get_if_present(std::string const &key) const
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.