All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Classes | Public Types | Public Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
cosmic::BeamFlashTrackMatchTaggerAlg Class Reference

#include <BeamFlashTrackMatchTaggerAlg.h>

Classes

struct  FlashComparisonProperties
 

Public Types

using Providers_t = lar::ProviderPack< geo::GeometryCore, detinfo::LArProperties >
 Pack of provider-interface supporting services we need. More...
 

Public Member Functions

 BeamFlashTrackMatchTaggerAlg (fhicl::ParameterSet const &p)
 
void RunCompatibilityCheck (std::vector< recob::OpFlash > const &, std::vector< recob::Track > const &, std::vector< anab::CosmicTag > &, std::vector< size_t > &, Providers_t, phot::PhotonVisibilityService const &, opdet::OpDigiProperties const &)
 
void SetHypothesisComparisonTree (TTree *, TH1F *, TH1F *)
 
void RunHypothesisComparison (unsigned int const, unsigned int const, std::vector< recob::OpFlash > const &, std::vector< recob::Track > const &, Providers_t, phot::PhotonVisibilityService const &, opdet::OpDigiProperties const &)
 
void RunHypothesisComparison (unsigned int const, unsigned int const, std::vector< recob::OpFlash > const &, std::vector< simb::MCParticle > const &, Providers_t, phot::PhotonVisibilityService const &, opdet::OpDigiProperties const &)
 

Private Types

enum  CompatibilityResultType { kCompatible = 0, kSingleChannelCut, kCumulativeChannelCut, kIntegralCut }
 
typedef struct
cosmic::BeamFlashTrackMatchTaggerAlg::FlashComparisonProperties 
FlashComparisonProperties_t
 
typedef enum
cosmic::BeamFlashTrackMatchTaggerAlg::CompatibilityResultType 
CompatibilityResultType
 

Private Member Functions

std::vector< float > GetMIPHypotheses (recob::Track const &track, Providers_t providers, phot::PhotonVisibilityService const &pvs, opdet::OpDigiProperties const &, float XOffset=0)
 
std::vector< float > GetMIPHypotheses (simb::MCParticle const &particle, size_t start_i, size_t end_i, Providers_t providers, phot::PhotonVisibilityService const &pvs, opdet::OpDigiProperties const &, float XOffset=0)
 
void AddLightFromSegment (TVector3 const &pt1, TVector3 const &pt2, std::vector< float > &lightHypothesis, float &totalHypothesisPE, geo::GeometryCore const &geom, phot::PhotonVisibilityService const &pvs, float const &PromptMIPScintYield, float XOffset)
 
void NormalizeLightHypothesis (std::vector< float > &lightHypothesis, float const &totalHypothesisPE, geo::GeometryCore const &geom)
 
CompatibilityResultType CheckCompatibility (std::vector< float > const &lightHypothesis, const recob::OpFlash *flashPointer, geo::GeometryCore const &geom)
 
bool InDetector (TVector3 const &, geo::GeometryCore const &)
 
bool InDriftWindow (double, double, geo::GeometryCore const &)
 
void FillFlashProperties (std::vector< float > const &opdetVector, float &, float &, float &, float &, float &, geo::GeometryCore const &geom)
 
float CalculateChi2 (std::vector< float > const &, std::vector< float > const &)
 
void PrintTrackProperties (recob::Track const &, std::ostream *output=&std::cout)
 
void PrintFlashProperties (recob::OpFlash const &, std::ostream *output=&std::cout)
 
void PrintHypothesisFlashComparison (std::vector< float > const &, const recob::OpFlash *, geo::GeometryCore const &geom, CompatibilityResultType, std::ostream *output=&std::cout)
 

Private Attributes

const anab::CosmicTagID_t COSMIC_TYPE_FLASHMATCH
 
const anab::CosmicTagID_t COSMIC_TYPE_OUTSIDEDRIFT
 
const bool DEBUG_FLAG
 
float fMinTrackLength
 
float fMinOpHitPE
 
float fMIPdQdx
 
float fOpDetSaturation
 
float fSingleChannelCut
 
float fCumulativeChannelThreshold
 
unsigned int fCumulativeChannelCut
 
float fIntegralCut
 
bool fMakeOutsideDriftTags
 
bool fNormalizeHypothesisToFlash
 
TTree * cTree
 
FlashComparisonProperties_t cFlashComparison_p
 
std::vector< float > cOpDetVector_flash
 
std::vector< float > cOpDetVector_hyp
 
TH1F * cOpDetHist_flash
 
TH1F * cOpDetHist_hyp
 

Detailed Description

Definition at line 39 of file BeamFlashTrackMatchTaggerAlg.h.

Member Typedef Documentation

Pack of provider-interface supporting services we need.

Definition at line 43 of file BeamFlashTrackMatchTaggerAlg.h.

Member Enumeration Documentation

Constructor & Destructor Documentation

cosmic::BeamFlashTrackMatchTaggerAlg::BeamFlashTrackMatchTaggerAlg ( fhicl::ParameterSet const &  p)

Title: Beam Flash<–>Track Match Algorithim Class Author: Wes Ketchum (wketc.nosp@m.hum@.nosp@m.lanl..nosp@m.gov), based on code from Ben Jones

Description: Algorithm that compares all tracks to the flash during the beam gate, and determines if that track is consistent with having produced that flash. Input: recob::OpFlash, recob::Track Output: anab::CosmicTag (and Assn<anab::CosmicTag,recob::Track>)

Definition at line 31 of file BeamFlashTrackMatchTaggerAlg.cxx.

