Changeset 53f4746 in git for external/TrackCovariance/TrkUtil.cc
- Timestamp:
- Apr 30, 2021, 4:30:36 PM (4 years ago)
- Branches:
- master
- Children:
- a47edcc
- Parents:
- 952bbbc
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
external/TrackCovariance/TrkUtil.cc
r952bbbc r53f4746 2 2 #include <iostream> 3 3 #include <algorithm> 4 #include <TSpline.h> 4 5 5 6 // Constructor … … 96 97 if (fBz == 0.0)std::cout << "TrkUtil::ParToP: Warning Bz not set" << std::endl; 97 98 // 98 return ParToP(Par, fBz);99 return ParToP(Par, fBz); 99 100 } 100 101 // … … 233 234 } 234 235 // 235 236 //237 void TrkUtil::SetBfield(Double_t Bz)238 {239 fBz = Bz;240 }241 242 236 // Setup chamber volume 243 237 void TrkUtil::SetDchBoundaries(Double_t Rmin, Double_t Rmax, Double_t Zmin, Double_t Zmax) … … 274 268 // << ", C= " << C << ", z0= " << z0 << ", ct= " << ct << std::endl; 275 269 // 276 // Track length per unit phase change 277 Double_t Scale = sqrt(1.0 + ct *ct) / (2.0*TMath::Abs(C));270 // Track length per unit phase change 271 Double_t Scale = sqrt(1.0 + ct * ct) / (2.0 * TMath::Abs(C)); 278 272 // 279 273 // Find intersections with chamber boundaries 280 274 // 281 Double_t phRin = 0.0; // phase of inner cylinder 282 Double_t phRin2 = 0.0; // phase of inner cylinder intersection (2nd branch)275 Double_t phRin = 0.0; // phase of inner cylinder 276 Double_t phRin2 = 0.0; // phase of inner cylinder intersection (2nd branch) 283 277 Double_t phRhi = 0.0; // phase of outer cylinder intersection 284 278 Double_t phZmn = 0.0; // phase of left wall intersection 285 279 Double_t phZmx = 0.0; // phase of right wall intersection 286 280 // ... with inner cylinder 287 Double_t Rtop = TMath::Abs((1.0 + C *D) / C);281 Double_t Rtop = TMath::Abs((1.0 + C * D) / C); 288 282 289 283 if (Rtop > fRmin && TMath::Abs(D) < fRmin) // *** don't treat large D tracks for the moment *** 290 284 { 291 Double_t ph = 2 * asin(C *sqrt((fRmin*fRmin - D*D) / (1.0 + 2.0*C*D)));292 Double_t z = z0 + ct *ph / (2.0*C);285 Double_t ph = 2 * asin(C * sqrt((fRmin * fRmin - D * D) / (1.0 + 2.0 * C * D))); 286 Double_t z = z0 + ct * ph / (2.0 * C); 293 287 294 288 //std::cout << "Rin intersection: ph = " << ph<<", z= "<<z << std::endl; 295 289 296 if (z < fZmax && z > fZmin) phRin = TMath::Abs(ph); // Intersection inside chamber volume 290 if (z < fZmax && z > fZmin) phRin = TMath::Abs(ph); // Intersection inside chamber volume 297 291 // 298 292 // Include second branch of loopers 299 293 Double_t Pi = 3.14159265358979323846; 300 Double_t ph2 = 2 *Pi - TMath::Abs(ph);294 Double_t ph2 = 2 * Pi - TMath::Abs(ph); 301 295 if (ph < 0)ph2 = -ph2; 302 296 z = z0 + ct * ph2 / (2.0 * C); … … 306 300 if (Rtop > fRmax && TMath::Abs(D) < fRmax) // *** don't treat large D tracks for the moment *** 307 301 { 308 Double_t ph = 2 * asin(C *sqrt((fRmax*fRmax - D*D) / (1.0 + 2.0*C*D)));309 Double_t z = z0 + ct *ph / (2.0*C);310 if (z < fZmax && z > fZmin) phRhi = TMath::Abs(ph); // Intersection inside chamber volume 302 Double_t ph = 2 * asin(C * sqrt((fRmax * fRmax - D * D) / (1.0 + 2.0 * C * D))); 303 Double_t z = z0 + ct * ph / (2.0 * C); 304 if (z < fZmax && z > fZmin) phRhi = TMath::Abs(ph); // Intersection inside chamber volume 311 305 } 312 306 // ... with left wall … … 314 308 if (Zdir > 0.0) 315 309 { 316 Double_t ph = 2.0 *C*Zdir;317 Double_t Rint = sqrt(D *D + (1.0 + 2.0*C*D)*pow(sin(ph / 2), 2) / (C*C));318 if (Rint < fRmax && Rint > fRmin) phZmn = TMath::Abs(ph); // Intersection inside chamber volume 310 Double_t ph = 2.0 * C * Zdir; 311 Double_t Rint = sqrt(D * D + (1.0 + 2.0 * C * D) * pow(sin(ph / 2), 2) / (C * C)); 312 if (Rint < fRmax && Rint > fRmin) phZmn = TMath::Abs(ph); // Intersection inside chamber volume 319 313 } 320 314 // ... with right wall … … 322 316 if (Zdir > 0.0) 323 317 { 324 Double_t ph = 2.0 *C*Zdir;325 Double_t Rint = sqrt(D *D + (1.0 + 2.0*C*D)*pow(sin(ph / 2), 2) / (C*C));326 if (Rint < fRmax && Rint > fRmin) phZmx = TMath::Abs(ph); // Intersection inside chamber volume 318 Double_t ph = 2.0 * C * Zdir; 319 Double_t Rint = sqrt(D * D + (1.0 + 2.0 * C * D) * pow(sin(ph / 2), 2) / (C * C)); 320 if (Rint < fRmax && Rint > fRmin) phZmx = TMath::Abs(ph); // Intersection inside chamber volume 327 321 } 328 322 // … … 342 336 { 343 337 dPhase = ph_arr[iPos + 2] - ph_arr[iPos + 1]; 344 tLength = dPhase *Scale;338 tLength = dPhase * Scale; 345 339 } 346 340 } … … 349 343 // 350 344 // Return number of ionization clusters 351 Bool_t TrkUtil::IonClusters(Double_t &Ncl, Double_t mass, TVectorD Par)345 Bool_t TrkUtil::IonClusters(Double_t& Ncl, Double_t mass, TVectorD Par) 352 346 { 353 347 // … … 386 380 TVector3 p = ParToP(Par); 387 381 bg = p.Mag() / mass; 388 muClu = Nclusters(bg) *tLen; // Avg. number of clusters382 muClu = Nclusters(bg) * tLen; // Avg. number of clusters 389 383 390 384 Ncl = gRandom->PoissonD(muClu); // Actual number of clusters … … 392 386 393 387 } 394 //388 // 395 389 return Signal; 396 390 } … … 413 407 // 414 408 // 415 /*416 std::vector<double> bg{ 0.5, 0.8, 1., 2., 3., 4., 5., 8., 10.,417 12., 15., 20., 50., 100., 200., 500., 1000. };418 // He 90 - Isobutane 10419 std::vector<double> ncl_He_Iso{ 42.94, 23.6,18.97,12.98,12.2,12.13,420 12.24,12.73,13.03,13.29,13.63,14.08,15.56,16.43,16.8,16.95,16.98 };421 //422 // pure He423 std::vector<double> ncl_He{ 11.79,6.5,5.23,3.59,3.38,3.37,3.4,3.54,3.63,424 3.7,3.8,3.92,4.33,4.61,4.78,4.87,4.89 };425 //426 // Argon 50 - Ethane 50427 std::vector<double> ncl_Ar_Eth{ 130.04,71.55,57.56,39.44,37.08,36.9,428 37.25,38.76,39.68,40.49,41.53,42.91,46.8,48.09,48.59,48.85,48.93 };429 //430 // pure Argon431 std::vector<double> ncl_Ar{ 88.69,48.93,39.41,27.09,25.51,25.43,25.69,432 26.78,27.44,28.02,28.77,29.78,32.67,33.75,34.24,34.57,34.68 };433 //434 Int_t nPoints = (Int_t)bg.size();435 bg.push_back(10000.);436 std::vector<double> ncl;437 switch (Opt)438 {439 case 0: ncl = ncl_He_Iso; // He-Isobutane440 break;441 case 1: ncl = ncl_He; // pure He442 break;443 case 2: ncl = ncl_Ar_Eth; // Argon - Ethane444 break;445 case 3: ncl = ncl_Ar; // pure Argon446 break;447 }448 ncl.push_back(ncl[nPoints - 1]);449 */450 409 const Int_t Npt = 18; 451 410 Double_t bg[Npt] = { 0.5, 0.8, 1., 2., 3., 4., 5., 8., 10., … … 469 428 // 470 429 Double_t ncl[Npt]; 471 472 473 430 switch (Opt) 431 { 432 case 0: std::copy(ncl_He_Iso, ncl_He_Iso + Npt, ncl); // He-Isobutane 474 433 break; 475 434 case 1: std::copy(ncl_He, ncl_He + Npt, ncl); // pure He 476 435 break; 477 436 case 2: std::copy(ncl_Ar_Eth, ncl_Ar_Eth + Npt, ncl); // Argon - Ethane 478 437 break; 479 438 case 3: std::copy(ncl_Ar, ncl_Ar + Npt, ncl); // pure Argon 480 439 break; 481 } 482 // 483 Int_t ilow = 0; 484 while (begam > bg[ilow])ilow++; 485 ilow--; 486 //std::cout << "ilow= " << ilow << ", low = " << bg[ilow] << ", val = " << begam 487 // << ", high = " << bg[ilow + 1] << std::endl; 488 // 489 Int_t ind[3] = { ilow, ilow + 1, ilow + 2 }; 490 TVectorD y(3); 491 for (Int_t i = 0; i < 3; i++)y(i) = ncl[ind[i]]; 492 TVectorD x(3); 493 for (Int_t i = 0; i < 3; i++)x(i) = bg[ind[i]]; 494 TMatrixD Xval(3, 3); 495 for (Int_t i = 0; i < 3; i++)Xval(i, 0) = 1.0; 496 for (Int_t i = 0; i < 3; i++)Xval(i, 1) = x(i); 497 for (Int_t i = 0; i < 3; i++)Xval(i, 2) = x(i) * x(i); 498 //std::cout << "Xval:" << std::endl; Xval.Print(); 499 Xval.Invert(); 500 TVectorD coeff = Xval * y; 501 Double_t interp = coeff[0] + coeff[1] * begam + coeff[2] * begam * begam; 502 //std::cout << "val1= (" <<x(0)<<", "<< y(0) << "), val2= (" 503 // <<x(1)<<", "<< y(1) << "), val3= (" 504 // <<x(2)<<", "<< y(2) 505 // << "), result= (" <<begam<<", "<< interp<<")" << std::endl; 506 // 507 //if (TMath::IsNaN(interp))std::cout << "NaN found: bg= " << begam << ", Opt= " << Opt << std::endl; 508 if (begam < bg[0]) interp = 0.0; 509 //std::cout << "bg= " << begam << ", Opt= " << Opt <<", interp = "<<interp<< std::endl; 510 return 100*interp; 511 } 512 // 513 Double_t TrkUtil::funcNcl(Double_t *xp, Double_t *par){ 440 } 441 // 442 Double_t interp = 0.0; 443 TSpline3* sp3 = new TSpline3("sp3", bg, ncl, Npt); 444 if (begam > bg[0] && begam < bg[Npt - 1]) interp = sp3->Eval(begam); 445 if(begam < bg[0]) interp = bg[0]; 446 if(begam > bg[Npt-1]) interp = bg[Npt-1]; 447 return 100 * interp; 448 } 449 // 450 Double_t TrkUtil::funcNcl(Double_t* xp, Double_t* par) { 514 451 Double_t bg = xp[0]; 515 452 return Nclusters(bg);
Note:
See TracChangeset
for help on using the changeset viewer.