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

 TrackTimeAssoc (const fhicl::ParameterSet &)
 
virtual ~TrackTimeAssoc ()
 
void produce (art::Event &)
 
void reconfigure (fhicl::ParameterSet const &p)
 
std::vector< double > GetMIPHypotheses (trkf::BezierTrack *BTrack, double XOffset=0)
 
std::vector< std::vector< double > > ScanMIPHypotheses (trkf::BezierTrack *Btrack)
 
void PrintHypotheses (std::vector< std::vector< double > > TrackHypotheses)
 
double GetChi2 (std::vector< double > signal, std::vector< double > hypothesis, double UpperLim=0)
 
double GetMinChi2 (std::vector< std::vector< double > > ScannedHypotheses, std::vector< double > FlashShape)
 
void StoreFlashMatches (std::vector< art::Ptr< recob::Track > > &Tracks, std::vector< art::Ptr< recob::OpFlash > > &Flashes, std::vector< anab::FlashMatch > &Matches, art::Event &evt)
 
void beginJob ()
 
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

std::string fTrackModuleLabel
 
std::string fFlashModuleLabel
 
int fBezierResolution
 
int fPairingMode
 
double fLengthCut
 
double fPECut
 

Detailed Description

Definition at line 41 of file TrackTimeAssoc_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

opdet::TrackTimeAssoc::TrackTimeAssoc ( const fhicl::ParameterSet )

Definition at line 146 of file TrackTimeAssoc_module.cc.

147  {
148 
149  produces< std::vector<anab::FlashMatch> >();
150  produces< art::Assns<recob::Track, anab::FlashMatch> >();
151  produces< art::Assns<recob::OpFlash, anab::FlashMatch> >();
152 
153  this->reconfigure(pset);
154  }
void reconfigure(fhicl::ParameterSet const &p)
opdet::TrackTimeAssoc::~TrackTimeAssoc ( )
virtual

Definition at line 182 of file TrackTimeAssoc_module.cc.

183  {
184  }

Member Function Documentation

void opdet::TrackTimeAssoc::beginJob ( )
virtual

Reimplemented from art::EDProducer.

Definition at line 174 of file TrackTimeAssoc_module.cc.

175  {
176  }
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
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 }
double opdet::TrackTimeAssoc::GetChi2 ( std::vector< double >  signal,
std::vector< double >  hypothesis,
double  UpperLim = 0 
)

Definition at line 502 of file TrackTimeAssoc_module.cc.

503  {
504 
505  double SignalIntegral = 0;
506  double HypoIntegral = 0;
507 
508  for(size_t i=0; i!=signal.size(); ++i)
509  {
510  SignalIntegral+=signal.at(i);
511  HypoIntegral+=hypothesis.at(i);
512  }
513 
514  // If light yield indicates >1 MIP light yield,
515  // Normalize the hypothesis to the signal size.
516  // We do not allow <1 MIP hypotheses.
517 
518  double NormFactor = SignalIntegral/HypoIntegral;
519  if(NormFactor > 1)
520  {
521  for(size_t i=0; i!=hypothesis.size(); ++i)
522  {
523  hypothesis.at(i) *= NormFactor;
524  }
525  }
526 
527  double Chi2=0;
528 
529  for(size_t i=0; i!=signal.size(); ++i)
530  {
531  // We assume width = sqrt(hypothesis)
532 
533  if(hypothesis.at(i)!=0)
534  Chi2 += pow(hypothesis.at(i) - signal.at(i),2)/(hypothesis.at(i));
535 
536  if(Chi2>UpperLim)
537  break;
538  }
539  return Chi2;
540  }
double opdet::TrackTimeAssoc::GetMinChi2 ( std::vector< std::vector< double > >  ScannedHypotheses,
std::vector< double >  FlashShape 
)

Definition at line 258 of file TrackTimeAssoc_module.cc.

259  {
260  double MinChi2 = 10000;
261  if(FlashShape.size()==0) return MinChi2;
262 
263  for(size_t i=0; i!=ScannedHypotheses.size(); ++i)
264  {
265  if(ScannedHypotheses.at(i).size()>0)
266  {
267  double Chi2 = GetChi2(FlashShape, ScannedHypotheses.at(i), MinChi2);
268  if(Chi2 < MinChi2)
269  {
270  MinChi2 = Chi2;
271  }
272  }
273  }
274  return MinChi2;
275  }
double GetChi2(std::vector< double > signal, std::vector< double > hypothesis, double UpperLim=0)
std::vector< double > opdet::TrackTimeAssoc::GetMIPHypotheses ( trkf::BezierTrack BTrack,
double  XOffset = 0 
)

