- Timestamp:
- May 1, 2021, 2:15:02 PM (4 years ago)
- Branches:
- master
- Children:
- 46d3442
- Parents:
- 53f4746
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
examples/ExamplePVtxFit.C
r53f4746 ra47edcc 14 14 15 15 #endif 16 16 17 17 18 … … 45 46 // Load selected branches with data from specified event 46 47 treeReader->ReadEntry(entry); 48 // 47 49 Int_t Ntr = 0; // # of tracks from primary vertex 48 50 Int_t NtrG = branchTrack->GetEntries(); 49 51 TVectorD** pr = new TVectorD * [NtrG]; 50 52 TMatrixDSym** cv = new TMatrixDSym * [NtrG]; 53 // 54 // True vertex 55 Double_t xpv, ypv, zpv; 51 56 // If event contains at least 1 track 52 57 // … … 60 65 // Get associated generated particle 61 66 GenParticle* gp = (GenParticle*)trk->Particle.GetObject(); 67 TVector3 xg(1.e-3*gp->X,1.e-3*gp->Y,1.e-3*gp->Z); 68 TVector3 pg(gp->Px,gp->Py,gp->Pz); 69 Double_t Q = (Double_t)gp->Charge; 70 Double_t Bz = 2.0; 71 TVectorD genParM =TrkUtil:: XPtoPar(xg, pg, Q, Bz); 72 TVectorD genPar = TrkUtil::ParToMm(genParM); 62 73 // 63 74 // Position of origin in mm … … 65 76 Double_t y = gp->Y; 66 77 Double_t z = gp->Z; 78 Bool_t prim = kTRUE; // Is primary? 79 Int_t mp = gp->M1; // Mother 80 while(mp>0){ 81 GenParticle* gm = 82 (GenParticle*)branchGenPart->At(mp); 83 Double_t xm = gm->X; 84 Double_t ym = gm->Y; 85 Double_t zm = gm->Z; 86 if(x!=xm || y!=ym || z!=zm){ 87 prim = kFALSE; 88 break; 89 }else mp = gm->M1; 90 } 67 91 // 68 92 // group tracks originating from the primary vertex 69 if ( x == 0.0 && y == 0.0)93 if (prim) 70 94 { 95 //std::cout<<"Event: "<<entry<<", track: "<<it; 96 //std::cout<<", x = "<<x<<", y = "<<y<<", z = "<<z<<std::endl; 97 xpv = x; 98 ypv = y; 99 zpv = z; 71 100 // 72 101 // Reconstructed track parameters … … 75 104 Double_t obsC = trk->C; 76 105 Double_t obsZ0 = trk->DZ; 106 //std::cout<<"Z0 track = "<< obsZ0 107 //<<", gen Z0 = "<<genPar(3) 108 //<<", gen cot = "<<genPar(4)<<std::endl; 77 109 Double_t obsCtg = trk->CtgTheta; 78 110 Double_t oPar[5] = { obsD0, obsPhi, obsC, obsZ0, obsCtg }; … … 96 128 Double_t Chi2 = Vtx->GetVtxChi2(); 97 129 Double_t Ndof = 2 * (Double_t)Ntr - 3; 98 Double_t PullX = xvtx(0) / TMath::Sqrt(covX(0, 0)); 99 Double_t PullY = xvtx(1) / TMath::Sqrt(covX(1, 1)); 100 Double_t PullZ = xvtx(2) / TMath::Sqrt(covX(2, 2)); 130 Double_t PullX = (xvtx(0)-xpv) / TMath::Sqrt(covX(0, 0)); 131 Double_t PullY = (xvtx(1)-ypv) / TMath::Sqrt(covX(1, 1)); 132 Double_t PullZ = (xvtx(2)-zpv) / TMath::Sqrt(covX(2, 2)); 133 //std::cout<<"**** True vertex (x, y, z) "<<xpv<<", " 134 //<<ypv<<", "<<zpv<<std::endl; 135 //std::cout<<"**** Found vertex (x, y, z) "<<xvtx(0)<<", " 136 //<<xvtx(1)<<", "<<xvtx(2)<<std::endl; 101 137 // 102 138 // Fill histograms
Note:
See TracChangeset
for help on using the changeset viewer.