34  DEBUG_FLAG(p.get<bool>("RunDebugMode",false)),
35  fMinTrackLength(p.get<float>("MinTrackLength")),
36  fMinOpHitPE(p.get<float>("MinOpHitPE",0.1)),
37  fMIPdQdx(p.get<float>("MIPdQdx",2.1)),
38  fOpDetSaturation(p.get<float>("OpDetSaturation",200.)),
39  fSingleChannelCut(p.get<float>("SingleChannelCut")),
40  fCumulativeChannelThreshold(p.get<float>("CumulativeChannelThreshold")),
41  fCumulativeChannelCut(p.get<unsigned int>("CumulativeChannelCut")),
42  fIntegralCut(p.get<float>("IntegralCut")),
43  fMakeOutsideDriftTags(p.get<bool>("MakeOutsideDriftTags",false)),
44  fNormalizeHypothesisToFlash(p.get<bool>("NormalizeHypothesisToFlash"))
45 {}
pdgs p
Definition: selectors.fcl:22

Member Function Documentation

void cosmic::BeamFlashTrackMatchTaggerAlg::AddLightFromSegment ( TVector3 const &  pt1,
TVector3 const &  pt2,
std::vector< float > &  lightHypothesis,
float &  totalHypothesisPE,
geo::GeometryCore const &  geom,
phot::PhotonVisibilityService const &  pvs,
float const &  PromptMIPScintYield,
float  XOffset 
)
private

Definition at line 355 of file BeamFlashTrackMatchTaggerAlg.cxx.

362  {
363 
364  double xyz_segment[3];
365  xyz_segment[0] = 0.5*(pt2.x()+pt1.x()) + XOffset;
366  xyz_segment[1] = 0.5*(pt2.y()+pt1.y());
367  xyz_segment[2] = 0.5*(pt2.z()+pt1.z());
368 
369  //get the visibility vector
370  auto const& PointVisibility = pvs.GetAllVisibilities(xyz_segment);
371 
372  //check pointer, as it may be null if given a y/z outside some range
373  if(!PointVisibility) return;
374 
375  //get the amount of light
376  float LightAmount = PromptMIPScintYield*(pt2-pt1).Mag();
377 
378  for(size_t opdet_i=0; opdet_i<pvs.NOpChannels(); opdet_i++){
379  lightHypothesis[opdet_i] += PointVisibility[opdet_i]*LightAmount;
380  totalHypothesisPE += PointVisibility[opdet_i]*LightAmount;
381 
382  //apply saturation limit
383  if(lightHypothesis[opdet_i]>fOpDetSaturation){
384  totalHypothesisPE -= (lightHypothesis[opdet_i]-fOpDetSaturation);
385  lightHypothesis[opdet_i] = fOpDetSaturation;
386  }
387  }
388 
389 }//end AddLightFromSegment
float cosmic::BeamFlashTrackMatchTaggerAlg::CalculateChi2 ( std::vector< float > const &  light_flash,
std::vector< float > const &  light_track 
)
private

Definition at line 510 of file BeamFlashTrackMatchTaggerAlg.cxx.

511  {
512 
513  float chi2=0;
514  for(size_t pmt_i=0; pmt_i<light_flash.size(); pmt_i++){
515 
516  if(light_flash[pmt_i] < fMinOpHitPE) continue;
517 
518  float err2 = 1;
519  if(light_track[pmt_i] > 1) err2 = light_track[pmt_i];
520 
521  chi2 += (light_flash[pmt_i]-light_track[pmt_i])*(light_flash[pmt_i]-light_track[pmt_i]) / err2;
522  }
523 
524  return chi2;
525 }
cosmic::BeamFlashTrackMatchTaggerAlg::CompatibilityResultType cosmic::BeamFlashTrackMatchTaggerAlg::CheckCompatibility ( std::vector< float > const &  lightHypothesis,
const recob::OpFlash flashPointer,
geo::GeometryCore const &  geom 
)
private

Definition at line 465 of file BeamFlashTrackMatchTaggerAlg.cxx.

468 {
469  float hypothesis_integral=0;
470  float flash_integral=0;
471  unsigned int cumulativeChannels=0;
472 
473  std::vector<double> PEbyOpDet(geom.NOpDets(),0);
474  //for (unsigned int c = 0; c < geom.NOpChannels(); c++){
475  for (unsigned int c = 0; c <= geom.MaxOpChannel(); c++){
476  if ( geom.IsValidOpChannel(c) ) {
477  unsigned int o = geom.OpDetFromOpChannel(c);
478  PEbyOpDet[o] += flashPointer->PE(c);
479  }
480  }
481 
482  float hypothesis_scale=1.;
483  if(fNormalizeHypothesisToFlash) hypothesis_scale = flashPointer->TotalPE();
484 
485  for(size_t pmt_i=0; pmt_i<lightHypothesis.size(); pmt_i++){
486 
487  flash_integral += PEbyOpDet[pmt_i];
488 
489  if(lightHypothesis[pmt_i] < std::numeric_limits<float>::epsilon() ) continue;
490  hypothesis_integral += lightHypothesis[pmt_i]*hypothesis_scale;
491 
492  if(PEbyOpDet[pmt_i] < fMinOpHitPE) continue;
493 
494  float diff_scaled = (lightHypothesis[pmt_i]*hypothesis_scale - PEbyOpDet[pmt_i])/std::sqrt(lightHypothesis[pmt_i]*hypothesis_scale);
495 
496  if( diff_scaled > fSingleChannelCut ) return CompatibilityResultType::kSingleChannelCut;
497 
498  if( diff_scaled > fCumulativeChannelThreshold ) cumulativeChannels++;
499  if(cumulativeChannels >= fCumulativeChannelCut) return CompatibilityResultType::kCumulativeChannelCut;
500 
501  }
502 
503  if( (hypothesis_integral - flash_integral)/std::sqrt(hypothesis_integral)
504  > fIntegralCut) return CompatibilityResultType::kIntegralCut;
505 
506  return CompatibilityResultType::kCompatible;
507 }
double PE(unsigned int i) const
Definition: OpFlash.h:110
double TotalPE() const
Definition: OpFlash.cxx:68
void cosmic::BeamFlashTrackMatchTaggerAlg::FillFlashProperties ( std::vector< float > const &  opdetVector,
float &  sum,
float &  y,
float &  sigmay,
float &  z,
float &  sigmaz,
geo::GeometryCore const &  geom 
)
private

