18 #include "CbmMuchHit.h"
23 #include "CbmStsTrackMatch.h"
24 #include "CbmSttHit.h"
25 #include "CbmSttPoint.h"
26 #include "CbmSttTrack.h"
28 #include "FairRootManager.h"
30 #include "TClonesArray.h"
32 #include "TLorentzVector.h"
47 : FairTask(name, iVerbose) {
59 (TClonesArray*) FairRootManager::Instance()->GetObject(
"SttPoint");
60 fSttHits = (TClonesArray*) FairRootManager::Instance()->GetObject(
"SttHit");
62 (TClonesArray*) FairRootManager::Instance()->GetObject(
"MuchTrack");
64 (TClonesArray*) FairRootManager::Instance()->GetObject(
"StsTrack");
65 fMCTracks = (TClonesArray*) FairRootManager::Instance()->GetObject(
"MCTrack");
67 (TClonesArray*) FairRootManager::Instance()->GetObject(
"StsTrackMatch");
73 FairRootManager::Instance()->GetObject(
"PrimaryVertex."));
76 FairRootManager::Instance()->GetObject(
"PrimaryVertex"));
79 Error(
"CbmL1SttTrackFinder::ReInit",
"vertex not found!");
84 FairRootManager::Instance()->Register(
87 cout <<
" **************************************************" << endl;
89 cout <<
" *** Using Much tracks for Stt tracking *** " << endl;
91 cout <<
" *** Using Sts tracks for Stt tracking *** " << endl;
92 cout <<
" **************************************************" << endl;
102 const int MaxBranches = 50;
104 static bool first = 1;
106 static int EventCounter = 0;
108 cout <<
" SttRec event " << EventCounter << endl;
111 static const Int_t nStations =
CbmKF::Instance()->SttStationIDMap.size();
116 TDirectory* curdir = gDirectory;
117 histodir = gDirectory->mkdir(
"SttRec");
120 new TH1F(
"NBranches",
"N Branches", MaxBranches, 0, MaxBranches);
124 int NHits =
fSttHits->GetEntriesFast();
125 vector<CbmL1SttHit> vSttHits;
127 for (
int ih = 0; ih < NHits; ++ih) {
128 CbmSttHit*
h = (CbmSttHit*)
fSttHits->UncheckedAt(ih);
130 vSttHits.push_back(
m);
133 vector<CbmL1SttTrack> vTracks;
136 TClonesArray* seedTracks;
141 nStsTracks = seedTracks->GetEntriesFast();
142 cout <<
" Seed tracks: " << nStsTracks << endl;
145 Double_t scatAng[MaxBranches] = {0.};
147 for (
int itr = 0; itr < nStsTracks; ++itr) {
150 TObject* sts = seedTracks->UncheckedAt(itr);
176 Int_t mcTrackID =
m->GetMCTrackId();
182 TVector3 mom0(-1e+7), mom1;
183 for (Int_t
i = 0;
i < nStations; ++
i)
185 for (
int ih = 0; ih < NHits; ++ih) {
187 CbmSttHit* hit = (CbmSttHit*)
fSttHits->UncheckedAt(
h.index);
189 (CbmSttPoint*)
fSttPoints->UncheckedAt(hit->GetRefIndex());
190 if (p->GetTrackID() != mcTrackID)
continue;
191 if (p->GetStationNo() == 1
192 && TMath::Sqrt(p->GetX() * p->GetX() + p->GetY() * p->GetY()) > 220)
194 if (hitPlanes[
h.iStation] < 0) {
195 hitPlanes[
h.iStation] = 1;
202 if (itr < MaxBranches)
204 TMath::Max(scatAng[itr], mom1.Angle(mom0) * TMath::RadToDeg());
206 if (nOK < nStations) {
219 Branches[0].
StsID = itr;
220 Branches[0].
NHits = 0;
225 Branches[0].
vHits.clear();
227 for (Int_t ist = 0; ist < nStations; ++ist) {
229 int NBranchesOld = NBranches;
231 for (Int_t ibr = 0; ibr < NBranchesOld; ++ibr) {
241 if (1. < 0.5 *
fabs(tr.
T[4]))
257 for (
int ih = 0; ih < NHits; ++ih) {
259 if (
h.iStation != ist)
continue;
263 uTr = tr.
T[0] *
h.FitPoint.phi_c + tr.
T[1] *
h.FitPoint.phi_s;
267 CbmSttHit* hit = (CbmSttHit*)
fSttHits->UncheckedAt(
h.index);
286 Double_t du = uTr -
h.FitPoint.u;
289 Double_t w =
h.FitPoint.sigma2 +
h.FitPoint.phi_cc * tr.
C[0]
290 +
h.FitPoint.phi_2sc * tr.
C[1]
291 +
h.FitPoint.phi_ss * tr.
C[2];
292 Double_t chi21 = du * du / w;
294 if (chi21 <= 20.) NewHits.push_back(ih);
297 int nnew = NewHits.size();
298 for (
int ih = 1; ih < nnew; ++ih) {
299 if (NBranches >= MaxBranches)
break;
312 double qp0 = tr.
T[4];
313 h.Filter(tr, 1, qp0);
319 for (
int ibr = 1; ibr < NBranches; ++ibr) {
320 if ((Branches[ibr].NHits > Branches[bestbr].NHits)
321 || (Branches[ibr].
NHits == Branches[bestbr].
NHits)
322 && (Branches[ibr].chi2 < Branches[bestbr].chi2))
325 vTracks.push_back(Branches[bestbr]);
338 if (nOK == nStations)
341 (vTracks.back()).ok = kFALSE;
345 int NTracks = vTracks.size();
346 cout <<
"NTracks=" << NTracks << endl;
349 vector<CbmL1SttTrack*> vpTracks;
350 for (
int i = 0;
i < NTracks; ++
i)
351 vpTracks.push_back(&(vTracks[
i]));
356 for (
int it = 0; it < NTracks; ++it) {
363 for (
int ih = 0; ih < tr.
NHits; ++ih)
364 if (tr.
vHits[ih]->busy) nbusy++;
365 if (0 && nbusy > 2) {
370 Int_t nDoubl[20] = {0};
371 for (Int_t ih = 0; ih < tr.
NHits; ++ih) {
372 Int_t i2 = tr.
vHits[ih]->iStation / 2;
373 if (nDoubl[i2] == 0) nDoubl[i2]++;
376 for (Int_t
i = 0;
i < nStations / 2; ++
i)
378 if (nHit < nStations / 2)
continue;
379 if (!(tr.
ok))
continue;
382 new ((*fTrackCollection)[NOutTracks]) CbmSttTrack();
388 track->SetSttTrack(&tp);
389 track->SetStsTrackID(tr.
StsID);
391 for (vector<CbmL1SttHit*>::iterator
i = tr.
vHits.begin();
394 if (++nh > 30)
break;
395 track->AddHitIndex((*i)->index);
397 track->SetNMissedHits(tr.
NMissed);
399 if (tr.
StsID < MaxBranches) track->SetScatAng(scatAng[tr.
StsID]);
401 for (
int ih = 0; ih < tr.
NHits; ++ih)
402 tr.
vHits[ih]->busy = 1;
405 if (EventCounter < 100 && EventCounter % 10 == 0
406 || EventCounter >= 100 && EventCounter % 100 == 0)
413 TFile HistoFile(
"SttRec.root",
"RECREATE");
419 if (!obj->IsFolder())
422 TDirectory* cur = gDirectory;
423 TDirectory* sub = cur->mkdir(obj->GetName());
425 TList* listSub = ((TDirectory*) obj)->GetList();
427 while (TObject* obj1 = it())