10 #include <sys/types.h> 52 cet::search_path sp(
"FW_SEARCH_PATH");
55 throw cet::exception(
"Chi2ParticleID") <<
"cannot find the root template file: \n" 57 <<
"\n bail ungracefully.\n";
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 avgdedx += trkdedx[i];
95 PIDA += trkdedx[i]*pow(trkres[i],0.42);
96 vpida.push_back(trkdedx[i]*pow(trkres[i],0.42));
99 if (trkdedx[i]>1000)
continue;
101 if (bin>=1&&bin<=dedx_range_pro->GetNbinsX()){
135 double errdedx = 0.04231+0.0001783*trkdedx[i]*trkdedx[i];
136 errdedx *= trkdedx[i];
137 chi2pro += pow((trkdedx[i]-bincpro)/std::sqrt(pow(binepro,2)+pow(errdedx,2)),2);
138 chi2ka += pow((trkdedx[i]-bincka)/std::sqrt(pow(bineka,2)+pow(errdedx,2)),2);
139 chi2pi += pow((trkdedx[i]-bincpi)/std::sqrt(pow(binepi,2)+pow(errdedx,2)),2);
140 chi2mu += pow((trkdedx[i]-bincmu)/std::sqrt(pow(binemu,2)+pow(errdedx,2)),2);
153 double chi2[4] = {chi2pro/npt,chi2ka/npt,chi2pi/npt,chi2mu/npt};
154 double pdg[4] = {2212,321,211,13};
155 double chi2min = 1e20;
157 double chi2min2 = 1e20;
160 for (
int ichi2 = 0; ichi2<4; ++ichi2){
161 if (chi2[ichi2]<chi2min){
164 chi2min = chi2[ichi2];
166 else if (chi2[ichi2]<chi2min2){
168 chi2min2 = chi2[ichi2];
172 pidOut.
fPdg = pdg[imin];
180 pidOut.
fPIDA = TMath::Median(vpida.size(), &vpida[0]);
183 pidOut.
fPIDA = PIDA/used_trkres;
187 double missingeavg = 0;
188 for (
unsigned i = 0; i<deadwireresrc.size(); ++i){
193 if (pidOut.
fPdg==2212){
196 else if (pidOut.
fPdg==321){
199 else if (pidOut.
fPdg==211){
202 else if (pidOut.
fPdg==13){
207 if (trkdedx.size()) missingeavg = avgdedx/trkdedx.size()*trkpitchc*deadwireresrc.size();
Chi2PIDAlg(fhicl::ParameterSet const &pset)
TProfile * dedx_range_mu
muon template
double fMissingEavg
missing energy from dead wires using average dEdx
double fMinChi2
Minimum reduced chi2.
const geo::PlaneID & PlaneID() const
TProfile * dedx_range_pro
proton template
TProfile * dedx_range_pi
pion template
double fChi2Muon
reduced chi2 using muon template
int fNdf
ndf for chi2 test
const std::vector< float > & DeadWireResRC() const
const std::vector< float > & ResidualRange() const
void reconfigure(fhicl::ParameterSet const &pset)
double fDeltaChi2
difference between two lowest reduced chi2's
T get(std::string const &key) const
std::string fTemplateFile
const std::vector< float > & dEdx() const
double fChi2Kaon
reduced chi2 using kaon template
int fPdg
determined particle ID
Utility object to perform functions of association.
double fChi2Proton
reduced chi2 using proton template
double fPIDA
PID developed by Bruce Baller.
TProfile * dedx_range_ka
kaon template
double fChi2Pion
reduced chi2 using pion template
cet::coded_exception< error, detail::translate > exception
void DoParticleID(art::Ptr< anab::Calorimetry > calo, anab::ParticleID &pidOut)
double fMissingE
missing energy from dead wires for contained particle