LArSoft  v07_13_02
Liquid Argon Software toolkit - http://larsoft.org/
trkf::CosmicTracker Class Reference
Inheritance diagram for trkf::CosmicTracker:
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

 CosmicTracker (fhicl::ParameterSet const &pset)
 
void reconfigure (fhicl::ParameterSet const &p)
 
void produce (art::Event &evt)
 
void beginJob ()
 
void endJob ()
 
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 Attributes

cluster::ClusterMatchTQ fClusterMatch
 
trkf::CosmicTrackerAlg fCTAlg
 
std::string fClusterModuleLabel
 label for input cluster collection More...
 
std::string fSortDir
 sort space points More...
 
bool fStitchTracks
 Stitch tracks from different TPCs. More...
 
double fDisCut
 Distance cut for track merging. More...
 
double fAngCut
 Angle cut for track merging. More...
 
bool fTrajOnly
 Only use trajectory points from TrackTrajectoryAlg for debugging. More...
 

Detailed Description

Definition at line 195 of file CosmicTracker_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

trkf::CosmicTracker::CosmicTracker ( fhicl::ParameterSet const &  pset)
explicit

Definition at line 230 of file CosmicTracker_module.cc.

References reconfigure().

230  :
231  fClusterMatch(pset.get< fhicl::ParameterSet >("ClusterMatch")),
232  fCTAlg(pset.get< fhicl::ParameterSet >("CTAlg"))
233  {
234  this->reconfigure(pset);
235  produces< std::vector<recob::Track> >();
236  produces< std::vector<recob::SpacePoint> >();
237  produces< art::Assns<recob::Track, recob::Cluster> >();
238  produces< art::Assns<recob::Track, recob::SpacePoint> >();
239  produces< art::Assns<recob::SpacePoint, recob::Hit> >();
240  produces< art::Assns<recob::Track, recob::Hit> >();
241 
242  }
trkf::CosmicTrackerAlg fCTAlg
void reconfigure(fhicl::ParameterSet const &p)
cluster::ClusterMatchTQ fClusterMatch

Member Function Documentation

void trkf::CosmicTracker::beginJob ( )
virtual

Reimplemented from art::EDProducer.

Definition at line 256 of file CosmicTracker_module.cc.

257  {
258  }
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
void trkf::CosmicTracker::endJob ( )
virtual

Reimplemented from art::EDProducer.

Definition at line 261 of file CosmicTracker_module.cc.

262  {
263  }
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
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
bool art::ProducerBase::modifiesEvent ( ) const
inlineinherited

Definition at line 40 of file ProducerBase.h.

References art::ProducerBase::getProductID().

41  {
42  return true;
43  }
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 trkf::CosmicTracker::produce ( art::Event evt)
virtual

Implements art::EDProducer.

Definition at line 266 of file CosmicTracker_module.cc.

References evd::details::begin(), cluster::ClusterMatchTQ::ClusterMatch(), recob::tracking::convertCollToPoint(), recob::tracking::convertCollToVector(), util::CreateAssn(), DEFINE_ART_MODULE, dir, trkPoint::dir, evd::details::end(), fAngCut, fClusterMatch, fClusterModuleLabel, fCTAlg, fDisCut, art::fill_ptr_vector(), fSortDir, fStitchTracks, fTrajOnly, art::DataViewImpl::getByLabel(), trkPoint::hit, hits(), util::kBogusD, cluster::ClusterMatchTQ::matchedclusters, MatchTrack(), trkPoint::pos, art::PtrVector< T >::push_back(), art::Event::put(), s, sp_sort_x0(), sp_sort_x1(), sp_sort_y0(), sp_sort_y1(), sp_sort_z0(), sp_sort_z1(), spt_sort_x0(), spt_sort_x1(), spt_sort_y0(), spt_sort_y1(), spt_sort_z0(), spt_sort_z1(), trkf::CosmicTrackerAlg::SPTReco(), tmp, trkf::CosmicTrackerAlg::trajHit, trkf::CosmicTrackerAlg::trajPos, trkf::CosmicTrackerAlg::trkDir, and trkf::CosmicTrackerAlg::trkPos.

