LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
evdb_tool::DrawSkewHits Class Reference
Inheritance diagram for evdb_tool::DrawSkewHits:
evdb_tool::IWFHitDrawer

Public Member Functions

 DrawSkewHits (const fhicl::ParameterSet &pset)
 
 ~DrawSkewHits ()
 
void configure (const fhicl::ParameterSet &pset) override
 
void Draw (evdb::View2D &, raw::ChannelID_t &) const override
 

Private Member Functions

double EvalExpoFit (double x, double tau1, double tau2, double amplitude, double peaktime) const
 
double EvalMultiExpoFit (double x, int HitNumber, int NHits, std::vector< double > tau1, std::vector< double > tau2, std::vector< double > amplitude, std::vector< double > peaktime) const
 

Private Attributes

std::vector< TPolyLine * > fPolyLineVec
 

Detailed Description

Definition at line 27 of file DrawSkewHits_tool.cc.

Constructor & Destructor Documentation

evdb_tool::DrawSkewHits::DrawSkewHits ( const fhicl::ParameterSet pset)
explicit

Definition at line 52 of file DrawSkewHits_tool.cc.

References configure().

53  {
54  configure(pset);
55  }
void configure(const fhicl::ParameterSet &pset) override
evdb_tool::DrawSkewHits::~DrawSkewHits ( )

Definition at line 57 of file DrawSkewHits_tool.cc.

57 {}

Member Function Documentation

void evdb_tool::DrawSkewHits::configure ( const fhicl::ParameterSet pset)
overridevirtual

Implements evdb_tool::IWFHitDrawer.

Definition at line 59 of file DrawSkewHits_tool.cc.

Referenced by DrawSkewHits().

60  {
61  return;
62  }
void evdb_tool::DrawSkewHits::Draw ( evdb::View2D view2D,
raw::ChannelID_t channel 
) const
overridevirtual

Implements evdb_tool::IWFHitDrawer.

Definition at line 64 of file DrawSkewHits_tool.cc.

References evdb::View2D::AddPolyLine(), recob::Hit::Channel(), anab::FVectorReader< T, N >::create(), art::PtrVector< T >::empty(), EvalExpoFit(), EvalMultiExpoFit(), evd::RecoDrawingOptions::fHitLabels, fPolyLineVec, evdb::EventHolder::GetEvent(), evdb::EventHolder::Instance(), art::PtrVector< T >::push_back(), art::PtrVector< T >::size(), x, and y.