Definition at line 281 of file TrackTimeAssoc_module.cc.

References trkf::BezierTrack::GetLength(), trkf::BezierTrack::GetTrackPoint(), geo::GeometryCore::NOpDets(), and s.

282  {
284  std::vector<double> ReturnVector(geom->NOpDets(),0);
285 
287 
288  float TrackLength = Btrack->GetLength();
289 
290  double xyz[3];
291  for (int b=0; b!=fBezierResolution; b++)
292  {
293  float s = float(b) / float(fBezierResolution);
294  float dQdx = 2.1; // Assume MIP value
295 
296  Btrack->GetTrackPoint(s,xyz);
297  xyz[0]+=XOffset;
298  const float* PointVisibility = pvs->GetAllVisibilities(xyz);
299  if (!PointVisibility) continue; // point not covered by the service
300  float LightAmount = dQdx*TrackLength/float(fBezierResolution);
301 
302  for(size_t OpDet =0; OpDet!=pvs->NOpChannels(); OpDet++)
303  {
304  ReturnVector.at(OpDet)+= PointVisibility[OpDet] * LightAmount;
305  }
306  }
307  return ReturnVector;
308  }
Float_t s
Definition: plot.C:23
unsigned int NOpDets() const
Number of OpDets in the whole detector.
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 opdet::TrackTimeAssoc::PrintHypotheses ( std::vector< std::vector< double > >  TrackHypotheses)

Definition at line 545 of file TrackTimeAssoc_module.cc.

546  {
547  // List the light hypotheses per track, per PMT
548  for (size_t i=0; i!=TrackHypotheses.size(); ++i)
549  {
550  mf::LogVerbatim("TrackTimeAssoc")<< "Visbility for track " << i <<std::endl;
551 
552  for(size_t j=0; j!=TrackHypotheses.at(i).size(); ++j)
553  {
554  mf::LogVerbatim("TrackTimeAssoc") << "Signal at PMT " << j << ", " << TrackHypotheses.at(i).at(j)<<std::endl;
555  }
556  }
557 
558  }
MaybeLogger_< ELseverityLevel::ELsev_info, true > LogVerbatim
void opdet::TrackTimeAssoc::produce ( art::Event evt)
virtual

Implements art::EDProducer.

Definition at line 313 of file TrackTimeAssoc_module.cc.

References evd::details::begin(), f, art::DataViewImpl::getByLabel(), recob::Track::Length(), geo::GeometryCore::NOpChannels(), geo::GeometryCore::NOpDets(), geo::GeometryCore::OpDetFromOpChannel(), recob::OpFlash::TotalPE(), track, and opdet::TrackTimeAssoc_tracksort().

