FairRoot/PandaRoot
PndTrkLegendreSecTask2.cxx
Go to the documentation of this file.
1 //
3 // PndTrkLegendreSecTask2
4 //
5 // Class for secondary track pattern recognition
6 //
7 // authors: Lia Lavezzi - INFN Pavia (2012)
8 //
10 
11 #include "PndTrkLegendreSecTask2.h"
12 
13 // stt
14 #include "PndSttHit.h"
15 #include "PndSttTube.h"
16 #include "PndSttMapCreator.h"
17 // sds
18 #include "PndSdsHit.h"
19 // track(cand)
20 #include "PndTrackCand.h"
21 #include "PndTrackCandHit.h"
22 #include "PndTrack.h"
23 
24 #include "PndTrkConformalHit.h"
25 #include "PndTrkConformalHitList.h"
27 #include "PndTrkTools.h"
28 #include "PndTrkSkewHit.h"
29 #include "PndTrkFitter.h"
30 // fairroot
31 #include "FairRootManager.h"
32 #include "FairRunAna.h"
33 #include "FairRuntimeDb.h"
34 // ROOT
35 #include "TClonesArray.h"
36 #include "TVector3.h"
37 #include "TArc.h"
38 #include "TLine.h"
39 #include "TMarker.h"
40 #include "TSpectrum2.h"
41 #include "TSpectrum.h"
42 #include "TStopwatch.h"
43 // tracking
44 #include "PndTrkClusterList.h"
45 #include "PndTrkGlpkFits.h"
46 #include "PndTrkClean.h"
47 
48 #include <iostream>
49 
50 using namespace std;
51 
52 
53 // ----- Default constructor -------------------------------------------
54 PndTrkLegendreSecTask2::PndTrkLegendreSecTask2() : FairTask("secondary track finder", 0), fDisplayOn(kFALSE), fPersistence(kTRUE), fUseMVDPix(kTRUE), fUseMVDStr(kTRUE), fUseSTT(kTRUE), fSecondary(kFALSE), fMvdPix_RealDistLimit(1000), fMvdStr_RealDistLimit(1000), fStt_RealDistLimit(1000), fMvdPix_ConfDistLimit(1000), fMvdStr_ConfDistLimit(1000), fStt_ConfDistLimit(1000), fInitDone(kFALSE) {
55  sprintf(fSttBranch,"STTHit");
56  sprintf(fMvdPixelBranch,"MVDHitsPixel");
57  sprintf(fMvdStripBranch,"MVDHitsStrip");
59 }
60 
61 PndTrkLegendreSecTask2::PndTrkLegendreSecTask2(int verbose) : FairTask("secondary track finder", verbose), fDisplayOn(kFALSE), fPersistence(kTRUE), fUseMVDPix(kTRUE), fUseMVDStr(kTRUE), fUseSTT(kTRUE), fSecondary(kFALSE), fMvdPix_RealDistLimit(1000), fMvdStr_RealDistLimit(1000), fStt_RealDistLimit(1000), fMvdPix_ConfDistLimit(1000), fMvdStr_ConfDistLimit(1000), fStt_ConfDistLimit(1000), fInitDone(kFALSE) {
62  sprintf(fSttBranch,"STTHit");
63  sprintf(fMvdPixelBranch,"MVDHitsPixel");
64  sprintf(fMvdStripBranch,"MVDHitsStrip");
66 }
67 
68 // -------------------------------------------------------------------------
69 
70 // ----- Destructor ----------------------------------------------------
72 
73 }
74 // -------------------------------------------------------------------------
75 
76 
77 
78 // ----- Public method Init --------------------------------------------
80 
81  fEventCounter = 0;
82 
83  fMvdPix_RealDistLimit = 0.5; // CHECK limits
84  fMvdStr_RealDistLimit = 0.5; // CHECK limits
85  fStt_RealDistLimit = 1.5 * 0.5; // CHECK limits
86  fMvdPix_ConfDistLimit = 0.003; // CHECK limits
87  fMvdStr_ConfDistLimit = 0.003; // CHECK limits
88  fStt_ConfDistLimit = 0.001; // CHECK limits
89  if(fSecondary) {
90  fMvdPix_RealDistLimit = 1.; // CHECK limits
91  fMvdStr_RealDistLimit = 1.; // CHECK limits
92  fMvdPix_ConfDistLimit = 0.007; // CHECK limits
93  fMvdStr_ConfDistLimit = 0.007; // CHECK limits
94  }
95 
96 
97  // Get RootManager
98  FairRootManager* ioman = FairRootManager::Instance();
99  if ( ! ioman ) {
100  cout << "-E- PndTrkLegendreSecTask2::Init: "
101  << "RootManager not instantiated, return!" << endl;
102  return kFATAL;
103  }
104 
105  // -- HITS -------------------------------------------------
106  //
107  // STT
108  fSttHitArray = (TClonesArray*) ioman->GetObject(fSttBranch);
109  if ( ! fSttHitArray ) {
110  cout << "-W- PndTrkLegendreSecTask2::Init: "
111  << "No STTHit array, return!" << endl;
112  return kERROR;
113  }
114  //
115  // MVD PIXEL
116  fMvdPixelHitArray = (TClonesArray*) ioman->GetObject(fMvdPixelBranch);
117  if ( !fMvdPixelHitArray){
118  std::cout << "-W- PndTrkLegendreSecTask2::Init: " << "No MVD Pixel hitArray, return!" << std::endl;
119  return kERROR;
120  }
121  //
122  // MVD STRIP
123  fMvdStripHitArray = (TClonesArray*) ioman->GetObject(fMvdStripBranch);
124  if ( !fMvdStripHitArray){
125  std::cout << "-W- PndTrkLegendreSecTask2::Init: " << "No MVD Strip hitArray, return!" << std::endl;
126  return kERROR;
127  }
128 
129  fTrackArray = new TClonesArray("PndTrack");
130  fTrackCandArray = new TClonesArray("PndTrackCand");
131  ioman->Register("Track", "pr", fTrackArray, fPersistence); // CHECK
132  ioman->Register("TrackCand", "pr", fTrackCandArray, fPersistence); // CHECK
133 
134 
135  // ---------------------------------------- maps of STT tubes
138  // ---------------------------------------------------- end map
139 
140  if(fDisplayOn) {
141  display = new TCanvas("display", "display", 0, 0, 800, 800); // CHECK
142  display->Divide(2, 2);
143  }
144 
146  if(fSecondary) legendre->SetUpLegendreHisto(90, 0, 180, 1000, -1.5, 1.5); // CHECK
149 
151 
152  tools = new PndTrkTools();
154 
155  return kSUCCESS;
156 
157 }
158 
159 // -------------------------------------------------------------------------
160 
162  FairRuntimeDb* rtdb = FairRunAna::Instance()->GetRuntimeDb();
163  fSttParameters = (PndGeoSttPar*) rtdb->getContainer("PndGeoSttPar");
164 }
165 
166 // -------------------------------------------------------------------------
167 
168 
170 
174 
175  if(fUseSTT) {
176  stthitlist->AddTCA(FairRootManager::Instance()->GetBranchId(fSttBranch), fSttHitArray);
178  }
179 
180  if(fUseMVDPix) {
181  mvdpixhitlist->AddTCA(FairRootManager::Instance()->GetBranchId(fMvdPixelBranch), fMvdPixelHitArray);
183  }
184 
185  if(fUseMVDStr) {
186  mvdstrhitlist->AddTCA(FairRootManager::Instance()->GetBranchId(fMvdStripBranch), fMvdStripHitArray);
188  }
189 
190  // conformalhitlist = new PndTrkConformalHitList();
191  fFoundPeaks.clear();
192 
193  fInitDone = kTRUE;
194  // stthitlist->PrintSectors();
195 }
196 
197 
198 // void PndTrkLegendreSecTask2::Reset()
199 // {
200 
201 // if(fDisplayOn) {
202 // char goOnChar;
203 // display->Update();
204 // display->Modified();
205 // cout << "Finish? ";
206 // cin >> goOnChar;
207 // cout << "FINISH" << endl;
208 // }
209 
210 // if(fInitDone) {
211 // if(stthitlist) delete stthitlist;
212 // if(mvdpixhitlist) delete mvdpixhitlist;
213 // if(mvdstrhitlist) delete mvdstrhitlist;
214 // if(fTimer) {
215 // fTimer->Stop();
216 // fTime += fTimer->RealTime();
217 
218 // if(fVerbose > 0) cerr << fEventCounter << " Real time " << fTime << " s" << endl;
219 // }
220 // }
221 
222 // fInitDone = kFALSE;
223 // }
224 
226  fTrackArray->Delete();
227  fTrackCandArray->Delete();
228  if(fVerbose > 0) cout << "*********************** " << fEventCounter << " ***********************" << endl;
229 
230  fEventCounter++;
231  // CHECK THIS!
232  if(fSttHitArray->GetEntriesFast() < 3) {
233  // Reset();
234  return;
235  }
236 
237  Initialize();
238  if(fVerbose > 1) {
239  cout << "number of stt hits " << fSttHitArray->GetEntriesFast() << endl;
240  cout << "number of mvdpix hits " << fMvdPixelHitArray->GetEntriesFast() << endl;
241  cout << "number of mvdstr hits " << fMvdStripHitArray->GetEntriesFast() << endl;
242  }
243 
244 
245  // **************** CHECK **************
246  // for(int isec = 0; isec < 6; isec++) {
247  // if(stthitlist->GetNofHitsInSector(isec) == 0) continue;
248  // conformalhitlist = new PndTrkConformalHitList();
249  // if(fDisplayOn) {
250  // Refresh();
251  // char goOnChar;
252  // // cout << "Start?";
253  // // cin >> goOnChar;
254  // display->Update();
255  // display->Modified();
256  // cout << " STARTING" << endl;
257  // cin >> goOnChar;
258  // stthitlist->DrawSector(isec, kGreen);
259  // stthitlist->PrintSector(isec);
260  // display->Update();
261  // display->Modified();
262  // cout << " STARTING" << endl;
263  // cin >> goOnChar;
264  // }
265 
266 
267  // std::vector< PndTrkHit* > sttinsec = stthitlist->GetHitListFromSector(isec);
268 
269 
270  // }
271 
272  // for(int ilay = 0; ilay < 26; ilay++) {
273  // if(stthitlist->GetNofHitsInLayer(ilay) == 0) continue;
274  // conformalhitlist = new PndTrkConformalHitList();
275  // if(fDisplayOn) {
276  // Refresh();
277  // char goOnChar;
278  // // cout << "Start?";
279  // // cin >> goOnChar;
280  // display->Update();
281  // display->Modified();
282  // cout << " STARTING" << endl;
283  // cin >> goOnChar;
284  // stthitlist->DrawLayer(ilay, kGreen);
285  // stthitlist->PrintLayer(ilay);
286  // display->Update();
287  // display->Modified();
288  // cout << " STARTING" << endl;
289  // cin >> goOnChar;
290  // }
291 
292 
293  // std::vector< PndTrkHit* > sttinlay = stthitlist->GetHitListFromLayer(ilay);
294 
295 
296  // }
297 
298  // for(int isec = 0; isec < 6; isec++) {
299 
300  // for(int ilay = 0; ilay < 26; ilay++) {
301  // if(stthitlist->GetNofHitsInSectorAndLayer(isec, ilay) == 0) continue;
302  // conformalhitlist = new PndTrkConformalHitList();
303  // if(fDisplayOn) {
304  // Refresh();
305  // char goOnChar;
306  // cout << "Start?";
307  // cin >> goOnChar;
308  // display->Update();
309  // display->Modified();
310  // cout << " STARTING" << endl;
311  // cin >> goOnChar;
312  // stthitlist->DrawSectorAndLayer(isec, ilay, kGreen);
313  // stthitlist->PrintSectorAndLayer(isec, ilay);
314  // display->Update();
315  // display->Modified();
316  // cout << " STARTING" << endl;
317  // cin >> goOnChar;
318  // }
319 
320 
321  // std::vector< PndTrkHit* > sttinlay = stthitlist->GetHitListFromSectorAndLayer(isec, ilay);
322 
323 
324  // }
325  // }
326  // ********************************************
327 
328  PndTrkClusterList clusterlist;
329  PndTrkCluster *cluster = NULL;
330 
331  // for(int isec = 0; isec < 6; isec++) {
332  // cout << "@@@@@@@@@@@@@@@@@ SECTOR " << isec << endl;
333 
334  // std::vector< PndTrkHit* > sttinsec = stthitlist->GetHitListFromSector(isec);
335 
336 
337  {
338  std::vector< PndTrkHit* > sttinsec = stthitlist->GetHitList();
339 
340 
341  // int toassigncounter = sttinsec.size();
342  Bool_t stilltoassign = kTRUE;
343  // while(toassigncounter > 0) {
344  while(stilltoassign == kTRUE) {
345 
346  if(fDisplayOn) {
347  Refresh();
348  char goOnChar;
349  display->Update();
350  display->Modified();
351  cout << " STARTING" << endl;
352  cin >> goOnChar;
353  display->Update();
354  display->Modified();
355  }
356 
357 
358 
359  cluster = new PndTrkCluster();
360  PndTrkHit *tmphit = NULL;
361 
362  for(int ilay = 0; ilay < 26; ilay++) {
363 // std::vector< PndTrkHit* > sttinlay = stthitlist->GetHitListFromSectorAndLayer(isec, ilay);
364  std::vector< PndTrkHit* > sttinlay = stthitlist->GetHitListFromLayer(ilay);
365 
366  for(int ihit = 0; ihit < sttinlay.size(); ihit++) {
367  PndTrkHit *thishit = sttinlay.at(ihit);
368  if(thishit->IsUsed() == kTRUE) continue;
369  // cout << "1TMPHIT " << tmphit << endl;
370  // if(tmphit) cout << " " << tmphit->GetHitID () << endl;
371  if(tmphit == NULL) {
372  tmphit = thishit;
373  // toassigncounter--;
374  cluster->AddHit(thishit);
375  // cout << " start add " << thishit->GetHitID() << endl;
376  thishit->SetUsedFlag(kTRUE);
377  // cout << "2TMPHIT " << tmphit << endl;
378  continue;
379  }
380  // .........
381 
382  PndSttTube *tmptube = (PndSttTube*) fTubeArray->At(tmphit->GetTubeID());
383 
384  if(tmptube->IsNeighboring(thishit->GetTubeID())) {
385  cluster->AddHit(sttinlay.at(ihit));
386  tmphit = thishit;
387  thishit->SetUsedFlag(kTRUE);
388  // cout << " add " << thishit->GetHitID() << endl;
389  // toassigncounter--;
390  }
391  // else cout << "not " << thishit->GetHitID () << endl;
392  }
393  }
394 
395  tmphit = NULL;
396  if(cluster->GetNofHits() > 3) clusterlist.AddCluster(cluster);
397  else {
398  // check if there is something more to assign
399  stilltoassign = CheckAssignability(sttinsec);
400  continue;
401  }
402 
403  if(fDisplayOn) {
404  Refresh();
405  char goOnChar;
406  // cin >> goOnChar;
407  cout << "ADD CLUSTER " << cluster->GetNofHits() << endl;
408 
409  cluster->LightUp();
410  display->Update();
411  display->Modified();
412  }
413 
414 
415  // cout << "clusterlist.size " << clusterlist.GetNofClusters() << endl;
416  // if(fDisplayOn) {
417  // Refresh();
418  // char goOnChar;
419  // cout << "Start?";
420  // cin >> goOnChar;
421  // cout << "ADD CLUSTER " << cluster->GetNofHits() << endl;
422 
423  // stthitlist->DrawSector(isec, kGreen);
424  // stthitlist->PrintSector(isec);
425  // cluster->LightUp();
426  // display->Update();
427  // display->Modified();
428  // cout << " NEXT" << endl;
429  // cin >> goOnChar;
430  // }
431 
432 
433  // ================ --> TO CONFORMAL PLANE
434 
436 
437  // translation and rotation
438  Int_t nchits = 0;
439  Double_t delta = 0, trasl[2] = {0., 0.};
440  if(fSecondary) {
441  // translation and rotation - CHECK
442  // cout << " REFERENCE HIT " << cluster->GetNofHits() << endl;
443  fRefHit = FindReferenceHit(cluster);
444  if(fRefHit == NULL) {
445  // cout << "REFHIT " << fRefHit << endl;
446  Reset();
447  return;
448  }
449  ComputeTraAndRot(fRefHit, delta, trasl);
450  }
451  // cout << "DELTA " << delta << " TRASL " << trasl[0] << " " << trasl[1] << endl;
452  conform->SetOrigin(trasl[0], trasl[1], delta);
453  nchits = FillConformalHitList();
454 
455 
456  if(nchits == 0) {
457  Reset();
458  return;
459  }
460 
461 
462  // APPLY LEGENDRE TO STT ALONE
463  // -------------------------------------------------------
464  // cout << "APPLY LEGENDRE =======================" << endl;
465  double theta_max, r_max;
466  Int_t maxpeak = ApplyLegendre(cluster, theta_max, r_max);
467  if(maxpeak <= 3) {
468  // check if there is something more to assign
469  stilltoassign = CheckAssignability(sttinsec);
470 
471  continue; // break;
472  }
473 
474  // cout << "EXTRACT MAX =======================" << endl;
475 
476  double fitm, fitq;
478  if(fDisplayOn) {
479  display->cd(2);
480  TLine *line = new TLine(-10.07, fitq + fitm * (-10.07), 10.07, fitq + fitm * (10.07));
481  line->Draw("SAME");
482 
483  display->Update();
484  display->Modified();
485  }
486 
487  // center and radius
488  Double_t xc, yc, R;
489  FromConformalToRealTrack(fitm, fitq, xc, yc, R);
490  // if(fVerbose > 1) cout << "XR, YC, R: " << xc << " " << yc << " " << R << endl;
491  PndTrkTrack *track = new PndTrkTrack(cluster, xc, yc, R);
492  if(fDisplayOn) {
493  display->cd(1);
494  track->Draw(kRed);
495  display->Update();
496  display->Modified();
497  char goOnChar;
498  cout << "waiting 3 " << endl;
499  cin >> goOnChar;
500  }
501 
502 
503  // ADD HITS TO CLUSTER: PIXEL, STRIP AND STT PARALLEL
504  // -------------------------------------------------------
505  // method of hit-to-track association:
506  // 0 conformal: mvd and stt in conformal plane
507  // 1 real: mvd and stt in real plane
508  // 2 mixed: mvd in real/stt in conformal plane
509  int method = 1;
510  // PndTrkCluster thiscluster = CreateClusterByDistance(method, fitm, fitq);
511  // cluster = &thiscluster;
512  int counteradded = AddHitToClusterByDistance(cluster, method, fitm, fitq);
513 
514  // CLEANUP
515  // -------------------------------------------------------
516  PndTrkCluster thiscluster = Cleanup(*cluster);
517  cluster = &thiscluster;
518 
519  double fitm2, fitq2;
520  fFitter->Reset();
521 
522  for(int ihit = 0; ihit < cluster->GetNofHits(); ihit++)
523  {
524  PndTrkHit *hit = cluster->GetHit(ihit);
525  // if(!hit) cout << "MISSING" << endl;
526  // else cout << "IHIT " << ihit << " is here " << endl;
527  double conformal[3];
528  // cout << "hit " << hit->GetHitID() << " detid " << hit->GetDetectorID () << endl;
529  PndTrkConformalHit *chit = NULL;
530  if(hit->IsSttSkew()) continue;
531  else if(hit->IsSttParallel() == kTRUE) chit = conform->GetConformalSttHit(hit);
532  else chit = conform->GetConformalHit(hit);
533 
534  double xi1 = chit->GetU() + fitm * chit->GetIsochrone()/ TMath::Sqrt(fitm * fitm + 1);
535  double yi1 = chit->GetV() - chit->GetIsochrone() / TMath::Sqrt(fitm * fitm + 1);
536 
537  double xi2 = chit->GetU() - fitm * chit->GetIsochrone() / TMath::Sqrt(fitm * fitm + 1);
538  double yi2 = chit->GetV() + chit->GetIsochrone()/ TMath::Sqrt(fitm * fitm + 1);
539 
540  double xi = 0, yi = 0;
541 
542  fabs(yi1 - (fitm * xi1 + fitq)) < fabs(yi2 - (fitm * xi2 + fitq)) ? (yi = yi1, xi = xi1) : (yi = yi2, xi = xi2);
543 
544  double sigma = chit->GetIsochrone();
545  fFitter->SetPointToFit(xi, yi, sigma);
546 
547  if(fDisplayOn) {
548  display->cd(2);
549  TMarker *mrk = new TMarker(xi, yi, 6);
550  mrk->Draw("SAME");
551  }
552  }
553 
554  fFitter->StraightLineFit(fitm2, fitq2);
555 
556  FromConformalToRealTrack(fitm2, fitq2, xc, yc, R);
557  // if(fVerbose > 1)
558  if(fVerbose > 1) cout << "FITTER XR, YC, R: " << xc << " " << yc << " " << R << endl;
559  track->SetRadius(R);
560  track->SetCenter(xc, yc);
561 
562  if(fDisplayOn) {
563  char goOnChar;
564  display->cd(2);
565  TLine *line = new TLine(-0.07, fitq + fitm * (-0.07), 0.07, fitq + fitm * (0.07));
566  line->Draw("SAME");
567  TLine *line2 = new TLine(-0.07, fitq2 + fitm2 * (-0.07), 0.07, fitq2 + fitm2 * (0.07));
568  line2->SetLineColor(2);
569  line2->Draw("SAME");
570 
571 
572  display->cd(1);
573  track->Draw(kGreen);
574 
575  display->Update();
576  display->Modified();
577  cin >> goOnChar;
578  }
579 
580 
581  fitm = fitm2;
582  fitq = fitq2;
583 
584  // check if there is something more to assign
585  stilltoassign = CheckAssignability(sttinsec);
586 
587 
588  // cout << "still to assing " << stilltoassign << endl;
589 
590  // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
591  // SKEWED ASSOCIATION ********* CHECK *********
592  // -------------------------------------------------------
593  if(fVerbose > 1) cout << "%%%%%%%%%%%%%%%%%%%% ZFINDER %%%%%%%%%%%%%%%%%%%%%%%%%%" << endl;
594 
595  if(fDisplayOn) {
596  RefreshZ();
597  DrawZGeometry(2);
598  }
599 
600 // PndTrkCluster skewhitlist;
601 // for(int ihit = 0; ihit < cluster->GetNofHits(); ihit++) {
602 // PndTrkHit *hit = (PndTrkHit*) cluster->GetHit(ihit);
603 // if(hit->IsSttSkew() == kTRUE) skewhitlist.AddHit(hit);
604 // }
605 
606  PndTrkCluster skewhitlist = CreateSkewHitList(track);
607  skewhitlist = CleanUpSkewHitList(&skewhitlist);
608 
609 
610 // for(int ihit = 0; ihit < skewhitlist.GetNofHits(); ihit++) {
611 // PndTrkSkewHit *skewhit = (PndTrkSkewHit*) skewhitlist.GetHit(ihit);
612 // cout << "SKEWED " << ihit << endl;
613 // skewhit->GetPosition().Print();
614 // }
615 
616 
617  int iz = -1, jz = -1;
618  // cout << "##################### CHOOSE Z" << endl;
619 
620  // 7. select which intersection is the most likely and add it to z fitting
621  fFitter->Reset();
622  for(int ihit = 0; ihit < skewhitlist.GetNofHits() - 1; ihit++) {
623  PndTrkSkewHit *skewhit1 = (PndTrkSkewHit*) skewhitlist.GetHit(ihit);
624  if(!skewhit1) continue;
625  TVector3 fin_intersection1[2] = {skewhit1->GetIntersection1(), skewhit1->GetIntersection2()};
626  double phi1[2] = {skewhit1->GetPhi1(), skewhit1->GetPhi2()};
627 
628  int jhit = ihit + 1;
629  PndTrkSkewHit *skewhit2 = (PndTrkSkewHit*) skewhitlist.GetHit(jhit);
630  if(!skewhit2) continue;
631  TVector3 fin_intersection2[2] = {skewhit2->GetIntersection1(), skewhit2->GetIntersection2()};
632  double phi2[2] = {skewhit2->GetPhi1(), skewhit2->GetPhi2()};
633 
634  // cout << "start from " << ihit << " " << jhit << ": " << iz << " " << jz << endl;
635  if(jz != -1) {
636  iz = jz;
637  double distance = fabs(fin_intersection1[iz].Z() - fin_intersection2[0].Z());
638  jz = 0;
639  // 11 22
640  fabs(fin_intersection1[iz].Z() - fin_intersection2[1].Z()) < distance ? (distance = fabs(fin_intersection1[iz].Z() - fin_intersection2[1].Z()), jz = 1) : distance;
641  }
642  else {
643  // 11 21
644  double distance = fabs(fin_intersection1[0].Z() - fin_intersection2[0].Z());
645  iz = 0;
646  jz = 0;
647  // 11 22
648  fabs(fin_intersection1[0].Z() - fin_intersection2[1].Z()) < distance ? (distance = fabs(fin_intersection1[0].Z() - fin_intersection2[1].Z()), iz = 0, jz = 1 ): distance;
649  // 12 21
650  fabs(fin_intersection1[1].Z() - fin_intersection2[0].Z()) < distance ? (distance = fabs(fin_intersection1[1].Z() - fin_intersection2[0].Z()), iz = 1, jz = 0) : distance;
651  // 12 22
652  fabs(fin_intersection1[1].Z() - fin_intersection2[1].Z()) < distance ? (distance = fabs(fin_intersection1[1].Z() - fin_intersection2[1].Z()), iz = 1, jz = 1): distance;
653  }
654  // cout << "end with " << ihit << " " << jhit << ": " << iz << " " << jz << endl;
655 
656  fFitter->SetPointToFit(phi1[iz], fin_intersection1[iz].Z(), 1.);// (fin_intersection1[0].Z() + fin_intersection1[1].Z())/2.); // CHECK sigma?
657 
658  // CHECK
659  // cout << "SKEWED " << ihit << endl;
660  // skewhit1->GetPosition().Print();
661 // skewhit1->GetIntersection1().Print();
662 // skewhit1->GetIntersection2().Print();
663 
664  if(iz == 0) skewhit1->SetPosition(skewhit1->GetIntersection1());
665  else skewhit1->SetPosition(skewhit1->GetIntersection2());
666 // skewhit1->GetPosition().Print();
667 
668  // CHECK last point?
669  if(ihit == skewhitlist.GetNofHits() - 2) {
670  fFitter->SetPointToFit(phi2[jz], fin_intersection2[jz].Z(), 1.);// (fin_intersection2[0].Z() + fin_intersection2[1].Z())/2.); // CHECK sigma?
671 
672  // CHECK
673  if(jz == 0) skewhit2->SetPosition(skewhit2->GetIntersection1());
674  else skewhit2->SetPosition(skewhit2->GetIntersection2());
675  }
676 
677 
678  if(fDisplayOn) {
679  char goOnChar;
680  display->cd(4);
681  TMarker *mrkfoundzphi1 = new TMarker(phi1[iz], fin_intersection1[iz].Z(), 20);
682  mrkfoundzphi1->SetMarkerColor(kYellow);
683  mrkfoundzphi1->Draw("SAME");
684 
685  TMarker *mrkfoundzphi2 = new TMarker(phi2[jz], fin_intersection2[jz].Z(), 20);
686  mrkfoundzphi2->SetMarkerColor(kYellow);
687  mrkfoundzphi2->Draw("SAME");
688 
689  display->Update();
690  display->Modified();
691  //
692  // cin >> goOnChar;
693  }
694  }
695 
696 
697  // ADD MVD POINTS ==================== RECHECK
698  PndTrkCluster *mvdcluster = track->GetCluster();
699  for(int ihit = 0; ihit < mvdcluster->GetNofHits(); ihit++) {
700  // cout << ihit << " TROVATO " << endl;
701  PndTrkHit *hit = mvdcluster->GetHit(ihit);
702  if(hit->GetDetectorID() != FairRootManager::Instance()->GetBranchId(fMvdPixelBranch) && hit->GetDetectorID() != FairRootManager::Instance()->GetBranchId(fMvdStripBranch)) continue;
703  TVector3 position = hit->GetPosition();
704  double phi = track->ComputePhi(position);
705  hit->SetPhi(phi);
706  // cout << ihit << " TROVATO " << phi << " " << position.Z() << endl;
707 
708  if(fDisplayOn) {
709  char goOnChar;
710  display->cd(4);
711  TMarker *mrkfoundzphi = new TMarker(phi, position.Z(), 21);
712  mrkfoundzphi->SetMarkerColor(kOrange);
713  mrkfoundzphi->Draw("SAME");
714  display->Update();
715  display->Modified();
716  // cin >> goOnChar;
717  }
718  fFitter->SetPointToFit(phi, position.Z(), 0.1); // CHECK ERROR
719  }
720  // ===================================
721 
722 
723  Double_t ml, pl;
724  Bool_t straightlinefit = fFitter->StraightLineFit(ml, pl);
725 
726 
727  // CHECK the following fit: if it fails, put the hits into play again?
728  if(straightlinefit = kTRUE) {
729 
730  if(fDisplayOn) {
731  char goOnChar;
732  display->cd(4);
733  TLine *l222 = new TLine(-1000, -1000 * ml + pl, 1000, 1000 * ml + pl);
734  l222->Draw("SAME");
735  display->cd(3);
736  l222->Draw("SAME");
737  display->Update();
738  display->Modified();
739  //
740  // cin >> goOnChar;
741  }
742 
743  PndTrkCluster *trkcluster = track->GetCluster();
744  for(int ihit = 0; ihit < trkcluster->GetNofHits(); ihit++) {
745  PndTrkHit *hit = trkcluster->GetHit(ihit);
746  // cout << "cluster ihit " << ihit << " " << hit->GetDetectorID() << " " << hit->GetHitID() << endl;
747  }
748 
749  // 8. last association z --> HIT: fill position and add to cluster ???? CHECK
750  for(int ihit = 0; ihit < skewhitlist.GetNofHits(); ihit++) {
751  PndTrkSkewHit *skewhit = (PndTrkSkewHit*) skewhitlist.GetHit(ihit);
752 
753  // cout << "ihit " << ihit << " " << skewhit->GetHitID() << " is already there? " << trkcluster->DoesContain(skewhit) << endl;
754  if(trkcluster->DoesContain(skewhit) == kTRUE) {
755  trkcluster->Replace(skewhit);
756  }
757  else trkcluster->AddHit(skewhit);
758  TVector3 intersection1 = skewhit->GetIntersection1();
759  double phi1 = track->ComputePhi(intersection1);
760  double calcz1 = ml * phi1 + pl;
761  TVector3 intersection2 = skewhit->GetIntersection2();
762  double phi2 = track->ComputePhi(intersection2);
763  double calcz2 = ml * phi2 + pl;
764 
765  fabs(intersection1.Z() - calcz1) < fabs(intersection2.Z() - calcz2) ? skewhit->SetPosition(intersection1) : skewhit->SetPosition(intersection2);
766  }
767 
768 
769  // 9. add skewedhitlist to cluster of the track
770  // fill the last two (missing) parameters
771 
772  for(int ihit = 0; ihit < trkcluster->GetNofHits(); ihit++) {
773  PndTrkHit *hit = trkcluster->GetHit(ihit);
774  double phi = track->ComputePhi(hit->GetPosition()); // CHECK is it neede to recalculate it?
775  // cout << "hit get pos " << endl;
776  //
777  // if(hit->IsSttSkew()) cout << "getp pos " << ihit << " " << hit->GetDetectorID() << " " << hit->GetHitID() << " " << hit->GetPosition().X() << " " << hit->GetPosition().Y() << " " << hit->GetPosition().Z() << endl;
778 
779  hit->SetSortVariable(phi);
780  hit->SetPhi(phi);
781 
782  }
783  trkcluster->Sort();
784  track->ComputeCharge();
785 
786  // 10. z-phi refit
787  Bool_t zfit = ZPhiFit(0, trkcluster, ml, pl);
788  // cout << "zfit1 on " << trkcluster->GetNofHits() << " hits/ " << zfit << " " << ml << " " << pl << " tanl " << - track->GetCharge() * ml * (180./TMath::Pi())/R << endl;
789 
790  PndTrkCluster *tmpcluster = CleanupZPhiFit(trkcluster, ml, pl);
791  trkcluster = tmpcluster;
792 
793  if(fDisplayOn) {
794  char goOnChar;
795  display->cd(4);
796  DrawZGeometry();
797  hzphi->SetXTitle("#phi");
798  hzphi->SetYTitle("#z");
799  hzphi->Draw();
800  display->Update();
801  display->Modified();
802  }
803 
804  zfit = ZPhiFit(1, trkcluster, ml, pl);
805 
806  // 11. fill the last two (missing) parameters
807 
808  // tanl = -q ml (180/pi) /R: See PndTrkTrack.h for an explanation
809 
810  if(zfit) {
811  track->SetTanL(- track->GetCharge() * ml * (180./TMath::Pi())/R);
812  track->SetZ0(pl);
813  }
814  else { // CHECK put these in default
815  track->SetTanL(-999);
816  track->SetZ0(-999);
817  }
818  // cout << "GET TANL " << ml << " " << R << " " << track->GetTanL() << endl;
819 
820  // test -------------------------------------------------------
821  PndTrkCluster *trkcluster2 = track->GetCluster();
822  // trkcluster2->Print();
823 
824  if(fDisplayOn) {
825  char goOnChar;
826  display->cd(1);
827  Refresh();
828  for(int ihit = 0; ihit < trkcluster2->GetNofHits(); ihit++) {
829  PndTrkHit *hit = trkcluster2->GetHit(ihit);
830  hit->Draw(kMagenta);
831 
832  display->Update();
833  display->Modified();
834  // cin >> goOnChar;
835  }
836  }
837  }
838  else { // CHECK put these in default
839  track->SetTanL(-999);
840  track->SetZ0(-999);
841  }
842  // ------------------------------------------------------- end test
843 
844  // TRANSFORM TO PNDTRACK AND PNDTRACKCAND
845  // -------------------------------------------------------
846  RegisterTrack(track);
847  }
848 
849  // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
850 
851  }
852 
853 
854  cluster = NULL;
855  delete cluster;
856 
857  if(fDisplayOn) {
858  char goOnChar;
859  display->Update();
860  display->Modified();
861  cout << "Finish? ";
862  cin >> goOnChar;
863  cout << "FINISH" << endl;
864  }
865  // if(fDisplayOn) {
866 
867  // for(int iclus = 0; iclus < clusterlist.GetNofClusters(); iclus++) {
868 
869  // cluster = clusterlist.GetCluster(iclus);
870  // Refresh();
871  // char goOnChar;
872  // cout << "...Start?";
873  // cin >> goOnChar;
874  // cout << "ADD CLUSTER " << cluster->GetNofHits() << endl;
875 
876  // cluster->LightUp();
877  // display->Update();
878  // display->Modified();
879  // cout << " NEXT" << endl;
880  // cin >> goOnChar;
881  // }
882  // }
883  Reset();
884 }
885 
886 Bool_t PndTrkLegendreSecTask2::CheckAssignability(std::vector< PndTrkHit *> hitlist) {
887 
888  for(int ihit = 0; ihit < hitlist.size(); ihit++) {
889  PndTrkHit* hit = hitlist.at(ihit);
890  if(hit->IsUsed() == kFALSE) return kTRUE;
891  }
892  return kFALSE;
893 }
894 
896 {
897 
898  if(fDisplayOn) {
899  char goOnChar;
900  display->Update();
901  display->Modified();
902  cout << "Finish? ";
903  cin >> goOnChar;
904  cout << "FINISH" << endl;
905  }
906 
907  if(fInitDone) {
908  if(stthitlist) delete stthitlist;
909  if(mvdpixhitlist) delete mvdpixhitlist;
910  if(mvdstrhitlist) delete mvdstrhitlist;
911  if(fTimer) {
912  fTimer->Stop();
913  fTime += fTimer->RealTime();
914 
915  if(fVerbose > 0) cerr << fEventCounter << " Real time " << fTime << " s" << endl;
916  }
917  }
918 
919  fInitDone = kFALSE;
920 }
921 // ============================================================================================
922 
924 
926 
927  // FILL ONCE FOR ALL THE CONFORMAL HIT LIST
928  for(int jhit = 0; jhit < mvdpixhitlist->GetNofHits(); jhit++) {
929  PndTrkHit *hit = mvdpixhitlist->GetHit(jhit);
930  if(hit == fRefHit) continue;
932  conformalhitlist->AddHit(chit);
933  }
934  for(int jhit = 0; jhit < mvdstrhitlist->GetNofHits(); jhit++) {
935  PndTrkHit *hit = mvdstrhitlist->GetHit(jhit);
936  if(hit == fRefHit) continue;
938  conformalhitlist->AddHit(chit);
939  }
940 
941  if(isec == -1) {
942  for(int jhit = 0; jhit < stthitlist->GetNofHits(); jhit++) {
943  PndTrkHit *hit = stthitlist->GetHit(jhit);
944  if(hit == fRefHit) continue;
945 
946  if(hit->IsSttSkew()) {
947  // continue;
949  conformalhitlist->AddHit(chit);
950  }
951  else {
953  conformalhitlist->AddHit(chit);
954  }
955  // PndTrkConformalHit * chit = conform->GetConformalSttHit(hit);
956  // conformalhitlist->AddHit(chit);
957  }
958  }
959  else {
960  for(int jhit = 0; jhit < stthitlist->GetNofHitsInSector(isec); jhit++) {
961  PndTrkHit *hit = stthitlist->GetHitFromSector(jhit, isec);
962  // cout << "fil conformal " << hit->GetHitID() << " " << hit->GetDetectorID() << endl;
963  if(hit->IsSttSkew()) {
964  // continue;
966  conformalhitlist->AddHit(chit);
967  }
968  else {
970  conformalhitlist->AddHit(chit);
971  }
972  // PndTrkConformalHit * chit = conform->GetConformalSttHit(hit);
973  // conformalhitlist->AddHit(chit);
974  }
975  }
976 
977 
978  return conformalhitlist->GetNofHits();
979 }
980 
981 
983 
985 
986  for(int jhit = 0; jhit < cluster->GetNofHits(); jhit++) {
987  PndTrkHit *hit = cluster->GetHit(jhit);
988  if(hit == fRefHit) continue;
989  PndTrkConformalHit * chit = NULL;
990  cout << "HIT " << hit->GetHitID() << " " << hit->IsSttParallel() << " " << hit->IsSttSkew() << endl;
991  if(hit->IsSttParallel() == kTRUE) chit = conform->GetConformalSttHit(hit);
992  else chit = conform->GetConformalHit(hit);
993  conformalhitlist->AddHit(chit);
994  cout << "CONFORMAL " << chit->GetU() << " " << chit->GetV() << " " << chit->GetIsochrone() << endl;
995 
996  }
997  return conformalhitlist->GetNofHits();
998 }
999 
1001 {
1002  // mode 0 STT alone
1003  // 1 STT + MVD
1004  for(int ihit = 0; ihit < conformalhitlist->GetNofHits(); ihit++) {
1006  // if(mode == 0 && chit->GetDetectorID() != FairRootManager::Instance()->GetBranchId(fSttBranch)) continue;
1007  PndTrkHit *hit = chit->GetHit();
1008  // if(hit->IsUsed()) continue;
1009  legendre->FillLegendreHisto(chit->GetU(), chit->GetV(), chit->GetIsochrone());
1010  if(fDisplayOn) {
1011  display->cd(2);
1012  // cout << "conformal hit " << chit->GetU() << " " << chit->GetV() << endl;
1013  DrawConfHit(chit->GetU(), chit->GetV(), chit->GetIsochrone());
1014  }
1015  }
1016 }
1017 
1019 {
1020  // ---------------------------------------------------------------
1021  // cout << "FILL LEGENDRE HISTO " << cluster->GetNofHits() << endl;
1022 
1023  for(int ihit = 0; ihit < conformalhitlist->GetNofHits(); ihit++) {
1025  PndTrkHit *hit = chit->GetHit();
1026  if(cluster->DoesContain(hit) == kFALSE) continue;
1027  legendre->FillLegendreHisto(chit->GetU(), chit->GetV(), chit->GetIsochrone());
1028  if(fDisplayOn) {
1029  DrawConfHit(chit->GetU(), chit->GetV(), chit->GetIsochrone());
1030  // cout << "conformal2: " << chit->GetU() << " " << chit->GetV() << " " << chit->GetIsochrone() << endl;
1031  }
1032  }
1033 }
1034 
1035 
1036 
1038 
1039  PndTrkCluster cluster;
1040  // ADD HIT IN CONFORMAL PLANE WITH DISTANCE CRITERION
1041  // cost x + sint y - r = 0 -> |cost x0 + sint y0 - r|
1042  // cout << "CONFORMALHITLIST " << conformalhitlist->GetNofHits() << endl;
1043  for(int ihit = 0; ihit < conformalhitlist->GetNofHits(); ihit++) {
1045  double dist = chit->GetDistanceFromTrack(fitm, fitq);
1046  int hitID = chit->GetHitID();
1047  int detID = chit->GetDetectorID();
1048 
1049  // CHECK limits
1050  double distlimit = 0;
1051  if(detID == FairRootManager::Instance()->GetBranchId(fMvdPixelBranch)) distlimit = 0.003;
1052  else if(detID == FairRootManager::Instance()->GetBranchId(fMvdStripBranch)) distlimit = 0.003;
1053  else if(detID == FairRootManager::Instance()->GetBranchId(fSttBranch)) {
1054  if(chit->GetIsochrone() > 1.e-4) distlimit = 6 * chit->GetIsochrone();
1055  else distlimit = 0.001;
1056  }
1057  // ---------------------------
1058  Bool_t accept = kFALSE;
1059 
1060 
1061  if(dist < distlimit) {
1062  if(fDisplayOn) {
1063  if(chit->GetIsochrone() > 0) {
1064  TArc *arc = new TArc(chit->GetU(), chit->GetV(), chit->GetIsochrone());
1065  arc->SetFillStyle(0);
1066  arc->SetLineColor(5);
1067  display->cd(2);
1068  arc->Draw("SAME");
1069  }
1070  else {
1071  TMarker *mrk;
1072  if(detID == FairRootManager::Instance()->GetBranchId(fMvdPixelBranch)) mrk = new TMarker(chit->GetU(), chit->GetV(), 21);
1073  else if(detID == FairRootManager::Instance()->GetBranchId(fMvdStripBranch)) mrk = new TMarker(chit->GetU(), chit->GetV(), 25);
1074  mrk->SetMarkerColor(5);
1075  display->cd(2);
1076  mrk->Draw("SAME");
1077  }
1078  }
1079 
1080  PndTrkHit *hit;
1081  if(detID == FairRootManager::Instance()->GetBranchId(fMvdPixelBranch)) {
1082  hit = mvdpixhitlist->GetHit(hitID);
1083  }
1084  else if(detID == FairRootManager::Instance()->GetBranchId(fMvdStripBranch)) {
1085  hit = mvdstrhitlist->GetHit(hitID);
1086  }
1087  else if(detID == FairRootManager::Instance()->GetBranchId(fSttBranch)) {
1088  hit = stthitlist->GetHit(hitID);
1089  }
1090 
1091  // ********** CHECK ***********
1092  // if you put "is used" the efficiency beecomes much lower!
1093  // DO NOT: if(!hit->IsUsed())
1094  cluster.AddHit(hit);
1095  accept = kTRUE;
1096 
1097  }
1098 
1099  // else cout << "DISCARDED " << hitID << " " << detID << " " << dist << " " << distlimit << endl;
1100  }
1101 
1102  return cluster;
1103 }
1104 
1106  // ADD HIT IN REAL PLANE WITH DISTANCE CRITERION
1107  // sqrt((xc - x)**2 + (yc - y)**2) < distlim
1108  PndTrkCluster cluster;
1109 
1110  // .........................................................
1111  if(fDisplayOn) {
1112  TArc *arc = new TArc(xc0, yc0, R0);
1113  arc->SetFillStyle(0);
1114  arc->SetLineColor(5);
1115  display->cd(1);
1116  arc->Draw("SAME");
1117  }
1118  for(int ihit = 0; ihit < stthitlist->GetNofHits(); ihit++) {
1119  PndTrkHit *hit = stthitlist->GetHit(ihit);
1120  if(hit->IsSttSkew()) continue;
1121  double dist = hit->GetXYDistanceFromTrack(xc0, yc0, R0);
1122  // cout << ihit << " dist " << dist << endl;
1123  // CHECK limits
1124  double distlimit = 1.5 * 0.5;
1125  if(dist < distlimit){
1126  // cout << "TRACK " << xc0 << " " << yc0 << " " << R0 << endl;
1127  // cout << "ADD HIT " << dist << " " << distlimit << " " << hit->GetHitID() << endl;
1128  cluster.AddHit(hit);
1129  if(fDisplayOn) {
1130  TArc *arc = new TArc(hit->GetPosition().X(), hit->GetPosition().Y(), hit->GetIsochrone());
1131  arc->SetFillStyle(0);
1132  arc->SetLineColor(5);
1133  display->cd(1);
1134  arc->Draw("SAME");
1135  }
1136  }
1137  }
1138  for(int ihit = 0; ihit < mvdpixhitlist->GetNofHits(); ihit++) {
1139  PndTrkHit *hit = mvdpixhitlist->GetHit(ihit);
1140  double dist = hit->GetXYDistanceFromTrack(xc0, yc0, R0);
1141  // CHECK limits
1142  double distlimit = 0.5;
1143  if(dist < distlimit) {
1144  cluster.AddHit(hit);
1145  if(fDisplayOn) {
1146  TMarker *mrk = new TMarker(hit->GetPosition().X(), hit->GetPosition().Y(), 21);
1147  mrk->SetMarkerColor(5);
1148  display->cd(1);
1149  mrk->Draw("SAME");
1150  }
1151  }
1152  }
1153  for(int ihit = 0; ihit < mvdstrhitlist->GetNofHits(); ihit++) {
1154  PndTrkHit *hit = mvdstrhitlist->GetHit(ihit);
1155  double dist = hit->GetXYDistanceFromTrack(xc0, yc0, R0);
1156  // CHECK limits
1157  double distlimit = 0.5;
1158  if(dist < distlimit){
1159  cluster.AddHit(hit);
1160  if(fDisplayOn) {
1161  TMarker *mrk = new TMarker(hit->GetPosition().X(), hit->GetPosition().Y(), 25);
1162  mrk->SetMarkerColor(5);
1163  display->cd(1);
1164  mrk->Draw("SAME");
1165  }
1166  }
1167  }
1168  return cluster;
1169 
1170 }
1171 
1173 
1174  PndTrkCluster cluster;
1175  double delta = conformalhitlist->GetConformalTransform()->GetRotation();
1176  // CHECK
1177  // ADD HIT IN MIXED MODE REAL P. FOR MVD & CONFORMAL P. FOR STT,
1178  // WITH DISTANCE CRITERION
1179  // real: fabs(R - sqrt((xc - x)**2 + (yc - y)**2)) < distlim
1180  // cofn: cost x + sint y - r = 0 -> |cost x0 + sint y0 - r|
1181 
1182  // CHECK if this needs to be kept --> change xc0 to xc etc
1183  // center and radius
1184  Double_t xc0, yc0, R0;
1185  FromConformalToRealTrack(fitm, fitq, xc0, yc0, R0);
1186  // .........................................................
1187  if(fDisplayOn) {
1188  TArc *arc = new TArc(xc0, yc0, R0);
1189  arc->SetFillStyle(0);
1190  arc->SetLineColor(5);
1191  display->cd(1);
1192  arc->Draw("SAME");
1193  }
1194  for(int ihit = 0; ihit < mvdpixhitlist->GetNofHits(); ihit++) {
1195  PndTrkHit *hit = mvdpixhitlist->GetHit(ihit);
1196  double dist = hit->GetXYDistanceFromTrack(xc0, yc0, R0);
1197  // CHECK limits
1198  double distlimit = 0.5;
1199  if(dist < distlimit) {
1200  cluster.AddHit(hit);
1201  if(fDisplayOn) {
1202  TMarker *mrk = new TMarker(hit->GetPosition().X(), hit->GetPosition().Y(), 21);
1203  mrk->SetMarkerColor(5);
1204  display->cd(1);
1205  mrk->Draw("SAME");
1206  }
1207  }
1208  }
1209  for(int ihit = 0; ihit < mvdstrhitlist->GetNofHits(); ihit++) {
1210  PndTrkHit *hit = mvdstrhitlist->GetHit(ihit);
1211  double dist = hit->GetXYDistanceFromTrack(xc0, yc0, R0);
1212  // CHECK limits
1213  double distlimit = 0.5;
1214  if(dist < distlimit){
1215  cluster.AddHit(hit);
1216  if(fDisplayOn) {
1217  TMarker *mrk = new TMarker(hit->GetPosition().X(), hit->GetPosition().Y(), 25);
1218  mrk->SetMarkerColor(5);
1219  display->cd(1);
1220  mrk->Draw("SAME");
1221  }
1222  }
1223  }
1224 
1225  for(int ihit = 0; ihit < conformalhitlist->GetNofHits(); ihit++) {
1227  double dist = chit->GetDistanceFromTrack(fitm, fitq);
1228 
1229  int hitID = chit->GetHitID();
1230  int detID = chit->GetDetectorID();
1231 
1232  // CHECK limits
1233  if(detID != FairRootManager::Instance()->GetBranchId(fSttBranch)) continue;
1234  double distlimit = 0;
1235  if(chit->GetIsochrone() > 1.e-4) distlimit = 6 * chit->GetIsochrone();
1236  else distlimit = 0.001;
1237  // ---------------------------
1238 
1239  if(dist < distlimit) {
1240 
1241  // cout << "ADDED " << hitID << " " << detID << " " << dist << " " << distlimit << endl;
1242 
1243  if(fDisplayOn) {
1244  TArc *arc = new TArc(chit->GetU(), chit->GetV(), chit->GetIsochrone());
1245  arc->SetFillStyle(0);
1246  arc->SetLineColor(5);
1247  display->cd(2);
1248  arc->Draw("SAME");
1249  }
1250 
1251  PndTrkHit *hit = stthitlist->GetHit(hitID);
1252 
1253  // ********** CHECK ***********
1254  // if you put "is used" the efficiency beecomes much lower!
1255  // DO NOT: if(!hit->IsUsed())
1256  cluster.AddHit(hit);
1257  }
1258  }
1259  return cluster;
1260 }
1261 
1262 
1264  double dist = hit->GetXYDistanceFromTrack(x0, y0, R);
1265  int detID = hit->GetDetectorID();
1266  if(detID == FairRootManager::Instance()->GetBranchId(fMvdPixelBranch)) {
1267  if(dist < fMvdPix_RealDistLimit) return kTRUE;
1268  }
1269  else if(detID == FairRootManager::Instance()->GetBranchId(fMvdStripBranch)) {
1270  if(dist < fMvdStr_RealDistLimit) return kTRUE;
1271  }
1272  else if(detID == FairRootManager::Instance()->GetBranchId(fSttBranch)) {
1273  if(dist < fStt_RealDistLimit) return kTRUE;
1274  }
1275  return kFALSE;
1276 }
1277 
1278 
1280  double dist = chit->GetDistanceFromTrack(fitm, fitp);
1281  int detID = chit->GetDetectorID();
1282  if(detID == FairRootManager::Instance()->GetBranchId(fMvdPixelBranch)) {
1283  if(dist < fMvdPix_ConfDistLimit) return kTRUE;
1284  }
1285  else if(detID == FairRootManager::Instance()->GetBranchId(fMvdStripBranch)) {
1286  if(dist < fMvdStr_ConfDistLimit) return kTRUE;
1287  }
1288  else if(detID == FairRootManager::Instance()->GetBranchId(fSttBranch)) {
1289  if(chit->GetIsochrone() > 1.e-4) {
1290  if(dist < (6 * chit->GetIsochrone())) return kTRUE;
1291  }
1292  else if(dist < fStt_ConfDistLimit) return kTRUE;
1293  }
1294 
1295  return kFALSE;
1296 }
1297 
1299  PndTrkCluster cluster;
1300 
1301  // mode: -------------------------------------------
1302  // 0 all conformal: pix conf - str conf - stt conf
1303  // 1 all real: pix real - str real - stt real
1304  // 2 mix: pix real - str real - stt conf
1305  // --------------------------------------------------
1306  Double_t x0, y0, R;
1307  FromConformalToRealTrack(fitm, fitp, x0, y0, R);
1308 
1309  for(int ihit = 0; ihit < conformalhitlist->GetNofHits(); ihit++) {
1311  PndTrkHit *hit = chit->GetHit();
1312  Bool_t accept = kFALSE;
1313 
1314  if(hit == fRefHit) accept = DoesRealHitBelong(hit, x0, y0, R);
1315  else {
1316  if(mode == 0) accept = DoesConfHitBelong(chit, fitm, fitp);
1317  else if(mode == 1) accept = DoesRealHitBelong(hit, x0, y0, R);
1318  else if(mode == 2) {
1319  if(hit->GetDetectorID() == FairRootManager::Instance()->GetBranchId(fSttBranch)) accept = DoesConfHitBelong(chit, fitm, fitp);
1320  else accept = DoesRealHitBelong(hit, x0, y0, R);
1321  }
1322  }
1323 
1324 
1325  if(accept == kTRUE && fDisplayOn) {
1326  display->cd(1);
1327  if(hit->GetDetectorID() == FairRootManager::Instance()->GetBranchId(fSttBranch)) {
1328  TArc *arc = new TArc(hit->GetPosition().X(), hit->GetPosition().Y(), hit->GetIsochrone());
1329  arc->SetFillStyle(0);
1330  arc->SetLineColor(5);
1331  arc->Draw("SAME");
1332  }
1333  else {
1334  TMarker *mrk;
1335  if(hit->GetDetectorID() == FairRootManager::Instance()->GetBranchId(fMvdPixelBranch)) mrk = new TMarker(hit->GetPosition().X(), hit->GetPosition().Y(), 21);
1336  else if(hit->GetDetectorID() == FairRootManager::Instance()->GetBranchId(fMvdStripBranch)) mrk = new TMarker(hit->GetPosition().X(), hit->GetPosition().Y(), 25);
1337  mrk->SetMarkerColor(5);
1338  mrk->Draw("SAME");
1339  }
1340  }
1341 
1342  // ********** CHECK ***********
1343  // if you put "is used" the efficiency beecomes much lower!
1344  // DO NOT: if(!hit->IsUsed())
1345  if(accept == kTRUE) {
1346  // cout << "ADDING TO CLUSTER" << endl;
1347  cluster.AddHit(hit);
1348  }
1349  }
1350  return cluster;
1351 }
1352 
1353 
1354 int PndTrkLegendreSecTask2::AddHitToClusterByDistance(PndTrkCluster *cluster, Int_t mode, double fitm, double fitp) {
1355 
1356  // mode: -------------------------------------------
1357  // 0 all conformal: pix conf - str conf - stt conf
1358  // 1 all real: pix real - str real - stt real
1359  // 2 mix: pix real - str real - stt conf
1360  // --------------------------------------------------
1361  Double_t x0, y0, R;
1362  FromConformalToRealTrack(fitm, fitp, x0, y0, R);
1363  int addedcounter = 0;
1364  for(int ihit = 0; ihit < conformalhitlist->GetNofHits(); ihit++) {
1366  PndTrkHit *hit = chit->GetHit();
1367  if(cluster->DoesContain(hit) == kTRUE) continue;
1368  Bool_t accept = kFALSE;
1369 
1370  if(hit == fRefHit) accept = DoesRealHitBelong(hit, x0, y0, R);
1371  else {
1372  if(mode == 0) accept = DoesConfHitBelong(chit, fitm, fitp);
1373  else if(mode == 1) accept = DoesRealHitBelong(hit, x0, y0, R);
1374  else if(mode == 2) {
1375  if(hit->GetDetectorID() == FairRootManager::Instance()->GetBranchId(fSttBranch)) accept = DoesConfHitBelong(chit, fitm, fitp);
1376  else accept = DoesRealHitBelong(hit, x0, y0, R);
1377  }
1378  }
1379 
1380  // cout << "@@@@@@@@@@@@@@ ACCEPT " << accept << endl;
1381  if(accept == kTRUE) accept = CheckVicinity(hit, cluster);
1382 
1383 
1384 
1385  if(accept == kTRUE && fDisplayOn) {
1386  display->cd(1);
1387  if(hit->GetDetectorID() == FairRootManager::Instance()->GetBranchId(fSttBranch)) {
1388  TArc *arc = new TArc(hit->GetPosition().X(), hit->GetPosition().Y(), hit->GetIsochrone());
1389  arc->SetFillStyle(0);
1390  arc->SetLineColor(5);
1391  arc->Draw("SAME");
1392  }
1393  else {
1394  TMarker *mrk;
1395  if(hit->GetDetectorID() == FairRootManager::Instance()->GetBranchId(fMvdPixelBranch)) mrk = new TMarker(hit->GetPosition().X(), hit->GetPosition().Y(), 21);
1396  else if(hit->GetDetectorID() == FairRootManager::Instance()->GetBranchId(fMvdStripBranch)) mrk = new TMarker(hit->GetPosition().X(), hit->GetPosition().Y(), 25);
1397  mrk->SetMarkerColor(5);
1398  mrk->Draw("SAME");
1399  }
1400  }
1401 
1402  // ********** CHECK ***********
1403  // if you put "is used" the efficiency beecomes much lower!
1404  // DO NOT: if(!hit->IsUsed())
1405  if(accept == kTRUE) {
1406  // cout << "ADDING TO CLUSTER" << endl;
1407  addedcounter++;
1408  cluster->AddHit(hit);
1409  }
1410  }
1411  return addedcounter;
1412 }
1413 
1414 // CHECK change the function to compute distance: now it just computes
1415 // the minimum hit-to-cluster distance but it could check:
1416 // 1- for mvd-stt the distance of the mvd hit from the 1st layer stt hit
1417 // 2- think of other solutions...
1419  Double_t fMinimumDistanceLimit = 3;
1420 
1421  double distance = cluster->GetMinimumXYDistanceFromHit(hit);
1422  if(hit->IsMvdStrip()) fMinimumDistanceLimit = 10;
1423  else if(hit->IsMvdPixel()) fMinimumDistanceLimit = 3; // CHECK
1424  else if(hit->IsStt()) fMinimumDistanceLimit = 2;
1425 
1426  // cout << "GET MINIMUM DISTANCE " << distance << endl;
1427 
1428  if(distance < fMinimumDistanceLimit) return kTRUE;
1429  return kFALSE;
1430 }
1431 
1432 void PndTrkLegendreSecTask2::FromConformalToRealTrack(double fitm, double fitp, double &x0, double &y0, double &R) {
1433  // CHECK if this needs to be kept --> change xc0 to xc etc
1434  // center and radius
1435  Double_t xcrot0, ycrot0;
1436  ycrot0 = 1 / (2 * fitp);
1437  xcrot0 = - fitm * ycrot0;
1438  R = sqrt(xcrot0 * xcrot0 + ycrot0 * ycrot0);
1439  // re-rotation and re-traslation of xc and yc
1440  // rotation
1443  // traslation
1446 }
1447 
1449  if(hxy == NULL) hxy = new TH2F("hxy", "xy plane", 100, -43, 43, 100, -43, 43);
1450  else hxy->Reset();
1451  display->cd(1);
1452  hxy->Draw();
1453  display->Update();
1454  display->Modified();
1455 
1456 }
1457 
1458 void PndTrkLegendreSecTask2::DrawZGeometry(int whichone, double phimin, double phimax, double zmin, double zmax)
1459 {
1460  if(hxz == NULL) hxz = new TH2F("hxz", "xz plane", 100, -43, 43, 100, -43, 113);
1461  else hxz->Reset();
1462  display->cd(3);
1463  hxz->Draw();
1464  if(whichone == 2) {
1465  if(hzphi == NULL) hzphi = new TH2F("hzphi", "z - phi plane", phimax - phimin, phimin, phimax, zmax - zmin, zmin, zmax);
1466  else {
1467  hzphi->Reset();
1468  hzphi->GetXaxis()->SetLimits(phimin, phimax);
1469  hzphi->GetYaxis()->SetLimits(zmin, zmax);
1470  }
1471  display->cd(4);
1472  hzphi->Draw();
1473  }
1474  display->Update();
1475  display->Modified();
1476 
1477 }
1478 
1479 // ============================================================================================
1480 // DISPLAY ***********************************************************************************
1481 // ============================================================================================
1482 
1484  // CHECK
1485  char goOnChar;
1486  // cout << "Refresh?" << endl;
1487  // cin >> goOnChar;
1488  // cout << "REFRESHING" << endl;
1489  DrawGeometry();
1490  if(fVerbose) cout << "Refresh stt" << endl;
1492  if(fVerbose) cout << "Refresh pixel" << endl;
1494  if(fVerbose) cout << "Refresh strip" << endl;
1496  if(fVerbose) cout << "Refresh stop" << endl;
1497 
1498 }
1499 
1501  display->cd(1);
1502  hitlist->Draw();
1503  display->Update();
1504  display->Modified();
1505 }
1506 void PndTrkLegendreSecTask2::DrawGeometryConf(double x1, double y1, double x2, double y2) {
1507  // CHECK
1508  char goOnChar;
1509  // cout << "DRAWING GEOMETRY CONF" << endl;
1510  // cin >> goOnChar;
1511 
1512  // CHECK previous calculations, now not used;
1513  if(huv == NULL) huv = new TH2F("huv", "uv plane", 100, x1, y1, 100, x2, y2);
1514  else {
1515  huv->Reset();
1516  huv->GetXaxis()->SetLimits(x1, y1);
1517  huv->GetYaxis()->SetLimits(x2, y2);
1518  }
1519  display->cd(2);
1520  huv->Draw();
1521  display->Update();
1522  display->Modified();
1523 
1524 }
1525 
1526 
1528  display->cd(3);
1529  legendre->Draw();
1530  display->Update();
1531  display->Modified();
1532 }
1533 
1534 void PndTrkLegendreSecTask2::RefreshConf() { // CHECK delete
1535  // CHECK
1536  char goOnChar;
1537  // cout << "RefreshConf?" << endl;
1538  // cin >> goOnChar;
1539  // cout << "REFRESHING CONF" << endl;
1540 }
1541 
1542 void PndTrkLegendreSecTask2::RefreshZ() { // CHECK delete
1543  // CHECK
1544  char goOnChar;
1545  // cout << "RefreshZ?" << endl;
1546  // cin >> goOnChar;
1547  // cout << "REFRESHING Z" << endl;
1548 }
1549 
1550 
1551 void PndTrkLegendreSecTask2::DrawConfHit(double u, double v, double r, int marker) {
1552  display->cd(2);
1553  if(r >= 0) {
1554  TArc *arc = new TArc(u, v, r);
1555  arc->SetFillStyle(0);
1556  arc->Draw("SAME");
1557  }
1558  else {
1559  TMarker *mrk = new TMarker(u, v, marker);
1560  mrk->Draw("SAME");
1561  }
1562  // display->Update();
1563  // display->Modified();
1564 }
1565 
1567 
1568 
1584  PndTrkCluster cluster;
1585  cluster.AddHit(firsthit);
1586  cluster.SetIRegion(firsthit->GetIRegion());
1587 
1588  // 2) LOOP on all the hits
1589  for(int ihit = 0; ihit < stthitlist->GetNofHits(); ihit++) {
1590  PndTrkHit *hit = stthitlist->GetHit(ihit);
1591 
1592  if(hit->IsUsed()) {
1593  // cout << "already used IV" << endl;
1594  continue;
1595  }
1596  if(!hit->IsRegion(firsthit->GetIRegion())) continue;
1597  // cout << ihit << " " << cluster.GetNofHits() << endl;
1598  // 3) LOOP (int hit3) on all the hits IN THE CLUSTER
1599  for(int jhit = 0; jhit < cluster.GetNofHits(); jhit++) {
1600  PndTrkHit *clushit = cluster.GetHit(jhit);
1601 
1602 
1603  if(*hit == *clushit) {
1604  continue;
1605  }
1606 
1607  Bool_t success = IsSttAssociate(hit, clushit);
1608  // cout << "success " << success << endl;
1609  if(!success) continue;
1610 
1611  cluster.AddHit(hit);
1612  break;
1613  }
1614  }
1615 
1616  if(cluster.GetNofHits() < 2) for(int ihit = 0; ihit < cluster.GetNofHits(); ihit++) cluster.DeleteAllHits();
1617  return cluster;
1618 }
1619 
1621 
1622  double distance = hit1->GetXYDistance(hit2); // ComputeDistance(hit1, hit2);
1623 
1624  if(distance < STTPARALDISTANCE) {
1625  // cout << "distance " << distance << endl;
1626  return kTRUE;
1627  }
1628  return kFALSE;
1629 
1630 }
1631 
1633 
1634  // cout << "LIGHT UP" << endl;
1635  Refresh();
1636  cluster->LightUp();
1637  display->Update();
1638  display->Modified();
1639 }
1640 
1641 // ================================== ZFINDER
1643 
1644  double xc = track->GetCenter().X();
1645  double yc = track->GetCenter().Y();
1646  double R = track->GetRadius();
1647  PndTrkCluster skewhitlist;
1648 
1649  double phimin = 400, phimax = -1, zmin = 1000, zmax = -1;
1650  for(int ihit = 0; ihit < stthitlist->GetNofHits(); ihit++) {
1651  PndTrkHit *hit = stthitlist->GetHit(ihit);
1652  // if(hit->IsUsed()) {
1653  // cout << "already used IV" << endl;
1654  // continue;
1655  // }
1656  if(hit->IsSttSkew() == kFALSE) continue;
1657 
1658  int tubeID = hit->GetTubeID();
1659  PndSttTube *tube = (PndSttTube*) fTubeArray->At(tubeID);
1660 
1661  TVector3 wireDirection = tube->GetWireDirection();
1662  Double_t halflength = tube->GetHalfLength();
1663 
1664  TVector3 first = tube->GetPosition() + wireDirection * halflength; // CHECK
1665  TVector3 second = tube->GetPosition() - wireDirection * halflength; // CHECK
1666  // if(fDisplayOn) {
1667  // char goOnChar;
1668  // display->cd(1);
1669  // TLine *l = new TLine(first.X(), first.Y(), second.X(), second.Y());
1670  // l->SetLineColor(kBlue);
1671  // l->Draw("SAME");
1672  // display->Update();
1673  // display->Modified();
1674  // cin >> goOnChar;
1675  // }
1676  double m1 = (first - second).Y()/(first - second).X();
1677  double q1 = first.Y() - m1 * first.X();
1678 
1679  // 1. compute intersection between the track circle and the wire
1680  TVector2 intersection1, intersection2;
1681  Int_t nofintersections = tools->ComputeSegmentCircleIntersection(TVector2(first.X(), first.Y()), TVector2(second.X(), second.Y()), xc, yc, R, intersection1, intersection2);
1682 
1683  if(nofintersections == 0) continue;
1684  if(nofintersections >= 2) {
1685  cout << "ERROR: MORE THAN 1 INTERSECTION!!" << endl;
1686  continue; // CHECK
1687  }
1688 
1689  if(fDisplayOn) {
1690  char goOnChar;
1691  display->cd(1);
1692  TLine *l = new TLine(first.X(), first.Y(), second.X(), second.Y());
1693  l->SetLineColor(kBlue);
1694  l->Draw("SAME");
1695 
1696  TMarker *mrk = new TMarker(intersection1.X(), intersection1.Y(), 20);
1697  mrk->SetMarkerColor(kBlue);
1698  mrk->Draw("SAME");
1699 
1700  display->Update();
1701  display->Modified();
1702 
1703 
1704  // cin >> goOnChar;
1705  }
1706 
1707 
1708  // 2. find the tangent to the track in the intersection point
1709  // tangent approximation
1710  TVector2 tangent = tools->ComputeTangentInPoint(xc, yc, intersection1);
1711 
1712  // 3. rotate clockwise the tangent/point/(wire, not explicitely)
1713  // in order to have the wire parallel to the x axis;
1714  // then translate everything to have the wire ON the x axis
1715  double beta = wireDirection.Phi();
1716  if(beta < 0) beta += TMath::Pi();
1717  // ... rotate the tangent
1718  double rtx = TMath::Cos(beta) * tangent.X() + TMath::Sin(beta) * tangent.Y();
1719  double rty = TMath::Cos(beta) * tangent.Y() - TMath::Sin(beta) * tangent.X();
1720  TVector2 rottangent(rtx, rty);
1721  rottangent = rottangent.Unit();
1722  // ... rotate the point
1723  double rx = TMath::Cos(beta) * intersection1.X() + TMath::Sin(beta) * intersection1.Y();
1724  double ry = TMath::Cos(beta) * intersection1.Y() - TMath::Sin(beta) * intersection1.X();
1725 
1726  // translation
1727  Double_t deltay = ry;
1728  rty -= deltay;
1729  ry -= deltay;
1730 
1731  // rotm, rotp
1732  Double_t rotm = rottangent.Y()/rottangent.X();
1733  Double_t rotp = ry - rotm * rx;
1734 
1735  // ellipsis
1736  double a = hit->GetIsochrone() * TMath::Cos(SKEW_ANGLE); // CHECK skew angle hard coded
1737  double b = hit->GetIsochrone();
1738 
1739  // center of ellipsis
1740  Double_t x0a, x0b, y0;
1741  y0 = 0.;
1742  x0a = (-rotp + TMath::Sqrt(b * b + a * a * rotm * rotm)) / rotm;
1743  x0b = (-rotp - TMath::Sqrt(b * b + a * a * rotm * rotm)) / rotm;
1744 
1745  // intersection point
1746  double intxa = (x0a * b * b - rotm * rotp * a * a) / (b * b + rotm * rotm * a * a);
1747  double intya = rotm * intxa + rotp;
1748  double intxb = (x0b * b * b - rotm * rotp * a * a) / (b * b + rotm * rotm * a * a);
1749  double intyb = rotm * intxb + rotp;
1750 
1751  // 4. retraslate/rerotate all back to the original plane
1752  // retranslate
1753  y0 += deltay;
1754  intya += deltay;
1755  intyb += deltay;
1756 
1757  // rerotate
1758  double x0anew = TMath::Cos(beta) * x0a - TMath::Sin(beta) * y0;
1759  double y0anew = TMath::Cos(beta) * y0 + TMath::Sin(beta) * x0a;
1760  double x0bnew = TMath::Cos(beta) * x0b - TMath::Sin(beta) * y0;
1761  double y0bnew = TMath::Cos(beta) * y0 + TMath::Sin(beta) * x0b;
1762 
1763  double intxanew = TMath::Cos(beta) * intxa - TMath::Sin(beta) * intya;
1764  double intyanew = TMath::Cos(beta) * intya + TMath::Sin(beta) * intxa;
1765  double intxbnew = TMath::Cos(beta) * intxb - TMath::Sin(beta) * intyb;
1766  double intybnew = TMath::Cos(beta) * intyb + TMath::Sin(beta) * intxb;
1767 
1768  intxa = intxanew;
1769  intya = intyanew;
1770  intxb = intxbnew;
1771  intyb = intybnew;
1772 
1773  // now we have x0a, y0a, center of the 1st ellipse
1774  // and x0b, y0b, center of the 2nd ellipse
1775  x0a = x0anew;
1776  double y0a = y0anew;
1777  x0b = x0bnew;
1778  double y0b = y0bnew;
1779 
1780  if(fDisplayOn) {
1781  char goOnChar;
1782  display->cd(1);
1783 
1784  TEllipse *ell1 = new TEllipse(x0a, y0a, a, b, 0, 360, -beta);
1785  ell1->SetFillStyle(0);
1786  ell1->SetLineColor(4);
1787  ell1->Draw("SAME");
1788  TEllipse *ell2 = new TEllipse(x0b, y0b, a, b, 0, 360, -beta);
1789  ell2->SetFillStyle(0);
1790  ell2->SetLineColor(6);
1791  ell2->Draw("SAME");
1792 
1793  TMarker *mrkinta = new TMarker(intxa, intya, 20);
1794  mrkinta->SetMarkerColor(4);
1795  mrkinta->Draw("SAME");
1796  TMarker *mrkintb = new TMarker(intxb, intyb, 20);
1797  mrkintb->SetMarkerColor(6);
1798  mrkintb->Draw("SAME");
1799  // cin >> goOnChar;
1800  }
1801 
1802  // 5. calculate z coordinate for each intersection
1803 
1804  // calculate z0a, z0b of the center of the ellipse
1805  Double_t t = ((x0a + y0a) - (first.X() + first.Y())) / ((second.X() - first.X()) + (second.Y() - first.Y()));
1806  Double_t z0a = first.Z() + (second.Z() - first.Z()) * t;
1807  // cout << "0 : calculate t, z0a " << t << " " << z0a << endl;
1808 
1809  t = ((x0b + y0b) - (first.X() + first.Y())) / ((second.X() - first.X()) + (second.Y() - first.Y()));
1810  Double_t z0b = first.Z() + (second.Z() - first.Z()) * t;
1811 
1812  TVector3 center1(x0a, y0a, z0a);
1813  TVector3 center2(x0b, y0b, z0b);
1814  if(fDisplayOn) {
1815  char goOnChar;
1816  display->cd(3);
1817  // cout << "COMPUTE Z COORDINATE" << endl;
1818  RefreshZ();
1819  DrawZGeometry();
1820  TLine *linezx = new TLine(first.X(), first.Z(), second.X(), second.Z());
1821  linezx->Draw("SAME");
1822  TMarker *mrkza = new TMarker(x0a, z0a, 20);
1823  mrkza->SetMarkerColor(4);
1824  mrkza->Draw("SAME");
1825  TMarker *mrkzb = new TMarker(x0b, z0b, 20);
1826  mrkzb->SetMarkerColor(6);
1827  mrkzb->Draw("SAME");
1828  // cin >> goOnChar;
1829  }
1830 
1831  // calculate the z of the intersection ON the ellipse (CHECK this step calculations!)
1832  double dx = intxa - x0a;
1833  double dy = intya - y0a;
1834  TVector3 dxdy(dx, dy, 0.0);
1835 
1836  TVector3 tfirst = first + dxdy;
1837  TVector3 tsecond = second + dxdy;
1838 
1839  t = ((intxa + intya) - (tfirst.X() + tfirst.Y())) / ((tsecond.X() - tfirst.X()) + (tsecond.Y() - tfirst.Y()));
1840  double intza = tfirst.Z() + (tsecond.Z() - tfirst.Z()) * t;
1841  if(fDisplayOn) {
1842  char goOnChar;
1843  display->cd(3);
1844  TLine *linezx1 = new TLine(tfirst.X(), tfirst.Z(), tsecond.X(), tsecond.Z());
1845  linezx1->SetLineStyle(1);
1846  linezx1->Draw("SAME");
1847  TMarker *mrkza1 = new TMarker(intxa, intza, 20);
1848  mrkza1->SetMarkerColor(kBlue - 9);
1849  mrkza1->Draw("SAME");
1850  // cin >> goOnChar;
1851  }
1852 
1853  tfirst = first - dxdy;
1854  tsecond = second - dxdy;
1855 
1856  t = ((intxb + intyb) - (tfirst.X() + tfirst.Y())) / ((tsecond.X() - tfirst.X()) + (tsecond.Y() - tfirst.Y()));
1857  double intzb = tfirst.Z() + (tsecond.Z() - tfirst.Z()) * t;
1858 
1859  TVector3 fin_intersection1(intxa, intya, intza);
1860  TVector3 fin_intersection2(intxb, intyb, intzb);
1861 
1862  if(fDisplayOn) {
1863  char goOnChar;
1864  display->cd(3);
1865  TLine *linezx2 = new TLine(tfirst.X(), tfirst.Z(), tsecond.X(), tsecond.Z());
1866  linezx2->SetLineStyle(1);
1867  linezx2->Draw("SAME");
1868  TMarker *mrkzb1 = new TMarker(intxb, intzb, 20);
1869  mrkzb1->SetMarkerColor(kMagenta - 7);
1870  mrkzb1->Draw("SAME");
1871  // cin >> goOnChar;
1872  }
1873  // int1.SetXYZ(intxa, intya, intza);
1874  // int2.SetXYZ(intxb, intyb, intzb);
1875  // errz = fabs(intza - intzb)/2. ;
1876 
1877  // CHECK to be changed
1878  int trackID = 1;
1879  double phi1 = track->ComputePhi(fin_intersection1);
1880  double phi2 = track->ComputePhi(fin_intersection2);
1881 
1882  PndTrkSkewHit *skewhit = new PndTrkSkewHit(*hit, trackID, center1, fin_intersection1, phi1, center2, fin_intersection2, phi2, a, b, -1, beta);
1883  // skewhit->Print();
1884  skewhitlist.AddHit(skewhit);
1885 
1886 
1887  }
1888  // cout << "PHI: " << phimin << " " << phimax << endl;
1889  // cout << "Z : " << zmin << " " << zmax << endl;
1890 
1891 
1892  return skewhitlist;
1893 }
1894 
1896 
1897 
1898  // 6. FIRST CLEANING of the track skewed associations
1899  // find most probable z - CHECK what happens if a track is very fwd peaked?
1900  // TRY WITH DELTA z = COST
1901  // cout << "##################### FIND MOST PROBABLE Z" << endl;
1902  double phimin = 400, phimax = -1, zmin = 1000, zmax = -1;
1903 
1904  for(int ihit = 0; ihit < skewhitlist->GetNofHits(); ihit++) {
1905  PndTrkSkewHit *skewhit = (PndTrkSkewHit*) skewhitlist->GetHit(ihit);
1906  if(!skewhit) continue;
1907  TVector3 fin_intersection1 = skewhit->GetIntersection1();
1908  TVector3 fin_intersection2 = skewhit->GetIntersection2();
1909 
1910  double phi1 = skewhit->GetPhi1();
1911  double phi2 = skewhit->GetPhi2();
1912 
1913  if(phi1 < phimin) phimin = phi1;
1914  if(phi2 < phimin) phimin = phi2;
1915  if(fin_intersection1.Z() < zmin) zmin = fin_intersection1.Z();
1916  if(fin_intersection2.Z() < zmin) zmin = fin_intersection2.Z();
1917 
1918  if(phi1 > phimax) phimax = phi1;
1919  if(phi2 > phimax) phimax = phi2;
1920  if(fin_intersection1.Z() > zmax) zmax = fin_intersection1.Z();
1921  if(fin_intersection2.Z() > zmax) zmax = fin_intersection2.Z();
1922  // ~~~~~~~~~~~~~~~~~~~~~~~~~~~ CHECK
1923  }
1924  // cout << "PHI: " << phimin << " " << phimax << endl;
1925  // cout << "Z : " << zmin << " " << zmax << endl;
1926 
1927  // DISPLAY ----------------------------
1928  if(fDisplayOn) {
1929  char goOnChar;
1930  display->cd(4);
1931  phimin -= 30;
1932  phimax += 30;
1933  zmin -= 13;
1934  zmax += 13;
1935  DrawZGeometry(2, phimin, phimax, zmin, zmax);
1936  hzphi->SetXTitle("#phi");
1937  hzphi->SetYTitle("#z");
1938  hzphi->Draw();
1939  display->Update();
1940  display->Modified();
1941 
1942 
1943  for(int ihit = 0; ihit < skewhitlist->GetNofHits(); ihit++) {
1944  PndTrkSkewHit *skewhit = (PndTrkSkewHit*) skewhitlist->GetHit(ihit);
1945  if(!skewhit) continue;
1946 
1947  TVector3 fin_intersection1 = skewhit->GetIntersection1();
1948  TVector3 fin_intersection2 = skewhit->GetIntersection2();
1949 
1950  double phi1 = skewhit->GetPhi1();
1951  double phi2 = skewhit->GetPhi2();
1952 
1953  TLine *linezphi = new TLine(phi1, fin_intersection1.Z(), phi2, fin_intersection2.Z());
1954  // TLine *linezphi = new TLine(fin_intersection1.Z(), phi1, fin_intersection2.Z(), phi2);
1955  linezphi->SetLineStyle(1);
1956  linezphi->Draw("SAME");
1957 
1958  TMarker *mrkzphi1 = new TMarker(phi1, fin_intersection1.Z(), 20);
1959  // TMarker *mrkzphi1 = new TMarker(fin_intersection1.Z(), phi1, 20);
1960 
1961  mrkzphi1->SetMarkerColor(kBlue - 9);
1962  mrkzphi1->Draw("SAME");
1963 
1964  TMarker *mrkzphi2 = new TMarker(phi2, fin_intersection2.Z(), 20);
1965  // TMarker *mrkzphi2 = new TMarker(fin_intersection2.Z(), phi2, 20);
1966  mrkzphi2->SetMarkerColor(kMagenta - 7);
1967  mrkzphi2->Draw("SAME");
1968  }
1969  display->Update();
1970  display->Modified();
1971  // cin >> goOnChar;
1972  }
1973  // DISPLAY ----------------------------
1974 
1975  TH1F hz("hz", "z", (zmax - zmin)/10., zmin, zmax); // CHECK
1976  for(int ihit = 0; ihit < skewhitlist->GetNofHits(); ihit++) {
1977  PndTrkSkewHit *skewhit = (PndTrkSkewHit*) skewhitlist->GetHit(ihit);
1978  if(!skewhit) continue;
1979  TVector3 fin_intersection1 = skewhit->GetIntersection1();
1980  TVector3 fin_intersection2 = skewhit->GetIntersection2();
1981  hz.Fill(fin_intersection1.Z());
1982  hz.Fill(fin_intersection2.Z());
1983  }
1984  int maxbinz = hz.GetMaximumBin();
1985  double mostprobZ = hz.GetBinCenter(maxbinz);
1986  // cout << mostprobZ << endl;
1987 
1988  // delete hits too far away ..........
1989  // cout << "##################### DELETE HITS" << endl;
1990  PndTrkCluster tmpskewhitlist;
1991  for(int ihit = 0; ihit < skewhitlist->GetNofHits(); ihit++) {
1992  PndTrkSkewHit *skewhit = (PndTrkSkewHit*) skewhitlist->GetHit(ihit);
1993  if(!skewhit) continue;
1994  TVector3 fin_intersection1 = skewhit->GetIntersection1();
1995  TVector3 fin_intersection2 = skewhit->GetIntersection2();
1996  double phi1 = skewhit->GetPhi1();
1997  double phi2 = skewhit->GetPhi2();
1998 
1999  if(fabs(fin_intersection1.Z() - mostprobZ) > 30. && fabs(fin_intersection2.Z() - mostprobZ) > 30.) {
2000  // cout << "THROW AWAY " << ihit << " " << fabs(fin_intersection1.Z() - mostprobZ) << " " << fabs(fin_intersection2.Z() - mostprobZ) << endl;
2001  continue;
2002  }
2003  skewhit->SetSortVariable((phi1 + phi2)/2.);
2004  tmpskewhitlist.AddHit(skewhit);
2005  }
2006  tmpskewhitlist.Sort();
2007  return tmpskewhitlist;
2008 }
2009 
2010 
2011 
2013  PndTrack *finaltrack = track->ConvertToPndTrack();
2014 
2015  TClonesArray& clref1 = *fTrackArray;
2016  Int_t size = clref1.GetEntriesFast();
2017  PndTrack *outputtrack = new(clref1[size]) PndTrack(finaltrack->GetParamFirst(), finaltrack->GetParamLast(), finaltrack->GetTrackCand());
2018 
2019  TClonesArray& clref2 = *fTrackCandArray;
2020  size = clref2.GetEntriesFast();
2021  PndTrackCand *outputtrackcand = new(clref2[size]) PndTrackCand(finaltrack->GetTrackCand());
2022 
2023  if(fVerbose > 1) {
2024  cout << "MOM FIRST: TOT, PT, PL " << outputtrack->GetParamFirst().GetMomentum().Mag() << " " << outputtrack->GetParamFirst().GetMomentum().Perp() << " " << outputtrack->GetParamFirst().GetMomentum().Z() << endl;
2025  cout << "MOM LAST: TOT, PT, PL " << outputtrack->GetParamLast().GetMomentum().Mag() << " " << outputtrack->GetParamLast().GetMomentum().Perp() << " " << outputtrack->GetParamLast().GetMomentum().Z() << endl;
2026  }
2027  if(fDisplayOn) {
2028  char goOnChar;
2029  display->cd(1);
2030  Refresh();
2031 
2032  track->Draw(kRed);
2033  display->Update();
2034  display->Modified();
2035 
2036  cout << "X, Y, R " << track->GetCenter().X() << " " << track->GetCenter().Y() << " " << track->GetRadius() << endl;
2037  cout << "Z0, TANL " << track->GetZ0() << " " << track->GetTanL() << endl;
2038  cout << "CHARGE " << track->GetCharge() << endl;
2039  // cin >> goOnChar;
2040  }
2041 
2042 }
2043 
2044 
2045 // ----------------------- FOR SECONDARIES
2047  int ntot = 0;
2048  if(isec == -1) ntot = stthitlist->GetNofHits();
2049  else ntot = stthitlist->GetNofHitsInSector(isec);
2050 
2051  if(ntot == 0) return NULL;
2052 
2053 
2054  int tmphitid = -1;
2055  Double_t tmpiso = 1.;
2056  PndTrkHit *refhit = NULL;
2057  for(int jhit = 0; jhit < ntot; jhit++) {
2058  PndTrkHit *hit = NULL;
2059  if(isec == -1) hit = stthitlist->GetHit(jhit);
2060  else hit = stthitlist->GetHitFromSector(jhit, isec);
2061 
2062  if(hit->IsUsed()) {
2063  if(fVerbose > 1) cout << "STT hit " << jhit << "already used " << endl;
2064  continue; }
2065  if(hit->IsSttSkew()) continue;
2066  if(hit->GetIsochrone() < tmpiso) {
2067  tmphitid = jhit;
2068  tmpiso = hit->GetIsochrone();
2069  refhit = hit;
2070  }
2071  }
2072  if(tmphitid == -1) return NULL;
2073 
2074  // PndTrkHit *refhit = &thishitlist[tmphitid];
2075  if(fVerbose > 1) cout << "STT REFERENCE HIT " << tmphitid << " " << refhit->GetIsochrone() << endl;
2076  return refhit;
2077 
2078 }
2079 
2081  {
2082  if(mvdpixhitlist->GetNofHits() == 0) return NULL;
2083  // loop on mvd pix hits
2084  int tmphitid = -1;
2085  PndTrkHit *refhit = NULL;
2086  for(int jhit = 0; jhit < mvdpixhitlist->GetNofHits(); jhit++) {
2087  PndTrkHit *hit = mvdpixhitlist->GetHit(jhit);
2088  if(hit->IsUsed()) {
2089  if(fVerbose > 1) cout << "already used V" << endl;
2090  continue;
2091  }
2092  tmphitid = jhit;
2093  break;
2094  }
2095  if(tmphitid == -1) return NULL;
2096  refhit = mvdpixhitlist->GetHit(tmphitid);
2097  if(fVerbose > 1) cout << "MVD PIXEL REFERENCE HIT " << refhit->GetHitID() << endl;
2098  return refhit;
2099 }
2100 
2102 {
2103  if(mvdstrhitlist->GetNofHits() == 0) return NULL;
2104  // loop on mvd str hits
2105  int tmphitid = -1;
2106  PndTrkHit *refhit = NULL;
2107  for(int jhit = 0; jhit < mvdstrhitlist->GetNofHits(); jhit++) {
2108  PndTrkHit *hit = mvdstrhitlist->GetHit(jhit);
2109  if(hit->IsUsed()) {
2110  if(fVerbose > 1) cout << "already used V" << endl;
2111  continue;
2112  }
2113  tmphitid = jhit;
2114  break;
2115  }
2116  if(tmphitid == -1) return NULL;
2117  refhit = mvdstrhitlist->GetHit(tmphitid);
2118  if(fVerbose > 1) cout << "MVD STRIP REFERENCE HIT " << refhit->GetHitID() << endl;
2119  return refhit;
2120 }
2121 
2123 {
2124  PndTrkHit *refhit = NULL;
2125  refhit = FindMvdStripReferenceHit();
2126  // refhit = FindMvdPixelReferenceHit();
2127  if(refhit != NULL) return refhit;
2128  // refhit = FindMvdStripReferenceHit();
2130  return refhit;
2131 }
2132 
2134 {
2135  PndTrkHit *refhit = NULL;
2136  // refhit = FindMvdReferenceHit();
2137  refhit = FindSttReferenceHit();
2138  if(refhit != NULL) return refhit;
2139  // refhit = FindSttReferenceHit();
2141 
2142  return refhit;
2143 }
2144 
2146  int ntot = cluster->GetNofHits();
2147  // cout << "FIND REFERENCE HIT " << ntot << endl;
2148 
2149  if(ntot == 0) return NULL;
2150 
2151 
2152  int tmphitid = -1;
2153  Double_t tmpiso = 1.;
2154  PndTrkHit *refhit = NULL;
2155  for(int jhit = 0; jhit < ntot; jhit++) {
2156  PndTrkHit *hit = cluster->GetHit(jhit);
2157 
2158  // if(hit->IsUsed()) {
2159  // if(fVerbose > 1) cout << "STT hit " << jhit << "already used " << endl;
2160  // continue; }
2161 
2162  if(hit->IsStt()) {
2163  if(hit->IsSttParallel()) {
2164  if(hit->GetIsochrone() < tmpiso) {
2165  tmphitid = jhit;
2166  tmpiso = hit->GetIsochrone();
2167  refhit = hit;
2168  }
2169  }
2170  }
2171  else {
2172  tmphitid = jhit;
2173  break;
2174  }
2175  }
2176 
2177  if(tmphitid == -1) return NULL;
2178  refhit = cluster->GetHit(tmphitid);
2179  if(fVerbose > 1) cout << "REFERENCE HIT " << refhit->GetHitID() << " " << refhit->GetDetectorID() << endl;
2180  return refhit;
2181 
2182 
2183 }
2184 
2185 
2187 
2188  trasl[0] = hit->GetPosition().X();
2189  trasl[1] = hit->GetPosition().Y();
2190 
2191  delta = 0.; // TMath::ATan2(hit->GetPosition().Y() - 0., hit->GetPosition().X() - 0.); // CHECK
2192 
2193 }
2194 
2195 
2197 
2198  // cout << "RESETTING LEGENDRE HISTO" << endl;
2200 
2201  if(fDisplayOn) {
2202  RefreshConf();
2203  if(fSecondary) DrawGeometryConf(-1., 1., -1., 1.);
2204  else DrawGeometryConf(-0.07, 0.07, -0.07, 0.07);
2205  }
2206  // cout << "%%%%%%%%%%%%%%%%%%%% XY FINDE %%%%%%%%%%%%%%%%%%%%%%%%%%" << endl;
2207  FillLegendreHisto(cluster);
2208 }
2209 
2211 
2212  // cout << "RESETTING LEGENDRE HISTO" << endl;
2214 
2215  if(fDisplayOn) {
2216  RefreshConf();
2217  if(fSecondary) DrawGeometryConf(-1., 1., -1., 1.);
2218  else DrawGeometryConf(-0.07, 0.07, -0.07, 0.07);
2219  }
2220  if(fVerbose > 1) cout << "%%%%%%%%%%%%%%%%%%%% XY FINDER %%%%%%%%%%%%%%%%%%%%%%%%%%" << endl;
2221  FillLegendreHisto(0);
2222 }
2223 
2224 Int_t PndTrkLegendreSecTask2::ApplyLegendre(double &theta_max, double &r_max) {
2225  PrepareLegendre();
2226  return ExtractLegendre(0, theta_max, r_max);
2227 }
2228 
2229 Int_t PndTrkLegendreSecTask2::ApplyLegendre(PndTrkCluster *cluster, double &theta_max, double &r_max) {
2230  RePrepareLegendre(cluster);
2231  return ExtractLegendre(1, theta_max, r_max);
2232 }
2233 
2234 
2235 
2236 Int_t PndTrkLegendreSecTask2::ExtractLegendre(Int_t mode, double &theta_max, double &r_max) {
2237  if(fDisplayOn) {
2238  char goOnChar;
2239  // cin >> goOnChar;
2241  // cout << "LEGENDRE (nof conf hits = " << conformalhitlist->GetNofHits() << ")" << endl;
2242  display->cd();
2243  // cin >> goOnChar;
2244  display->Update();
2245  display->Modified();
2246  }
2247 
2248  // FIND MAXIMUM IN LEGENDRE HISTO
2249 
2250  // legendre->ApplyThresholdLegendreHisto(0.3);
2251  int maxpeak = legendre->ExtractLegendreMaximum(theta_max, r_max);
2252 
2253  bool alreadythere = false;
2254  // if(mode == 0)
2255  {
2256 
2257  if(maxpeak <= 3) {
2258  // if(fVerbose > 1)
2259  cout << "MAXPEAK " << maxpeak << ", BREAK NOW! " << endl;
2260  return maxpeak;
2261  }
2262 
2263  for(int ialready = 0; ialready < fFoundPeaks.size(); ialready++) {
2264  std::pair<double, double> foundthetar = fFoundPeaks.at(ialready);
2265  double foundtheta = foundthetar.first;
2266  double foundr = foundthetar.second;
2267  // IF THIS PEAK WAS ALREADY FOUND, DELETE THE PEAK AND GO ON (TO AVOID INFINITE LOOPS)
2268  if(theta_max == foundtheta && r_max == foundr) {
2269  legendre->DeleteZoneAroundXYLegendre(theta_max, r_max);
2270  maxpeak = legendre->ExtractLegendreMaximum(theta_max, r_max);
2271  alreadythere = true;
2272  if(fVerbose > 0) cout << "OH NO! THIS PEAK IS ALREADY THERE" << endl;
2273  return -1;
2274  }
2275  }
2276 
2277  if(alreadythere == false) {
2278  std::pair<double, double> tr(theta_max, r_max);
2279  fFoundPeaks.push_back(tr);
2280  }
2281  }
2282  // ZOOM LEGENDRE HISTO
2283  legendre->SetUpZoomHisto(theta_max, r_max, 3, 0.005);
2284  // cout << "THETA/R " << theta_max << " " << r_max << " maxpeak " << maxpeak << endl;
2285 
2286  for(int ihit = 0; ihit < conformalhitlist->GetNofHits(); ihit++) {
2288  legendre->FillZoomHisto(chit->GetU(), chit->GetV(), chit->GetIsochrone());
2289  }
2290 
2291  if(mode == 0 && alreadythere == true) {
2292  cout << "THIS PEAK IS ALREADY THERE" << endl;
2293  legendre->DeleteZoneAroundXYZoom(theta_max, r_max);
2294  }
2295 
2296  int maxpeakzoom = legendre->ExtractZoomMaximum(theta_max, r_max);
2297  // cout << "THETA/R ZOOM " << theta_max << " " << r_max << " maxpeakzoom " << maxpeakzoom << endl;
2298 
2299  if(fDisplayOn) {
2300  char goOnChar;
2301  display->cd(3);
2302  TMarker *mrk = new TMarker(theta_max, r_max, 29);
2303  mrk->Draw("SAME");
2304  display->cd(4);
2305  legendre->DrawZoom();
2306  mrk->Draw("SAME");
2307  display->Update();
2308  display->Modified();
2309  // cin >> goOnChar;
2310  }
2311 
2312  return maxpeak;
2313 }
2314 
2315 
2317 
2318  // CLEANUP
2319  // -------------------------------------------------------
2320  // CleanCluster(cluster);
2321  // cluster->SortMvdPixelByLayerID();
2322  // cluster->SortByLayerID();
2323  PndTrkClean clean;
2324  int leftvotes = 0;
2325  int rightvotes = 0;
2326 
2327  TVector2 trasl = conform->GetTranslation();
2329 
2330  // SET SORT VARIABLE
2331  // MVD PIX PART OF CLUSTER
2332  PndTrkCluster mvdpixcluster = cluster.GetMvdPixelHitList();
2333  for(int ihit = 0; ihit < mvdpixcluster.GetNofHits(); ihit++) {
2334  PndTrkHit *hit = mvdpixcluster.GetHit(ihit);
2335  if(fSecondary) hit->SetSortVariable(hit->GetDistance(TVector3(trasl.X(), trasl.Y(), angle)));
2336  else hit->SetSortVariable(hit->GetDistance(TVector3(0., 0., 0)));
2337  int sensorID = hit->GetSensorID();
2338  int layerID = clean.FindMvdLayer(sensorID);
2339  if(layerID%2 == 0) rightvotes++;
2340  else leftvotes++;
2341  }
2342  // MVD STR PART OF CLUSTER
2343  PndTrkCluster mvdstrcluster = cluster.GetMvdStripHitList();
2344  for(int ihit = 0; ihit < mvdstrcluster.GetNofHits(); ihit++) {
2345  PndTrkHit *hit = mvdstrcluster.GetHit(ihit);
2346  if(fSecondary) hit->SetSortVariable(hit->GetDistance(TVector3(trasl.X(), trasl.Y(), angle)));
2347  else hit->SetSortVariable(hit->GetDistance(TVector3(0., 0., 0)));
2348  int sensorID = hit->GetSensorID();
2349  int layerID = clean.FindMvdLayer(sensorID);
2350  if(layerID%2 == 0) rightvotes++;
2351  else leftvotes++;
2352  }
2353  // STT PARALLEL PART OF CLUSTER
2354  PndTrkCluster sttcluster = cluster.GetSttParallelHitList();
2355  for(int ihit = 0; ihit < sttcluster.GetNofHits(); ihit++) {
2356  PndTrkHit *hit = sttcluster.GetHit(ihit);
2357  int layerID = -999, tubeID = hit->GetTubeID(), sectorID = -999;
2358  PndSttTube *tube = (PndSttTube*) fTubeArray->At(tubeID);
2359  layerID = tube->GetLayerID();
2360  sectorID = tube->GetSectorID();
2361  if(fSecondary) hit->SetSortVariable(hit->GetDistance(TVector3(trasl.X(), trasl.Y(), angle)));
2362  else hit->SetSortVariable(1000+layerID);
2363  if(sectorID < 3) rightvotes++;
2364  else leftvotes++;
2365  }
2366 
2367  // cout << "VOTES: LEFT " << leftvotes << " RIGHT " << rightvotes << endl;
2368  for(int ihit = 0; ihit < cluster.GetNofHits(); ihit++) {
2369  PndTrkHit *hit = cluster.GetHit(ihit);
2370  // cout << "for sorting " << hit->GetDetectorID () << " " << hit->GetHitID() << " " << hit->GetSortVariable() << endl;
2371  }
2372 
2373  cluster.Sort();
2374  for(int ihit = 0; ihit < cluster.GetNofHits(); ihit++) {
2375  PndTrkHit *hit = cluster.GetHit(ihit);
2376  // cout << "sorted " << hit->GetDetectorID () << " " << hit->GetHitID() << " " << hit->GetSortVariable() << endl;
2377  }
2378 
2379  // cluster.Print();
2380 
2381  // DELETE HITS
2382  PndTrkCluster deletioncluster;
2383 
2384  // LEFT/RIGHT CRITERION ------------------------------------------ NOW OFF
2385  // PIXEL
2386  mvdpixcluster = cluster.GetMvdPixelHitList();
2387  for(int ihit = 0; ihit < mvdpixcluster.GetNofHits(); ihit++) {
2388  PndTrkHit *hit = mvdpixcluster.GetHit(ihit);
2389  int sensorID = hit->GetSensorID();
2390  int layerID = clean.FindMvdLayer(sensorID);
2391  // cout << "pixel sorted " << hit->GetHitID() << " " << hit->GetSortVariable() << " " << sensorID << " " << layerID << endl;
2392 
2393 
2394  if((leftvotes > rightvotes) && (layerID%2 == 0)) {
2395  // deletioncluster.AddHit(hit);
2396  // cout << "pixel DELETED " << hit->GetHitID() << " " << ihit << " " << mvdpixcluster.GetNofHits() << endl;
2397  }
2398  else if((leftvotes < rightvotes) && (layerID%2 != 0)) {
2399  // deletioncluster.AddHit(hit);
2400  // cout << "pixel DELETED " << hit->GetHitID() << " " << ihit << " " << mvdpixcluster.GetNofHits() << endl;
2401  }
2402 
2403  if(fDisplayOn) {
2404  char goOnChar;
2405  display->cd(1);
2406  hit->Draw(kGreen);
2407  display->Update();
2408  display->Modified();
2409  cout << "WAITING" << endl;
2410  cin >> goOnChar;
2411  }
2412  }
2413  // STRIP
2414  mvdstrcluster = cluster.GetMvdStripHitList();
2415  for(int ihit = 0; ihit < mvdstrcluster.GetNofHits(); ihit++) {
2416  PndTrkHit *hit = mvdstrcluster.GetHit(ihit);
2417  int sensorID = hit->GetSensorID();
2418  // cout << "strip sorted " << hit->GetHitID() << " " << hit->GetSortVariable() << " " << sensorID << " " << clean.FindMvdLayer(sensorID) << endl;
2419  int layerID = clean.FindMvdLayer(sensorID);
2420  if((leftvotes > rightvotes) && (layerID%2 == 0)) {
2421  // deletioncluster.AddHit(hit);
2422  // cout << "strip DELETED " << hit->GetHitID() << endl;
2423  }
2424  else if((leftvotes < rightvotes) && (layerID%2 != 0)) {
2425  // deletioncluster.AddHit(hit);
2426  // cout << "strip DELETED " << hit->GetHitID() << endl;
2427  }
2428  if(fDisplayOn) {
2429  char goOnChar;
2430  display->cd(1);
2431  hit->Draw(kBlue);
2432  display->Update();
2433  display->Modified();
2434  // cin >> goOnChar;
2435  }
2436  }
2437 
2438  // STT PARALLEL
2439  sttcluster = cluster.GetSttParallelHitList();
2440  for(int ihit = 0; ihit < sttcluster.GetNofHits(); ihit++) {
2441  PndTrkHit *hit = sttcluster.GetHit(ihit);
2442  int layerID = -999, tubeID = hit->GetTubeID();
2443  PndSttTube *tube = (PndSttTube*) fTubeArray->At(tubeID);
2444  layerID = tube->GetLayerID();
2445  // cout << "stt sorted " << hit->GetHitID() << " " << hit->GetSortVariable() << " " << tubeID << " " << layerID << endl;
2446 
2447  int sectorID = tube->GetSectorID();
2448 
2449  if((leftvotes > rightvotes) && (sectorID < 3)) {
2450  // deletioncluster.AddHit(hit);
2451  // cout << "stt DELETED " << hit->GetHitID() << " " << sectorID << endl;
2452  }
2453  else if((leftvotes < rightvotes) && (sectorID >= 3)) {
2454  // deletioncluster.AddHit(hit);
2455  // cout << "stt DELETED " << hit->GetHitID() << " " << sectorID << endl;
2456  }
2457  // ~~~~~~~~~~~~~~~~~~ check *******************
2458  else { // NEIGHBORING CRITERION ------------------------------------------------
2459  TArrayI neighboring = tube->GetNeighborings();
2460  // cout << "NEIGHBORING TO TUBE " << tubeID << endl;
2461  // for(int nhit = 0; nhit < neighboring.GetSize(); nhit++) {
2462  // cout << " " << neighboring.At(nhit);
2463  // }
2464  // cout << endl;
2465 
2466  int neighboringcounter = 0;
2467  for(int ohit = 0; ohit < sttcluster.GetNofHits(); ohit++) {
2468  if(ihit == ohit) continue;
2469  PndTrkHit *otherhit = sttcluster.GetHit(ohit);
2470  int otherhitID = otherhit->GetTubeID();
2471 
2472  for(int nhit = 0; nhit < neighboring.GetSize(); nhit++) {
2473  if(otherhitID == neighboring.At(nhit)) neighboringcounter++;
2474  }
2475 
2476  // if(isthere == false)
2477  // {
2478  // deletioncluster.AddHit(hit);
2479  // cout << "stt DELETEDbis " << hit->GetHitID() << " " << sectorID << endl;
2480  // }
2481  }
2482  // cout << "hit " << ihit << " has " << neighboringcounter << " NEIGHBORINS" << endl;
2483 
2484  if(layerID != 0 && layerID != 7 && layerID != 8 && ihit != sttcluster.GetNofHits() - 1 && neighboringcounter == 1) {
2485  // cout << "I SHOULD DELETE THIS" << endl;
2486  // deletioncluster.AddHit(hit);
2487  // OFF FOR NOW: delete if there is just 1 neighboring
2488  // cout << "stt DELETED " << hit->GetHitID() << " " << sectorID << endl;
2489  }
2490 
2491  // ON, delete if there is no neighboring (isolated hit)
2492  if(neighboringcounter == 0) {
2493  // cout << "I WILL DELETE THIS" << endl;
2494  deletioncluster.AddHit(hit);
2495  // cout << "stt DELETED " << hit->GetHitID() << " " << sectorID << endl;
2496  }
2497 
2498  if(fDisplayOn) {
2499  char goOnChar;
2500  display->cd(1);
2501  hit->Draw(kCyan);
2502  display->Update();
2503  display->Modified();
2504  // cin >> goOnChar;
2505  }
2506  }
2507  }
2508 
2509  if(fDisplayOn) {
2510  char goOnChar;
2511  // cin >> goOnChar;
2512  }
2513  // ~~~~~~~~~~~~~~~~~~
2514 
2515 
2516 
2517  // ACTUAL DELETION OF HITS
2518 
2519  PndTrkCluster finalcluster;
2520  for(int ihit = 0; ihit < cluster.GetNofHits(); ihit++) {
2521  PndTrkHit *hit = cluster.GetHit(ihit);
2522  bool stop = false;
2523  for(int jhit = 0; jhit < deletioncluster.GetNofHits(); jhit++) {
2524  PndTrkHit *dhit = deletioncluster.GetHit(jhit);
2525  if(hit == dhit) {
2526  // ********** CHECK ***********
2527  // cout << "trhrow in again" << endl;
2528  // dhit->SetUsedFlag(0);
2529  stop = true;
2530  break;
2531  }
2532  }
2533  if(!stop) finalcluster.AddHit(hit);
2534  }
2535 
2536  return finalcluster;
2537 }
2538 
2539 
2541 
2542  PndTrkCluster *cleancluster = new PndTrkCluster();
2543  for(int ihit = 0; ihit < cluster->GetNofHits(); ihit++) {
2544  PndTrkHit *hit = cluster->GetHit(ihit);
2545  if(hit->IsSttParallel()) {
2546  cleancluster->AddHit(hit);
2547  continue; // CHECK IsSttParrallel will be changed
2548  }
2549 
2550  TVector3 position = hit->GetPosition();
2551  double phi = hit->GetPhi();
2552 
2553  // d = | m x - y + p | / sqrt(m**2 + 1)
2554  double distance = fabs(fitm * phi - position.Z() + fitp )/sqrt(fitm * fitm + 1);
2555  // cout << "distance " << hit->GetHitID() << " " << distance << endl;
2556 
2557  if(hit->GetDetectorID() == FairRootManager::Instance()->GetBranchId(fMvdPixelBranch) || hit->GetDetectorID() == FairRootManager::Instance()->GetBranchId(fMvdStripBranch)) {
2558  if(distance < 1) cleancluster->AddHit(hit);
2559  }
2560  else if(hit->GetDetectorID() == FairRootManager::Instance()->GetBranchId(fSttBranch)) {
2561  if(distance < 5) cleancluster->AddHit(hit);
2562  }
2563  }
2564  // cout << "cleancluster " << cleancluster->GetNofHits () << endl;
2565  return cleancluster;
2566 }
2567 
2568 
2569 Bool_t PndTrkLegendreSecTask2::ZPhiFit(int iter, PndTrkCluster *cluster, double &fitm, double &fitp)
2570 {
2571 
2572  // cout << "ZPHIFIT " << iter << endl;
2573 
2574  if(iter != 0) {
2575  if(fDisplayOn) {
2576  char goOnChar;
2577  display->cd(3);
2578  DrawZGeometry();
2579  hzphi->SetXTitle("#phi");
2580  hzphi->SetYTitle("#z");
2581  hzphi->Draw();
2582  display->Update();
2583  display->Modified();
2584  }
2585  }
2586 
2587  fFitter->Reset();
2588  PndTrkHit *hit = NULL;
2589  PndTrkHit *refhit = NULL;
2590  double refiso = 1000;
2591  for(int ihit = 0; ihit < cluster->GetNofHits(); ihit++) {
2592  hit = cluster->GetHit(ihit);
2593  if(hit->IsSttParallel() == kTRUE) continue; // CHECK IsSttParrallel will be changed
2594 
2595 
2596  TVector3 position = hit->GetPosition();
2597  double phi = hit->GetPhi();
2598  // fFitter->SetPointToFit(phi, position.Z(), 0.1);
2599 
2600  // CHECK refhit stuff
2601  if(hit->GetDetectorID() == FairRootManager::Instance()->GetBranchId(fMvdPixelBranch) || hit->GetDetectorID() == FairRootManager::Instance()->GetBranchId(fMvdStripBranch)) {
2602  if(iter != 0) refhit = hit;
2603  fFitter->SetPointToFit(phi, position.Z(), 0.001);
2604  // cout << ihit << " " << hit->GetDetectorID() << " " << hit->GetHitID() << " " << hit->IsSttParallel() << " SetPointToFit " << phi << " " << position.Z() << " " << endl;
2605  }
2606  else if(hit->GetDetectorID() == FairRootManager::Instance()->GetBranchId(fSttBranch)) {
2607  if(iter != 0 && refhit == NULL && hit->GetIsochrone() < refiso) refhit = hit;
2608  fFitter->SetPointToFit(phi, position.Z(), 0.1);
2609  // cout << ihit << " " << hit->GetDetectorID() << " " << hit->GetHitID() << " " << hit->IsSttParallel() << " SetPointToFit " << phi << " " << position.Z() << " " << endl;
2610  }
2611 
2612  if(fDisplayOn) {
2613  char goOnChar;
2614  if(iter == 0) display->cd(4);
2615  TMarker *mrkfoundzphi = NULL;
2616  if(hit->GetDetectorID() == FairRootManager::Instance()->GetBranchId(fMvdPixelBranch) || hit->GetDetectorID() == FairRootManager::Instance()->GetBranchId(fMvdStripBranch)) {
2617  mrkfoundzphi = new TMarker(phi, position.Z(), 21);
2618  if(iter == 0) mrkfoundzphi->SetMarkerColor(kOrange);
2619  else mrkfoundzphi->SetMarkerColor(4);
2620  }
2621  else if(hit->GetDetectorID() == FairRootManager::Instance()->GetBranchId(fSttBranch)) {
2622  mrkfoundzphi = new TMarker(phi, position.Z(), 20);
2623  if(iter == 0) mrkfoundzphi->SetMarkerColor(kGreen);
2624  else mrkfoundzphi->SetMarkerColor(4);
2625  }
2626  mrkfoundzphi->Draw("SAME");
2627  // display->cd(3);
2628  // mrkfoundzphi->Draw("SAME");
2629 
2630  }
2631  }
2632  // ===================================
2633  bool fit = kFALSE;
2634  if(iter == 0) fit = fFitter->StraightLineFit(fitm, fitp);
2635  else {
2636  if(refhit != NULL) fit = fFitter->ConstrainedStraightLineFit(refhit->GetPhi(), refhit->GetPosition().Z(), fitm, fitp);
2637  else fit = fFitter->StraightLineFit(fitm, fitp);
2638  }
2639 
2640  if(fit) {
2641  if(fDisplayOn) {
2642  char goOnChar;
2643  if(iter != 0) display->cd(4);
2644  TLine *l22 = new TLine(-1000, -1000 * fitm + fitp, 1000, 1000 * fitm + fitp);
2645  if(iter == 0) l22->SetLineColor(3);
2646  else if(iter == 1) l22->SetLineColor(4);
2647  l22->Draw("SAME");
2648  display->cd(3);
2649  l22->Draw("SAME");
2650  display->Update();
2651  display->Modified();
2652  cin >> goOnChar;
2653  }
2654  }
2655  // ++++++++++++++++++++++++++++++++++
2656 
2657  return fit;
2658 }
2659 
2660 double PndTrkLegendreSecTask2::ComputeZRediduals(PndTrkCluster *cluster, double fitm, double fitp) {
2661 
2662  TH1F hresiduals("hresiduals", "residuals in z", 20, -5, 5);
2663 
2664  for(int ihit = 0; ihit < cluster->GetNofHits(); ihit++) {
2665  PndTrkHit *hit = cluster->GetHit(ihit);
2666 
2667  if(hit->GetDetectorID() != FairRootManager::Instance()->GetBranchId(fSttBranch)) continue;
2668  if(hit->IsSttParallel()) continue;
2669 
2670  TVector3 position = hit->GetPosition();
2671  double phi = hit->GetPhi();
2672 
2673 
2674  double distance = fitm * phi + fitp - position.Z();
2675 
2676  hresiduals.Fill(distance);
2677  }
2678 
2679  if(fDisplayOn) {
2680  display->cd(4);
2681  char goOnChar;
2682  cout << "residuals";
2683  cin >> goOnChar;
2684  hresiduals.Draw();
2685  display->Update();
2686  display->Modified();
2687  cin >> goOnChar;
2688  }
2689  return hresiduals.GetMean();
2690 }
2691 
2692 double PndTrkLegendreSecTask2::CorrectZ(PndTrkCluster *cluster, double deltaz, double fitm, double fitp) {
2693 
2694  for(int ihit = 0; ihit < cluster->GetNofHits(); ihit++) {
2695  PndTrkHit *hit = cluster->GetHit(ihit);
2696 
2697  if(hit->GetDetectorID() != FairRootManager::Instance()->GetBranchId(fSttBranch)) continue;
2698  if(hit->IsSttParallel()) continue;
2699 
2700  TVector3 position = hit->GetPosition();
2701  double newz = position.Z() - deltaz;
2702 
2703 
2704  int tubeID = hit->GetTubeID();
2705  PndSttTube *tube = (PndSttTube*) fTubeArray->At(tubeID);
2706 
2707  TVector3 wireDirection = tube->GetWireDirection();
2708  Double_t halflength = tube->GetHalfLength();
2709 
2710  TVector3 first = tube->GetPosition() + wireDirection * halflength; // CHECK
2711  TVector3 second = tube->GetPosition() - wireDirection * halflength; // CHECK
2712 
2713  double m, p;
2714  double newx = position.X();
2715  double newy = position.Y();
2716  if((second.X() - first.X()) != 0) {
2717  m = (second.Z() - first.Z())/(second.X() - first.X());
2718  p = position.Z() - m * position.X();
2719  newx = (newz - p)/m;
2720  }
2721 
2722  if((second.Y() - first.Y()) != 0) {
2723 
2724  m = (second.Z() - first.Z())/(second.Y() - first.Y());
2725  p = position.Z() - m * position.Y();
2726  newy = (newz - p)/m;
2727  }
2728 
2729  hit->SetPosition(TVector3(newx, newy, newz));
2730 
2731  if(fDisplayOn) {
2732  display->cd(1);
2733  char goOnChar;
2734  cout << endl;
2735  cout << "SEE IT" ;
2736  TMarker *mrk = new TMarker(newx, newy, 6);
2737  mrk->SetMarkerColor(kOrange);
2738  mrk->Draw("SAME");
2739  display->Update();
2740  display->Modified();
2741 
2742  cout << "old " << position.X() << " " << position.Y() << " " << position.Z() << endl;
2743  cout << "new " << newx << " " << newy << " " << newz << endl;
2744 
2745  cin >> goOnChar;
2746  }
2747 
2748  }
2749 }
2751 
PndTrkCluster CreateSkewHitList(PndTrkTrack *track)
Double_t x0
Definition: checkhelixhit.C:70
Int_t ApplyLegendre(double &theta_max, double &r_max)
int fVerbose
Definition: poormantracks.C:24
void Replace(PndTrkHit *hit)
void LightCluster(PndTrkCluster *cluster)
double dy
PndTrkSdsHitList * mvdpixhitlist
void SetUpZoomHisto(double theta, double r, double deltatheta, double deltar)
void RegisterTrack(PndTrkTrack *track)
Double_t GetRadius()
Definition: PndTrkTrack.h:43
void AddTCA(Int_t detID, TClonesArray *array)
double r
Definition: RiemannTest.C:14
void DrawGeometryConf(double x1, double y1, double x2, double y2)
int FindMvdLayer(int sensorID)
__m128 m
Definition: P4_F32vec4.h:28
TTree * b
PndTrack ConvertToPndTrack()
virtual void Exec(Option_t *opt)
Double_t GetHalfLength()
Definition: PndSttTube.cxx:99
Double_t GetPhi1()
Definition: PndTrkSkewHit.h:37
Int_t ExtractLegendre(Int_t mode, double &theta_max, double &r_max)
Double_t GetPhi()
Definition: PndTrkHit.h:67
friend F32vec4 sqrt(const F32vec4 &a)
Definition: P4_F32vec4.h:29
PndTrkConformalTransform * conform
PndTrkSttHitList * Instanciate()
PndRiemannTrack track
Definition: RiemannTest.C:33
static T Sqrt(const T &x)
Definition: PndCAMath.h:37
Double_t GetMinimumXYDistanceFromHit(PndTrkHit *hit)
std::vector< PndTrkHit * > GetHitList()
#define verbose
PndTrkCluster CreateClusterByRealDistance(double xc0, double yc0, double R0)
PndTrkCluster GetCluster()
Definition: PndTrkTrack.h:48
static T Sin(const T &x)
Definition: PndCAMath.h:42
void SetTanL(double tanl)
Definition: PndTrkTrack.h:39
Double_t sigma[nsteps]
Definition: dedx_bands.C:65
void FillLegendreHisto(double x, double y, double radius)
void SetPhi(Double_t phi)
Definition: PndTrkHit.h:48
Double_t GetZ0()
Definition: PndTrkTrack.h:46
int GetNofHitsInSector(int isec)
void SetSortVariable(Double_t sortvar)
Definition: PndTrkHit.h:44
PndTrkCluster CreateClusterByDistance(Int_t mode, double fitm, double fitq)
void AddHit(PndTrkHit *hit)
Bool_t IsMvdPixel()
Definition: PndTrkHit.h:75
double Y
Definition: anaLmdDigi.C:68
PndTrkHit * GetHitFromSector(int ihit, int isec)
static T Cos(const T &x)
Definition: PndCAMath.h:43
void RePrepareLegendre(PndTrkCluster *cluster)
__m128 v
Definition: P4_F32vec4.h:4
PndTrkHit * GetHit(int index)
std::vector< PndTrkHit * > GetHitListFromLayer(int ilay)
void DeleteZoneAroundXYLegendre(double x, double y)
TVector3 GetIntersection2()
Definition: PndTrkSkewHit.h:35
TVector2 GetCenter()
Definition: PndTrkTrack.h:44
Double_t p
Definition: anasim.C:58
void SetIRegion(int iregion)
Definition: PndTrkCluster.h:46
PndTrkHit * GetHit(int index)
Bool_t IsMvdStrip()
Definition: PndTrkHit.h:76
void AddCluster(PndTrkCluster *cluster)
int ExtractLegendreMaximum(double &theta_max, double &r_max)
Int_t GetHitID()
Definition: PndTrkHit.h:56
Double_t ComputePhi(TVector3 hit)
void DrawHits(PndTrkHitList *hitlist)
Bool_t IsSttParallel()
Definition: PndTrkHit.h:70
int GetLayerID()
Definition: PndSttTube.cxx:128
int isec
Definition: f_Init.h:19
Int_t GetSensorID()
Definition: PndTrkHit.h:60
void ComputeCharge()
Int_t mode
Definition: autocutx.C:47
double CorrectZ(PndTrkCluster *cluster, double deltaz, double fitm, double fitp)
Int_t GetCharge()
Definition: PndTrkTrack.h:57
void AddHit(PndTrkConformalHit *chit)
void SetCenter(double x, double y)
Definition: PndTrkTrack.h:37
std::vector< std::pair< double, double > > fFoundPeaks
Int_t a
Definition: anaLmdDigi.C:126
Bool_t CheckAssignability(std::vector< PndTrkHit * > hitlist)
Int_t GetIRegion()
Definition: PndTrkHit.h:64
Bool_t IsNeighboring(int tubeID)
Definition: PndSttTube.cxx:145
Int_t GetDetectorID()
Definition: PndTrkHit.h:57
#define MVDSTRIP
PndTrkCluster GetSttParallelHitList()
Double_t GetPhi2()
Definition: PndTrkSkewHit.h:38
PndTrackCand GetTrackCand()
Definition: PndTrack.h:47
void SetUsedFlag(Bool_t used)
Definition: PndTrkHit.h:50
Double_t
Bool_t CheckVicinity(PndTrkHit *hit, PndTrkCluster *cluster)
Double_t GetDistance(PndTrkHit *fromhit)
Definition: PndTrkHit.cxx:83
PndTrkConformalHit * GetHit(int index)
TArrayI GetNeighborings()
Definition: PndSttTube.cxx:137
void SetRadius(double radius)
Definition: PndTrkTrack.h:36
PndTrkConformalHit GetConformalHit(PndTrkHit *hit)
PndTrkSdsHitList * InstanciateStrip()
int ExtractZoomMaximum(double &theta_max, double &r_max)
#define STTPARALDISTANCE
Int_t FillConformalHitList(int isec=-1)
Double_t y0
Definition: checkhelixhit.C:71
Bool_t DoesConfHitBelong(PndTrkConformalHit *hit, double fitm, double fitp)
void Draw(Color_t color=kBlack)
PndTrkCluster CleanUpSkewHitList(PndTrkCluster *skewhitlist)
TVector3 GetPosition()
Definition: PndTrkHit.h:62
TVector3 GetPosition()
Definition: PndSttTube.cxx:87
void SetPosition(TVector3 pos)
Definition: PndTrkHit.h:47
FairTrackParP GetParamLast()
Definition: PndTrack.h:50
TVector2 ComputeTangentInPoint(double xc, double yc, TVector2 point)
FairRuntimeDb * rtdb
Definition: hit_dirc.C:66
void FillZoomHisto(double x, double y, double radius)
TClonesArray * FillTubeArray()
PndTrkCluster CreateClusterByConfDistance(double fitm, double fitq)
void SetOrigin(double x, double y, double delta)
void Draw(Color_t color=kBlack)
friend F32vec4 fabs(const F32vec4 &a)
Definition: P4_F32vec4.h:47
Bool_t ConstrainedStraightLineFit(Double_t x0, Double_t y0, Double_t &fitm, Double_t &fitp)
void ExtractLegendreSingleLineParameters(double &slope, double &intercept)
static PndGeoHandling * Instance()
double GetDistanceFromTrack(double fitm, double fitp)
Bool_t IsUsed()
Definition: PndTrkHit.h:58
PndTrkCluster * CleanupZPhiFit(PndTrkCluster *cluster, double fitm, double fitp)
double dx
void DrawConfHit(double x, double y, double r, int marker=2)
double X
Definition: anaLmdDigi.C:68
Double_t GetXYDistanceFromTrack(double x0, double y0, double R)
Definition: PndTrkHit.cxx:105
void DeleteZoneAroundXYZoom(double x, double y)
PndTrkCluster Cleanup(PndTrkCluster cluster)
int hit(Int_t nEvents=0, TString inFile="sim.root", TString parFile="par.root", TString inDigi="digi.root", TString outFile="hit.root", Int_t timeBased=0)
Definition: hit.C:1
PndTrkCluster GetMvdPixelHitList()
PndTrkLegendreTransform * legendre
Int_t ComputeSegmentCircleIntersection(TVector2 ex1, TVector2 ex2, double xc, double yc, double R, TVector2 &intersection1, TVector2 &intersection2)
Definition: PndTrkTools.cxx:77
void Draw(Color_t color)
Definition: PndTrkHit.cxx:109
Int_t GetNofHits()
Definition: PndTrkHitList.h:43
Bool_t DoesContain(PndTrkHit *hit)
TVector3 GetIntersection1()
Definition: PndTrkSkewHit.h:34
Double_t GetXYDistance(PndTrkHit *fromhit)
Definition: PndTrkHit.cxx:94
PndTrkConformalTransform * GetConformalTransform()
Bool_t StraightLineFit(Double_t &fitm, Double_t &fitp)
void SetZ0(double z0)
Definition: PndTrkTrack.h:40
PndTrkHit * FindSttReferenceHit(int isec=-1)
Bool_t IsStt()
Definition: PndTrkHit.h:72
PndTrkConformalHit GetConformalSttHit(PndTrkHit *hit)
ClassImp(PndAnaContFact)
double Z
Definition: anaLmdDigi.C:68
void ComputeTraAndRot(PndTrkHit *hit, Double_t &delta, Double_t trasl[2])
Bool_t DoesRealHitBelong(PndTrkHit *hit, double x0, double y0, double R)
TTree * t
Definition: bump_analys.C:13
PndTrkConformalHitList * conformalhitlist
Bool_t ZPhiFit(int iter, PndTrkCluster *cluster, double &fitm, double &fitp)
void FromConformalToRealTrack(double fitm, double fitp, double &x0, double &y0, double &R)
void SetConformalTransform(PndTrkConformalTransform *conformal)
Double_t GetIsochrone()
Definition: PndTrkHit.h:63
Double_t angle
#define MVDPIXEL
Int_t GetNofHits()
Definition: PndTrkCluster.h:52
double ComputeZRediduals(PndTrkCluster *cluster, double fitm, double fitp)
Double_t Pi
int GetSectorID()
Definition: PndSttTube.cxx:124
#define SKEW_ANGLE
PndTrkCluster CreateSttCluster(PndTrkHit *firsthit)
PndTrkCluster CreateClusterByMixedDistance(double fitm, double fitq)
Int_t GetTubeID()
Definition: PndTrkHit.h:61
Double_t R
Definition: checkhelixhit.C:61
Double_t GetTanL()
Definition: PndTrkTrack.h:45
PndTrkCluster GetMvdStripHitList()
Int_t AddHitToClusterByDistance(PndTrkCluster *cluster, Int_t mode, double fitm, double fitp)
TVector3 GetWireDirection()
Definition: PndSttTube.cxx:107
void DrawZGeometry(int whichone=1, double phimin=0, double phimax=360, double zmin=-43, double zmax=113)
Bool_t IsSttSkew()
Definition: PndTrkHit.h:71
FairTrackParP GetParamFirst()
Definition: PndTrack.h:49
PndTrkSdsHitList * mvdstrhitlist
void SetPointToFit(double x, double y, double sigma)
Bool_t IsRegion(Int_t iregion)
Definition: PndTrkHit.h:65
Bool_t IsSttAssociate(PndTrkHit *hit1, PndTrkHit *hit2)
PndTrkSdsHitList * InstanciatePixel()