FairRoot/PandaRoot
Public Member Functions | Protected Member Functions | Static Protected Member Functions | Protected Attributes | List of all members
PndLmdLinFitTask Class Reference

#include <PndLmdLinFitTask.h>

Inheritance diagram for PndLmdLinFitTask:

Public Member Functions

 PndLmdLinFitTask ()
 
 PndLmdLinFitTask (TString tTCandBranchName, TString tRecoBranchName, TString tOutputBranchName="LMDPndTrack", TString tOutputFolder="PndLmd")
 
virtual ~PndLmdLinFitTask ()
 
virtual InitStatus Init ()
 
virtual void Exec (Option_t *opt)
 
virtual void Finish ()
 
void SetRadLen (double x)
 

Protected Member Functions

double FCN_MS (const double *vars)
 
double ScatteredAngle (double radLen)
 
double line3DfitMS (TGraph2DErrors *gr, const TVector3 &posSeed, const TVector3 &dirSeed, std::vector< double > &fitpar, TMatrixDSym *covmatrix)
 
double GetSigmaMS (int side)
 
 ClassDef (PndLmdLinFitTask, 2)
 

Static Protected Member Functions

static double distance_MS (double x, double y, double z, double errx, double erry, const double *p, double *zpr)
 

Protected Attributes

TClonesArray * fTCandArray
 
TClonesArray * fRecoArray
 
TString fTCandBranchName
 
TString fRecoBranchName
 
TString fOutputBranchName
 
TString fOutputFolder
 
TClonesArray * fTrackArray
 
double fPbeam
 
double fsigmaMSa
 
double fsigmaMSb
 
bool hitMergedfl [4]
 
double fPDGCode
 
int fCharge
 
PndGeoHandlingfGeoH
 
ROOT::Math::Minimizer * fmin
 
TGraph2DErrors * fGraph2D
 
double ftotRadLen
 

Detailed Description

Definition at line 30 of file PndLmdLinFitTask.h.

Constructor & Destructor Documentation

PndLmdLinFitTask::PndLmdLinFitTask ( )

Definition at line 44 of file PndLmdLinFitTask.cxx.

References fCharge, fmin, fOutputBranchName, fOutputFolder, fPbeam, fPDGCode, fRecoBranchName, fsigmaMSa, fsigmaMSb, fTCandBranchName, ftotRadLen, and hitMergedfl.

45  : FairTask("3D-Straight-Line-Fit"),
46  fTCandArray(0),
47  fRecoArray(0),
48  fTrackArray(0),
49  fGeoH(0) {
50  fTCandBranchName = "LMDTrackCand";
51  // fRecoBranchName = "LMDHitsStrip";
52  fRecoBranchName = "LMDHitsPixel";
53  // fRecoBranchName = "LmdHits";
54  fOutputBranchName = "LMDPndTrack";
55  fOutputFolder = "PndLmd";
56 
57  fPbeam = 0;
58  fPDGCode = -2212; // barp
59  fCharge = -1; // barp
60  fsigmaMSa = 0;
61  fsigmaMSb = 0;
62  ftotRadLen = 0;
63 
64  fmin = ROOT::Math::Factory::CreateMinimizer("Minuit2", "Migrad");
65 
66  fmin->SetMaxFunctionCalls(1000000);
67  fmin->SetMaxIterations(100000);
68  fmin->SetTolerance(0.001);
69 
70  for (int ih = 0; ih < 4; ih++) hitMergedfl[ih] = false;
71 }
TClonesArray * fTCandArray
TClonesArray * fRecoArray
PndGeoHandling * fGeoH
ROOT::Math::Minimizer * fmin
TClonesArray * fTrackArray
PndLmdLinFitTask::PndLmdLinFitTask ( TString  tTCandBranchName,
TString  tRecoBranchName,
TString  tOutputBranchName = "LMDPndTrack",
TString  tOutputFolder = "PndLmd" 
)

Definition at line 72 of file PndLmdLinFitTask.cxx.

References fCharge, fmin, fOutputBranchName, fOutputFolder, fPbeam, fPDGCode, fRecoBranchName, fsigmaMSa, fsigmaMSb, fTCandBranchName, ftotRadLen, and hitMergedfl.

76  : FairTask("3D-Straight-Line-Fit"),
77  fTCandArray(0),
78  fRecoArray(0),
79  fTrackArray(0),
80  fGeoH(0) {
81  fTCandBranchName = tTCandBranchName;
82  fRecoBranchName = tRecoBranchName;
83  fOutputBranchName = tOutputBranchName;
84  fOutputFolder = tOutputFolder;
85 
86  fPbeam = 0;
87  fPDGCode = -2212; // barp
88  fCharge = -1; // barp
89  // fsigmaMS = 0;
90  fsigmaMSa = 0;
91  fsigmaMSb = 0;
92  ftotRadLen = 0;
93 
94  fmin = ROOT::Math::Factory::CreateMinimizer("Minuit2", "Migrad");
95 
96  fmin->SetMaxFunctionCalls(1000000);
97  fmin->SetMaxIterations(100000);
98  fmin->SetTolerance(0.001);
99 
100  for (int ih = 0; ih < 4; ih++) hitMergedfl[ih] = false;
101 }
TClonesArray * fTCandArray
TClonesArray * fRecoArray
PndGeoHandling * fGeoH
ROOT::Math::Minimizer * fmin
TClonesArray * fTrackArray
PndLmdLinFitTask::~PndLmdLinFitTask ( )
virtual

Definition at line 103 of file PndLmdLinFitTask.cxx.

103  {
104  // delete fmin;
105  cout << "PndLmdLinFitTask::~PndLmdLinFitTask()" << endl;
106 }

Member Function Documentation

PndLmdLinFitTask::ClassDef ( PndLmdLinFitTask  ,
 
)
protected
double PndLmdLinFitTask::distance_MS ( double  x,
double  y,
double  z,
double  errx,
double  erry,
const double *  p,
double *  zpr 
)
staticprotected

Definition at line 318 of file PndLmdLinFitTask.cxx.

References Double_t, and sqrt().

Referenced by FCN_MS().

320  {
321  double THfunc[8] = {1, 1, 1, 1, 1, 1, 1, 1};
322  // p[5] = sqrt(1-p[1]*p[1]-p[3]*p[3]);
323  // Double_t t_min = p[1]*(x-p[0])+p[3]*(y-p[2])+p[5]*(z-p[4]);
324  // Double_t t_min = p[5]*(z-p[4]);
325  // Double_t t_min = p[1]*(x-p[0])+p[3]*(y-p[2]);
326  Double_t t_min = p[1] * (x - p[0]) + p[3] * (y - p[2]) +
327  sqrt(1 - p[1] * p[1] - p[3] * p[3]) * (z - p[4]);
328  // Double_t t_min = (z-p[4]);//TEST
329  for (int iz = 0; iz < 8; iz++)
330  if (((p[4] + t_min) - zpr[iz]) <= 0) THfunc[iz] = 0;
331 
332  double funcX = p[0] + p[1] * t_min +
333  (-p[6] + p[7]) * ((p[4] + t_min) - zpr[0]) * THfunc[0] +
334  (-p[8] + p[9]) * ((p[4] + t_min) - zpr[2]) * THfunc[2] +
335  (-p[10] + p[11]) * ((p[4] + t_min) - zpr[4]) * THfunc[4] +
336  (-p[12] + p[13]) * ((p[4] + t_min) - zpr[6]) * THfunc[6];
337  double funcY = p[2] + p[3] * t_min +
338  (-p[14] + p[15]) * ((p[4] + t_min) - zpr[0]) * THfunc[0] +
339  (-p[16] + p[17]) * ((p[4] + t_min) - zpr[2]) * THfunc[2] +
340  (-p[18] + p[19]) * ((p[4] + t_min) - zpr[4]) * THfunc[4] +
341  (-p[20] + p[21]) * ((p[4] + t_min) - zpr[6]) * THfunc[6];
342 
343  double fdx = TMath::Power((x - funcX) / errx, 2);
344  double fdy = TMath::Power((y - funcY) / erry, 2);
345  double fdz = 0;
346  double fchi2 = fdx + fdy + fdz;
347  return fchi2;
348 }
Double_t p
Definition: anasim.C:58
friend F32vec4 sqrt(const F32vec4 &a)
Definition: P4_F32vec4.h:29
Double_t
Double_t z
Double_t x
Double_t y
void PndLmdLinFitTask::Exec ( Option_t *  opt)
virtual

Definition at line 163 of file PndLmdLinFitTask.cxx.

References Double_t, fCharge, fGeoH, fPbeam, fPDGCode, fRecoArray, fTCandArray, fTrackArray, fVerbose, PndTrackCandHit::GetDetId(), PndTrackCandHit::GetHitId(), PndSdsMergedHit::GetIsMerged(), PndTrackCand::GetNHits(), PndGeoHandling::GetOUVShortId(), PndSdsHit::GetPosition(), PndSdsHit::GetSensorID(), PndTrackCand::GetSortedHit(), hitMergedfl, line3DfitMS(), pid(), and track.