314  {
315 
316  // int EventID = evt.id().event();
317 
318 
319  // Read in flashes from the event
321  evt.getByLabel(fFlashModuleLabel, flashh);
322  std::vector<art::Ptr<recob::OpFlash> > Flashes;
323  for(unsigned int i=0; i < flashh->size(); ++i)
324  {
325  art::Ptr<recob::OpFlash> flash(flashh,i);
326  if(flash->TotalPE()>fPECut) Flashes.push_back(flash);
327  }
328 
329  // Read in tracks from the event
331  evt.getByLabel(fTrackModuleLabel, trackh);
332  std::vector<art::Ptr<recob::Track> > Tracks;
333  for(unsigned int i=0; i < trackh->size(); ++i)
334  {
335  art::Ptr<recob::Track> track(trackh,i);
336  if(track->Length()>fLengthCut) Tracks.push_back(track);
337  }
338 
339  std::sort(Tracks.begin(), Tracks.end(), TrackTimeAssoc_tracksort);
340 
341  // Use these to produce Bezier tracks
342  std::vector<bool> TracksToCut(Tracks.size(),false);
343  std::vector<trkf::BezierTrack*> BTracks;
344  BTracks.clear();
345  for(size_t i=0; i!=Tracks.size(); i++)
346  BTracks.push_back(new trkf::BezierTrack(*Tracks.at(i)));
347 
349  size_t NOpDets = geom->NOpDets();
350 
351  std::map<int, bool> OnBeamFlashes;
352 
353  std::vector<std::vector<std::vector<double> > > TrackHypotheses;
354  std::vector<std::vector<double> > FlashShapes;
355 
356 
357  // For each track
358  for (size_t i=0; i!=BTracks.size(); ++i)
359  {
360  TrackHypotheses.push_back(ScanMIPHypotheses(BTracks.at(i)));
361  }
362 
363 
364  for(size_t f=0; f!=Flashes.size(); ++f)
365  {
366 
367  std::vector<double> ThisFlashShape(NOpDets,0);
368 
369  // if(Flashes.at(f)->InBeamFrame())
370  // {
371  for (unsigned int c = 0; c < geom->NOpChannels(); c++){
372  unsigned int o = geom->OpDetFromOpChannel(c);
373  ThisFlashShape[o]+=Flashes.at(f)->PE(c);
374  }
375  if(Flashes.at(f)->OnBeamTime()) OnBeamFlashes[f]=true;
376  // }
377  FlashShapes.push_back(ThisFlashShape);
378 
379  }
380 
381  // This map stores the Chi2 for every match:
382  // Chi2Map[Track][Flash] = chi2
383  std::map<int, std::map<int, double> > Chi2Map;
384 
385  // This map sorts the preferences of each track for each flash
386  // SortedPrefs[TrackID][Chi2] = {flashid1, flashid2, ...}
387  std::vector<std::map<double, std::vector<int> > > SortedPrefs(Tracks.size());
388 
389 
390  for(size_t i=0; i!=TrackHypotheses.size(); ++i)
391  {
392  for(size_t j=0; j!=FlashShapes.size(); ++j)
393  {
394  double Chi2 = GetMinChi2(TrackHypotheses.at(i), FlashShapes.at(j));
395 
396  Chi2Map[i][j]=Chi2;
397  SortedPrefs[i][Chi2].push_back(j);
398 
399  }
400  }
401 
402 
403  // This will hold the list of matches
404  std::vector<anab::FlashMatch> Matches;
405 
406 
407 
408  if(fPairingMode==0)
409  {
410  // In pairing mode 0, store all combinatoric matches and let the user
411  // deal with Chi2s later
412  for(size_t i=0; i!=BTracks.size(); ++i)
413  for(size_t j=0; j!=Flashes.size(); ++j)
414  Matches.push_back( anab::FlashMatch(Chi2Map[i][j], j, i, (Flashes.at(j)->OnBeamTime()>0)));
415  }
416 
417  else if(fPairingMode==1)
418  {
419  // In pairing mode 1, use the stable marriage algorithm to make a guess
420  // at good 1<->1 pairings
421 
422  bool StillPairing =true;
423  std::vector<int> FlashesPaired(Flashes.size(),-1);
424  std::vector<int> TracksPaired(BTracks.size(),-1);
425 
426  // If we made a new match in the last round, don't stop
427  while(StillPairing)
428  {
429  StillPairing=false;
430  for(size_t i=0; i!=BTracks.size(); ++i)
431  {
432  // If this track still to be paired
433  if(TracksPaired[i]<0)
434  {
435  // Find the flash with best remaining chi2
436  bool MadeMatch = false;
437  for(auto itPref = SortedPrefs[i].begin(); itPref!=SortedPrefs[i].end(); ++itPref)
438  {
439  for(size_t iflash =0; iflash!=itPref->second.size(); ++iflash)
440  {
441  int FlashID = itPref->second.at(iflash);
442  int FlashExistingPref = FlashesPaired[FlashID];
443  if(FlashExistingPref < 0)
444  {
445  // This flash is available - make pairing
446  TracksPaired[i] = FlashID;
447 
448  // if the flash is on beam, claim to be
449  // satisfied, but don't occupy flash
450  // if flash is cosmic, claim it.
451  if(!OnBeamFlashes[FlashID])
452  FlashesPaired[FlashID] = i;
453 
454  StillPairing = true;
455  MadeMatch = true;
456  }
457  else
458  {
459  // This flash taken - flash gets to vote
460  if(Chi2Map[i][FlashID] < Chi2Map[FlashExistingPref][FlashID])
461  {
462  // If the flash prefers the new guy, switch
463  FlashesPaired[FlashID] = i;
464  TracksPaired[i] = FlashID;
465  TracksPaired[FlashExistingPref] = -1;
466  MadeMatch = true;
467  StillPairing = true;
468  break;
469  }
470  // or else just roll on...
471  }
472  }
473  if(MadeMatch) break;
474  } // end loop over chi2s
475  } // end if unpaired track
476  } // end loop over tracks
477  } // end loop until no more pairing
478 
479 
480  for(size_t i=0; i!=BTracks.size(); ++i)
481  {
482  if(TracksPaired[i]>0)
483  {
484  int TrackID = i;
485  int FlashID = TracksPaired[i];
486 
487  Matches.push_back( anab::FlashMatch(Chi2Map[TrackID][FlashID], FlashID, TrackID, Flashes.at(FlashID)->OnBeamTime() ));
488  }
489  }
490  }
491 
492 
493  StoreFlashMatches(Tracks, Flashes, Matches, evt);
494 
495  }
unsigned int NOpChannels() const
Number of electronics channels for all the optical detectors.
double GetMinChi2(std::vector< std::vector< double > > ScannedHypotheses, std::vector< double > FlashShape)
unsigned int OpDetFromOpChannel(int opChannel) const
Convert unique channel to detector number.
TFile f
Definition: plotHisto.C:6
std::vector< evd::details::RawDigitInfo_t >::const_iterator begin(RawDigitCacheDataClass const &cache)
void StoreFlashMatches(std::vector< art::Ptr< recob::Track > > &Tracks, std::vector< art::Ptr< recob::OpFlash > > &Flashes, std::vector< anab::FlashMatch > &Matches, art::Event &evt)
unsigned int NOpDets() const
Number of OpDets in the whole detector.
std::vector< std::vector< double > > ScanMIPHypotheses(trkf::BezierTrack *Btrack)
bool getByLabel(std::string const &label, std::string const &productInstanceName, Handle< PROD > &result) const
Definition: DataViewImpl.h:344
Float_t track
Definition: plot.C:34
bool TrackTimeAssoc_tracksort(art::Ptr< recob::Track > t1, art::Ptr< recob::Track > t2)
void opdet::TrackTimeAssoc::reconfigure ( fhicl::ParameterSet const &  p)

