LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
AggregateVertexAna_module.cc
Go to the documentation of this file.
1 //
3 // AggregateVertexAna module
4 //
5 // brebel@fnal.gov
6 //
8 
9 // Framework includes
15 #include "art_root_io/TFileService.h"
19 #include "fhiclcpp/ParameterSet.h"
21 
22 #include <string>
23 
28 
29 #include "TH1.h"
30 #include "TH2.h"
31 
32 namespace vertex {
33 
35 
36  public:
37  explicit AggregateVertexAna(fhicl::ParameterSet const& pset);
39 
40  private:
41  void analyze(const art::Event& evt);
42  void beginJob();
43 
44  TH1F* HnTrksVtx;
45  TH1F* HnVtxes;
46  TH1F* HVtxSep;
47  TH2F* HVtxRZ;
48 
49  std::string fDBScanModuleLabel;
50  std::string fHoughModuleLabel;
51  std::string fHitModuleLabel;
52  std::string fTrack3DModuleLabel;
53  std::string fEndPointModuleLabel;
54  std::string fVertexModuleLabel;
55 
60 
61  }; // class AggregateVertexAna
62 
63 } // Namespace aggr
64 
65 namespace vertex {
66 
67  //-----------------------------------------------
69  : EDAnalyzer(pset)
70  , fHitModuleLabel(pset.get<std::string>("FFFTHitModuleLabel"))
71  , fTrack3DModuleLabel(pset.get<std::string>("Track3DModuleLabel"))
72  , fEndPointModuleLabel(pset.get<std::string>("EndPointModuleLabel"))
73  , fVertexModuleLabel(pset.get<std::string>("VertexModuleLabel"))
74  {}
75 
76  //-----------------------------------------------
78 
79  //-----------------------------------------------
81  {
83 
84  HnVtxes = tfs->make<TH1F>("Num Vertices", "Num Vertices", 8, -0.5, 7.5);
85  HVtxSep = tfs->make<TH1F>("Vertices spacing", "Vertices spacing", 20, 0.001, 5.0);
86  HVtxRZ = tfs->make<TH2F>("Vtx in RZ", "Vtx in RZ", 20, -50.0, +50.0, 20, 0.0, 50.0);
87  HnTrksVtx = tfs->make<TH1F>("Tracks per vtx", "Tracks per vtx", 8, -0.5, 7.5);
88 
89  return;
90  }
91 
92  //-----------------------------------------------
94  {
96  evt.getByLabel(fHitModuleLabel, hitListHandle);
97  for (unsigned int ii = 0; ii < hitListHandle->size(); ++ii) {
98  art::Ptr<recob::Hit> hit(hitListHandle, ii);
99  fhitlist.push_back(hit); // class member
100  }
101 
103  evt.getByLabel(fEndPointModuleLabel, epListHandle);
104  for (unsigned int ii = 0; ii < epListHandle->size(); ++ii) {
105  art::Ptr<recob::EndPoint2D> ep(epListHandle, ii);
106  feplist.push_back(ep); // class member
107  }
108 
109  art::Handle<std::vector<recob::Track>> trackListHandle;
110  evt.getByLabel(fTrack3DModuleLabel, trackListHandle);
111  for (unsigned int ii = 0; ii < trackListHandle->size(); ++ii) {
112  art::Ptr<recob::Track> track(trackListHandle, ii);
113  ftracklist.push_back(track); // class member
114  }
115 
116  art::Handle<std::vector<recob::Vertex>> vertexListHandle;
117  evt.getByLabel(fVertexModuleLabel, vertexListHandle);
118  for (unsigned int ii = 0; ii < vertexListHandle->size(); ++ii) {
119  art::Ptr<recob::Vertex> vertex(vertexListHandle, ii);
120  fVertexlist.push_back(vertex); // class member
121  }
122 
123  HnVtxes->Fill(feplist.size(), 1);
124 
125  art::FindManyP<recob::Track> fmt(vertexListHandle, evt, fVertexModuleLabel);
126  art::FindManyP<recob::Hit> fmh(vertexListHandle, evt, fVertexModuleLabel);
127 
128  for (size_t v1 = 0; v1 < fVertexlist.size(); ++v1) {
129 
130  std::vector<art::Ptr<recob::Track>> tvlist = fmt.at(v1);
131 
132  HnTrksVtx->Fill(tvlist.size(), 1);
133 
134  if (tvlist.size() < 1) continue;
135 
136  std::vector<art::Ptr<recob::Hit>> hitvlist = fmh.at(v1);
137 
138  // Hits no longer has XYZ() method. To get 3d hit position info I'm going to have to
139  // loop on all the SpacePoints and loop on all Hits from there till it matches
140  // one from this vertex. This affects the two Fill() efforts below. EC, 19-Nov-2010.
141  art::PtrVector<recob::Hit>::const_iterator hitv = hitvlist.begin();
142 
143  for (size_t v2 = v1 + 1; v2 < fVertexlist.size(); ++v2) {
144 
145  std::vector<art::Ptr<recob::Hit>> hitvlist2 = fmh.at(v2);
146 
147  std::vector<art::Ptr<recob::Hit>>::const_iterator hitv2 = hitvlist2.begin();
148 
149  // These two whiles should be each precisely one iteration long.
150  while (hitv != hitvlist.end()) {
151  while (hitv2 != hitvlist2.end()) {
152  TVector3 dist;
153  mf::LogInfo("AggregateVertexAna")
154  << "AggregateVertexAna: dist is " << dist.Mag() << ".";
155  HVtxSep->Fill(dist.Mag(), 1);
156  hitv2++;
157  }
158  hitv++;
159  } // end loop over hitv entries
160 
161  } // end loop over v2
162  } // end loop over v1
163 
164  return;
165  } // end analyze
166 } // end namespace
167 
168 namespace vertex {
169 
171 
172 }
MaybeLogger_< ELseverityLevel::ELsev_info, false > LogInfo
Declaration of signal hit object.
art::PtrVector< recob::Track > ftracklist
STL namespace.
art::PtrVector< recob::Hit > fhitlist
EDAnalyzer(fhicl::ParameterSet const &pset)
Definition: EDAnalyzer.cc:6
void analyze(const art::Event &evt)
art::PtrVector< recob::EndPoint2D > feplist
typename data_t::const_iterator const_iterator
Definition: PtrVector.h:55
#define DEFINE_ART_MODULE(klass)
Definition: ModuleMacros.h:65
void push_back(Ptr< U > const &p)
Definition: PtrVector.h:435
Provides recob::Track data product.
size_type size() const
Definition: PtrVector.h:302
Detector simulation of raw signals on wires.
decltype(auto) get(T &&obj)
ADL-aware version of std::to_string.
Definition: StdUtils.h:120
bool getByLabel(std::string const &label, std::string const &instance, Handle< PROD > &result) const
constexpr double dist(const TReal *x, const TReal *y, const unsigned int dimension)
art::PtrVector< recob::Vertex > fVertexlist
TCEvent evt
Definition: DataStructs.cxx:8
Float_t track
Definition: plot.C:35
AggregateVertexAna(fhicl::ParameterSet const &pset)
vertex reconstruction