163  {
164  // Reset output Array
165  if (fTrackArray == 0) Fatal("PndLmdLinFitTask::Exec", "No TrackArray");
166  fTrackArray->Delete();
167 
168  Int_t ntcand = fTCandArray->GetEntriesFast();
169 
170  // Detailed output
171  if (fVerbose > 1)
172  std::cout << " -I- PndLmdLinFitTask: contains " << ntcand
173  << " RhoCandidates" << std::endl;
174  if (fVerbose > 2) {
175  std::cout << " Detailed Debug info on the candidates:" << std::endl;
176  unsigned int index = 12345; // detid=12345, //[R.K.03/2017] unused
177  // variable
178  for (Int_t itr = 0; itr < ntcand; ++itr) {
179  PndTrackCand* trcnd = (PndTrackCand*)fTCandArray->At(itr);
180  std::cout << "TrackCand no. " << itr << " has " << trcnd->GetNHits()
181  << " hits." << std::endl;
182  std::cout << "Point: \t Index: " << std::endl;
183  for (unsigned int ihit = 0; ihit < trcnd->GetNHits();
184  ihit++) { // fill Graph
185  PndTrackCandHit theHit = trcnd->GetSortedHit(ihit); // get hit
186  index = theHit.GetHitId();
187  // detid = theHit.GetDetId(); //[R.K.03/2017] unused variable
188  std::cout << ihit << "\t" << index << std::endl;
189  }
190  }
191  }
192 
193  // Fitting
194  // ----------------------------------------------------------------------------------
195  // if(fVerbose>1)
196  // std::cout<<" -I- PndLmdLinFitTask: start Fitting "<<std::endl;
197  int rec_tkr = 0;
198  for (Int_t track = 0; track < ntcand; track++) {
199  PndTrackCand* trcnd = (PndTrackCand*)fTCandArray->At(track);
200  const int numPts = trcnd->GetNHits(); // read how many points in this track
201 
202  TGraph2DErrors fitme(numPts); // new graph for fitting
203  // Int_t firstHit=-1, lastHit=-1; //[R.K.03/2017] unused variable
204  TVector3 hit0, hit1;
205  for (int ihit = 0; ihit < numPts; ihit++) { // fill Graph
206  PndTrackCandHit theHit = trcnd->GetSortedHit(ihit); // get hit
207  Int_t index = theHit.GetHitId();
208  // Int_t detId = theHit.GetDetId(); //[R.K. 01/2017] unused variable
209  // if(fVerbose>2) std::cout << "Point: "<< ihit<< " index: "<< index
210  // <<std::endl;
211 
212  // PndSdsHit* addHit = (PndSdsHit*) fRecoArray->At(index);
213  PndSdsMergedHit* addHit = (PndSdsMergedHit*)fRecoArray->At(index);
214  // cout<<"IsMerged??? "<<addHit->GetIsMerged()<<endl;
215  hitMergedfl[ihit] = addHit->GetIsMerged();
216 
217  TVector3 addPos = addHit->GetPosition();
218  double xhit = addPos.X();
219  double yhit = addPos.Y();
220  double zhit = addPos.Z();
221  // lmddim->Transform_global_to_lmd_local(xhit,yhit,zhit,false);
222  // TVector3 addPos2(xhit,yhit,zhit);
223  if (ihit == 0) {
224  // firstHit=index; //[R.K.03/2017] unused variable
225  hit0 = addPos;
226  } else {
227  if (ihit == 2) hit1 = addPos;
228  // if(ihit==1) hit1 = addPos;
229  // if(ihit==numPts-1) hit1 = addPos;
230  if (ihit == numPts - 1) {
231  // lastHit=index; //[R.K.03/2017] unused variable
232  // hit1 = addPos2;
233  }
234  }
235  double errxhit = addHit->GetDx();
236  double erryhit = addHit->GetDy();
237  double errzhit = addHit->GetDz();
238  fitme.SetPoint(ihit, xhit, yhit, zhit);
239  fitme.SetPointError(ihit, errxhit, erryhit, errzhit);
240  // fitme.SetPointError(ihit, 0.5*errxhit,0.5*erryhit,0.5*errzhit);
241  } // end of Hits in TCand
242 
243  TVector3 dirSeed = hit1 - hit0;
244  TVector3 posSeed = hit0;
245  // cout<<"DirSeed before fit and norm:"<<endl;
246  // dirSeed.Print();
247  dirSeed = dirSeed.Unit();
248  std::vector<double> fit_parameters(22); // fit-parameter
249  TMatrixDSym* COVmatrix = new TMatrixDSym(6);
250  Double_t accuracy = line3DfitMS(&fitme, posSeed, dirSeed, fit_parameters,
251  COVmatrix); // with kink angles
252  // Double_t accuracy = line3Dfit(numPts, &fitme, posSeed, dirSeed,
253  // parFit, COVmatrix); //MS taking into account by hits errors
254 
255  // save as PndTrack
256  TVector3 FitPoint(fit_parameters[0], fit_parameters[2], fit_parameters[4]);
257  TVector3 FitDir(fit_parameters[1], fit_parameters[3], fit_parameters[5]);
258  // TVector3 FitDir(parFit[1]+parFit[9], parFit[3]+parFit[17],
259  // sqrt(1-(parFit[1]+parFit[9])*(parFit[1]+parFit[9])-(parFit[3]+parFit[17])*(parFit[3]+parFit[17])));//TEST
260  TVector3 FitMom = FitDir * fPbeam;
261  Double_t COVmatrixPosMom[6][6];
262 
263  for (int ij = 0; ij < 6; ij++) {
264  for (int ji = 0; ji < 6; ji++) COVmatrixPosMom[ij][ji] = 0;
265  }
266 
267  int iconver[6] = {3, 0, 4, 1, 5, 2};
268  for (int ij = 0; ij < 6; ij++) {
269  for (int ji = 0; ji < 6; ji++) {
270  if (ij == 1 || ij == 3 || ij == 5) (*COVmatrix)(ij, ji) *= fPbeam;
271  if (ji == 1 || ji == 3 || ji == 5) (*COVmatrix)(ij, ji) *= fPbeam;
272  int km = iconver[ij];
273  int mk = iconver[ji];
274  COVmatrixPosMom[km][mk] = (*COVmatrix)(ij, ji);
275  }
276  }
277  delete COVmatrix;
278 
279  // Read info about 1st plane(sensor)
280  PndTrackCandHit theHit = trcnd->GetSortedHit(0); // get 1st hit
281  Int_t hitID = theHit.GetHitId();
282  int sysID = theHit.GetDetId();
283  PndSdsHit* myHit = (PndSdsHit*)(fRecoArray->At(hitID));
284  Int_t id = myHit->GetSensorID();
285 
286  TVector3 oo, uu, vv;
287  fGeoH->GetOUVShortId(id, oo, uu, vv);
288  // TVector3 o = oo;
289  TVector3 o = FitPoint;
290  TVector3 dj = uu;
291  TVector3 dk = vv;
292 
293  FairTrackParP* trkfitp = new FairTrackParP(
294  FitPoint, FitMom, COVmatrixPosMom, fCharge, o, dj, dk);
295  int flagpndtrk = 0;
296  if (accuracy > 1e3)
297  flagpndtrk = -1; // quality of track: bad if chi2 is too large
298  int ndf = 2 * (trcnd->GetNHits()) - 4; // number d.o.f
299  int pid = fPDGCode;
300 
301  PndTrack* trackfit = new PndTrack(
302  *trkfitp, *trkfitp, *trcnd, flagpndtrk, accuracy, ndf, pid, track,
303  sysID); // TODO: FairTrackParP at 1st and last point???
304  new ((*fTrackArray)[rec_tkr]) PndTrack(*(trackfit)); // save Track
305 
306  delete trackfit; // TEST
307  rec_tkr++;
308  //}
309  } // end of TCand's
310 
311  // Done--------------------------------------------------------------------------------------
312  if (fVerbose > 2) std::cout << "Fitting done" << std::endl;
313 
314  return;
315 }
int fVerbose
Definition: poormantracks.C:24
void GetOUVShortId(Int_t shortId, TVector3 &o, TVector3 &u, TVector3 &v)
TVector3 GetPosition() const
Definition: PndSdsHit.h:93
PndTrackCandHit GetSortedHit(UInt_t i)
Definition: PndTrackCand.h:54
int pid()
bool GetIsMerged() const
TClonesArray * fTCandArray
TClonesArray * fRecoArray
Double_t
PndMCTrack * track
Definition: anaLmdCluster.C:89
UInt_t GetNHits() const
Definition: PndTrackCand.h:59
PndGeoHandling * fGeoH
TClonesArray * fTrackArray
Int_t GetSensorID() const
Definition: PndSdsHit.h:90
Int_t GetHitId() const
double line3DfitMS(TGraph2DErrors *gr, const TVector3 &posSeed, const TVector3 &dirSeed, std::vector< double > &fitpar, TMatrixDSym *covmatrix)
Int_t GetDetId() const
double PndLmdLinFitTask::FCN_MS ( const double *  vars)
protected

