176 TVector3 dumori( 0.0, 0.0, 0.0 );
186 ctree->GetEntry(iEntry);
189 bool canGoForward =
true;
222 fDx = tmpVec.X();
fDy = tmpVec.Y();
fDz = tmpVec.Z();
228 TVector3 fDvec_user( fDvec_beam.X() -
fCx, fDvec_beam.Y() -
fCy, fDvec_beam.Z() -
fCz );
235 TVector3 detO_beam( fCvec_beam.X() - fDvec_beam.X(),
236 fCvec_beam.Y() - fDvec_beam.Y(),
237 fCvec_beam.Z() - fDvec_beam.Z() );
238 TVector3 detO( fCvec.X() - fDvec.X(),
239 fCvec.Y() - fDvec.Y(),
240 fCvec.Z() - fDvec.Z() );
241 TVector3 detO_user( detO_beam.X(), detO_beam.Y(), detO_beam.Z() );
251 TVector3 tmpVec( dpdpx, dpdpy, dpdpz );
253 dpdpx = tmpVec.X(); dpdpy = tmpVec.Y(); dpdpz = tmpVec.Z();
261 <<
"\n\tProceeding, but results are possibly unphysical.";
264 parentMomentum = std::sqrt( dpdpx*dpdpx + dpdpy*dpdpy + dpdpz*dpdpz );
274 TLorentzVector p4par_beam( dpdpx, dpdpy, dpdpz,
parentEnergy );
275 TVector3 p3par_beam = p4par_beam.Vect();
277 TLorentzVector p4par_near( p3par_near.X(), p3par_near.Y(), p3par_near.Z(),
parentEnergy );
284 p4par.SetPxPyPzE( tmpv3.Px(), tmpv3.Py(), tmpv3.Pz(), p4par.E() );
287 TLorentzVector p4par_user = p4par_near;
289 TVector3 ppar_user = p4par_user.Vect();
291 p4par_user.SetPxPyPzE( ppar_user.Px(), ppar_user.Py(), ppar_user.Pz(), p4par_user.E() );
293 TVector3 boost_beta = p4par_beam.BoostVector();
304 double score = rnd->
RndGen().Uniform( 0.0, 1.0 );
308 unsigned int imap = 0;
double s1 = 0.0;
309 std::map< HNLProd_t, double >::iterator pdit =
dynamicScores.begin();
311 s1 += (*pdit).second;
315 <<
" : (*pdit).second = " << (*pdit).second;
322 prodChan = (*pdit).first;
345 TLorentzVector p4HNL_rest =
HNLEnergy( prodChan, p4par );
347 fECM = p4HNL_rest.E();
350 double boost_correction_two = 0.0;
355 double betaMag = boost_beta.Mag();
356 double gamma = std::sqrt( 1.0 / ( 1.0 - betaMag * betaMag ) );
357 double betaLab = 1.0;
360 double timeBit = detO.Mag();
361 TLorentzVector detO_4v( detO.X(), detO.Y(), detO.Z(), timeBit ); detO_4v.Boost( -boost_beta );
362 TVector3 detO_rest_unit = (detO_4v.Vect()).Unit();
363 TLorentzVector p4HNL_rest_good( p4HNL_rest.P() * detO_rest_unit.X(),
364 p4HNL_rest.P() * detO_rest_unit.Y(),
365 p4HNL_rest.P() * detO_rest_unit.Z(),
369 TLorentzVector p4Lep_rest_good( -1.0 * pLep_rest * detO_rest_unit.X(),
370 -1.0 * pLep_rest * detO_rest_unit.Y(),
371 -1.0 * pLep_rest * detO_rest_unit.Z(),
376 TLorentzVector p4HNL_good = p4HNL_rest_good;
377 p4HNL_good.Boost( boost_beta );
378 boost_correction_two = p4HNL_good.E() / p4HNL_rest.E();
380 TVector3 detO_unit = detO.Unit();
382 TVector3 p4HNL_good_vect = p4HNL_good.Vect();
383 TVector3 p4HNL_good_unit = p4HNL_good_vect.Unit();
387 TVector3 distNum = detO.Cross( p4HNL_good_unit );
388 double dist = distNum.Mag();
390 double prevDist = 2.0 * dist;
392 while( betaLab > 0.0 && ( dist > 1.0e-3 && dist < prevDist &&
393 std::abs(dist - prevDist) > 1.0e-3 * prevDist ) ){
398 timeBit = detO.Mag() / ( betaLab );
399 detO_4v.SetXYZT( detO.X(), detO.Y(), detO.Z(), timeBit );
400 detO_4v.Boost( -boost_beta );
401 detO_rest_unit = (detO_4v.Vect()).Unit();
402 p4HNL_rest_good.SetPxPyPzE( p4HNL_rest.P() * detO_rest_unit.X(),
403 p4HNL_rest.P() * detO_rest_unit.Y(),
404 p4HNL_rest.P() * detO_rest_unit.Z(),
408 p4HNL_good = p4HNL_rest_good;
409 p4HNL_good.Boost( boost_beta );
411 detO_unit = detO.Unit();
412 p4HNL_good_vect = p4HNL_good.Vect();
413 p4HNL_good_unit = p4HNL_good_vect.Unit();
415 distNum = detO.Cross( p4HNL_good_unit );
416 dist = distNum.Mag();
431 double betaHNL = p4HNL_good.P() / p4HNL_good.E();
432 double costh_pardet = 0.0;
433 double boost_correction = 0.0;
435 costh_pardet = ( p4par_beam.X() * detO.X() +
436 p4par_beam.Y() * detO.Y() +
438 if( costh_pardet < -1.0 ) costh_pardet = -1.0;
439 if( costh_pardet > 1.0 ) costh_pardet = 1.0;
440 boost_correction = 1.0 / ( gamma * ( 1.0 - betaMag * betaHNL * costh_pardet ) );
442 if(
true && boost_correction * p4HNL_rest.E() > p4HNL_rest.M() ) {
443 boost_correction = 1.0 / ( gamma * ( 1.0 - betaMag * betaHNL * costh_pardet ) );
445 boost_correction = p4HNL_good.E() / p4HNL_rest_good.E();
449 assert( boost_correction > 0.0 && boost_correction_two > 0.0 );
452 double EHNL = p4HNL_rest.E() * boost_correction;
453 double MHNL = p4HNL_rest.M();
454 double PHNL = std::sqrt( EHNL * EHNL - MHNL * MHNL );
455 TVector3 pdu = ( p4par.Vect() ).Unit();
456 TLorentzVector p4HNL_rand( PHNL * pdu.X(), PHNL * pdu.Y(), PHNL * pdu.Z(), EHNL );
460 double FDx = fDvec_beam.X();
461 double FDy = fDvec_beam.Y();
462 double FDz = fDvec_beam.Z();
465 TVector3 fRVec_beam( absolutePoint.X() - FDx, absolutePoint.Y() - FDy, absolutePoint.Z() - FDz );
472 TVector3 rRVec_near( fRVec_beam.X() + FDx, fRVec_beam.Y() + FDy, fRVec_beam.Z() + FDz );
480 rRVec_user.SetXYZ( rRVec_user.X() + (
fCx),
481 rRVec_user.Y() + (
fCy),
482 rRVec_user.Z() + (
fCz) );
485 TLorentzVector p4HNL( p4HNL_rand.P() * fRVec_unit.X(),
486 p4HNL_rand.P() * fRVec_unit.Y(),
487 p4HNL_rand.P() * fRVec_unit.Z(),
491 TLorentzVector p4HNL_near( pHNL_near.X(), pHNL_near.Y(), pHNL_near.Z(), p4HNL.E() );
499 TLorentzVector p4Lep_good = p4Lep_rest_good;
500 p4Lep_good.Boost( boost_beta );
501 TVector3 boost_beta_HNL = p4HNL_near.BoostVector();
502 p4Lep_good.Boost( -boost_beta_HNL );
510 double zm = 0.0, zp = 0.0;
518 if( zm == -999.9 && zp == 999.9 ){
523 double tzm = zm, tzp = zp;
525 zp = (tzp - tzm)/2.0;
536 int iAccFail = 0;
const int iAccFailBail = 10;
537 while( iAccFail < iAccFailBail && accCorr == 0.0 ){
541 <<
"\nRerolling point. This is the " << iAccFail <<
"th try out of " << iAccFailBail;
551 fRVec_beam.SetXYZ( absolutePoint.X() - (
fCx),
552 absolutePoint.Y() - (
fCy),
553 absolutePoint.Z() - (
fCz) );
557 p4HNL.SetPxPyPzE( p4HNL_rand.P() * fRVec_unit.X(),
558 p4HNL_rand.P() * fRVec_unit.Y(),
559 p4HNL_rand.P() * fRVec_unit.Z(),
563 p4HNL_near.SetPxPyPzE( pHNL_near.X(), pHNL_near.Y(), pHNL_near.Z(), p4HNL.E() );
571 p4Lep_good = p4Lep_rest_good;
572 p4Lep_good.Boost( boost_beta );
573 boost_beta_HNL = p4HNL_near.BoostVector();
574 p4Lep_good.Boost( -boost_beta_HNL );
590 if( zm == -999.9 && zp == 999.9 ){
595 double tzm = zm, tzp = zp;
597 zp = (tzp - tzm)/2.0;
604 if( accCorr == 0.0 ){
610 double acceptance = acc_saa * boost_correction * boost_correction * accCorr;
615 double detDist = std::sqrt( detO.X() * detO.X() +
616 detO.Y() * detO.Y() +
617 detO.Z() * detO.Z() );
619 double delay = detDist / kSpeedOfLightNs * ( 1.0 / betaHNL - 1.0 );
634 TVector3 tmpVec( dxvx, dxvy, dxvz );
636 dxvx = tmpVec.X(); dxvy = tmpVec.Y(); dxvz = tmpVec.Z();
639 TLorentzVector x4HNL_beam( dxvx, dxvy, dxvz, delay );
640 TVector3 x3HNL_beam = x4HNL_beam.Vect();
642 TLorentzVector x4HNL_near( x3HNL_near.X(), x3HNL_near.Y(), x3HNL_near.Z(), delay );
644 TLorentzVector x4HNL( fDvec_user.X(), fDvec_user.Y(), fDvec_user.Z(), delay );
649 LOG(
"HNL",
pDEBUG ) <<
"Filling gnmf...";
657 if( std::abs(parPdg) ==
kPdgMuon ) typeMod *= -1;
669 gnmf.
startPoint.SetXYZ( fDvec_beam.X(), fDvec_beam.Y(), fDvec_beam.Z() );
677 TLorentzVector p4HNL_user = p4HNL_near;
679 TVector3 pHNL_user = p4HNL_user.Vect();
681 p4HNL_user.SetPxPyPzE( pHNL_user.Px(), pHNL_user.Py(), pHNL_user.Pz(), p4HNL_user.E() );
683 gnmf.
p4 = p4HNL_near;
684 gnmf.
parp4 = p4par_near;
691 gnmf.
XYWgt = acc_saa;
1030 switch( std::abs( parPDG ) ){
1035 default:
LOG(
"HNL",
pWARN ) <<
"Unknown parent. Proceeding, but results may be unphysical";
break;
1038 std::map< HNLProd_t, double > dynScores;
1044 double Ue42 =
fU4l2s.at(0);
1045 double Um42 =
fU4l2s.at(1);
1046 double Ut42 =
fU4l2s.at(2);
1053 double KScale[4] = { -1.0, -1.0, -1.0, -1.0 }, mixScale[4] = { -1.0, -1.0, -1.0, -1.0 };
1054 double totalMix = 0.0;
1055 switch( std::abs( parPDG ) ){
1060 mixScale[0] = 1.0 * Um42 * KScale[0]; totalMix += mixScale[0];
1061 mixScale[1] = 1.0 * Ue42 * KScale[1]; totalMix += mixScale[1];
1062 mixScale[2] = 1.0 * Ut42 * KScale[2]; totalMix += mixScale[2];
1064 dynScores.insert( std::pair< HNLProd_t, double >( {
kHNLProdMuon3Numu, mixScale[0] / totalMix } ) );
1065 dynScores.insert( std::pair< HNLProd_t, double >( {
kHNLProdMuon3Nue, mixScale[1] / totalMix } ) );
1066 dynScores.insert( std::pair< HNLProd_t, double >( {
kHNLProdMuon3Nutau, mixScale[2] / totalMix } ) );
1070 if( totalMix <= 0.0 ){
1071 dynScores.insert( std::pair< HNLProd_t, double >( {
kHNLProdNull, -999.9 } ) );
1083 mixScale[0] =
BR_K2mu * Um42 * KScale[0]; totalMix += mixScale[0];
1084 mixScale[1] =
BR_K2e * Ue42 * KScale[1]; totalMix += mixScale[1];
1085 mixScale[2] =
BR_K3mu * Um42 * KScale[2]; totalMix += mixScale[2];
1086 mixScale[3] =
BR_K3e * Ue42 * KScale[3]; totalMix += mixScale[3];
1088 if( totalMix <= 0.0 ){
1089 dynScores.insert( std::pair< HNLProd_t, double >( {
kHNLProdNull, -999.9 } ) );
1094 dynScores.insert( std::pair< HNLProd_t, double >( {
kHNLProdKaon2Muon, mixScale[0] / totalMix } ) );
1095 dynScores.insert( std::pair< HNLProd_t, double >( {
kHNLProdKaon2Electron, mixScale[1] / totalMix } ) );
1096 dynScores.insert( std::pair< HNLProd_t, double >( {
kHNLProdKaon3Muon, mixScale[2] / totalMix } ) );
1097 dynScores.insert( std::pair< HNLProd_t, double >( {
kHNLProdKaon3Electron, mixScale[3] / totalMix } ) );
1105 mixScale[0] =
BR_pi2mu * Um42 * KScale[0]; totalMix += mixScale[0];
1106 mixScale[1] =
BR_pi2e * Ue42 * KScale[1]; totalMix += mixScale[1];
1108 if( totalMix <= 0.0 ){
1109 dynScores.insert( std::pair< HNLProd_t, double >( {
kHNLProdNull, -999.9 } ) );
1114 dynScores.insert( std::pair< HNLProd_t, double >( {
kHNLProdPion2Muon, mixScale[0] / totalMix } ) );
1115 dynScores.insert( std::pair< HNLProd_t, double >( {
kHNLProdPion2Electron, mixScale[1] / totalMix } ) );
1123 mixScale[0] =
BR_K03mu * Um42 * KScale[0]; totalMix += mixScale[0];
1124 mixScale[1] =
BR_K03e * Ue42 * KScale[1]; totalMix += mixScale[1];
1126 if( totalMix <= 0.0 ){
1127 dynScores.insert( std::pair< HNLProd_t, double >( {
kHNLProdNull, -999.9 } ) );
1132 dynScores.insert( std::pair< HNLProd_t, double >( {
kHNLProdNeuk3Muon, mixScale[0] / totalMix } ) );
1133 dynScores.insert( std::pair< HNLProd_t, double >( {
kHNLProdNeuk3Electron, mixScale[1] / totalMix } ) );
1139 <<
"Unknown parent particle. Cannot make scales, exiting."; exit(1);
1143 <<
"Score map now has " << dynScores.size() <<
" elements. Returning.";
1151 TLorentzVector p4par_rest = p4par;
1152 TVector3 boost_beta = p4par.BoostVector();
1153 p4par_rest.Boost( -boost_beta );
1161 bool allow_duplicate =
true;
1163 double * mass =
new double[decayList.size()];
1166 for( std::vector<int>::const_iterator pdg_iter = fullList.begin(); pdg_iter != fullList.end(); ++pdg_iter )
1168 if( pdg_iter != fullList.begin() ){
1169 int pdgc = *pdg_iter;
1175 for( std::vector<int>::const_iterator pdg_iter = decayList.begin(); pdg_iter != decayList.end(); ++pdg_iter )
1177 int pdgc = *pdg_iter;
1179 mass[iv++] = m; sum += m;
1183 TGenPhaseSpace fPhaseSpaceGenerator;
1184 bool permitted = fPhaseSpaceGenerator.SetDecay( p4par_rest, decayList.size(), mass );
1187 <<
" *** Phase space decay is not permitted \n"
1188 <<
" Total particle mass = " << sum <<
"\n"
1194 exception.
SetReason(
"Decay not permitted kinematically");
1201 for(
int idec=0; idec<200; idec++) {
1202 double w = fPhaseSpaceGenerator.Generate();
1203 wmax = TMath::Max(wmax,w);
1209 <<
"Max phase space gen. weight @ current HNL system: " << wmax;
1214 bool accept_decay=
false;
1215 unsigned int itry=0;
1216 while(!accept_decay)
1223 <<
"Couldn't generate an unweighted phase space decay after "
1224 << itry <<
" attempts";
1229 exception.
SetReason(
"Couldn't select decay after N attempts");
1233 double w = fPhaseSpaceGenerator.Generate();
1236 <<
"Decay weight = " << w <<
" > max decay weight = " << wmax;
1238 double gw = wmax * rnd->
RndHadro().Rndm();
1239 accept_decay = (gw<=w);
1242 <<
"Decay weight = " << w <<
" / R = " << gw
1243 <<
" - accepted: " << accept_decay;
1248 int idp = 0; TLorentzVector p4HNL, p4HNL_rest;
1250 TLorentzVector p4Lep, p4Lep_HNLRest;
1252 p4HNL.SetPxPyPzE( 0.0, 0.0, 0.0, 0.0 );
1253 p4HNL_rest.SetPxPyPzE( 0.0, 0.0, 0.0, 0.0 );
1254 p4Lep.SetPxPyPzE( 0.0, 0.0, 0.0, 0.0 );
1255 p4Lep_HNLRest.SetPxPyPzE( 0.0, 0.0, 0.0, 0.0 );
1257 for(std::vector<int>::const_iterator pdg_iter = decayList.begin(); pdg_iter != decayList.end(); ++pdg_iter) {
1258 int pdgc = *pdg_iter;
1259 TLorentzVector * p4fin = fPhaseSpaceGenerator.GetDecay(idp);
1261 if( std::abs( pdgc ) ==
kPdgHNL ) p4HNL = *p4fin;
1264 std::abs( pdgc ) ==
kPdgTau ){
1273 TVector3 boostHNL = p4HNL.BoostVector();
1274 p4Lep_HNLRest = p4Lep;
fLPE = p4Lep_HNLRest.E();
1275 p4Lep_HNLRest.Boost( boostHNL );
1350 TVector3 ppar = p4par.Vect(); assert( ppar.Mag() > 0.0 );
1351 TVector3 pparUnit = ppar.Unit();
1354 double Qx = 0.0, Qy = 0.0, Qz = 1.0;
1360 double nterm = Qx * detO.X() + Qy * detO.Y() + Qz * detO.Z();
1361 double dterm = Qx * ppar.X() + Qy * ppar.Y() + Qz * ppar.Z();
1362 double t = nterm / dterm;
1363 double x_incp = t * pparUnit.X(), y_incp = t * pparUnit.Y(), z_incp = t * pparUnit.Z();
1367 TVector3 IPdev( detO.X() - x_incp, detO.Y() - y_incp, detO.Z() - z_incp );
1374 double ttx = ( IPdev.X() != 0.0 ) ?
fLx / std::abs( IPdev.X() ) : 99999.9;
1375 double tty = ( IPdev.Y() != 0.0 ) ?
fLy / std::abs( IPdev.Y() ) : 99999.9;
1376 double tt = std::max( ttx, tty );
1377 TVector3 atilde( tt * IPdev.X(), tt * IPdev.Y(), tt * IPdev.Z() );
1379 double fLT = IPdev.Mag();
1380 double dist = atilde.Mag();
1382 assert( fLT > 0.0 );
1383 double detRadius = std::max(
fLx,
fLy ) / 2.0;
1385 if( parentHitsCentre ){
1390 TVector3 r1VecPrim( -pparUnit.Y(), pparUnit.X(), 0.0 );
1391 TVector3 r1Vec = r1VecPrim.Unit();
1392 r1Vec.Rotate( phi, pparUnit );
1393 TVector3 r2Vec( r1Vec ); r2Vec.Rotate( 0.5 *
constants::kPi, pparUnit );
1395 double rprod = r1Vec.X() * r2Vec.X() + r1Vec.Y() * r2Vec.Y() + r1Vec.Z() * r2Vec.Z();
1400 TVector3 p1( detO.X() + detRadius*r1Vec.X(),
1401 detO.Y() + detRadius*r1Vec.Y(),
1402 detO.Z() + detRadius*r1Vec.Z() );
1403 TVector3 p2( detO.X() - detRadius*r1Vec.X(),
1404 detO.Y() - detRadius*r1Vec.Y(),
1405 detO.Z() - detRadius*r1Vec.Z() );
1406 TVector3 p3( detO.X() + detRadius*r2Vec.X(),
1407 detO.Y() + detRadius*r2Vec.Y(),
1408 detO.Z() + detRadius*r2Vec.Z() );
1409 TVector3 p4( detO.X() - detRadius*r2Vec.X(),
1410 detO.Y() - detRadius*r2Vec.Y(),
1411 detO.Z() - detRadius*r2Vec.Z() );
1414 double thLarge = -999.9;
double thSmall = 999.9;
1415 double th1 = TMath::ACos( ( p1.X()*pparUnit.X() + p1.Y()*pparUnit.Y() + p1.Z()*pparUnit.Z() ) / p1.Mag() );
if( th1 > thLarge ){ thLarge = th1; }
else if( th1 < thSmall ){ thSmall = th1; }
1416 double th2 = TMath::ACos( ( p2.X()*pparUnit.X() + p2.Y()*pparUnit.Y() + p2.Z()*pparUnit.Z() ) / p2.Mag() );
if( th2 > thLarge ){ thLarge = th2; }
else if( th2 < thSmall ){ thSmall = th2; }
1417 double th3 = TMath::ACos( ( p3.X()*pparUnit.X() + p3.Y()*pparUnit.Y() + p3.Z()*pparUnit.Z() ) / p3.Mag() );
if( th3 > thLarge ){ thLarge = th3; }
else if( th3 < thSmall ){ thSmall = th3; }
1418 double th4 = TMath::ACos( ( p4.X()*pparUnit.X() + p4.Y()*pparUnit.Y() + p4.Z()*pparUnit.Z() ) / p4.Mag() );
if( th4 > thLarge ){ thLarge = th4; }
else if( th4 < thSmall ){ thSmall = th4; }
1423 TVector3 rVec = IPdev.Unit();
1426 double dh = fLT + dist, dl = fLT - dist;
1428 TVector3 ph( x_incp + dh * rVec.X(), y_incp + dh * rVec.Y(), z_incp + dh * rVec.Z() );
1429 TVector3 pl( x_incp - dl * rVec.X(), y_incp - dl * rVec.Y(), z_incp - dl * rVec.Z() );
1430 double thh = TMath::ACos( ( ph.X()*pparUnit.X() + ph.Y()*pparUnit.Y() + ph.Z()*pparUnit.Z() ) / ph.Mag() );
1431 double thl = TMath::ACos( ( pl.X()*pparUnit.X() + pl.Y()*pparUnit.Y() + pl.Z()*pparUnit.Z() ) / pl.Mag() );
1437 <<
"Could not calculate the angle range for detector at ( " << detO.X() <<
", "
1438 << detO.Y() <<
", " << detO.Z() <<
" ) [m] from HNL production point with parent momentum = ( "
1439 << ppar.X() <<
", " << ppar.Y() <<
", " << ppar.Z() <<
" ) [GeV]. Returning zero.";
1448 TVector3 ppar = p4par.Vect(); assert( ppar.Mag() > 0.0 );
1449 TVector3 pparUnit = ppar.Unit();
1451 const double sx1 = TMath::Sin(
fBx1), cx1 = TMath::Cos(
fBx1);
1452 const double sz = TMath::Sin(
fBz), cz = TMath::Cos(
fBz);
1453 const double sx2 = TMath::Sin(
fBx2), cx2 = TMath::Cos(
fBx2);
1455 const double xun[3] = { cz, -cx1*sz, sx1*sz };
1456 const double yun[3] = { sz*cx2, cx1*cz*cx2 - sx1*sx2, -sx1*cz*cx2 - cx1*sx2 };
1457 const double zun[3] = { sz*sx2, cx1*cz*sx2 + sx1*cx2, -sx1*cz*sx2 + cx1*cx2 };
1460 <<
"\nxun = ( " << xun[0] <<
", " << xun[1] <<
", " << xun[2] <<
" )"
1461 <<
"\nyun = ( " << yun[0] <<
", " << yun[1] <<
", " << yun[2] <<
" )"
1462 <<
"\nzun = ( " << zun[0] <<
", " << zun[1] <<
", " << zun[2] <<
" )";
1472 double inProd = zun[0] * detO_cm.X() + zun[1] * detO_cm.Y() + zun[2] * detO_cm.Z();
1473 assert( pparUnit.X() * zun[0] + pparUnit.Y() * zun[1] + pparUnit.Z() * zun[2] != 0.0 );
1474 inProd /= ( pparUnit.X() * zun[0] + pparUnit.Y() * zun[1] + pparUnit.Z() * zun[2] );
1479 TVector3 dumori(0.0, 0.0, 0.0);
1489 TVector3 detO_near( fCvec_near.X() - fDvec_beam.X(),
1490 fCvec_near.Y() - fDvec_beam.Y(),
1491 fCvec_near.Z() - fDvec_beam.Z() );
1494 const double aConst[3] = { fDvec_beam.X(), fDvec_beam.Y(), fDvec_beam.Z() };
1495 const double aConstUser[3] = { -detO_user.X(), -detO_user.Y(), -detO_user.Z() };
1499 const double dConst[3] = {
fCx,
fCy,
fCz };
1500 const double nConst[3] = { pparUnit.X(), pparUnit.Y(), pparUnit.Z() };
1503 const double nMult = nConst[0] * (dConst[0] - aConst[0]) +
1504 nConst[1] * (dConst[1] - aConst[1]) +
1505 nConst[2] * (dConst[2] - aConst[2]);
1510 const double POCA_m[3] = { aConst[0] + nMult * nConst[0],
1511 aConst[1] + nMult * nConst[1],
1512 aConst[2] + nMult * nConst[2] };
1516 const double zConstMult = ((
fCz) - aConst[2]) / (POCA_m[2] - aConst[2]);
1517 const double startPoint_m[3] = { aConst[0] + nMult * zConstMult * nConst[0],
1518 aConst[1] + nMult * zConstMult * nConst[1],
1519 aConst[2] + nMult * zConstMult * nConst[2] };
1537 const double swvMag = std::sqrt( sweepVect[0]*sweepVect[0] + sweepVect[1]*sweepVect[1] + sweepVect[2]*sweepVect[2] ); assert( swvMag > 0.0 );
1548 TVector3 detSweepVect( sweepVect[0], sweepVect[1], sweepVect[2] );
1550 TVector3 detPpar = ppar;
1562 std::string detPathString = this->
CheckGeomPoint( detStartPoint.X(), detStartPoint.Y(), detStartPoint.Z() );
int iDNode = 1;
1563 bool startsInsideDet = ( detPathString.find(
"/", iDNode) != string::npos );
1565 TLorentzVector detPpar_4v( detPpar.X(), detPpar.Y(), detPpar.Z(), p4par.E() );
1570 double minusPoint[3] = { 0.0, 0.0, 0.0 };
double plusPoint[3] = { 0.0, 0.0, 0.0 };
1571 if( startsInsideDet ){
1572 minusPoint[0] = (gGeoManager->GetCurrentPoint())[0];
1573 minusPoint[1] = (gGeoManager->GetCurrentPoint())[1];
1574 minusPoint[2] = (gGeoManager->GetCurrentPoint())[2];
1577 gGeoManager->SetCurrentPoint( detStartPoint.X(), detStartPoint.Y(), detStartPoint.Z() );
1578 gGeoManager->SetCurrentDirection( detSweepVect.X() / swvMag, detSweepVect.Y() / swvMag, detSweepVect.Z() / swvMag );
1579 const double sStepSize = 0.05 * std::min( std::min(
fLx,
fLy ),
fLz );
1583 if( startsInsideDet ){
1588 double currx = (gGeoManager->GetCurrentPoint())[0];
1589 double curry = (gGeoManager->GetCurrentPoint())[1];
1590 double currz = (gGeoManager->GetCurrentPoint())[2];
1591 double currDist = std::sqrt( currx*currx + curry*curry + currz*currz );
1593 double curdx = (gGeoManager->GetCurrentDirection())[0];
1594 double curdy = (gGeoManager->GetCurrentDirection())[1];
1595 double curdz = (gGeoManager->GetCurrentDirection())[2];
1597 double stepMod = 0.99;
1599 double halfBoxSize = boxSize/2.0;
1605 double largeStep = currDist + desiredDist;
1607 gGeoManager->SetCurrentPoint( currx + largeStep * curdx,
1608 curry + largeStep * curdy,
1609 currz + largeStep * curdz );
1620 plusPoint[0] = (gGeoManager->GetCurrentPoint())[0];
1621 plusPoint[1] = (gGeoManager->GetCurrentPoint())[1];
1622 plusPoint[2] = (gGeoManager->GetCurrentPoint())[2];
1630 double currx = (gGeoManager->GetCurrentPoint())[0];
1631 double curry = (gGeoManager->GetCurrentPoint())[1];
1632 double currz = (gGeoManager->GetCurrentPoint())[2];
1633 double currDist = std::sqrt( currx*currx + curry*curry + currz*currz );
1635 double stepMod = 0.99;
1637 double halfBoxSize = boxSize / 2.0;
1642 double largeStep = currDist - desiredDist;
1644 double curdx = (gGeoManager->GetCurrentDirection())[0];
1645 double curdy = (gGeoManager->GetCurrentDirection())[1];
1646 double curdz = (gGeoManager->GetCurrentDirection())[2];
1648 gGeoManager->SetCurrentPoint( currx + largeStep * curdx,
1649 curry + largeStep * curdy,
1650 currz + largeStep * curdz );
1661 minusPoint[0] = (gGeoManager->GetCurrentPoint())[0];
1662 minusPoint[1] = (gGeoManager->GetCurrentPoint())[1];
1663 minusPoint[2] = (gGeoManager->GetCurrentPoint())[2];
1669 currx = (gGeoManager->GetCurrentPoint())[0];
1670 curry = (gGeoManager->GetCurrentPoint())[1];
1671 currz = (gGeoManager->GetCurrentPoint())[2];
1682 gGeoManager->SetCurrentPoint( -currx, -curry, -currz );
1693 plusPoint[0] = (gGeoManager->GetCurrentPoint())[0];
1694 plusPoint[1] = (gGeoManager->GetCurrentPoint())[1];
1695 plusPoint[2] = (gGeoManager->GetCurrentPoint())[2];
1732 vMNear.SetXYZ( vMNear.X() + (
fCx),
1734 vMNear.Z() + (
fCz) );
1741 vPNear.SetXYZ( vPNear.X() + (
fCx),
1743 vPNear.Z() + (
fCz) );
1768 TVector3 minusVec( minusPoint[0] - decayPoint_user.X(), minusPoint[1] - decayPoint_user.Y(), minusPoint[2] - decayPoint_user[2] );
1769 TVector3 plusVec( plusPoint[0] - decayPoint_user.X(), plusPoint[1] - decayPoint_user.Y(), plusPoint[2] - decayPoint_user[2] );
1770 TVector3 startVec( detStartPoint[0] - decayPoint_user.X(), detStartPoint[1] - decayPoint_user.Y(), detStartPoint[2] - decayPoint_user.Z() );
1776 double minusNum = startVec.X() * minusVec.X() + startVec.Y() * minusVec.Y() + startVec.Z() * minusVec.Z();
1777 double minusDen = startVec.Mag() * minusVec.Mag(); assert( minusDen > 0.0 );
1779 zm = TMath::ACos( minusNum / minusDen ) * TMath::RadToDeg();
1781 double plusNum = startVec.X() * plusVec.X() + startVec.Y() * plusVec.Y() + startVec.Z() * plusVec.Z();
1782 double plusDen = startVec.Mag() * plusVec.Mag(); assert( plusDen > 0.0 );
1784 zp = TMath::ACos( plusNum / plusDen ) * TMath::RadToDeg();
1804 double SMECM,
double zm,
double zp )
const
1815 assert( zm >= 0.0 && zp >= zm );
1816 if( zp == zm )
return 1.0;
1818 double M = p4HNL.M();
1819 if( M < 1.0e-3 )
return 1.0;
1821 TF1 * fHNL = ( TF1* ) gROOT->GetListOfFunctions()->FindObject(
"fHNL" );
1822 if( !fHNL ){ fHNL =
new TF1(
"fHNL",
labangle, 0.0, 180.0, 6 ); }
1823 fHNL->SetParameter( 0, p4par.E() );
1824 fHNL->SetParameter( 1, p4par.Px() );
1825 fHNL->SetParameter( 2, p4par.Py() );
1826 fHNL->SetParameter( 3, p4par.Pz() );
1827 fHNL->SetParameter( 4, p4HNL.P() );
1828 fHNL->SetParameter( 5, p4HNL.E() );
1830 double ymax = fHNL->GetMaximum(), xmax = fHNL->GetMaximumX();
1831 double range1 = 0.0;
1833 if( fHNL->GetMinimum() >= fHNL->GetMaximum() )
return 1.0;
1835 if( zm < fHNL->GetMinimum() ){
1836 double z0 = fHNL->GetMinimum();
1837 if( ymax > zp && xmax < 180.0 ){
1841 double xl1 = fHNL->GetX( z0, 0.0, xmax );
1842 double xh1 = fHNL->GetX( zp, 0.0, xmax );
1843 double xl2 = fHNL->GetX( z0, xmax, 180.0 );
1844 double xh2 = fHNL->GetX( zp, xmax, 180.0 );
1846 range1 += std::abs( xl1 - xh1 ) + std::abs( xh2 - xl2 ); nPreim = 2;
1847 }
else if( ymax > zp && xmax == 180.0 ){
1848 double xl = fHNL->GetX( z0 ), xh = fHNL->GetX( zp );
1849 range1 = std::abs( xh - xl );
1851 }
else if( ymax <= zp ){
1858 }
else if( ymax > zp && xmax < 180.0 ){
1862 double xl1 = fHNL->GetX( zm, 0.0, xmax );
1863 double xh1 = fHNL->GetX( zp, 0.0, xmax );
1864 double xl2 = fHNL->GetX( zm, xmax, 180.0 );
1865 double xh2 = fHNL->GetX( zp, xmax, 180.0 );
1867 range1 += std::abs( xl1 - xh1 ) + std::abs( xh2 - xl2 ); nPreim = 2;
1868 }
else if( ymax > zp && xmax == 180.0 ){
1869 double xl = fHNL->GetX( zm ), xh = fHNL->GetX( zp );
1870 range1 = std::abs( xh - xl );
1872 }
else if( zm < ymax && ymax <= zp ){
1873 double xl = fHNL->GetX( zm, 0., xmax ), xh = fHNL->GetX( zm, xmax, 180.0 );
1874 range1 = std::abs( xh - xl );
1878 TF1 * fSMv = ( TF1* ) gROOT->GetListOfFunctions()->FindObject(
"fSMv" );
1880 fSMv =
new TF1(
"fSMv",
labangle, 0.0, 180.0, 6 );
1882 fSMv->SetParameter( 0, p4par.E() );
1883 fSMv->SetParameter( 1, p4par.Px() );
1884 fSMv->SetParameter( 2, p4par.Py() );
1885 fSMv->SetParameter( 3, p4par.Pz() );
1886 fSMv->SetParameter( 4, SMECM );
1887 fSMv->SetParameter( 5, SMECM );
1888 double range2 = -1.0;
1890 if( fSMv->GetMaximum() == fSMv->GetMinimum() )
return 1.0;
1896 if( fSMv->GetMinimum() < zp ){
1897 if( fSMv->GetMinimum() < zm ){
1898 range2 = std::abs( fSMv->GetX( zp ) - fSMv->GetX( zm ) );
1900 range2 = fSMv->GetX( zp );
1902 if( range2 < 1.0e-6 || range1 / range2 > 10.0 )
return 1.0;
1904 TVector3 bv = p4par.BoostVector();
1906 TLorentzVector vcx( p4HNL.P(), 0.0, 0.0, p4HNL.E() ),
1907 vcy( 0.0, p4HNL.P(), 0.0, p4HNL.E() ),
1908 vcz( 0.0, 0.0, p4HNL.P(), p4HNL.E() );
1909 vcx.Boost( bv ); vcy.Boost( bv ); vcz.Boost( bv );
1911 TLorentzVector vsx( SMECM, 0.0, 0.0, SMECM ),
1912 vsy( 0.0, SMECM, 0.0, SMECM ),
1913 vsz( 0.0, 0.0, SMECM, SMECM );
1914 vsx.Boost( bv ); vsy.Boost( bv ); vsz.Boost( bv );
1916 double xpart = std::abs( ( vcx.X() / vcz.Z() ) / ( vsx.X() / vsz.Z() ) );
1917 double ypart = std::abs( ( vcy.Y() / vcz.Z() ) / ( vsy.Y() / vsz.Z() ) );
1919 return 1.0 / ( xpart * ypart );
1922 assert( range2 > 0.0 );
1924 return range1 / range2;