EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PndRecoMultiKalmanTask.cxx
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file PndRecoMultiKalmanTask.cxx
1 //-----------------------------------------------------------
2 // File and Version Information:
3 // $Id$
4 //
5 // Description:
6 // Implementation of class PndRecoMultiKalmanTask
7 // see PndRecoMultiKalmanTask.h for details
8 //
9 // Environment:
10 // Software developed for the PANDA Detector at FAIR.
11 //
12 // Author List:
13 // Sebastian Neubert TUM (original author)
14 // Stefano Spataro, UNI Torino
15 //
16 //-----------------------------------------------------------
17 
18 // Panda Headers ----------------------
19 
20 // This Class' Header ------------------
21 #include "PndRecoMultiKalmanTask.h"
22 
23 // C/C++ Headers ----------------------
24 #include <iostream>
25 #include <cmath>
26 
27 // Collaborating Class Headers --------
28 #include "TClonesArray.h"
29 #include "PndTrack.h"
30 #include "FairRootManager.h"
31 #include "FairGeanePro.h"
32 #include "FairRunAna.h"
33 #include "FairRuntimeDb.h"
34 
36  : FairTask(name, iVerbose), fPersistence(kFALSE)
37 {
38  fTrackInBranchName = "LheTrack";
39  fTrackOutBranchName = "LheGenTrack";
40  fMvdBranchName = "";
42  fFitTrackArrayElectron = new TClonesArray("PndTrack");
43  fFitTrackArrayMuon = new TClonesArray("PndTrack");
44  fFitTrackArrayPion = new TClonesArray("PndTrack");
45  fFitTrackArrayKaon = new TClonesArray("PndTrack");
46  fFitTrackArrayProton = new TClonesArray("PndTrack");
47  fUseGeane = kTRUE;
48  fNumIt = 1;
49  fFitter = new PndRecoKalmanFit();
50 }
51 
52 
54 {
55 }
56 
59 {
60 
65  if (!fFitter->Init()) return kFATAL;
66 
67  //Get ROOT Manager
69 
70  if(ioman==0)
71  {
72  Error("PndRecoMultiKalmanTask::Init","RootManager not instantiated!");
73  return kERROR;
74  }
75 
76  // Get input collection
77  fTrackArray=(TClonesArray*) ioman->GetObject(fTrackInBranchName);
78  if(fTrackArray==0)
79  {
80  Error("PndRecoMultiKalmanTask::Init","track-array not found!");
81  return kERROR;
82  }
83 
84  ioman->Register(fTrackOutBranchName+"Electron","Gen", fFitTrackArrayElectron, kTRUE);
85  ioman->Register(fTrackOutBranchName+"Muon", "Gen", fFitTrackArrayMuon, kTRUE);
86  ioman->Register(fTrackOutBranchName+"Pion", "Gen", fFitTrackArrayPion, kTRUE);
87  ioman->Register(fTrackOutBranchName+"Kaon", "Gen", fFitTrackArrayKaon, kTRUE);
88  ioman->Register(fTrackOutBranchName+"Proton", "Gen", fFitTrackArrayProton, kTRUE);
89  return kSUCCESS;
90 }
91 
93 {
95 #if _EIC_OFF_
96  fSttParameters = (PndGeoSttPar*) rtdb->getContainer("PndGeoSttPar");
97 #endif
98 }
99 
100 void PndRecoMultiKalmanTask::Exec(Option_t* opt)
101 {
102  if (fVerbose>0) std::cout<<"PndRecoMultiKalmanTask::Exec"<<std::endl;
103 
104  fFitTrackArrayElectron->Clear();
105  fFitTrackArrayMuon->Clear();
106  fFitTrackArrayPion->Clear();
107  fFitTrackArrayKaon->Clear();
108  fFitTrackArrayProton->Clear();
109 
110  Int_t ntracks=fTrackArray->GetEntriesFast();
111 
112  // Detailed output
113  if (fVerbose>1) std::cout << " -I- PndRecoMultiKalmanTask: contains " << ntracks << " Tracks."<< std::endl;
114 
115  // Cut too busy events TODO
116  if(ntracks>20)
117  {
118  std::cout<<" -I- PndRecoMultiKalmanTask::Exec: ntracks=" << ntracks << " Evil Event! skipping" << std::endl;
119  return;
120  }
121 
122 
123  for(Int_t itr=0;itr<ntracks;++itr)
124  {
125  if (fVerbose>1) std::cout<<"starting track"<<itr<<std::endl;
126  PndTrack *prefitTrack = (PndTrack*)fTrackArray->At(itr);
127  Int_t fCharge= prefitTrack->GetParamFirst().GetQ();
128 
129  { // Electron
130  Int_t PDGCode = -11*fCharge;
131  PndTrack *fitTrack = new PndTrack();
132  fitTrack = fFitter->Fit(prefitTrack, PDGCode);
133 
134  TClonesArray& trkRef = *fFitTrackArrayElectron;
135  Int_t size = trkRef.GetEntriesFast();
136  PndTrack* pndTrack = new(trkRef[size]) PndTrack(fitTrack->GetParamFirst(), fitTrack->GetParamLast(), fitTrack->GetTrackCand(),
137  fitTrack->GetFlag(), fitTrack->GetChi2(), fitTrack->GetNDF(), fitTrack->GetPidHypo(), itr, kLheTrack);
138  } // end of electron
139 
140  { // Muon
141  Int_t PDGCode = -13*fCharge;
142  PndTrack *fitTrack = new PndTrack();
143  fitTrack = fFitter->Fit(prefitTrack, PDGCode);
144 
145  TClonesArray& trkRef = *fFitTrackArrayMuon;
146  Int_t size = trkRef.GetEntriesFast();
147  PndTrack* pndTrack = new(trkRef[size]) PndTrack(fitTrack->GetParamFirst(), fitTrack->GetParamLast(), fitTrack->GetTrackCand(),
148  fitTrack->GetFlag(), fitTrack->GetChi2(), fitTrack->GetNDF(), fitTrack->GetPidHypo(), itr, kLheTrack);
149  } // end of Muon
150 
151  { // Pion
152  Int_t PDGCode = 211*fCharge;
153  PndTrack *fitTrack = new PndTrack();
154  fitTrack = fFitter->Fit(prefitTrack, PDGCode);
155 
156  TClonesArray& trkRef = *fFitTrackArrayPion;
157  Int_t size = trkRef.GetEntriesFast();
158  PndTrack* pndTrack = new(trkRef[size]) PndTrack(fitTrack->GetParamFirst(), fitTrack->GetParamLast(), fitTrack->GetTrackCand(),
159  fitTrack->GetFlag(), fitTrack->GetChi2(), fitTrack->GetNDF(), fitTrack->GetPidHypo(), itr, kLheTrack);
160  } // end of Pion
161 
162  { // Kaon
163  Int_t PDGCode = 321*fCharge;
164  PndTrack *fitTrack = new PndTrack();
165  fitTrack = fFitter->Fit(prefitTrack, PDGCode);
166 
167  TClonesArray& trkRef = *fFitTrackArrayKaon;
168  Int_t size = trkRef.GetEntriesFast();
169  PndTrack* pndTrack = new(trkRef[size]) PndTrack(fitTrack->GetParamFirst(), fitTrack->GetParamLast(), fitTrack->GetTrackCand(),
170  fitTrack->GetFlag(), fitTrack->GetChi2(), fitTrack->GetNDF(), fitTrack->GetPidHypo(), itr, kLheTrack);
171  } // end of Kaon
172 
173  { // Proton
174  Int_t PDGCode = 2212*fCharge;
175  PndTrack *fitTrack = new PndTrack();
176  fitTrack = fFitter->Fit(prefitTrack, PDGCode);
177 
178  TClonesArray& trkRef = *fFitTrackArrayProton;
179  Int_t size = trkRef.GetEntriesFast();
180  PndTrack* pndTrack = new(trkRef[size]) PndTrack(fitTrack->GetParamFirst(), fitTrack->GetParamLast(), fitTrack->GetTrackCand(),
181  fitTrack->GetFlag(), fitTrack->GetChi2(), fitTrack->GetNDF(), fitTrack->GetPidHypo(), itr, kLheTrack);
182  } // end of Proton
183 
184  } // end of track loop
185 
186  if (fVerbose>0) std::cout<<"Fitting done"<<std::endl;
187 
188  return;
189 }
190