Definition at line 315 of file BeamFlashTrackMatchTaggerAlg.cxx.

319  {
320  y=0; sigmay=0; z=0; sigmaz=0; sum=0;
321  double xyz[3];
322  for(unsigned int opdet=0; opdet<opdetVector.size(); opdet++){
323  sum+=opdetVector[opdet];
324  geom.Cryostat(0).OpDet(opdet).GetCenter(xyz);
325  y += opdetVector[opdet]*xyz[1];
326  z += opdetVector[opdet]*xyz[2];
327  }
328 
329  y /= sum; z /= sum;
330 
331  for(unsigned int opdet=0; opdet<opdetVector.size(); opdet++){
332  geom.Cryostat(0).OpDet(opdet).GetCenter(xyz);
333  sigmay += (opdetVector[opdet]*xyz[1]-y)*(opdetVector[opdet]*xyz[1]-y);
334  sigmaz += (opdetVector[opdet]*xyz[2]-y)*(opdetVector[opdet]*xyz[2]-y);
335  }
336 
337  sigmay = std::sqrt(sigmay)/sum;
338  sigmaz = std::sqrt(sigmaz)/sum;
339 
340 }
process_name opflash particleana ie ie ie z
process_name opflash particleana ie ie y
std::vector< float > cosmic::BeamFlashTrackMatchTaggerAlg::GetMIPHypotheses ( recob::Track const &  track,
Providers_t  providers,
phot::PhotonVisibilityService const &  pvs,
opdet::OpDigiProperties const &  opdigip,
float  XOffset = 0 
)
private

Definition at line 400 of file BeamFlashTrackMatchTaggerAlg.cxx.

405 {
406  auto const& geom = *(providers.get<geo::GeometryCore>());
407  auto const& larp = *(providers.get<detinfo::LArProperties>());
408  std::vector<float> lightHypothesis(geom.NOpDets(),0);
409  float totalHypothesisPE=0;
410  const float PromptMIPScintYield = larp.ScintYield()*larp.ScintYieldRatio()*opdigip.QE()*fMIPdQdx;
411 
412  //get QE from ubChannelConfig, which gives per tube, so goes in AddLightFromSegment
413  //VisibleEnergySeparation(step);
414 
415  for(size_t pt=1; pt<track.NumberTrajectoryPoints(); pt++)
416  AddLightFromSegment(track.LocationAtPoint<TVector3>(pt-1),track.LocationAtPoint<TVector3>(pt),
417  lightHypothesis,totalHypothesisPE,
418  geom,pvs,PromptMIPScintYield,
419  XOffset);
420 
421  if(fNormalizeHypothesisToFlash && totalHypothesisPE > std::numeric_limits<float>::epsilon())
422  NormalizeLightHypothesis(lightHypothesis,totalHypothesisPE,geom);
423 
424  return lightHypothesis;
425 
426 }//end GetMIPHypotheses
process_name use argoneut_mc_hitfinder track
void NormalizeLightHypothesis(std::vector< float > &lightHypothesis, float const &totalHypothesisPE, geo::GeometryCore const &geom)
void AddLightFromSegment(TVector3 const &pt1, TVector3 const &pt2, std::vector< float > &lightHypothesis, float &totalHypothesisPE, geo::GeometryCore const &geom, phot::PhotonVisibilityService const &pvs, float const &PromptMIPScintYield, float XOffset)
Description of geometry of one entire detector.
std::vector< float > cosmic::BeamFlashTrackMatchTaggerAlg::GetMIPHypotheses ( simb::MCParticle const &  particle,
size_t  start_i,
size_t  end_i,
Providers_t  providers,
phot::PhotonVisibilityService const &  pvs,
opdet::OpDigiProperties const &  opdigip,
float  XOffset = 0 
)
private

Definition at line 430 of file BeamFlashTrackMatchTaggerAlg.cxx.

