All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
analyze_PandoraReco.cxx
Go to the documentation of this file.
1 #include <numeric>
2 
6 
7 #include "TPrincipal.h"
8 
16 
17 
18 namespace single_photon
19 {
20 
21 
22 
23  //Analyze Tracks
25  std::vector<PandoraPFParticle> all_PPFPs,
26  const std::vector<art::Ptr<recob::Track>>& tracks,
27  std::map<art::Ptr<recob::PFParticle>, std::vector<art::Ptr<recob::SpacePoint>>> & pfParticleToSpacePointsMap,
28  std::map<int, art::Ptr<simb::MCParticle> > & MCParticleToTrackIdMap,
29  std::map<int, double> &sliceIdToNuScoreMap,
30  var_all& vars,
31  para_all& paras){
32 
33 
34  if(g_is_verbose) std::cout<<"AnalyzeTracks()\t||\t Starting recob::Track analysis"<<std::endl;;
35 
36  int i_trk=0;
37 
38 
39  //const double adc2eU(5.1e-3);
40  //const double adc2eV(5.2e-3);
41  // const double adc2eW(5.4e-3);
42 
43 
44  // const double tau(theDetector->ElectronLifetime());
45 
46 
47  //loop over each recob::Track
48  for (TrackVector::const_iterator iter = tracks.begin(), iterEnd = tracks.end(); iter != iterEnd; ++iter)
49  {
50 
51  const art::Ptr<recob::Track> track = *iter;
52  // const art::Ptr<recob::PFParticle> pfp = trackToNuPFParticleMap[track];
53  PandoraPFParticle* ppfp = PPFP_GetPPFPFromTrack(all_PPFPs, track);
54  const art::Ptr<recob::PFParticle> pfp = ppfp->pPFParticle;
55 
56  const std::vector< art::Ptr<recob::SpacePoint> > trk_spacepoints = pfParticleToSpacePointsMap[pfp];
57  const std::vector<art::Ptr<recob::Hit>> trk_hits = ppfp->pPFPHits;//pfParticleToHitsMap[pfp];
58 
59  int m_trkid = track->ID();
60  double tem_length = track->Length();
61  auto tem_trk_dir = track->Direction(); // type of vars.m_trk_dir: a std::pair of two 3D vector
62  //first: direction of first point, second: direction of the end of track
63 
64  if(g_is_verbose) std::cout<<"AnalyzeTracks()\t||\t On Track: "<<i_trk<<" with TrackID: "<<m_trkid<<" and length: "<<tem_length<<""<<std::endl;;
65 
66  vars.m_reco_track_calo_energy_plane0[i_trk] = CalcEShowerPlane(trk_hits, 0, paras);
67  vars.m_reco_track_calo_energy_plane1[i_trk] = CalcEShowerPlane(trk_hits, 1, paras);
68  vars.m_reco_track_calo_energy_plane2[i_trk] = CalcEShowerPlane(trk_hits, 2, paras);
69  vars.m_reco_track_calo_energy_max[i_trk] = std::max( vars.m_reco_track_calo_energy_plane2[i_trk], std::max(vars.m_reco_track_calo_energy_plane0[i_trk],vars.m_reco_track_calo_energy_plane1[i_trk]));
70 
71  vars.m_reco_track_num_spacepoints[i_trk] = (int)trk_spacepoints.size();
72 
73 
74  vars.m_reco_track_startx[i_trk]= track->Start().X();
75  vars.m_reco_track_starty[i_trk]= track->Start().Y();
76  vars.m_reco_track_startz[i_trk]= track->Start().Z();
77 
78  vars.m_reco_track_length[i_trk] =tem_length;
79  vars.m_reco_track_dirx[i_trk] = tem_trk_dir.first.X();
80  vars.m_reco_track_diry[i_trk] = tem_trk_dir.first.Y();
81  vars.m_reco_track_dirz[i_trk] = tem_trk_dir.first.Z();
82 
83  vars.m_reco_track_endx[i_trk] = track->End().X();
84  vars.m_reco_track_endy[i_trk]= track->End().Y();
85  vars.m_reco_track_endz[i_trk]= track->End().Z();
86 
87  std::vector<double> hend = {vars.m_reco_track_endx[i_trk],vars.m_reco_track_endy[i_trk],vars.m_reco_track_endz[i_trk]};
88  std::vector<double> hstart = {vars.m_reco_track_startx[i_trk],vars.m_reco_track_starty[i_trk],vars.m_reco_track_startz[i_trk]};
89 
90  vars.m_reco_track_end_dist_to_active_TPC[i_trk] = distToTPCActive(hend, paras);
91  vars.m_reco_track_start_dist_to_active_TPC[i_trk] = distToTPCActive(hstart, paras);
92 
93  vars.m_reco_track_end_dist_to_CPA[i_trk] = distToCPA(hend, paras);
94  vars.m_reco_track_start_dist_to_CPA[i_trk] = distToCPA(hstart, paras);
95 
96  vars.m_reco_track_end_in_SCB[i_trk] = distToSCB(vars.m_reco_track_end_dist_to_SCB[i_trk],hend, paras);
97  vars.m_reco_track_start_in_SCB[i_trk] = distToSCB(vars.m_reco_track_start_dist_to_SCB[i_trk],hstart, paras);
98 
99 
100  vars.m_reco_track_theta_yz[i_trk] = atan2(vars.m_reco_track_diry[i_trk],vars.m_reco_track_dirz[i_trk]);
101  vars.m_reco_track_phi_yx[i_trk] = atan2(vars.m_reco_track_diry[i_trk],vars.m_reco_track_dirx[i_trk]);
102 
103  std::vector<double> tmp_trk_start = {vars.m_reco_track_startx[i_trk],vars.m_reco_track_starty[i_trk],vars.m_reco_track_startz[i_trk]};
104  std::vector<double> tmp_trk_end = {vars.m_reco_track_endx[i_trk],vars.m_reco_track_endy[i_trk],vars.m_reco_track_endz[i_trk]};
105  double max_dist_from_line = -9999999;
106 
107  vars.m_reco_track_spacepoint_chi[i_trk] = 0.0;
108  //Principal componant analysis of SPACEPOINTS and not trajectory points. Will add a few things here in future.
109 
110  if(g_is_verbose) std::cout<<"AnalyzeTracks()\t||\t Beginining PCA analysis of track"<<std::endl;;
111 
112  TPrincipal* principal;
113  principal = new TPrincipal(3,"ND");
114  for(int x = 0; x < vars.m_reco_track_num_spacepoints[i_trk]; x++){
115  // get the position of spacepoint in xyz
116  std::vector<double> tmp_spacepoints = {trk_spacepoints[x]->XYZ()[0],trk_spacepoints[x]->XYZ()[1] , trk_spacepoints[x]->XYZ()[2]};
117  principal->AddRow(&tmp_spacepoints[0]);
118 
119  // distance between track direction and spacepoint
120  double dist = dist_line_point(tmp_trk_start,tmp_trk_end,tmp_spacepoints);
121  if(dist> max_dist_from_line) max_dist_from_line = dist;
122  vars.m_reco_track_spacepoint_chi[i_trk] += dist*dist;
123  }
124  vars.m_reco_track_spacepoint_max_dist[i_trk]= max_dist_from_line;
125 
126  principal->MakePrincipals();
127  TVectorD * eigen = (TVectorD*) principal->GetEigenValues();
128 
129  vars.m_reco_track_spacepoint_principal0[i_trk]=(*eigen)(0);
130  vars.m_reco_track_spacepoint_principal1[i_trk]=(*eigen)(1);
131  vars.m_reco_track_spacepoint_principal2[i_trk]=(*eigen)(2);
132 
133  delete principal;
134 
135  if(g_is_verbose) std::cout<<"AnalyzeTracks()\t||\t Completed PCA analysis of track. Primary componant: "<<vars.m_reco_track_spacepoint_principal0.back()<<""<<std::endl;;
136 
137  //range based energy calculation assuming
138 
139  if(paras.s_run_pi0_filter){
140  // assume this track is a proton track, get its energy
141  vars.m_reco_track_proton_kinetic_energy[i_trk] = -9999;
142  }else{
143  //WARNING, extra input is needed for the proton track energy;
144  // vars.m_reco_track_proton_kinetic_energy[i_trk] = proton_length2energy_tgraph.Eval(tem_length)/1000.0;
145  }
146 
147  if(tem_length == 0.0) vars.m_reco_track_proton_kinetic_energy[i_trk]=0.0;
148 
149  // Dead Wire Approximity
150  // vars.m_reco_track_end_to_nearest_dead_wire_plane0[i_trk] = distanceToNearestDeadWire(0, vars.m_reco_track_endy[i_trk], vars.m_reco_track_endz[i_trk],geom,bad_channel_list_fixed_mcc9);
151  // vars.m_reco_track_end_to_nearest_dead_wire_plane1[i_trk] = distanceToNearestDeadWire(1, vars.m_reco_track_endy[i_trk], vars.m_reco_track_endz[i_trk],geom,bad_channel_list_fixed_mcc9);
152  // vars.m_reco_track_end_to_nearest_dead_wire_plane2[i_trk] = distanceToNearestDeadWire(2, vars.m_reco_track_endy[i_trk], vars.m_reco_track_endz[i_trk],geom,bad_channel_list_fixed_mcc9);
153 
154  vars.m_reco_track_sliceId[i_trk] = ppfp->get_SliceID();//PFPToSliceIdMap[pfp];
155  // Guanqun: how do you make sure the sliceId is positive, not -1, as for cosmic tracks?
156  // sliceIdToNuScoreMap seems to only have sliceID:nuScore pairs for these with actual nuScores.
157  vars.m_reco_track_nuscore[i_trk] = sliceIdToNuScoreMap[ vars.m_reco_track_sliceId[i_trk]] ;
158  vars.m_reco_track_isclearcosmic[i_trk] = ppfp->get_IsClearCosmic();//PFPToClearCosmicMap[pfp];
159 
160  //std::cout<<"checking track nuslice"<<std::endl;
161  // std::cout<<"is nuslice for track with pfp "<<pfp->Self()<<" is: "<<PFPToNuSliceMap[pfp]<<std::endl;
162  vars.m_reco_track_is_nuslice[i_trk] = ppfp->get_IsNuSlice();//PFPToNuSliceMap[pfp];
163 
164  vars.m_reco_track_num_daughters[i_trk] = pfp->NumDaughters();
165  if(vars.m_reco_track_num_daughters[i_trk]>0){
166  //currently just look at 1 daughter
167  // vars.m_reco_track_daughter_trackscore[i_trk] = PFPToTrackScoreMap[pfParticleMap[pfp->Daughters().front()]];
168  int pfp_size = all_PPFPs.size();
169  for(int index = 0; index < pfp_size; index++){
170  if( (pfp->Daughters().front()) == all_PPFPs[index].pPFParticle->Self()){
171  vars.m_reco_track_daughter_trackscore[i_trk] = all_PPFPs[index].get_TrackScore();
172  break;
173  }
174  }
175 
176  }
177 
178  vars.m_reco_track_trackscore[i_trk] = ppfp->get_TrackScore();
179  vars.m_reco_track_pfparticle_pdg[i_trk] = ppfp->get_PdgCode();
180 
181  // vars.m_reco_track_trackscore[i_trk] = PFPToTrackScoreMap[pfp];
182  // if ( PFPToTrackScoreMap.find(pfp) != PFPToTrackScoreMap.end() ) {
183  // vars.m_reco_track_trackscore[i_trk] = PFPToTrackScoreMap[pfp];
184  // vars.m_reco_track_pfparticle_pdg[i_trk] = pfp->PdgCode();
185  // } else{
186  // vars.m_reco_track_trackscore[i_trk] = -999;
187  // vars.m_reco_track_pfparticle_pdg[i_trk] = -999;
188  // }
189 
190  //A loop over the trajectory points
191  size_t const traj_size = track->CountValidPoints();
192  vars.m_reco_track_num_trajpoints[i_trk] = (int)traj_size;
193 
194  for(unsigned int p = 0; p < traj_size; ++p) {
195  //recob::Track::TrajectoryPoint_t const & trajp = track->TrajectoryPoint(j);
196  //recob::Track::Point_t const & pos = trajp.position;
197  //recob::Track::Vector_t const & mom = trajp.momentum;
198 
199  }
200 
201 
202  i_trk++;
203 
204  } // end of recob::Track loop
205 
206  //Lets sort and order the showers
209 
210 
211  if(g_is_verbose) std::cout<<"AnalyzeTracks()\t||\t Finished."<<std::endl;;
212  }
213 
214 
215 
216  void AnalyzeTrackCalo(const std::vector<art::Ptr<recob::Track>> &tracks, std::vector<PandoraPFParticle> all_PPFPs,var_all& vars, para_all& paras){
217 
218  if(g_is_verbose) std::cout<<"CollectCalo(recob::Track)\t||\t Starting calo module for recob::Track"<<std::endl;;
219 
220  for(size_t i_trk = 0; i_trk<tracks.size(); ++i_trk){
221  const art::Ptr<recob::Track> track = tracks[i_trk];
222  PandoraPFParticle* ppfp = PPFP_GetPPFPFromTrack(all_PPFPs, track);
223  std::vector<art::Ptr<anab::Calorimetry>> Calos = ppfp->get_Calorimetries();
224 
225  if(Calos.size()!=3){
226  std::cout<<"Singlephoton::Tracks\t||\tERROR!! ERROR!!! anab::Calorimetery vector is not of length 3!!! "<<Calos.size()<<". Skipping this track!!"<<std::endl;
227  continue;
228  }
229  //if(trackToCaloMap[track].size()!=3){
230  // std::cout<<"Singlephoton::Tracks\t||\tERROR!! ERROR!!! anab::Calorimetery vector is not of length 3!!! "<<trackToCaloMap[track].size()<<". Skipping this track!!"<<std::endl;
231  // continue;
232  //}
233 
234  const art::Ptr<anab::Calorimetry> calo_p0 = Calos[0];
235  const art::Ptr<anab::Calorimetry> calo_p1 = Calos[1];
236  const art::Ptr<anab::Calorimetry> calo_p2 = Calos[2];
237 
238 
239  size_t calo_length_p0 = calo_p0->dEdx().size();
240  size_t calo_length_p1 = calo_p1->dEdx().size();
241  size_t calo_length_p2 = calo_p2->dEdx().size();
242 
243  TruncMean tm_p0;
244  TruncMean tm_p1;
245  TruncMean tm_p2;
246 
247  std::vector<double> trunc_dEdx_p0;
248  std::vector<double> res_range_good_p0;
249  std::vector<double> dEdx_good_p0;
250 
251  std::vector<double> trunc_dEdx_p1;
252  std::vector<double> res_range_good_p1;
253  std::vector<double> dEdx_good_p1;
254 
255  std::vector<double> trunc_dEdx_p2;
256  std::vector<double> res_range_good_p2;
257  std::vector<double> dEdx_good_p2;
258 
259  vars.m_reco_track_num_calo_hits_p0[i_trk] = (int)calo_length_p0;
260  vars.m_reco_track_num_calo_hits_p1[i_trk] = (int)calo_length_p1;
261  vars.m_reco_track_num_calo_hits_p2[i_trk] = (int)calo_length_p2;
262 
263  vars.m_reco_track_best_calo_plane[i_trk]=-1;
264 
265  // guanqun: vectors have been clear and resized, so probably not need to reset their values?
266  vars.m_reco_track_good_calo_p0[i_trk] = 0;
267  vars.m_reco_track_mean_dEdx_p0[i_trk] = 0.0;
268  vars.m_reco_track_mean_dEdx_start_half_p0[i_trk] = 0.0;
269  vars.m_reco_track_mean_dEdx_end_half_p0[i_trk] = 0.0;
270  vars.m_reco_track_mean_trunc_dEdx_p0[i_trk] = 0.0;
273  vars.m_reco_track_trunc_PIDA_p0[i_trk] = 0.0;
274 
275  vars.m_reco_track_good_calo_p1[i_trk] = 0;
276  vars.m_reco_track_mean_dEdx_p1[i_trk] = 0.0;
277  vars.m_reco_track_mean_dEdx_start_half_p1[i_trk] = 0.0;
278  vars.m_reco_track_mean_dEdx_end_half_p1[i_trk] = 0.0;
279  vars.m_reco_track_mean_trunc_dEdx_p1[i_trk] = 0.0;
282  vars.m_reco_track_trunc_PIDA_p1[i_trk] = 0.0;
283 
284  vars.m_reco_track_good_calo_p2[i_trk] = 0;
285  vars.m_reco_track_mean_dEdx_p2[i_trk] = 0.0;
286  vars.m_reco_track_mean_dEdx_start_half_p2[i_trk] = 0.0;
287  vars.m_reco_track_mean_dEdx_end_half_p2[i_trk] = 0.0;
288  vars.m_reco_track_mean_trunc_dEdx_p2[i_trk] = 0.0;
291  vars.m_reco_track_trunc_PIDA_p2[i_trk] = 0.0;
292 
293 
294 
295  //First off look over ALL points
296  //--------------------------------- plane 0 ----------- Induction
297  for (size_t k = 0; k < calo_length_p0; ++k) {
298  double res_range = calo_p0->ResidualRange()[k]; //ResidualRange() returns range from end of track
299  double dEdx = calo_p0->dEdx()[k];
300 
301  vars.m_reco_track_mean_dEdx_p0[i_trk] += dEdx;
302  if(k <= calo_length_p0/2){
304  }else{
306  }
307 
308  bool is_sensible = dEdx < paras.s_track_calo_max_dEdx;
309  bool is_nan =dEdx != dEdx; // != has higher precedence than =
310  bool is_inf = std::isinf(dEdx);
311  bool is_nonzero = dEdx> paras.s_track_calo_min_dEdx;
312 
313  if(is_sensible && !is_nan && !is_inf && is_nonzero && k != 0 && k != calo_length_p0-1){
314  res_range_good_p0.push_back(res_range);
315  dEdx_good_p0.push_back(dEdx);
316  }
317 
318  // std::cout<<"\t"<<k<<" "<<calo->dEdx()[k]<<" "<<calo->ResidualRange()[k]<<" "<< ""<<std::endl;;
319  }// End of first loop.
320 
321  vars.m_reco_track_good_calo_p0[i_trk] = 0;
322  if(res_range_good_p0.size() >= paras.s_track_calo_min_dEdx_hits){
323  vars.m_reco_track_good_calo_p0[i_trk] = res_range_good_p0.size();
324 
325  //The radius we truncate over is going to be the max of either 1/frac of a track or 2x the minimuvars.m_dx in the res_range
326  double tenth_track = std::max(res_range_good_p0.front(), res_range_good_p0.back())/paras.s_track_calo_trunc_fraction;
327  double min_dx = 999;
328  for(int j = res_range_good_p0.size()-1; j>1; j--){
329  double dx = fabs(res_range_good_p0[j]-res_range_good_p0[j-1]);
330  if(dx < min_dx) min_dx = dx;
331  }
332  double rad = std::max( min_dx*2, tenth_track);
333 
334  //Calculate the residual range
335  tm_p0.setRadius(rad);
336  tm_p0.CalcTruncMeanProfile(res_range_good_p0,dEdx_good_p0, trunc_dEdx_p0);
337 
338  double pida_sum_trunc=0.0;
339  //Calculate the mean truncated mean dEdx
340  for(size_t k=0; k< trunc_dEdx_p0.size(); k++){
341  double dEdx = trunc_dEdx_p0[k];
342  vars.m_reco_track_mean_trunc_dEdx_p0[i_trk] += dEdx;
343  if(k <= trunc_dEdx_p0.size()/2){
345  }else{
347  }
348 
349 
350  if(trunc_dEdx_p0[k] != trunc_dEdx_p0[k] || std::isinf(trunc_dEdx_p0[k]) || trunc_dEdx_p0[k]<0){
351  std::cout<<"Truncated dedx is either inf or nan (or negative) @ "<<k<<" "<<trunc_dEdx_p0[k]<<std::endl;
352  std::cout<<"Vector Length : "<<trunc_dEdx_p0.size()<<std::endl;
353  std::cout<<"i\t range \t dedx \t trunc dedx"<<std::endl;
354  //for(int m=0; m<trunc_dEdx.size(); m++){
355  // std::cout<<m<<"\t"<<c_resrange.at(m)<<" "<<c_dEdx.at(m)<<" "<<trunc_dEdx.at(m)<<std::endl;
356  //}
357  std::cout<<"Using Radius: "<<rad<<std::endl;
358  //exit(EXIT_FAILURE);
359  vars.m_reco_track_good_calo_p0[i_trk] = 0;
360  }
361 
362  // dEdx/pow(residual_range, -0.42) is the constant A in residual range formula
363  pida_sum_trunc += trunc_dEdx_p0[k]/(pow(res_range_good_p0[k],-0.42));
364  }
365  vars.m_reco_track_trunc_PIDA_p0[i_trk] = pida_sum_trunc;
366  vars.m_reco_track_resrange_p0[i_trk] = res_range_good_p0;
367  vars.m_reco_track_trunc_dEdx_p0[i_trk] = trunc_dEdx_p0;
368  vars.m_reco_track_dEdx_p0[i_trk] = dEdx_good_p0;
369 
370  //std::cout<<"the residual range at the start is "<<res_range_good[0]<<std::endl;
371  }
372 
373  vars.m_reco_track_mean_dEdx_p0[i_trk] *=1.0/((double)calo_length_p0);
374  vars.m_reco_track_mean_dEdx_start_half_p0[i_trk] *=2.0/((double)calo_length_p0);
375  vars.m_reco_track_mean_dEdx_end_half_p0[i_trk] *=2.0/((double)calo_length_p0);
376  vars.m_reco_track_mean_trunc_dEdx_p0[i_trk] *=1.0/((double)trunc_dEdx_p0.size());
377  vars.m_reco_track_mean_trunc_dEdx_start_half_p0[i_trk] *=2.0/((double)trunc_dEdx_p0.size());
378  vars.m_reco_track_mean_trunc_dEdx_end_half_p0[i_trk] *=2.0/((double)trunc_dEdx_p0.size());
379  vars.m_reco_track_trunc_PIDA_p0[i_trk] *=1.0/((double)trunc_dEdx_p0.size());
380 
381  //First off look over ALL points
382  //--------------------------------- plane 1 ----------- Induction
383  for (size_t k = 0; k < calo_length_p1; ++k) {
384  double res_range = calo_p1->ResidualRange()[k];
385  double dEdx = calo_p1->dEdx()[k];
386 
387  vars.m_reco_track_mean_dEdx_p1[i_trk] += dEdx;
388  if(k <= calo_length_p1/2){
390  }else{
392  }
393 
394  bool is_sensible = dEdx < paras.s_track_calo_max_dEdx;
395  bool is_nan =dEdx != dEdx;
396  bool is_inf = std::isinf(dEdx);
397  bool is_nonzero = dEdx> paras.s_track_calo_min_dEdx;
398 
399  if(is_sensible && !is_nan && !is_inf && is_nonzero && k != 0 && k != calo_length_p1-1){
400  res_range_good_p1.push_back(res_range);
401  dEdx_good_p1.push_back(dEdx);
402  }
403 
404  // std::cout<<"\t"<<k<<" "<<calo->dEdx()[k]<<" "<<calo->ResidualRange()[k]<<" "<< ""<<std::endl;;
405  }// End of first loop.
406 
407  vars.m_reco_track_good_calo_p1[i_trk] = 0;
408  if(res_range_good_p1.size() >= paras.s_track_calo_min_dEdx_hits){
409  vars.m_reco_track_good_calo_p1[i_trk] = res_range_good_p1.size();
410 
411  //The radius we truncate over is going to be the max of either 1/frac of a track or 2x the minimuvars.m_dx in the res_range
412  double tenth_track = std::max(res_range_good_p1.front(), res_range_good_p1.back())/paras.s_track_calo_trunc_fraction;
413  double min_dx = 999;
414  for(int j = res_range_good_p1.size()-1; j>1; j--){
415  double dx = fabs(res_range_good_p1[j]-res_range_good_p1[j-1]);
416  if(dx < min_dx) min_dx = dx;
417  }
418  double rad = std::max( min_dx*2, tenth_track);
419 
420  //Calculate the residual range
421  tm_p1.setRadius(rad);
422  tm_p1.CalcTruncMeanProfile(res_range_good_p1,dEdx_good_p1, trunc_dEdx_p1);
423 
424  double pida_sum_trunc=0.0;
425  //Calculate the mean truncated mean dEdx
426  for(size_t k=0; k< trunc_dEdx_p1.size(); k++){
427  double dEdx = trunc_dEdx_p1[k];
428  vars.m_reco_track_mean_trunc_dEdx_p1[i_trk] += dEdx;
429  if(k <= trunc_dEdx_p1.size()/2){
431  }else{
433  }
434 
435 
436  if(trunc_dEdx_p1[k] != trunc_dEdx_p1[k] || std::isinf(trunc_dEdx_p1[k]) || trunc_dEdx_p1[k]<0){
437  std::cout<<"Truncated dedx is either inf or nan (or negative) @ "<<k<<" "<<trunc_dEdx_p1[k]<<std::endl;
438  std::cout<<"Vector Length : "<<trunc_dEdx_p1.size()<<std::endl;
439  std::cout<<"i\t range \t dedx \t trunc dedx"<<std::endl;
440  //for(int m=0; m<trunc_dEdx.size(); m++){
441  // std::cout<<m<<"\t"<<c_resrange.at(m)<<" "<<c_dEdx.at(m)<<" "<<trunc_dEdx.at(m)<<std::endl;
442  //}
443  std::cout<<"Using Radius: "<<rad<<std::endl;
444  //exit(EXIT_FAILURE);
445  vars.m_reco_track_good_calo_p1[i_trk] = 0;
446  }
447 
448  pida_sum_trunc += trunc_dEdx_p1[k]/(pow(res_range_good_p1[k],-0.42));
449  }
450  vars.m_reco_track_trunc_PIDA_p1[i_trk] = pida_sum_trunc;
451  vars.m_reco_track_resrange_p1[i_trk] = res_range_good_p1;
452  vars.m_reco_track_trunc_dEdx_p1[i_trk] = trunc_dEdx_p1;
453  vars.m_reco_track_dEdx_p1[i_trk] = dEdx_good_p1;
454 
455  //std::cout<<"the residual range at the start is "<<res_range_good[0]<<std::endl;
456  }
457 
458  vars.m_reco_track_mean_dEdx_p1[i_trk] *=1.0/((double)calo_length_p1);
459  vars.m_reco_track_mean_dEdx_start_half_p1[i_trk] *=2.0/((double)calo_length_p1);
460  vars.m_reco_track_mean_dEdx_end_half_p1[i_trk] *=2.0/((double)calo_length_p1);
461  vars.m_reco_track_mean_trunc_dEdx_p1[i_trk] *=1.0/((double)trunc_dEdx_p1.size());
462  vars.m_reco_track_mean_trunc_dEdx_start_half_p1[i_trk] *=2.0/((double)trunc_dEdx_p1.size());
463  vars.m_reco_track_mean_trunc_dEdx_end_half_p1[i_trk] *=2.0/((double)trunc_dEdx_p1.size());
464  vars.m_reco_track_trunc_PIDA_p1[i_trk] *=1.0/((double)trunc_dEdx_p1.size());
465 
466  //First off look over ALL points
467  //--------------------------------- plane 2 ----------- Collection
468  for (size_t k = 0; k < calo_length_p2; ++k) {
469  double res_range = calo_p2->ResidualRange()[k];
470  double dEdx = calo_p2->dEdx()[k];
471 
472  vars.m_reco_track_mean_dEdx_p2[i_trk] += dEdx;
473  if(k <= calo_length_p2/2){
475  }else{
477  }
478 
479  bool is_sensible = dEdx < paras.s_track_calo_max_dEdx;
480  bool is_nan =dEdx != dEdx;
481  bool is_inf = std::isinf(dEdx);
482  bool is_nonzero = dEdx> paras.s_track_calo_min_dEdx;
483 
484  if(is_sensible && !is_nan && !is_inf && is_nonzero && k != 0 && k != calo_length_p2-1){
485  res_range_good_p2.push_back(res_range);
486  dEdx_good_p2.push_back(dEdx);
487  }
488 
489  // std::cout<<"\t"<<k<<" "<<calo->dEdx()[k]<<" "<<calo->ResidualRange()[k]<<" "<< ""<<std::endl;;
490  }// End of first loop.
491 
492  vars.m_reco_track_good_calo_p2[i_trk] = 0;
493  if(res_range_good_p2.size() >= paras.s_track_calo_min_dEdx_hits){
494  vars.m_reco_track_good_calo_p2[i_trk] = res_range_good_p2.size();
495 
496  //The radius we truncate over is going to be the max of either 1/frac of a track or 2x the minimuvars.m_dx in the res_range
497  double tenth_track = std::max(res_range_good_p2.front(), res_range_good_p2.back())/paras.s_track_calo_trunc_fraction;
498  double min_dx = 999;
499  for(int j = res_range_good_p2.size()-1; j>1; j--){
500  double dx = fabs(res_range_good_p2[j]-res_range_good_p2[j-1]);
501  if(dx < min_dx) min_dx = dx;
502  }
503  double rad = std::max( min_dx*2, tenth_track);
504 
505  //Calculate the residual range
506  tm_p2.setRadius(rad);
507  tm_p2.CalcTruncMeanProfile(res_range_good_p2,dEdx_good_p2, trunc_dEdx_p2);
508 
509  double pida_sum_trunc=0.0;
510  //Calculate the mean truncated mean dEdx
511  for(size_t k=0; k< trunc_dEdx_p2.size(); k++){
512  double dEdx = trunc_dEdx_p2[k];
513  vars.m_reco_track_mean_trunc_dEdx_p2[i_trk] += dEdx;
514  if(k <= trunc_dEdx_p2.size()/2){
516  }else{
518  }
519 
520 
521  if(trunc_dEdx_p2[k] != trunc_dEdx_p2[k] || std::isinf(trunc_dEdx_p2[k]) || trunc_dEdx_p2[k]<0){
522  std::cout<<"Truncated dedx is either inf or nan (or negative) @ "<<k<<" "<<trunc_dEdx_p2[k]<<std::endl;
523  std::cout<<"Vector Length : "<<trunc_dEdx_p2.size()<<std::endl;
524  std::cout<<"i\t range \t dedx \t trunc dedx"<<std::endl;
525  //for(int m=0; m<trunc_dEdx.size(); m++){
526  // std::cout<<m<<"\t"<<c_resrange.at(m)<<" "<<c_dEdx.at(m)<<" "<<trunc_dEdx.at(m)<<std::endl;
527  //}
528  std::cout<<"Using Radius: "<<rad<<std::endl;
529  //exit(EXIT_FAILURE);
530  vars.m_reco_track_good_calo_p2[i_trk] = 0;
531  }
532 
533  pida_sum_trunc += trunc_dEdx_p2[k]/(pow(res_range_good_p2[k],-0.42));
534  }
535  vars.m_reco_track_trunc_PIDA_p2[i_trk] = pida_sum_trunc;
536  vars.m_reco_track_resrange_p2[i_trk] = res_range_good_p2;
537  vars.m_reco_track_trunc_dEdx_p2[i_trk] = trunc_dEdx_p2;
538  vars.m_reco_track_dEdx_p2[i_trk] = dEdx_good_p2;
539 
540  //std::cout<<"the residual range at the start is "<<res_range_good[0]<<std::endl;
541  }
542 
543  vars.m_reco_track_mean_dEdx_p2[i_trk] *=1.0/((double)calo_length_p2);
544  vars.m_reco_track_mean_dEdx_start_half_p2[i_trk] *=2.0/((double)calo_length_p2);
545  vars.m_reco_track_mean_dEdx_end_half_p2[i_trk] *=2.0/((double)calo_length_p2);
546  vars.m_reco_track_mean_trunc_dEdx_p2[i_trk] *=1.0/((double)trunc_dEdx_p2.size());
547  vars.m_reco_track_mean_trunc_dEdx_start_half_p2[i_trk] *=2.0/((double)trunc_dEdx_p2.size());
548  vars.m_reco_track_mean_trunc_dEdx_end_half_p2[i_trk] *=2.0/((double)trunc_dEdx_p2.size());
549  vars.m_reco_track_trunc_PIDA_p2[i_trk] *=1.0/((double)trunc_dEdx_p2.size());
550 
551 
552  //************************ Now
553  //lets pick one as a default?
554 
555  if(vars.m_reco_track_good_calo_p2[i_trk]!=0){
556  vars.m_reco_track_best_calo_plane[i_trk] = 2;
557 
568  vars.m_reco_track_dEdx_best_plane [i_trk] = vars.m_reco_track_dEdx_p2[i_trk];
569 
570  }else if(vars.m_reco_track_good_calo_p0[i_trk] > vars.m_reco_track_good_calo_p1[i_trk] ){
571  vars.m_reco_track_best_calo_plane[i_trk] = 0;
572 
583  vars.m_reco_track_dEdx_best_plane [i_trk] = vars.m_reco_track_dEdx_p0[i_trk];
584 
585 
586  }else if(vars.m_reco_track_good_calo_p1[i_trk]!=0){
587  vars.m_reco_track_best_calo_plane[i_trk] = 1;
588 
599  vars.m_reco_track_dEdx_best_plane [i_trk] = vars.m_reco_track_dEdx_p1[i_trk];
600 
601 
602 
603  }else{
604  vars.m_reco_track_best_calo_plane[i_trk] = -1;
605  }
606 
607 
608  }
609  }
610 
611 
612 
613  void CollectPID(std::vector<art::Ptr<recob::Track>> & tracks,
614  std::vector<PandoraPFParticle> all_PPFPs,var_all& vars){
615 
616  for(size_t i_trk=0; i_trk<tracks.size(); ++i_trk){
617  art::Ptr<recob::Track> track = tracks[i_trk];
618 
619  PandoraPFParticle* ppfp = PPFP_GetPPFPFromTrack(all_PPFPs, track);
620  art::Ptr<anab::ParticleID> pid = ppfp->get_ParticleID();//trackToPIDMap[track];
621  if (!ppfp->get_HasPID()) {
622  std::cout << "[analyze_Tracks] bad PID object" << std::endl;
623  continue;
624  }
625 
626  // For each PID object, create vector of PID scores for each algorithm
627  // Loop over this and get scores for algorithm of choice
628  // But first, prepare garbage values, just in case
629  std::vector<anab::sParticleIDAlgScores> AlgScoresVec = pid->ParticleIDAlgScores();
630  double pidScore_BL_mu_plane0 = -999;
631  double pidScore_BL_mu_plane1 = -999;
632  double pidScore_BL_mu_plane2 = -999;
633  double pidScore_BL_p_plane0 = -999;
634  double pidScore_BL_p_plane1 = -999;
635  double pidScore_BL_p_plane2 = -999;
636  double pidScore_BL_mip_plane0 = -999;
637  double pidScore_BL_mip_plane1 = -999;
638  double pidScore_BL_mip_plane2 = -999;
639  double pidScore_PIDA_plane0 = -999;
640  double pidScore_PIDA_plane1 = -999;
641  double pidScore_PIDA_plane2 = -999;
642  double pidScore_chi2_mu_plane0 = -999;
643  double pidScore_chi2_mu_plane1 = -999;
644  double pidScore_chi2_mu_plane2 = -999;
645  double pidScore_chi2_p_plane0 = -999;
646  double pidScore_chi2_p_plane1 = -999;
647  double pidScore_chi2_p_plane2 = -999;
648  double pidScore_three_plane_proton = -999;
649 
650  //int planeid = 2;
651  for (size_t i_algscore=0; i_algscore<AlgScoresVec.size(); i_algscore++) {
652 
653  anab::sParticleIDAlgScores AlgScore = AlgScoresVec.at(i_algscore);
654  //int planeid = UBPID::uB_getSinglePlane(AlgScore.fPlaneID);
655  int planeid = 0;//CHECK UBPID::uB_getSinglePlane(AlgScore.fPlaneMask);
656  std::cout<<"WARNING: planeid is not set properly; so please check if you think this section matters"<<std::endl;
657  /*
658  if (planeid != 2){
659  std::cout << "[ParticleIDValidation] Not using information for plane "
660  << planeid << " (using plane 2 calorimetry only)" << std::endl;
661  continue;
662  }
663  */
664  if (AlgScore.fAlgName == "BraggPeakLLH" && anab::kVariableType(AlgScore.fVariableType) == anab::kLikelihood){
665  if (TMath::Abs(AlgScore.fAssumedPdg == 13)) {
666  if (planeid == 0) pidScore_BL_mu_plane0 = AlgScore.fValue; //AlgScore.fValue: value produced by algorithm
667  if (planeid == 1) pidScore_BL_mu_plane1 = AlgScore.fValue;
668  if (planeid == 2) pidScore_BL_mu_plane2 = AlgScore.fValue;
669  }
670  if (TMath::Abs(AlgScore.fAssumedPdg == 2212)) {
671  if (planeid == 0) pidScore_BL_p_plane0 = AlgScore.fValue;
672  if (planeid == 1) pidScore_BL_p_plane1 = AlgScore.fValue;
673  if (planeid == 2) pidScore_BL_p_plane2 = AlgScore.fValue;
674  }
675  if (TMath::Abs(AlgScore.fAssumedPdg == 0)) {
676  if (planeid == 0) pidScore_BL_mip_plane0 = AlgScore.fValue;
677  if (planeid == 1) pidScore_BL_mip_plane1 = AlgScore.fValue;
678  if (planeid == 2) pidScore_BL_mip_plane2 = AlgScore.fValue;
679  }
680  }
681  if (AlgScore.fAlgName == "Chi2" && anab::kVariableType(AlgScore.fVariableType) == anab::kGOF){
682  if (TMath::Abs(AlgScore.fAssumedPdg == 13)) {
683  if (planeid == 0) pidScore_chi2_mu_plane0 = AlgScore.fValue;
684  if (planeid == 1) pidScore_chi2_mu_plane1 = AlgScore.fValue;
685  if (planeid == 2) pidScore_chi2_mu_plane2 = AlgScore.fValue;
686  }
687  if (TMath::Abs(AlgScore.fAssumedPdg == 2212)) {
688  if (planeid == 0) pidScore_chi2_p_plane0 = AlgScore.fValue;
689  if (planeid == 1) pidScore_chi2_p_plane1 = AlgScore.fValue;
690  if (planeid == 2) pidScore_chi2_p_plane2 = AlgScore.fValue;
691  }
692  }
693  if (AlgScore.fAlgName == "PIDA_mean" && anab::kVariableType(AlgScore.fVariableType) == anab::kPIDA){
694  if (planeid == 0) pidScore_PIDA_plane0 = AlgScore.fValue;
695  if (planeid == 1) pidScore_PIDA_plane1 = AlgScore.fValue;
696  if (planeid == 2) pidScore_PIDA_plane2 = AlgScore.fValue;
697  }
698  //CHECK if (AlgScore.fAlgName == "ThreePlaneProtonPID" && anab::kVariableType(AlgScore.fVariableType) == anab::kLikelihood && TMath::Abs(AlgScore.fAssumedPdg) == 2212 && AlgScore.fPlaneMask == UBPID::uB_SinglePlaneGetBitset(2) ){}
699  if (AlgScore.fAlgName == "ThreePlaneProtonPID" && anab::kVariableType(AlgScore.fVariableType) == anab::kLikelihood && TMath::Abs(AlgScore.fAssumedPdg) == 2212 && AlgScore.fPlaneMask == 0 ){
700  //if (AlgScore.fAlgName == "ThreePlaneProtonPID" && anab::kVariableType(AlgScore.fVariableType) == anab::kLikelihood && TMath::Abs(AlgScore.fAssumedPdg) == 2212 && AlgScore.fPlaneMask == UBPID::uB_SinglePlaneGetBitset(2) && anab::kTrackDir(AlgScore.fTrackDir) == anab::kForward){}
701  pidScore_three_plane_proton = AlgScore.fValue;
702  }
703  } // end looping over AlgScoresVec
704 
705  vars.m_reco_track_pid_bragg_likelihood_mu_plane0[i_trk] = pidScore_BL_mu_plane0;
706  vars.m_reco_track_pid_bragg_likelihood_mu_plane1[i_trk] = pidScore_BL_mu_plane1;
707  vars.m_reco_track_pid_bragg_likelihood_mu_plane2[i_trk] = pidScore_BL_mu_plane2;
708  vars.m_reco_track_pid_bragg_likelihood_p_plane0[i_trk] = pidScore_BL_p_plane0;
709  vars.m_reco_track_pid_bragg_likelihood_p_plane1[i_trk] = pidScore_BL_p_plane1;
710  vars.m_reco_track_pid_bragg_likelihood_p_plane2[i_trk] = pidScore_BL_p_plane2;
711  vars.m_reco_track_pid_bragg_likelihood_mip_plane0[i_trk] = pidScore_BL_mip_plane0;
712  vars.m_reco_track_pid_bragg_likelihood_mip_plane1[i_trk] = pidScore_BL_mip_plane1;
713  vars.m_reco_track_pid_bragg_likelihood_mip_plane2[i_trk] = pidScore_BL_mip_plane2;
714  vars.m_reco_track_pid_chi2_mu_plane0[i_trk] = pidScore_chi2_mu_plane0;
715  vars.m_reco_track_pid_chi2_mu_plane1[i_trk] = pidScore_chi2_mu_plane1;
716  vars.m_reco_track_pid_chi2_mu_plane2[i_trk] = pidScore_chi2_mu_plane2;
717  vars.m_reco_track_pid_chi2_p_plane0[i_trk] = pidScore_chi2_p_plane0;
718  vars.m_reco_track_pid_chi2_p_plane1[i_trk] = pidScore_chi2_p_plane1;
719  vars.m_reco_track_pid_chi2_p_plane2[i_trk] = pidScore_chi2_p_plane2;
720  vars.m_reco_track_pid_pida_plane0[i_trk] = pidScore_PIDA_plane0;
721  vars.m_reco_track_pid_pida_plane1[i_trk] = pidScore_PIDA_plane1;
722  vars.m_reco_track_pid_pida_plane2[i_trk] = pidScore_PIDA_plane2;
723  vars.m_reco_track_pid_three_plane_proton_pid[i_trk] = pidScore_three_plane_proton;
724 
725  }
726  return;
727  }
728 
729 
730 
731  //Analyze falshes
732  void AnalyzeFlashes(const std::vector<art::Ptr<recob::OpFlash>>& flashes, art::Handle<std::vector<sbn::crt::CRTHit>> crthit_h, double evt_timeGPS_nsec, std::map<art::Ptr<recob::OpFlash>, std::vector< art::Ptr<sbn::crt::CRTHit>>> crtvetoToFlashMap,
733  var_all& vars, para_all& paras){
734 
735 
736  for(auto pair: crtvetoToFlashMap){
737  std::cout<<"for flash at time "<< pair.first->Time()<<" has "<< pair.second.size() << " associated CRT hits "<<std::endl;
738  if(pair.second.size() > 0){
739  for (auto hit: pair.second){
740  std::cout<<"---- associated CRT hit at time "<<hit->ts0_ns/1000. <<" with PE "<<hit->peshit<<std::endl;
741  vars.m_CRT_veto_hit_PE.push_back(hit->peshit);
742  }
743 
744  }
745  vars.m_CRT_veto_nhits = pair.second.size();//save the number of associated CRT veto hits
746  }
747 
748 
749  if(g_is_verbose) std::cout<<"AnalyzeFlashes()\t||\t Beginning analysis of recob::OpFlash\n";
750 
751  size_t flash_size = flashes.size();
752  for(size_t i = 0; i < flash_size; ++i) {
753 
754  art::Ptr<recob::OpFlash> const & flash = flashes[i];
755 
756  vars.m_reco_flash_total_pe[i]=(flash->TotalPE());
757  vars.m_reco_flash_time[i]=(flash->Time());
758  vars.m_reco_flash_time_width[i]=flash->TimeWidth();
759  vars.m_reco_flash_abs_time[i]=flash->AbsTime();
760  vars.m_reco_flash_frame[i]=flash->Frame();
761  vars.m_reco_flash_ycenter[i]=flash->YCenter();
762  vars.m_reco_flash_ywidth[i]=flash->YWidth();
763  vars.m_reco_flash_zcenter[i]=flash->ZCenter();
764  vars.m_reco_flash_zwidth[i]=flash->ZWidth();
765 
766  // paras.s_beamgate_flash_end/paras.s_beamgate_flash_start are read from pset
767  if(vars.m_reco_flash_time[i] <= paras.s_beamgate_flash_end && vars.m_reco_flash_time[i] >= paras.s_beamgate_flash_start){
769  vars.m_reco_flash_total_pe_in_beamgate[i]=(flash->TotalPE());
770  vars.m_reco_flash_time_in_beamgate[i]=(flash->Time());
771  vars.m_reco_flash_ycenter_in_beamgate[i] = flash->YCenter();
772  vars.m_reco_flash_zcenter_in_beamgate[i] = flash->ZCenter();
773  }
774 
775  }
776 
777  if(g_is_verbose) std::cout<<"AnalyzeFlashes()\t||\t Finished. There was "<<flash_size<<" flashes with: "<<vars.m_reco_num_flashes_in_beamgate<<" in the beamgate defined by: "<<paras.s_beamgate_flash_start<<" <-> "<<paras.s_beamgate_flash_end<<std::endl;
778 
779  //fill these values only for events that have CRT information - run3 G and later
780  //code taken from ubcrt/UBCRTCosmicFilter/UBCRTCosmicFilter_module.cc
781  if(paras.s_runCRT){
782  if (vars.m_reco_num_flashes_in_beamgate == 1){ //fill only if there's a flash in the beamgate
783 
784  int _nCRThits_in_event = crthit_h->size();
785 
786  double _dt_abs = 100000.0;
787  // double _within_resolution = 0;
788  double _beam_flash_time = vars.m_reco_flash_time_in_beamgate[0]; // Guanqun: why use index 0?
789 
790  // Loop over the CRT hits.
791  for (int j = 0; j < _nCRThits_in_event; j++)
792  {
793  /*
794  if (verbose)
795  std::cout << "\t Time of the CRT Hit wrt the event timestamp = " << ((crthit_h->at(j).ts0_ns - evt_timeGPS_nsec + fDTOffset) / 1000.) << " us." << std::endl;
796  */
797  double _crt_time_temp = ((crthit_h->at(j).ts0_ns - evt_timeGPS_nsec + paras.s_DTOffset) / 1000.);
798 
799  // Fill the vector variables.
800  vars.m_CRT_hits_time.push_back(_crt_time_temp);
801  vars.m_CRT_hits_PE.push_back(crthit_h->at(j).peshit);
802  vars.m_CRT_hits_x.push_back(crthit_h->at(j).x_pos);
803  vars.m_CRT_hits_y.push_back(crthit_h->at(j).y_pos);
804  vars.m_CRT_hits_z.push_back(crthit_h->at(j).z_pos);
805 
806  if (fabs(_beam_flash_time - _crt_time_temp) < _dt_abs)
807  {
808  _dt_abs = fabs(_beam_flash_time - _crt_time_temp);
809  vars.m_CRT_dt = _beam_flash_time - _crt_time_temp;
810  vars.m_CRT_min_hit_time = _crt_time_temp;
811  // set 'within_resolution' to 'true' and break the loop if 'closest_crt_diff' is less than fResolution.
812  if (_dt_abs < paras.s_Resolution)
813  {
814  //_within_resolution = 1;
815  // Set the position information and the intensity of the CRT hit.
816  vars.m_CRT_min_hit_PE = crthit_h->at(j).peshit;
817  vars.m_CRT_min_hit_x = crthit_h->at(j).x_pos;
818  vars.m_CRT_min_hit_y = crthit_h->at(j).y_pos;
819  vars.m_CRT_min_hit_z = crthit_h->at(j).z_pos;
820 
821 
822  // if (verbose)
823  // {
824  std::cout << "CRT hit PE = " << vars.m_CRT_min_hit_PE << " PEs." << std::endl;
825  std::cout << "CRT hit x = " << vars.m_CRT_min_hit_x << " cm." << std::endl;
826  std::cout << "CRT hit y = " << vars.m_CRT_min_hit_y << " cm." << std::endl;
827  std::cout << "CRT hit z = " << vars.m_CRT_min_hit_z << " cm." << std::endl;
828  // }
829  break;
830  }
831  } // End of conditional for closest CRT hit time.
832  } // End of loop over CRT hits.
833  } //if there is 1 flash in beamgate
834  }//if runCRT
835  }//analyze flashes
836 
837 
838 
839 
840  //Analyze Showers
842  std::vector<PandoraPFParticle> all_PPFPs,
843  const std::vector<art::Ptr<recob::Shower>>& showers,
844  std::map<art::Ptr<recob::Cluster>, std::vector<art::Ptr<recob::Hit>> > & clusterToHitMap ,
845  double triggeroffset,
846  detinfo::DetectorPropertiesData const & theDetector,
847  var_all& vars,
848  para_all& paras){
849  // if(g_is_verbose) std::cout<<"AnalyzeShowers()\t||\t Begininning recob::Shower analysis suite"<<std::endl;;
850 
851  int i_shr = 0;
852 
853  std::vector<int> spacers = Printer_header({"Slice"," pfpID"," Start(x, "," y, "," z )"," trackscore"," pdg"});
854  for (ShowerVector::const_iterator iter = showers.begin(), iterEnd = showers.end(); iter != iterEnd; ++iter)
855  {
856 
857 
858  const art::Ptr<recob::Shower> shower = *iter;
859  // const art::Ptr<recob::PFParticle> pfp = showerToPFParticleMap[shower];
860  PandoraPFParticle* ppfp = PPFP_GetPPFPFromShower(all_PPFPs, shower);
861 
862  const art::Ptr<recob::PFParticle> pfp = ppfp->pPFParticle;
863 
864  art::Ptr<recob::Shower> shower3d;
865  vars.m_reco_shower3d_exists[i_shr] = 0;
866  shower3d = shower;
867 
868  const std::vector<art::Ptr<recob::Hit>> hits = ppfp->pPFPHits;
869  const std::vector<art::Ptr<recob::Cluster>> clusters = ppfp->pClusters;
870 
871  //int vars.m_shrid = shower->ID(); This is an used variable, always -999
872  double tem_length = shower->Length();
873  double tem_open_angle = shower->OpenAngle();
874 
875  TVector3 shr_start = shower->ShowerStart();
876  TVector3 shr_dir = shower->Direction();
877 
878  TVector3 shr3d_start = shower3d->ShowerStart();
879  TVector3 shr3d_dir = shower3d->Direction();
880 
881  // if(g_is_verbose) std::cout<<"AnalyzeShowers()\t||\t On Shower: "<<i_shr<<" which has length: "<<tem_length<<""<<std::endl;;
882 
883  vars.m_reco_shower_startx[i_shr] = shr_start.X();
884  vars.m_reco_shower_starty[i_shr] = shr_start.Y();
885  vars.m_reco_shower_startz[i_shr] = shr_start.Z();
886 
887 
888  std::vector<double> hstart = {vars.m_reco_shower_startx[i_shr],vars.m_reco_shower_starty[i_shr],vars.m_reco_shower_startz[i_shr]};
889  vars.m_reco_shower_start_dist_to_active_TPC[i_shr] = distToTPCActive(hstart, paras);
890  vars.m_reco_shower_start_dist_to_CPA[i_shr] = distToCPA(hstart, paras);
891  vars.m_reco_shower_start_in_SCB[i_shr] = distToSCB(vars.m_reco_shower_start_dist_to_SCB[i_shr],hstart, paras);
892 
893  vars.m_reco_shower_dirx[i_shr] = shr_dir.X();
894  vars.m_reco_shower_diry[i_shr] = shr_dir.Y();
895  vars.m_reco_shower_dirz[i_shr] = shr_dir.Z();
896  vars.m_reco_shower_length[i_shr] = tem_length;
897  vars.m_reco_shower_openingangle[i_shr] = tem_open_angle;
898 
899  vars.m_reco_shower3d_startx[i_shr] = shr3d_start.X();
900  vars.m_reco_shower3d_starty[i_shr] = shr3d_start.Y();
901  vars.m_reco_shower3d_startz[i_shr] = shr3d_start.Z();
902  vars.m_reco_shower3d_dirx[i_shr] = shr3d_dir.X();
903  vars.m_reco_shower3d_diry[i_shr] = shr3d_dir.Y();
904  vars.m_reco_shower3d_dirz[i_shr] = shr3d_dir.Z();
905  vars.m_reco_shower3d_length[i_shr] = shower3d->Length();
906  vars.m_reco_shower3d_openingangle[i_shr] = shower3d->OpenAngle();
907 
908 
909  vars.m_reco_shower_conversion_distance[i_shr] = sqrt( pow(shr_start.X()-vars.m_vertex_pos_x,2)+pow(shr_start.Y()-vars.m_vertex_pos_y,2)+ pow(shr_start.Z()-vars.m_vertex_pos_z,2) );
910  vars.m_reco_shower3d_conversion_distance[i_shr] = sqrt( pow(shr3d_start.X()-vars.m_vertex_pos_x,2)+pow(shr3d_start.Y()-vars.m_vertex_pos_y,2)+ pow(shr3d_start.Z()-vars.m_vertex_pos_z,2) );
911 
912  //pandroa shower
913  std::vector<double> shr_ts = {shr_start.X(), shr_start.Y(), shr_start.Z()};
914  std::vector<double> shr_te = {shr_start.X()-shr_dir.X(),shr_start.Y()-shr_dir.Y(),shr_start.Z()-shr_dir.Z()};
915  std::vector<double> shr_tv = {vars.m_vertex_pos_x,vars.m_vertex_pos_y,vars.m_vertex_pos_z};
916 
917  vars.m_reco_shower_impact_parameter[i_shr] = dist_line_point(shr_ts,shr_te,shr_tv );
918  vars.m_reco_shower_implied_dirx[i_shr] = shr_start.X()-vars.m_vertex_pos_x;;
919  vars.m_reco_shower_implied_diry[i_shr] = shr_start.Y()-vars.m_vertex_pos_y;
920  vars.m_reco_shower_implied_dirz[i_shr] = shr_start.Z()-vars.m_vertex_pos_z;
921 
922  double norm = sqrt(pow(vars.m_reco_shower_implied_dirx[i_shr],2)+pow(vars.m_reco_shower_implied_diry[i_shr],2)+pow(vars.m_reco_shower_implied_dirz[i_shr],2));
926 
927  //now 3D shower
928  std::vector<double> shr3d_ts = {shr3d_start.X(), shr3d_start.Y(), shr3d_start.Z()};
929  std::vector<double> shr3d_te = {shr3d_start.X()-shr3d_dir.X(),shr3d_start.Y()-shr3d_dir.Y(),shr3d_start.Z()-shr3d_dir.Z()};
930  std::vector<double> shr3d_tv = {vars.m_vertex_pos_x,vars.m_vertex_pos_y,vars.m_vertex_pos_z};
931 
932  vars.m_reco_shower3d_impact_parameter[i_shr] = dist_line_point(shr3d_ts,shr3d_te,shr3d_tv );
933  vars.m_reco_shower3d_implied_dirx[i_shr] = shr3d_start.X()-vars.m_vertex_pos_x;;
934  vars.m_reco_shower3d_implied_diry[i_shr] = shr3d_start.Y()-vars.m_vertex_pos_y;
935  vars.m_reco_shower3d_implied_dirz[i_shr] = shr3d_start.Z()-vars.m_vertex_pos_z;
936 
937  double shr3d_norm = sqrt(pow(vars.m_reco_shower3d_implied_dirx[i_shr],2)+pow(vars.m_reco_shower3d_implied_diry[i_shr],2)+pow(vars.m_reco_shower3d_implied_dirz[i_shr],2));
938  vars.m_reco_shower3d_implied_dirx[i_shr] = vars.m_reco_shower3d_implied_dirx[i_shr]/shr3d_norm;
939  vars.m_reco_shower3d_implied_diry[i_shr] = vars.m_reco_shower3d_implied_diry[i_shr]/shr3d_norm;
940  vars.m_reco_shower3d_implied_dirz[i_shr] = vars.m_reco_shower3d_implied_dirz[i_shr]/shr3d_norm;
941 
942 
943  vars.m_reco_shower_theta_yz[i_shr] = atan2(vars.m_reco_shower_diry[i_shr],vars.m_reco_shower_dirz[i_shr]);
944  vars.m_reco_shower_phi_yx[i_shr] = atan2(vars.m_reco_shower_diry[i_shr],vars.m_reco_shower_dirx[i_shr]);
945 
946  vars.m_reco_shower3d_theta_yz[i_shr] = atan2(vars.m_reco_shower3d_diry[i_shr],vars.m_reco_shower3d_dirz[i_shr]);
947  vars.m_reco_shower3d_phi_yx[i_shr] = atan2(vars.m_reco_shower3d_diry[i_shr],vars.m_reco_shower3d_dirx[i_shr]);
948 
949 
950  // vars.m_reco_shower_start_to_nearest_dead_wire_plane0[i_shr] = distanceToNearestDeadWire(0, vars.m_reco_shower_starty[i_shr], vars.m_reco_shower_startz[i_shr],geom, bad_channel_list_fixed_mcc9);
951  // vars.m_reco_shower_start_to_nearest_dead_wire_plane1[i_shr] = distanceToNearestDeadWire(1, vars.m_reco_shower_starty[i_shr], vars.m_reco_shower_startz[i_shr],geom, bad_channel_list_fixed_mcc9);
952  // vars.m_reco_shower_start_to_nearest_dead_wire_plane2[i_shr] = distanceToNearestDeadWire(2, vars.m_reco_shower_starty[i_shr], vars.m_reco_shower_startz[i_shr],geom, bad_channel_list_fixed_mcc9);
953  std::vector<int> t_num(3,0); // num of triangles on each plane
954  std::vector<int> t_numhits(3,0); // num of hits on each plane
955  std::vector<double> t_area(3,0.0);
956 
957  //Right, this basically loops over all hits in all planes and for each plane forms the Delaunay triangilization of it and calculates the 2D area inscribed by the convex hull
958  // if(g_is_verbose) std::cout<<"AnalyzeShowers()\t||\t Starting Delaunay Triangleization"<<std::endl;;
959 
960  //auto start = std::chrono::high_resolution_clock::now();
961  delaunay_hit_wrapper(hits, t_numhits, t_num, t_area, paras);
962 
963  //auto finish = std::chrono::high_resolution_clock::now();
964  //auto microseconds = std::chrono::duration_cast<std::chrono::milliseconds>(finish-start);
965  //if(g_is_verbose) std::cout<<"AnalyzeShowers()\t||\t Finished Delaunay Triangleization. It took "<< microseconds.count() << "ms and found "<<t_num[0]+t_num[1]+t_num[2]<<" triangles"<<std::endl;;
966 
967  vars.m_reco_shower_delaunay_num_triangles_plane0[i_shr] = t_num[0];
968  vars.m_reco_shower_delaunay_num_triangles_plane1[i_shr] = t_num[1];
969  vars.m_reco_shower_delaunay_num_triangles_plane2[i_shr] = t_num[2];
970 
971  vars.m_reco_shower_delaunay_area_plane0[i_shr] = t_area[0];
972  vars.m_reco_shower_delaunay_area_plane1[i_shr] = t_area[1];
973  vars.m_reco_shower_delaunay_area_plane2[i_shr] = t_area[2];
974 
975  vars.m_reco_shower_num_hits_plane0[i_shr] = t_numhits[0];
976  vars.m_reco_shower_num_hits_plane1[i_shr] = t_numhits[1];
977  vars.m_reco_shower_num_hits_plane2[i_shr] = t_numhits[2];
978  //-------------- Calorimetry 3D --------------------
979 
980 
981  const std::vector< double > shr3d_energy = shower3d->Energy();
982  const std::vector< double > shr3d_dEdx = shower3d->dEdx();
983  //const int shr3d_bestplane = shower3d->best_plane();
984 
985  // std::cout<<"SHOWER3D_ENERGY: best plane: "<<shr3d_bestplane<<std::endl;
986  //for(auto &en:shr3d_energy){
987  // std::cout<<en<<" ";
988  //}
989  if(shr3d_energy.size()==3){
990  vars.m_reco_shower3d_energy_plane0[i_shr] = shr3d_energy[0];
991  vars.m_reco_shower3d_energy_plane1[i_shr] = shr3d_energy[1];
992  vars.m_reco_shower3d_energy_plane2[i_shr] = shr3d_energy[2];
993  }else{
994  vars.m_reco_shower3d_energy_plane0[i_shr] =-99;
995  vars.m_reco_shower3d_energy_plane1[i_shr] =-99;
996  vars.m_reco_shower3d_energy_plane2[i_shr] =-999;
997  }
998 
999  // std::cout<<std::endl<<"SHOWER3D_DEDX: "<<std::endl;
1000  //for(auto &dedx: shr3d_dEdx){
1001  // std::cout<<dedx<<" ";
1002  //}
1003  if(shr3d_dEdx.size()==3){
1004  vars.m_reco_shower3d_dEdx_plane0[i_shr] = shr3d_dEdx[0];
1005  vars.m_reco_shower3d_dEdx_plane1[i_shr] = shr3d_dEdx[1];
1006  vars.m_reco_shower3d_dEdx_plane2[i_shr] = shr3d_dEdx[2];
1007  }else{
1008  vars.m_reco_shower3d_dEdx_plane0[i_shr] =-99;
1009  vars.m_reco_shower3d_dEdx_plane1[i_shr] =-99;
1010  vars.m_reco_shower3d_dEdx_plane2[i_shr] =-999;
1011  }
1012 
1013 
1014  //------------- calorimetry ------------
1015  vars.m_reco_shower_energy_plane0[i_shr] = CalcEShowerPlane(hits, 0, paras);
1016  vars.m_reco_shower_energy_plane1[i_shr] = CalcEShowerPlane(hits, 1, paras);
1017  vars.m_reco_shower_energy_plane2[i_shr] = CalcEShowerPlane(hits, 2, paras);
1018 
1019  vars.m_reco_shower_energy_max[i_shr] = std::max( vars.m_reco_shower_energy_plane0[i_shr], std::max( vars.m_reco_shower_energy_plane1[i_shr] , vars.m_reco_shower_energy_plane2[i_shr]));
1020 
1021  vars.m_reco_shower_plane0_nhits[i_shr] = getNHitsPlane(hits, 0);
1022  vars.m_reco_shower_plane1_nhits[i_shr] = getNHitsPlane(hits, 1);
1023  vars.m_reco_shower_plane2_nhits[i_shr] = getNHitsPlane(hits, 2);
1024 
1025  vars.m_reco_shower_plane0_meanRMS[i_shr] = getMeanHitWidthPlane(hits, 0);
1026  vars.m_reco_shower_plane1_meanRMS[i_shr] = getMeanHitWidthPlane(hits, 1);
1027  vars.m_reco_shower_plane2_meanRMS[i_shr] = getMeanHitWidthPlane(hits, 2);
1028 
1029 
1030  //currently only run on 1 shower events
1031  if(showers.size()==1){
1032  for(auto &h: hits){
1033 
1034  int plane= h->View();
1035  int wire = h->WireID().Wire;
1036  int tick = h->PeakTime();
1037 
1038  vars.m_reco_shower_hit_tick.push_back(tick);
1039  vars.m_reco_shower_hit_plane.push_back(plane);
1040  vars.m_reco_shower_hit_wire.push_back(wire);
1041  }
1042  }
1043 
1044 
1045  //std::cout<<"The energy on each plane is 0: "<< vars.m_reco_shower_energy_plane0[i_shr]<<", 1: "<< vars.m_reco_shower_energy_plane1[i_shr]<<", 2: "<< vars.m_reco_shower_energy_plane2[i_shr]<<std::endl;
1046 
1047 
1048  vars.m_reco_shower_dQdx_plane0[i_shr] = CalcdQdxShower(shower,clusters, clusterToHitMap, 0 , triggeroffset, theDetector, paras);
1049  vars.m_reco_shower_dQdx_plane1[i_shr] = CalcdQdxShower(shower,clusters, clusterToHitMap, 1 , triggeroffset, theDetector, paras);
1050  vars.m_reco_shower_dQdx_plane2[i_shr] = CalcdQdxShower(shower,clusters, clusterToHitMap, 2 , triggeroffset, theDetector, paras);
1051  vars.m_reco_shower_dEdx_plane0[i_shr] = CalcdEdxFromdQdx(vars.m_reco_shower_dQdx_plane0[i_shr], paras);
1052  vars.m_reco_shower_dEdx_plane1[i_shr] = CalcdEdxFromdQdx(vars.m_reco_shower_dQdx_plane1[i_shr], paras);
1053 
1054  vars.m_reco_shower_dEdx_plane2[i_shr] = CalcdEdxFromdQdx(vars.m_reco_shower_dQdx_plane2[i_shr], paras);
1055 
1059 
1060 
1061  std::vector< double > reco_shr_angles_wrt_wires;
1062  for (geo::PlaneGeo const& plane: paras.s_geom->IteratePlanes()) {
1063  //6 planes in SBND
1064  //WireAngleToVertical : 30 ,150,90,150,30 ,90
1065  //ub wire angles : 30 ,150,90 (respected to beam,z)
1066  //Pitch : 0.3,0.3,0.3,0.3,0.3,0.3
1067 
1068  const double angToVert(paras.s_geom->WireAngleToVertical(plane.View(), plane.ID())+0.5*M_PI);//wire angle respected to z + pi/2
1069 
1070  TVector3 wire_vector;
1071  if(abs(angToVert) < 1e-9 ){
1072  wire_vector = {0,0,1};
1073  } else{
1074  wire_vector = { 0 , sin(angToVert) ,cos(angToVert) };
1075  }
1076 
1077  // std::cout<<" Angle "<<angToVert<<" Get Vec y="<<wire_vector[1]<< " z= "<<wire_vector[2]<<std::endl;
1078  reco_shr_angles_wrt_wires.push_back( abs(0.5*M_PI-acos(wire_vector.Dot(shr_dir))) );
1079 
1080  if(reco_shr_angles_wrt_wires.size()==3) break;
1081  }
1082  vars.m_reco_shower_angle_wrt_wires_plane0[i_shr] = reco_shr_angles_wrt_wires[0];
1083  vars.m_reco_shower_angle_wrt_wires_plane1[i_shr] = reco_shr_angles_wrt_wires[1];
1084  vars.m_reco_shower_angle_wrt_wires_plane2[i_shr] = reco_shr_angles_wrt_wires[2];
1085 
1089 
1090 
1091 
1092  vars.m_reco_shower_dEdx_plane0_mean[i_shr] = std::accumulate(vars.m_reco_shower_dEdx_plane0[i_shr].begin(), vars.m_reco_shower_dEdx_plane0[i_shr].end(), 0.0)/((double)vars.m_reco_shower_dEdx_plane0[i_shr].size());
1093  vars.m_reco_shower_dEdx_plane1_mean[i_shr] = std::accumulate(vars.m_reco_shower_dEdx_plane1[i_shr].begin(), vars.m_reco_shower_dEdx_plane1[i_shr].end(), 0.0)/((double)vars.m_reco_shower_dEdx_plane1[i_shr].size());
1094  vars.m_reco_shower_dEdx_plane2_mean[i_shr] = std::accumulate(vars.m_reco_shower_dEdx_plane2[i_shr].begin(), vars.m_reco_shower_dEdx_plane2[i_shr].end(), 0.0)/((double)vars.m_reco_shower_dEdx_plane2[i_shr].size());
1095 
1096  auto maxp0 = std::max_element(vars.m_reco_shower_dEdx_plane0[i_shr].begin(), vars.m_reco_shower_dEdx_plane0[i_shr].end());
1097  auto maxp1 = std::max_element(vars.m_reco_shower_dEdx_plane1[i_shr].begin(), vars.m_reco_shower_dEdx_plane1[i_shr].end());
1098  auto maxp2 = std::max_element(vars.m_reco_shower_dEdx_plane2[i_shr].begin(), vars.m_reco_shower_dEdx_plane2[i_shr].end());
1099  auto minp0 = std::min_element(vars.m_reco_shower_dEdx_plane0[i_shr].begin(), vars.m_reco_shower_dEdx_plane0[i_shr].end());
1100  auto minp1 = std::min_element(vars.m_reco_shower_dEdx_plane1[i_shr].begin(), vars.m_reco_shower_dEdx_plane1[i_shr].end());
1101  auto minp2 = std::min_element(vars.m_reco_shower_dEdx_plane2[i_shr].begin(), vars.m_reco_shower_dEdx_plane2[i_shr].end());
1102 
1103 
1104  if(maxp0 == vars.m_reco_shower_dEdx_plane0[i_shr].end()){
1105  vars.m_reco_shower_dEdx_plane0_max[i_shr] = -999;
1106  }else{
1107  vars.m_reco_shower_dEdx_plane0_max[i_shr] = *maxp0;
1108  }
1109 
1110  if(maxp1 == vars.m_reco_shower_dEdx_plane1[i_shr].end()){
1111  vars.m_reco_shower_dEdx_plane1_max[i_shr] = -999;
1112  }else{
1113  vars.m_reco_shower_dEdx_plane1_max[i_shr] = *maxp1;
1114  }
1115 
1116  if(maxp2 == vars.m_reco_shower_dEdx_plane2[i_shr].end()){
1117  vars.m_reco_shower_dEdx_plane2_max[i_shr] = -999;
1118  }else{
1119  vars.m_reco_shower_dEdx_plane2_max[i_shr] = *maxp2;
1120  }
1121 
1122 
1123  if(minp0 == vars.m_reco_shower_dEdx_plane0[i_shr].end()){
1124  vars.m_reco_shower_dEdx_plane0_min[i_shr] = -999;
1125  }else{
1126  vars.m_reco_shower_dEdx_plane0_min[i_shr] = *minp0;
1127  }
1128 
1129  if(minp1 == vars.m_reco_shower_dEdx_plane1[i_shr].end()){
1130  vars.m_reco_shower_dEdx_plane1_min[i_shr] = -999;
1131  }else{
1132  vars.m_reco_shower_dEdx_plane1_min[i_shr] = *minp1;
1133  }
1134 
1135  if(minp2 == vars.m_reco_shower_dEdx_plane2[i_shr].end()){
1136  vars.m_reco_shower_dEdx_plane2_min[i_shr] = -999;
1137  }else{
1138  vars.m_reco_shower_dEdx_plane2_min[i_shr] = *minp2;
1139  }
1140 
1141 
1142  vars.m_reco_shower_dEdx_plane0_nhits[i_shr] = vars.m_reco_shower_dEdx_plane0[i_shr].size();
1143  vars.m_reco_shower_dEdx_plane1_nhits[i_shr] = vars.m_reco_shower_dEdx_plane1[i_shr].size();
1144  vars.m_reco_shower_dEdx_plane2_nhits[i_shr] = vars.m_reco_shower_dEdx_plane2[i_shr].size();
1145 
1150  vars.m_reco_shower_dEdx_plane0_median[i_shr],
1151  vars.m_reco_shower_dEdx_plane1_median[i_shr],
1153  vars.m_reco_shower_dEdx_plane0_nhits[i_shr],
1154  vars.m_reco_shower_dEdx_plane1_nhits[i_shr],
1155  vars.m_reco_shower_dEdx_plane2_nhits[i_shr] );
1156 
1158  vars.m_reco_shower_dEdx_amalgamated[i_shr],
1159  vars.m_reco_shower_dEdx_plane0_median[i_shr],
1160  vars.m_reco_shower_dEdx_plane1_median[i_shr],
1162  vars.m_reco_shower_dEdx_plane0_nhits[i_shr],
1163  vars.m_reco_shower_dEdx_plane1_nhits[i_shr],
1164  vars.m_reco_shower_dEdx_plane2_nhits[i_shr] );
1165 
1166  //-------------- Flashes : Was there a flash in the beavars.m_time and if so was it near in Z? --------------------
1167  double zmin = vars.m_reco_shower_startz[i_shr];
1168  double zmax = zmin + vars.m_reco_shower_dirz[i_shr]*vars.m_reco_shower_length[i_shr];
1169  if(zmin > zmax) std::swap(zmin, zmax);
1170 
1171  double ymin = vars.m_reco_shower_starty[i_shr];
1172  double ymax = zmin + vars.m_reco_shower_diry[i_shr]*vars.m_reco_shower_length[i_shr];
1173  if(ymin > ymax) std::swap(ymin, ymax);
1174 
1175  //Code property of Gray Yarbrough (all rights reserved)
1176  //int optical_flash_in_beamgate_counter=0;
1177  double shortest_dist_to_flash_z=DBL_MAX;
1178  double shortest_dist_to_flash_y=DBL_MAX;
1179  double shortest_dist_to_flash_yz=DBL_MAX;
1180  //-999 my nonsenese int can change
1181  int shortest_dist_to_flash_index_z=-999;
1182  int shortest_dist_to_flash_index_y=-999;
1183  int shortest_dist_to_flash_index_yz=-999;
1184 
1185  // if(g_is_verbose) std::cout<<"AnalyzeShowers()\t||\tnumber of flashes: "<< vars.m_reco_num_flashes<< ""<<std::endl;;
1186  for(int i_flash = 0; i_flash < vars.m_reco_num_flashes; ++i_flash) {
1187 
1188  double const zcenter=vars.m_reco_flash_zcenter[i_flash];
1189  // if(g_is_verbose) std::cout<< "AnalyzeShowers()\t||\tflash z center:" <<vars.m_reco_flash_zcenter[i_flash]<< ""<<std::endl;;
1190  double const ycenter=vars.m_reco_flash_ycenter[i_flash];
1191  // if(g_is_verbose) std::cout<< "AnaluzeShowers()\t||\tflash y center:" <<vars.m_reco_flash_ycenter[i_flash]<< ""<<std::endl;;
1192 
1193  //z plane
1194  double dist_z=DBL_MAX;
1195  if(zcenter < zmin) {
1196  dist_z = zmin - zcenter;
1197  }
1198  else if(zcenter > zmax) {
1199  dist_z = zcenter - zmax;
1200  }
1201  else {
1202  dist_z = 0;
1203  }
1204  if(dist_z < shortest_dist_to_flash_z){
1205  shortest_dist_to_flash_z = dist_z;
1206  shortest_dist_to_flash_index_z=i_flash;
1207  }
1208 
1209 
1210  //y plane
1211 
1212  double dist_y=DBL_MAX;
1213  if(ycenter < ymin) {
1214  dist_y = ymin - ycenter;
1215  }
1216  else if(ycenter > ymax) {
1217  dist_y = ycenter - ymax;
1218  }
1219  else {
1220  dist_y= 0;
1221  }
1222  if(dist_y < shortest_dist_to_flash_y){
1223  shortest_dist_to_flash_y = dist_y;
1224  shortest_dist_to_flash_index_y=i_flash;
1225  }
1226 
1227  double dist_yz=DBL_MAX;
1228  dist_yz=std::sqrt(dist_y*dist_y+dist_z*dist_z);
1229  if(dist_yz<shortest_dist_to_flash_yz){
1230  shortest_dist_to_flash_yz = dist_yz;
1231  shortest_dist_to_flash_index_yz=i_flash;
1232  }
1233 
1234  }
1235 
1236 
1237  //assume setting to nonsense value
1238  if(vars.m_reco_num_flashes_in_beamgate == 0) shortest_dist_to_flash_z = -2;
1239  vars.m_reco_shower_flash_shortest_distz[i_shr]=shortest_dist_to_flash_z;
1240  vars.m_reco_shower_flash_shortest_index_z[i_shr]=shortest_dist_to_flash_index_z;
1241 
1242  if(vars.m_reco_num_flashes_in_beamgate == 0) shortest_dist_to_flash_y = -2;
1243  vars.m_reco_shower_flash_shortest_disty[i_shr]=shortest_dist_to_flash_y;
1244  vars.m_reco_shower_flash_shortest_index_y[i_shr]=shortest_dist_to_flash_index_y;
1245  vars.m_reco_shower_flash_shortest_distyz[i_shr]=shortest_dist_to_flash_yz;
1246  vars.m_reco_shower_flash_shortest_index_yz[i_shr]=shortest_dist_to_flash_index_yz;
1247  if(vars.m_reco_num_flashes_in_beamgate == 0) shortest_dist_to_flash_yz = -2;
1248 
1249  //end optical flash code
1250 
1251 
1252  vars.m_reco_shower_num_daughters[i_shr] = pfp->NumDaughters(); //corresponding PFParticle
1253  // std::cout<<" CHECK numebr "<<vars.m_reco_shower_num_daughters[i_shr]<<std::endl;
1254  if(vars.m_reco_shower_num_daughters[i_shr]>0){
1255  //currently just look at 1 daughter
1256  //vars.m_reco_shower_daughter_trackscore[i_shr] = PFPToTrackScoreMap[pfParticleMap[pfp->Daughters().front()]];
1257  int pfp_size = all_PPFPs.size();
1258  for(int index = 0; index < pfp_size; index++){
1259  // std::cout<<"CHECK Compare "<<pfp->Daughters().front()<<
1260  // " "<<all_PPFPs[index].pPFParticle->Self()<<std::endl;
1261  if( (pfp->Daughters().front()) == all_PPFPs[index].pPFParticle->Self()){
1262  vars.m_reco_shower_daughter_trackscore[i_shr] = all_PPFPs[index].get_TrackScore();
1263  break;
1264  }
1265  }
1266  }
1267 
1268 
1269  //------------and finally some slice info-----------------
1270 
1271  vars.m_reco_shower_sliceId[i_shr] = ppfp->get_SliceID();//PFPToSliceIdMap[pfp];
1272  vars.m_reco_shower_nuscore[i_shr] = ppfp->get_NuScore();//sliceIdToNuScoreMap[ vars.m_reco_shower_sliceId[i_shr]] ;
1273  vars.m_reco_shower_isclearcosmic[i_shr] = ppfp->get_IsClearCosmic();//PFPToClearCosmicMap[pfp];
1274  vars.m_reco_shower_is_nuslice[i_shr] = ppfp->get_IsNuSlice();//PFPToNuSliceMap[pfp];
1275 
1276  vars.m_reco_shower_trackscore[i_shr] = ppfp->get_TrackScore();
1277  vars.m_reco_shower_pfparticle_pdg[i_shr] = ppfp->get_PdgCode();
1278 
1279  // if ( vars.m_reco_shower_sliceId[i_shr] >0) std::cout<<"AnalyzeShowers()\t||\t On Shower: "<<i_shr<<". Pfp id = "<< pfp->Self()<<". The slice id for this shower is "<< vars.m_reco_shower_sliceId[i_shr]<<", the neutrino score for this slice is "<< vars.m_reco_shower_nuscore[i_shr]<<", and is_nuslice = "<< vars.m_reco_shower_is_nuslice[i_shr]<<". The track score is : "<< vars.m_reco_shower_trackscore[i_shr]<<std::endl;
1280 
1281  i_shr++;
1282 
1283  //std::vector<int> spacers = Printer_header({"Slice","pfpID","Start(x, "," y, ",", z )", "trackScore", "Pdg"});
1285  {std::to_string(ppfp->get_SliceID()),
1287  std::to_string(shr_start.X()),
1288  std::to_string(shr_start.Y()),
1289  std::to_string(shr_start.Z()),
1290  std::to_string(ppfp->get_TrackScore()),
1291  std::to_string(ppfp->get_PdgCode())
1292  },spacers);
1293 
1294  }
1295 
1296  //Lets sort and order the showers
1298  }
1299 }
std::vector< double > m_reco_shower_dEdx_plane1_max
Definition: variables.h:1023
void AnalyzeTrackCalo(const std::vector< art::Ptr< recob::Track >> &tracks, std::vector< PandoraPFParticle > all_PPFPs, var_all &vars, para_all &paras)
std::vector< double > m_reco_shower_dEdx_plane2_min
Definition: variables.h:1027
std::vector< int > m_reco_shower_flash_shortest_index_yz
Definition: variables.h:822
std::vector< double > m_reco_flash_zcenter
Definition: variables.h:407
std::vector< double > m_reco_track_spacepoint_chi
Definition: variables.h:612
std::vector< double > CalcdEdxFromdQdx(std::vector< double > dqdx, para_all &paras)
Definition: Processors.cxx:342
std::vector< int > m_reco_shower_hit_plane
Definition: variables.h:1007
std::vector< double > m_reco_track_spacepoint_principal2
Definition: variables.h:610
std::vector< int > m_reco_track_pfparticle_pdg
Definition: variables.h:684
void setRadius(const double &rad)
Set the smearing radius over which to take hits for truncated mean computaton.
std::vector< double > m_reco_track_mean_dEdx_best_plane
Definition: variables.h:633
std::vector< double > m_reco_track_spacepoint_principal0
Definition: variables.h:608
std::vector< double > m_reco_shower_nuscore
Definition: variables.h:836
std::vector< double > m_reco_track_pid_bragg_likelihood_mu_plane0
Definition: variables.h:1044
std::vector< double > m_reco_track_mean_trunc_dEdx_start_half_p1
Definition: variables.h:657
std::vector< double > m_reco_shower_theta_yz
Definition: variables.h:794
std::vector< std::vector< double > > m_reco_track_trunc_dEdx_p0
Definition: variables.h:623
std::vector< int > m_reco_shower_num_hits_plane2
Definition: variables.h:831
std::vector< bool > m_reco_shower_isclearcosmic
Definition: variables.h:837
std::vector< double > m_reco_track_pid_chi2_mu_plane0
Definition: variables.h:1056
std::vector< double > m_reco_shower_plane0_nhits
Definition: variables.h:1000
std::vector< int > m_reco_shower_delaunay_num_triangles_plane0
Definition: variables.h:806
ClusterModuleLabel join with tracks
int getNHitsPlane(std::vector< art::Ptr< recob::Hit >> hits, int this_plane)
Definition: Processors.cxx:472
std::vector< double > m_reco_track_calo_energy_max
Definition: variables.h:596
std::vector< double > m_reco_shower_startz
Definition: variables.h:783
std::vector< art::Ptr< recob::Cluster > > pClusters
std::vector< double > m_reco_flash_total_pe_in_beamgate
Definition: variables.h:409
IteratorBox< plane_iterator,&GeometryCore::begin_plane,&GeometryCore::end_plane > IteratePlanes() const
Enables ranged-for loops on all planes of the detector.
process_name opflash particleana ie x
std::vector< double > m_reco_track_pid_bragg_likelihood_mu_plane2
Definition: variables.h:1046
std::vector< double > m_reco_track_mean_trunc_dEdx_best_plane
Definition: variables.h:637
void CalcTruncMeanProfile(const std::vector< double > &rr_v, const std::vector< double > &dq_v, std::vector< double > &dq_trunc_v, const double &nsigma=1)
Given residual range and dq vectors return truncated local dq. Input vectors are assumed to be match ...
std::vector< double > m_reco_track_pid_chi2_p_plane2
Definition: variables.h:1061
int getAmalgamateddEdxNHits(double amalgamateddEdx, double median_plane0, double median_plane1, double median_plane2, int plane0_nhits, int plane1_nhits, int plane2_nhits)
std::vector< double > m_reco_shower_plane1_nhits
Definition: variables.h:1001
std::vector< double > m_reco_track_end_dist_to_SCB
Definition: variables.h:589
std::vector< double > m_reco_shower_dEdx_plane2_nhits
Definition: variables.h:1041
std::vector< double > m_reco_shower3d_implied_dirz
Definition: variables.h:769
std::vector< std::vector< double > > m_reco_track_dEdx_p1
Definition: variables.h:628
std::vector< double > m_reco_shower_impact_parameter
Definition: variables.h:801
std::vector< double > m_reco_shower_dEdx_plane1_min
Definition: variables.h:1026
std::vector< double > m_reco_track_trunc_PIDA_p0
Definition: variables.h:650
std::vector< double > m_reco_track_pid_bragg_likelihood_p_plane2
Definition: variables.h:1049
std::vector< double > m_reco_track_daughter_trackscore
Definition: variables.h:574
std::vector< double > m_reco_shower_dEdx_plane1_nhits
Definition: variables.h:1040
std::vector< double > m_reco_track_mean_trunc_dEdx_end_half_p0
Definition: variables.h:649
std::vector< int > m_reco_track_good_calo_p0
Definition: variables.h:646
std::vector< double > m_reco_track_startx
Definition: variables.h:579
std::vector< double > m_reco_shower_dEdx_plane0_nhits
Definition: variables.h:1039
std::vector< std::vector< double > > m_reco_shower_dEdx_plane0
Definition: variables.h:1016
pdgs p
Definition: selectors.fcl:22
std::vector< int > m_reco_shower_delaunay_num_triangles_plane2
Definition: variables.h:808
std::vector< int > m_reco_track_good_calo_p1
Definition: variables.h:655
std::vector< int > m_reco_shower_flash_shortest_index_y
Definition: variables.h:821
std::vector< double > m_reco_shower_dQdx_plane0_median
Definition: variables.h:1036
std::vector< double > m_reco_shower3d_energy_plane1
Definition: variables.h:772
std::vector< double > m_reco_shower_implied_dirx
Definition: variables.h:802
std::vector< double > m_reco_shower_flash_shortest_disty
Definition: variables.h:817
std::vector< double > m_reco_track_pid_chi2_p_plane1
Definition: variables.h:1060
std::vector< int > m_reco_shower_num_daughters
Definition: variables.h:749
std::vector< double > m_reco_track_theta_yz
Definition: variables.h:598
double s_track_calo_trunc_fraction
Definition: variables.h:157
std::vector< double > m_CRT_hits_y
Definition: variables.h:560
std::vector< double > m_reco_track_mean_trunc_dEdx_end_half_best_plane
Definition: variables.h:639
std::vector< std::vector< double > > m_reco_shower_dQdx_plane1
Definition: variables.h:1014
std::vector< double > m_reco_track_end_dist_to_active_TPC
Definition: variables.h:585
art::Ptr< recob::PFParticle > pPFParticle
std::vector< int > m_reco_track_best_calo_plane
Definition: variables.h:632
std::vector< size_t > sort_indexes(const std::vector< T > &v)
Definition: helper_math.h:20
std::vector< double > m_reco_track_phi_yx
Definition: variables.h:599
std::vector< int > m_reco_track_num_calo_hits_p2
Definition: variables.h:674
std::vector< double > m_reco_track_pid_chi2_mu_plane2
Definition: variables.h:1058
const std::vector< art::Ptr< anab::Calorimetry > > get_Calorimetries() const
std::vector< double > m_reco_shower_dEdx_plane2_median
Definition: variables.h:1030
std::vector< std::vector< double > > m_reco_track_dEdx_p2
Definition: variables.h:670
std::vector< int > m_reco_track_num_daughters
Definition: variables.h:573
std::vector< double > m_reco_shower3d_startz
Definition: variables.h:755
std::vector< double > m_reco_track_trunc_PIDA_best_plane
Definition: variables.h:640
std::vector< double > m_reco_shower3d_dEdx_plane2
Definition: variables.h:777
process_name use argoneut_mc_hitfinder track
std::vector< int > m_reco_shower_delaunay_num_triangles_plane1
Definition: variables.h:807
std::vector< std::vector< double > > m_reco_track_dEdx_best_plane
Definition: variables.h:622
int delaunay_hit_wrapper(const std::vector< art::Ptr< recob::Hit >> &hits, std::vector< int > &num_hits, std::vector< int > &num_triangles, std::vector< double > &area, para_all &paras)
Definition: Processors.cxx:520
std::vector< double > m_reco_shower_dQdx_plane2_median
Definition: variables.h:1038
process_name hit
Definition: cheaterreco.fcl:51
std::vector< double > m_reco_track_mean_dEdx_p0
Definition: variables.h:643
std::vector< double > m_reco_track_diry
Definition: variables.h:577
float fValue
Result of Particle ID algorithm/test.
Definition: ParticleID.h:28
std::vector< std::vector< double > > m_reco_track_resrange_p1
Definition: variables.h:627
std::vector< double > m_reco_shower3d_phi_yx
Definition: variables.h:760
double dist_line_point(std::vector< double > &X1, std::vector< double > &X2, std::vector< double > &point)
Definition: helper_math.cxx:8
std::vector< double > m_reco_shower3d_energy_plane0
Definition: variables.h:771
std::vector< double > m_reco_flash_time
Definition: variables.h:401
std::vector< std::vector< double > > m_reco_track_resrange_p0
Definition: variables.h:624
std::vector< bool > m_reco_shower_is_nuslice
Definition: variables.h:838
std::vector< double > m_reco_track_pid_bragg_likelihood_mip_plane0
Definition: variables.h:1050
std::vector< double > m_reco_track_mean_dEdx_start_half_p0
Definition: variables.h:644
std::vector< double > m_reco_track_pid_chi2_p_plane0
Definition: variables.h:1059
std::vector< double > m_reco_track_mean_dEdx_end_half_p1
Definition: variables.h:654
const art::Ptr< anab::ParticleID > get_ParticleID() const
process_name shower
Definition: cheaterreco.fcl:51
std::vector< double > m_reco_track_dirz
Definition: variables.h:578
std::vector< double > m_reco_shower_delaunay_area_plane2
Definition: variables.h:834
std::vector< double > m_reco_track_mean_dEdx_end_half_best_plane
Definition: variables.h:635
std::vector< int > m_reco_flash_frame
Definition: variables.h:404
std::vector< double > m_reco_shower_startx
Definition: variables.h:781
std::vector< double > m_reco_track_starty
Definition: variables.h:580
std::bitset< 8 > fPlaneMask
Bitset for PlaneID used by algorithm, allowing for multiple planes and up to 8 total planes...
Definition: ParticleID.h:29
std::vector< double > m_reco_shower_energy_plane2
Definition: variables.h:991
std::vector< int > m_reco_track_start_in_SCB
Definition: variables.h:592
std::vector< double > m_reco_track_spacepoint_principal1
Definition: variables.h:609
std::vector< double > m_reco_shower_dirz
Definition: variables.h:793
std::vector< art::Ptr< recob::Hit > > pPFPHits
std::string fAlgName
&lt; determined particle ID
Definition: ParticleID.h:23
std::vector< double > m_reco_track_proton_kinetic_energy
Definition: variables.h:603
while getopts h
std::vector< double > m_reco_shower_implied_diry
Definition: variables.h:803
auto vector(Vector const &v)
Returns a manipulator which will print the specified array.
Definition: DumpUtils.h:265
T abs(T value)
std::vector< double > m_reco_track_mean_dEdx_end_half_p0
Definition: variables.h:645
kVariableType fVariableType
Variable type enum: defined in ParticleID_VariableTypeEnums.h. Set to kNotSet by default.
Definition: ParticleID.h:24
std::vector< double > m_reco_shower_flash_shortest_distyz
Definition: variables.h:818
std::vector< int > m_reco_shower_start_in_SCB
Definition: variables.h:787
std::vector< double > m_reco_track_mean_trunc_dEdx_start_half_p2
Definition: variables.h:666
std::vector< bool > m_reco_track_is_nuslice
Definition: variables.h:685
std::vector< size_t > m_reco_track_ordered_energy_index
Definition: variables.h:606
std::vector< double > m_reco_flash_time_in_beamgate
Definition: variables.h:410
std::vector< double > m_reco_track_spacepoint_max_dist
Definition: variables.h:613
std::vector< double > m_reco_track_pid_bragg_likelihood_p_plane1
Definition: variables.h:1048
double s_track_calo_min_dEdx_hits
Definition: variables.h:156
std::vector< double > m_reco_shower3d_theta_yz
Definition: variables.h:759
std::vector< double > m_reco_track_start_dist_to_CPA
Definition: variables.h:588
std::vector< double > m_reco_flash_time_width
Definition: variables.h:402
std::vector< int > Printer_header(std::vector< std::string > headings)
std::vector< double > m_reco_shower_angle_wrt_wires_plane1
Definition: variables.h:1032
std::vector< int > m_reco_track_sliceId
Definition: variables.h:680
std::vector< double > m_reco_track_calo_energy_plane2
Definition: variables.h:595
std::vector< double > m_reco_shower_energy_max
Definition: variables.h:988
std::vector< double > m_reco_shower_plane2_nhits
Definition: variables.h:1002
std::vector< double > m_reco_track_mean_dEdx_p1
Definition: variables.h:652
std::vector< double > m_reco_shower3d_length
Definition: variables.h:763
std::vector< double > m_reco_track_nuscore
Definition: variables.h:681
std::vector< double > m_reco_shower_dEdx_plane0_max
Definition: variables.h:1022
std::vector< double > m_reco_shower_dEdx_amalgamated
Definition: variables.h:1034
std::vector< double > m_CRT_hits_x
Definition: variables.h:559
std::vector< double > m_reco_shower_length
Definition: variables.h:798
std::vector< double > m_reco_track_calo_energy_plane1
Definition: variables.h:594
std::vector< double > m_reco_shower_delaunay_area_plane1
Definition: variables.h:833
double getMeanHitWidthPlane(std::vector< art::Ptr< recob::Hit >> hits, int this_plane)
Definition: Processors.cxx:454
std::vector< int > m_reco_shower_num_hits_plane1
Definition: variables.h:830
std::vector< double > m_reco_shower_plane2_meanRMS
Definition: variables.h:1005
std::vector< double > m_reco_track_trunc_PIDA_p1
Definition: variables.h:659
Geometry information for a single wire plane.The plane is represented in the geometry by a solid whic...
Definition: PlaneGeo.h:82
std::vector< double > m_reco_shower_dEdx_plane1_mean
Definition: variables.h:1020
std::vector< double > m_reco_track_mean_trunc_dEdx_p1
Definition: variables.h:656
std::vector< double > m_reco_shower_flash_shortest_distz
Definition: variables.h:816
std::vector< double > m_reco_shower3d_dEdx_plane0
Definition: variables.h:775
tick_as<> tick
Tick number, represented by std::ptrdiff_t.
Definition: electronics.h:75
geo::GeometryCore const * s_geom
Definition: variables.h:143
std::vector< int > m_reco_track_good_calo_best_plane
Definition: variables.h:636
std::vector< double > m_reco_track_mean_dEdx_p2
Definition: variables.h:661
std::vector< double > m_CRT_veto_hit_PE
Definition: variables.h:547
std::vector< double > m_reco_shower_dEdx_plane2_max
Definition: variables.h:1024
std::vector< int > m_reco_shower_flash_shortest_index_z
Definition: variables.h:820
std::vector< int > m_reco_track_end_in_SCB
Definition: variables.h:591
std::vector< double > m_reco_shower_daughter_trackscore
Definition: variables.h:750
std::vector< double > m_reco_shower3d_implied_dirx
Definition: variables.h:767
std::vector< double > m_reco_shower_implied_dirz
Definition: variables.h:804
std::vector< std::vector< double > > m_reco_shower_dEdx_plane2
Definition: variables.h:1018
std::vector< double > m_reco_shower_energy_plane1
Definition: variables.h:990
std::vector< double > m_reco_shower_dEdx_plane0_mean
Definition: variables.h:1019
std::vector< double > m_reco_shower3d_implied_diry
Definition: variables.h:768
std::vector< double > m_reco_shower_starty
Definition: variables.h:782
std::vector< double > m_reco_track_dirx
Definition: variables.h:576
int distToSCB(double &dist, std::vector< double > &vec, para_all &paras)
std::vector< int > m_reco_shower_dEdx_amalgamated_nhits
Definition: variables.h:1035
std::vector< int > m_reco_shower_sliceId
Definition: variables.h:835
std::vector< double > m_reco_shower3d_openingangle
Definition: variables.h:762
std::vector< std::vector< double > > m_reco_shower_dQdx_plane0
Definition: variables.h:1013
double distToCPA(std::vector< double > &vec, para_all &paras)
std::vector< double > m_reco_shower_plane1_meanRMS
Definition: variables.h:1004
std::vector< double > m_reco_track_mean_dEdx_start_half_best_plane
Definition: variables.h:634
std::vector< double > m_reco_track_pid_three_plane_proton_pid
Definition: variables.h:1062
std::vector< double > m_reco_flash_ycenter_in_beamgate
Definition: variables.h:411
std::vector< double > m_reco_track_mean_trunc_dEdx_p2
Definition: variables.h:665
PandoraPFParticle * PPFP_GetPPFPFromTrack(std::vector< PandoraPFParticle > &PPFPs, art::Ptr< recob::Track > pTrack)
std::vector< double > m_reco_track_mean_trunc_dEdx_end_half_p2
Definition: variables.h:667
void AnalyzeTracks(std::vector< PandoraPFParticle > all_PPFPs, const std::vector< art::Ptr< recob::Track >> &tracks, std::map< art::Ptr< recob::PFParticle >, std::vector< art::Ptr< recob::SpacePoint >>> &pfParticleToSpacePointsMap, std::map< int, art::Ptr< simb::MCParticle > > &MCParticleToTrackIdMap, std::map< int, double > &sliceIdToNuScoreMap, var_all &vars, para_all &paras)
std::vector< double > m_reco_shower_start_dist_to_active_TPC
Definition: variables.h:784
std::vector< double > m_reco_track_endz
Definition: variables.h:584
float dEdx(detinfo::DetectorClocksData const &clockData, detinfo::DetectorPropertiesData const &detProp, const TCSlice &slc, TP3D &tp3d)
Definition: PFPUtils.cxx:2687
std::vector< double > CalcdQdxShower(const art::Ptr< recob::Shower > &shower, const std::vector< art::Ptr< recob::Cluster >> &clusters, std::map< art::Ptr< recob::Cluster >, std::vector< art::Ptr< recob::Hit >> > &clusterToHitMap, int plane, double triggeroffset, detinfo::DetectorPropertiesData const &theDetector, para_all &paras)
Definition: Processors.cxx:354
std::vector< std::vector< double > > m_reco_shower_dQdx_plane2
Definition: variables.h:1015
std::vector< double > m_reco_flash_ywidth
Definition: variables.h:406
std::vector< double > m_reco_track_trackscore
Definition: variables.h:683
auto norm(Vector const &v)
Return norm of the specified vector.
std::vector< double > m_reco_track_endx
Definition: variables.h:582
std::vector< double > m_reco_shower_openingangle
Definition: variables.h:797
std::vector< double > m_reco_flash_ycenter
Definition: variables.h:405
std::vector< double > m_CRT_hits_PE
Definition: variables.h:558
std::vector< double > m_reco_shower_phi_yx
Definition: variables.h:795
std::vector< size_t > m_reco_shower_ordered_energy_index
Definition: variables.h:1012
std::vector< double > m_reco_shower_dEdx_plane2_mean
Definition: variables.h:1021
std::vector< double > m_reco_track_start_dist_to_active_TPC
Definition: variables.h:586
std::vector< int > m_reco_track_num_trajpoints
Definition: variables.h:601
std::vector< double > m_reco_track_pid_bragg_likelihood_mip_plane1
Definition: variables.h:1051
std::vector< double > m_reco_shower_dEdx_plane0_min
Definition: variables.h:1025
double CalcEShowerPlane(const std::vector< art::Ptr< recob::Hit >> &hits, int this_plane, para_all &paras)
Definition: Processors.cxx:293
std::vector< double > m_reco_track_mean_trunc_dEdx_start_half_best_plane
Definition: variables.h:638
std::vector< double > m_reco_shower3d_dEdx_plane1
Definition: variables.h:776
std::vector< double > m_reco_track_pid_chi2_mu_plane1
Definition: variables.h:1057
std::vector< double > m_reco_shower_energy_plane0
Definition: variables.h:989
std::vector< int > m_reco_track_num_calo_hits_p0
Definition: variables.h:672
std::vector< double > m_CRT_hits_z
Definition: variables.h:561
std::vector< double > m_reco_shower3d_diry
Definition: variables.h:757
std::vector< double > m_reco_flash_zwidth
Definition: variables.h:408
std::vector< double > m_reco_shower_delaunay_area_plane0
Definition: variables.h:832
std::vector< int > m_reco_track_good_calo_p2
Definition: variables.h:664
double getAmalgamateddEdx(double angle_wrt_plane0, double angle_wrt_plane1, double angle_wrt_plane2, double median_plane0, double median_plane1, double median_plane2, int plane0_nhits, int plane1_nhits, int plane2_nhits)
std::vector< bool > m_reco_track_isclearcosmic
Definition: variables.h:682
std::vector< double > m_reco_track_pid_pida_plane1
Definition: variables.h:1054
constexpr double dist(const TReal *x, const TReal *y, const unsigned int dimension)
std::vector< double > m_reco_flash_total_pe
Definition: variables.h:400
void Printer_content(std::vector< std::string > nums, std::vector< int > spacers)
std::vector< double > m_reco_shower3d_dirz
Definition: variables.h:758
std::vector< std::vector< double > > m_reco_track_trunc_dEdx_p2
Definition: variables.h:629
std::vector< double > m_reco_flash_zcenter_in_beamgate
Definition: variables.h:412
std::vector< int > m_reco_shower_hit_wire
Definition: variables.h:1006
std::string to_string(WindowPattern const &pattern)
std::vector< double > m_reco_track_trunc_PIDA_p2
Definition: variables.h:668
std::vector< std::vector< double > > m_reco_track_dEdx_p0
Definition: variables.h:625
std::vector< double > m_reco_track_start_dist_to_SCB
Definition: variables.h:590
PandoraPFParticle * PPFP_GetPPFPFromShower(std::vector< PandoraPFParticle > &PPFPs, art::Ptr< recob::Shower > pShower)
std::vector< std::vector< double > > m_reco_track_trunc_dEdx_p1
Definition: variables.h:626
std::vector< double > m_reco_shower_dQdx_plane1_median
Definition: variables.h:1037
std::vector< double > m_reco_shower_angle_wrt_wires_plane2
Definition: variables.h:1033
std::vector< double > m_reco_shower3d_impact_parameter
Definition: variables.h:766
do i e
std::vector< double > m_reco_flash_abs_time
Definition: variables.h:403
std::vector< double > m_reco_shower3d_conversion_distance
Definition: variables.h:764
std::vector< double > m_reco_shower_start_dist_to_SCB
Definition: variables.h:786
std::vector< int > m_reco_shower3d_exists
Definition: variables.h:752
std::vector< double > m_reco_track_mean_trunc_dEdx_end_half_p1
Definition: variables.h:658
std::vector< double > m_reco_track_mean_dEdx_start_half_p1
Definition: variables.h:653
std::vector< double > m_reco_shower3d_dirx
Definition: variables.h:756
std::vector< double > m_reco_shower_trackscore
Definition: variables.h:839
std::vector< double > m_reco_track_mean_dEdx_start_half_p2
Definition: variables.h:662
std::vector< int > m_reco_track_num_calo_hits_p1
Definition: variables.h:673
std::vector< double > m_reco_shower_angle_wrt_wires_plane0
Definition: variables.h:1031
std::vector< double > m_reco_track_endy
Definition: variables.h:583
std::vector< double > m_reco_shower3d_starty
Definition: variables.h:754
std::vector< double > m_reco_shower_hit_tick
Definition: variables.h:1008
std::vector< double > m_reco_track_startz
Definition: variables.h:581
std::vector< double > m_reco_shower_pfparticle_pdg
Definition: variables.h:840
void CollectPID(std::vector< art::Ptr< recob::Track >> &tracks, std::vector< PandoraPFParticle > all_PPFPs, var_all &vars)
double getMedian(std::vector< double > thisvector)
Definition: helper_math.cxx:88
std::vector< int > m_reco_track_num_spacepoints
Definition: variables.h:602
std::vector< double > m_reco_track_end_dist_to_CPA
Definition: variables.h:587
double distToTPCActive(std::vector< double > &vec, para_all &paras)
pdgs k
Definition: selectors.fcl:22
void AnalyzeShowers(std::vector< PandoraPFParticle > all_PPFPs, const std::vector< art::Ptr< recob::Shower >> &showers, std::map< art::Ptr< recob::Cluster >, std::vector< art::Ptr< recob::Hit >> > &clusterToHitMap, double triggeroffset, detinfo::DetectorPropertiesData const &theDetector, var_all &vars, para_all &paras)
std::vector< double > m_CRT_hits_time
Definition: variables.h:557
std::vector< double > m_reco_shower3d_energy_plane2
Definition: variables.h:773
int m_reco_num_flashes_in_beamgate
Definition: variables.h:415
std::vector< std::vector< double > > m_reco_track_resrange_p2
Definition: variables.h:669
std::vector< double > m_reco_shower_diry
Definition: variables.h:792
std::vector< double > m_reco_track_pid_bragg_likelihood_mu_plane1
Definition: variables.h:1045
std::vector< double > m_reco_shower_start_dist_to_CPA
Definition: variables.h:785
std::vector< double > m_reco_track_mean_trunc_dEdx_start_half_p0
Definition: variables.h:648
std::vector< double > m_reco_shower_dEdx_plane0_median
Definition: variables.h:1028
std::vector< double > m_reco_shower_conversion_distance
Definition: variables.h:799
std::vector< size_t > m_reco_track_ordered_displacement_index
Definition: variables.h:607
double WireAngleToVertical(geo::View_t view, geo::TPCID const &tpcid) const
Returns the angle of the wires in the specified view from vertical.
void AnalyzeFlashes(const std::vector< art::Ptr< recob::OpFlash >> &flashes, art::Handle< std::vector< sbn::crt::CRTHit >> crthit_h, double evt_timeGPS_nsec, std::map< art::Ptr< recob::OpFlash >, std::vector< art::Ptr< sbn::crt::CRTHit >>> crtvetoToFlashMap, var_all &vars, para_all &paras)
BEGIN_PROLOG could also be cout
std::vector< double > m_reco_track_mean_dEdx_end_half_p2
Definition: variables.h:663
std::vector< std::vector< double > > m_reco_track_trunc_dEdx_best_plane
Definition: variables.h:620
std::vector< double > m_reco_shower_dirx
Definition: variables.h:791
std::vector< double > m_reco_track_pid_pida_plane0
Definition: variables.h:1053
std::vector< double > m_reco_track_pid_pida_plane2
Definition: variables.h:1055
std::vector< double > m_reco_track_mean_trunc_dEdx_p0
Definition: variables.h:647
std::vector< int > m_reco_shower_num_hits_plane0
Definition: variables.h:829
int fAssumedPdg
PDG of particle hypothesis assumed by algorithm, if applicable. Set to 0 by default.
Definition: ParticleID.h:27
std::vector< double > m_reco_track_calo_energy_plane0
Definition: variables.h:593
std::vector< double > m_reco_shower3d_startx
Definition: variables.h:753
std::vector< double > m_reco_track_length
Definition: variables.h:575
std::vector< double > m_reco_shower_plane0_meanRMS
Definition: variables.h:1003
std::vector< double > m_reco_shower_dEdx_plane1_median
Definition: variables.h:1029
std::vector< double > m_reco_track_pid_bragg_likelihood_p_plane0
Definition: variables.h:1047
std::vector< std::vector< double > > m_reco_track_resrange_best_plane
Definition: variables.h:621
std::vector< std::vector< double > > m_reco_shower_dEdx_plane1
Definition: variables.h:1017
std::vector< double > m_reco_track_pid_bragg_likelihood_mip_plane2
Definition: variables.h:1052