LArSoft  v06_85_00
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(), 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 
410  std::vector< std::vector<double> > dQdx;
411  std::vector<double> mom(2, util::kBogusD);
412  tcol->push_back(recob::Track(xyz, dircos, dQdx, mom, tcol->size()));
413 
414  // make associations between the track and space points
415  util::CreateAssn(*this, evt, *tcol, *spcol, *tspassn, spStart, spEnd);
416 
417  // now the track and clusters
418  //util::CreateAssn(*this, evt, *tcol, clustersPerTrack, *tcassn);
419 
420  // and the hits and track
421  std::vector<art::Ptr<recob::Hit> > trkhits;
422  for (size_t ihit = 0; ihit<hitlist.size(); ++ihit){
423  //if (fCTAlg.usehit[ihit] == 1){
424  trkhits.push_back(hitlist[ihit]);
425  //}
426  }
427  util::CreateAssn(*this, evt, *tcol, trkhits, *thassn);
428  }
429  }
430  }//itrk
431 
432  // by default creates a spacepoint and direction for each hit
433  if (!fTrajOnly){
434  std::vector<std::vector<unsigned int>> trkidx;
435  //stitch tracks from different TPCs
436  if (fStitchTracks){
437  for (size_t itrk1 = 0; itrk1<trkpts.size(); ++itrk1){
438  for (size_t itrk2 = itrk1+1; itrk2<trkpts.size(); ++itrk2){
439  if (MatchTrack(trkpts[itrk1], trkpts[itrk2], fDisCut, fAngCut)){
440  int found1 = -1;
441  int found2 = -1;
442  for (size_t i = 0; i<trkidx.size(); ++i){
443  for (size_t j = 0; j<trkidx[i].size(); ++j){
444  if (trkidx[i][j]==itrk1) found1 = i;
445  if (trkidx[i][j]==itrk2) found2 = i;
446  }
447  }
448  //std::cout<<itrk1<<" "<<itrk2<<" "<<found1<<" "<<found2<<std::endl;
449  if (found1==-1&&found2==-1){
450  std::vector<unsigned int> tmp;
451  tmp.push_back(itrk1);
452  tmp.push_back(itrk2);
453  trkidx.push_back(tmp);
454  }
455  else if(found1==-1&&found2!=-1){
456  trkidx[found2].push_back(itrk1);
457  }
458  else if(found1!=-1&&found2==-1){
459  trkidx[found1].push_back(itrk2);
460  }
461  else if (found1!=found2){//merge two vectors
462  trkidx[found1].insert(trkidx[found1].end(),
463  trkidx[found2].begin(),
464  trkidx[found2].end());
465  trkidx.erase(trkidx.begin()+found2);
466  }
467  }//found match
468  }//itrk2
469  }//itrk1
470  for (size_t itrk = 0; itrk<trkpts.size(); ++itrk){
471  bool found = false;
472  for (size_t i = 0; i<trkidx.size(); ++i){
473  for (size_t j = 0; j<trkidx[i].size(); ++j){
474  if (trkidx[i][j]==itrk) found = true;
475  }
476  }
477  if (!found) {
478  std::vector<unsigned int> tmp;
479  tmp.push_back(itrk);
480  trkidx.push_back(tmp);
481  }
482  }
483  }//stitch
484  else{
485  trkidx.resize(trkpts.size());
486  for (size_t i = 0; i<trkpts.size(); ++i){
487  trkidx[i].push_back(i);
488  }
489  }
490 
491  //make recob::track and associations
492  for (size_t i = 0; i<trkidx.size(); ++i){
493  //all track points
494  std::vector<trkPoint> finaltrkpts;
495  //all the clusters associated with the current track
496  std::vector<art::Ptr<recob::Cluster>> clustersPerTrack;
497  //all hits
498  std::vector<art::Ptr<recob::Hit> > hitlist;
499  for(size_t j = 0; j<trkidx[i].size(); ++j){
500  for (size_t k = 0; k<trkpts[trkidx[i][j]].size(); ++k){
501  finaltrkpts.push_back(trkpts[trkidx[i][j]][k]);
502  hitlist.push_back(trkpts[trkidx[i][j]][k].hit);
503  }//k
504  for (size_t iclu = 0; iclu<matchedclusters[trkidx[i][j]].size(); ++iclu){
505  art::Ptr <recob::Cluster> cluster(clusterListHandle,matchedclusters[trkidx[i][j]][iclu]);
506  clustersPerTrack.push_back(cluster);
507  }
508 
509  }//j
510  if (fStitchTracks){
511  if (fSortDir=="+x") std::sort(finaltrkpts.begin(),finaltrkpts.end(),sp_sort_x0);
512  if (fSortDir=="-x") std::sort(finaltrkpts.begin(),finaltrkpts.end(),sp_sort_x1);
513  if (fSortDir=="+y") std::sort(finaltrkpts.begin(),finaltrkpts.end(),sp_sort_y0);
514  if (fSortDir=="-y") std::sort(finaltrkpts.begin(),finaltrkpts.end(),sp_sort_y1);
515  if (fSortDir=="+z") std::sort(finaltrkpts.begin(),finaltrkpts.end(),sp_sort_z0);
516  if (fSortDir=="-z") std::sort(finaltrkpts.begin(),finaltrkpts.end(),sp_sort_z1);
517  }
518  size_t spStart = spcol->size();
519  std::vector<recob::SpacePoint> spacepoints;
520  for (size_t ipt = 0; ipt<finaltrkpts.size(); ++ipt){
522  sp_hits.push_back(finaltrkpts[ipt].hit);
523  double hitcoord[3];
524  hitcoord[0] = finaltrkpts[ipt].pos.X();
525  hitcoord[1] = finaltrkpts[ipt].pos.Y();
526  hitcoord[2] = finaltrkpts[ipt].pos.Z();
527  //std::cout<<"hitcoord "<<hitcoord[0]<<" "<<hitcoord[1]<<" "<<hitcoord[2]<<std::endl;
528  double err[6] = {util::kBogusD};
529  recob::SpacePoint mysp(hitcoord,
530  err,
531  util::kBogusD,
532  spStart + spacepoints.size());//3d point at end of track
533  spacepoints.push_back(mysp);
534  spcol->push_back(mysp);
535  util::CreateAssn(*this, evt, *spcol, sp_hits, *shassn);
536  }//ipt
537  size_t spEnd = spcol->size();
538  if(spacepoints.size()>0){
539  // make a vector of the trajectory points along the track
540  std::vector<TVector3> xyz(spacepoints.size());
541  std::vector<TVector3> dircos(spacepoints.size());
542  for(size_t s = 0; s < spacepoints.size(); ++s){
543  xyz[s] = TVector3(spacepoints[s].XYZ());
544  dircos[s] = finaltrkpts[s].dir;
545  //flip direction if needed.
546  if (spacepoints.size()>1){
547  if (s==0){
548  TVector3 xyz1 = TVector3(spacepoints[s+1].XYZ());
549  TVector3 dir = xyz1-xyz[s];
550  if (dir.Angle(dircos[s])>0.8*TMath::Pi()){
551  dircos[s] = -dircos[s];
552  }
553  }
554  else{
555  TVector3 dir = xyz[s]-xyz[s-1];
556  if (dir.Angle(dircos[s])>0.8*TMath::Pi()){
557  dircos[s] = -dircos[s];
558  }
559  }
560  }
561  //std::cout<<s<<" "<<xyz[s].X()<<" "<<xyz[s].Y()<<" "<<xyz[s].Z()<<" "<<dircos[s].X()<<" "<<dircos[s].Y()<<" "<<dircos[s].Z()<<std::endl;
562  }
563  std::vector< std::vector<double> > dQdx;
564  std::vector<double> mom(2, util::kBogusD);
565  tcol->push_back(recob::Track(xyz, dircos, dQdx, mom, tcol->size()));
566 
567  // make associations between the track and space points
568  util::CreateAssn(*this, evt, *tcol, *spcol, *tspassn, spStart, spEnd);
569 
570  // now the track and clusters
571  util::CreateAssn(*this, evt, *tcol, clustersPerTrack, *tcassn);
572 
573  // and the hits and track
574  std::vector<art::Ptr<recob::Hit> > trkhits;
575  for (size_t ihit = 0; ihit<hitlist.size(); ++ihit){
576  //if (fCTAlg.usehit[ihit] == 1){
577  trkhits.push_back(hitlist[ihit]);
578  //}
579  }
580  util::CreateAssn(*this, evt, *tcol, trkhits, *thassn);
581  }
582 
583  }//i
584  }
585  mf::LogVerbatim("Summary") << std::setfill('-')
586  << std::setw(175)
587  << "-"
588  << std::setfill(' ');
589  mf::LogVerbatim("Summary") << "CosmicTracker Summary:";
590  for(unsigned int i = 0; i<tcol->size(); ++i) mf::LogVerbatim("Summary") << tcol->at(i) ;
591  mf::LogVerbatim("Summary") << "CosmicTracker Summary End:";
592 
593  evt.put(std::move(tcol));
594  evt.put(std::move(spcol));
595  evt.put(std::move(tspassn));
596  evt.put(std::move(tcassn));
597  evt.put(std::move(thassn));
598  evt.put(std::move(shassn));
599 
600  return;
601  }
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)
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
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.
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:51
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: