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.

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

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

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

Definition at line 95 of file PndLmdLinFitTask.cxx.

95  {
96  // delete fmin;
97  cout << "PndLmdLinFitTask::~PndLmdLinFitTask()" << endl;
98 }

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 308 of file PndLmdLinFitTask.cxx.

References Double_t, and sqrt().

Referenced by FCN_MS().

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

Definition at line 153 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.

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

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

Referenced by line3DfitMS().

338  {
339  double* x = fGraph2D->GetX();
340  double* y = fGraph2D->GetY();
341  double* z = fGraph2D->GetZ();
342  double* errx = fGraph2D->GetEX();
343  double* erry = fGraph2D->GetEY();
344  int npoints = fGraph2D->GetN();
345  double sum(0.0);
346  double erralA = GetSigmaMS(0);
347  double erralB = GetSigmaMS(1);
348  double zpr[8];
349  int izcur = 0;
350  for (int izpl = 0; izpl < 4; izpl++) {
351  zpr[izcur] = z[izpl];
352  izcur++;
353  zpr[izcur] = z[izpl];
354  izcur++;
355  }
356  for (int i = 0; i < npoints; ++i) {
357  double chi2 = distance_MS(x[i], y[i], z[i], errx[i], erry[i], vars, zpr);
358  sum += chi2;
359  }
360  double fdal = 0;
361  for (int jms = 0; jms < 8; jms = jms + 2) {
362  double errTot = sqrt(erralA * erralA + erralB * erralB);
363  fdal += TMath::Power(((vars[7 + jms] - vars[6 + jms]) / errTot), 2);
364  fdal += TMath::Power(((vars[15 + jms] - vars[14 + jms]) / errTot), 2);
365  }
366  sum += fdal;
367  return sum;
368 }
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 494 of file PndLmdLinFitTask.cxx.

494  {
495 }
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 100 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().

100  {
101  // Get ROOT Manager
102  FairRootManager* ioman = FairRootManager::Instance();
103 
104  if (ioman == 0) {
105  Error("PndLmdLinFitTask::Init", "RootManager not instantiated!");
106  return kERROR;
107  }
108 
109  // Get input collection
110  fTCandArray = (TClonesArray*) ioman->GetObject(fTCandBranchName);
111 
112  if (fTCandArray == 0) {
113  Error("PndLmdLinFitTask::Init", "trackcand-array not found!");
114  return kERROR;
115  }
116 
117  fRecoArray = (TClonesArray*) ioman->GetObject(fRecoBranchName);
118 
119  if (fRecoArray == 0) {
120  Error("PndLmdLinFitTask::Init", "reco-array not found!");
121  return kERROR;
122  }
123 
124  fTrackArray = new TClonesArray("PndTrack");
125  ioman->Register(fOutputBranchName, fOutputFolder, fTrackArray, kTRUE);
126 
127  // read beam momentum from base
128  FairRun* fRun = FairRun::Instance();
129  FairRuntimeDb* rtdb = fRun->GetRuntimeDb();
130  FairBaseParSet* par = (FairBaseParSet*) (rtdb->findContainer("FairBaseParSet"));
131  fPbeam = par->GetBeamMom();
132  fPDGCode = -2212; // barp
133  fCharge = -1; // barp
134 
136  // double totRadLen = 0.00306;//rad.length of whole plane
137  cout << "RadLeng = " << ftotRadLen << endl;
138  double totRadLen = ftotRadLen;
139  if (totRadLen < 1e-6) totRadLen = 0.00306; // standart rad.length of whole plane
140  // totRadLen -=2*0.000175;// -flex-cable
141  // totRadLen -=0.00053;// -sensor
142  fsigmaMSb = ScatteredAngle(totRadLen);
143  double totRadLenCable = 0.053; // sensor
144  totRadLenCable += 0.05; // rest
145  fsigmaMSa = ScatteredAngle(totRadLenCable);
146 
147  fmin->SetPrintLevel(fVerbose);
148 
149  std::cout << "-I- PndLmdLinFitTask: Initialisation successfull" << std::endl;
150  return kSUCCESS;
151 }
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 385 of file PndLmdLinFitTask.cxx.

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

Referenced by Exec().

