EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PndGFTrackToPndTrackConvertorTask.cxx
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file PndGFTrackToPndTrackConvertorTask.cxx
1 //-----------------------------------------------------------
2 // Task which coverts TClonesArray of GFTrack to TClonesArray of PndTrack
3 //-----------------------------------------------------------
4 
5 // Panda Headers ----------------------
6 
7 // This Class' Header ------------------
9 
10 // C/C++ Headers ----------------------
11 #include <iostream>
12 #include <cmath>
13 
14 // Collaborating Class Headers --------
15 #include "TClonesArray.h"
16 #include "FairRootManager.h"
17 #include "PndTrack.h"
18 #include "GFTrack.h"
19 #include "GFException.h"
20 #include "PndGenfitAdapters.h"
21 #include "FairRunAna.h"
22 #include "FairRuntimeDb.h"
23 
25 : FairTask(name, iVerbose)
26 {
27  fTrackInBranchName = "TrackPostFitComplete";
28  fTrackOutBranchName = "PndTrackPostFitComplete";
29  fOutTrackArray = new TClonesArray("PndTrack");
30 }
31 
32 
34 {
35 }
36 
39 {
40 
41  //Get ROOT Manager
43 
44  if(ioman==0)
45  {
46  Error("PndGFTrackToPndTrackConvertorTask::Init","RootManager not instantiated!");
47  return kERROR;
48  }
49 
50  // Get input collection
51  fInTrackArray=(TClonesArray*) ioman->GetObject(fTrackInBranchName);
52  if(fInTrackArray==0)
53  {
54  Error("PndGFTrackToPndTrackConvertorTask::Init","track-array not found!");
55  return kERROR;
56  }
57 
58  ioman->Register(fTrackOutBranchName,"Gen", fOutTrackArray, kTRUE);
59 
60  return kSUCCESS;
61 }
62 
64 {
65  if (fVerbose>0) std::cout<<"PndGFTrackToPndTrackConvertorTask::Exec"<<std::endl;
66 
67  fOutTrackArray->Delete();
68 
69  Int_t ntracks=fInTrackArray->GetEntriesFast();
70 
71  // Detailed output
72  if (fVerbose>1) std::cout << " -I- PndGFTrackToPndTrackConvertorTask: contains " << ntracks << " Tracks."<< std::endl;
73 
74 
75  for(Int_t itr=0;itr<ntracks;++itr)
76  {
77  if (fVerbose>1) std::cout<<"starting track"<<itr<<std::endl;
78 
79  TClonesArray& trkRef = *fOutTrackArray;
80  Int_t size = trkRef.GetEntriesFast();
81 
82  GFTrack *inTrack = (GFTrack*) fInTrackArray->At(itr);
83  try
84  {
85  PndTrack* outTrack = GenfitTrack2PndTrack(inTrack);
86  PndTrack* pndTrack = new(trkRef[size]) PndTrack(outTrack->GetParamFirst(), outTrack->GetParamLast(), outTrack->GetTrackCand(),
87  outTrack->GetFlag(), outTrack->GetChi2(), outTrack->GetNDF(), outTrack->GetPidHypo(), itr, FairRootManager::Instance()->GetBranchId(fTrackInBranchName));
88  }
89  catch(GFException& e)
90  {
91  std::cout << "*** PndGFTrackToPndTrackConvertorTask::Exec" << "\t" << "Genfit Exception: " << e.what() << std::endl;
92  continue;
93  //throw e;
94  }
95 
96  }
97 
98  return;
99 }
100