266  {
267 
268  // get services
270 
271  std::unique_ptr<std::vector<recob::Track> > tcol (new std::vector<recob::Track>);
272  std::unique_ptr<std::vector<recob::SpacePoint> > spcol(new std::vector<recob::SpacePoint>);
273  std::unique_ptr<art::Assns<recob::Track, recob::SpacePoint> > tspassn(new art::Assns<recob::Track, recob::SpacePoint>);
274  std::unique_ptr<art::Assns<recob::Track, recob::Cluster> > tcassn(new art::Assns<recob::Track, recob::Cluster>);
275  std::unique_ptr<art::Assns<recob::Track, recob::Hit> > thassn(new art::Assns<recob::Track, recob::Hit>);
276  std::unique_ptr<art::Assns<recob::SpacePoint, recob::Hit> > shassn(new art::Assns<recob::SpacePoint, recob::Hit>);
277 
278  //double timetick = detprop->SamplingRate()*1e-3; //time sample in us
279  //double presamplings = detprop->TriggerOffset(); // presamplings in ticks
280  //double plane_pitch = geom->PlanePitch(0,1); //wire plane pitch in cm
281  //double wire_pitch = geom->WirePitch(); //wire pitch in cm
282  //double Efield_drift = larprop->Efield(0); // Electric Field in the drift region in kV/cm
283  //double Temperature = detprop->Temperature(); // LAr Temperature in K
284 
285  //double driftvelocity = larprop->DriftVelocity(Efield_drift,Temperature); //drift velocity in the drift region (cm/us)
286  //double timepitch = driftvelocity*timetick; //time sample (cm)
287 
288 
289  // get input Cluster object(s).
290  art::Handle< std::vector<recob::Cluster> > clusterListHandle;
291  std::vector<art::Ptr<recob::Cluster> > clusterlist;
292  if (evt.getByLabel(fClusterModuleLabel,clusterListHandle))
293  art::fill_ptr_vector(clusterlist, clusterListHandle);
294 
295  art::FindManyP<recob::Hit> fm(clusterListHandle, evt, fClusterModuleLabel);
296 
297  // find matched clusters
298  fClusterMatch.ClusterMatch(clusterlist,fm);
299  std::vector<std::vector<unsigned int> > &matchedclusters = fClusterMatch.matchedclusters;
300 
301  // get track space points
302  std::vector<std::vector<trkPoint>> trkpts(matchedclusters.size());
303  for (size_t itrk = 0; itrk<matchedclusters.size(); ++itrk){//loop over tracks
304 
305  std::vector<art::Ptr<recob::Hit> > hitlist;
306  for (size_t iclu = 0; iclu<matchedclusters[itrk].size(); ++iclu){//loop over clusters
307 
308  std::vector< art::Ptr<recob::Hit> > hits = fm.at(matchedclusters[itrk][iclu]);
309  for (size_t ihit = 0; ihit<hits.size(); ++ihit){
310  hitlist.push_back(hits[ihit]);
311  }
312  }
313  //reconstruct space points and directions
314  fCTAlg.SPTReco(hitlist);
315  if (!fTrajOnly){
316  if (!fCTAlg.trkPos.size()) continue;
317  for (size_t i = 0; i<hitlist.size(); ++i){
318  trkPoint trkpt;
319  trkpt.pos = fCTAlg.trkPos[i];
320  trkpt.dir = fCTAlg.trkDir[i];
321  trkpt.hit = hitlist[i];
322  trkpts[itrk].push_back(trkpt);
323  }
324  if (fSortDir=="+x") std::sort(trkpts[itrk].begin(),trkpts[itrk].end(),sp_sort_x0);
325  if (fSortDir=="-x") std::sort(trkpts[itrk].begin(),trkpts[itrk].end(),sp_sort_x1);
326  if (fSortDir=="+y") std::sort(trkpts[itrk].begin(),trkpts[itrk].end(),sp_sort_y0);
327  if (fSortDir=="-y") std::sort(trkpts[itrk].begin(),trkpts[itrk].end(),sp_sort_y1);
328  if (fSortDir=="+z") std::sort(trkpts[itrk].begin(),trkpts[itrk].end(),sp_sort_z0);
329  if (fSortDir=="-z") std::sort(trkpts[itrk].begin(),trkpts[itrk].end(),sp_sort_z1);
330  }
331 
332  if (fTrajOnly){//debug only
333  if (!fCTAlg.trajPos.size()) continue;
334  size_t spStart = spcol->size();
335  std::vector<recob::SpacePoint> spacepoints;
336  // for (size_t ihit = 0; ihit<hitlist.size(); ++ihit){
337  // if (fCTAlg.usehit[ihit] == 1){
338  for (size_t ipt = 0; ipt<fCTAlg.trajPos.size(); ++ipt){
340  //sp_hits.push_back(hitlist[ihit]);
341  double hitcoord[3];
342  hitcoord[0] = fCTAlg.trajPos[ipt].X();
343  hitcoord[1] = fCTAlg.trajPos[ipt].Y();
344  hitcoord[2] = fCTAlg.trajPos[ipt].Z();
345 // if (itrk==1){
346 // std::cout<<"hitcoord "<<hitcoord[0]<<" "<<hitcoord[1]<<" "<<hitcoord[2]<<std::endl;
347 // }
348  double err[6] = {util::kBogusD};
349  recob::SpacePoint mysp(hitcoord,
350  err,
351  util::kBogusD,
352  spStart + spacepoints.size());//3d point at end of track
353  spacepoints.push_back(mysp);
354  spcol->push_back(mysp);
355  util::CreateAssn(*this, evt, *spcol, fCTAlg.trajHit[ipt], *shassn);
356  //}//
357  }//ihit
358  size_t spEnd = spcol->size();
359  //sort in z direction
360  //std::sort(spacepoints.begin(),spacepoints.end(),sp_sort_z0);
361  //std::sort(spcol->begin()+spStart,spcol->begin()+spEnd,sp_sort_z0);
362  if (fSortDir == "+x"){
363  std::sort(spacepoints.begin(),spacepoints.end(),spt_sort_x0);
364  std::sort(spcol->begin()+spStart,spcol->begin()+spEnd,spt_sort_x0);
365  }
366  if (fSortDir == "-x"){
367  std::sort(spacepoints.begin(),spacepoints.end(),spt_sort_x1);
368  std::sort(spcol->begin()+spStart,spcol->begin()+spEnd,spt_sort_x1);
369  }
370  if (fSortDir == "+y"){
371  std::sort(spacepoints.begin(),spacepoints.end(),spt_sort_y0);
372  std::sort(spcol->begin()+spStart,spcol->begin()+spEnd,spt_sort_y0);
373  }
374  if (fSortDir == "-y"){
375  std::sort(spacepoints.begin(),spacepoints.end(),spt_sort_y1);
376  std::sort(spcol->begin()+spStart,spcol->begin()+spEnd,spt_sort_y1);
377  }
378  if (fSortDir == "+z"){
379  std::sort(spacepoints.begin(),spacepoints.end(),spt_sort_z0);
380  std::sort(spcol->begin()+spStart,spcol->begin()+spEnd,spt_sort_z0);
381  }
382  if (fSortDir == "-z"){
383  std::sort(spacepoints.begin(),spacepoints.end(),spt_sort_z1);
384  std::sort(spcol->begin()+spStart,spcol->begin()+spEnd,spt_sort_z1);
385  }
386 
387  if(spacepoints.size()>0){
388 
389  // make a vector of the trajectory points along the track
390  std::vector<TVector3> xyz(spacepoints.size());
391  for(size_t s = 0; s < spacepoints.size(); ++s){
392  xyz[s] = TVector3(spacepoints[s].XYZ());
393  }
394  //Calculate track direction cosines
395  TVector3 startpointVec,endpointVec, DirCos;
396  startpointVec = xyz[0];
397  endpointVec = xyz.back();
398  DirCos = endpointVec - startpointVec;
399  //SetMag casues a crash if the magnitude of the vector is zero
400  try
401  {
402  DirCos.SetMag(1.0);//normalize vector
403  }
404  catch(...){std::cout<<"The Spacepoint is infinitely small"<<std::endl;
405  continue;
406  }
407  //std::cout<<DirCos.x()<<" "<<DirCos.y()<<" "<<DirCos.z()<<std::endl;
408  std::vector<TVector3> dircos(spacepoints.size(), DirCos);
409 
412  recob::Track::Flags_t(xyz.size()), false),
413  0, -1., 0, recob::tracking::SMatrixSym55(), recob::tracking::SMatrixSym55(), tcol->size()));
414 
415  // make associations between the track and space points
416  util::CreateAssn(*this, evt, *tcol, *spcol, *tspassn, spStart, spEnd);
417 
418  // now the track and clusters
419  //util::CreateAssn(*this, evt, *tcol, clustersPerTrack, *tcassn);
420 
421  // and the hits and track
422  std::vector<art::Ptr<recob::Hit> > trkhits;
423  for (size_t ihit = 0; ihit<hitlist.size(); ++ihit){
424  //if (fCTAlg.usehit[ihit] == 1){
425  trkhits.push_back(hitlist[ihit]);
426  //}
427  }
428  util::CreateAssn(*this, evt, *tcol, trkhits, *thassn);
429  }
430  }
431  }//itrk
432 
433  // by default creates a spacepoint and direction for each hit
434  if (!fTrajOnly){
435  std::vector<std::vector<unsigned int>> trkidx;
436  //stitch tracks from different TPCs
437  if (fStitchTracks){
438  for (size_t itrk1 = 0; itrk1<trkpts.size(); ++itrk1){
439  for (size_t itrk2 = itrk1+1; itrk2<trkpts.size(); ++itrk2){
440  if (MatchTrack(trkpts[itrk1], trkpts[itrk2], fDisCut, fAngCut)){
441  int found1 = -1;
442  int found2 = -1;
443  for (size_t i = 0; i<trkidx.size(); ++i){
444  for (size_t j = 0; j<trkidx[i].size(); ++j){
445  if (trkidx[i][j]==itrk1) found1 = i;
446  if (trkidx[i][j]==itrk2) found2 = i;
447  }
448  }
449  //std::cout<<itrk1<<" "<<itrk2<<" "<<found1<<" "<<found2<<std::endl;
450  if (found1==-1&&found2==-1){
451  std::vector<unsigned int> tmp;
452  tmp.push_back(itrk1);
453  tmp.push_back(itrk2);
454  trkidx.push_back(tmp);
455  }
456  else if(found1==-1&&found2!=-1){
457  trkidx[found2].push_back(itrk1);
458  }
459  else if(found1!=-1&&found2==-1){
460  trkidx[found1].push_back(itrk2);
461  }
462  else if (found1!=found2){//merge two vectors
463  trkidx[found1].insert(trkidx[found1].end(),
464  trkidx[found2].begin(),
465  trkidx[found2].end());
466  trkidx.erase(trkidx.begin()+found2);
467  }
468  }//found match
469  }//itrk2
470  }//itrk1
471  for (size_t itrk = 0; itrk<trkpts.size(); ++itrk){
472  bool found = false;
473  for (size_t i = 0; i<trkidx.size(); ++i){
474  for (size_t j = 0; j<trkidx[i].size(); ++j){
475  if (trkidx[i][j]==itrk) found = true;
476  }
477  }
478  if (!found) {
479  std::vector<unsigned int> tmp;
480  tmp.push_back(itrk);
481  trkidx.push_back(tmp);
482  }
483  }
484  }//stitch
485  else{
486  trkidx.resize(trkpts.size());
487  for (size_t i = 0; i<trkpts.size(); ++i){
488  trkidx[i].push_back(i);
489  }
490  }
491 
492  //make recob::track and associations
493  for (size_t i = 0; i<trkidx.size(); ++i){
494  //all track points
495  std::vector<trkPoint> finaltrkpts;
496  //all the clusters associated with the current track
497  std::vector<art::Ptr<recob::Cluster>> clustersPerTrack;
498  //all hits
499  std::vector<art::Ptr<recob::Hit> > hitlist;
500  for(size_t j = 0; j<trkidx[i].size(); ++j){
501  for (size_t k = 0; k<trkpts[trkidx[i][j]].size(); ++k){
502  finaltrkpts.push_back(trkpts[trkidx[i][j]][k]);
503  hitlist.push_back(trkpts[trkidx[i][j]][k].hit);
504  }//k
505  for (size_t iclu = 0; iclu<matchedclusters[trkidx[i][j]].size(); ++iclu){
506  art::Ptr <recob::Cluster> cluster(clusterListHandle,matchedclusters[trkidx[i][j]][iclu]);
507  clustersPerTrack.push_back(cluster);
508  }
509 
510  }//j
511  if (fStitchTracks){
512  if (fSortDir=="+x") std::sort(finaltrkpts.begin(),finaltrkpts.end(),sp_sort_x0);
513  if (fSortDir=="-x") std::sort(finaltrkpts.begin(),finaltrkpts.end(),sp_sort_x1);
514  if (fSortDir=="+y") std::sort(finaltrkpts.begin(),finaltrkpts.end(),sp_sort_y0);
515  if (fSortDir=="-y") std::sort(finaltrkpts.begin(),finaltrkpts.end(),sp_sort_y1);
516  if (fSortDir=="+z") std::sort(finaltrkpts.begin(),finaltrkpts.end(),sp_sort_z0);
517  if (fSortDir=="-z") std::sort(finaltrkpts.begin(),finaltrkpts.end(),sp_sort_z1);
518  }
519  size_t spStart = spcol->size();
520  std::vector<recob::SpacePoint> spacepoints;
521  for (size_t ipt = 0; ipt<finaltrkpts.size(); ++ipt){
523  sp_hits.push_back(finaltrkpts[ipt].hit);
524  double hitcoord[3];
525  hitcoord[0] = finaltrkpts[ipt].pos.X();
526  hitcoord[1] = finaltrkpts[ipt].pos.Y();
527  hitcoord[2] = finaltrkpts[ipt].pos.Z();
528  //std::cout<<"hitcoord "<<hitcoord[0]<<" "<<hitcoord[1]<<" "<<hitcoord[2]<<std::endl;
529  double err[6] = {util::kBogusD};
530  recob::SpacePoint mysp(hitcoord,
531  err,
532  util::kBogusD,
533  spStart + spacepoints.size());//3d point at end of track
534  spacepoints.push_back(mysp);
535  spcol->push_back(mysp);
536  util::CreateAssn(*this, evt, *spcol, sp_hits, *shassn);
537  }//ipt
538  size_t spEnd = spcol->size();
539  if(spacepoints.size()>0){
540  // make a vector of the trajectory points along the track
541  std::vector<TVector3> xyz(spacepoints.size());
542  std::vector<TVector3> dircos(spacepoints.size());
543  for(size_t s = 0; s < spacepoints.size(); ++s){
544  xyz[s] = TVector3(spacepoints[s].XYZ());
545  dircos[s] = finaltrkpts[s].dir;
546  //flip direction if needed.
547  if (spacepoints.size()>1){
548  if (s==0){
549  TVector3 xyz1 = TVector3(spacepoints[s+1].XYZ());
550  TVector3 dir = xyz1-xyz[s];
551  if (dir.Angle(dircos[s])>0.8*TMath::Pi()){
552  dircos[s] = -dircos[s];
553  }
554  }
555  else{
556  TVector3 dir = xyz[s]-xyz[s-1];
557  if (dir.Angle(dircos[s])>0.8*TMath::Pi()){
558  dircos[s] = -dircos[s];
559  }
560  }
561  }
562  //std::cout<<s<<" "<<xyz[s].X()<<" "<<xyz[s].Y()<<" "<<xyz[s].Z()<<" "<<dircos[s].X()<<" "<<dircos[s].Y()<<" "<<dircos[s].Z()<<std::endl;
563  }
566  recob::Track::Flags_t(xyz.size()), false),
567  0, -1., 0, recob::tracking::SMatrixSym55(), recob::tracking::SMatrixSym55(), tcol->size()));
568 
569  // make associations between the track and space points
570  util::CreateAssn(*this, evt, *tcol, *spcol, *tspassn, spStart, spEnd);
571 
572  // now the track and clusters
573  util::CreateAssn(*this, evt, *tcol, clustersPerTrack, *tcassn);
574 
575  // and the hits and track
576  std::vector<art::Ptr<recob::Hit> > trkhits;
577  for (size_t ihit = 0; ihit<hitlist.size(); ++ihit){
578  //if (fCTAlg.usehit[ihit] == 1){
579  trkhits.push_back(hitlist[ihit]);
580  //}
581  }
582  util::CreateAssn(*this, evt, *tcol, trkhits, *thassn);
583  }
584 
585  }//i
586  }
587  mf::LogVerbatim("Summary") << std::setfill('-')
588  << std::setw(175)
589  << "-"
590  << std::setfill(' ');
591  mf::LogVerbatim("Summary") << "CosmicTracker Summary:";
592  for(unsigned int i = 0; i<tcol->size(); ++i) mf::LogVerbatim("Summary") << tcol->at(i) ;
593  mf::LogVerbatim("Summary") << "CosmicTracker Summary End:";
594 
595  evt.put(std::move(tcol));
596  evt.put(std::move(spcol));
597  evt.put(std::move(tspassn));
598  evt.put(std::move(tcassn));
599  evt.put(std::move(thassn));
600  evt.put(std::move(shassn));
601 
602  return;
603  }
bool spt_sort_x1(const recob::SpacePoint h1, const recob::SpacePoint h2)
Float_t s
Definition: plot.C:23
bool sp_sort_x1(const trkPoint &tp1, const trkPoint &tp2)
MaybeLogger_< ELseverityLevel::ELsev_info, true > LogVerbatim
void SPTReco(std::vector< art::Ptr< recob::Hit > > &fHits)
bool sp_sort_y1(const trkPoint &tp1, const trkPoint &tp2)
ROOT::Math::SMatrix< Double32_t, 5, 5, ROOT::Math::MatRepSym< Double32_t, 5 > > SMatrixSym55
Definition: TrackingTypes.h:85
std::vector< Vector_t > convertCollToVector(std::vector< Vector > const &coll)
Definition: TrackingTypes.h:58
TrackTrajectory::Flags_t Flags_t
Definition: Track.h:71
std::vector< TVector3 > trajPos
bool sp_sort_z1(const trkPoint &tp1, const trkPoint &tp2)
bool MatchTrack(const std::vector< trkPoint > &trkpts1, const std::vector< trkPoint > &trkpts2, double discut, double angcut)
art::Ptr< recob::Hit > hit
std::vector< TVector3 > trkDir
Float_t tmp
Definition: plot.C:37
bool fTrajOnly
Only use trajectory points from TrackTrajectoryAlg for debugging.
Cluster finding and building.
trkf::CosmicTrackerAlg fCTAlg
bool fStitchTracks
Stitch tracks from different TPCs.
double fAngCut
Angle cut for track merging.
bool sp_sort_z0(const trkPoint &tp1, const trkPoint &tp2)
bool sp_sort_y0(const trkPoint &tp1, const trkPoint &tp2)
ProductID put(std::unique_ptr< PROD > &&product)
Definition: Event.h:102
bool sp_sort_x0(const trkPoint &tp1, const trkPoint &tp2)
void hits()
Definition: readHits.C:15
void push_back(Ptr< U > const &p)
Definition: PtrVector.h:441
A trajectory in space reconstructed from hits.
std::vector< evd::details::RawDigitInfo_t >::const_iterator begin(RawDigitCacheDataClass const &cache)
std::vector< std::vector< unsigned int > > matchedclusters
bool spt_sort_y0(const recob::SpacePoint h1, const recob::SpacePoint h2)
bool spt_sort_z1(const recob::SpacePoint h1, const recob::SpacePoint h2)
void ClusterMatch(const std::vector< art::Ptr< recob::Cluster > > &clusterlist, const art::FindManyP< recob::Hit > &fm)
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::vector< Point_t > convertCollToPoint(std::vector< Point > const &coll)
Definition: TrackingTypes.h:55
cluster::ClusterMatchTQ fClusterMatch
double fDisCut
Distance cut for track merging.
Detector simulation of raw signals on wires.
std::vector< TVector3 > trkPos
std::string fClusterModuleLabel
label for input cluster collection
bool spt_sort_z0(const recob::SpacePoint h1, const recob::SpacePoint h2)
TDirectory * dir
Definition: macro.C:5
bool getByLabel(std::string const &label, std::string const &productInstanceName, Handle< PROD > &result) const
Definition: DataViewImpl.h:344
bool spt_sort_x0(const recob::SpacePoint h1, const recob::SpacePoint h2)
bool spt_sort_y1(const recob::SpacePoint h1, const recob::SpacePoint h2)
std::vector< evd::details::RawDigitInfo_t >::const_iterator end(RawDigitCacheDataClass const &cache)
constexpr double kBogusD
obviously bogus double value
void fill_ptr_vector(std::vector< Ptr< T >> &ptrs, H const &h)
Definition: Ptr.h:464
std::string fSortDir
sort space points
Track from a non-cascading particle.A recob::Track consists of a recob::TrackTrajectory, plus additional members relevant for a "fitted" track:
Definition: Track.h:52
std::vector< std::vector< art::Ptr< recob::Hit > > > trajHit
void trkf::CosmicTracker::reconfigure ( fhicl::ParameterSet const &  p)