436 {
437  auto const& geom = *(providers.get<geo::GeometryCore>());
438  auto const& larp = *(providers.get<detinfo::LArProperties>());
439  std::vector<float> lightHypothesis(geom.NOpDets(),0);
440  float totalHypothesisPE=0;
441  const float PromptMIPScintYield = larp.ScintYield()*larp.ScintYieldRatio()*opdigip.QE()*fMIPdQdx;
442 
443  for(size_t pt=start_i+1; pt<=end_i; pt++)
444  AddLightFromSegment(particle.Position(pt-1).Vect(),particle.Position(pt).Vect(),
445  lightHypothesis,totalHypothesisPE,
446  geom,pvs,PromptMIPScintYield,
447  XOffset);
448 
449  if(fNormalizeHypothesisToFlash && totalHypothesisPE > std::numeric_limits<float>::epsilon())
450  NormalizeLightHypothesis(lightHypothesis,totalHypothesisPE,geom);
451 
452  return lightHypothesis;
453 
454 }//end GetMIPHypotheses
void NormalizeLightHypothesis(std::vector< float > &lightHypothesis, float const &totalHypothesisPE, geo::GeometryCore const &geom)
void AddLightFromSegment(TVector3 const &pt1, TVector3 const &pt2, std::vector< float > &lightHypothesis, float &totalHypothesisPE, geo::GeometryCore const &geom, phot::PhotonVisibilityService const &pvs, float const &PromptMIPScintYield, float XOffset)
Description of geometry of one entire detector.
bool cosmic::BeamFlashTrackMatchTaggerAlg::InDetector ( TVector3 const &  pt,
geo::GeometryCore const &  geom 
)
private

Definition at line 342 of file BeamFlashTrackMatchTaggerAlg.cxx.

342  {
343  if(pt.x() < 0 || pt.x() > 2*geom.DetHalfWidth()) return false;
344  if(std::abs(pt.y()) > geom.DetHalfHeight()) return false;
345  if(pt.z() < 0 || pt.z() > geom.DetLength()) return false;
346  return true;
347 }
T abs(T value)
bool cosmic::BeamFlashTrackMatchTaggerAlg::InDriftWindow ( double  start_x,
double  end_x,
geo::GeometryCore const &  geom 
)
private

Definition at line 349 of file BeamFlashTrackMatchTaggerAlg.cxx.

349  {
350  if(start_x < 0. || end_x < 0.) return false;
351  if(start_x > 2*geom.DetHalfWidth() || end_x > 2*geom.DetHalfWidth()) return false;
352  return true;
353 }
void cosmic::BeamFlashTrackMatchTaggerAlg::NormalizeLightHypothesis ( std::vector< float > &  lightHypothesis,
float const &  totalHypothesisPE,
geo::GeometryCore const &  geom 
)
private

Definition at line 391 of file BeamFlashTrackMatchTaggerAlg.cxx.

393  {
394  for(size_t opdet_i=0; opdet_i<geom.NOpDets(); opdet_i++)
395  lightHypothesis[opdet_i] /= totalHypothesisPE;
396 }
void cosmic::BeamFlashTrackMatchTaggerAlg::PrintFlashProperties ( recob::OpFlash const &  flash,
std::ostream *  output = &std::cout 
)
private

Definition at line 545 of file BeamFlashTrackMatchTaggerAlg.cxx.

546 {
547  *output << "----------------------------------------------" << std::endl;
548  *output << "Flash properties: ";
549 
550  *output << "\n\tTime=" << flash.Time();
551  *output << "\n\tOnBeamTime=" << flash.OnBeamTime();
552  *output << "\n\ty position (center,width)=(" << flash.YCenter() << "," << flash.YWidth() << ")";
553  *output << "\n\tz position (center,width)=(" << flash.ZCenter() << "," << flash.ZWidth() << ")";
554  *output << "\n\tTotal PE=" << flash.TotalPE();
555 
556  *output << std::endl;
557  *output << "----------------------------------------------" << std::endl;
558 
559 }
BEGIN_PROLOG sequence::SlidingWindowTriggerPatternsOppositeWindows END_PROLOG simSlidingORM6O6 effSlidingORW output
void cosmic::BeamFlashTrackMatchTaggerAlg::PrintHypothesisFlashComparison ( std::vector< float > const &  lightHypothesis,
const recob::OpFlash flashPointer,
geo::GeometryCore const &  geom,
CompatibilityResultType  result,
std::ostream *  output = &std::cout 
)
private

Definition at line 561 of file BeamFlashTrackMatchTaggerAlg.cxx.

566 {
567 
568  *output << "----------------------------------------------" << std::endl;
569  *output << "Hypothesis-flash comparison: ";
570 
571  float hypothesis_integral=0;
572  float flash_integral=0;
573 
574  float hypothesis_scale=1.;
575  if(fNormalizeHypothesisToFlash) hypothesis_scale = flashPointer->TotalPE();
576 
577 
578  std::vector<double> PEbyOpDet(geom.NOpDets(),0);
579  //for (unsigned int c = 0; c < geom.NOpChannels(); c++){
580  for ( unsigned int c = 0; c <= geom.MaxOpChannel(); c++){
581  if ( geom.IsValidOpChannel(c) ) {
582  unsigned int o = geom.OpDetFromOpChannel(c);
583  PEbyOpDet[o] += flashPointer->PE(c);
584  }
585  }
586 
587  for(size_t pmt_i=0; pmt_i<lightHypothesis.size(); pmt_i++){
588 
589  flash_integral += PEbyOpDet[pmt_i];
590 
591  *output << "\n\t pmt_i=" << pmt_i << ", (hypothesis,flash)=("
592  << lightHypothesis[pmt_i]*hypothesis_scale << "," << PEbyOpDet[pmt_i] << ")";
593 
594  if(lightHypothesis[pmt_i] < std::numeric_limits<float>::epsilon() ) continue;
595 
596  *output << " difference="
597  << (lightHypothesis[pmt_i]*hypothesis_scale - PEbyOpDet[pmt_i])/std::sqrt(lightHypothesis[pmt_i]*hypothesis_scale);
598 
599  hypothesis_integral += lightHypothesis[pmt_i]*hypothesis_scale;
600  }
601 
602  *output << "\n\t TOTAL (hypothesis,flash)=("
603  << hypothesis_integral << "," << flash_integral << ")"
604  << " difference=" << (hypothesis_integral - flash_integral)/std::sqrt(hypothesis_integral);
605 
606  *output << std::endl;
607  *output << "End result=" << result << std::endl;
608  *output << "----------------------------------------------" << std::endl;
609 
610 }
double PE(unsigned int i) const
Definition: OpFlash.h:110
BEGIN_PROLOG sequence::SlidingWindowTriggerPatternsOppositeWindows END_PROLOG simSlidingORM6O6 effSlidingORW output
double TotalPE() const
Definition: OpFlash.cxx:68
void cosmic::BeamFlashTrackMatchTaggerAlg::PrintTrackProperties ( recob::Track const &  track,
std::ostream *  output = &std::cout 
)
private

