35 throw cet::exception(
"Chi2ParticleID") <<
"cannot find the root template file: \n" 37 <<
"\n bail ungracefully.\n";
52 std::bitset<8> thisBitset;
54 thisBitset.set(planeID.
Plane);
63 std::vector<anab::sParticleIDAlgScores> AlgScoresVec;
66 for (
size_t i_calo = 0; i_calo < calos.size(); i_calo++){
71 else if(plid != calo->
PlaneID())
80 std::vector<double> vpida;
81 std::vector<float> trkdedx = calo->
dEdx();
86 for (
unsigned i = 0; i<trkdedx.size(); ++i){
88 if (i==0 || i==trkdedx.size()-1)
continue;
89 avgdedx += trkdedx[i];
91 PIDA += trkdedx[i]*
pow(trkres[i],0.42);
92 vpida.push_back(trkdedx[i]*
pow(trkres[i],0.42));
95 if (trkdedx[i]>1000)
continue;
97 if (bin>=1&&bin<=dedx_range_pro->GetNbinsX()){
131 double errdedx = 0.04231+0.0001783*trkdedx[i]*trkdedx[i];
132 errdedx *= trkdedx[i];
133 chi2pro +=
pow((trkdedx[i]-bincpro)/std::sqrt(
pow(binepro,2)+
pow(errdedx,2)),2);
134 chi2ka +=
pow((trkdedx[i]-bincka)/std::sqrt(
pow(bineka,2)+
pow(errdedx,2)),2);
135 chi2pi +=
pow((trkdedx[i]-bincpi)/std::sqrt(
pow(binepi,2)+
pow(errdedx,2)),2);
136 chi2mu +=
pow((trkdedx[i]-bincmu)/std::sqrt(
pow(binemu,2)+
pow(errdedx,2)),2);
157 chi2proton.
fNdf = npt;
158 chi2proton.
fValue = chi2pro/npt;
166 chi2muon.
fValue = chi2mu/npt;
174 chi2kaon.
fValue = chi2ka/npt;
182 chi2pion.
fValue = chi2pi/npt;
184 AlgScoresVec.push_back(chi2proton);
185 AlgScoresVec.push_back(chi2muon);
186 AlgScoresVec.push_back(chi2kaon);
187 AlgScoresVec.push_back(chi2pion);
193 pida_median.
fAlgName =
"PIDA_median";
196 pida_median.
fValue = TMath::Median(vpida.size(), &vpida[0]);
198 AlgScoresVec.push_back(pida_median);
204 pida_mean.
fValue = PIDA/used_trkres;
206 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
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)
QTextStream & bin(QTextStream &s)
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.