386  {
387  const int nparams = fitpar.size();
388  ROOT::Math::Functor f(this, &PndLmdLinFitTask::FCN_MS, nparams);
389  fmin->SetFunction(f);
390 
391  if (fVerbose > 2) cout << "PndLmdLinFitTask::line3Dfit with SEED is used (multiple "
392  "scattering taking into account with kinks)" << endl;
393  Int_t Npoint = gr->GetN();
394  Double_t ErrX1 = gr->GetErrorX(0);
395  Double_t ErrY1 = gr->GetErrorY(0);
396  Double_t ErrZ1 = gr->GetErrorZ(0);
397 
398  Double_t ErrX2 = gr->GetErrorX(2);
399  Double_t ErrY2 = gr->GetErrorY(2);
400 
401  Double_t errRx = TMath::Hypot(ErrX1, ErrX2);
402  Double_t errRy = TMath::Hypot(ErrY1, ErrY2);
403 
404  fGraph2D = gr;
405 
406  if (fVerbose > 5) {
407  cout << "Number of hits = " << Npoint << endl;
408  cout << "posSeed:" << endl;
409  posSeed.Print();
410  TVector3 ErrPosSeed(ErrX1, ErrY1, ErrZ1);
411  cout << "ErrposSeed:" << endl;
412  ErrPosSeed.Print();
413  cout << "dirSeed:" << endl;
414  dirSeed.Print();
415  }
416 
417  fmin->SetVariable(0, "x0", posSeed.X(), ErrX1);
418  fmin->SetVariable(1, "Ax", dirSeed.X(), errRx);
419  fmin->SetVariable(2, "y0", posSeed.Y(), ErrY1);
420  fmin->SetVariable(3, "Ay", dirSeed.Y(), errRy);
421 
422  fmin->SetFixedVariable(4, "z0", posSeed.Z());
423  fmin->SetFixedVariable(5, "Az", dirSeed.Z());
424 
425  double scaling_factor(1e-4);
426  fmin->SetVariable(6, "al0x_a", 0.0, scaling_factor * fsigmaMSa);
427  fmin->SetVariable(7, "al0x_b", 0.0, scaling_factor * fsigmaMSb);
428  fmin->SetFixedVariable(8, "al1x_a", 0.0);
429  fmin->SetVariable(9, "al1x_b", 0.0, scaling_factor * fsigmaMSb);
430  fmin->SetFixedVariable(10, "al2x_a", 0.0);
431  fmin->SetVariable(11, "al2x_b", 0.0, scaling_factor * fsigmaMSb);
432  fmin->SetFixedVariable(12, "al3x_a", 0.0);
433  fmin->SetFixedVariable(13, "al3x_b", 0.0);
434 
435  fmin->SetVariable(14, "al0y_a", 0.0, scaling_factor * fsigmaMSa);
436  fmin->SetVariable(15, "al0y_b", 0.0, scaling_factor * fsigmaMSb);
437  fmin->SetFixedVariable(16, "al1y_a", 0.0);
438  fmin->SetVariable(17, "al1y_b", 0.0, scaling_factor * fsigmaMSb);
439  fmin->SetFixedVariable(18, "al2y_a", 0.0);
440  fmin->SetVariable(19, "al2y_b", 0.0, scaling_factor * fsigmaMSb);
441  fmin->SetFixedVariable(20, "al3y_a", 0.0);
442  fmin->SetFixedVariable(21, "al3y_b", 0.0);
443 
444  if (Npoint < 4) {
445  fmin->FixVariable(11);
446  fmin->FixVariable(19);
447  }
448 
449  fmin->Minimize();
450 
451  double recpres = 1e-7;
452 
453  if (fmin->Edm() > 1e2 * recpres) {
454  return 1e6;
455  }
456 
457  // get fit parameters
458  for (int i = 0; i < nparams; ++i) {
459  fitpar[i] = fmin->X()[i];
460  }
461 
462  for (size_t i = 0; i < 6; i++) {
463  for (size_t j = 0; j < 6; j++) {
464  (*covmatrix)(i, j) = fmin->CovMatrix(i, j);
465  }
466  }
467 
469  (*covmatrix)(4, 4) = (gr->GetErrorZ(0) * gr->GetErrorZ(0)) / 12.;
470 
471  fitpar[5] = sqrt(1 - fitpar[1] * fitpar[1] - fitpar[3] * fitpar[3]);
472  double dp5_dp1 = fitpar[1] / fitpar[5];
473  double dp5_dp3 = fitpar[3] / fitpar[5];
474  double errdz2 = pow(dp5_dp1, 2) * (*covmatrix)(1, 1) + pow(dp5_dp3, 2) * (*covmatrix)(3, 3)
475  + 2 * fabs(dp5_dp1 * dp5_dp3 * (*covmatrix)(1, 3));
476  (*covmatrix)(5, 5) = errdz2;
478 
479  Double_t chi2 = fmin->MinValue() / (2. * Npoint - 4);
480 
481  if (fVerbose > 2) {
482  cout << " chi2 = " << chi2 << endl;
483  cout << "[AFTER FIT] start.point: (" << fitpar[0] << ", " << fitpar[2] << ", " << fitpar[4] << ")"
484  << endl;
485  cout << "[AFTER FIT] dir: (" << fitpar[1] << ", " << fitpar[3] << ", " << fitpar[5] << ")"
486  << " sqrt(p1^2+p3^2+p5^2) = "
487  << sqrt(fitpar[1] * fitpar[1] + fitpar[3] * fitpar[3] + fitpar[5] * fitpar[5]) << endl;
488  }
490 
491  return chi2;
492 }
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 370 of file PndLmdLinFitTask.cxx.

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

Referenced by Init().

370  {
371  // Calculation of ThetaMS -------------------------------------
372  // Charge & mass of particle
373  // Int_t PDGCode = -2212; //barp //[R.K. 01/2017] unused variable
374  Double_t fMass = 0.938272046;
375  Double_t Ebeam = TMath::Hypot(fPbeam, fMass);
376  TLorentzVector LorMom(0, 0, fPbeam, Ebeam);
377  Double_t beta = LorMom.Beta();
378  Double_t X_to_X0 = radLen;
379  Double_t thetaMS = 13.6 * 1e-3 * TMath::Sqrt(X_to_X0) * (1 + 0.038 * TMath::Log(X_to_X0))
380  / (beta * fPbeam);
381  return thetaMS;
382 }
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: