LArSoft  v06_85_00
Liquid Argon Software toolkit - http://larsoft.org/
vertex::PrimaryVertexFinder Class Reference
Inheritance diagram for vertex::PrimaryVertexFinder:
art::EDProducer art::ProducerBase art::Consumer art::EngineCreator art::ProductRegistryHelper

Public Types

using ModuleType = EDProducer
 
using WorkerType = WorkerT< EDProducer >
 
template<typename UserConfig , typename KeysToIgnore = void>
using Table = ProducerBase::Table< UserConfig, KeysToIgnore >
 

Public Member Functions

 PrimaryVertexFinder (fhicl::ParameterSet const &pset)
 
virtual ~PrimaryVertexFinder ()
 
void beginJob ()
 
void reconfigure (fhicl::ParameterSet const &p)
 
void produce (art::Event &evt)
 
template<typename PROD , BranchType B = InEvent>
ProductID getProductID (std::string const &instanceName={}) const
 
template<typename PROD , BranchType B>
ProductID getProductID (ModuleDescription const &moduleDescription, std::string const &instanceName) const
 
bool modifiesEvent () const
 
template<typename T , BranchType = InEvent>
ProductToken< T > consumes (InputTag const &)
 
template<typename T , art::BranchType BT>
art::ProductToken< T > consumes (InputTag const &it)
 
template<typename T , BranchType = InEvent>
void consumesMany ()
 
template<typename Element , BranchType = InEvent>
ViewToken< Element > consumesView (InputTag const &)
 
template<typename T , art::BranchType BT>
art::ViewToken< T > consumesView (InputTag const &it)
 
template<typename T , BranchType = InEvent>
ProductToken< T > mayConsume (InputTag const &)
 
template<typename T , art::BranchType BT>
art::ProductToken< T > mayConsume (InputTag const &it)
 
template<typename T , BranchType = InEvent>
void mayConsumeMany ()
 
template<typename Element , BranchType = InEvent>
ViewToken< Element > mayConsumeView (InputTag const &)
 
template<typename T , art::BranchType BT>
art::ViewToken< T > mayConsumeView (InputTag const &it)
 
base_engine_tcreateEngine (seed_t seed)
 
base_engine_tcreateEngine (seed_t seed, std::string const &kind_of_engine_to_make)
 
base_engine_tcreateEngine (seed_t seed, std::string const &kind_of_engine_to_make, label_t const &engine_label)
 
seed_t get_seed_value (fhicl::ParameterSet const &pset, char const key[]="seed", seed_t const implicit_seed=-1)
 

Static Public Member Functions

static cet::exempt_ptr< Consumernon_module_context ()
 

Protected Member Functions

CurrentProcessingContext const * currentContext () const
 
void validateConsumedProduct (BranchType const bt, ProductInfo const &pi)
 
void prepareForJob (fhicl::ParameterSet const &pset)
 
void showMissingConsumes () const
 

Private Member Functions

double StartPointSeperation (recob::SpacePoint sp1, recob::SpacePoint sp2)
 
bool IsInVertexCollection (int a, std::vector< std::vector< int > > vertex_collection)
 
int IndexInVertexCollection (int a, int b, std::vector< std::vector< int > > vertex_collection)
 
bool IsInNewVertex (int a, std::vector< int > newvertex)
 
double gammavalue (TVector3 startpoint1, TVector3 startpoint2, TVector3 dircos1, TVector3 dircos2)
 
double alphavalue (double gamma, TVector3 startpoint1, TVector3 startpoint2, TVector3 dircos1, TVector3 dircos2)
 
double MinDist (double alpha, double gamma, TVector3 startpoint1, TVector3 startpoint2, TVector3 dircos1, TVector3 dircos2)
 
TVector3 PointOnExtendedTrack (double alphagamma, TVector3 startpoint, TVector3 dircos)
 

Private Attributes

std::string fTrackModuleLabel
 
double fVertexWindow
 
TH2F * fNoTracks
 
TH1F * fLength_1stTrack
 
TH1F * fLength_2ndTrack
 
TH1F * fLength_3rdTrack
 
TH1F * fLength_4thTrack
 
TH1F * fLength_5thTrack
 

Detailed Description

Definition at line 61 of file PrimaryVertexFinder_module.cc.

Member Typedef Documentation

using art::EDProducer::ModuleType = EDProducer
inherited

Definition at line 34 of file EDProducer.h.

template<typename UserConfig , typename KeysToIgnore = void>
using art::EDProducer::Table = ProducerBase::Table<UserConfig, KeysToIgnore>
inherited

Definition at line 43 of file EDProducer.h.

using art::EDProducer::WorkerType = WorkerT<EDProducer>
inherited

Definition at line 35 of file EDProducer.h.

Constructor & Destructor Documentation

vertex::PrimaryVertexFinder::PrimaryVertexFinder ( fhicl::ParameterSet const &  pset)
explicit

Definition at line 106 of file PrimaryVertexFinder_module.cc.

