Public Member Functions | List of all members
tf::TimingFitAlg Class Reference

Algorithm to determine the direction of tracks using timing. More...

#include "/cvmfs/nova-development.opensciencegrid.org/novasoft/releases/N21-01-23/TimingFit/TimingFitAlg.h"

Public Member Functions

 TimingFitAlg ()
 
TimingFitResult HoughFit (const rb::Track *track) const
 
TimingFitResult HoughFitPts (const std::vector< Pt > &pts) const
 Helper for HoughFit. May be useful for more advanced users. More...
 

Detailed Description

Algorithm to determine the direction of tracks using timing.

Definition at line 26 of file TimingFitAlg.h.

Constructor & Destructor Documentation

tf::TimingFitAlg::TimingFitAlg ( )

Definition at line 31 of file TimingFitAlg.cxx.

32  {
33  }

Member Function Documentation

TimingFitResult tf::TimingFitAlg::HoughFit ( const rb::Track track) const

Definition at line 153 of file TimingFitAlg.cxx.

References rb::Cluster::Cell(), cellMax, dir, rb::Prong::Dir(), Dot(), calib::Calibrator::GetTimeRes(), HoughFitPts(), rb::Cluster::MeanTNS(), rb::Cluster::MeanXYZ(), rb::Cluster::NCell(), elec2geo::pos, gen_hdf5record::pt, rb::Cluster::RecoHit(), rb::RecoHit::T(), confusionMatrixTree::t, getGoodRuns4SAM::t0, rb::RecoHit::X(), rb::RecoHit::Y(), and rb::RecoHit::Z().

Referenced by tf::TimingFit::produce(), and cosrej::CosRej::produce().

154  {
155  std::vector<Pt> pts;
156 
158 
159  const unsigned int cellMax = track->NCell();
160  const TVector3 dir = track->Dir();
161  // Center Pts around (0,0). Makes natural choice of MINUIT seeding
162  const TVector3 origin = track->MeanXYZ();
163  const double t0 = track->MeanTNS();
164  for(unsigned int cellIdx = 0; cellIdx < cellMax; ++cellIdx){
165  const art::Ptr<rb::CellHit> chit = track->Cell(cellIdx);
166 
167  const rb::RecoHit rhit = track->RecoHit(chit);
168  const double t = rhit.T();
169 
170  const TVector3 pos(rhit.X(), rhit.Y(), rhit.Z());
171 
172  Pt pt((pos-origin).Dot(dir), t-t0, cal->GetTimeRes(*chit));
173  pts.push_back(pt);
174  } // end for cellIdx
175 
176  return HoughFitPts(pts);
177  }
float T() const
Definition: RecoHit.h:39
double GetTimeRes(rb::CellHit const &cellhit)
unsigned int NCell(geo::View_t view) const
Number of cells in view view.
Definition: Cluster.cxx:134
float Dot(const Proxy &v) const
float Z() const
Definition: RecoHit.h:38
TVector3 MeanXYZ(rb::AveragingScheme=kDefaultScheme) const
Definition: Cluster.cxx:538
Calibrated quantities relying on position in the orthogonal view. To generate a rb::CellHit from a rb...
Definition: RecoHit.h:19
TimingFitResult HoughFitPts(const std::vector< Pt > &pts) const
Helper for HoughFit. May be useful for more advanced users.
virtual TVector3 Dir() const
Unit vector describing prong direction.
Definition: Prong.h:77
rb::RecoHit RecoHit(const art::Ptr< rb::CellHit > &chit) const
Return calibrated hit based on assumed W coordinate.
Definition: Cluster.cxx:259
art::Ptr< rb::CellHit > Cell(geo::View_t view, unsigned int viewIdx) const
Get the ith cell from view view.
Definition: Cluster.cxx:145
TDirectory * dir
Definition: macro.C:5
const int cellMax
float X() const
Definition: RecoHit.h:36
double MeanTNS(rb::AveragingScheme scheme=kDefaultScheme) const
Definition: Cluster.cxx:554
float Y() const
Definition: RecoHit.h:37
TimingFitResult tf::TimingFitAlg::HoughFitPts ( const std::vector< Pt > &  pts) const

Helper for HoughFit. May be useful for more advanced users.

Definition at line 79 of file TimingFitAlg.cxx.

References tf::TimingFitResult::bestInvSpeed, tf::TimingFitResult::bestScore, tf::TimingFitResult::fwdScore, runNovaSAM::ret, tf::TimingFitResult::revScore, tf::TimingFitErrorHandler(), submit_hadd::u, and tf::TimingFitResult::valid.

Referenced by HoughFit().

80  {
81  TimingFitResult ret;
82  if(pts.size() < 2){
83  ret.valid = false;
84  return ret;
85  }
86 
87  gOldHandler = SetErrorHandler(TimingFitErrorHandler);
88 
89  HoughScore hs(pts);
90 
91  ROOT::Minuit2::MnUserParameters mnPars;
92  mnPars.Add("t0", 0, 100);
93  mnPars.Add("cinv", 0, 1./30);
94 
95  // Best fit
96  ROOT::Minuit2::MnMigrad mnMigrad(hs, mnPars);
97  ROOT::Minuit2::FunctionMinimum funcMin = mnMigrad();
98  ret.bestInvSpeed = mnMigrad.Parameter(1).Value();
99  ret.bestScore = -funcMin.Fval()/pts.size();
100  ret.valid = funcMin.IsValid();
101 
102  // Degugging code to look at fit failures
103  /*
104  if(!ret.valid){
105  TH2F h("", ";t_{0} (ns);1/c (ns/cm)", 100, -300, 300, 100, -.2, +.2);
106 
107  for(int x = 0; x < h.GetNbinsX()+2; ++x){
108  const double t0 = h.GetXaxis()->GetBinCenter(x);
109  for(int y = 0; y < h.GetNbinsY()+2; ++y){
110  const double cinv = h.GetYaxis()->GetBinCenter(y);
111 
112  h.SetBinContent(x, y, hs.Eval(t0, cinv));
113  } // end for y (cinv)
114  } // end for x (t0)
115 
116  h.Draw("colz");
117  gPad->Print("map.eps");
118 
119  TGraphErrors* g = new TGraphErrors;
120  for(unsigned int i = 0; i < pts.size(); ++i){
121  g->SetPoint(g->GetN(), pts[i].L, pts[i].t);
122  g->SetPointError(g->GetN()-1, 0, pts[i].err);
123  }
124 
125  g->SetMarkerStyle(kFullCircle);
126  g->Draw("ap");
127  gPad->Print("t_vs_z.eps");
128 
129  exit(0);
130  }
131  */
132 
133  // Best fit constrained to +c
134  mnMigrad.SetValue(0u, 0.);
135  mnMigrad.SetValue(1, +1./30);
136  mnMigrad.Fix(1);
137  funcMin = mnMigrad();
138  ret.fwdScore = -funcMin.Fval()/pts.size();
139 
140  // Best fit constrained to -c
141  mnMigrad.SetValue(0u, 0.);
142  mnMigrad.SetValue(1, -1./30);
143  mnMigrad.Fix(1);
144  funcMin = mnMigrad();
145  ret.revScore = -funcMin.Fval()/pts.size();
146 
147  SetErrorHandler(gOldHandler);
148 
149  return ret;
150  }
void TimingFitErrorHandler(int level, bool b_abort, const char *loc, const char *msg)
ErrorHandlerFunc_t gOldHandler

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