Definition at line 528 of file BeamFlashTrackMatchTaggerAlg.cxx.

529 {
530  *output << "----------------------------------------------" << std::endl;
531  *output << "Track properties: ";
532  *output << "\n\tLength=" << track.Length();
533 
534  auto const& pt_begin = track.LocationAtPoint(0);
535  *output << "\n\tBegin Location (x,y,z)=(" << pt_begin.x() << "," << pt_begin.y() << "," << pt_begin.z() << ")";
536 
537  auto const& pt_end = track.LocationAtPoint(track.NumberTrajectoryPoints()-1);
538  *output << "\n\tEnd Location (x,y,z)=(" << pt_end.x() << "," << pt_end.y() << "," << pt_end.z() << ")";
539 
540  *output << "\n\tTrajectoryPoints=" << track.NumberTrajectoryPoints();
541  *output << std::endl;
542  *output << "----------------------------------------------" << std::endl;
543 }
process_name use argoneut_mc_hitfinder track
BEGIN_PROLOG sequence::SlidingWindowTriggerPatternsOppositeWindows END_PROLOG simSlidingORM6O6 effSlidingORW output
void cosmic::BeamFlashTrackMatchTaggerAlg::RunCompatibilityCheck ( std::vector< recob::OpFlash > const &  flashVector,
std::vector< recob::Track > const &  trackVector,
std::vector< anab::CosmicTag > &  cosmicTagVector,
std::vector< size_t > &  assnTrackTagVector,
Providers_t  providers,
phot::PhotonVisibilityService const &  pvs,
opdet::OpDigiProperties const &  opdigip 
)

Definition at line 64 of file BeamFlashTrackMatchTaggerAlg.cxx.

70  {
71 
72  auto const& geom = *(providers.get<geo::GeometryCore>());
73 
74  std::vector< const recob::OpFlash* > flashesOnBeamTime;
75  for(auto const& flash : flashVector){
76  if(!flash.OnBeamTime()) continue;
77  flashesOnBeamTime.push_back(&flash);
78  }
79 
80  //make sure this association vector is initialized properly
81  assnTrackTagVector.resize(trackVector.size(),std::numeric_limits<size_t>::max());
82  cosmicTagVector.reserve(trackVector.size());
83 
84  for(size_t track_i=0; track_i<trackVector.size(); track_i++){
85 
86  recob::Track const& track(trackVector[track_i]);
87 
88  if(track.Length() < fMinTrackLength) continue;
89 
90  //get the begin and end points of this track
91  TVector3 const& pt_begin = track.LocationAtPoint<TVector3>(0);
92  TVector3 const& pt_end = track.LocationAtPoint<TVector3>(track.NumberTrajectoryPoints()-1);
93  std::vector<float> xyz_begin = { (float)pt_begin.x(), (float)pt_begin.y(), (float)pt_begin.z()};
94  std::vector<float> xyz_end = {(float)pt_end.x(), (float)pt_end.y(), (float)pt_end.z()};
95 
96  //check if this track is outside the drift window, and if it is continue
97  if(!InDriftWindow(pt_begin.x(),pt_end.x(),geom)) {
99  cosmicTagVector.emplace_back(xyz_begin,xyz_end,1.,COSMIC_TYPE_OUTSIDEDRIFT);
100  assnTrackTagVector[track_i] = cosmicTagVector.size()-1;
101  }
102  continue;
103  }
104 
105  //get light hypothesis for track
106  std::vector<float> lightHypothesis = GetMIPHypotheses(track,providers,pvs,opdigip);
107 
108  //check compatibility with beam flash
109  bool compatible=false;
110  for(const recob::OpFlash* flashPointer : flashesOnBeamTime){
111  CompatibilityResultType result = CheckCompatibility(lightHypothesis,flashPointer, geom);
112  if(result==CompatibilityResultType::kCompatible) compatible=true;
113  if(DEBUG_FLAG){
115  PrintFlashProperties(*flashPointer);
116  PrintHypothesisFlashComparison(lightHypothesis,flashPointer,geom,result);
117  }
118  }
119 
120  //make tag
121  float cosmicScore=1.;
122  if(compatible) cosmicScore=0.;
123  cosmicTagVector.emplace_back(xyz_begin,xyz_end,cosmicScore,COSMIC_TYPE_FLASHMATCH);
124  assnTrackTagVector[track_i]=cosmicTagVector.size()-1;
125  }
126 
127 }
CompatibilityResultType CheckCompatibility(std::vector< float > const &lightHypothesis, const recob::OpFlash *flashPointer, geo::GeometryCore const &geom)
process_name use argoneut_mc_hitfinder track
std::vector< float > GetMIPHypotheses(recob::Track const &track, Providers_t providers, phot::PhotonVisibilityService const &pvs, opdet::OpDigiProperties const &, float XOffset=0)
void PrintTrackProperties(recob::Track const &, std::ostream *output=&std::cout)
Description of geometry of one entire detector.
void PrintHypothesisFlashComparison(std::vector< float > const &, const recob::OpFlash *, geo::GeometryCore const &geom, CompatibilityResultType, std::ostream *output=&std::cout)
bool InDriftWindow(double, double, geo::GeometryCore const &)
Track from a non-cascading particle.A recob::Track consists of a recob::TrackTrajectory, plus additional members relevant for a &quot;fitted&quot; track:
void PrintFlashProperties(recob::OpFlash const &, std::ostream *output=&std::cout)
void cosmic::BeamFlashTrackMatchTaggerAlg::RunHypothesisComparison ( unsigned int const  run,
unsigned int const  event,
std::vector< recob::OpFlash > const &  flashVector,
std::vector< recob::Track > const &  trackVector,
Providers_t  providers,
phot::PhotonVisibilityService const &  pvs,
opdet::OpDigiProperties const &  opdigip 
)

