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