All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
icarusalg/icarusalg/gallery/galleryAnalysis/C++/TrackAnalysis.cpp
Go to the documentation of this file.
1 /**
2  * @file TrackAnalysis.cpp
3  * @brief Does something with the tracks (implementation file).
4  * @author Gianluca Petrillo (petrillo@fnal.gov)
5  * @date October 23, 2017
6  * @see TrackAnalysis.h
7  *
8  */
9 
10 #include "TrackAnalysis.h"
11 
12 // LArSoft libraries
13 
14 // canvas libraries
15 
16 // ROOT libraries
17 
18 // C/C++ standard libraries
19 #include <algorithm> // std::count_if()
20 
21 
22 TrackAnalysis::TrackAnalysis(fhicl::ParameterSet const& config)
23  : fMinLength(config.get<double>("MinLength", 0.0))
24  {}
25 
27  if (fDir) {
28  fHNTracks = std::make_unique<TH1F>
29  ("HNTracks", "Number of tracks;number of tracks;events", 50, 0., 50.);
30  fHNTracks->SetDirectory(fDir);
31  }
32  else fHNTracks.reset();
33 } // TrackAnalysis::prepare()
34 
35 
36 void TrackAnalysis::processTracks(std::vector<recob::Track> const& tracks) {
37 
38  unsigned int nTracksAboveThreshold = std::count_if(
39  tracks.begin(), tracks.end(),
40  [this](auto const& track){ return track.Length() > fMinLength; }
41  );
42 
43  if (fHNTracks) fHNTracks->Fill(nTracksAboveThreshold);
44 
45 } // TrackAnalysis::processTracks()
46 
47 
49  if (fHNTracks) {
50  fDir->cd();
51  fHNTracks->Write();
52  }
53 } // TrackAnalysis::finish()
54 
ClusterModuleLabel join with tracks
process_name use argoneut_mc_hitfinder track
double fMinLength
Minimum length, in centimetres.
void processTracks(std::vector< recob::Track > const &tracks)