LArSoft  v07_13_02
Liquid Argon Software toolkit - http://larsoft.org/
AggregateVertexAna_module.cc
Go to the documentation of this file.
1 //
3 // AggregateVertexAna module
4 //
5 // brebel@fnal.gov
6 //
8 #ifndef VERTEX_AGGREGATEVERTEXANA_H
9 #define VERTEX_AGGREGATEVERTEXANA_H
10 
11 extern "C" {
12 #include <sys/types.h>
13 #include <sys/stat.h>
14 }
15 
16 // Framework includes
18 #include "fhiclcpp/ParameterSet.h"
29 
30 #include <vector>
31 #include <string>
32 
38 
39 #include "TF1.h"
40 #include "TH1.h"
41 #include "TH2.h"
42 
43 namespace vertex {
44 
46 
47  public:
48 
49  explicit AggregateVertexAna(fhicl::ParameterSet const& pset);
51 
52  void analyze (const art::Event& evt);
53  void beginJob();
54 
55  private:
56 
57  TH1F* HnTrksVtx;
58  TH1F* HnVtxes;
59  TH1F* HVtxSep;
60  TH2F* HVtxRZ;
61 
62  std::string fDBScanModuleLabel;
63  std::string fHoughModuleLabel;
64  std::string fHitModuleLabel;
65  std::string fTrack3DModuleLabel;
66  std::string fEndPointModuleLabel;
67  std::string fVertexModuleLabel;
68 
73 
74 
75  }; // class AggregateVertexAna
76 
77 } // Namespace aggr
78 
79 namespace vertex{
80 
81  //-----------------------------------------------
83  : EDAnalyzer(pset)
84  , fHitModuleLabel (pset.get< std::string >("FFFTHitModuleLabel"))
85  , fTrack3DModuleLabel (pset.get< std::string >("Track3DModuleLabel"))
86  , fEndPointModuleLabel(pset.get< std::string >("EndPointModuleLabel"))
87  , fVertexModuleLabel (pset.get< std::string >("VertexModuleLabel"))
88  {
89 
90 
91  }
92 
93  //-----------------------------------------------
95  {
96  }
97 
98  //-----------------------------------------------
100  {
102 
103  HnVtxes = tfs->make<TH1F>("Num Vertices","Num Vertices",8,-0.5,7.5);
104  HVtxSep = tfs->make<TH1F>("Vertices spacing","Vertices spacing",20,0.001,5.0);
105  HVtxRZ = tfs->make<TH2F>("Vtx in RZ","Vtx in RZ",20,-50.0,+50.0,20,0.0,50.0);
106  HnTrksVtx = tfs->make<TH1F>("Tracks per vtx","Tracks per vtx",8,-0.5,7.5);
107 
108  return;
109  }
110 
111  //-----------------------------------------------
113  {
114  art::Handle< std::vector<recob::Hit> > hitListHandle;
115  evt.getByLabel(fHitModuleLabel,hitListHandle);
116  for(unsigned int ii = 0; ii < hitListHandle->size(); ++ii){
117  art::Ptr<recob::Hit> hit(hitListHandle, ii);
118  fhitlist.push_back(hit); // class member
119  }
120 
122  evt.getByLabel(fEndPointModuleLabel,epListHandle);
123  for(unsigned int ii = 0; ii < epListHandle->size(); ++ii){
124  art::Ptr<recob::EndPoint2D> ep(epListHandle, ii);
125  feplist.push_back(ep); // class member
126  }
127 
128  art::Handle< std::vector<recob::Track> > trackListHandle;
129  evt.getByLabel(fTrack3DModuleLabel,trackListHandle);
130  for(unsigned int ii = 0; ii < trackListHandle->size(); ++ii){
131  art::Ptr<recob::Track> track(trackListHandle, ii);
132  ftracklist.push_back(track); // class member
133  }
134 
135  art::Handle< std::vector<recob::Vertex> > vertexListHandle;
136  evt.getByLabel(fVertexModuleLabel,vertexListHandle);
137  for(unsigned int ii = 0; ii < vertexListHandle->size(); ++ii){
138  art::Ptr<recob::Vertex> vertex(vertexListHandle, ii);
139  fVertexlist.push_back(vertex); // class member
140  }
141 
142  HnVtxes->Fill(feplist.size(),1);
143 
144  art::FindManyP<recob::Track> fmt(vertexListHandle, evt, fVertexModuleLabel);
145  art::FindManyP<recob::Hit> fmh(vertexListHandle, evt, fVertexModuleLabel);
146 
147  for(size_t v1 = 0; v1 < fVertexlist.size(); ++v1) {
148 
149  std::vector< art::Ptr<recob::Track> > tvlist = fmt.at(v1);
150 
151  HnTrksVtx->Fill(tvlist.size(),1);
152 
153  if(tvlist.size() < 1) continue;
154 
155  std::vector< art::Ptr<recob::Hit> > hitvlist = fmh.at(v1);
156 
157  // Hits no longer has XYZ() method. To get 3d hit position info I'm going to have to
158  // loop on all the SpacePoints and loop on all Hits from there till it matches
159  // one from this vertex. This affects the two Fill() efforts below. EC, 19-Nov-2010.
160  art::PtrVector<recob::Hit>::const_iterator hitv = hitvlist.begin();
161 
162  for(size_t v2 = v1+1; v2 < fVertexlist.size(); ++v2){
163 
164  std::vector< art::Ptr<recob::Hit> > hitvlist2 = fmh.at(v2);
165 
166  std::vector< art::Ptr<recob::Hit> >::const_iterator hitv2 = hitvlist2.begin();
167 
168  // These two whiles should be each precisely one iteration long.
169  while( hitv != hitvlist.end() ){
170  while( hitv2 != hitvlist2.end() ){
171  TVector3 dist;
172  mf::LogInfo("AggregateVertexAna") << "AggregateVertexAna: dist is " << dist.Mag() << ".";
173  HVtxSep->Fill(dist.Mag(),1);
174  hitv2++;
175  }
176  hitv++;
177  }// end loop over hitv entries
178 
179  }// end loop over v2
180  }// end loop over v1
181 
182  return;
183  }// end analyze
184 }// end namespace
185 
186 namespace vertex{
187 
189 
190 }
191 #endif // AGGREGATEVTXANA_H
MaybeLogger_< ELseverityLevel::ELsev_info, false > LogInfo
Declaration of signal hit object.
art::PtrVector< recob::Track > ftracklist
STL namespace.
art::PtrVector< recob::Hit > fhitlist
void analyze(const art::Event &evt)
art::PtrVector< recob::EndPoint2D > feplist
#define DEFINE_ART_MODULE(klass)
Definition: ModuleMacros.h:42
Provides recob::Track data product.
void push_back(Ptr< U > const &p)
Definition: PtrVector.h:441
EDAnalyzer(Table< Config > const &config)
Definition: EDAnalyzer.h:100
size_type size() const
Definition: PtrVector.h:308
Detector simulation of raw signals on wires.
data_t::const_iterator const_iterator
Definition: PtrVector.h:61
T * make(ARGS...args) const
Utility object to perform functions of association.
bool getByLabel(std::string const &label, std::string const &productInstanceName, Handle< PROD > &result) const
Definition: DataViewImpl.h:344
art::PtrVector< recob::Vertex > fVertexlist
TCEvent evt
Definition: DataStructs.cxx:5
Float_t track
Definition: plot.C:34
AggregateVertexAna(fhicl::ParameterSet const &pset)
vertex reconstruction