FairRoot/PandaRoot
PndTrkCluster.cxx
Go to the documentation of this file.
1 //
2 // PndTrkCluster.cxx
3 //
4 //
5 //
6 //
7 // authors: Lia Lavezzi - INFN Pavia (2012)
8 //
10 
11 #include "PndTrkCluster.h"
12 
13 #include "PndDetectorList.h"
14 
15 #include <iostream>
16 #include <cmath>
17 #include <vector>
18 #include <iterator>
19 #include <algorithm>
20 
21 #include "TMath.h"
22 #include "PndTrkSttHitList.h"
23 #include "PndTrkSdsHitList.h"
24 #include "PndTrkHit.h"
25 
26 using namespace std;
27 
29  return *hit1 < *hit2;
30 }
31 
32 PndTrkCluster::PndTrkCluster() : fFromPoint(0., 0., 0.), fIRegion(-1), fHitList(TClonesArray("PndTrkHit", 10000)) {
33 }
34 
35 // PndTrkCluster::PndTrkCluster(const PndTrkCluster &cluster): fFromPoint(cluster.fFromPoint), fIRegion(cluster.fIRegion), fHitList(TClonesArray(cluster.fHitList))
36 // {
37 // // *this = cluster;
38 // }
39 
40 PndTrkCluster::PndTrkCluster(const PndTrkCluster &cluster) : TObject(cluster), fFromPoint(0., 0., 0.), fIRegion(-1), fHitList(TClonesArray("PndTrkHit", 10000)) {
41  *this = cluster;
42 }
43 
45  // fHitList.Clear();
46  fHitList.Delete();
47 }
48 
49 // operator equals
50 void PndTrkCluster::Clear(Option_t* opt) {
51  fHitList.Clear(opt);
52 }
53 
54 // operator equals
56  fFromPoint = cluster.fFromPoint;
57  fIRegion = cluster.fIRegion;
58  fHitList = cluster.fHitList;
59  return *this;
60 }
61 
62 
64  // return hitlist.GetEntriesFast() == cluster.GetNofHits(); // CHECK
65  return fHitList.GetEntriesFast() == cluster.GetNofHits(); // CHECK
66 
67 }
68 
69 
71  // hitlist.Add(hit);
72  hit->SetUsedFlag(1); // CHECK
73  int size = fHitList.GetEntriesFast();
74  new(fHitList[size]) PndTrkHit(*hit);
75 }
76 
78  // hitlist.Add(hit);
79  hit.SetUsedFlag(1); // CHECK
80  int size = fHitList.GetEntriesFast();
81  new(fHitList[size]) PndTrkHit(hit);
82 }
83 
84 
85 // CHECK if it works, never tried
87  hit->SetUsedFlag(0);
88  // hitlist.Remove(hit);
89  fHitList.Remove(hit);
90 }
91 
92 // CHECK if it works, never tried
94  DeleteHit(hit);
95  // hitlist.Compress(); // CHECK
96  fHitList.Compress();
97 }
98 
99 // CHECK if it works, never tried
100 void PndTrkCluster::DeleteHit(Int_t index) {
101  //PndTrkHit* hit = (PndTrkHit*) fHitList.At(index); //[R.K. 01/2017] unused variable
102 // hitlist.RemoveAt(index);
103 // hitlist.Compress(); // CHECK
104  fHitList.RemoveAt(index);
105  fHitList.Compress(); // CHECK
106 
107 }
108 
109 // CHECK if it works, never tried
111  DeleteHit(index);
112  // hitlist.Compress(); // CHECK
113  fHitList.Compress(); // CHECK
114 }
115 
117  for(int ihit = 0; ihit < GetNofHits(); ihit++) {
118  DeleteHit(ihit);
119  }
120  fHitList.Compress();
121  // hitlist.Compress();
122 }
123 
124 void PndTrkCluster::DeleteHits(std::vector< int > todelete) {
125  for(size_t ihit = 0; ihit < todelete.size(); ihit++) {
126  int hitno = todelete[ihit];
127  DeleteHit(hitno);
128  }
129  // hitlist.Compress();
130  fHitList.Compress();
131 }
132 
133 // =========================== GET DETECTOR SPECIFIC HIT LIST ============================
134 
136  PndTrkCluster cluster;
137  for(int ihit = 0; ihit < GetNofHits(); ihit++) {
138  // PndTrkHit *hit = (PndTrkHit*) hitlist[ihit];
139  PndTrkHit *hit = (PndTrkHit*) fHitList.At(ihit);
140  if(hit->IsMvdStrip()) {
141  cluster.AddHit(hit);
142  cluster.SetIRegion(MVDSTRIP);
143  // cout << "found one" << hit->GetHitID() << endl;
144  }
145  }
146  return cluster;
147 }
148 
150  PndTrkCluster cluster;
151  for(int ihit = 0; ihit < GetNofHits(); ihit++) {
152  // PndTrkHit *hit = (PndTrkHit*) hitlist[ihit];
153  PndTrkHit *hit = (PndTrkHit*) fHitList.At(ihit);
154  if(hit->IsMvdPixel()) {
155  cluster.AddHit(hit);
156  cluster.SetIRegion(MVDPIXEL);
157  // cout << "found one" << hit->GetHitID() << endl;
158  }
159  }
160  return cluster;
161 }
162 
164  PndTrkCluster cluster;
165  for(int ihit = 0; ihit < GetNofHits(); ihit++) {
166  // PndTrkHit *hit = (PndTrkHit*) hitlist[ihit];
167  PndTrkHit *hit = (PndTrkHit*) fHitList.At(ihit);
168  if(hit->IsMvd()) {
169  cluster.AddHit(hit);
170  cluster.SetIRegion(hit->GetIRegion());
171  // cout << "found one" << hit->GetHitID() << endl;
172  }
173  }
174  return cluster;
175 }
176 
178  PndTrkCluster cluster;
179  for(int ihit = 0; ihit < GetNofHits(); ihit++) {
180  // PndTrkHit *hit = (PndTrkHit*) hitlist[ihit];
181  PndTrkHit *hit = (PndTrkHit*) fHitList.At(ihit);
182  if(hit->IsSttParallel()) {
183  cluster.AddHit(hit);
184  cluster.SetIRegion(hit->GetIRegion());
185  // cout << "found one" << hit->GetHitID() << endl;
186  }
187  }
188  return cluster;
189 }
190 
192 {
193  PndTrkCluster cluster;
194  for(int ihit = 0; ihit < GetNofHits(); ihit++) {
195  // PndTrkHit *hit = (PndTrkHit*) hitlist[ihit];
196  PndTrkHit *hit = (PndTrkHit*) fHitList.At(ihit);
197  if(hit->IsSttSkew()) {
198  cluster.AddHit(hit);
199  cluster.SetIRegion(hit->GetIRegion());
200  // cout << "found one" << hit->GetHitID() << endl;
201  }
202  }
203  return cluster;
204 }
205 
207  {
208  PndTrkCluster cluster;
209  for(int ihit = 0; ihit < GetNofHits(); ihit++) {
210  // PndTrkHit *hit = (PndTrkHit*) hitlist[ihit];
211  PndTrkHit *hit = (PndTrkHit*) fHitList.At(ihit);
212  if(hit->IsStt()) {
213  cluster.AddHit(hit);
214  cluster.SetIRegion(hit->GetIRegion());
215  // cout << "found one" << hit->GetHitID() << endl;
216  }
217  }
218  return cluster;
219 }
220 // =======================================================================
221 
222 
223 // finds the first instance of the hit in the cluster (there should be only one!)
225  // return (PndTrkHit*) hitlist.FindObject(hit);
226  return (PndTrkHit*) fHitList.FindObject(hit);
227 }
228 
229 
230 // ==================== V SHAPED CLUSTER ===============
231 // finds the extremities (first/last) of the cluster
232 // -------------------------------------------------
233 // considering the distance from the point frompoint;
234 // an extremity is a hit with only one neighbour.
235 // checks if there are correctly 2 extremities only (-> kTRUE)
236 // if there are 0 extremities -> CHECK (-> kFALSE)
237 // if there are >2 extremities -> CHECK (-> kFALSE)
238 Bool_t PndTrkCluster::FindExtremitiesFrom(TVector3 frompoint, PndTrkHit &firstextremity, PndTrkHit &secondextremity) {
239  const int nhits = MAXNOFHITSINCLUSTER; // hitlist.size(); // CHECK
240  int associations[nhits] = {0};
241  for(int ihit = 0; ihit < GetNofHits(); ihit++) {
242  // PndTrkHit *hit1 = (PndTrkHit*) hitlist[ihit];
243  PndTrkHit *hit1 = (PndTrkHit*) fHitList.At(ihit);
244  for(int jhit = 0; jhit < GetNofHits(); jhit++) {
245  if(ihit == jhit) continue;
246  // PndTrkHit *hit2 = (PndTrkHit*) hitlist[jhit];
247  PndTrkHit *hit2 = (PndTrkHit*) fHitList.At(jhit);
248 
249  if(hit1->GetXYDistance(hit2) < STTPARALDISTANCE) {
250  associations[ihit]++;
251  }
252  }
253  }
254 
255  int counter = 0;
256  Double_t tmpdistance1 = 1000, tmpdistance2 = -1;
257 
258  for(int ihit = 0; ihit < GetNofHits(); ihit++) {
259  if(associations[ihit] != 1) continue;
260  counter++;
261  // PndTrkHit *hit = (PndTrkHit*) hitlist[ihit];
262  PndTrkHit *hit = (PndTrkHit*) fHitList.At(ihit);
263  double distance = hit->GetXYDistance(frompoint);
264  if(distance < tmpdistance1) {
265  tmpdistance1 = distance;
266  firstextremity = *hit;
267  }
268 
269  if(distance > tmpdistance2) {
270  tmpdistance2 = distance;
271  secondextremity = *hit;
272  }
273  }
274 
275  if(counter == 2) return kTRUE;
276 
277  if(counter == 0) cout << "NO EXTREMITY FOUND :-(" << endl;
278  if(counter > 2) cout << "TOO MANY EXTREMITIES FOUND :-( " << counter << endl;
279  return kFALSE;
280 }
281 
282 // checks if the cluster is V shaped:
283 // ----------------------------------
284 // it is run only when the distances between each of the two
285 // found extremities and the frompoint are too similar.
286 // It computes the poca to frompoint and a circle which passes
287 // among poca, firstextremity and secondextremity, then it
288 // checks the distance of each hit from this circle and if
289 // too many are too distant it means the cluster has V shape.
290 Bool_t PndTrkCluster::CheckClusterAgainsV(TVector3 frompoint, PndTrkHit *firstextremity, PndTrkHit *secondextremity) {
291 
292  if(fabs(firstextremity->GetPosition().Perp() - secondextremity->GetPosition().Perp()) < 2) {
293  cout << "WARNING, V detected?" << endl;
294 
295  if(firstextremity == NULL || secondextremity == NULL) {
296  cout << "NULL POINTER" << endl;
297  return kFALSE;
298  }
299 
300  if(*firstextremity == *secondextremity) {
301  cout << "COINCIDENT EXTREMITIES" << endl; // CHECK
302  return kFALSE;
303  }
304 
305 
306  PndTrkHit *pca = GetPocaTo(frompoint);
307  if(*pca == *firstextremity || *pca == *secondextremity) {
308  cout << "POCA COINCIDENT TO ONE OF THE EXTREMITIES" << endl; // CHECK
309  return kFALSE;
310  }
311 
312  Double_t x0, y0, radius = -1;
313  Bool_t computation = ComputeCircle(firstextremity->GetPosition(), secondextremity->GetPosition(), pca->GetPosition(), x0, y0, radius);
314  if(!computation) {
315  cout << "TWO POINTS ALIGNED" << endl;
316  return kFALSE;
317  }
318  cout << "circle " << x0 << " " << y0 << " " << radius << endl;
319 
320  int counter = 0;
321  for(int ihit = 0; ihit < GetNofHits(); ihit++) {
322  // PndTrkHit *hit = (PndTrkHit*) hitlist[ihit];
323  PndTrkHit *hit = (PndTrkHit*) fHitList.At(ihit);
324  if(fabs( hit->GetXYDistance(TVector3(x0, y0, 0.)) - radius) > 2) counter++;
325  }
326 
327  if(GetNofHits() - counter < 3) cout << "***************** YES ***************** " << counter << " on " << GetNofHits() << endl;
328  else cout << " ********************** NO ******************* " << counter << " " << GetNofHits() << endl;
329  return kTRUE;
330 
331  }
332  // else cout << " DISTANCE " << fabs(firstextremity->GetPosition().Perp() - secondextremity->GetPosition().Perp()) << endl;
333 
334  return kFALSE;
335 }
336 
337 // CHECK if it works now
339 
340  // PndTrkHit *tmphit = (PndTrkHit*) hitlist[0];
341  PndTrkHit *tmphit = (PndTrkHit*) fHitList.At(0);
342 
343  cluster1.AddHit(athit);
344  cluster2.AddHit(athit);
345  TVector3 tmpposition = athit->GetPosition();
346  PndTrkHit *secondhit = NULL;
347 
348  cout << "CLUS1: " << tmphit->GetHitID() << endl;
349  for(int ihit = 0; ihit < GetNofHits(); ihit++) {
350  // PndTrkHit *hit = (PndTrkHit*) hitlist[ihit];
351  PndTrkHit *hit = (PndTrkHit*) fHitList.At(ihit);
352  if(*hit == *athit) {
353  cout << "hit == ahit " << endl;
354  continue;
355  }
356  cout << "*** " << hit->GetHitID() << " " << hit->GetXYDistance(tmpposition) << " " << STTPARALDISTANCE << endl;
357  if(hit->GetXYDistance(tmpposition) < STTPARALDISTANCE) { // CHECK
358  cluster1.AddHit(hit);
359  tmpposition = hit->GetPosition();
360  if(secondhit == NULL) {
361  cout << "secondhit " << endl;
362  secondhit = hit;
363  }
364  else cout << "sechit " << secondhit << endl;
365  cout << "CLUS1: " << hit->GetHitID() << endl;
366 
367  }
368  }
369 
370  cout << "CLUS2: " << tmphit->GetHitID() << endl;
371 
372  tmpposition = athit->GetPosition();
373  for(int ihit = 0; ihit < GetNofHits(); ihit++) {
374  // PndTrkHit *hit = (PndTrkHit*) hitlist[ihit];
375  PndTrkHit *hit = (PndTrkHit*) fHitList.At(ihit);
376  cout << "athit " << athit << endl;
377  cout << "hit " << hit << endl;
378  cout << "secondhit " << secondhit << endl;
379  if(*hit == *athit) continue;
380  if(*hit == *secondhit) continue;
381 
382  if(hit->GetXYDistance(tmpposition) < STTPARALDISTANCE) { // CHECK
383  cluster2.AddHit(hit);
384  tmpposition = hit->GetPosition();
385  cout << "CLUS2: " << hit->GetHitID() << endl;
386  }
387  }
388 
389  return kTRUE;
390 }
391 // CHECK??
392 // splits the V shaped cluster at the point athit
393 // ----------------------------------------------
394 // starts from one extremity and stops @ athit,
395 // the same for the other extremity.
396 Bool_t PndTrkCluster::SplitV(PndTrkHit *athit, PndTrkHit *firstextremity, PndTrkHit* secondextremity, PndTrkCluster &cluster1, PndTrkCluster &cluster2) {
397  // cout << "splitV" << endl;
398 
399 
400  cluster1.AddHit(firstextremity);
401  cluster2.AddHit(secondextremity);
402  cluster1.SetIRegion(fIRegion);
403  cluster2.SetIRegion(fIRegion);
404 
405  TVector3 tmpposition = firstextremity->GetPosition();
406 
407  PndTrkHit *hit = NULL, *tmphit = firstextremity;
408 
409 
410  // cout << "first " << firstextremity->GetHitID() << endl;
411  // cout << "lat " << secondextremity->GetHitID() << endl;
412  // cout << "athit " << athit->GetHitID() << endl;
413  // cout << endl;
414 
415  // cluster1.Print();
416  // cluster2.Print();
417  for(int iclus = 0; iclus < 2; iclus++) {
418  // cout << "iclus " << iclus << endl;
419  // cluster2.Print();
420  // set all unused
421  for(int ihit = 0; ihit < GetNofHits(); ihit++) {
422  // hit = (PndTrkHit*) hitlist[ihit];
423  hit = (PndTrkHit*) fHitList.At(ihit);
424  hit->SetUsedFlag(kFALSE);
425  }
426 
427 
428  hit = NULL;
429 
430  if(iclus == 1) {
431  tmpposition = secondextremity->GetPosition();
432  tmphit = secondextremity;
433  }
434 
435  double tmpdistance2 = 1000;
436  while(!hit || (hit && (hit->GetPosition() - athit->GetPosition()).Perp() > STTPARALDISTANCE)) {
437  // if(!hit) cout << "here!" << endl;
438  // if(hit) cout << "here " << (hit->GetPosition() - athit->GetPosition()).Perp() << endl;
439  for(int ihit = 0; ihit < GetNofHits(); ihit++) {
440  // hit = (PndTrkHit*) hitlist[ihit];
441  hit = (PndTrkHit*) fHitList.At(ihit);
442 
443  // if(hit->IsUsed()) continue;
444  // cout << "test " << hit->GetHitID() << " " << hit->GetDistance(tmpposition) << endl;
445  cout << (*hit == *firstextremity) << " " << (*hit == *secondextremity) << " " << (*hit == *tmphit) << endl;
446 
447  // CHECK SearchHit
448  if((iclus == 0 && cluster1.SearchHit(hit) != 0) || (iclus == 1 && cluster2.SearchHit(hit) != 0)) {
449  cout << hit->GetHitID() << " is already there .................." << endl;
450  continue;
451  }
452  if(*hit == *firstextremity || *hit == *secondextremity || *hit == *tmphit) continue;
453 
454  if(hit->GetXYDistance(tmpposition) < STTPARALDISTANCE && (hit->GetPosition() - athit->GetPosition()).Perp() < tmpdistance2) { // CHECK
455  // cout << "add " << hit->GetHitID() << " to cluster " << iclus + 1 << endl;
456  if(iclus == 0) cluster1.AddHit(hit);
457  else cluster2.AddHit(hit);
458  hit->SetUsedFlag(kTRUE);
459  tmpposition = hit->GetPosition();
460  tmphit = hit;
461  tmpdistance2 = (hit->GetPosition() - athit->GetPosition()).Perp();
462  break;
463  }
464  }
465  }
466  cout << endl;
467  }
468  cout << "here2" << endl;
469 
470  // add the common hit
471  cluster1.AddHit(athit);
472  cluster2.AddHit(athit);
473 
474  if(cluster1.GetNofHits() == 0 || cluster2.GetNofHits() == 0) return kFALSE; // CHECK!!!!!!!!!!!!!!!!!
475 
476 
477 
478  // set the fUsed flags to true for all used hits
479  for(int ihit = 0; ihit < cluster1.GetNofHits(); ihit++) (cluster1.GetHit(ihit))->SetUsedFlag(kTRUE);
480  for(int ihit = 0; ihit < cluster2.GetNofHits(); ihit++) (cluster2.GetHit(ihit))->SetUsedFlag(kTRUE);
481 
482  return kTRUE;
483 }
484 
485 // =======================================================================================
486 
487 
489 
490  // cout << "------------------------------------ sorting" << endl;
491  fFromPoint = firstextremity->GetPosition();
492  PndTrkHit *hit;
493  for(int ihit = 0; ihit < GetNofHits(); ihit++) {
494  // hit = (PndTrkHit*) hitlist[ihit];
495  hit = (PndTrkHit*) fHitList[ihit];
496 
497  if(criterion.CompareTo("xydistance") == 0) { // CHECK
498  double distance = hit->GetDistance(fFromPoint);
499  // cout << "distance " << distance << endl;
500  hit->SetSortVariable(distance);
501  }
502 
503  }
504  // sorting
505  Sort() ;
506 }
507 
509 {
510  // CHECK each TObject must return IsSortable = kTRUE
511 
512  fHitList.UnSort();
513  // hitlist.Sort();
514  fHitList.Sort();
515 
516 
517 }
518 
520 {
521  // CHECK each TObject must return IsSortable = kTRUE
522  PndTrkHit *hit;
523  for(int ihit = 0; ihit < GetNofHits(); ihit++) {
524  // hit = (PndTrkHit* ) hitlist[ihit];
525  hit = (PndTrkHit* ) fHitList[ihit];
526 
527  int srt = hit->GetSortVariable();
528  hit->SetSortVariable(-srt);
529  }
530  // hitlist.Sort();
531  fHitList.Sort();
532 
533  // reput the sort variable as they were before
534  for(int ihit = 0; ihit < GetNofHits(); ihit++) {
535  hit = (PndTrkHit* ) fHitList[ihit];
536  int srt = hit->GetSortVariable();
537  hit->SetSortVariable(-srt);
538  }
539 
540 }
541 // =======================================================================================
542 // MERGE CLUSTERS
543 
545  for(int ihit = 0; ihit < cluster->GetNofHits(); ihit++) {
546  PndTrkHit *hit = cluster->GetHit(ihit);
547  AddHit(hit);
548  }
549 
550  TString iregion1;
551  iregion1 += fIRegion;
552  TString iregion2;
553  iregion2 += cluster->GetIRegion();
554 }
555 
557 
558  fFromPoint = frompoint;
559  PndTrkHit *hit;
560 
561  for(int ihit = 0; ihit < cluster->GetNofHits(); ihit++) {
562  hit = cluster->GetHit(ihit);
563  AddHit(hit);
564  }
565 
566  for(int ihit = 0; ihit < GetNofHits(); ihit++) {
567  hit = (PndTrkHit* ) fHitList[ihit];
568  // hit = (PndTrkHit* ) hitlist[ihit];
569  if(criterion.CompareTo("xydistance") == 0) { // CHECK
570  double distance = hit->GetDistance(fFromPoint);
571  // cout << "distance " << distance << endl;
572  hit->SetSortVariable(distance);
573  }
574  }
575  // sorting
576  Sort();
577 
578 
579 }
580 
581 
582 // =======================================================================================
583 PndTrkHit * PndTrkCluster::GetPocaTo(TVector3 frompoint) {
584  // cout << "getPocaTo" << endl;
585  Double_t tmpdistance = 1000;
586 
587  // PndTrkHit *tmphit = (PndTrkHit* ) hitlist[0];
588  PndTrkHit *tmphit = (PndTrkHit* ) fHitList[0];
589 
590  for(int ihit = 0; ihit < GetNofHits(); ihit++) {
591  // PndTrkHit *hit = (PndTrkHit* ) hitlist[ihit];
592  PndTrkHit *hit = (PndTrkHit* ) fHitList[ihit];
593 
594  double distance = hit->GetXYDistance(frompoint);
595  if(distance < tmpdistance) {
596  tmpdistance = distance;
597  tmphit = hit;
598  }
599  }
600  return tmphit;
601 }
602 
603 Bool_t PndTrkCluster::ComputeCircle(TVector3 v1, TVector3 v2, TVector3 v3, double &x0, double &y0, double &R) {
604 
605  Double_t d1 = 2 * (v1 - v2).X();
606  Double_t d2 = 2 * (v1 - v3).X();
607 
608  Double_t n1 = (v1 - v2).Y();
609  Double_t n2 = (v1 - v3).Y();
610 
611  Double_t m1 = v1.Mag2() - v2.Mag2();
612  Double_t m2 = v1.Mag2() - v3.Mag2();
613 
614  if((d2 * n1 - d1 * n2) == 0) {
615  cout << "allineati" << endl;
616  return kFALSE;
617  }
618 
619  y0 = 0.5 * (d2 * m1 - d1 * m2) / (d2 * n1 - d1 * n2);
620  if(d1 != 0) x0 = (m1 - 2 * n1 * y0)/d1;
621  else x0 = (m2 - 2 * n2 * y0)/d2;
622 
623  R = (v1 - TVector3(x0, y0, 0)).Mag();
624  return kTRUE;
625 }
626 // =======================================================================================
628  //bool isthere = false; //[R.K. 01/2017] unused variable
629  // if(hitlist.FindObject(hit) == 0) return kFALSE;
630  if(fHitList.FindObject(hit) == 0) return kFALSE;
631  return kTRUE;
632 
633 }
634 
635 
637  PndTrkHit *oldhit = (PndTrkHit*) SearchHit(hit);
638  // cout << "oldhit " << oldhit << " " << hit << endl;
639  DeleteHitAndCompress(oldhit);
640  AddHit(hit);
641 }
642 
644  // cout << index << " hitlist " << hitlist.GetEntriesFast() << " " << hitlist.GetEntries() << endl;
645  // cout << hitlist.At(index) << endl;
646 
647  // return (PndTrkHit*) hitlist.At(index);
648  return (PndTrkHit*) fHitList.At(index);
649 }
650 
652  if(index == 0) return NULL;
653  // return (PndTrkHit*) hitlist[index - 1];
654  return (PndTrkHit*) fHitList.At(index - 1);
655 }
656 
658  if(index == GetNofHits() - 1) return NULL;
659  // return (PndTrkHit*) hitlist[index + 1];
660  return (PndTrkHit*) fHitList.At(index + 1);
661 }
662 
663 
664 
666  int similarity = NofSharedHits(cluster2);
667  if(((double) similarity/GetNofHits()) > 0.5 || ((double) similarity/cluster2->GetNofHits()) > 0.5) return kTRUE;
668  return kFALSE;
669 }
670 
672  int similarity = 0;
673 // cout << "GetNofHits " << GetNofHits() << endl;
674  for(int ihit = 0; ihit < GetNofHits(); ihit++) {
675  PndTrkHit *hit = (PndTrkHit*) fHitList.At(ihit);
676  if(cluster2->DoesContain(hit)) {
677 // cout << hit->GetDetectorID() << " " << hit->GetHitID() << " simile" << endl;
678  similarity++;
679  }
680  }
681  // cout << "similarity " << similarity << endl;
682  return similarity;
683 }
684 
686  int similarity = NofSharedHits(cluster2);
687 // cout << "similarity " << similarity << " on " << GetNofHits() << " and " << cluster2->GetNofHits() << endl;
688 
689  if(((double) similarity/GetNofHits()) > limit || ((double) similarity/cluster2->GetNofHits()) > limit) return kTRUE;
690  return kFALSE;
691 }
692 
693 
694 
696 
697  std::vector<int> tobeadded;
698  for(int ihit = 0; ihit < cluster2->GetNofHits(); ihit++) {
699  PndTrkHit *hit = cluster2->GetHit(ihit);
700  if(DoesContain(hit)) continue;
701  tobeadded.push_back(ihit);
702  }
703 
704  for(size_t ihit = 0; ihit < tobeadded.size(); ihit++) {
705  int hitno = tobeadded.at(ihit);
706  PndTrkHit *hit = cluster2->GetHit(hitno);
707  AddHit(hit);
708  }
709 
710  Sort();
711  return GetNofHits();
712 }
713 
714 
715 
716 
718  double distance = 1000000;
719  // cout << " from hit " << hit->GetHitID() << " " << hit->GetDetectorID() << endl;
720 
721  for(int ihit = 0; ihit < GetNofHits(); ihit++) {
722  PndTrkHit *clushit = GetHit(ihit);
723  double tmpdistance = hit->GetXYDistance(clushit);
724  if(tmpdistance < distance) {
725  distance = tmpdistance;
726  // cout << " new minimum " << clushit->GetHitID() << " " << clushit->GetDetectorID() << endl;
727  }
728  }
729  return distance;
730 }
731 
732 
733 // PndTrkCluster PndTrkCluster::MergeTo(PndTrkCluster cluster2) {
734 // std::vector<int> tobeadded;
735 // for(int ihit = 0; ihit < GetNofHits(); ihit++) {
736 // PndTrkHit *hit = (PndTrkHit*) hitlist[ihit];
737 // if(cluster2.DoesContain(hit)) continue;
738 // tobeadded.push_back(ihit);
739 // }
740 
741 // for(int ihit = 0; ihit < tobeadded.size(); ihit++) {
742 // int hitno = tobeadded.at(ihit);
743 // cluster2.AddHit((PndTrkHit*) hitlist[hitno]);
744 // }
745 // return cluster2;
746 
747 // }
748 
750  cout << "###############################" << endl;
751  cout << "iregion " << fIRegion << " with nhits " << GetNofHits() << endl;
752  for(int ihit = 0; ihit < GetNofHits(); ihit++) {
753  // PndTrkHit *hit = (PndTrkHit*) hitlist[ihit];
754  PndTrkHit *hit = (PndTrkHit*) fHitList.At(ihit);
755  cout << " " << hit->GetHitID() << " " << hit->GetDetectorID() << " " << hit->GetSortVariable() << endl;
756  }
757 }
758 
760  for(int ihit = 0; ihit < GetNofHits(); ihit++) {
761  PndTrkHit *hit = GetHit(ihit);
762  cout << " " << hit->GetHitID();
763  }
764  cout << endl;
765 }
766 
767 
768 
769 void PndTrkCluster::Draw(Color_t color) {
770  // cout << "S: " << hitlist.size() << endl;
771  for(int ihit = 0; ihit < GetNofHits(); ihit++) {
772  // PndTrkHit *hit = (PndTrkHit*) hitlist[ihit];
773  PndTrkHit *hit = (PndTrkHit*) fHitList.At(ihit);
774  hit->Draw(color);
775  }
776 }
777 
779  Draw(kOrange); // Yellow);
780 }
781 
782 
783 
785 
Double_t x0
Definition: checkhelixhit.C:70
Bool_t SharedAt(PndTrkCluster *cluster2, double limit)
PndTrkCluster GetMvdHitList()
void Replace(PndTrkHit *hit)
PndTrkCluster GetSttHitList()
PndTrkHit * SearchHit(PndTrkHit *hit)
Bool_t SplitAtHit(PndTrkHit *athit, PndTrkCluster &cluster1, PndTrkCluster &cluster2)
Bool_t ComputeCircle(TVector3 v1, TVector3 v2, TVector3 v3, double &x0, double &y0, double &R)
void AddClusterAndSortFrom(PndTrkCluster *cluster, TVector3 frompoint, TString criterion)
void Draw(Color_t color=kBlack)
Bool_t operator==(const PndTrkCluster cluster) const
int MergeTo(PndTrkCluster *cluster2)
void DeleteHitAndCompress(PndTrkHit *hit)
Double_t GetMinimumXYDistanceFromHit(PndTrkHit *hit)
PndTrkCluster GetSttSkewHitList()
void SetSortVariable(Double_t sortvar)
Definition: PndTrkHit.h:44
void AddHit(PndTrkHit *hit)
Bool_t IsMvdPixel()
Definition: PndTrkHit.h:75
double Y
Definition: anaLmdDigi.C:68
PndTrkHit * GetNextHit(int index)
void SetIRegion(int iregion)
Definition: PndTrkCluster.h:46
PndTrkHit * GetHit(int index)
Bool_t IsMvdStrip()
Definition: PndTrkHit.h:76
Int_t GetHitID()
Definition: PndTrkHit.h:56
Bool_t IsSttParallel()
Definition: PndTrkHit.h:70
Bool_t IsMvd()
Definition: PndTrkHit.h:77
void DeleteHit(PndTrkHit *hit)
TString m2(TString pts, TString exts="e px py pz")
Definition: invexp.C:117
Int_t GetIRegion()
Definition: PndTrkHit.h:64
void SortFromHit(PndTrkHit *firstextremity, TString criterion)
Int_t NofSharedHits(PndTrkCluster *cluster2)
Int_t GetDetectorID()
Definition: PndTrkHit.h:57
#define MVDSTRIP
int counter
Definition: ZeeAnalysis.C:59
PndTrkCluster GetSttParallelHitList()
void DeleteHits(std::vector< int > todelete)
#define MAXNOFHITSINCLUSTER
Definition: PndTrkCluster.h:17
void Clear(Option_t *="")
void SetUsedFlag(Bool_t used)
Definition: PndTrkHit.h:50
Double_t
Bool_t IsSimilarTo(PndTrkCluster *cluster2)
Double_t GetDistance(PndTrkHit *fromhit)
Definition: PndTrkHit.cxx:83
#define STTPARALDISTANCE
Double_t y0
Definition: checkhelixhit.C:71
TVector3 GetPosition()
Definition: PndTrkHit.h:62
friend F32vec4 fabs(const F32vec4 &a)
Definition: P4_F32vec4.h:47
PndTrkHit * GetPreviousHit(int index)
double X
Definition: anaLmdDigi.C:68
void AddCluster(PndTrkCluster *cluster)
Int_t GetIRegion()
Definition: PndTrkCluster.h:53
PndTrkCluster GetMvdPixelHitList()
PndTrkHit * GetPocaTo(TVector3 frompoint)
Bool_t FindExtremitiesFrom(TVector3 frompoint, PndTrkHit &firstextremity, PndTrkHit &secondextremity)
TVector3 fFromPoint
void Draw(Color_t color)
Definition: PndTrkHit.cxx:109
Bool_t DoesContain(PndTrkHit *hit)
Bool_t SplitV(PndTrkHit *athit, PndTrkHit *firstextremity, PndTrkHit *secondextremity, PndTrkCluster &cluster1, PndTrkCluster &cluster2)
Double_t GetXYDistance(PndTrkHit *fromhit)
Definition: PndTrkHit.cxx:94
TVector3 v1
Definition: bump_analys.C:40
PndTrkCluster & operator=(const PndTrkCluster &cluster)
Bool_t IsStt()
Definition: PndTrkHit.h:72
ClassImp(PndAnaContFact)
TVector3 v2
Definition: bump_analys.C:40
Double_t GetSortVariable()
Definition: PndTrkHit.h:66
Bool_t SorterFunction(PndTrkHit *hit1, PndTrkHit *hit2)
TClonesArray fHitList
PndSdsMCPoint * hit
Definition: anasim.C:70
#define MVDPIXEL
Int_t GetNofHits()
Definition: PndTrkCluster.h:52
double limit
Definition: dedx_bands.C:18
Double_t R
Definition: checkhelixhit.C:61
PndTrkCluster GetMvdStripHitList()
Bool_t IsSttSkew()
Definition: PndTrkHit.h:71
Bool_t CheckClusterAgainsV(TVector3 frompoint, PndTrkHit *firstextremity, PndTrkHit *secondextremity)