Definition at line 351 of file PndLmdLinFitTask.cxx.

References distance_MS(), fGraph2D, GetSigmaMS(), i, npoints, sqrt(), x, y, and z.

Referenced by line3DfitMS().

351  {
352  double* x = fGraph2D->GetX();
353  double* y = fGraph2D->GetY();
354  double* z = fGraph2D->GetZ();
355  double* errx = fGraph2D->GetEX();
356  double* erry = fGraph2D->GetEY();
357  int npoints = fGraph2D->GetN();
358  double sum(0.0);
359  double erralA = GetSigmaMS(0);
360  double erralB = GetSigmaMS(1);
361  double zpr[8];
362  int izcur = 0;
363  for (int izpl = 0; izpl < 4; izpl++) {
364  zpr[izcur] = z[izpl];
365  izcur++;
366  zpr[izcur] = z[izpl];
367  izcur++;
368  }
369  for (int i = 0; i < npoints; ++i) {
370  double chi2 = distance_MS(x[i], y[i], z[i], errx[i], erry[i], vars, zpr);
371  sum += chi2;
372  }
373  double fdal = 0;
374  for (int jms = 0; jms < 8; jms = jms + 2) {
375  double errTot = sqrt(erralA * erralA + erralB * erralB);
376  fdal += TMath::Power(((vars[7 + jms] - vars[6 + jms]) / errTot), 2);
377  fdal += TMath::Power(((vars[15 + jms] - vars[14 + jms]) / errTot), 2);
378  }
379  sum += fdal;
380  return sum;
381 }
TGraph2DErrors * fGraph2D
Int_t i
Definition: run_full.C:25
static double distance_MS(double x, double y, double z, double errx, double erry, const double *p, double *zpr)
friend F32vec4 sqrt(const F32vec4 &a)
Definition: P4_F32vec4.h:29
TString vars[MAX]
Definition: autocutx.C:34
Double_t z
double GetSigmaMS(int side)
Double_t x
Double_t y
void PndLmdLinFitTask::Finish ( )
virtual

Definition at line 516 of file PndLmdLinFitTask.cxx.

516 {}
double PndLmdLinFitTask::GetSigmaMS ( int  side)
inlineprotected

Definition at line 56 of file PndLmdLinFitTask.h.

References fsigmaMSa, and fsigmaMSb.

Referenced by FCN_MS().

56  {
57  if (side < 1)
58  return fsigmaMSa;
59  else
60  return fsigmaMSb;
61  }
InitStatus PndLmdLinFitTask::Init ( )
virtual

Definition at line 108 of file PndLmdLinFitTask.cxx.

References fCharge, fGeoH, fmin, fOutputBranchName, fOutputFolder, fPbeam, fPDGCode, fRecoArray, fRecoBranchName, fRun, fsigmaMSa, fsigmaMSb, fTCandArray, fTCandBranchName, ftotRadLen, fTrackArray, fVerbose, PndGeoHandling::Instance(), par, rtdb, and ScatteredAngle().

Referenced by runLumi4Fitter(), and runLumiPixel4Fitter().

108  {
109  // Get ROOT Manager
110  FairRootManager* ioman = FairRootManager::Instance();
111 
112  if (ioman == 0) {
113  Error("PndLmdLinFitTask::Init", "RootManager not instantiated!");
114  return kERROR;
115  }
116 
117  // Get input collection
118  fTCandArray = (TClonesArray*)ioman->GetObject(fTCandBranchName);
119 
120  if (fTCandArray == 0) {
121  Error("PndLmdLinFitTask::Init", "trackcand-array not found!");
122  return kERROR;
123  }
124 
125  fRecoArray = (TClonesArray*)ioman->GetObject(fRecoBranchName);
126 
127  if (fRecoArray == 0) {
128  Error("PndLmdLinFitTask::Init", "reco-array not found!");
129  return kERROR;
130  }
131 
132  fTrackArray = new TClonesArray("PndTrack");
133  ioman->Register(fOutputBranchName, fOutputFolder, fTrackArray, kTRUE);
134 
135  // read beam momentum from base
136  FairRun* fRun = FairRun::Instance();
137  FairRuntimeDb* rtdb = fRun->GetRuntimeDb();
138  FairBaseParSet* par =
139  (FairBaseParSet*)(rtdb->findContainer("FairBaseParSet"));
140  fPbeam = par->GetBeamMom();
141  fPDGCode = -2212; // barp
142  fCharge = -1; // barp
143 
145  // double totRadLen = 0.00306;//rad.length of whole plane
146  cout << "RadLeng = " << ftotRadLen << endl;
147  double totRadLen = ftotRadLen;
148  if (totRadLen < 1e-6)
149  totRadLen = 0.00306; // standart rad.length of whole plane
150  // totRadLen -=2*0.000175;// -flex-cable
151  // totRadLen -=0.00053;// -sensor
152  fsigmaMSb = ScatteredAngle(totRadLen);
153  double totRadLenCable = 0.053; // sensor
154  totRadLenCable += 0.05; // rest
155  fsigmaMSa = ScatteredAngle(totRadLenCable);
156 
157  fmin->SetPrintLevel(fVerbose);
158 
159  std::cout << "-I- PndLmdLinFitTask: Initialisation successfull" << std::endl;
160  return kSUCCESS;
161 }
int fVerbose
Definition: poormantracks.C:24
Double_t par[3]
TClonesArray * fTCandArray
double ScatteredAngle(double radLen)
FairRunAna * fRun
Definition: hit_dirc.C:58
TClonesArray * fRecoArray
FairRuntimeDb * rtdb
Definition: hit_dirc.C:66
static PndGeoHandling * Instance()
PndGeoHandling * fGeoH
ROOT::Math::Minimizer * fmin
TClonesArray * fTrackArray
double PndLmdLinFitTask::line3DfitMS ( TGraph2DErrors *  gr,
const TVector3 &  posSeed,
const TVector3 &  dirSeed,
std::vector< double > &  fitpar,
TMatrixDSym *  covmatrix 
)
protected

