er  dev
ERmuSiTrackFinder.cxx
1 #include "ERmuSiTrackFinder.h"
2 
3 #include <vector>
4 #include <iostream>
5 using namespace std;
6 
7 #include "TVector3.h"
8 #include "TMath.h"
9 
10 #include "FairRootManager.h"
11 #include "FairRunAna.h"
12 #include "FairRuntimeDb.h"
13 #include<iostream>
14 
15 #include "ERDetectorList.h"
16 #include "ERmuSiTrack.h"
17 #include "ERmuSiPoint.h"
18 
19 // ----------------------------------------------------------------------------
21  : FairTask("ER muSi track finding scheme")
22 {
23 }
24 // ----------------------------------------------------------------------------
25 
26 // ----------------------------------------------------------------------------
28  : FairTask("ER muSi track finding scheme ", verbose)
29 {
30 }
31 // ----------------------------------------------------------------------------
32 
33 // ----------------------------------------------------------------------------
35 {
36 }
37 // ----------------------------------------------------------------------------
38 
39 // ----------------------------------------------------------------------------
40 void ERmuSiTrackFinder::SetParContainers()
41 {
42  // Get run and runtime database
43  FairRunAna* run = FairRunAna::Instance();
44  if ( ! run ) Fatal("SetParContainers", "No analysis run");
45 
46  FairRuntimeDb* rtdb = run->GetRuntimeDb();
47  if ( ! rtdb ) Fatal("SetParContainers", "No runtime database");
48 }
49 // ----------------------------------------------------------------------------
50 
51 // ----------------------------------------------------------------------------
53 {
54  // Get input array
55  FairRootManager* ioman = FairRootManager::Instance();
56  if ( ! ioman ) Fatal("Init", "No FairRootManager");
57 
58  fmuSiHits = (TClonesArray*) ioman->GetObject("muSiHit");
59  //todo check
60 
61  // Register output array fmuSiHits
62  fmuSiTracks = new TClonesArray("ERmuSiTrack",1000);
63 
64  ioman->Register("muSiTrack", "muSi tracks", fmuSiTracks, kTRUE);
65 
66  return kSUCCESS;
67 }
68 // -------------------------------------------------------------------------
69 
70 // ----- Public method Exec --------------------------------------------
71 void ERmuSiTrackFinder::Exec(Option_t* opt)
72 {
73  Reset();
74  std::cout << std::endl;
75  std::cout << "ERmuSiTrackFinder:" << std::endl;
76  //Раскидываем хиты по станциям
77 
78  std::vector<ERmuSiHit*> HitsByStation[3];
79 
80  for (Int_t iHit = 0; iHit < fmuSiHits->GetEntriesFast(); iHit++){
81 
82  ERmuSiHit* hit = (ERmuSiHit*) fmuSiHits->At(iHit);
83  HitsByStation[hit->Station()].push_back(hit);
84  }
85 
86  for (std::vector<ERmuSiHit*>::iterator it0 = HitsByStation[0].begin(); it0 != HitsByStation[0].end(); ++it0 ){
87  for(std::vector<ERmuSiHit*>::iterator it1 = HitsByStation[1].begin(); it1 != HitsByStation[1].end(); ++it1){
88 
89  TVector3 singlet1((*it1)->GetX()-(*it0)->GetX(),(*it1)->GetY()-(*it0)->GetY(),(*it1)->GetZ()-(*it0)->GetZ());
90 
91  for(std::vector<ERmuSiHit*>::iterator it2 = HitsByStation[2].begin(); it2 != HitsByStation[2].end(); ++it2){
92 
93  TVector3 singlet2((*it2)->GetX()-(*it1)->GetX(),(*it2)->GetY()-(*it1)->GetY(),(*it2)->GetZ()-(*it1)->GetZ());
94 
95  Double_t angle = singlet2.Angle(singlet1);
96  if (angle < fAngleCut){
97  ERmuSiTrack* track = new((*fmuSiTracks)[fmuSiTracks->GetEntriesFast()])ERmuSiTrack();
98  track->AddHit(0,*(*it0));
99  track->AddHit(1,*(*it1));
100  track->AddHit(2,*(*it2));
101  }
102  }
103  }
104  }
105  std::cout << "Tracks count:" << fmuSiTracks->GetEntriesFast() << std::endl;
106 }
107 //----------------------------------------------------------------------------
108 
109 //----------------------------------------------------------------------------
111 {
112  if (fmuSiTracks) {
113  fmuSiTracks->Delete();
114  }
115 }
116 // ----------------------------------------------------------------------------
117 
118 // ----------------------------------------------------------------------------
120 {
121 
122 }
123 // ----------------------------------------------------------------------------
124 
125 //-----------------------------------------------------------------------------
126 ClassImp(ERmuSiTrackFinder)
virtual InitStatus Init()
TClonesArray * fmuSiHits
virtual void Exec(Option_t *opt)