FairRoot/PandaRoot
PndTrackArrayMerger.cxx
Go to the documentation of this file.
1 //
2 // This class COPIES PndTrack objects from all specified input branches
3 // into one output branch. Linking is still to be done...
4 //
5 // Aurthor: R.Kliemt, May 2011
6 
7 #include "PndTrackArrayMerger.h"
8 #include "PndTrackCand.h"
9 #include "PndTrack.h"
10 #include <iostream>
11 
12 
14 :fPersistance(kTRUE), fOutputBranch("ALLTracks"), fOutputArray(), fInputArrayList(), fInputBranchList()
15 {}
16 
18 :fPersistance(kTRUE), fOutputBranch(s), fOutputArray(), fInputArrayList(), fInputBranchList()
19 {}
20 
22 {}
23 
25 {return;}
26 
28 {return kSUCCESS;}
29 
30 
32 {
33  FairRootManager* ioman = FairRootManager::Instance();
34  if ( ! ioman )
35  {
36  std::cout << "-E- PndSdsStripHitProducer::Init: "
37  << "RootManager not instantiated!" << std::endl;
38  return kFATAL;
39  }
40 
41  //setup input arrays
42  TClonesArray* tmparray;
43  for(std::vector<TString>::iterator iter = fInputBranchList.begin(); iter!=fInputBranchList.end();++iter)
44  {
45  tmparray = (TClonesArray*) ioman->GetObject((*iter).Data());
46  if ( ! tmparray )
47  {
48  Error("Init()","No %s array! Skipping that name.",(*iter).Data());
49  continue;
50  }
51  TString namebuff = (TString) tmparray->GetClass()->GetName();
52  if(namebuff == "PndTrack"){
53  fInputArrayList.push_back(tmparray);
54  }
55  }
56 
57  //setup output array
58  fOutputArray = ioman->Register(fOutputBranch, "PndTrack", "AllTracks", fPersistance);
59  //fOutputArray = new TClonesArray("PndTrack");
60  // ioman->Register(fOutputBranch, "AllTracks", fOutputArray, fPersistance);
61 
62  return kSUCCESS;
63 }
64 
66 {
67  fOutputArray->Clear();
68  // copy data from input arrays to output array
69  TClonesArray* tmparray;
70  PndTrack* tmptrk;
71  Int_t namenum=0;
72  TString brname;
73  Int_t entries=0;
74 
75 
76  for(std::vector<TClonesArray*>::iterator iter = fInputArrayList.begin(); iter!=fInputArrayList.end();++iter)
77  {
78  tmparray=*iter;
79 #if ROOT_VERSION_CODE >= ROOT_VERSION(5,29,1)
80  // MOVES References into a new TCA
81  // Just from root 5.29.02
82  if (tmparray != 0) {
83  fOutputArray->AbsorbObjects(tmparray, 0, tmparray->GetEntries() - 1);
84  }
85 #else
86  brname=fInputBranchList[namenum];
87  for ( Int_t i=0;i<tmparray->GetEntriesFast();i++)
88  {
89  tmptrk=(PndTrack*)tmparray->At(i);
90  entries=fOutputArray->GetEntriesFast();
91  PndTrack* mynewtrack = new ((*fOutputArray)[entries])
92  PndTrack(tmptrk->GetParamFirst(),tmptrk->GetParamLast(),*(tmptrk->GetTrackCandPtr()),
93  tmptrk->GetFlag(), tmptrk->GetChi2(), tmptrk->GetNDF(),
94  tmptrk->GetPidHypo(),-1,-1);
95  mynewtrack->Reset(); //resetting links
96  for(int nlin=0;nlin<tmptrk->GetNLinks();nlin++)
97  {
98  mynewtrack->AddLink(tmptrk->GetLink(nlin));
99  }
100  }
101  namenum++;
102 #endif
103  }
104 
105  return;
106 }
107 
109 {
110  // called after all Tasks did their Exex() and the data is copied to the file
111 // fOutputArray->Clear();
112  FinishEvents();
113 }
114 
116 
TString fOutputBranch
Flag if to store.
Int_t i
Definition: run_full.C:25
std::vector< TString > fInputBranchList
virtual InitStatus ReInit()
TLorentzVector s
Definition: Pnd2DStar.C:50
Int_t GetFlag() const
Definition: PndTrack.h:33
TClonesArray * fOutputArray
ClassImp(PndTrackArrayMerger)
Int_t GetNDF() const
Definition: PndTrack.h:35
FairTrackParP GetParamLast()
Definition: PndTrack.h:50
virtual InitStatus Init()
virtual void Exec(Option_t *opt)
Double_t GetChi2() const
Definition: PndTrack.h:34
Int_t GetPidHypo() const
Definition: PndTrack.h:32
PndTrackCand * GetTrackCandPtr()
Definition: PndTrack.h:48
std::vector< TClonesArray * > fInputArrayList
virtual void SetParContainers()
FairTrackParP GetParamFirst()
Definition: PndTrack.h:49