!!!!!!!!!!!!!!!!! z0, dz weren't fitted

!!!!!!!!!!!!!!!!!


Definition at line 398 of file PndLmdLinFitTask.cxx.

References Double_t, f, fabs(), FCN_MS(), fGraph2D, fmin, fsigmaMSa, fsigmaMSb, fVerbose, i, and sqrt().

Referenced by Exec().

402  {
403  const int nparams = fitpar.size();
404  ROOT::Math::Functor f(this, &PndLmdLinFitTask::FCN_MS, nparams);
405  fmin->SetFunction(f);
406 
407  if (fVerbose > 2)
408  cout << "PndLmdLinFitTask::line3Dfit with SEED is used (multiple "
409  "scattering taking into account with kinks)"
410  << endl;
411  Int_t Npoint = gr->GetN();
412  Double_t ErrX1 = gr->GetErrorX(0);
413  Double_t ErrY1 = gr->GetErrorY(0);
414  Double_t ErrZ1 = gr->GetErrorZ(0);
415 
416  Double_t ErrX2 = gr->GetErrorX(2);
417  Double_t ErrY2 = gr->GetErrorY(2);
418 
419  Double_t errRx = TMath::Hypot(ErrX1, ErrX2);
420  Double_t errRy = TMath::Hypot(ErrY1, ErrY2);
421 
422  fGraph2D = gr;
423 
424  if (fVerbose > 5) {
425  cout << "Number of hits = " << Npoint << endl;
426  cout << "posSeed:" << endl;
427  posSeed.Print();
428  TVector3 ErrPosSeed(ErrX1, ErrY1, ErrZ1);
429  cout << "ErrposSeed:" << endl;
430  ErrPosSeed.Print();
431  cout << "dirSeed:" << endl;
432  dirSeed.Print();
433  }
434 
435  fmin->SetVariable(0, "x0", posSeed.X(), ErrX1);
436  fmin->SetVariable(1, "Ax", dirSeed.X(), errRx);
437  fmin->SetVariable(2, "y0", posSeed.Y(), ErrY1);
438  fmin->SetVariable(3, "Ay", dirSeed.Y(), errRy);
439 
440  fmin->SetFixedVariable(4, "z0", posSeed.Z());
441  fmin->SetFixedVariable(5, "Az", dirSeed.Z());
442 
443  double scaling_factor(1e-4);
444  fmin->SetVariable(6, "al0x_a", 0.0, scaling_factor * fsigmaMSa);
445  fmin->SetVariable(7, "al0x_b", 0.0, scaling_factor * fsigmaMSb);
446  fmin->SetFixedVariable(8, "al1x_a", 0.0);
447  fmin->SetVariable(9, "al1x_b", 0.0, scaling_factor * fsigmaMSb);
448  fmin->SetFixedVariable(10, "al2x_a", 0.0);
449  fmin->SetVariable(11, "al2x_b", 0.0, scaling_factor * fsigmaMSb);
450  fmin->SetFixedVariable(12, "al3x_a", 0.0);
451  fmin->SetFixedVariable(13, "al3x_b", 0.0);
452 
453  fmin->SetVariable(14, "al0y_a", 0.0, scaling_factor * fsigmaMSa);
454  fmin->SetVariable(15, "al0y_b", 0.0, scaling_factor * fsigmaMSb);
455  fmin->SetFixedVariable(16, "al1y_a", 0.0);
456  fmin->SetVariable(17, "al1y_b", 0.0, scaling_factor * fsigmaMSb);
457  fmin->SetFixedVariable(18, "al2y_a", 0.0);
458  fmin->SetVariable(19, "al2y_b", 0.0, scaling_factor * fsigmaMSb);
459  fmin->SetFixedVariable(20, "al3y_a", 0.0);
460  fmin->SetFixedVariable(21, "al3y_b", 0.0);
461 
462  if (Npoint < 4) {
463  fmin->FixVariable(11);
464  fmin->FixVariable(19);
465  }
466 
467  fmin->Minimize();
468 
469  double recpres = 1e-7;
470 
471  if (fmin->Edm() > 1e2 * recpres) {
472  return 1e6;
473  }
474 
475  // get fit parameters
476  for (int i = 0; i < nparams; ++i) {
477  fitpar[i] = fmin->X()[i];
478  }
479 
480  for (size_t i = 0; i < 6; i++) {
481  for (size_t j = 0; j < 6; j++) {
482  (*covmatrix)(i, j) = fmin->CovMatrix(i, j);
483  }
484  }
485 
487  (*covmatrix)(4, 4) = (gr->GetErrorZ(0) * gr->GetErrorZ(0)) / 12.;
488 
489  fitpar[5] = sqrt(1 - fitpar[1] * fitpar[1] - fitpar[3] * fitpar[3]);
490  double dp5_dp1 = fitpar[1] / fitpar[5];
491  double dp5_dp3 = fitpar[3] / fitpar[5];
492  double errdz2 = pow(dp5_dp1, 2) * (*covmatrix)(1, 1) +
493  pow(dp5_dp3, 2) * (*covmatrix)(3, 3) +
494  2 * fabs(dp5_dp1 * dp5_dp3 * (*covmatrix)(1, 3));
495  (*covmatrix)(5, 5) = errdz2;
497 
498  Double_t chi2 = fmin->MinValue() / (2. * Npoint - 4);
499 
500  if (fVerbose > 2) {
501  cout << " chi2 = " << chi2 << endl;
502  cout << "[AFTER FIT] start.point: (" << fitpar[0] << ", " << fitpar[2]
503  << ", " << fitpar[4] << ")" << endl;
504  cout << "[AFTER FIT] dir: (" << fitpar[1] << ", " << fitpar[3] << ", "
505  << fitpar[5] << ")"
506  << " sqrt(p1^2+p3^2+p5^2) = "
507  << sqrt(fitpar[1] * fitpar[1] + fitpar[3] * fitpar[3] +
508  fitpar[5] * fitpar[5])
509  << endl;
510  }
512 
513  return chi2;
514 }
int fVerbose
Definition: poormantracks.C:24
TGraph2DErrors * fGraph2D
Int_t i
Definition: run_full.C:25
friend F32vec4 sqrt(const F32vec4 &a)
Definition: P4_F32vec4.h:29
Double_t
TFile * f
Definition: bump_analys.C:12
friend F32vec4 fabs(const F32vec4 &a)
Definition: P4_F32vec4.h:47
ROOT::Math::Minimizer * fmin
double FCN_MS(const double *vars)
double PndLmdLinFitTask::ScatteredAngle ( double  radLen)
protected