Definition at line 245 of file CosmicTracker_module.cc.

References fAngCut, fClusterModuleLabel, fDisCut, fSortDir, fStitchTracks, fTrajOnly, and fhicl::ParameterSet::get().

Referenced by CosmicTracker().

246  {
247  fClusterModuleLabel = pset.get< std::string >("ClusterModuleLabel");
248  fSortDir = pset.get< std::string >("SortDirection","+z");
249  fStitchTracks = pset.get< bool >("StitchTracks");
250  fDisCut = pset.get< double >("DisCut");
251  fAngCut = pset.get< double >("AngCut");
252  fTrajOnly = pset.get< bool >("TrajOnly");
253  }
bool fTrajOnly
Only use trajectory points from TrackTrajectoryAlg for debugging.
bool fStitchTracks
Stitch tracks from different TPCs.
double fAngCut
Angle cut for track merging.
double fDisCut
Distance cut for track merging.
std::string fClusterModuleLabel
label for input cluster collection
std::string fSortDir
sort space points
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
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

double trkf::CosmicTracker::fAngCut
private

Angle cut for track merging.

Definition at line 218 of file CosmicTracker_module.cc.

Referenced by produce(), and reconfigure().

cluster::ClusterMatchTQ trkf::CosmicTracker::fClusterMatch
private

Definition at line 209 of file CosmicTracker_module.cc.

Referenced by produce().

std::string trkf::CosmicTracker::fClusterModuleLabel
private

label for input cluster collection

Definition at line 212 of file CosmicTracker_module.cc.

Referenced by produce(), and reconfigure().

trkf::CosmicTrackerAlg trkf::CosmicTracker::fCTAlg
private

Definition at line 210 of file CosmicTracker_module.cc.

Referenced by produce().

double trkf::CosmicTracker::fDisCut
private

Distance cut for track merging.

Definition at line 217 of file CosmicTracker_module.cc.

Referenced by produce(), and reconfigure().

std::string trkf::CosmicTracker::fSortDir
private

sort space points

Definition at line 214 of file CosmicTracker_module.cc.

Referenced by produce(), and reconfigure().

bool trkf::CosmicTracker::fStitchTracks
private

Stitch tracks from different TPCs.

Definition at line 216 of file CosmicTracker_module.cc.

Referenced by produce(), and reconfigure().

bool trkf::CosmicTracker::fTrajOnly
private

Only use trajectory points from TrackTrajectoryAlg for debugging.

Definition at line 220 of file CosmicTracker_module.cc.

Referenced by produce(), and reconfigure().


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