LArSoft  v06_85_00
Liquid Argon Software toolkit - http://larsoft.org/
TTSpacePointFinder_module.cc
Go to the documentation of this file.
1 #ifndef TTSPACEPOINTFINDER_H
2 #define TTSPACEPOINTFINDER_H
3 
22 #include <string>
23 #include <math.h>
24 
25 // Framework includes
29 
30 // LArSoft Includes
38 
39 namespace sppt{
40 
42 
43  public:
44 
45  explicit TTSpacePointFinder(fhicl::ParameterSet const& pset);
46  virtual ~TTSpacePointFinder();
47 
48  void produce(art::Event& evt);
49  void beginJob();
50  void beginRun(art::Run& run);
51  void endJob();
52  void reconfigure(fhicl::ParameterSet const& p);
53 
54  private:
55 
56  std::string fHitModuleLabel;
57  std::string fUHitsInstanceLabel;
58  std::string fVHitsInstanceLabel;
59  std::string fYHitsInstanceLabel;
60 
62 
63  protected:
64 
65  }; // class TTSpacePointFinder
66 
67  //-------------------------------------------------
69  fSpptAlg( pset.get< fhicl::ParameterSet >("SpacePointAlgParams") )
70  {
71  this->reconfigure(pset);
72  produces< std::vector<recob::SpacePoint> >();
73  produces<art::Assns<recob::SpacePoint, recob::Hit> >();
74  }
75 
76  //-------------------------------------------------
78 
79  //-------------------------------------------------
81  fHitModuleLabel = p.get< std::string >("HitModuleLabel","tthit");
82  fUHitsInstanceLabel = p.get< std::string >("UHitsInstaceLabel","uhits");
83  fVHitsInstanceLabel = p.get< std::string >("VHitsInstaceLabel","vhits");
84  fYHitsInstanceLabel = p.get< std::string >("YHitsInstaceLabel","yhits");
85 
86  fSpptAlg.reconfigure(p.get< fhicl::ParameterSet >("SpacePointAlgParams"));
87 
88  }
89 
90  //-------------------------------------------------
92 
93  //-------------------------------------------------
97  }
98 
99  //-------------------------------------------------
101 
102  //-------------------------------------------------
104  {
105 
106  //initialize our spacepoint collection
107  std::unique_ptr<std::vector<recob::SpacePoint> > spptCollection(new std::vector<recob::SpacePoint>);
108  std::unique_ptr<std::vector<std::vector<art::Ptr<recob::Hit> > > >
109  spptAssociatedHits(new std::vector<std::vector<art::Ptr<recob::Hit> > >);
110 
111  // Read in the hits. Note, we will reorder hit vector, so we do in fact need a copy.
114  std::vector< art::Ptr<recob::Hit> > hitVec_U;
115  art::fill_ptr_vector(hitVec_U,hitHandle_U);
116 
119  std::vector< art::Ptr<recob::Hit> > hitVec_V;
120  art::fill_ptr_vector(hitVec_V,hitHandle_V);
121 
124  std::vector< art::Ptr<recob::Hit> > hitVec_Y;
125  art::fill_ptr_vector(hitVec_Y,hitHandle_Y);
126 
127  LOG_DEBUG("TTSpacePointFinder")
128  << "Got handles to hits:\n"
129  << hitVec_U.size() << " u hits, "
130  << hitVec_V.size() << " v hits, "
131  << hitVec_Y.size() << " y hits.";
132 
133  //now, call the space point alg
134  fSpptAlg.createSpacePoints(hitVec_U,hitVec_V,hitVec_Y,
135  spptCollection,spptAssociatedHits);
136 
137  mf::LogInfo("TTSpacePointFinder") << "Finished spacepoint alg. Created " << spptCollection->size() << " spacepoints.";
138 
139 
140  //check that spptCollection and spptAssociatedHits have same size
141  if(spptCollection->size() != spptAssociatedHits->size()){
142  mf::LogError("TTSpacePointFinder") << "ERROR in space point alg.\n"
143  << "Spacepoint and associated hit collections have different sizes!\n"
144  << spptCollection->size() << " != " << spptAssociatedHits->size()
145  << "\nWill return with no space points put on event.";
146  return;
147  }
148 
149  //Now, need to fill in the sppt<-->hit associations
150  std::unique_ptr<art::Assns<recob::SpacePoint,recob::Hit> > spptAssns(new art::Assns<recob::SpacePoint,recob::Hit>);
151  for(unsigned int isppt=0; isppt<spptCollection->size(); isppt++){
152  util::CreateAssn(*this,evt,*spptCollection,spptAssociatedHits->at(isppt),*spptAssns,isppt);
153  }
154 
155  //finally, put things on the event
156  evt.put(std::move(spptCollection));
157  evt.put(std::move(spptAssns));
158 
159  } // End of produce()
160 
162 
163 } // end of sppt namespace
164 
165 
166 #endif // TTSPACEPOINTFINDER_H
MaybeLogger_< ELseverityLevel::ELsev_info, false > LogInfo
Declaration of signal hit object.
MaybeLogger_< ELseverityLevel::ELsev_error, false > LogError
Definition: Run.h:30
ProductID put(std::unique_ptr< PROD > &&product)
Definition: Event.h:102
auto vector(Vector const &v)
Returns a manipulator which will print the specified array.
Definition: DumpUtils.h:265
#define DEFINE_ART_MODULE(klass)
Definition: ModuleMacros.h:42
parameter set interface
std::string fYHitsInstanceLabel
Input V hits instance name.
T get(std::string const &key) const
Definition: ParameterSet.h:231
bool CreateAssn(PRODUCER const &prod, art::Event &evt, std::vector< T > const &a, art::Ptr< U > const &b, art::Assns< U, T > &assn, std::string a_instance, size_t indx=UINT_MAX)
Creates a single one-to-one association.
std::string fVHitsInstanceLabel
Input U hits instance name.
Definition of data types for geometry description.
void createSpacePoints(std::vector< art::Ptr< recob::Hit > > &hitVec_U, std::vector< art::Ptr< recob::Hit > > &hitVec_V, std::vector< art::Ptr< recob::Hit > > &hitVec_Y, std::unique_ptr< std::vector< recob::SpacePoint > > &spptCollection, std::unique_ptr< std::vector< std::vector< art::Ptr< recob::Hit > > > > &spptAssociatedHits)
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
void reconfigure(fhicl::ParameterSet const &p)
void reconfigure(fhicl::ParameterSet const &pset)
std::string fUHitsInstanceLabel
Input hit module name.
#define LOG_DEBUG(id)
SpacePointAlg_TimeSort fSpptAlg
Input Y hits instance name.
void fill_ptr_vector(std::vector< Ptr< T >> &ptrs, H const &h)
Definition: Ptr.h:464
TTSpacePointFinder(fhicl::ParameterSet const &pset)
art framework interface to geometry description