107  {
108  this->reconfigure(pset);
109  produces< std::vector<recob::Vertex> >();
110  produces< art::Assns<recob::Vertex, recob::Hit> >();
111  produces< art::Assns<recob::Vertex, recob::Track> >();
112  produces< art::Assns<recob::Vertex, recob::Shower> >();
113  }
void reconfigure(fhicl::ParameterSet const &p)
vertex::PrimaryVertexFinder::~PrimaryVertexFinder ( )
virtual

Definition at line 116 of file PrimaryVertexFinder_module.cc.

117  {
118  }

Member Function Documentation

double vertex::PrimaryVertexFinder::alphavalue ( double  gamma,
TVector3  startpoint1,
TVector3  startpoint2,
TVector3  dircos1,
TVector3  dircos2 
)
private

Definition at line 475 of file PrimaryVertexFinder_module.cc.

476 {
477  double alpha = (gamma*(dircos1*dircos2)) + (startpoint2*dircos1) - (startpoint1*dircos1);
478 
479  return alpha;
480 }
void vertex::PrimaryVertexFinder::beginJob ( )
virtual

Reimplemented from art::EDProducer.

Definition at line 128 of file PrimaryVertexFinder_module.cc.

References art::TFileDirectory::make().

128  {
129  // get access to the TFile service
131 
132  // fNoVertices= tfs->make<TH2F>("fNoVertices", ";Event No; No of vertices", 100,0, 100, 30, 0, 30);
133  fNoTracks= tfs->make<TH2F>("fNoTracks", ";Event No; No of Tracks", 10,0, 10, 10, 0, 10);
134  fLength_1stTrack = tfs->make<TH1F>("fLength_Track1", "Muon Track Length", 100,0,100);
135  fLength_2ndTrack = tfs->make<TH1F>("fLength_Track2", "2nd Track Length", 100,0,100);
136  fLength_3rdTrack = tfs->make<TH1F>("fLength_Track3", "3rd Track Length", 100,0,100);
137  fLength_4thTrack = tfs->make<TH1F>("fLength_Track4", "4th Track Length", 100,0,100);
138  fLength_5thTrack = tfs->make<TH1F>("fLength_Track5", "5th Track Length", 100,0,100);
139  }
T * make(ARGS...args) const
template<typename T , BranchType = InEvent>
ProductToken<T> art::Consumer::consumes ( InputTag const &  )
inherited
template<typename T , art::BranchType BT>
art::ProductToken<T> art::Consumer::consumes ( InputTag const &  it)
inherited

Definition at line 147 of file Consumer.h.

References art::InputTag::instance(), art::InputTag::label(), and art::InputTag::process().

148 {
149  if (!moduleContext_)
150  return ProductToken<T>::invalid();
151 
152  consumables_[BT].emplace_back(ConsumableType::Product,
153  TypeID{typeid(T)},
154  it.label(),
155  it.instance(),
156  it.process());
157  return ProductToken<T>{it};
158 }
static ProductToken< T > invalid()
Definition: ProductToken.h:47
ConsumableProducts consumables_
Definition: Consumer.h:138
bool moduleContext_
Definition: Consumer.h:136
template<typename T , art::BranchType BT>
void art::Consumer::consumesMany ( )
inherited

Definition at line 162 of file Consumer.h.

163 {
164  if (!moduleContext_)
165  return;
166 
167  consumables_[BT].emplace_back(ConsumableType::Many, TypeID{typeid(T)});
168 }
ConsumableProducts consumables_
Definition: Consumer.h:138
bool moduleContext_
Definition: Consumer.h:136
template<typename Element , BranchType = InEvent>
ViewToken<Element> art::Consumer::consumesView ( InputTag const &  )
inherited
template<typename T , art::BranchType BT>
art::ViewToken<T> art::Consumer::consumesView ( InputTag const &  it)
inherited

Definition at line 172 of file Consumer.h.

References art::InputTag::instance(), art::InputTag::label(), and art::InputTag::process().

173 {
174  if (!moduleContext_)
175  return ViewToken<T>::invalid();
176 
177  consumables_[BT].emplace_back(ConsumableType::ViewElement,
178  TypeID{typeid(T)},
179  it.label(),
180  it.instance(),
181  it.process());
182  return ViewToken<T>{it};
183 }
static ViewToken< Element > invalid()
Definition: ProductToken.h:75
ConsumableProducts consumables_
Definition: Consumer.h:138
bool moduleContext_
Definition: Consumer.h:136
EngineCreator::base_engine_t & EngineCreator::createEngine ( seed_t  seed,
std::string const &  kind_of_engine_to_make 
)
inherited

Definition at line 32 of file EngineCreator.cc.

References art::EngineCreator::rng().

34 {
35  return rng()->createEngine(
36  placeholder_schedule_id(), seed, kind_of_engine_to_make);
37 }
long seed
Definition: chem4.cc:68
static art::ServiceHandle< art::RandomNumberGenerator > & rng()
EngineCreator::base_engine_t & EngineCreator::createEngine ( seed_t  seed,
std::string const &  kind_of_engine_to_make,
label_t const &  engine_label 
)
inherited

Definition at line 40 of file EngineCreator.cc.

