All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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 27 of file DrawSkewHits_tool.cc.

Constructor & Destructor Documentation

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

Definition at line 57 of file DrawSkewHits_tool.cc.

58 {
59  configure(pset);
60 }
void configure(const fhicl::ParameterSet &pset) override
evdb_tool::DrawSkewHits::~DrawSkewHits ( )

Definition at line 62 of file DrawSkewHits_tool.cc.

63 {
64 }

Member Function Documentation

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

Implements evdb_tool::IWFHitDrawer.

Definition at line 66 of file DrawSkewHits_tool.cc.

67 {
68  return;
69 }
void evdb_tool::DrawSkewHits::Draw ( evdb::View2D &  view2D,
raw::ChannelID_t channel 
) const
overridevirtual

Implements evdb_tool::IWFHitDrawer.

Definition at line 72 of file DrawSkewHits_tool.cc.

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

Definition at line 184 of file DrawSkewHits_tool.cc.

189 {
190  return (amplitude * exp(0.4*(x-peaktime)/tau1) / ( 1 + exp(0.4*(x-peaktime)/tau2) ) );
191 }
process_name opflash particleana ie x
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 194 of file DrawSkewHits_tool.cc.

201 {
202  double x_sum = 0.;
203 
204  for(int i = HitNumber; i < HitNumber+NHits; i++)
205  {
206  x_sum += (amplitude[i] * exp(0.4*(x-peaktime[i])/tau1[i]) / ( 1 + exp(0.4*(x-peaktime[i])/tau2[i]) ) );
207  }
208 
209  return x_sum;
210 }
process_name opflash particleana ie x

Member Data Documentation

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

Definition at line 52 of file DrawSkewHits_tool.cc.


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