Definition at line 130 of file BeamFlashTrackMatchTaggerAlg.cxx.

136  {
137 
138  auto const& geom = *(providers.get<geo::GeometryCore>());
139 
140  cFlashComparison_p.run = run;
141  cFlashComparison_p.event = event;
142 
143  std::vector< std::pair<unsigned int, const recob::OpFlash*> > flashesOnBeamTime;
144  for(unsigned int i=0; i<flashVector.size(); i++){
145  recob::OpFlash const& flash = flashVector[i];
146  if(!flash.OnBeamTime()) continue;
147  flashesOnBeamTime.push_back(std::make_pair(i,&flash));
148  }
149 
150  for(size_t track_i=0; track_i<trackVector.size(); track_i++){
151 
152  recob::Track const& track(trackVector[track_i]);
153 
154  if(track.Length() < fMinTrackLength) continue;
155 
156  //get the begin and end points of this track
157  TVector3 const& pt_begin = track.LocationAtPoint<TVector3>(0);
158  TVector3 const& pt_end = track.LocationAtPoint<TVector3>(track.NumberTrajectoryPoints()-1);
159  std::vector<float> xyz_begin = { (float)pt_begin.x(), (float)pt_begin.y(), (float)pt_begin.z()};
160  std::vector<float> xyz_end = {(float)pt_end.x(), (float)pt_end.y(), (float)pt_end.z()};
161 
162  //check if this track is outside the drift window, and if it is continue
163  if(!InDriftWindow(pt_begin.x(),pt_end.x(),geom)) continue;
164 
165  cFlashComparison_p.trk_startx = pt_begin.x();
166  cFlashComparison_p.trk_starty = pt_begin.y();
167  cFlashComparison_p.trk_startz = pt_begin.z();
168  cFlashComparison_p.trk_endx = pt_end.x();
169  cFlashComparison_p.trk_endy = pt_end.y();
170  cFlashComparison_p.trk_endz = pt_end.z();
171 
172  //get light hypothesis for track
173  cOpDetVector_hyp = GetMIPHypotheses(track,providers,pvs,opdigip);
174 
175  cFlashComparison_p.hyp_index = track_i;
180  geom);
181 
182  for(auto flash : flashesOnBeamTime){
183  cOpDetVector_flash = std::vector<float>(geom.NOpDets(),0);
185  for(size_t c=0; c<=geom.MaxOpChannel(); c++){
186  if ( geom.IsValidOpChannel( c ) ) {
187  unsigned int OpDet = geom.OpDetFromOpChannel(c);
188  cOpDetVector_flash[OpDet] += flash.second->PE(c);
189  }
190  }
191  for(size_t o=0; o<cOpDetVector_flash.size(); o++)
193 
194  cFlashComparison_p.flash_index = flash.first;
195  cFlashComparison_p.flash_totalPE = flash.second->TotalPE();
196  cFlashComparison_p.flash_y = flash.second->YCenter();
197  cFlashComparison_p.flash_sigmay = flash.second->YWidth();
198  cFlashComparison_p.flash_z = flash.second->ZCenter();
199  cFlashComparison_p.flash_sigmaz = flash.second->ZWidth();
200 
202 
203  cTree->Fill();
204  }//end loop over flashes
205 
206  }//end loop over tracks
207 
208 
209 }
float CalculateChi2(std::vector< float > const &, std::vector< float > const &)
double PE(unsigned int i) const
Definition: OpFlash.h:110
process_name use argoneut_mc_hitfinder track
double ZCenter() const
Definition: OpFlash.h:117
std::vector< float > GetMIPHypotheses(recob::Track const &track, Providers_t providers, phot::PhotonVisibilityService const &pvs, opdet::OpDigiProperties const &, float XOffset=0)
int OnBeamTime() const
Definition: OpFlash.h:123
Description of geometry of one entire detector.
double YWidth() const
Definition: OpFlash.h:116
bool InDriftWindow(double, double, geo::GeometryCore const &)
void FillFlashProperties(std::vector< float > const &opdetVector, float &, float &, float &, float &, float &, geo::GeometryCore const &geom)
double TotalPE() const
Definition: OpFlash.cxx:68
double YCenter() const
Definition: OpFlash.h:115
Track from a non-cascading particle.A recob::Track consists of a recob::TrackTrajectory, plus additional members relevant for a &quot;fitted&quot; track:
double ZWidth() const
Definition: OpFlash.h:118
void cosmic::BeamFlashTrackMatchTaggerAlg::RunHypothesisComparison ( unsigned int const  run,
unsigned int const  event,
std::vector< recob::OpFlash > const &  flashVector,
std::vector< simb::MCParticle > const &  mcParticleVector,
Providers_t  providers,
phot::PhotonVisibilityService const &  pvs,
opdet::OpDigiProperties const &  opdigip 
)