References art::EngineCreator::rng().

43 {
44  return rng()->createEngine(
45  placeholder_schedule_id(), seed, kind_of_engine_to_make, engine_label);
46 }
long seed
Definition: chem4.cc:68
static art::ServiceHandle< art::RandomNumberGenerator > & rng()
CurrentProcessingContext const * art::EDProducer::currentContext ( ) const
protectedinherited

Definition at line 120 of file EDProducer.cc.

References art::EDProducer::current_context_.

121  {
122  return current_context_.get();
123  }
CPC_exempt_ptr current_context_
Definition: EDProducer.h:116
double vertex::PrimaryVertexFinder::gammavalue ( TVector3  startpoint1,
TVector3  startpoint2,
TVector3  dircos1,
TVector3  dircos2 
)
private

Definition at line 468 of file PrimaryVertexFinder_module.cc.

469 {
470  double gamma = ((startpoint1*dircos2)-(startpoint2*dircos2)+((dircos1*dircos2)*(startpoint2*dircos1))-((dircos1*dircos2)*(startpoint1*dircos1)))/(1-((dircos1*dircos2)*(dircos1*dircos2)));
471 
472  return gamma;
473 }
EngineCreator::seed_t EngineCreator::get_seed_value ( fhicl::ParameterSet const &  pset,
char const  key[] = "seed",
seed_t const  implicit_seed = -1 
)
inherited

Definition at line 49 of file EngineCreator.cc.

References fhicl::ParameterSet::get().

Referenced by art::MixFilter< T >::initEngine_().

52 {
53  auto const& explicit_seeds = pset.get<std::vector<int>>(key, {});
54  return explicit_seeds.empty() ? implicit_seed : explicit_seeds.front();
55 }
template<typename PROD , BranchType B>
ProductID art::EDProducer::getProductID ( std::string const &  instanceName = {}) const
inlineinherited

Definition at line 123 of file EDProducer.h.

References art::EDProducer::moduleDescription_.

124  {
125  return ProducerBase::getProductID<PROD, B>(moduleDescription_,
126  instanceName);
127  }
ModuleDescription moduleDescription_
Definition: EDProducer.h:115
template<typename PROD , BranchType B>
ProductID art::ProducerBase::getProductID ( ModuleDescription const &  moduleDescription,
std::string const &  instanceName 
) const
inherited

Definition at line 56 of file ProducerBase.h.

References B, and art::ModuleDescription::moduleLabel().

Referenced by art::ProducerBase::modifiesEvent().

58  {
59  auto const& pd =
60  get_ProductDescription<PROD>(B, md.moduleLabel(), instanceName);
61  return pd.productID();
62  }
Int_t B
Definition: plot.C:25
int vertex::PrimaryVertexFinder::IndexInVertexCollection ( int  a,
int  b,
std::vector< std::vector< int > >  vertex_collection 
)
private

Definition at line 441 of file PrimaryVertexFinder_module.cc.

References evd::details::begin().

442 {
443  int index = -1;
444  for(unsigned int i = 0; i < vertex_collection.size() ; i++){
445  for(std::vector<int>::iterator itr = vertex_collection[i].begin(); itr < vertex_collection[i].end(); ++itr){
446  if (a == *itr || b == *itr)
447  index = i;
448  }
449  }
450  return index;
451 }
intermediate_table::iterator iterator
std::vector< evd::details::RawDigitInfo_t >::const_iterator begin(RawDigitCacheDataClass const &cache)
bool vertex::PrimaryVertexFinder::IsInNewVertex ( int  a,
std::vector< int >  newvertex 
)
private

Definition at line 453 of file PrimaryVertexFinder_module.cc.

454 {
455  int flag = 0;
456  for(unsigned int i = 0; i < newvertex.size() ; i++){
457  if (a == newvertex[i]){
458  flag = 1;
459  break;
460  }
461  }
462 
463  if(flag==1)
464  return true;
465  return false;
466 }
bool vertex::PrimaryVertexFinder::IsInVertexCollection ( int  a,
std::vector< std::vector< int > >  vertex_collection 
)
private

Definition at line 424 of file PrimaryVertexFinder_module.cc.

References evd::details::begin().

425 {
426  int flag = 0;
427 
428  for(unsigned int i = 0; i < vertex_collection.size() ; i++){
429  for(std::vector<int>::iterator itr = vertex_collection[i].begin(); itr < vertex_collection[i].end(); ++itr){
430  if (a == *itr){
431  flag = 1;
432  break;
433  }
434  }
435  }
436  if(flag==1)
437  return true;
438  return false;
439 }
intermediate_table::iterator iterator
std::vector< evd::details::RawDigitInfo_t >::const_iterator begin(RawDigitCacheDataClass const &cache)
template<typename T , BranchType = InEvent>
ProductToken<T> art::Consumer::mayConsume ( InputTag const &  )
inherited
template<typename T , art::BranchType BT>
art::ProductToken<T> art::Consumer::mayConsume ( InputTag const &  it)
inherited

Definition at line 190 of file Consumer.h.