65  {
69 
70  //grab the singleton with the event
72  if (!event) return;
73 
74  fPolyLineVec.clear();
75 
76  for (size_t imod = 0; imod < recoOpt->fHitLabels.size(); ++imod) {
77  art::InputTag const which = recoOpt->fHitLabels[imod];
78 
80  event->getByLabel(which, hitVecHandle);
81 
82  // Get a container for the subset of hits we are working with and setup to fill it
84  bool stillSearching(true);
85  int fitParamsOffset(0);
86 
87  // Loop through all hits and find those on the channel in question, also count up to the start of these hits
88  for (size_t hitIdx = 0; hitIdx < hitVecHandle->size(); hitIdx++) {
89  art::Ptr<recob::Hit> hit(hitVecHandle, hitIdx);
90 
91  if (hit->Channel() == channel) {
92  hitPtrVec.push_back(hit);
93  stillSearching = false;
94  }
95  else if (!stillSearching)
96  break;
97 
98  if (stillSearching) fitParamsOffset++;
99  }
100 
101  // No hits no work
102  if (hitPtrVec.empty()) continue;
103 
104  // The fit parameters will be returned in an auxiliary object
105  auto hitResults = anab::FVectorReader<recob::Hit, 4>::create(*event, "dprawhit");
106  const auto& fitParamVecs = hitResults->vectors();
107 
108  // Containers for the piecess...
109  std::vector<double> hitPeakTimeVec;
110  std::vector<double> hitTau1Vec;
111  std::vector<double> hitTau2Vec;
112  std::vector<double> hitPeakAmpVec;
113  std::vector<int> hitStartTVec;
114  std::vector<int> hitEndTVec;
115  std::vector<int> hitNMultiHitVec;
116  std::vector<int> hitLocalIdxVec;
117 
118  // Ok, loop through the hits for this channnel and recover the parameters
119  for (size_t idx = 0; idx < hitPtrVec.size(); ++idx) {
120  const auto& fitParams = fitParamVecs[fitParamsOffset + idx];
121  const auto& hit = hitPtrVec[idx];
122 
123  hitPeakTimeVec.push_back(fitParams[0]);
124  hitTau1Vec.push_back(fitParams[1]);
125  hitTau2Vec.push_back(fitParams[2]);
126  hitPeakAmpVec.push_back(fitParams[3]);
127  hitStartTVec.push_back(hit->StartTick());
128  hitEndTVec.push_back(hit->EndTick());
129  hitNMultiHitVec.push_back(hit->Multiplicity());
130  hitLocalIdxVec.push_back(hit->LocalIndex());
131  }
132 
133  // Now we can go through these and start filling the polylines
134  for (size_t idx = 0; idx < hitPeakTimeVec.size(); idx++) {
135  if (hitNMultiHitVec[idx] > 1 && hitLocalIdxVec[idx] == 0) {
136  TPolyLine& p2 = view2D.AddPolyLine(1001, kRed, 3, 1);
137 
138  // set coordinates of TPolyLine based fitted function
139  for (int j = 0; j < 1001; ++j) {
140  double x = hitStartTVec[idx] +
141  j * (hitEndTVec[idx + hitNMultiHitVec[idx] - 1] - hitStartTVec[idx]) / 1000;
142  double y = EvalMultiExpoFit(
143  x, idx, hitNMultiHitVec[idx], hitTau1Vec, hitTau2Vec, hitPeakAmpVec, hitPeakTimeVec);
144  p2.SetPoint(j, x, y);
145  }
146 
147  fPolyLineVec.push_back(&p2);
148  p2.Draw("same");
149  }
150 
151  // Always draw the single peaks in addition to the sum of all peaks
152  // create TPolyLine that actually gets drawn
153  TPolyLine& p1 = view2D.AddPolyLine(1001, kOrange + 7, 3, 1);
154 
155  // set coordinates of TPolyLine based fitted function
156  for (int j = 0; j < 1001; ++j) {
157  double x = hitStartTVec[idx - hitLocalIdxVec[idx]] +
158  j *
159  (hitEndTVec[idx + hitNMultiHitVec[idx] - hitLocalIdxVec[idx] - 1] -
160  hitStartTVec[idx - hitLocalIdxVec[idx]]) /
161  1000;
162  double y = EvalExpoFit(
163  x, hitTau1Vec[idx], hitTau2Vec[idx], hitPeakAmpVec[idx], hitPeakTimeVec[idx]);
164  p1.SetPoint(j, x, y);
165  }
166 
167  fPolyLineVec.push_back(&p1);
168 
169  p1.Draw("same");
170  }
171  }
172 
173  return;
174  }
Float_t x
Definition: compare.C:6
const art::Event * GetEvent() const
Definition: EventHolder.cxx:45
TPolyLine & AddPolyLine(int n, int c, int w, int s)
Definition: View2D.cxx:210
Float_t y
Definition: compare.C:6
static std::unique_ptr< FVectorReader > create(const art::Event &evt, const art::InputTag &tag)
Definition: MVAReader.h:28
void push_back(Ptr< U > const &p)
Definition: PtrVector.h:435
static EventHolder * Instance()
Definition: EventHolder.cxx:15
std::vector< TPolyLine * > fPolyLineVec
bool empty() const
Definition: PtrVector.h:330
size_type size() const
Definition: PtrVector.h:302
Detector simulation of raw signals on wires.
double EvalExpoFit(double x, double tau1, double tau2, double amplitude, double peaktime) const
double EvalMultiExpoFit(double x, int HitNumber, int NHits, std::vector< double > tau1, std::vector< double > tau2, std::vector< double > amplitude, std::vector< double > peaktime) const
std::vector< art::InputTag > fHitLabels
module labels that produced hits
Namespace collecting geometry-related classes utilities.
Event finding and building.
double evdb_tool::DrawSkewHits::EvalExpoFit ( double  x,
double  tau1,
double  tau2,
double  amplitude,
double  peaktime 
) const
private

Definition at line 176 of file DrawSkewHits_tool.cc.

Referenced by Draw().

181  {
182  return (amplitude * exp(0.4 * (x - peaktime) / tau1) / (1 + exp(0.4 * (x - peaktime) / tau2)));
183  }
Float_t x
Definition: compare.C:6
double evdb_tool::DrawSkewHits::EvalMultiExpoFit ( double  x,
int  HitNumber,
int  NHits,
std::vector< double >  tau1,
std::vector< double >  tau2,
std::vector< double >  amplitude,
std::vector< double >  peaktime 
) const
private

Definition at line 186 of file DrawSkewHits_tool.cc.

References DEFINE_ART_CLASS_TOOL.

Referenced by Draw().

193  {
194  double x_sum = 0.;
195 
196  for (int i = HitNumber; i < HitNumber + NHits; i++) {
197  x_sum += (amplitude[i] * exp(0.4 * (x - peaktime[i]) / tau1[i]) /
198  (1 + exp(0.4 * (x - peaktime[i]) / tau2[i])));
199  }
200 
201  return x_sum;
202  }
Float_t x
Definition: compare.C:6

Member Data Documentation

std::vector<TPolyLine*> evdb_tool::DrawSkewHits::fPolyLineVec
mutableprivate

Definition at line 47 of file DrawSkewHits_tool.cc.

Referenced by Draw().


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