Definition at line 212 of file BeamFlashTrackMatchTaggerAlg.cxx.

218  {
219 
220  auto const& geom = *(providers.get<geo::GeometryCore>());
221 
222  cFlashComparison_p.run = run;
223  cFlashComparison_p.event = event;
224 
225  std::vector< std::pair<unsigned int, const recob::OpFlash*> > flashesOnBeamTime;
226  for(unsigned int i=0; i<flashVector.size(); i++){
227  recob::OpFlash const& flash = flashVector[i];
228  if(!flash.OnBeamTime()) continue;
229  flashesOnBeamTime.push_back(std::make_pair(i,&flash));
230  }
231 
232  for(size_t particle_i=0; particle_i<mcParticleVector.size(); particle_i++){
233 
234  simb::MCParticle const& particle(mcParticleVector[particle_i]);
235  if(particle.Process().compare("primary")!=0) continue;
236  if(particle.Trajectory().TotalLength() < fMinTrackLength) continue;
237 
238  //get the begin and end points of this track
239  size_t start_i=0, end_i=particle.NumberTrajectoryPoints()-1;
240  bool prev_inside=false;
241  for(size_t pt_i=0; pt_i < particle.NumberTrajectoryPoints(); pt_i++){
242  bool inside = InDetector(particle.Position(pt_i).Vect(),geom);
243  if(inside && !prev_inside) start_i = pt_i;
244  if(!inside && prev_inside) { end_i = pt_i-1; break; }
245  prev_inside = inside;
246  }
247  TVector3 const& pt_begin = particle.Position(start_i).Vect();
248  TVector3 const& pt_end = particle.Position(end_i).Vect();
249  std::vector<float> xyz_begin = { (float)pt_begin.x(), (float)pt_begin.y(), (float)pt_begin.z()};
250  std::vector<float> xyz_end = {(float)pt_end.x(), (float)pt_end.y(), (float)pt_end.z()};
251 
252  //check if this track is outside the drift window, and if it is continue
253  if(!InDriftWindow(pt_begin.x(),pt_end.x(),geom)) continue;
254 
255  cFlashComparison_p.trk_startx = pt_begin.x();
256  cFlashComparison_p.trk_starty = pt_begin.y();
257  cFlashComparison_p.trk_startz = pt_begin.z();
258  cFlashComparison_p.trk_endx = pt_end.x();
259  cFlashComparison_p.trk_endy = pt_end.y();
260  cFlashComparison_p.trk_endz = pt_end.z();
261 
262  //get light hypothesis for track
263  cOpDetVector_hyp = GetMIPHypotheses(particle,start_i,end_i,providers,pvs,opdigip);
264 
265  cFlashComparison_p.hyp_index = particle_i;
270  geom);
271 
272  for(auto flash : flashesOnBeamTime){
273  cOpDetVector_flash = std::vector<float>(geom.NOpDets(),0);
275  //for(size_t c=0; c<geom.NOpChannels(); c++){
276  for(size_t c=0; c<=geom.MaxOpChannel(); c++){
277  if ( geom.IsValidOpChannel(c) ) {
278  unsigned int OpDet = geom.OpDetFromOpChannel(c);
279  cOpDetVector_flash[OpDet] += flash.second->PE(c);
280  }
281  }
282  for(size_t o=0; o<cOpDetVector_flash.size(); o++)
284  cFlashComparison_p.flash_index = flash.first;
285  cFlashComparison_p.flash_totalPE = flash.second->TotalPE();
286  cFlashComparison_p.flash_y = flash.second->YCenter();
287  cFlashComparison_p.flash_sigmay = flash.second->YWidth();
288  cFlashComparison_p.flash_z = flash.second->ZCenter();
289  cFlashComparison_p.flash_sigmaz = flash.second->ZWidth();
290 
292 
293  //cOpDetHist_flash->SetBins(cOpDetVector_flash.size(),0,cOpDetVector_flash.size());
294  for(size_t i=0; i<cOpDetVector_flash.size(); i++)
295  cOpDetHist_flash->SetBinContent(i+1,cOpDetVector_flash[i]);
296 
297  //cOpDetHist_hyp->SetBins(cOpDetVector_hyp.size(),0,cOpDetVector_hyp.size());
298  for(size_t i=0; i<cOpDetVector_hyp.size(); i++)
299  cOpDetHist_hyp->SetBinContent(i+1,cOpDetVector_hyp[i]);
300 
301  for(size_t i=0; i<cOpDetVector_flash.size(); i++){
302  std::cout << "Flash/Hyp " << i << " : "
303  << cOpDetHist_flash->GetBinContent(i+1) << " "
304  << cOpDetHist_hyp->GetBinContent(i+1) << std::endl;
305  }
306 
307  cTree->Fill();
308  }//end loop over flashes
309 
310  }//end loop over tracks
311 
312 
313 }
float CalculateChi2(std::vector< float > const &, std::vector< float > const &)
double PE(unsigned int i) const
Definition: OpFlash.h:110
double ZCenter() const
Definition: OpFlash.h:117
std::vector< float > GetMIPHypotheses(recob::Track const &track, Providers_t providers, phot::PhotonVisibilityService const &pvs, opdet::OpDigiProperties const &, float XOffset=0)
int OnBeamTime() const
Definition: OpFlash.h:123
Description of geometry of one entire detector.
double YWidth() const
Definition: OpFlash.h:116
bool InDriftWindow(double, double, geo::GeometryCore const &)
void FillFlashProperties(std::vector< float > const &opdetVector, float &, float &, float &, float &, float &, geo::GeometryCore const &geom)
double TotalPE() const
Definition: OpFlash.cxx:68
bool InDetector(TVector3 const &, geo::GeometryCore const &)
double YCenter() const
Definition: OpFlash.h:115
BEGIN_PROLOG could also be cout
double ZWidth() const
Definition: OpFlash.h:118
void cosmic::BeamFlashTrackMatchTaggerAlg::SetHypothesisComparisonTree ( TTree *  tree,
TH1F *  hist_flash,
TH1F *  hist_hyp 
)