References art::InputTag::instance(), art::InputTag::label(), and art::InputTag::process().

191 {
192  if (!moduleContext_)
193  return ProductToken<T>::invalid();
194 
195  consumables_[BT].emplace_back(ConsumableType::Product,
196  TypeID{typeid(T)},
197  it.label(),
198  it.instance(),
199  it.process());
200  return ProductToken<T>{it};
201 }
static ProductToken< T > invalid()
Definition: ProductToken.h:47
ConsumableProducts consumables_
Definition: Consumer.h:138
bool moduleContext_
Definition: Consumer.h:136
template<typename T , art::BranchType BT>
void art::Consumer::mayConsumeMany ( )
inherited

Definition at line 205 of file Consumer.h.

206 {
207  if (!moduleContext_)
208  return;
209 
210  consumables_[BT].emplace_back(ConsumableType::Many, TypeID{typeid(T)});
211 }
ConsumableProducts consumables_
Definition: Consumer.h:138
bool moduleContext_
Definition: Consumer.h:136
template<typename Element , BranchType = InEvent>
ViewToken<Element> art::Consumer::mayConsumeView ( InputTag const &  )
inherited
template<typename T , art::BranchType BT>
art::ViewToken<T> art::Consumer::mayConsumeView ( InputTag const &  it)
inherited

Definition at line 215 of file Consumer.h.

References art::InputTag::instance(), art::InputTag::label(), and art::InputTag::process().

216 {
217  if (!moduleContext_)
218  return ViewToken<T>::invalid();
219 
220  consumables_[BT].emplace_back(ConsumableType::ViewElement,
221  TypeID{typeid(T)},
222  it.label(),
223  it.instance(),
224  it.process());
225  return ViewToken<T>{it};
226 }
static ViewToken< Element > invalid()
Definition: ProductToken.h:75
ConsumableProducts consumables_
Definition: Consumer.h:138
bool moduleContext_
Definition: Consumer.h:136
double vertex::PrimaryVertexFinder::MinDist ( double  alpha,
double  gamma,
TVector3  startpoint1,
TVector3  startpoint2,
TVector3  dircos1,
TVector3  dircos2 
)
private

Definition at line 482 of file PrimaryVertexFinder_module.cc.

483 {
484  TVector3 mindis_vector = startpoint1 - startpoint2 + alpha*dircos1 - gamma*dircos2;
485  double mindis = mindis_vector.Mag();
486  return mindis;
487 }
bool art::ProducerBase::modifiesEvent ( ) const
inlineinherited

Definition at line 40 of file ProducerBase.h.

References art::ProducerBase::getProductID().

41  {
42  return true;
43  }
TVector3 vertex::PrimaryVertexFinder::PointOnExtendedTrack ( double  alphagamma,
TVector3  startpoint,
TVector3  dircos 
)
private

Definition at line 489 of file PrimaryVertexFinder_module.cc.

References DEFINE_ART_MODULE.

490 {
491  TVector3 PointOnExtendedTrack = startpoint + (alphagamma * dircos);
492  return PointOnExtendedTrack;
493 }
TVector3 PointOnExtendedTrack(double alphagamma, TVector3 startpoint, TVector3 dircos)
void art::Consumer::prepareForJob ( fhicl::ParameterSet const &  pset)
protectedinherited

Definition at line 89 of file Consumer.cc.

References fhicl::ParameterSet::get_if_present().

Referenced by art::EDProducer::doBeginJob(), art::EDFilter::doBeginJob(), and art::EDAnalyzer::doBeginJob().

90 {
91  if (!moduleContext_)
92  return;
93 
94  pset.get_if_present("errorOnMissingConsumes", requireConsumes_);
95  for (auto& consumablesPerBranch : consumables_) {
96  cet::sort_all(consumablesPerBranch);
97  }
98 }
bool requireConsumes_
Definition: Consumer.h:137
ConsumableProducts consumables_
Definition: Consumer.h:138
bool moduleContext_
Definition: Consumer.h:136
void vertex::PrimaryVertexFinder::produce ( art::Event evt)
virtual
Todo:
replace with the real query when this module is updated to look for showers too

Implements art::EDProducer.

Definition at line 142 of file PrimaryVertexFinder_module.cc.

References evd::details::begin(), util::CreateAssn(), evd::details::end(), art::EventID::event(), art::DataViewImpl::getByLabel(), hits(), art::Event::id(), art::Ptr< T >::key(), LOG_VERBATIM, art::Event::put(), sort_pred2(), track, lar::dump::vector(), x, y, and z.

