3 gROOT->LoadMacro(
"$VMCWORKDIR/gconfig/rootlogon.C");
9 TFile *
inFile = TFile::Open(inSimFile,
"READ");
10 TFile *fiDigiFile = TFile::Open(inDigiFile,
"READ");
11 TFile *fiReco1File = TFile::Open(inRecoFile,
"READ");
13 TTree *
tree=(TTree *) inFile->Get(
"pndsim") ;
14 tree->AddFriend(
"pndsim",inRecoFile);
15 tree->AddFriend(
"pndsim",inDigiFile);
17 TClonesArray*
trk_array=
new TClonesArray(
"PndTrack");
18 tree->SetBranchAddress(
"SttMvdTrack", &trk_array);
20 TClonesArray*
mc_array=
new TClonesArray(
"PndMCTrack");
21 tree->SetBranchAddress(
"MCTrack", &mc_array);
23 TClonesArray *mvdpixarray =
new TClonesArray(
"PndSdsHit");
24 tree->SetBranchAddress(
"MVDHitsPixel",&mvdpixarray);
25 TClonesArray *mvdstrarray =
new TClonesArray(
"PndSdsHit");
26 tree->SetBranchAddress(
"MVDHitsStrip",&mvdstrarray);
27 TClonesArray *mvdmcarray =
new TClonesArray(
"PndSdsMCPoint");
28 tree->SetBranchAddress(
"MVDPoint",&mvdmcarray);
29 TClonesArray *sttarray =
new TClonesArray(
"PndSttHit");
30 tree->SetBranchAddress(
"STTHit",&sttarray);
31 TClonesArray *sttmcarray =
new TClonesArray(
"PndSttPoint");
32 tree->SetBranchAddress(
"STTPoint",&sttmcarray);
33 TClonesArray *gemarray =
new TClonesArray(
"PndGemHit");
34 tree->SetBranchAddress(
"GEMHit",&gemarray);
35 TClonesArray *gemmcarray =
new TClonesArray(
"PndGemMCPoint");
36 tree->SetBranchAddress(
"GEMPoint",&gemmcarray);
39 TFile *
out = TFile::Open(
"out_test.root",
"RECREATE");
40 TNtuple *nt =
new TNtuple(
"nt",
"nt",
"evt:trk:num:id:hit:x:y:z:mcx:mcy:mcz:rho:p:theta:phi:q");
42 TList *bl = (TList*) fiDigiFile->Get(
"BranchList");
43 FairRootManager *fairman =
new FairRootManager();
44 fairman->SetBranchNameList(bl);
45 int mvdpixdetid = fairman->GetBranchId(
"MVDHitsPixel");
46 int mvdstrdetid = fairman->GetBranchId(
"MVDHitsStrip");
47 int sttdetid = fairman->GetBranchId(
"STTHit");
48 int gemdetid = fairman->GetBranchId(
"GEMHit");
49 cout << mvdpixdetid << endl;
50 cout << mvdstrdetid << endl;
51 cout << sttdetid << endl;
52 cout << gemdetid << endl;
54 if (nEntries==0) nEntries = tree->GetEntriesFast();
55 for (Int_t j=0; j< nEntries; j++){
60 cout <<
"processing event " << j <<
"\n";
62 for(
int itrk = 0; itrk < trk_array->GetEntriesFast(); itrk++)
64 cout <<
"*** track " << itrk << endl;
68 cout <<
"ERROR track " << itrk <<
" does not exist" << endl;
75 cout <<
"ERROR track " << itrk <<
" has no candidate association" << endl;
79 TVector3
mom = parFirst.GetMomentum();
80 for (Int_t ihit = 0; ihit < cand->
GetNHits(); ihit++) {
86 Float_t
x = 0,
y= 0,
z=0, mcx = 0, mcy= 0, mcz=0;
88 FairMCPoint *
point = NULL;
89 if(detId == FairRootManager::Instance()->GetBranchId(
"MVDHitsPixel"))
91 hit = (FairHit*) mvdpixarray->At(hitId);
94 cout <<
"ERROR mvd pix " << hitId <<
" does not exist" << endl;
98 if (hit->GetRefIndex()==-1) cout <<
"ERROR mvd: ref index -1" << endl;
101 point = (
PndSdsMCPoint*)(mvdmcarray->At(hit->GetRefIndex()));
102 mcx = point->GetX(); mcy = point->GetY(); mcz = point->GetZ();
106 else if(detId == FairRootManager::Instance()->GetBranchId(
"MVDHitsStrip"))
108 hit = (FairHit*) mvdstrarray->At(hitId);
109 if(!hit) cout <<
"ERROR mvd str " << hitId <<
" does not exist" << endl;
112 if (hit->GetRefIndex()==-1) cout <<
"ERROR mvd: ref index -1" << endl;
115 point = (
PndSdsMCPoint*)(mvdmcarray->At(hit->GetRefIndex()));
116 mcx = point->GetX(); mcy = point->GetY(); mcz = point->GetZ();
120 else if(detId == FairRootManager::Instance()->GetBranchId(
"STTHit"))
122 hit = (FairHit*) sttarray->At(hitId);
123 if(!hit) cout <<
"ERROR stt " << hitId <<
" does not exist" << endl;
126 if (hit->GetRefIndex()==-1) cout <<
"ERROR stt: ref index -1" << endl;
129 point = (
PndSttPoint*)(sttmcarray->At(hit->GetRefIndex()));
130 mcx = point->GetX(); mcy = point->GetY(); mcz = point->GetZ();
134 else if(detId == FairRootManager::Instance()->GetBranchId(
"GEMHit"))
136 hit = (FairHit*) gemarray->At(hitId);
137 if(!hit) cout <<
"ERROR gem " << hitId <<
" does not exist" << endl;
140 if (hit->GetRefIndex()==-1) cout <<
"ERROR gem: ref index -1" << endl;
143 point = (
PndGemMCPoint*)(gemmcarray->At(hit->GetRefIndex()));
144 mcx = point->GetX(); mcy = point->GetY(); mcz = point->GetZ();
148 else cout <<
"ERROR detId unknown " << detId <<
" for hit " << hitId << endl;
151 x = hit->GetX();
y = hit->GetY();
z = hit->GetZ();
154 Float_t ntArray[] = {
155 j, itrk, cand->
GetNHits(), detId, ihit,
156 x,
y,
z, mcx, mcy, mcz, rho,
157 mom.Mag(), mom.Theta()*TMath::RadToDeg(), mom.Phi()*TMath::RadToDeg(), parFirst.GetQ()
162 cout <<
"Momentum @ first point" << endl;
164 cout <<
"TrackCand:" << endl;
PndTrackCandHit GetSortedHit(UInt_t i)
PndTrackCand * GetTrackCandPtr()
int check_trackcand(Int_t nEntries=0)
FairTrackParP GetParamFirst()