Definition at line 47 of file BeamFlashTrackMatchTaggerAlg.cxx.

48  {
49  cTree = tree;
50 
51  cOpDetHist_flash = hist_flash;
52  cOpDetHist_flash->SetNameTitle("opdet_hist_flash","Optical Detector Occupancy, Flash");
53 
54  cOpDetHist_hyp = hist_hyp;
55  cOpDetHist_hyp->SetNameTitle("opdet_hist_hyp","Optical Detector Occupancy, Hypothesis");
56 
58  cTree->Branch("opdet_hyp",&cOpDetVector_hyp);
59  cTree->Branch("opdet_flash",&cOpDetVector_flash);
60  cTree->Branch("opdet_hist_flash","TH1F",cOpDetHist_flash);
61  cTree->Branch("opdet_hist_hyp","TH1F",cOpDetHist_hyp);
62 }

Member Data Documentation

FlashComparisonProperties_t cosmic::BeamFlashTrackMatchTaggerAlg::cFlashComparison_p
private

Definition at line 130 of file BeamFlashTrackMatchTaggerAlg.h.

TH1F* cosmic::BeamFlashTrackMatchTaggerAlg::cOpDetHist_flash
private

Definition at line 133 of file BeamFlashTrackMatchTaggerAlg.h.

TH1F* cosmic::BeamFlashTrackMatchTaggerAlg::cOpDetHist_hyp
private

Definition at line 134 of file BeamFlashTrackMatchTaggerAlg.h.

std::vector<float> cosmic::BeamFlashTrackMatchTaggerAlg::cOpDetVector_flash
private

Definition at line 131 of file BeamFlashTrackMatchTaggerAlg.h.

std::vector<float> cosmic::BeamFlashTrackMatchTaggerAlg::cOpDetVector_hyp
private

Definition at line 132 of file BeamFlashTrackMatchTaggerAlg.h.

const anab::CosmicTagID_t cosmic::BeamFlashTrackMatchTaggerAlg::COSMIC_TYPE_FLASHMATCH
private

Definition at line 76 of file BeamFlashTrackMatchTaggerAlg.h.

const anab::CosmicTagID_t cosmic::BeamFlashTrackMatchTaggerAlg::COSMIC_TYPE_OUTSIDEDRIFT
private

Definition at line 77 of file BeamFlashTrackMatchTaggerAlg.h.

TTree* cosmic::BeamFlashTrackMatchTaggerAlg::cTree
private

Definition at line 93 of file BeamFlashTrackMatchTaggerAlg.h.

const bool cosmic::BeamFlashTrackMatchTaggerAlg::DEBUG_FLAG
private

Definition at line 78 of file BeamFlashTrackMatchTaggerAlg.h.

unsigned int cosmic::BeamFlashTrackMatchTaggerAlg::fCumulativeChannelCut
private

Definition at line 86 of file BeamFlashTrackMatchTaggerAlg.h.

float cosmic::BeamFlashTrackMatchTaggerAlg::fCumulativeChannelThreshold
private

Definition at line 85 of file BeamFlashTrackMatchTaggerAlg.h.

float cosmic::BeamFlashTrackMatchTaggerAlg::fIntegralCut
private

Definition at line 87 of file BeamFlashTrackMatchTaggerAlg.h.

bool cosmic::BeamFlashTrackMatchTaggerAlg::fMakeOutsideDriftTags
private

Definition at line 89 of file BeamFlashTrackMatchTaggerAlg.h.

float cosmic::BeamFlashTrackMatchTaggerAlg::fMinOpHitPE
private

Definition at line 81 of file BeamFlashTrackMatchTaggerAlg.h.

float cosmic::BeamFlashTrackMatchTaggerAlg::fMinTrackLength
private

Definition at line 80 of file BeamFlashTrackMatchTaggerAlg.h.

float cosmic::BeamFlashTrackMatchTaggerAlg::fMIPdQdx
private

Definition at line 82 of file BeamFlashTrackMatchTaggerAlg.h.

bool cosmic::BeamFlashTrackMatchTaggerAlg::fNormalizeHypothesisToFlash
private

Definition at line 90 of file BeamFlashTrackMatchTaggerAlg.h.

float cosmic::BeamFlashTrackMatchTaggerAlg::fOpDetSaturation
private

Definition at line 83 of file BeamFlashTrackMatchTaggerAlg.h.

float cosmic::BeamFlashTrackMatchTaggerAlg::fSingleChannelCut
private

Definition at line 84 of file BeamFlashTrackMatchTaggerAlg.h.


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