Changeset 7bca620 in git
- Timestamp:
- Feb 10, 2022, 11:42:45 AM (3 years ago)
- Branches:
- master
- Children:
- 5c03893
- Parents:
- b750b0a
- Files:
-
- 1 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
examples/ExamplePVtxFind.C
rb750b0a r7bca620 45 45 TH1D* hTrFoundB = new TH1D("hTrFoundB", "Found BAD primary tracks", 41, -0.5, 40.5); 46 46 TH1D* hTrDiff = new TH1D("hTrDiff", "Found - available tracks", 21, -10.5, 10.5); 47 // Chi2 for cuts 48 TH1D* hChi2SngP = new TH1D("hChi2SngP", "#chi^2 for single tracks", 200, 0., 50.); 49 TH1D* hChi2MaxP = new TH1D("hChi2MaxP", "#chi^2 max contribution", 200, 0., 50.); 50 TH1D* hChi2SngN = new TH1D("hChi2SngN", "#chi^2 for single tracks", 200, 0., 50.); 51 TH1D* hChi2MaxN = new TH1D("hChi2MaxN", "#chi^2 max contribution", 200, 0., 50.); 52 53 47 54 // 48 55 // Loop over all events … … 53 60 treeReader->ReadEntry(entry); 54 61 Int_t NtrG = branchTrack->GetEntries(); 55 if(entry%500 ==0)std::cout << "Event "<<entry<<" opened containing " << NtrG << " tracks" << std::endl;56 T VectorD** pr = new TVectorD * [NtrG];57 TMatrixDSym** cv = new TMatrixDSym * [NtrG];62 TVectorD** pr = new TVectorD * [NtrG]; // Track Parameters 63 TMatrixDSym** cv = new TMatrixDSym * [NtrG]; // Track covariances 64 Bool_t *fprvx = new Bool_t[NtrG]; // Primary vertex flag 58 65 // 59 66 // test Particle branch … … 88 95 pr[it] = new TVectorD(obsPar); 89 96 cv[it] = new TMatrixDSym(trk->CovarianceMatrix()); 90 // Check covariance91 /*92 TMatrixDSymEigen Eign(*cv[it]);93 TVectorD lambda = Eign.GetEigenValues();94 Bool_t good = kTRUE;95 for(Int_t i=0; i<5; i++) if(lambda(i)<0.0) good = kFALSE;96 if(!good){97 std::cout<<"Cov["<<it<<"]"<<" eigenvalues: "98 <<lambda(0)<<", "<<lambda(1)<<", "<<lambda(2)<<", "99 <<lambda(3)<<", "<<lambda(4)<<std::endl;100 TMatrixDSym Ctmp = *cv[it];101 std::cout<<"Error D (dir - cov) "<<trk->ErrorD0102 <<" - "<<TMath::Sqrt(Ctmp(0,0))<<std::endl;103 }104 */105 //std::cout << "Track loaded it= " << it << std::endl;106 97 // 107 98 // Find true primary vertex … … 114 105 Double_t z = gp->Z; 115 106 Bool_t prim = kTRUE; // Is primary? 107 fprvx[it] = kFALSE; 116 108 Int_t mp = gp->M1; // Mother 117 109 while (mp > 0) { … … 129 121 if (prim) { // It's a primary track 130 122 Nprim++; 123 fprvx[it] = kTRUE; 131 124 xpv = x; // Store true primary 132 125 ypv = y; … … 136 129 } // End loop on tracks 137 130 } 138 std::cout<<"PVtxFind true vertex: Nprim= "<<Nprim<<", x,y,z= "<<xpv<<", "<<ypv<<", "<<zpv<<std::endl; 131 if(entry%500 ==0){ 132 std::cout << "Event "<<entry<<" opened containing " << NtrG << " / "<< Nprim 133 << " Total / primary tracks"<< std::endl; 134 } 135 //std::cout<<"PVtxFind true vertex: Nprim= "<<Nprim<<", x,y,z= "<<xpv<<", "<<ypv<<", "<<zpv<<std::endl; 139 136 // 140 137 // Find primary vertex … … 161 158 TVectorD** PrSk = new TVectorD * [1]; 162 159 TMatrixDSym** CvSk = new TMatrixDSym * [1]; 163 Double_t MaxChi2 = 2.0+3*2.;160 Double_t MaxChi2 = 9.; 164 161 for (Int_t n = 0; n < NtrG; n++) { 165 162 PrSk[0] = new TVectorD(*pr[n]); … … 169 166 Double_t Chi2One = Vskim->GetVtxChi2(); 170 167 //std::cout<<"Track "<<n<<", Chi2 = "<<Chi2One<<std::endl; 168 if(fprvx[n])hChi2SngP->Fill(Chi2One); 169 else hChi2SngN->Fill(Chi2One); 170 // 171 171 if (Chi2One < MaxChi2) { 172 172 nSkimmed[nSkim] = n; … … 184 184 // Load tracks for primary fit 185 185 Int_t MinTrk = 1; // Minumum # tracks for vertex fit 186 std::vector<Int_t> trnum; 186 187 if (nSkim >= MinTrk) { 187 188 TVectorD** PrFit = new TVectorD * [nSkim]; … … 190 191 PrFit[n] = new TVectorD(*pr[nSkimmed[n]]); 191 192 CvFit[n] = new TMatrixDSym(*cv[nSkimmed[n]]); 193 trnum.push_back(nSkimmed[n]); 192 194 } 193 195 delete[] nSkimmed; … … 200 202 // 201 203 // Remove tracks with large chi2 202 Double_t MaxChi2Fit = 4.5;204 Double_t MaxChi2Fit = 8.0; 203 205 Bool_t Done = kFALSE; 204 206 while (!Done) { … … 213 215 Double_t Chi2Mx = Chi2L[iMax]; 214 216 //std::cout << "Chi2Mx "<<Chi2Mx << std::endl; 217 if(fprvx[trnum[iMax]])hChi2MaxP->Fill(Chi2Mx); 218 else hChi2MaxN->Fill(Chi2Mx); 215 219 if (Chi2Mx > MaxChi2Fit && Nfound > 1) { 216 220 //std::cout << "Before remove. Nfound = "<<Nfound << std::endl; 217 221 Vtx->RemoveTrk(iMax); 222 trnum.erase(trnum.begin() + iMax); 218 223 //std::cout << "After remove." << std::endl; 219 224 Nfound--; … … 230 235 if (Nfound >= Nmin) { 231 236 TVectorD xvtx = Vtx->GetVtx(); 232 std::cout << "Found vertex " << xvtx(0)<<", "<<xvtx(1)<<", "<<xvtx(2) << std::endl;237 //std::cout << "Found vertex " << xvtx(0)<<", "<<xvtx(1)<<", "<<xvtx(2) << std::endl; 233 238 TMatrixDSym covX = Vtx->GetVtxCov(); 234 239 Double_t Chi2 = Vtx->GetVtxChi2(); … … 256 261 delete[] PrFit; 257 262 delete[] CvFit; 263 delete[] fprvx; 264 trnum.clear(); 258 265 } 259 266 … … 271 278 TCanvas* Cnv = new TCanvas("Cnv", "Delphes primary vertex pulls", 50, 50, 900, 500); 272 279 Cnv->Divide(2, 2); 273 Cnv->cd(1); gPad->SetLogy(1); gStyle->SetOptFit(1111); 280 Cnv->cd(1); gPad->SetLogy(1); gStyle->SetOptFit(1111); gStyle->SetOptStat(111111); 274 281 hXpull->Fit("gaus"); hXpull->Draw(); 275 Cnv->cd(2); gPad->SetLogy(1); gStyle->SetOptFit(1111); 282 Cnv->cd(2); gPad->SetLogy(1); gStyle->SetOptFit(1111); gStyle->SetOptStat(111111); 276 283 hYpull->Fit("gaus"); hYpull->Draw(); 277 Cnv->cd(3); gPad->SetLogy(1); gStyle->SetOptFit(1111); 284 Cnv->cd(3); gPad->SetLogy(1); gStyle->SetOptFit(1111); gStyle->SetOptStat(111111); 278 285 hZpull->Fit("gaus"); hZpull->Draw(); 279 286 Cnv->cd(4); hChi2->Draw(); … … 288 295 CnvN->cd(3); 289 296 hTrDiff->Draw(); 297 // 298 TCanvas* CnvCh = new TCanvas("CnvCh", "#chi^2", 200, 200, 900, 500); 299 CnvCh->Divide(2,1); 300 CnvCh->cd(1); 301 hChi2SngP->Draw(); 302 hChi2SngN->SetLineColor(kRed); 303 hChi2SngN->Draw("SAME"); 304 CnvCh->cd(2); 305 hChi2MaxP->Draw(); 306 hChi2MaxN->SetLineColor(kRed); 307 hChi2MaxN->Draw("SAME"); 290 308 } -
external/TrackCovariance/ObsTrk.cc
rb750b0a r7bca620 74 74 fCovILC.ResizeTo(5, 5); 75 75 fGenPar = XPtoPar(fGenX, fGenP, Q); 76 fGenParMm = ParToMm(fGenPar); 76 77 fGenParACTS = ParToACTS(fGenPar); 77 78 fGenParILC = ParToILC(fGenPar); 78 79 // 79 80 fObsPar = GenToObsPar(fGenPar); 81 fObsParMm = ParToMm(fObsPar); 80 82 fObsParACTS = ParToACTS(fObsPar); 81 83 fObsParILC = ParToILC(fObsPar); … … 83 85 fObsP = ParToP(fObsPar); 84 86 fObsQ = ParToQ(fObsPar); 87 fCovMm = CovToMm(fCov); 85 88 fCovACTS = CovToACTS(fObsPar, fCov); 86 89 fCovILC = CovToILC(fCov); -
external/TrackCovariance/VertexFit.cc
rb750b0a r7bca620 17 17 { 18 18 fNtr = 0; 19 fR old= -1.0;19 fRstart = -1.0; 20 20 fVtxDone = kFALSE; 21 21 fVtxCst = kFALSE; … … 31 31 { 32 32 fNtr = Ntr; 33 fR old= -1.0;33 fRstart = -1.0; 34 34 fVtxDone = kFALSE; 35 35 fVtxCst = kFALSE; … … 55 55 { 56 56 fNtr = Ntr; 57 fR old= -1.0;57 fRstart = -1.0; 58 58 fVtxDone = kFALSE; 59 59 fVtxCst = kFALSE; … … 220 220 std::vector<TVectorD*> x0i; // Tracks at ma 221 221 std::vector<TVectorD*> ni; // Track derivative wrt phase 222 std::vector<TMatrixDSym*> Ci; // Position error matrix at fixed phase222 std::vector<TMatrixDSym*> Ci; // Position error matrix at fixed phase 223 223 std::vector<TVectorD*> wi; // Ci*ni 224 std::vector<Double_t> s_in; // Starting phase 225 // 226 // 224 227 // 225 228 // Track loop 226 229 for (Int_t i = 0; i < fNtr; i++) 227 230 { 228 Double_t s = 0.;229 231 TVectorD par = *fPar[i]; 230 232 TMatrixDSym Cov = *fCov[i]; 231 x0i.push_back(new TVectorD(Fill_x0(par))); 233 Double_t s = 0.; 234 // Case when starting radius is provided 235 if(fRstart > TMath::Abs(par(0))){ 236 s = 2.*TMath::ASin(par(2)*TMath::Sqrt((fRstart*fRstart-par(0)*par(0))/(1.+2.*par(2)*par(0)))); 237 } 238 // 239 x0i.push_back(new TVectorD(Fill_x(par, s))); 232 240 ni.push_back(new TVectorD(derXds(par, s))); 233 241 TMatrixD A = derXdPar(par, s); … … 235 243 TMatrixDSym Cinv = RegInv(*Ci[i]); 236 244 wi.push_back(new TVectorD(Cinv * (*ni[i]))); 245 s_in.push_back(s); 237 246 } 238 247 //std::cout << "Vtx init completed. fNtr = "<<fNtr << std::endl; … … 262 271 for (Int_t i = 0; i < fNtr; i++){ 263 272 Double_t si = Dot(*wi[i], fXv - (*x0i[i])) / Ci[i]->Similarity(*wi[i]); 264 ffi.push_back(si );273 ffi.push_back(si+s_in[i]); 265 274 //TVectorD xvi = Fill_x(*fPar[i],si); 266 275 //std::cout << "Fast vertex "<<i<<": xvi = "<<xvi(0)<<", "<<xvi(1)<<", "<<xvi(2) … … 280 289 Ci.clear(); 281 290 wi.clear(); 291 s_in.clear(); 282 292 } 283 293 // … … 402 412 // 403 413 fVtxDone = kTRUE; // Set fit completion flag 404 fRold= TMath::Sqrt(fXv(0)*fXv(0) + fXv(1)*fXv(1)); // Store fit414 //fRstart = TMath::Sqrt(fXv(0)*fXv(0) + fXv(1)*fXv(1)); // Store fit 405 415 //std::cout << "Found vertex " << fXv(0) << ", " << fXv(1) << ", " << fXv(2) 406 416 // << ", after "<<Ntry<<" iterations"<<std::endl; -
external/TrackCovariance/VertexFit.h
rb750b0a r7bca620 36 36 // Results 37 37 Bool_t fVtxDone; // Flag vertex fit completed 38 Double_t fR old; // Current value of vertex radius38 Double_t fRstart; // Starting value of vertex radius (0 = none) 39 39 TVectorD fXv; // Found vertex 40 40 TMatrixDSym fcovXv; // Vertex covariance … … 83 83 // Handle tracks/constraints 84 84 void AddVtxConstraint(TVectorD xv, TMatrixDSym cov); // Add gaussian vertex constraint 85 void AddTrk(TVectorD *par, TMatrixDSym *Cov); // Add track to input list 86 void RemoveTrk(Int_t iTrk); // Remove iTrk track 85 void AddTrk(TVectorD *par, TMatrixDSym *Cov); // Add track to input list 86 void RemoveTrk(Int_t iTrk); // Remove iTrk track 87 void SetStartR(Double_t R) { fRstart = R; }; // Set starting radius 87 88 // 88 89 };
Note:
See TracChangeset
for help on using the changeset viewer.