ProtoDUNETrackUtils.cxx
Go to the documentation of this file.
2 
8 #include "canvas/Persistency/Common/FindManyP.h"
9 #include "dune/DuneObj/ProtoDUNEBeamEvent.h"
12 
13 #include "TFile.h"
14 #include "TH1F.h"
15 
16 #include <string>
17 
19 
20 }
21 
23 
24 }
25 
26 std::vector<anab::CosmicTag> protoana::ProtoDUNETrackUtils::GetRecoTrackCosmicTag(const recob::Track &track, art::Event const &evt, std::string trackModule) const{
27 
28  auto recoTracks = evt.getValidHandle<std::vector<recob::Track> >(trackModule);
29 
30  unsigned int trackIndex = track.ID();
31 
32  // Convert to std::vector<anab::CosmicTag> from std::vector<art::Ptr<anab::CosmicTag>>
33  std::vector<anab::CosmicTag> trackTags;
34 
35  try{
36  const art::FindManyP<anab::CosmicTag> findCosmicTags(recoTracks,evt,trackModule);
37  for(unsigned int t = 0; t < findCosmicTags.at(trackIndex).size(); ++t){
38  trackTags.push_back((*(findCosmicTags.at(trackIndex)[t])));
39  }
40  }
41  catch(...){
42 // std::cerr << "Product not found - returning empty vector" << std::endl;
43  }
44 
45  return trackTags;
46 }
47 
48 std::vector<anab::T0> protoana::ProtoDUNETrackUtils::GetRecoTrackT0(const recob::Track &track, art::Event const &evt, std::string trackModule) const{
49 
50  auto recoTracks = evt.getValidHandle<std::vector<recob::Track> >(trackModule);
51 
52  unsigned int trackIndex = track.ID();
53 
54  // Convert to std::vector<anab::T0> from std::vector<art::Ptr<anab::T0>>
55  std::vector<anab::T0> trackT0s;
56 
57  try{
58  const art::FindManyP<anab::T0> findTrackT0s(recoTracks,evt,trackModule);
59  for(unsigned int t = 0; t < findTrackT0s.at(trackIndex).size(); ++t){
60  trackT0s.push_back((*(findTrackT0s.at(trackIndex)[t])));
61  }
62  }
63  catch(...){
64 // std::cerr << "Product not found - returning empty vector" << std::endl;
65  }
66 
67  return trackT0s;
68 
69 }
70 
71 // Get the Calorimetry(s) from a given reco track
72 std::vector<anab::Calorimetry> protoana::ProtoDUNETrackUtils::GetRecoTrackCalorimetry(const recob::Track &track, art::Event const &evt, const std::string trackModule, const std::string caloModule) const{
73 
74  auto recoTracks = evt.getValidHandle<std::vector<recob::Track> >(trackModule);
75  std::vector<anab::Calorimetry> caloInfo;
76 
77  try{
78  const art::FindManyP<anab::Calorimetry> findCalorimetry(recoTracks,evt,caloModule);
79  std::vector<art::Ptr<anab::Calorimetry>> theseCalos = findCalorimetry.at(track.ID());
80 
81  for( auto calo : theseCalos){
82  caloInfo.push_back(*calo);
83  }
84  }
85  catch(...){
86  std::cerr << "No track calorimetry object found... returning empty vector" << std::endl;
87  }
88 
89  return caloInfo;
90 }
91 
92 // Get the hits from a given reco track
93 const std::vector<const recob::Hit*> protoana::ProtoDUNETrackUtils::GetRecoTrackHits(const recob::Track &track, art::Event const &evt, const std::string trackModule) const{
94 
95  auto recoTracks = evt.getValidHandle<std::vector<recob::Track> >(trackModule);
96  art::FindManyP<recob::Hit> findHits(recoTracks,evt,trackModule);
97  std::vector<art::Ptr<recob::Hit>> inputHits = findHits.at(track.ID());
98 
99  std::vector<const recob::Hit*> trackHits;
100 
101  for(const art::Ptr<recob::Hit> hit : inputHits){
102 
103  trackHits.push_back(hit.get());
104 
105  }
106 
107  return trackHits;
108 
109 }
110 
111 const std::vector<const recob::Hit*> protoana::ProtoDUNETrackUtils::GetRecoTrackHitsFromPlane(const recob::Track &track, art::Event const &evt, const std::string trackModule, unsigned int planeID ) const{
112 
113  std::vector<const recob::Hit*> trackHits;
114  if( planeID > 2 ){
115  std::cout << "Please input plane 0, 1, or 2" << std::endl;
116  return trackHits;
117  }
118 
119  auto recoTracks = evt.getValidHandle<std::vector<recob::Track> >(trackModule);
120  art::FindManyP<recob::Hit> findHits(recoTracks,evt,trackModule);
121  std::vector<art::Ptr<recob::Hit>> inputHits = findHits.at(track.ID());
122 
123  for(const art::Ptr<recob::Hit> hit : inputHits){
124  unsigned int thePlane = hit.get()->WireID().asPlaneID().Plane;
125  if( thePlane != planeID ) continue;
126 
127  trackHits.push_back(hit.get());
128 
129  }
130 
131  return trackHits;
132 
133 }
134 
135 std::vector< float > protoana::ProtoDUNETrackUtils::CalibrateCalorimetry( const recob::Track &track, art::Event const &evt, const std::string trackModule, const std::string caloModule, const fhicl::ParameterSet &ps ) {
136 
137 
138  unsigned int planeID = ps.get< unsigned int >( "PlaneID" );
139 
140  double betap = ps.get< double >( "betap" );
141  double Rho = ps.get< double >( "Rho" );
142  double Efield = ps.get< double >( "Efield" );
143  double Wion = ps.get< double >( "Wion" );
144  double alpha = ps.get< double >( "alpha" );
145  double norm_factor = ps.get< double >( "norm_factor" );
146  double calib_factor = ps.get< double >( "calib_factor" );
147  std::string X_correction_name = ps.get< std::string >( "X_correction" );
148  TFile X_correction_file = TFile( X_correction_name.c_str(), "OPEN" );
149  TH1F * X_correction_hist = NULL;
150 
151  bool UseNewVersion = ps.get< bool >( "UseNewVersion", false );
152  if( UseNewVersion ){
153  std::string hist_name = "dqdx_X_correction_hist_" + std::to_string(planeID);
154  X_correction_hist = (TH1F*)X_correction_file.Get( hist_name.c_str() );
155 
156  }
157  else{
158  X_correction_hist = (TH1F*)X_correction_file.Get( "dqdx_X_correction_hist" );
159  }
160 
161 
162  std::vector< float > calibrated_dEdx;
163 
164  //Get the Calorimetry vector from the track
165  /*std::vector< anab::Calorimetry >*/ auto caloVector = GetRecoTrackCalorimetry( track, evt, trackModule, caloModule );
166 
167  size_t calo_position;
168  bool found_plane = false;
169  for( size_t i = 0; i < caloVector.size(); ++i ){
170  unsigned int thePlane = caloVector.at(i).PlaneID().Plane;
171  if( thePlane == planeID ){
172  calo_position = i;
173  found_plane = true;
174  break;
175  }
176  }
177 
178  if( !found_plane ){
179  std::cout << "Could not find the correct plane in the calorimetry vector" << std::endl;
180  return calibrated_dEdx;
181  }
182 
183  std::vector< float > dQdX = caloVector.at( calo_position).dQdx();
184  auto theXYZPoints = caloVector.at( calo_position).XYZ();
185 
186  //Get the hits from the track from a specific plane
187  const std::vector< const recob::Hit* > hits = GetRecoTrackHitsFromPlane( track, evt, trackModule, planeID );
188  if( hits.size() == 0 ){
189  std::cout << "Got empty hits vector" << std::endl;
190  return calibrated_dEdx;
191  }
192 
193  //Do Ajib's correction
194  for( size_t i = 0; i < dQdX.size(); ++i ){
195  float hit_x = theXYZPoints[i].X();
196  int X_bin = X_correction_hist->FindBin( hit_x );
197  float X_correction = X_correction_hist->GetBinContent(X_bin);
198 
199  float corrected_dq_dx = dQdX[i] * X_correction * norm_factor;
200  float scaled_corrected_dq_dx = corrected_dq_dx / calib_factor;
201  float cal_de_dx = calc_dEdX( scaled_corrected_dq_dx, betap, Rho, Efield, Wion, alpha );
202 
203  calibrated_dEdx.push_back( cal_de_dx );
204  }
205 
206 
207  return calibrated_dEdx;
208 }
209 
210 float protoana::ProtoDUNETrackUtils::calc_dEdX(double dqdx, double betap, double Rho, double Efield, double Wion, double alpha){
211  return (exp(dqdx*(betap/(Rho*Efield)*Wion))-alpha)/(betap/(Rho*Efield));
212 }
213 
214 
215 // Get the hits from a given reco track
216 unsigned int protoana::ProtoDUNETrackUtils::GetNumberRecoTrackHits(const recob::Track &track, art::Event const &evt, const std::string trackModule) const{
217 
218  return GetRecoTrackHits(track,evt,trackModule).size();
219 
220 }
221 
222 // Get the PID from a given track
223 std::vector<anab::ParticleID> protoana::ProtoDUNETrackUtils::GetRecoTrackPID(const recob::Track &track, art::Event const &evt, const std::string trackModule, const std::string pidModule) const{
224 
225  auto recoTracks = evt.getValidHandle<std::vector<recob::Track> >(trackModule);
226  std::vector<anab::ParticleID> pidvec;
227 
228  try{
229  const art::FindManyP<anab::ParticleID> findPID(recoTracks,evt,pidModule);
230  std::vector<art::Ptr<anab::ParticleID>> thePID = findPID.at(track.ID());
231 
232  for( auto pid : thePID){
233  pidvec.push_back(*pid);
234  }
235  }
236  catch(...){
237  std::cerr << "No track PID object found... returning empty vector" << std::endl;
238  }
239 
240  return pidvec;
241 
242 }
243 
244 protoana::BrokenTrack protoana::ProtoDUNETrackUtils::IsBrokenTrack( const recob::Track &track, art::Event const &evt, const std::string trackModule, const std::string caloModule, const fhicl::ParameterSet & BrokenTrackPars, const fhicl::ParameterSet & CalorimetryPars ){
245 
246  BrokenTrack theBrokenTrack;
247  theBrokenTrack.Valid = false;
248 
249  double fBrokenTrackZ_low = BrokenTrackPars.get< double >( "BrokenTrackZ_low" );
250  double fBrokenTrackZ_high = BrokenTrackPars.get< double >( "BrokenTrackZ_high" );
251 
252  double fStitchTrackZ_low = BrokenTrackPars.get< double >( "StitchTrackZ_low" );
253  double fStitchTrackZ_high = BrokenTrackPars.get< double >( "StitchTrackZ_high" );
254 
255  double fStitchXTol = BrokenTrackPars.get< double >( "StitchXTol" );
256  double fStitchYTol = BrokenTrackPars.get< double >( "StitchYTol" );
257 
258  ////Check the end of the track
259  double endZ = track.Trajectory().End().Z();
260  double endX = track.Trajectory().End().X();
261  double endY = track.Trajectory().End().Y();
262  if( fBrokenTrackZ_low < endZ && endZ < fBrokenTrackZ_high ){
263 
264  const auto recoTracks = evt.getValidHandle<std::vector<recob::Track> >(trackModule);
265  for( auto const & tr : *recoTracks ){
266 
267  //Skip the track in question
268  if( tr.ID() == track.ID() ) continue;
269 
270  double stitchStartZ = tr.Trajectory().Start().Z();
271  if( fStitchTrackZ_low < stitchStartZ && stitchStartZ < fStitchTrackZ_high ){
272  double deltaX = fabs(endX - tr.Trajectory().Start().X());
273  double deltaY = fabs(endY - tr.Trajectory().Start().Y());
274 
275  std::cout << "Possible stitching track: " << stitchStartZ << " " << deltaX << " " << deltaY << std::endl;
276 
277  if( deltaX < fStitchXTol && deltaY < fStitchYTol ){
278 
279 
280  //Get the cosine of the angle between them
281  auto stitchDir = tr.StartDirection();
282  double stitch_cos_theta = stitchDir.X()*track.EndDirection().X() + stitchDir.Y()*track.EndDirection().Y() + stitchDir.Z()*track.EndDirection().Z() ;
283  std::cout << "Cos_theta " << stitch_cos_theta << std::endl;
284 
285 
286  unsigned int planeID = CalorimetryPars.get< unsigned int >( "PlaneID");
287  //Get the calorimetries, calibrate, and combine
288  /*std::vector< anab::Calorimetry >*/ auto broken_calos = GetRecoTrackCalorimetry(track, evt, trackModule, caloModule);
289 
290  bool found_broken_calo = false;
291  size_t calo_position= 0;
292  for( size_t i = 0; i < broken_calos.size(); ++i ){
293  unsigned int thePlane = broken_calos.at(i).PlaneID().Plane;
294  if( thePlane == planeID ){
295  found_broken_calo = true;
296  calo_position = i;
297  break;
298  }
299  }
300 
301  //If no calorimetry object is found for this track, return the default BrokenTrack.
302  if( !found_broken_calo ) return theBrokenTrack;
303 
304  auto broken_range = broken_calos.at( calo_position ).ResidualRange();
305  auto broken_dQdx = broken_calos.at( calo_position ).dQdx();
306  std::vector< float > broken_cal_dEdx = CalibrateCalorimetry( track, evt, trackModule, caloModule, CalorimetryPars );
307 
308  calo_position = 0;
309  /*std::vector< anab::Calorimetry >*/ auto stitch_calos = GetRecoTrackCalorimetry(tr, evt, trackModule, caloModule);
310 
311  bool found_stitch_calo = false;
312  for( size_t i = 0; i < stitch_calos.size(); ++i ){
313  unsigned int thePlane = stitch_calos.at(i).PlaneID().Plane;
314  if( thePlane == planeID ){
315  found_stitch_calo = true;
316  calo_position = i;
317  break;
318  }
319  }
320 
321  //If no calorimetry object is found for this track, try the next
322  if( !found_stitch_calo ) continue;
323 
324  auto stitch_range = stitch_calos.at( calo_position ).ResidualRange();
325  auto stitch_dQdx = stitch_calos.at( calo_position ).dQdx();
326  std::vector< float > stitch_cal_dEdx = CalibrateCalorimetry( tr, evt, trackModule, caloModule, CalorimetryPars );
327 
328  //piece them together in order
329  std::vector< float > combined_range, combined_dQdx, combined_dEdx;
330 
331 
332  combined_range = stitch_range;
333  if( stitch_range[0] > stitch_range.back() ){
334  std::cout << "Adding range: " << stitch_range[0] << std::endl;
335  for( size_t i = 0 ; i < broken_range.size(); ++i ){
336  combined_range.push_back( broken_range[i] + stitch_range[0] );
337  }
338  }
339  else{
340  std::cout << "Adding range: " << stitch_range[0] << std::endl;
341  for( size_t i = 0 ; i < broken_range.size(); ++i ){
342  combined_range.push_back( broken_range[i] + stitch_range.back() );
343  }
344  }
345 
346  for( size_t i = 0; i < combined_range.size(); ++i ){
347  std::cout << combined_range[i] << std::endl;
348  }
349 
350  combined_dQdx = stitch_dQdx;
351  combined_dQdx.insert( combined_dQdx.end(), broken_dQdx.begin(), broken_dQdx.end() );
352  combined_dEdx = stitch_cal_dEdx;
353  combined_dEdx.insert( combined_dEdx.end(), broken_cal_dEdx.begin(), broken_cal_dEdx.end() );
354 /* float total_stitch_range;
355  if( stitch_range[0] > stitch_range.back() ){
356  total_stitch_range = stitch_range[0];
357  }
358  else{
359  total_stitch_range = stitch_range.back();
360  }
361 
362  std::cout << stitch_range[0] << " " << stitch_range.back() << " " << total_stitch_range << std::endl;
363 
364  if( broken_range[0] > broken_range.back() ){
365  for( size_t i = 0; i < broken_range.size(); ++i ){
366  combined_range.push_back( broken_range.at(i) + total_stitch_range );
367  combined_dQdx.push_back( broken_dQdx.at(i) );
368  combined_dEdx.push_back( broken_cal_dEdx.at(i) );
369  }
370  }
371  else{
372  for( size_t i = broken_range.size() - 1; i >= 0; --i ){
373  combined_range.push_back( broken_range.at(i) + total_stitch_range );
374  combined_dQdx.push_back( broken_dQdx.at(i) );
375  combined_dEdx.push_back( broken_cal_dEdx.at(i) );
376  }
377  }
378 
379  if( stitch_range[0] > stitch_range.back() ){
380  combined_range.insert( combined_range.end(), stitch_range.begin(), stitch_range.end() );
381  combined_dQdx.insert( combined_dQdx.end(), stitch_dQdx.begin(), stitch_dQdx.end() );
382  combined_dEdx.insert( combined_dEdx.end(), stitch_cal_dEdx.begin(), stitch_cal_dEdx.end() );
383  }
384  else{
385  combined_range.insert( combined_range.end(), stitch_range.rbegin(), stitch_range.rend() );
386  combined_dQdx.insert( combined_dQdx.end(), stitch_dQdx.rbegin(), stitch_dQdx.rend() );
387  combined_dEdx.insert( combined_dEdx.end(), stitch_cal_dEdx.rbegin(), stitch_cal_dEdx.rend() );
388  }
389 */
390 
391  theBrokenTrack.firstTrack = &track;
392  theBrokenTrack.secondTrack = &tr;
393  theBrokenTrack.CosTheta = stitch_cos_theta;
394  theBrokenTrack.Combined_ResidualRange = combined_range;
395  theBrokenTrack.Combined_dQdx = combined_dQdx;
396  theBrokenTrack.Combined_dEdx = combined_dEdx;
397  theBrokenTrack.Valid = true;
398 
399  return theBrokenTrack;
400  }
401  }
402  }
403  }
404  return theBrokenTrack;
405 }
406 
407 
408 std::pair< double, int > protoana::ProtoDUNETrackUtils::Chi2PIDFromTrack_MC( const recob::Track &track, art::Event const &evt, const std::string trackModule, const std::string caloModule, TProfile * profile ){
409 
410  /*std::vector< anab::Calorimetry >*/ auto calo = GetRecoTrackCalorimetry(track, evt, trackModule, caloModule);
411  std::vector< double > calo_dEdX;
412  std::vector< double > calo_range;
413  for( size_t i = 0; i < calo[0].dEdx().size(); ++i ){
414  calo_dEdX.push_back( calo[0].dEdx()[i] );
415  calo_range.push_back( calo[0].ResidualRange()[i] );
416  }
417 
418  return Chi2PID( calo_dEdX, calo_range, profile );
419 
420 }
421 
422 std::pair< double, int > protoana::ProtoDUNETrackUtils::Chi2PID( const std::vector< double > & track_dedx, const std::vector< double > & range, TProfile * profile ){
423 
424  double pid_chi2 = 0.;
425  int npt = 0;
426 
427  if( track_dedx.size() < 1 || range.size() < 1 )
428  return std::make_pair(9999., -1);
429 
430  //Ignore first and last point
431  for( size_t i = 1; i < track_dedx.size()-1; ++i ){
432 
433  //Skip large pulse heights
434  if( track_dedx[i] > 1000. || track_dedx[i] < 0.) {
435  continue;
436  }
437 
438  int bin = profile->FindBin( range[i] );
439  if( bin >= 1 && bin <= profile->GetNbinsX() ){
440 
441  double template_dedx = profile->GetBinContent( bin );
442  if( template_dedx < 1.e-6 ){
443  template_dedx = ( profile->GetBinContent( bin - 1 ) + profile->GetBinContent( bin + 1 ) ) / 2.;
444  }
445 
446  double template_dedx_err = profile->GetBinError( bin );
447  if( template_dedx_err < 1.e-6 ){
448  template_dedx_err = ( profile->GetBinError( bin - 1 ) + profile->GetBinError( bin + 1 ) ) / 2.;
449  }
450 
451 
452  double dedx_res = 0.04231 + 0.0001783 * track_dedx[i] * track_dedx[i];
453  dedx_res *= track_dedx[i];
454 
455  //Chi2 += ( track_dedx - template_dedx )^2 / ( (template_dedx_err)^2 + (dedx_res)^2 )
456  pid_chi2 += ( pow( (track_dedx[i] - template_dedx), 2 ) / ( pow(template_dedx_err, 2) + pow(dedx_res, 2) ) );
457 
458  ++npt;
459  }
460  }
461 
462  if( npt == 0 )
463  return std::make_pair(9999., -1);
464 
465 
466 
467  return std::make_pair(pid_chi2, npt);
468 }
469 
470 //std::map< size_t, std::vector< const recob::Hit * > > protoana::ProtoDUNETrackUtils::GetRecoHitsFromTrajPoints(const recob::Track & track, art::Event const & evt, std::string trackModule){
471 std::map< size_t, const recob::Hit * > protoana::ProtoDUNETrackUtils::GetRecoHitsFromTrajPoints(const recob::Track & track, art::Event const & evt, std::string trackModule){
472 
473  auto recoTracks = evt.getValidHandle< std::vector< recob::Track > >(trackModule);
474  art::FindManyP< recob::Hit, recob::TrackHitMeta > trackHitMetas(recoTracks,evt,trackModule);
475  art::FindManyP< recob::Hit > findHits(recoTracks,evt,trackModule);
476 
477  std::vector< art::Ptr< recob::Hit > > track_hits = findHits.at( track.ID() );
478 
479 
480  //First, find the location of the beam track in the track list
481  size_t beam_index = 0;
482  for( size_t i = 0; i < recoTracks->size(); ++i ){
483  if( (*recoTracks)[i].ID() == track.ID() ){
484  beam_index = i;
485  break;
486  }
487  }
488 
489 
490  //std::map< size_t, std::vector< const recob::Hit * > > results;
491  std::map< size_t, const recob::Hit * > results;
492  if( trackHitMetas.isValid() ){
493 
494  auto beamHits = trackHitMetas.at( beam_index );
495  auto beamMetas = trackHitMetas.data( beam_index );
496 
497  for( size_t i = 0; i < beamHits.size(); ++i ){
498 
499  if( beamMetas[i]->Index() == static_cast<unsigned int>(std::numeric_limits<int>::max()) )
500  continue;
501 
502  if( !track.HasValidPoint( beamMetas[i]->Index() ) ){
503  std::cout << "Has no valid hit: " << beamMetas[i]->Index() << std::endl;
504  continue;
505  }
506 
507  //results[ beamMetas[i]->Index() ] = std::vector< const recob::Hit * >();
508 
509  for( size_t j = 0; j < track_hits.size(); ++j ){
510 
511  //if( track_hits[j]->WireID().Plane == 2 ){//Look at just the collection plane
512 
513  if( beamHits[i].key() == track_hits[j].key() ){
514 
515  if( beamMetas[i]->Index() >= track.NumberTrajectoryPoints() ){
516  throw cet::exception("ProtoDUNETrackUtils.cxx")
517  << "Requested track trajectory index " << beamMetas[i]->Index()
518  << " exceeds the total number of trajectory points "<< track.NumberTrajectoryPoints()
519  << " for track index " << beam_index
520  << ". Something is wrong with the track reconstruction. Please contact tjyang@fnal.gov";
521  }
522 
523  //If we've reached here, it's a good hit within the track. Connect to the trajectory point
524  //results[ beamMetas[i]->Index() ].push_back( track_hits[j].get() );
525  results[ beamMetas[i]->Index() ] = track_hits[j].get();
526  }
527  //}
528  }
529  }
530 
531  }
532  return results;
533 
534 }
535 
536 bool protoana::ProtoDUNETrackUtils::IsBeamlike( const recob::Track & track, art::Event const & evt, const fhicl::ParameterSet & BeamPars, bool flip ){
537 
538  double startX = track.Trajectory().Start().X();
539  double startY = track.Trajectory().Start().Y();
540  double startZ = track.Trajectory().Start().Z();
541 
542  double endX = track.Trajectory().End().X();
543  double endY = track.Trajectory().End().Y();
544  double endZ = track.Trajectory().End().Z();
545 
546  auto startDir = track.StartDirection();
547  auto endDir = track.EndDirection();
548  double trackDirX = 0.;
549  double trackDirY = 0.;
550  double trackDirZ = 0.;
551 
552  //'Flip' the track if endZ < startZ
553  if( flip && ( endZ < startZ ) ){
554  startX = endX;
555  startY = endY;
556  startZ = endZ;
557 
558  trackDirX = -1. * endDir.X();
559  trackDirY = -1. * endDir.Y();
560  trackDirZ = -1. * endDir.Z();
561  }
562  else{
563  trackDirX = startDir.X();
564  trackDirY = startDir.Y();
565  trackDirZ = startDir.Z();
566  }
567 
568  double beamX = 0.;
569  double beamY = 0.;
570 
571  double beamDirX = 0.;
572  double beamDirY = 0.;
573  double beamDirZ = 0.;
574 
575  //Real data: compare to the reconstructed beam particle
576  if( evt.isRealData() ){
577  std::vector<art::Ptr<beam::ProtoDUNEBeamEvent>> beamVec;
578  auto beamHandle = evt.getValidHandle< std::vector< beam::ProtoDUNEBeamEvent > >("beamevent");
579 
580  if( beamHandle.isValid()){
581  art::fill_ptr_vector(beamVec, beamHandle);
582  }
583  //Should just have one
584  const beam::ProtoDUNEBeamEvent & beamEvent = *(beamVec.at(0));
585 
586  const std::vector< recob::Track > & beamTracks = beamEvent.GetBeamTracks();
587  if( beamTracks.size() == 0 ){
588  std::cout << "Warning: no tracks associated to beam data" << std::endl;
589  return false;
590  }
591  else if( beamTracks.size() > 1 ){
592  std::cout << "Warning: mutiple tracks associated to beam data" << std::endl;
593  return false;
594  }
595 
596  beamX = beamTracks.at(0).Trajectory().End().X();
597  beamY = beamTracks.at(0).Trajectory().End().Y();
598 
599  beamDirX = beamTracks.at(0).EndDirection().X();
600  beamDirY = beamTracks.at(0).EndDirection().Y();
601  beamDirZ = beamTracks.at(0).EndDirection().Z();
602 
603  }
604  //MC: compare to the projected particle from the particle gun
605  else{
607  auto mcTruths = evt.getValidHandle< std::vector< simb::MCTruth > >("generator");
608 
609  const simb::MCParticle* true_beam_particle = truthUtil.GetGeantGoodParticle((*mcTruths)[0],evt);
610 
611  if( !true_beam_particle ){
612  std::cout << "No true beam particle" << std::endl;
613  return false;
614  }
615 
616 
617  beamDirX = true_beam_particle->Px() / true_beam_particle->P();
618  beamDirY = true_beam_particle->Py() / true_beam_particle->P();
619  beamDirZ = true_beam_particle->Pz() / true_beam_particle->P();
620 
621  //Project the beam to Z = 0
622  beamX = true_beam_particle->Position(0).X() + (-1.*true_beam_particle->Position(0).Z())*(beamDirX / beamDirZ);
623  beamY = true_beam_particle->Position(0).Y() + (-1.*true_beam_particle->Position(0).Z())*(beamDirY / beamDirZ);
624 
625  }
626 
627  double deltaX = startX - beamX;
628  double deltaY = startY - beamY;
629 
630  double costheta = beamDirX*trackDirX + beamDirY*trackDirY + beamDirZ*trackDirZ;
631 
632  std::pair< double, double > startX_cut = BeamPars.get< std::pair< double, double > >("TrackStartXCut");
633  std::pair< double, double > startY_cut = BeamPars.get< std::pair< double, double > >("TrackStartYCut");
634  std::pair< double, double > startZ_cut = BeamPars.get< std::pair< double, double > >("TrackStartZCut");
635  double costheta_cut = BeamPars.get< double >("TrackDirCut");
636 
637  if( deltaX < startX_cut.first || deltaX > startX_cut.second )
638  return false;
639  if( deltaY < startY_cut.first || deltaY > startY_cut.second )
640  return false;
641  if( startZ < startZ_cut.first || startZ > startZ_cut.second )
642  return false;
643  if( costheta < costheta_cut )
644  return false;
645 
646  //If here, the track is in the good beam region
647  return true;
648 }
649 
650 //Jake's implementation
652  const recob::Track & track, const art::Event & evt,
653  const std::string trackModule, const std::string hitModule,
654  double min_length, double min_x,
655  double max_x, double min_y, double max_y, double min_z, bool check_wire,
656  double check_x, double check_y, double check_z) {
657 
659  anab::MVAReader<recob::Hit, 4> hitResults(evt, "emtrkmichelid:emtrkmichel");
660 
661  //Skip short tracks
662  //Skip tracks that start/end outside of interesting volume
663  auto start = track.Vertex();
664  auto end = track.End();
665  if ((TMath::Max(start.X(), end.X()) > max_x) ||
666  (TMath::Min(start.X(), end.X()) < min_x) ||
667  (TMath::Max(start.Y(), end.Y()) > max_y) ||
668  (TMath::Min(start.Y(), end.Y()) < min_y) ||
669  (TMath::Min(start.Z(), end.Z()) < min_z) ||
670  (track.Length() < min_length)) {
671  return {-1., 0};
672  }
673 
674 
675  //Get the hits from the TrackHitMetas and only for view 2 (collection plane)
676  std::map<size_t, const recob::Hit *>
677  hits_from_traj = GetRecoHitsFromTrajPoints(track, evt, trackModule);
678  std::vector<const recob::Hit *> hits_from_traj_view2;
679  std::vector<size_t> index_from_traj_view2;
680 
681  for (auto it = hits_from_traj.begin(); it != hits_from_traj.end(); ++it) {
682  if (it->second->View() != 2) continue;
683  hits_from_traj_view2.push_back(it->second);
684  index_from_traj_view2.push_back(it->first);
685  }
686 
687  //Find the vertex hit & info to compare to later
688  double highest_z = -100.;
689  int vertex_tpc = -1;
690  int vertex_wire = -1;
691  float vertex_peak_time = -1.;
692 
693  if (check_z) {
694  for (const auto * hit : hits_from_traj_view2) {
695  double wire_z = geom->Wire(hit->WireID()).GetCenter().Z();
696  if (wire_z > highest_z) {
697  highest_z = wire_z;
698  vertex_tpc = hit->WireID().TPC;
699  vertex_peak_time = hit->PeakTime();
700  vertex_wire = hit->WireID().Wire;
701  }
702  }
703  }
704  else {
705  const recob::TrackTrajectory & traj = track.Trajectory();
706  double highest_diff = -1.;
707  for (size_t i = 0; i < hits_from_traj_view2.size(); ++i) {
708  const recob::Hit * hit = hits_from_traj_view2[i];
709  size_t traj_index = index_from_traj_view2[i];
710 
711  double traj_x = traj.LocationAtPoint(traj_index).X();
712  double traj_y = traj.LocationAtPoint(traj_index).Y();
713  double traj_z = traj.LocationAtPoint(traj_index).Z();
714 
715  double diff = sqrt(std::pow((traj_x - check_x), 2) +
716  std::pow((traj_y - check_y), 2) +
717  std::pow((traj_z - check_z), 2));
718  if (diff > highest_diff) {
719  highest_diff = diff;
720  vertex_tpc = hit->WireID().TPC;
721  vertex_peak_time = hit->PeakTime();
722  vertex_wire = hit->WireID().Wire;
723  }
724  }
725  }
726 
727  std::pair<double, int> results = {0., 0};
728 
729  //Go through all hits in the event.
730  auto allHits = evt.getValidHandle<std::vector<recob::Hit>>(hitModule);
731  std::vector<art::Ptr<recob::Hit>> hit_vector;
732  art::fill_ptr_vector(hit_vector, allHits);
733  art::FindManyP<recob::Track> tracks_from_all_hits(allHits, evt, trackModule);
734  for (size_t i = 0; i < hit_vector.size(); ++i) {
735 
736  //If this hit is in the trajectory hits vector, skip
737  const recob::Hit * theHit = hit_vector[i].get();
738  if (std::find(hits_from_traj_view2.begin(),
739  hits_from_traj_view2.end(),
740  theHit) != hits_from_traj_view2.end()) {
741  continue;
742  }
743 
744  //Skip hits that are outside of our TPC/plane or window of interest
745  int wire = theHit->WireID().Wire;
746  float peak_time = theHit->PeakTime();
747  int tpc = theHit->WireID().TPC;
748  int plane = theHit->View();
749  if ((abs(wire - vertex_wire) > 15) ||
750  (abs(peak_time - vertex_peak_time) > 100.) ||
751  (tpc != vertex_tpc) || (plane != 2)) {
752  continue;
753  }
754 
755  //It's ok if the hits don't come from any track
756  //or if that track is the primary one, because sometimes the michel hits
757  //are associated to it.
758  //
759  //It's not ok if the hits come from another track that is long
760  //(i.e. an actual daughter). Skip these
761  auto & tracks_from_hit = tracks_from_all_hits.at(hit_vector[i].key());
762  if (!tracks_from_hit.empty() &&
763  (tracks_from_hit[0].get()->ID() != track.ID()) &&
764  (tracks_from_hit[0].get()->Length() > 25.))
765  continue;
766 
767  //add up the CNN results
768  std::array<float, 4> cnn_out = hitResults.getOutput(hit_vector[i]);
769  results.first += cnn_out[hitResults.getIndex("michel")];
770  results.second += 1;
771  }
772 
773  return results;
774 }
775 //Yinrui's modification
777  const recob::Track & track, const art::Event & evt,
778  const std::string trackModule, const std::string hitModule,
779  double min_length, double min_x,
780  double max_x, double min_y, double max_y, double min_z, bool check_wire,
781  double check_x, double check_y, double check_z) {
782 
784  anab::MVAReader<recob::Hit, 4> hitResults(evt, "emtrkmichelid:emtrkmichel");
785 
786  //Skip short tracks
787  //Skip tracks that start/end outside of interesting volume
788  auto start = track.Vertex();
789  auto end = track.End();
790  if ((TMath::Max(start.X(), end.X()) > max_x) ||
791  (TMath::Min(start.X(), end.X()) < min_x) ||
792  (TMath::Max(start.Y(), end.Y()) > max_y) ||
793  (TMath::Min(start.Y(), end.Y()) < min_y) ||
794  (TMath::Min(start.Z(), end.Z()) < min_z) ||
795  (track.Length() < min_length)) {
796  return {-1., 0};
797  }
798 
799 
800  //Get the hits from the TrackHitMetas and only for view 2 (collection plane)
801  std::map<size_t, const recob::Hit *>
802  hits_from_traj = GetRecoHitsFromTrajPoints(track, evt, trackModule);
803  std::vector<const recob::Hit *> hits_from_traj_view2;
804  std::vector<size_t> index_from_traj_view2;
805 
806  for (auto it = hits_from_traj.begin(); it != hits_from_traj.end(); ++it) {
807  if (it->second->View() != 2) continue;
808  hits_from_traj_view2.push_back(it->second);
809  index_from_traj_view2.push_back(it->first);
810  }
811 
812  //Find the vertex hit & info to compare to later
813  double highest_z = -100.;
814  int vertex_tpc = -1;
815  int vertex_wire = -1;
816  float vertex_peak_time = -1.;
817 
818  if (check_z) {
819  for (const auto * hit : hits_from_traj_view2) {
820  double wire_z = geom->Wire(hit->WireID()).GetCenter().Z();
821  if (wire_z > highest_z) {
822  highest_z = wire_z;
823  vertex_tpc = hit->WireID().TPC;
824  vertex_peak_time = hit->PeakTime();
825  vertex_wire = hit->WireID().Wire;
826  }
827  }
828  }
829  else {
830  const recob::TrackTrajectory & traj = track.Trajectory();
831  double highest_diff = -1.;
832  for (size_t i = 0; i < hits_from_traj_view2.size(); ++i) {
833  const recob::Hit * hit = hits_from_traj_view2[i];
834  size_t traj_index = index_from_traj_view2[i];
835 
836  double traj_x = traj.LocationAtPoint(traj_index).X();
837  double traj_y = traj.LocationAtPoint(traj_index).Y();
838  double traj_z = traj.LocationAtPoint(traj_index).Z();
839 
840  double diff = sqrt(std::pow((traj_x - check_x), 2) +
841  std::pow((traj_y - check_y), 2) +
842  std::pow((traj_z - check_z), 2));
843  if (diff > highest_diff) {
844  highest_diff = diff;
845  vertex_tpc = hit->WireID().TPC;
846  vertex_peak_time = hit->PeakTime();
847  vertex_wire = hit->WireID().Wire;
848  }
849  }
850  }
851 
852  std::pair<double, double> results = {0., 0.};
853 
854  //Go through all hits in the event.
855  auto allHits = evt.getValidHandle<std::vector<recob::Hit>>(hitModule);
856  std::vector<art::Ptr<recob::Hit>> hit_vector;
857  art::fill_ptr_vector(hit_vector, allHits);
858  art::FindManyP<recob::Track> tracks_from_all_hits(allHits, evt, trackModule);
859  for (size_t i = 0; i < hit_vector.size(); ++i) {
860 
861  //If this hit is in the trajectory hits vector, skip
862  const recob::Hit * theHit = hit_vector[i].get();
863  if (std::find(hits_from_traj_view2.begin(),
864  hits_from_traj_view2.end(),
865  theHit) != hits_from_traj_view2.end()) {
866  continue;
867  }
868 
869  //Skip hits that are outside of our TPC/plane or window of interest
870  int wire = theHit->WireID().Wire;
871  float peak_time = theHit->PeakTime();
872  int tpc = theHit->WireID().TPC;
873  int plane = theHit->View();
874  if ((abs(wire - vertex_wire) > 15) ||
875  (abs(peak_time - vertex_peak_time) > 100.) ||
876  (tpc != vertex_tpc) || (plane != 2)) {
877  continue;
878  }
879 
880  //It's ok if the hits don't come from any track
881  //or if that track is the primary one, because sometimes the michel hits
882  //are associated to it.
883  //
884  //It's not ok if the hits come from another track that is long
885  //(i.e. an actual daughter). Skip these
886  auto & tracks_from_hit = tracks_from_all_hits.at(hit_vector[i].key());
887  if (!tracks_from_hit.empty() &&
888  (tracks_from_hit[0].get()->ID() != track.ID()) &&
889  (tracks_from_hit[0].get()->Length() > 25.))
890  continue;
891 
892  //add up the CNN results
893  std::array<float, 4> cnn_out = hitResults.getOutput(hit_vector[i]);
894  double hitcharge = hit_vector[i]->Integral();
895  results.first += hitcharge*cnn_out[hitResults.getIndex("michel")];
896  results.second += hitcharge;
897  }
898 
899  return results;
900 }
901 //Ajib's implementation
903  const recob::Track & track, const art::Event & evt,
904  const std::string trackModule, const std::string hitModule,
905  double min_length, double min_x,
906  double max_x, double min_y, double max_y, double min_z, bool check_wire,
907  double check_x, double check_y, double check_z) {
908 
909  // Get all tracks
910  std::vector < art::Ptr < recob::Track > > trkList;
911  auto trkListHandle = evt.getHandle < std::vector < recob::Track > >(trackModule);
912  if (trkListHandle) {
913  art::fill_ptr_vector(trkList, trkListHandle);
914  }
915 
916  // Get all hits
917  std::vector < art::Ptr < recob::Hit > > hitList;
918  auto hitListHandle = evt.getHandle < std::vector < recob::Hit > >(hitModule);
919  if (hitListHandle) {
920  art::fill_ptr_vector(hitList, hitListHandle);
921  }
922 
923  // Get track-hit association
924  art::FindManyP<recob::Hit, recob::TrackHitMeta> fmthm(trkListHandle, evt,trackModule); // to associate tracks and hits
925 
926  // Get hit-track association
927  art::FindManyP<recob::Track> thass(hitListHandle, evt, trackModule); //to associate hit just trying
928 
929  // Get CNN scores
930  anab::MVAReader<recob::Hit, 4> hitResults(evt, "emtrkmichelid:emtrkmichel");
931 
932  int endwire = -1;
933  int endtpc = -1;
934  double endpeakt = -1;
935  std::vector<int> wirekeys;
936 
937  if (fmthm.isValid()){
938  float zlast0=-99999;
939  auto vhit=fmthm.at(track.ID());
940  auto vmeta=fmthm.data(track.ID());
941  for (size_t ii = 0; ii<vhit.size(); ++ii){ //loop over all meta data hit
942  bool fBadhit = false;
943  if (vmeta[ii]->Index() == static_cast<unsigned int>(std::numeric_limits<int>::max())){
944  fBadhit = true;
945  continue;
946  }
947  if (vmeta[ii]->Index()>=track.NumberTrajectoryPoints()){
948  throw cet::exception("Calorimetry_module.cc") << "Requested track trajectory index "<<vmeta[ii]->Index()<<" exceeds the total number of trajectory points "<<track.NumberTrajectoryPoints()<<" for track index "<<track.ID()<<". Something is wrong with the track reconstruction. Please contact tjyang@fnal.gov!!";
949  }
950  if (!track.HasValidPoint(vmeta[ii]->Index())){
951  fBadhit = true;
952  continue;
953  }
954  auto loc = track.LocationAtPoint(vmeta[ii]->Index());
955  if (fBadhit) continue; //HY::If BAD hit, skip this hit and go next
956  if (loc.Z()<-100) continue; //hit not on track
957  if(vhit[ii]->WireID().Plane==2){
958  wirekeys.push_back(vhit[ii].key());
959  float zlast=loc.Z();
960  if(zlast>zlast0){
961  zlast0=zlast;
962  endwire=vhit[ii]->WireID().Wire;
963  endpeakt=vhit[ii]->PeakTime();
964  endtpc=vhit[ii]->WireID().TPC;
965  }
966  }
967  }
968  }
969 
970  int ndaughterhits = 0;
971  double average_daughter_score_mic = 0;
972 
973  for(size_t hitl=0;hitl<hitList.size();hitl++){
974  std::array<float,4> cnn_out=hitResults.getOutput(hitList[hitl]);
975  auto & tracks = thass.at(hitList[hitl].key());
976  // hit not on the track
977  if (std::find(wirekeys.begin(), wirekeys.end(), hitl) != wirekeys.end()) continue;
978  // hit not on a long track
979  if (!tracks.empty() && int(tracks[0].key()) != track.ID() && trkList[tracks[0].key()]->Length()>25) continue;
980  int planeid=hitList[hitl]->WireID().Plane;
981  if (planeid!=2) continue;
982  int tpcid=hitList[hitl]->WireID().TPC;
983  if (tpcid!=endtpc) continue;
984  float peakth1=hitList[hitl]->PeakTime();
985  int wireh1=hitList[hitl]->WireID().Wire;
986  if(std::abs(wireh1-endwire)<8 && std::abs(peakth1-endpeakt)<150 && tpcid==endtpc){
987  ++ndaughterhits;
988  average_daughter_score_mic += cnn_out[hitResults.getIndex("michel")];
989  //std::cout<<hitList[hitl]->WireID().Wire<<" "<<hitList[hitl]->PeakTime()<<" "<<hitList[hitl]->Integral()<<" "<<cnn_out[hitResults.getIndex("michel")]<<std::endl;
990  }
991  }
992 
993  if (ndaughterhits) average_daughter_score_mic /= ndaughterhits;
994 
995  return {average_daughter_score_mic, ndaughterhits};
996 }
end
while True: pbar.update(maxval-len(onlies[E][S])) #print iS, "/", len(onlies[E][S]) found = False for...
std::pair< double, double > GetVertexMichelScore_weight_by_charge(const recob::Track &track, const art::Event &evt, const std::string trackModule, const std::string hitModule, double min_length=5., double min_x=-200., double max_x=0., double min_y=200., double max_y=500., double min_z=25., bool check_wire=true, double check_x=0, double check_y=0., double check_z=0.)
unsigned int GetNumberRecoTrackHits(const recob::Track &track, art::Event const &evt, const std::string trackModule) const
Get the number of hits from a given reco track.
std::vector< float > Combined_ResidualRange
bool IsBeamlike(const recob::Track &track, art::Event const &evt, const fhicl::ParameterSet &BeamPars, bool flip=false)
std::vector< anab::ParticleID > GetRecoTrackPID(const recob::Track &track, art::Event const &evt, const std::string trackModule, const std::string pidModule) const
Get the PID from a given track.
BrokenTrack IsBrokenTrack(const recob::Track &track, art::Event const &evt, const std::string trackModule, const std::string caloModule, const fhicl::ParameterSet &BrokenTrackPars, const fhicl::ParameterSet &CalorimetryPars)
Try to determine if it&#39;s a broken track.
double betap
Definition: doAna.cpp:14
const simb::MCParticle * GetGeantGoodParticle(const simb::MCTruth &genTruth, const art::Event &evt) const
Handle< PROD > getHandle(SelectorBase const &) const
Definition: DataViewImpl.h:382
std::string string
Definition: nybbler.cc:12
geo::WireID WireID() const
Definition: Hit.h:233
const recob::TrackTrajectory & Trajectory() const
Access to the stored recob::TrackTrajectory.
Definition: Track.h:98
std::vector< anab::Calorimetry > GetRecoTrackCalorimetry(const recob::Track &track, art::Event const &evt, const std::string trackModule, const std::string caloModule) const
Get the Calorimetry(s) from a given reco track.
Point_t const & LocationAtPoint(size_t i) const
Definition: Track.h:126
constexpr T pow(T x)
Definition: pow.h:72
bool HasValidPoint(size_t i) const
Definition: Track.h:111
size_t NumberTrajectoryPoints() const
Various functions related to the presence and the number of (valid) points.
Definition: Track.h:102
Class to keep data related to recob::Hit associated with recob::Track.
int getIndex(const std::string &name) const
Index of column with given name, or -1 if name not found.
Definition: MVAReader.h:82
geo::View_t View() const
View for the plane of the hit.
Definition: Hit.h:232
WireID_t Wire
Index of the wire within its plane.
Definition: geo_types.h:580
unsigned int Index
std::vector< anab::T0 > GetRecoTrackT0(const recob::Track &track, art::Event const &evt, std::string trackModule) const
Get the T0(s) from a given reco track.
std::pair< double, int > GetVertexMichelScore(const recob::Track &track, const art::Event &evt, const std::string trackModule, const std::string hitModule, double min_length=5., double min_x=-200., double max_x=0., double min_y=200., double max_y=500., double min_z=25., bool check_wire=true, double check_x=0, double check_y=0., double check_z=0.)
float calc_dEdX(double, double, double, double, double, double)
bool isRealData() const
T abs(T value)
double dEdx(float dqdx, float Efield)
Definition: doAna.cpp:21
Vector_t StartDirection() const
Access to track direction at different points.
Definition: Track.h:131
const double e
double Length(size_t p=0) const
Access to various track properties.
Definition: Track.h:167
IDparameter< geo::WireID > WireID
Member type of validated geo::WireID parameter.
def key(type, name=None)
Definition: graph.py:13
A trajectory in space reconstructed from hits.
T LocationAtPoint(unsigned int p) const
Position at point p. Use e.g. as:
const recob::Track * secondTrack
std::vector< anab::CosmicTag > GetRecoTrackCosmicTag(const recob::Track &track, art::Event const &evt, std::string trackModule) const
Get the cosmic tag(s) from a given reco track.
T get(std::string const &key) const
Definition: ParameterSet.h:271
Point_t const & Vertex() const
Definition: Track.h:124
double Rho
Definition: doAna.cpp:13
double alpha
Definition: doAna.cpp:15
ValidHandle< PROD > getValidHandle(InputTag const &tag) const
Definition: DataViewImpl.h:441
double calib_factor
Definition: doAna.cpp:18
static int max(int a, int b)
static constexpr double ps
Definition: Units.h:99
Detector simulation of raw signals on wires.
std::vector< float > Combined_dQdx
std::pair< double, int > Chi2PID(const std::vector< double > &track_dedx, const std::vector< double > &range, TProfile *profile)
std::vector< float > Combined_dEdx
const std::vector< const recob::Hit * > GetRecoTrackHitsFromPlane(const recob::Track &track, art::Event const &evt, const std::string trackModule, unsigned int planeID) const
Get the hits from a given reco track from a specific plane.
Definition: tracks.py:1
WireGeo const & Wire(geo::WireID const &wireid) const
Returns the specified wire.
int ID() const
Definition: Track.h:198
const std::vector< const recob::Hit * > GetRecoTrackHits(const recob::Track &track, art::Event const &evt, const std::string trackModule) const
Get the hits from a given reco track.
float PeakTime() const
Time of the signal peak, in tick units.
Definition: Hit.h:218
Declaration of signal hit object.
const recob::Track * firstTrack
Vector_t EndDirection() const
Definition: Track.h:133
Point_t const & End() const
Returns the position of the last valid point of the trajectory [cm].
QTextStream & bin(QTextStream &s)
Point_t const & End() const
Definition: Track.h:125
const std::vector< recob::Track > & GetBeamTracks() const
2D representation of charge deposited in the TDC/wire plane
Definition: Hit.h:48
TCEvent evt
Definition: DataStructs.cxx:7
void fill_ptr_vector(std::vector< Ptr< T >> &ptrs, H const &h)
Definition: Ptr.h:297
TPCID_t TPC
Index of the TPC within its cryostat.
Definition: geo_types.h:406
double Wion
Definition: doAna.cpp:16
std::map< size_t, const recob::Hit * > GetRecoHitsFromTrajPoints(const recob::Track &track, art::Event const &evt, std::string trackModule)
Point_t const & Start() const
Returns the position of the first valid point of the trajectory [cm].
std::pair< double, int > Chi2PIDFromTrack_MC(const recob::Track &track, art::Event const &evt, const std::string trackModule, const std::string caloModule, TProfile *profile)
Until we have fully calibrated calorimetry, use this PID algo.
std::array< float, N > getOutput(size_t key) const
Get copy of the MVA output vector at index "key".
Definition: MVAReader.h:129
std::string to_string(ModuleType const mt)
Definition: ModuleType.h:34
Track from a non-cascading particle.A recob::Track consists of a recob::TrackTrajectory, plus additional members relevant for a "fitted" track:
Definition: Track.h:49
calorimetry
std::pair< double, int > GetVertexMichelScoreAlt(const recob::Track &track, const art::Event &evt, const std::string trackModule, const std::string hitModule, double min_length=5., double min_x=-200., double max_x=0., double min_y=200., double max_y=500., double min_z=25., bool check_wire=true, double check_x=0, double check_y=0., double check_z=0.)
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
QTextStream & endl(QTextStream &s)
std::vector< float > CalibrateCalorimetry(const recob::Track &track, art::Event const &evt, const std::string trackModule, const std::string caloModule, const fhicl::ParameterSet &ps)
Calibrate a Calorimetry object for a given plane from a given track.