143  {
144 
145  mf::LogInfo("PrimaryVertexFinder") << "------------------------------------------------------------------------------";
146 
147  // std::cout << "run : " << evt.Header().Run() << std::endl;
148  // std::cout << "subrun : " << evt.Header().Subrun() << std::endl;
149  //std::cout << "event : " << evt.Header().Event() << std::endl;
150 
151  mf::LogInfo("PrimaryVertexFinder") << "event : " << evt.id().event();
152 
153 
155 
156  //mf::LogInfo("PrimaryVertexFinder") << "I am in Primary vertex finder " << std::endl;
157 
158  art::Handle< std::vector<recob::Track> > trackListHandle;
159  evt.getByLabel(fTrackModuleLabel,trackListHandle);
160 
161  //Point to a collection of vertices to output.
162  std::unique_ptr< std::vector<recob::Vertex> > vcol(new std::vector<recob::Vertex>);
163  std::unique_ptr< art::Assns<recob::Vertex, recob::Hit> > vhassn(new art::Assns<recob::Vertex, recob::Hit>);
164  std::unique_ptr< art::Assns<recob::Vertex, recob::Track> > vtassn(new art::Assns<recob::Vertex, recob::Track>);
165  std::unique_ptr< art::Assns<recob::Vertex, recob::Shower> > vsassn(new art::Assns<recob::Vertex, recob::Shower>);
166 
167 
168  std::vector<recob::Track> const& trkIn = *trackListHandle;
169 
170  mf::LogInfo("PrimaryVertexFinder") << "number of tracks in this event = " << trkIn.size();
171  fNoTracks->Fill(evt.id().event(),trkIn.size());
172 
173  std::vector<recob::SpacePoint> startpoints_vec; // first space point of each track
174 
175  std::vector <TVector3> startvec;
176  TVector3 startXYZ;
177 
178  std::vector <TVector3> endvec;
179  TVector3 endXYZ;
180 
181  std::vector <TVector3> dircosvec;
182  TVector3 dircosXYZ;
183 
184  std::vector< std::pair<art::Ptr<recob::Track>, double> > trackpair;
185 
186  art::FindMany<recob::SpacePoint> TrackSpacePoints
187  (trackListHandle, evt, fTrackModuleLabel);
188 
189  for(unsigned int i = 0; i<trkIn.size(); ++i){
190  recob::Track::Point_t start, end;
191  std::tie(start, end) = trkIn[i].Extent();
192  startXYZ.SetXYZ(start.X(),start.Y(),start.Z());
193  endXYZ.SetXYZ(end.X(),end.Y(),end.Z());
194 
195 
196  double length = (endXYZ-startXYZ).Mag();// (endvec[i]-startvec[i]).Mag();
197  //mf::LogInfo("PrimaryVertexFinder") << "Track length calculated = " << length << std::endl;
198  trackpair.push_back(std::pair<art::Ptr<recob::Track>,double>({ trackListHandle, i },length));
199  }
200 
201  for(size_t i = 0; i<trackpair.size(); ++i){
202  mf::LogInfo("PrimaryVertexFinder") << "track id is = " << (trackpair[i].first)->ID()
203  << " track length = " << (trackpair[i].second);
204  }
205 
206  std::sort(trackpair.rbegin(), trackpair.rend(), sort_pred2);
207 
208  mf::LogInfo("PrimaryVertexFinder") << "AFTER SORTING ";
209  for(size_t i = 0; i < trackpair.size(); ++i){
210  mf::LogInfo("PrimaryVertexFinder") << "track id is = " << (trackpair[i].first)->ID()
211  << " track length = " << (trackpair[i].second);
212  }
213 
214  if(trackpair.size()>0)
215  fLength_1stTrack->Fill(trackpair[0].second);
216 
217  if(trackpair.size()>1)
218  fLength_2ndTrack->Fill(trackpair[1].second);
219 
220  if(trackpair.size()>2)
221  fLength_3rdTrack->Fill(trackpair[2].second);
222 
223  if(trackpair.size()>3)
224  fLength_4thTrack->Fill(trackpair[3].second);
225 
226  if(trackpair.size()>4)
227  fLength_5thTrack->Fill(trackpair[4].second);
228 
229  for(size_t j = 0; j < trackpair.size(); ++j) { //loop over tracks
230  art::Ptr<recob::Track> const& track = trackpair[j].first;
231 
232  // the index of this track in the query is the same as its position in
233  // the data product:
234  std::vector<recob::SpacePoint const*> const& spacepoints
235  = TrackSpacePoints.at(track.key());
236 
237  startXYZ = trackpair[j].first->Vertex();
238  endXYZ = trackpair[j].first->End();
239  dircosXYZ = trackpair[j].first->VertexDirection();
240 
241  startvec.push_back(startXYZ);
242  endvec.push_back(endXYZ);
243  dircosvec.push_back(dircosXYZ);
244 
245  mf::LogInfo("PrimaryVertexFinder") << "PrimaryVertexFinder got "<< spacepoints.size()
246  <<" 3D spacepoint(s) from Track3Dreco.cxx";
247 
248  // save the first SpacePoint of each Track... from now the SpacePoint ID represents the Track ID!!
249  startpoints_vec.emplace_back(
250  spacepoints[0]->XYZ(), spacepoints[0]->ErrXYZ(),
251  spacepoints[0]->Chisq(), startpoints_vec.size()
252  );
253 
254  }// loop over tracks
255 
256  for(size_t i = 0; i < startvec.size(); ++i){ //trackpair.size()
257  mf::LogInfo("PrimaryVertexFinder") << "Tvector3 start point SORTED = ";
258  startvec[i].Print();
259  }
260  for(size_t i = 0; i < dircosvec.size(); ++i){ //trackpair.size()
261  mf::LogInfo("PrimaryVertexFinder") << "Tvector3 dir cos SORTED = ";
262  dircosvec[i].Print();
263  }
264 
265  std::vector<std::vector<int> > vertex_collection_int;
266  std::vector <std::vector <TVector3> > vertexcand_vec;
267 
268  for (unsigned int i=0; i<trackpair.size(); ++i){
269  for (unsigned int j=i+1; j<trackpair.size(); ++j){
270  mf::LogInfo("PrimaryVertexFinder") << "distance between " << i << " and " << j
271  << " = "
272  << StartPointSeperation(startpoints_vec[i], startpoints_vec[j]);
273  double GAMMA = gammavalue(startvec[i], startvec[j], dircosvec[i], dircosvec[j]);
274  double ALPHA = alphavalue(GAMMA, startvec[i], startvec[j], dircosvec[i], dircosvec[j]);
275  double MINDIST = MinDist(ALPHA, GAMMA, startvec[i], startvec[j], dircosvec[i], dircosvec[j]);
276  mf::LogInfo("PrimaryVertexFinder") << "alpha = " << ALPHA << " gamma = "
277  << GAMMA << " MINIMUM DISTANCE = " << MINDIST;
278 
279  TVector3 TRACK1POINT = PointOnExtendedTrack(ALPHA, startvec[i], dircosvec[i]);
280  TVector3 TRACK2POINT = PointOnExtendedTrack(GAMMA, startvec[j], dircosvec[j]);
281 
282  mf::LogInfo("PrimaryVertexFinder") << "POINTS ON THE TRACKS ARE:: ";
283  TRACK1POINT.Print();
284  TRACK2POINT.Print();
285 
286  //if(StartPointSeperation(startpoints_vec[i], startpoints_vec[j])<fVertexWindow){ ///// correct this
287  //if(MINDIST<2 && trackpair[i].second >30 && trackpair[j].second >30){
288  if(MINDIST < fVertexWindow && ((TRACK1POINT-startvec[i]).Mag()) < fVertexWindow){
289 
290  if((!IsInVertexCollection(i, vertex_collection_int)) && (!IsInVertexCollection(j, vertex_collection_int))){
291  std::vector<int> newvertex_int;
292  std::vector <TVector3> vertexcand;
293  newvertex_int.push_back(i);
294  newvertex_int.push_back(j);
295  vertex_collection_int.push_back(newvertex_int);
296  //newvertex.clear();
297  vertexcand.push_back(TRACK1POINT);
298  vertexcand.push_back(TRACK2POINT);
299  vertexcand_vec.push_back(vertexcand);
300  }
301  else{
302  int index = IndexInVertexCollection(i, j, vertex_collection_int);
303  //mf::LogInfo("PrimaryVertexFinder") << "index where a new vertex will be added = " << index << std::endl;
304  if(!IsInNewVertex(i, vertex_collection_int[index])){
305  vertex_collection_int[index].push_back(i);
306  vertexcand_vec[index].push_back(TRACK1POINT); //need to fix for delta rays
307  }
308  if(!IsInNewVertex(j, vertex_collection_int[index])){
309  vertex_collection_int[index].push_back(j);
310  vertexcand_vec[index].push_back(TRACK2POINT); //need to fix for delta rays
311  }
312  }
313  }// end else
314  }
315  }
316 
317 
318  //now add the unmatched track IDs to the collection
319  for(size_t i = 0; i < trackpair.size(); ++i){
320  if(!IsInVertexCollection(i, vertex_collection_int)){
321  //if(trackpair[i].second>30){
322  std::vector<int> temp;
323  std::vector <TVector3> temp1;
324  temp.push_back(i);
325  temp1.push_back(startvec[i]);
326  vertex_collection_int.push_back(temp);
327  vertexcand_vec.push_back(temp1);
328  //}
329  }
330  }
331 
332  // indices (in their data products) of tracks and showers connected to the vertex
333  std::vector<size_t> vTrackIndices, vShowerIndices;
334 
335  // find the hits of all the tracks
336  art::FindManyP<recob::Hit> TrackHits(trackListHandle, evt, fTrackModuleLabel);
337 
338  // find the hits of all the showers
339  // art::FindManyP<recob::Hit> ShowerHits(showerListHandle, evt, fShowerModuleLabel);
342 
343  for(size_t i = 0; i < vertex_collection_int.size(); ++i){
344  double x = 0.;
345  double y = 0.;
346  double z = 0.;
347  int elemsize = 0.;
348  for(std::vector<int>::iterator itr = vertex_collection_int[i].begin(); itr < vertex_collection_int[i].end(); ++itr){
349  mf::LogInfo("PrimaryVertexFinder") << "vector elements at index " << i << " are " << *itr
350  << "\ntrack original ID = " << (trackpair[*itr].first)->ID();
351  // save the index in the data product of this track
352  vTrackIndices.push_back(trackpair[*itr].first.key());
353  }
354  mf::LogInfo("PrimaryVertexFinder") << "------------";
355 
356 
357  for(std::vector<TVector3>::iterator itr = vertexcand_vec[i].begin(); itr < vertexcand_vec[i].end(); ++itr){
358  //calculate sum of x, y and z of a vertex
359  x += (*itr).X();
360  y += (*itr).Y();
361  z += (*itr).Z();
362  elemsize = vertexcand_vec[i].size();
363  }
364 
365  double avgx = x/elemsize;
366  double avgy = y/elemsize;
367  double avgz = z/elemsize;
368 
369  Double_t vtxcoord[3];
370  vtxcoord[0] = avgx;
371  vtxcoord[1] = avgy;
372  vtxcoord[2] = avgz;
373 
374  recob::Vertex the3Dvertex(vtxcoord, vcol->size());
375  vcol->push_back(the3Dvertex);
376 
377  if(!vTrackIndices.empty()){
378  // associate the tracks and their hits with the vertex
379  util::CreateAssn(*this, evt, *vtassn,
380  vcol->size() - 1, vTrackIndices.begin(), vTrackIndices.end());
381  for(size_t tIndex: vTrackIndices) {
382  std::vector<art::Ptr<recob::Hit>> const& hits = TrackHits.at(tIndex);
383  util::CreateAssn(*this, evt, *vcol, hits, *vhassn);
384  }
385  vTrackIndices.clear();
386  } // if tracks
387 
388  if(!vShowerIndices.empty()){
389  // associate the showers and their hits with the vertex
390  util::CreateAssn(*this, evt, *vsassn,
391  vcol->size() - 1, vShowerIndices.begin(), vShowerIndices.end());
392  for(size_t sIndex: vShowerIndices){
393  std::vector<art::Ptr<recob::Hit>> const& hits = ShowerHits.at(sIndex);
394  util::CreateAssn(*this, evt, *vcol, hits, *vhassn);
395  }
396  vShowerIndices.clear();
397  } // if showers
398 
399 
400  }// end loop over vertex_collection_ind
401 
402  LOG_VERBATIM("Summary") << std::setfill('-') << std::setw(175) << "-" << std::setfill(' ');
403  LOG_VERBATIM("Summary") << "PrimaryVertexFinder Summary:";
404  for(size_t i = 0; i < vcol->size(); ++i) LOG_VERBATIM("Summary") << vcol->at(i) ;
405 
406  evt.put(std::move(vcol));
407  evt.put(std::move(vtassn));
408  evt.put(std::move(vhassn));
409  evt.put(std::move(vsassn));
410 
411  } // end of produce
Float_t x
Definition: compare.C:6
key_type key() const
Definition: Ptr.h:356
intermediate_table::iterator iterator
TVector3 PointOnExtendedTrack(double alphagamma, TVector3 startpoint, TVector3 dircos)
MaybeLogger_< ELseverityLevel::ELsev_info, false > LogInfo
Float_t y
Definition: compare.C:6
Double_t z
Definition: plot.C:279
Definition of vertex object for LArSoft.
Definition: Vertex.h:35
bool IsInNewVertex(int a, std::vector< int > newvertex)
int IndexInVertexCollection(int a, int b, std::vector< std::vector< int > > vertex_collection)
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
void hits()
Definition: readHits.C:15
std::vector< evd::details::RawDigitInfo_t >::const_iterator begin(RawDigitCacheDataClass const &cache)
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.
double MinDist(double alpha, double gamma, TVector3 startpoint1, TVector3 startpoint2, TVector3 dircos1, TVector3 dircos2)
double StartPointSeperation(recob::SpacePoint sp1, recob::SpacePoint sp2)
bool sort_pred2(const std::pair< art::Ptr< recob::Track >, double > &left, const std::pair< art::Ptr< recob::Track >, double > &right)
bool getByLabel(std::string const &label, std::string const &productInstanceName, Handle< PROD > &result) const
Definition: DataViewImpl.h:344
bool IsInVertexCollection(int a, std::vector< std::vector< int > > vertex_collection)
tracking::Point_t Point_t
Definition: Track.h:55
EventNumber_t event() const
Definition: EventID.h:117
double gammavalue(TVector3 startpoint1, TVector3 startpoint2, TVector3 dircos1, TVector3 dircos2)
std::vector< evd::details::RawDigitInfo_t >::const_iterator end(RawDigitCacheDataClass const &cache)
double alphavalue(double gamma, TVector3 startpoint1, TVector3 startpoint2, TVector3 dircos1, TVector3 dircos2)
#define LOG_VERBATIM(category)
Float_t track
Definition: plot.C:34
size_t size() const
Definition: DataViewImpl.cc:34
EventID id() const
Definition: Event.h:56
void vertex::PrimaryVertexFinder::reconfigure ( fhicl::ParameterSet const &  p)

