Changes in modules/ParticlePropagator.cc [341014c:5b51d33] in git
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
modules/ParticlePropagator.cc
r341014c r5b51d33 17 17 */ 18 18 19 19 20 /** \class ParticlePropagator 20 21 * … … 34 35 #include "classes/DelphesFormula.h" 35 36 37 #include "ExRootAnalysis/ExRootResult.h" 38 #include "ExRootAnalysis/ExRootFilter.h" 36 39 #include "ExRootAnalysis/ExRootClassifier.h" 37 #include "ExRootAnalysis/ExRootFilter.h" 38 #include "ExRootAnalysis/ExRootResult.h" 39 40 41 #include "TMath.h" 42 #include "TString.h" 43 #include "TFormula.h" 44 #include "TRandom3.h" 45 #include "TObjArray.h" 40 46 #include "TDatabasePDG.h" 41 #include "TFormula.h"42 47 #include "TLorentzVector.h" 43 #include "TMath.h"44 #include "TObjArray.h"45 #include "TRandom3.h"46 #include "TString.h"47 48 48 49 #include <algorithm> 50 #include <stdexcept> 49 51 #include <iostream> 50 52 #include <sstream> 51 #include <stdexcept>52 53 53 54 using namespace std; … … 66 67 } 67 68 69 68 70 //------------------------------------------------------------------------------ 69 71 … … 71 73 { 72 74 fRadius = GetDouble("Radius", 1.0); 73 fRadius2 = fRadius *fRadius;75 fRadius2 = fRadius*fRadius; 74 76 fHalfLength = GetDouble("HalfLength", 3.0); 75 77 fBz = GetDouble("Bz", 0.0); … … 138 140 const Double_t c_light = 2.99792458E8; 139 141 140 if (!fBeamSpotInputArray || fBeamSpotInputArray->GetSize() == 0)142 if (!fBeamSpotInputArray || fBeamSpotInputArray->GetSize () == 0) 141 143 beamSpotPosition.SetXYZT(0.0, 0.0, 0.0, 0.0); 142 144 else 143 145 { 144 Candidate &beamSpotCandidate = *((Candidate *) fBeamSpotInputArray->At(0));146 Candidate &beamSpotCandidate = *((Candidate *) fBeamSpotInputArray->At(0)); 145 147 beamSpotPosition = beamSpotCandidate.Position; 146 148 } 147 149 148 150 fItInputArray->Reset(); 149 while((candidate = static_cast<Candidate 151 while((candidate = static_cast<Candidate*>(fItInputArray->Next()))) 150 152 { 151 153 if(candidate->GetCandidates()->GetEntriesFast() == 0) … … 155 157 else 156 158 { 157 particle = static_cast<Candidate 159 particle = static_cast<Candidate*>(candidate->GetCandidates()->At(0)); 158 160 } 159 161 160 162 particlePosition = particle->Position; 161 163 particleMomentum = particle->Momentum; 162 x = particlePosition.X() *1.0E-3;163 y = particlePosition.Y() *1.0E-3;164 z = particlePosition.Z() *1.0E-3;165 166 bsx = beamSpotPosition.X() *1.0E-3;167 bsy = beamSpotPosition.Y() *1.0E-3;168 bsz = beamSpotPosition.Z() *1.0E-3;164 x = particlePosition.X()*1.0E-3; 165 y = particlePosition.Y()*1.0E-3; 166 z = particlePosition.Z()*1.0E-3; 167 168 bsx = beamSpotPosition.X()*1.0E-3; 169 bsy = beamSpotPosition.Y()*1.0E-3; 170 bsz = beamSpotPosition.Z()*1.0E-3; 169 171 170 172 q = particle->Charge; … … 191 193 { 192 194 mother = candidate; 193 candidate = static_cast<Candidate 195 candidate = static_cast<Candidate*>(candidate->Clone()); 194 196 195 197 candidate->InitialPosition = particlePosition; … … 205 207 { 206 208 // solve pt2*t^2 + 2*(px*x + py*y)*t - (fRadius2 - x*x - y*y) = 0 207 tmp = px * y - py *x;208 discr2 = pt2 * fRadius2 - tmp *tmp;209 tmp = px*y - py*x; 210 discr2 = pt2*fRadius2 - tmp*tmp; 209 211 210 212 if(discr2 < 0.0) … … 214 216 } 215 217 216 tmp = px * x + py *y;218 tmp = px*x + py*y; 217 219 discr = TMath::Sqrt(discr2); 218 t1 = (-tmp + discr) /pt2;219 t2 = (-tmp - discr) /pt2;220 t1 = (-tmp + discr)/pt2; 221 t2 = (-tmp - discr)/pt2; 220 222 t = (t1 < 0.0) ? t2 : t1; 221 223 222 z_t = z + pz *t;224 z_t = z + pz*t; 223 225 if(TMath::Abs(z_t) > fHalfLength) 224 226 { … … 228 230 } 229 231 230 x_t = x + px *t;231 y_t = y + py *t;232 z_t = z + pz *t;233 234 l = TMath::Sqrt( (x_t - x) * (x_t - x) + (y_t - y) * (y_t - y) + (z_t - z) *(z_t - z));232 x_t = x + px*t; 233 y_t = y + py*t; 234 z_t = z + pz*t; 235 236 l = TMath::Sqrt( (x_t - x)*(x_t - x) + (y_t - y)*(y_t - y) + (z_t - z)*(z_t - z)); 235 237 236 238 mother = candidate; 237 candidate = static_cast<Candidate 239 candidate = static_cast<Candidate*>(candidate->Clone()); 238 240 239 241 candidate->InitialPosition = particlePosition; 240 candidate->Position.SetXYZT(x_t * 1.0E3, y_t * 1.0E3, z_t * 1.0E3, particlePosition.T() + t * e *1.0E3);241 candidate->L = l *1.0E3;242 candidate->Position.SetXYZT(x_t*1.0E3, y_t*1.0E3, z_t*1.0E3, particlePosition.T() + t*e*1.0E3); 243 candidate->L = l*1.0E3; 242 244 243 245 candidate->Momentum = particleMomentum; … … 249 251 switch(TMath::Abs(candidate->PID)) 250 252 { 251 case 11:252 fElectronOutputArray->Add(candidate);253 break;254 case 13:255 fMuonOutputArray->Add(candidate);256 break;257 default:258 fChargedHadronOutputArray->Add(candidate);253 case 11: 254 fElectronOutputArray->Add(candidate); 255 break; 256 case 13: 257 fMuonOutputArray->Add(candidate); 258 break; 259 default: 260 fChargedHadronOutputArray->Add(candidate); 259 261 } 260 262 } 261 263 else 262 264 { 263 fNeutralOutputArray->Add(candidate);265 fNeutralOutputArray->Add(candidate); 264 266 } 265 267 } … … 273 275 // helix radius r = p_{T0} / (omega gamma m) 274 276 275 gammam = e * 1.0E9 / (c_light * c_light);// gammam in [eV/c^2]276 omega = q * fBz / (gammam); // omega is here in [89875518/s]277 r = pt / (q * fBz) * 1.0E9 / c_light;// in [m]277 gammam = e*1.0E9 / (c_light*c_light); // gammam in [eV/c^2] 278 omega = q * fBz / (gammam); // omega is here in [89875518/s] 279 r = pt / (q * fBz) * 1.0E9/c_light; // in [m] 278 280 279 281 phi_0 = TMath::ATan2(py, px); // [rad] in [-pi, pi] 280 282 281 283 // 2. helix axis coordinates 282 x_c = x + r *TMath::Sin(phi_0);283 y_c = y - r *TMath::Cos(phi_0);284 x_c = x + r*TMath::Sin(phi_0); 285 y_c = y - r*TMath::Cos(phi_0); 284 286 r_c = TMath::Hypot(x_c, y_c); 285 287 phi_c = TMath::ATan2(y_c, x_c); … … 288 290 289 291 rcu = TMath::Abs(r); 290 rc2 = r_c *r_c;292 rc2 = r_c*r_c; 291 293 292 294 // calculate coordinates of closest approach to track circle in transverse plane xd, yd, zd 293 xd = x_c * x_c * x_c - x_c * rcu * r_c + x_c * y_c *y_c;295 xd = x_c*x_c*x_c - x_c*rcu*r_c + x_c*y_c*y_c; 294 296 xd = (rc2 > 0.0) ? xd / rc2 : -999; 295 yd = y_c * (-rcu *r_c + rc2);297 yd = y_c*(-rcu*r_c + rc2); 296 298 yd = (rc2 > 0.0) ? yd / rc2 : -999; 297 zd = z + (TMath::Sqrt(xd * xd + yd * yd) - TMath::Sqrt(x * x + y * y)) * pz /pt;299 zd = z + (TMath::Sqrt(xd*xd + yd*yd) - TMath::Sqrt(x*x + y*y))*pz/pt; 298 300 299 301 // use perigee momentum rather than original particle … … 309 311 // calculate additional track parameters (correct for beamspot position) 310 312 311 d0 = ((x - bsx) * py - (y - bsy) * px) / pt; 312 dz = z - ((x - bsx) * px + (y - bsy) * py) / pt * (pz / pt); 313 p = particleMomentum.P(); 314 ctgTheta = 1.0 / TMath::Tan(particleMomentum.Theta()); 313 d0 = ((x - bsx) * py - (y - bsy) * px) / pt; 314 dz = z - ((x - bsx) * px + (y - bsy) * py) / pt * (pz / pt); 315 p = particleMomentum.P(); 316 ctgTheta = 1.0 / TMath::Tan (particleMomentum.Theta()); 317 315 318 316 319 // 3. time evaluation t = TMath::Min(t_r, t_z) … … 319 322 t_r = 0.0; // in [ns] 320 323 int sign_pz = (pz > 0.0) ? 1 : -1; 321 if(pz == 0.0) 322 t_z = 1.0E99; 323 else 324 t_z = gammam / (pz * 1.0E9 / c_light) * (-z + fHalfLength * sign_pz); 325 326 if(r_c + TMath::Abs(r) < fRadius) 324 if(pz == 0.0) t_z = 1.0E99; 325 else t_z = gammam / (pz*1.0E9/c_light) * (-z + fHalfLength*sign_pz); 326 327 if(r_c + TMath::Abs(r) < fRadius) 327 328 { 328 329 // helix does not cross the cylinder sides … … 331 332 else 332 333 { 333 asinrho = TMath::ASin((fRadius * fRadius - r_c * r_c - r * r) / (2 * TMath::Abs(r) *r_c));334 asinrho = TMath::ASin((fRadius*fRadius - r_c*r_c - r*r) / (2*TMath::Abs(r)*r_c)); 334 335 delta = phi_0 - phi; 335 if(delta < -TMath::Pi()) delta += 2 *TMath::Pi();336 if(delta > TMath::Pi()) delta -= 2 *TMath::Pi();336 if(delta <-TMath::Pi()) delta += 2*TMath::Pi(); 337 if(delta > TMath::Pi()) delta -= 2*TMath::Pi(); 337 338 t1 = (delta + asinrho) / omega; 338 339 t2 = (delta + TMath::Pi() - asinrho) / omega; … … 358 359 x_t = x_c + r * TMath::Sin(omega * t - phi_0); 359 360 y_t = y_c + r * TMath::Cos(omega * t - phi_0); 360 z_t = z + pz *1.0E9 / c_light / gammam * t;361 z_t = z + pz*1.0E9 / c_light / gammam * t; 361 362 r_t = TMath::Hypot(x_t, y_t); 362 363 364 363 365 // compute path length for an helix 364 366 365 alpha = pz *1.0E9 / c_light / gammam;366 l = t * TMath::Sqrt(alpha * alpha + r * r * omega *omega);367 alpha = pz*1.0E9 / c_light / gammam; 368 l = t * TMath::Sqrt(alpha*alpha + r*r*omega*omega); 367 369 368 370 if(r_t > 0.0) … … 372 374 if(particle == candidate) 373 375 { 374 particle->D0 = d0 *1.0E3;375 particle->DZ = dz *1.0E3;376 particle->D0 = d0*1.0E3; 377 particle->DZ = dz*1.0E3; 376 378 particle->P = p; 377 379 particle->PT = pt; … … 381 383 382 384 mother = candidate; 383 candidate = static_cast<Candidate 385 candidate = static_cast<Candidate*>(candidate->Clone()); 384 386 385 387 candidate->InitialPosition = particlePosition; 386 candidate->Position.SetXYZT(x_t * 1.0E3, y_t * 1.0E3, z_t * 1.0E3, particlePosition.T() + t * c_light *1.0E3);388 candidate->Position.SetXYZT(x_t*1.0E3, y_t*1.0E3, z_t*1.0E3, particlePosition.T() + t*c_light*1.0E3); 387 389 388 390 candidate->Momentum = particleMomentum; 389 391 390 candidate->L = l *1.0E3;391 392 candidate->Xd = xd *1.0E3;393 candidate->Yd = yd *1.0E3;394 candidate->Zd = zd *1.0E3;392 candidate->L = l*1.0E3; 393 394 candidate->Xd = xd*1.0E3; 395 candidate->Yd = yd*1.0E3; 396 candidate->Zd = zd*1.0E3; 395 397 396 398 candidate->AddCandidate(mother); … … 399 401 switch(TMath::Abs(candidate->PID)) 400 402 { 401 case 11:402 fElectronOutputArray->Add(candidate);403 break;404 case 13:405 fMuonOutputArray->Add(candidate);406 break;407 default:408 fChargedHadronOutputArray->Add(candidate);403 case 11: 404 fElectronOutputArray->Add(candidate); 405 break; 406 case 13: 407 fMuonOutputArray->Add(candidate); 408 break; 409 default: 410 fChargedHadronOutputArray->Add(candidate); 409 411 } 410 412 } … … 414 416 415 417 //------------------------------------------------------------------------------ 418
Note:
See TracChangeset
for help on using the changeset viewer.