Definition at line 383 of file PndLmdLinFitTask.cxx.

References Double_t, fPbeam, CAMath::Log(), and CAMath::Sqrt().

Referenced by Init().

383  {
384  // Calculation of ThetaMS -------------------------------------
385  // Charge & mass of particle
386  // Int_t PDGCode = -2212; //barp //[R.K. 01/2017] unused variable
387  Double_t fMass = 0.938272046;
388  Double_t Ebeam = TMath::Hypot(fPbeam, fMass);
389  TLorentzVector LorMom(0, 0, fPbeam, Ebeam);
390  Double_t beta = LorMom.Beta();
391  Double_t X_to_X0 = radLen;
392  Double_t thetaMS = 13.6 * 1e-3 * TMath::Sqrt(X_to_X0) *
393  (1 + 0.038 * TMath::Log(X_to_X0)) / (beta * fPbeam);
394  return thetaMS;
395 }
static T Sqrt(const T &x)
Definition: PndCAMath.h:37
Double_t
static T Log(const T &x)
Definition: PndCAMath.h:40
void PndLmdLinFitTask::SetRadLen ( double  x)
inline

Definition at line 46 of file PndLmdLinFitTask.h.

References ftotRadLen, and x.

Referenced by reco_LMD(), and runLumiPixel4Fitter().

