Public Member Functions | Private Member Functions | Private Attributes | List of all members
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
 
- Public Member Functions inherited from evdb_tool::IWFHitDrawer
virtual ~IWFHitDrawer () noexcept=default
 

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 23 of file DrawSkewHits_tool.cc.

Constructor & Destructor Documentation

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

Definition at line 53 of file DrawSkewHits_tool.cc.

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

Definition at line 58 of file DrawSkewHits_tool.cc.

59 {
60 }

Member Function Documentation

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

Implements evdb_tool::IWFHitDrawer.

Definition at line 62 of file DrawSkewHits_tool.cc.

63 {
64  return;
65 }
void evdb_tool::DrawSkewHits::Draw ( evdb::View2D &  view2D,
raw::ChannelID_t channel 
) const
overridevirtual

Implements evdb_tool::IWFHitDrawer.

Definition at line 68 of file DrawSkewHits_tool.cc.

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

Definition at line 180 of file DrawSkewHits_tool.cc.

185 {
186  return (amplitude * exp(0.4*(x-peaktime)/tau1) / ( 1 + exp(0.4*(x-peaktime)/tau2) ) );
187 }
G4double tau1[100]
Definition: G4S2Light.cc:61
list x
Definition: train.py:276
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 190 of file DrawSkewHits_tool.cc.

197 {
198  double x_sum = 0.;
199 
200  for(int i = HitNumber; i < HitNumber+NHits; i++)
201  {
202  x_sum += (amplitude[i] * exp(0.4*(x-peaktime[i])/tau1[i]) / ( 1 + exp(0.4*(x-peaktime[i])/tau2[i]) ) );
203  }
204 
205  return x_sum;
206 }
list x
Definition: train.py:276

Member Data Documentation

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

Definition at line 48 of file DrawSkewHits_tool.cc.


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