Definition at line 121 of file PrimaryVertexFinder_module.cc.

References fhicl::ParameterSet::get().

122  {
123  fTrackModuleLabel = p.get< std::string >("TrackModuleLabel");
124  fVertexWindow = p.get<double > ("VertexWindow");
125  return;
126  }
void art::Consumer::showMissingConsumes ( ) const
protectedinherited

Definition at line 125 of file Consumer.cc.

Referenced by art::EDProducer::doEndJob(), art::EDFilter::doEndJob(), art::EDAnalyzer::doEndJob(), and art::RootOutput::endJob().

126 {
127  if (!moduleContext_)
128  return;
129 
130  // If none of the branches have missing consumes statements, exit early.
131  if (std::all_of(cbegin(missingConsumes_),
132  cend(missingConsumes_),
133  [](auto const& perBranch) { return perBranch.empty(); }))
134  return;
135 
136  constexpr cet::HorizontalRule rule{60};
137  mf::LogPrint log{"MTdiagnostics"};
138  log << '\n'
139  << rule('=') << '\n'
140  << "The following consumes (or mayConsume) statements are missing from\n"
141  << module_context(moduleDescription_) << '\n'
142  << rule('-') << '\n';
143 
144  cet::for_all_with_index(
145  missingConsumes_, [&log](std::size_t const i, auto const& perBranch) {
146  for (auto const& pi : perBranch) {
147  log << " "
148  << assemble_consumes_statement(static_cast<BranchType>(i), pi)
149  << '\n';
150  }
151  });
152  log << rule('=');
153 }
cet::exempt_ptr< ModuleDescription const > moduleDescription_
Definition: Consumer.h:140
constexpr T pi()
Returns the constant pi (up to 35 decimal digits of precision)
bool moduleContext_
Definition: Consumer.h:136
ConsumableProductSets missingConsumes_
Definition: Consumer.h:139
double vertex::PrimaryVertexFinder::StartPointSeperation ( recob::SpacePoint  sp1,
recob::SpacePoint  sp2 
)
private