Definition at line 159 of file TrackTimeAssoc_module.cc.

References fhicl::ParameterSet::get().

160  {
161  fTrackModuleLabel = pset.get<std::string>("TrackModuleLabel");
162  fFlashModuleLabel = pset.get<std::string>("FlashModuleLabel");
163  fBezierResolution = pset.get<int>("BezierResolution");
164  fLengthCut = pset.get<double>("LengthCut");
165  fPECut = pset.get<double>("PECut");
166  fPairingMode = pset.get<int>("PairingMode");
167 
168 
169  }
std::vector< std::vector< double > > opdet::TrackTimeAssoc::ScanMIPHypotheses ( trkf::BezierTrack Btrack)

Definition at line 188 of file TrackTimeAssoc_module.cc.

References phot::PhotonVisibilityService::GetAllVisibilities(), trkf::BezierTrack::GetTrackPoint(), trkf::BezierTrack::GetTrajectory(), recob::Trajectory::Length(), phot::PhotonVisibilityService::NOpChannels(), geo::GeometryCore::NOpDets(), s, and recob::Trajectory::Start().

189  {
190 
191  double MinX = 0; //temporary
192  double MaxX = 250; //temporary
193  size_t XSteps = 50; //temporary
194 
196 
197  std::vector<std::vector<double> > ReturnVector(XSteps);
198  for(size_t i=0; i!=XSteps; ++i)
199  ReturnVector[i].resize(geom->NOpDets());
200 
202 
203  float TrackLength = Btrack->GetTrajectory().Length();
204  float OldVertex = Btrack->GetTrajectory().Start().X();
205 
206  std::vector<bool> ValidTrajectory(XSteps, true);
207 
208  double xyz[3];
209  for (int b=0; b!=fBezierResolution; b++)
210  {
211  auto const* larp = lar::providerFrom<detinfo::LArPropertiesService>();
212 
213  double MIPYield = larp->ScintYield();
214  double QE = 0.01;
215  double MIPdQdx = 2.1;
216  double PromptFrac = 0.25;
217  double PromptMIPScintYield = MIPYield * QE * MIPdQdx * PromptFrac;
218 
219  // std::cout<<"check : " << PromptMIPScintYield<<std::endl;
220 
221  float s = float(b) / float(fBezierResolution);
222  float LightAmount = PromptMIPScintYield * TrackLength/float(fBezierResolution);
223 
224 
225  for(size_t i=0; i!=XSteps; ++i)
226  {
227  if(ValidTrajectory[i])
228  {
229  float NewVertex = MinX + float(i)/float(XSteps)*(MaxX-MinX);
230  Btrack->GetTrackPoint(s,xyz);
231  xyz[0] += NewVertex-OldVertex;
232 
233  if((xyz[0] > MaxX) || (xyz[0] < MinX) ) ValidTrajectory[i]=false;
234 
235  const float* PointVisibility = pvs->GetAllVisibilities(xyz);
236  if (!PointVisibility) continue; // point not covered by visibility service
237 
238  for(size_t OpDet =0; OpDet!=pvs->NOpChannels(); OpDet++)
239  {
240  ReturnVector.at(i).at(OpDet) += PointVisibility[OpDet] * LightAmount;
241  }
242  }
243  }
244  }
245  for(size_t i=0; i!=ReturnVector.size(); ++i)
246  if(!ValidTrajectory[i]) ReturnVector.at(i).clear();
247  return ReturnVector;
248  }
Float_t s
Definition: plot.C:23
double Length(size_t startAt=0) const
Returns the approximate length of the trajectory.
Definition: Trajectory.cxx:64
void GetTrackPoint(double s, double *xyz) const
float const * GetAllVisibilities(double const *xyz, bool wantReflected=false) const
recob::Trajectory const & GetTrajectory() const
Returns the current trajectory.
Definition: BezierTrack.h:96
unsigned int NOpDets() const
Number of OpDets in the whole detector.
Point_t const & Start() const
Returns the position of the first point of the trajectory [cm].
Definition: Trajectory.h:228
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 opdet::TrackTimeAssoc::StoreFlashMatches ( std::vector< art::Ptr< recob::Track > > &  Tracks,
std::vector< art::Ptr< recob::OpFlash > > &  Flashes,
std::vector< anab::FlashMatch > &  Matches,
art::Event evt 
)

