8 : fEndZLow(endz_low), fEndZHigh(endz_high), fThreshold(threshold) {}
12 std::vector<int> & true_daughter_pdg,
13 std::vector<double> & true_daughter_startP
18 if (endZ < fEndZLow) {
22 else if (endZ > fEndZHigh) {
25 else if (process ==
"pi+Inelastic") {
27 bool has_pion_above_threshold =
false;
28 for (
size_t i = 0; i < true_daughter_startP.size(); ++i) {
29 if (
abs(true_daughter_pdg[i]) == 211 &&
30 true_daughter_startP[i] > fThreshold) {
31 has_pion_above_threshold =
true;
36 if (has_pion_above_threshold) {
50 else if (pdg == -13) {
63 bool no_pion_daughter,
64 bool beam_cuts,
bool has_shower) {
77 if (!no_pion_daughter) {
90 std::vector<int> results;
91 for (
const int PDG : bt_PDGs) {
98 else if (
abs(
PDG) == 2212) {
101 else if (
abs(
PDG) == 22) {
102 results.push_back(4);
104 else if (
abs(
PDG) > 2212) {
105 results.push_back(5);
107 else if (
abs(
PDG) == 11) {
108 results.push_back(6);
111 results.push_back(7);
119 const std::vector<int> bt_origins,
const std::vector<int> bt_IDs,
120 const std::vector<int> bt_PDGs,
const std::vector<int> bt_ParIDs,
121 const std::vector<int> bt_ParPDGs,
122 const std::vector<int> true_daughters,
123 const std::vector<int> true_grand_daughters) {
124 std::vector<int> results;
125 for (
size_t i = 0; i < bt_origins.size(); ++i) {
126 if (bt_IDs[i] == beam_ID) {
127 results.push_back(1);
129 else if (bt_origins[i] == 2) {
130 results.push_back(2);
132 else if (
abs(bt_PDGs[i]) == 11 && (
abs(bt_ParPDGs[i]) == 13)) {
133 results.push_back(10);
135 else if (std::find(true_daughters.begin(), true_daughters.end(), bt_IDs[i]) !=
136 true_daughters.end()) {
137 if (
abs(bt_PDGs[i]) == 211) {
138 results.push_back(3);
140 else if (
abs(bt_PDGs[i]) == 13) {
141 results.push_back(4);
143 else if (bt_PDGs[i] == 2212) {
144 results.push_back(5);
146 else if (bt_PDGs[i] == 22) {
147 results.push_back(6);
149 else if (bt_PDGs[i] > 2212) {
150 results.push_back(7);
154 results.push_back(12);
157 else if (std::find(true_grand_daughters.begin(),
158 true_grand_daughters.end(), bt_IDs[i]) !=
159 true_grand_daughters.end()) {
160 if ((bt_PDGs[i] == 22 ||
abs(bt_PDGs[i]) == 11) && bt_ParPDGs[i] == 111) {
161 results.push_back(11);
164 results.push_back(8);
167 else if (std::find(true_grand_daughters.begin(),
168 true_grand_daughters.end(), bt_ParIDs[i]) !=
169 true_grand_daughters.end()) {
170 results.push_back(9);
174 results.push_back(12);
181 const double & Py,
const double & Pz,
182 const std::vector<int> & dPDGs,
183 const std::vector<double> & dPx,
184 const std::vector<double> & dPy,
185 const std::vector<double> & dPz) {
186 double costheta = -999.;
187 double max_p = -999.;
188 double P = sqrt(Px*Px + Py*Py + Pz*Pz);
189 for (
size_t i = 0; i < dPDGs.size(); ++i) {
190 if (dPDGs[i] != 2212)
continue;
192 double dP = sqrt(dPx[i]*dPx[i] + dPy[i]*dPy[i] + dPz[i]*dPz[i]);
194 costheta = (dPx[i]*Px + dPy[i]*Py + dPz[i]*Pz)/(dP*P);
207 const double & Py,
const double & Pz,
208 const std::vector<int> & dPDGs,
209 const std::vector<double> & dPx,
210 const std::vector<double> & dPy,
211 const std::vector<double> & dPz) {
212 double costheta = -999.;
213 double max_p = -999.;
214 double P = sqrt(Px*Px + Py*Py + Pz*Pz);
215 for (
size_t i = 0; i < dPDGs.size(); ++i) {
216 if (dPDGs[i] != fPDG)
continue;
218 double dP = sqrt(dPx[i]*dPx[i] + dPy[i]*dPy[i] + dPz[i]*dPz[i]);
220 costheta = (dPx[i]*Px + dPy[i]*Py + dPz[i]*Pz)/(dP*P);
239 else if (
process ==
"primaryBackground") {
242 else if (
process.find(
"Inelastic") != std::string::npos) {
264 std::vector<double> trunc_mean;
266 double truncate_high = 1 - fLimit;
271 for(
auto &&vec : vecs_dEdX){
273 std::vector<double> help_vec;
278 trunc_mean.push_back(-9999.);
283 std::vector<double> temp_vec;
284 for (
double d : vec) {
288 temp_vec.push_back(
d);
290 for (
double d : temp_vec) {
295 if (temp_vec.empty()) {
296 trunc_mean.push_back(-9999.);
300 sort(temp_vec.begin(), temp_vec.end());
304 i_low = rint ( temp_vec.size()*fLimit);
305 i_high = rint( temp_vec.size()*truncate_high);
309 for(
int i = i_low; i < i_high; i++){
310 if (temp_vec[i] < 0) {
311 std::cout <<
"added " << temp_vec[i] <<
" " << i <<
std::endl;
313 help_vec.push_back(temp_vec[i]);
318 trunc_mean.push_back(accumulate(help_vec.begin(), help_vec.end(), 0.0) / help_vec.size());
319 if (trunc_mean.back() < 0 && trunc_mean.back() != -9999. && trunc_mean.back() != -999.) {
320 std::cout << accumulate(help_vec.begin(), help_vec.end(), 0.0) <<
" " << help_vec.size() <<
std::endl;
321 std::cout << temp_vec.size() <<
" " << i_low <<
" " << i_high <<
std::endl;
322 for (
size_t i = 0; i < help_vec.size(); ++i) {
323 std::cout <<
"\t" << help_vec[i] <<
std::endl;
341 : fTrackScoreCut(cut) {}
342 std::vector<double>
operator ()(
const std::vector<double> &track_score,
343 const std::vector<double> &shower_x,
344 const std::vector<double> &shower_y,
345 const std::vector<double> &shower_z,
346 double &
x,
double &
y,
double &
z) {
347 std::vector<double> results;
348 for(
size_t i = 0; i < track_score.size(); ++i){
349 if ((track_score[i] < fTrackScoreCut) &&
350 (track_score[i] > 0.)) {
354 results.push_back(dist);
357 results.push_back(-999.);
371 : fTrackScoreCut(cut) {}
373 const std::vector<double> &shower_x,
374 const std::vector<double> &shower_y,
375 const std::vector<double> &shower_z,
376 const std::vector<double> &
energy,
377 double &
x,
double &
y,
double &
z) {
378 for(
size_t i = 0; i < track_score.size(); ++i){
382 if ((track_score[i] < fTrackScoreCut) &&
383 (track_score[i] > 0.) &&
384 (dist > 5. && dist < 1000.) &&
385 (energy[i] > 80. && energy[i] < 1000.)) {
399 : fCheckCalo(check_calo) {}
400 bool operator()(
int reco_beam_type, std::vector<double> energies) {
402 return (energies.size() > 0 && reco_beam_type == 13);
405 return (reco_beam_type == 13);
417 return (reco_beam_endZ < fEndZCut);
428 double dEdX_low,
double dEdX_med,
double dEdX_high)
429 : fTrackScoreCut(track_score_cut),
433 fdEdXHigh(dEdX_high) {}
435 const std::vector<double> &track_score,
436 const std::vector<int> &trackID,
437 const std::vector<double> &
dEdX,
438 const std::vector<double> &chi2,
439 const std::vector<int> &ndof) {
440 for(
size_t i = 0; i < track_score.size(); ++i ) {
441 if ((trackID[i] != -999) && (track_score[i] > fTrackScoreCut)) {
442 if (dEdX[i] < fdEdXMed && dEdX[i] > fdEdXLow) {
446 else if (dEdX[i] < fdEdXHigh) {
447 if (ndof[i] > 0 && chi2[i]/ndof[i] > fChi2Cut) {
459 auto pid_search = std::find(pidCandidates.begin(), pidCandidates.end(), 211);
460 return (pid_search != pidCandidates.end());
468 : fDoTracks(do_tracks) {}
472 return (data_BI_nMomenta == 1 && data_BI_nTracks == 1);
475 return (data_BI_nMomenta == 1);
482 double fXLow, fXHigh,
488 double y_low,
double y_high,
489 double z_low,
double z_high,
491 : fXLow(x_low), fXHigh(x_high),
492 fYLow(y_low), fYHigh(y_high),
493 fZLow(z_low), fZHigh(z_high),
496 double startY,
double startZ,
497 double dirX,
double dirY,
498 double dirZ,
double BI_X,
499 double BI_Y,
double BI_dirX,
500 double BI_dirY,
double BI_dirZ) {
502 double deltaX = startX - BI_X;
503 double deltaY = startY - BI_Y;
504 double cos = BI_dirX*dirX + BI_dirY*dirY +
506 if( (deltaX < fXLow) || (deltaX > fXHigh) )
509 if ( (deltaY < fYLow) || (deltaY > fYHigh) )
512 if ( (startZ < fZLow) || (startZ > fZHigh) )
533 double mean_x,
double mean_y,
double mean_z,
534 double sigma_x,
double sigma_y,
double sigma_z,
535 double mean_theta_x,
double mean_theta_y,
double mean_theta_z)
536 : fDoAngle(do_angle),
537 fXYZCut(xyz_cut), fCosCut(cos_cut),
538 fMeanX(mean_x), fMeanY(mean_y), fMeanZ(mean_z),
539 fSigmaX(sigma_x), fSigmaY(sigma_y), fSigmaZ(sigma_z),
540 fMeanThetaX(mean_theta_x), fMeanThetaY(mean_theta_y),
541 fMeanThetaZ(mean_theta_z) {}
543 bool operator()(
double calo_beam_startX,
double calo_beam_startY,
544 double calo_beam_startZ,
double calo_beam_endX,
545 double calo_beam_endY,
double calo_beam_endZ) {
547 double diffX = calo_beam_endX - calo_beam_startX;
548 double diffY = calo_beam_endY - calo_beam_startY;
549 double diffZ = calo_beam_endZ - calo_beam_startZ;
550 double r = sqrt(diffX*diffX + diffY*diffY + diffZ*diffZ);
552 double cosTrk_thetaX = diffX /
r;
553 double cosTrk_thetaY = diffY /
r;
554 double cosTrk_thetaZ = diffZ /
r;
556 double cosTheta = cos(fMeanThetaX*TMath::Pi()/180.)*cosTrk_thetaX +
557 cos(fMeanThetaY*TMath::Pi()/180.)*cosTrk_thetaY +
558 cos(fMeanThetaZ*TMath::Pi()/180.)*cosTrk_thetaZ;
560 if (
abs((calo_beam_startX - fMeanX)/fSigmaX) > fXYZCut)
563 if (
abs((calo_beam_startY - fMeanY)/fSigmaY) > fXYZCut)
566 if (
abs((calo_beam_startZ - fMeanZ)/fSigmaZ) > fXYZCut)
569 if (fDoAngle && (cosTheta < fCosCut))
has_shower_dist_energy(double cut)
beam_cut_BI(double x_low, double x_high, double y_low, double y_high, double z_low, double z_high, double cos_low)
bool operator()(int reco_beam_type, std::vector< double > energies)
int operator()(int pdg, double endZ, std::string process, int nPi0, std::vector< int > &true_daughter_pdg, std::vector< double > &true_daughter_startP)
truncatedMean_pos(double limit)
std::pair< float, std::string > P
bool operator()(int data_BI_nMomenta, int data_BI_nTracks)
double dEdX(double KE, const simb::MCParticle *part)
leading_costheta(int pdg)
std::vector< double > operator()(std::vector< std::vector< double >> &vecs_dEdX)
data_BI_quality(bool do_tracks)
auto daughter_PDG_types(const std::vector< int > bt_PDGs)
auto categorize_daughters
isBeamType(bool check_calo)
constexpr double dist(const TReal *x, const TReal *y, const unsigned int dimension)
bool operator()(double calo_beam_startX, double calo_beam_startY, double calo_beam_startZ, double calo_beam_endX, double calo_beam_endY, double calo_beam_endZ)
secondary_noPion(double track_score_cut, double chi2_cut, double dEdX_low, double dEdX_med, double dEdX_high)
beam_cut_TPC(bool do_angle, double xyz_cut, double cos_cut, double mean_x, double mean_y, double mean_z, double sigma_x, double sigma_y, double sigma_z, double mean_theta_x, double mean_theta_y, double mean_theta_z)
bool operator()(const std::vector< double > &track_score, const std::vector< int > &trackID, const std::vector< double > &dEdX, const std::vector< double > &chi2, const std::vector< int > &ndof)
bool operator()(const std::vector< double > &track_score, const std::vector< double > &shower_x, const std::vector< double > &shower_y, const std::vector< double > &shower_z, const std::vector< double > &energy, double &x, double &y, double &z)
bool operator()(double startX, double startY, double startZ, double dirX, double dirY, double dirZ, double BI_X, double BI_Y, double BI_dirX, double BI_dirY, double BI_dirZ)
bool operator()(double reco_beam_endZ)
double operator()(const double &Px, const double &Py, const double &Pz, const std::vector< int > &dPDGs, const std::vector< double > &dPx, const std::vector< double > &dPy, const std::vector< double > &dPz)
constexpr Point origin()
Returns a origin position with a point of the specified type.
QTextStream & endl(QTextStream &s)
new_interaction_topology(double endz_low, double endz_high, double threshold)