Definition at line 415 of file PrimaryVertexFinder_module.cc.

References x, recob::SpacePoint::XYZ(), y, and z.

416 {
417  double x= (sp2.XYZ()[0])-(sp1.XYZ()[0]);
418  double y= (sp2.XYZ()[1])-(sp1.XYZ()[1]);
419  double z= (sp2.XYZ()[2])-(sp1.XYZ()[2]);
420  double distance = std::sqrt(pow(x,2)+pow(y,2)+pow(z,2));
421  return distance;
422 }
Float_t x
Definition: compare.C:6
Float_t y
Definition: compare.C:6
Double_t z
Definition: plot.C:279
const double * XYZ() const
Definition: SpacePoint.h:64
void art::Consumer::validateConsumedProduct ( BranchType const  bt,
ProductInfo const &  pi 
)
protectedinherited

Definition at line 101 of file Consumer.cc.

References art::errors::ProductRegistrationFailure.

103 {
104  // Early exits if consumes tracking has been disabled or if the
105  // consumed product is an allowed consumable.
106  if (!moduleContext_)
107  return;
108 
109  if (cet::binary_search_all(consumables_[bt], pi))
110  return;
111 
112  if (requireConsumes_) {
114  "Consumer: an error occurred during validation of a "
115  "retrieved product\n\n")
116  << "The following consumes (or mayConsume) statement is missing from\n"
117  << module_context(moduleDescription_) << ":\n\n"
118  << " " << assemble_consumes_statement(bt, pi) << "\n\n";
119  }
120 
121  missingConsumes_[bt].insert(pi);
122 }
cet::exempt_ptr< ModuleDescription const > moduleDescription_
Definition: Consumer.h:140
bool requireConsumes_
Definition: Consumer.h:137
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
constexpr T pi()
Returns the constant pi (up to 35 decimal digits of precision)
ConsumableProducts consumables_
Definition: Consumer.h:138
bool moduleContext_
Definition: Consumer.h:136
ConsumableProductSets missingConsumes_
Definition: Consumer.h:139

Member Data Documentation

TH1F* vertex::PrimaryVertexFinder::fLength_1stTrack
private

Definition at line 87 of file PrimaryVertexFinder_module.cc.

TH1F* vertex::PrimaryVertexFinder::fLength_2ndTrack
private

Definition at line 88 of file PrimaryVertexFinder_module.cc.

TH1F* vertex::PrimaryVertexFinder::fLength_3rdTrack
private

Definition at line 89 of file PrimaryVertexFinder_module.cc.

TH1F* vertex::PrimaryVertexFinder::fLength_4thTrack
private

Definition at line 90 of file PrimaryVertexFinder_module.cc.

TH1F* vertex::PrimaryVertexFinder::fLength_5thTrack
private

Definition at line 91 of file PrimaryVertexFinder_module.cc.

TH2F* vertex::PrimaryVertexFinder::fNoTracks
private

Definition at line 86 of file PrimaryVertexFinder_module.cc.

std::string vertex::PrimaryVertexFinder::fTrackModuleLabel
private

Definition at line 76 of file PrimaryVertexFinder_module.cc.

double vertex::PrimaryVertexFinder::fVertexWindow
private

Definition at line 77 of file PrimaryVertexFinder_module.cc.


The documentation for this class was generated from the following file: