FairRoot/PandaRoot
PndMdtTrkFinder.cxx
Go to the documentation of this file.
1 // -------------------------------------------------------------------------
2 // ----- PndMdtTrkFinder source file -----
3 // ----- Created 16/06/08 by S.Spataro -----
4 // -------------------------------------------------------------------------
5 
6 #include "PndMdtTrkFinder.h"
7 #include "PndMdtMuonFilter.h"
9 #include "PndMdtTrk.h"
10 #include "PndMdtHit.h"
11 #include "PndTrack.h"
12 #include "PndDetectorList.h"
13 
14 #include "FairRootManager.h"
15 #include "FairRun.h"
16 #include "FairRunAna.h"
17 #include "FairRuntimeDb.h"
18 #include "FairTrackParH.h"
19 
20 #include "TVector3.h"
21 #include "TMath.h"
22 #include "TClonesArray.h"
23 #include "TGeoManager.h"
24 #include "TGeoVolume.h"
25 #include "TGeoBBox.h"
26 #include "TGeoMatrix.h"
27 #include <iostream>
28 
29 using std::cout;
30 using std::endl;
31 
32 // ----- Default constructor -------------------------------------------
34  FairTask(" MDT Tracklet Finder") {
35 }
36 // -------------------------------------------------------------------------
37 
38 // ----- Destructor ----------------------------------------------------
40 // -------------------------------------------------------------------------
41 
42 
43 
44 // ----- Public method Init --------------------------------------------
45 InitStatus PndMdtTrkFinder::Init() {
46  cout << "-I- PndMdtTrkFinder::Init: "
47  << "INITIALIZATION *********************" << endl;
48 
49  //FairRun* sim = FairRun::Instance(); //[R.K. 01/2017] unused variable?
50  //FairRuntimeDb* rtdb=sim->GetRuntimeDb(); //[R.K. 01/2017] unused variable?
51 
52  // Get RootManager
53  FairRootManager* ioman = FairRootManager::Instance();
54  if ( ! ioman ) {
55  cout << "-E- PndMdtTrkFinder::Init: "
56  << "RootManager not instantiated!" << endl;
57  return kFATAL;
58  }
59 
60  fHitArray = (TClonesArray*) ioman->GetObject("MdtHit");
61  if ( ! fHitArray ) {
62  cout << "-W- PndMdtTrkFinder::Init: "
63  << "No MdtHit array!" << endl;
64  return kERROR;
65  }
66 
67  // Create and register output array
68  fTrkArray = new TClonesArray("PndMdtTrk");
69 
70  ioman->Register("MdtTrk","Mdt",fTrkArray,kTRUE);
71 
72  cout << "-I- PndMdtTrkFinder: Intialization successfull" << endl;
73 
74  return kSUCCESS;
75 
76 }
77 // -------------------------------------------------------------------------
78 
79 //______________________________________________________
81 
82  // Get run and runtime database
83  FairRun* run = FairRun::Instance();
84  if ( ! run ) Fatal("PndMdtTrkFinder:: SetParContainers", "No analysis run");
85 
86  FairRuntimeDb* db = run->GetRuntimeDb();
87  if ( ! db ) Fatal("PndMdtTrkFinder:: SetParContainers", "No runtime database");
88 
89  // Get Mdt Reconstruction parameter container
90  //fRecoPar = (PndMdtRecoPar*) db->getContainer("PndMdtRecoPar");
91 
92 }
93 
94 //______________________________________________________
95 
96 // ----- Public method Exec --------------------------------------------
97 void PndMdtTrkFinder::Exec(Option_t*)
98 {
99  // Reset output array
100  fTrkArray->Delete();
101 
102  std::vector<PndMdtTrk*> fTrklets;
103  std::vector<PndMdtTrk*>::iterator tit = fTrklets.begin();
104  std::vector<PndMdtTrk*>::iterator tnd = fTrklets.end();
105  std::map<unsigned long, std::vector<PndMdtHit*> > fTrkHitMap;
106  //
107  Int_t nHits = fHitArray->GetEntriesFast();
108 
109  for(Int_t ihit=0; ihit < nHits; ++ ihit)
110  {
111  PndMdtHit* aHit = (PndMdtHit*)fHitArray->At(ihit);
112 
113  Bool_t NotUsed = kTRUE;
114  for( ; tit != tnd; ++tit){
115  //PndMdtTrk* aTrk = *tit; //[R.K. 01/2017] unused variable?
116 
117  }
118 
119  if(NotUsed){
120  PndMdtTrk* aTrk = new PndMdtTrk();
121  unsigned long fPointer = (unsigned long) aTrk;
122  fTrkHitMap[fPointer].push_back(aHit);//a track and its hits
123  fTrklets.push_back(aTrk);
124  }
125  }
126 }
127 
128 // ----- Private method MdtMapping --------------------------------------------
129 
130 // ----- Private method AddTrk --------------------------------------------
132  // Creates a new hit in the TClonesArray.
133 
134  // Float_t chi2=0;
135  // for (Int_t ll=1; ll<10; ll++)
136  // {
137  // if (track->GetHitBit(ll)==0) continue;
138  // if (ll==1)
139  // chi2 = chi2 + (track->GetHit(ll)/1.5)*(track->GetHitAngle(ll)/1.5); // manual correction for the first layer
140  // else
141  // chi2 = chi2 + track->GetHitAngle(ll)*track->GetHitAngle(ll);
142  // }
143  // track->SetChi2(chi2);
144 
145  TClonesArray& trkRef = *fTrkArray;
146  Int_t size = trkRef.GetEntriesFast();
147  return new(trkRef[size]) PndMdtTrk(*track);
148 }
149 
150 
151 
TClonesArray * fHitArray
Int_t run
Definition: autocutx.C:47
virtual void Exec(Option_t *opt)
int nHits
Definition: RiemannTest.C:16
PndMCTrack * track
Definition: anaLmdCluster.C:89
PndMdtTrk * AddTrk(PndMdtTrk *track)
virtual void SetParContainers()
ClassImp(PndAnaContFact)
TClonesArray * fTrkArray
virtual InitStatus Init()