FairRoot/PandaRoot
PndTrackCandDraw.cxx
Go to the documentation of this file.
1 // -------------------------------------------------------------------------
2 // ----- PndTrackCandDraw source file -----
3 // ----- Created 03/01/08 by M. Al-Turany -----
4 // -------------------------------------------------------------------------
5 
6 #include "PndTrackCandDraw.h"
7 #include "FairHit.h"
8 #include "FairBoxSet.h"
9 //#include "TClonesArray.h"
10 #include "TObjArray.h"
11 #include "TObjString.h"
12 #include "TEveManager.h"
13 #include "TEveBoxSet.h"
14 #include "GFTrackCand.h"
15 #include "PndTrackCand.h"
16 #include "PndTrackCandHit.h"
17 #include "FairRootManager.h"
18 
19 #include "PndDetectorList.h"
20 #include <iostream>
21 using std::cout;
22 using std::endl;
23 
24 // ----- Standard constructor ------------------------------------------
25 PndTrackCandDraw::PndTrackCandDraw(const char* TrackCandName, Int_t iVerbose) :
26  FairBoxSetDraw(TrackCandName, iVerbose), fTrackCandList(0){
27 }
28 // -------------------------------------------------------------------------
29 InitStatus PndTrackCandDraw::Init() {
31 
32  if (fVerbose > 1)
33  cout << "PndTrackCandDraw::Init()" << endl;
34  fManager = FairRootManager::Instance();
35  TList* branchNames = fManager->GetBranchNameList();
36 
37  TIter next(branchNames);
38  TObjString* brName;
39  while ((brName = (TObjString*)next())){
40  TClonesArray *array = (TClonesArray *) fManager->GetObject(brName->GetString().Data());
41  if (array == 0){
42  std::cout << "-I- PndTrackCandDraw::Init() branch " << brName->GetString().Data() << " not found!" << std::endl;
43  }
44  }
45  fq = 0;
46 
47  return kSUCCESS;
48 }
49 // -------------------------------------------------------------------------
50 
51 void PndTrackCandDraw::AddBoxes(FairBoxSet* set, TObject* obj, Int_t i) {
52 
53  if (0 == strcmp(obj->ClassName(), "GFTrackCand")
54  || 0 == strcmp(obj->ClassName(), "PndLhePidTrack"))
55  AddBoxesTrackCand(set, obj, i);
56  else if (0 == strcmp(obj->ClassName(), "PndTrackCand"))
57  AddBoxesPndTrackCand(set, obj, i);
58 }
59 
60 void PndTrackCandDraw::AddBoxesTrackCand(FairBoxSet* set, TObject* obj, Int_t i) {
61  GFTrackCand *tc;
62 
63  if (0 == strcmp(obj->ClassName(), "GFTrackCand")) {
64  tc = (GFTrackCand *) obj;
65  std::cout << "fTrackCandList is full of GFTrackCands" << std::endl;
66  } else {
67  std::cout << "fTrackCandList is full of UNKNOWN " << obj->ClassName()
68  << "?" << std::endl;
69  }
70  if (0 == tc)
71  return;
72 
73  for (size_t j = 0; j < tc->getNHits(); j++) {
74  unsigned int detId, hitId;
75  tc->getHit(j, detId, hitId);
76  TVector3 point = GetVector(detId, hitId);
77  set->AddBox(point.X(), point.Y(), point.Z());
78  set->DigitValue(i);
79  }
80 }
81 
82 void PndTrackCandDraw::AddBoxesPndTrackCand(FairBoxSet* set, TObject* obj, Int_t i) {
83 
84  PndTrackCand* pndtc = (PndTrackCand*) obj;
85  std::cout << "Hits in TrackCand: " << std::endl;
86 
87  ((FairMultiLinkedData_Interface*) pndtc)->Print();
88  for (size_t j = 0; j < pndtc->GetNHits(); j++) {
89  TVector3 point = GetVector(pndtc->GetSortedHit(j));
90  set->AddBox(point.X(), point.Y(), point.Z());
91  std::cout << " color: " << i << std::endl;
92  set->DigitValue(i);
93  }
94 }
95 
96 TVector3 PndTrackCandDraw::GetVector(Int_t detId, Int_t hitId) {
97  FairHit * p;
98  FairRootManager* ioman = FairRootManager::Instance();
99  TString branchName = ioman->GetBranchName(detId);
100  TClonesArray* data = (TClonesArray*) (ioman->GetObject(branchName));
101  p = dynamic_cast<FairHit*>(data->At(hitId));
102  if (p != 0) {
103  std::cout << "Hit in " << branchName << "(" << p->GetX() << "/" << p->GetY() << "/" << p->GetZ() << ")" << std::endl;
104  return (TVector3(p->GetX(), p->GetY(), p->GetZ()));
105  }
106  return TVector3();
107 }
108 
109 TVector3 PndTrackCandDraw::GetVector(FairLink link) {
110  FairHit *p;
111  FairRootManager* ioman = FairRootManager::Instance();
112  TString branchName = ioman->GetBranchName(link.GetType());
113 
114  p = (FairHit*) ioman->GetCloneOfLinkData(link);
115 
116  if (p != 0) {
117  TVector3 vec(p->GetX(), p->GetY(), p->GetZ());
118  std::cout << "Hit in " << branchName << "Link: " << link << "(" << p->GetX() << "/" << p->GetY() << "/" << p->GetZ() << ")";// << std::endl;
119 
120  delete p;
121  return (vec);
122  }
123  return TVector3();
124 
125 }
126 
127 TVector3 PndTrackCandDraw::GetVector(TObject* ){ // obj //[R.K.03/2017] unused variable(s)
128 
129  return TVector3();
130 
131 }
132 
133 // ----- Destructor ----------------------------------------------------
135 }
136 // -------------------------------------------------------------------------
137 
139 
Double_t p
Definition: anasim.C:58
int fVerbose
Definition: poormantracks.C:24
void Print() const
Int_t i
Definition: run_full.C:25
virtual void AddBoxesTrackCand(FairBoxSet *set, TObject *obj, Int_t i=0)
PndTrackCandHit GetSortedHit(UInt_t i)
Definition: PndTrackCand.h:54
unsigned int getNHits() const
Definition: GFTrackCand.h:113
FairBoxSet * fq
Definition: PndCaloDraw.cxx:33
void getHit(unsigned int i, unsigned int &detId, unsigned int &hitId) const
Get detector ID and cluster index (hitId) for hit number i.
Definition: GFTrackCand.h:84
Track candidate – a list of cluster indices.
Definition: GFTrackCand.h:55
virtual void AddBoxesPndTrackCand(FairBoxSet *set, TObject *obj, Int_t i=0)
fRun Init()
Definition: NHitsPerEvent.C:20
UInt_t GetNHits() const
Definition: PndTrackCand.h:59
ClassImp(PndAnaContFact)
Int_t iVerbose
virtual InitStatus Init()
static int next[96]
Definition: ranlxd.cxx:374
virtual void AddBoxes(FairBoxSet *set, TObject *obj, Int_t i=0)
dble_vec_t vec[12]
Definition: ranlxd.cxx:380
virtual TVector3 GetVector(TObject *obj)
PndSdsMCPoint * point
Definition: anaLmdCluster.C:72