46 { ftotRadLen = 1e-2 * x; } // rad.length X/X0 [%]
Double_t x

Member Data Documentation

int PndLmdLinFitTask::fCharge
protected

Definition at line 80 of file PndLmdLinFitTask.h.

Referenced by Exec(), Init(), and PndLmdLinFitTask().

PndGeoHandling* PndLmdLinFitTask::fGeoH
protected

Definition at line 81 of file PndLmdLinFitTask.h.

Referenced by Exec(), and Init().

TGraph2DErrors* PndLmdLinFitTask::fGraph2D
protected

Definition at line 84 of file PndLmdLinFitTask.h.

Referenced by FCN_MS(), and line3DfitMS().

ROOT::Math::Minimizer* PndLmdLinFitTask::fmin
protected

Definition at line 83 of file PndLmdLinFitTask.h.

Referenced by Init(), line3DfitMS(), and PndLmdLinFitTask().

TString PndLmdLinFitTask::fOutputBranchName
protected

Definition at line 69 of file PndLmdLinFitTask.h.

Referenced by Init(), and PndLmdLinFitTask().

TString PndLmdLinFitTask::fOutputFolder
protected

Definition at line 70 of file PndLmdLinFitTask.h.

Referenced by Init(), and PndLmdLinFitTask().

double PndLmdLinFitTask::fPbeam
protected

Definition at line 74 of file PndLmdLinFitTask.h.

Referenced by Exec(), Init(), PndLmdLinFitTask(), and ScatteredAngle().

double PndLmdLinFitTask::fPDGCode
protected

Definition at line 79 of file PndLmdLinFitTask.h.

Referenced by Exec(), Init(), and PndLmdLinFitTask().

TClonesArray* PndLmdLinFitTask::fRecoArray
protected

Definition at line 65 of file PndLmdLinFitTask.h.

Referenced by Exec(), and Init().

TString PndLmdLinFitTask::fRecoBranchName
protected

Definition at line 68 of file PndLmdLinFitTask.h.

Referenced by Init(), and PndLmdLinFitTask().

double PndLmdLinFitTask::fsigmaMSa
protected

Definition at line 75 of file PndLmdLinFitTask.h.

Referenced by GetSigmaMS(), Init(), line3DfitMS(), and PndLmdLinFitTask().

double PndLmdLinFitTask::fsigmaMSb
protected

Definition at line 76 of file PndLmdLinFitTask.h.

Referenced by GetSigmaMS(), Init(), line3DfitMS(), and PndLmdLinFitTask().

TClonesArray* PndLmdLinFitTask::fTCandArray
protected

Definition at line 64 of file PndLmdLinFitTask.h.

Referenced by Exec(), and Init().

TString PndLmdLinFitTask::fTCandBranchName
protected

Definition at line 67 of file PndLmdLinFitTask.h.

Referenced by Init(), and PndLmdLinFitTask().

double PndLmdLinFitTask::ftotRadLen
protected

Definition at line 86 of file PndLmdLinFitTask.h.

Referenced by Init(), PndLmdLinFitTask(), and SetRadLen().

TClonesArray* PndLmdLinFitTask::fTrackArray
protected

Definition at line 72 of file PndLmdLinFitTask.h.

Referenced by Exec(), and Init().

bool PndLmdLinFitTask::hitMergedfl[4]
protected

Definition at line 78 of file PndLmdLinFitTask.h.

Referenced by Exec(), and PndLmdLinFitTask().


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