Definition at line 564 of file TrackTimeAssoc_module.cc.

References util::CreateAssn(), and art::Event::put().

565  {
566  std::unique_ptr< std::vector<anab::FlashMatch> > flash_matches ( new std::vector<anab::FlashMatch>);
567  std::unique_ptr< art::Assns<recob::Track, anab::FlashMatch > > assn_track( new art::Assns<recob::Track, anab::FlashMatch>);
568  std::unique_ptr< art::Assns<recob::OpFlash, anab::FlashMatch > > assn_flash( new art::Assns<recob::OpFlash, anab::FlashMatch>);
569 
570  for(size_t i=0; i!=Matches.size(); ++i)
571  {
572  flash_matches->push_back(Matches.at(i));
573 
574  util::CreateAssn(*this, evt, *(flash_matches.get()), Tracks.at(Matches.at(i).SubjectID()), *(assn_track.get()), i);
575 
576  util::CreateAssn(*this, evt, *(flash_matches.get()), Flashes.at(Matches.at(i).FlashID()), *(assn_flash.get()), i);
577  }
578 
579 
580  evt.put(std::move(flash_matches));
581  evt.put(std::move(assn_track));
582  evt.put(std::move(assn_flash));
583  }
ProductID put(std::unique_ptr< PROD > &&product)
Definition: Event.h:102
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.
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

int opdet::TrackTimeAssoc::fBezierResolution
private

Definition at line 66 of file TrackTimeAssoc_module.cc.

std::string opdet::TrackTimeAssoc::fFlashModuleLabel
private

Definition at line 65 of file TrackTimeAssoc_module.cc.

double opdet::TrackTimeAssoc::fLengthCut
private

Definition at line 68 of file TrackTimeAssoc_module.cc.

int opdet::TrackTimeAssoc::fPairingMode
private

Definition at line 67 of file TrackTimeAssoc_module.cc.

double opdet::TrackTimeAssoc::fPECut
private

Definition at line 69 of file TrackTimeAssoc_module.cc.

std::string opdet::TrackTimeAssoc::fTrackModuleLabel
private

Definition at line 64 of file TrackTimeAssoc_module.cc.


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