diff --git a/codes/wls/decay-acceptance.wls b/codes/wls/decay-acceptance.wls new file mode 100755 index 0000000..9f9ee7e --- /dev/null +++ b/codes/wls/decay-acceptance.wls @@ -0,0 +1,845 @@ +#!/usr/bin/env wolframscript +(* ::Package:: *) + +(* ::Chapter::Closed:: *) +(*Decay acceptance definitions*) + + +(* ::Section::Closed:: *) +(*A kink in the trajectory due to magnetic field*) + + +(* ::Subsection:: *) +(*Parameters*) + + +(* ::Input:: *) +(*(*electric charge in SI units*)*) +(*qValSI=1.6*10^-19;*) +(*(*Magnetic field in SI units*)*) +(*BvalFCCee=1;*) +(*(*Electron mass in SI units*)*) +(*mekG=9.1*10^-31;*) +(*m\[Mu]kG=105/(0.5*10^-3) 9.1*10^-31;*) +(*hbar=6.58*10^-25;*) +(*cval=3*10^8;*) +(*(*1 kg in terms of GeV. Converted using the electron mass in GeV and in kg*)*) +(*kgToGeVval=(0.5*10^-3)/(9.1*10^-31);*) +(*GeVTokgVal=kgToGeVval^-1;*) + + +(* ::Subsection:: *) +(*Constant magnetic field*) + + +(* ::Subsubsection:: *) +(*Exact expressions*) + + +(* ::Input:: *) +(*(*Velocities in SI in terms of p, E in GeV, and speed of light*)*) +(*vxEnergy=c*pxGeV/EGeV;*) +(*vyEnergy=c*pyGeV/EGeV;*) +(*vzEnergy=c*pzGeV/EGeV;*) +(*\[Gamma]Energy=EGeV/mGeV;*) +(*(*EOMs \[Gamma] (dOverscript[v, _])/dt = q[Overscript[v, _]\[Times]Overscript[B, _]], where Overscript[B, _] is assumed to be located along the y axis in the positive direction. All the quantities entering the EOM are in SI units*)*) +(*EQsHelicalTrajectory=DSolve[{x''[t]==1/(m*\[Gamma]) q*Cross[{x'[t],y'[t],z'[t]},{0,B,0}][[1]],y''[t]==1/(m*\[Gamma]) q*Cross[{x'[t],y'[t],z'[t]},{0,B,0}][[2]],z''[t]==q/(m*\[Gamma])*Cross[{x'[t],y'[t],z'[t]},{0,B,0}][[3]],x[0]==x0,y[0]==y0,z[0]==z0,x'[0]==vx,y'[0]==vy,z'[0]==vz},{x,y,z},t][[1]];*) +(*Print["Helical trajectories - x, y, z. Here, \!\(\*SubscriptBox[\(p\), \(i\)]\) in the units of GeV:"]*) +(*{xHelicalTemp1[x0m_,pxGeV_,pzGeV_,EGeV_,BTl_,qCoulomb_,tsecond_,GeVTokg_],yHelicalTemp1[y0m_,pyGeV_,EGeV_,tsecond_],zHelicalTemp1[z0m_,pxGeV_,pzGeV_,EGeV_,BTl_,qCoulomb_,tsecond_,GeVTokg_]}={(x[t]/.EQsHelicalTrajectory),(y[t]/.EQsHelicalTrajectory),(z[t]/.EQsHelicalTrajectory)}/.{vx->vxEnergy,vy->vyEnergy,vz->vzEnergy,\[Gamma]->\[Gamma]Energy,m-> mGeV*GeVTokg,B->BTl,q->qCoulomb,x0->x0m,t->tsecond}*) +(*Print["Velocities dx/dt, dy/dt, dz/dt:"]*) +(*{vxHelicalTemp1[pxGeV_,pzGeV_,EGeV_,BTl_,qCoulomb_,tsecond_,GeVTokg_],vyHelicalTemp1[pyGeV_,EGeV_],vzHelicalTemp1[pxGeV_,pzGeV_,EGeV_,BTl_,qCoulomb_,tsecond_,GeVTokg_]}={D[xHelicalTemp1[x0m,pxGeV,pzGeV,EGeV,BTl,qCoulomb,tsecond,GeVTokg],tsecond],D[yHelicalTemp1[y0m,pyGeV,EGeV,tsecond],tsecond],D[zHelicalTemp1[z0m,pxGeV,pzGeV,EGeV,BTl,qCoulomb,tsecond,GeVTokg],tsecond]}//Simplify*) +(*Print["Momenta \!\(\*SubscriptBox[\(p\), \(i\)]\)(t) = E \!\(\*SubscriptBox[\(v\), \(i\)]\)(t)/\!\(\*SuperscriptBox[\(c\), \(2\)]\):"]*) +(*{pxHelicalTemp1[pxGeV_,pzGeV_,BTl_,qCoulomb_,tsecond_,GeVTokg_],pyHelicalTemp1[pyGeV_],pzHelicalTemp1[pxGeV_,pzGeV_,BTl_,qCoulomb_,tsecond_,GeVTokg_]}=EGeV/c {vxHelicalTemp1[pxGeV,pzGeV,EGeV,BTl,qCoulomb,tsecond,GeVTokg],vyHelicalTemp1[pyGeV,EGeV],vzHelicalTemp1[pxGeV,pzGeV,EGeV,BTl,qCoulomb,tsecond,GeVTokg]}//Simplify*) +(*Print["Cross-check: \!\(\*SuperscriptBox[OverscriptBox[\(v\), \(_\)], \(2\)]\)(t) = \!\(\*SubscriptBox[SuperscriptBox[\(v\), \(2\)], \(x\)]\)(t)+\!\(\*SubscriptBox[SuperscriptBox[\(v\), \(2\)], \(y\)]\)(t)+\!\(\*SubscriptBox[SuperscriptBox[\(v\), \(2\)], \(z\)]\)(t) is equal to \!\(\*SuperscriptBox[\(v\), \(2\)]\)(t = 0) = \!\(\*SubscriptBox[SuperscriptBox[\(v\), \(2\)], \(x, 0\)]\)+\!\(\*SubscriptBox[SuperscriptBox[\(v\), \(2\)], \(y, 0\)]\)+\!\(\*SubscriptBox[SuperscriptBox[\(v\), \(2\)], \(z, 0\)]\) = \!\(\*SuperscriptBox[\(c\), \(2\)]\)\!\(\*SuperscriptBox[OverscriptBox[\(p\), \(_\)], \(2\)]\)/\!\(\*SuperscriptBox[\(E\), \(2\)]\)"]*) +(*vxHelicalTemp1[pxGeV,pzGeV,EGeV,BTl,qCoulomb,tsecond,GeVTokg]^2+vyHelicalTemp1[pyGeV,EGeV]^2+vzHelicalTemp1[pxGeV,pzGeV,EGeV,BTl,qCoulomb,tsecond,GeVTokg]^2//Expand//Simplify*) +(*(*Therefore, after passing the domain with the magnetic field, the new Subscript[p', x],Subscript[p', z] are Subscript[p', x] = Subscript[p, x,0]\[Times](Subscript[v, x](Subscript[t, passing]))/Subscript[v, x,0], Subscript[p', z] = Subscript[p, z,0]\[Times](Subscript[v, z](Subscript[t, passing]))/Subscript[v, z,0]*)*) +(*(*Approximate value of the period of time for which the charged particle passes through the domain with magnetic field. It is estimated roughly assuming that the momentum Subscript[p, z] is left unchanged*)*) +(*tz0[zprojm_,z0m_,c_,pzGeV_,EGeV_]=(*t/.Solve[zHelicalTemp1[z0m,pxGeV,pzGeV,EGeV,BTl,qCoulomb,t,GeVTokg]\[Equal]zproj,t][[1]]/.{Subscript[\[ConstantC], 1]\[Rule]0}*)t/.Solve[z0m+vzEnergy*t==zprojm,t][[1]];*) +(*(*Helical trajectories x[Subscript[t, z = 0]], y[Subscript[t, z = 0]].*)*) +(*xHelicalTemp2[x0m_,z0m_,pxGeV_,pzGeV_,BTl_,qsign_,zprojm_]=xHelicalTemp1[x0m,pxGeV,pzGeV,EGeV,BTl,qCoulomb,tz0[zprojm,z0m,c,pzGeV,EGeV],GeVTokg]/.{c->cval,qCoulomb-> qValSI*qsign,GeVTokg->GeVTokgVal};*) +(*yHelicalTemp2[y0m_,z0m_,pyGeV_,pzGeV_,zprojm_]=yHelicalTemp1[y0m,pyGeV,EGeV,tz0[zprojm,z0m,c,pzGeV,EGeV]]/.{m->mlkg,\[Gamma]->\[Gamma]Energy,vz->vzEnergy,vx->vxEnergy,vy->vyEnergy}/.{c->cval,qCoulomb-> qValSI*qsign,GeVTokg->GeVTokgVal};*) +(*zHelicalTemp2[z0m_,pxGeV_,pzGeV_,BTl_,qsign_,zprojm_]=zHelicalTemp1[z0m,pxGeV,pzGeV,EGeV,BTl,qCoulomb,tz0[zprojm,z0m,c,pzGeV,EGeV],GeVTokg]/.{c->3*10^8,qCoulomb-> qValSI*qsign,GeVTokg->GeVTokgVal};*) +(*{pxHelicalTemp2[z0m_,pxGeV_,pzGeV_,BTl_,qsign_,zprojm_],pyHelicalTemp2[pyGeV_],pzHelicalTemp2[z0m_,pxGeV_,pzGeV_,BTl_,qsign_,zprojm_]}={pxHelicalTemp1[pxGeV,pzGeV,BTl,qCoulomb,tz0[zprojm,z0m,c,pzGeV,EGeV],GeVTokg],pyHelicalTemp1[pyGeV],pzHelicalTemp1[pxGeV,pzGeV,BTl,qCoulomb,tz0[zprojm,z0m,c,pzGeV,EGeV],GeVTokg]}/.{c->cval,qCoulomb-> qValSI*qsign,GeVTokg->GeVTokgVal}//Simplify;*) +(*Print["Larmor radius (in m):"]*) +(*LarmorRadius[EGeV_,BTl_]=cval*(EGeV*GeVTokgVal)/(qValSI*BTl)*) + + +(* ::Subsubsection:: *) +(*Approx expressions*) + + +(* ::Input:: *) +(*(*The minimal value of momentum at which the trigonometric functions may be replaced with their expansion*)*) +(*pzKickApprox[BTl_,zprojm_,z0m_]=pzGeV/.Solve[(BTl*qValSI)/EGeV*tz0[zprojm,z0m,cval,pzGeV,EGeV] 1/GeVTokgVal==0.2,pzGeV][[1]]//Simplify;*) +(*(*Expansions of the coordinate and momenta*)*) +(*xHelicalApproxTemp2[x0m_,z0m_,pxGeV_,pzGeV_,BTl_,qsign_,zprojm_]=Normal@Series[xHelicalTemp1[x0m,pxGeV,pzGeV,EGeV,BTl,qValSI,tsecond,GeVTokgVal],{tsecond,0,2}]/.{c->cval}/.{tsecond-> tz0[zprojm,z0m,cval,pzGeV,EGeV]}//Simplify;*) +(*zHelicalApproxTemp2[z0m_,pxGeV_,pzGeV_,BTl_,qsign_,zprojm_]=Normal@Series[zHelicalTemp1[z0m,pxGeV,pzGeV,EGeV,BTl,qValSI*qsign,tsecond,GeVTokgVal],{tsecond,0,2}]/.{c->cval}/.{tsecond-> tz0[zprojm,z0m,cval,pzGeV,EGeV]}//Simplify;*) +(*pxHelicalApproxTemp2[z0m_,pxGeV_,pzGeV_,BTl_,qsign_,zprojm_]=(Normal@Series[pxHelicalTemp1[pxGeV,pzGeV,BTl,qValSI*qsign,tsecond,GeVTokgVal],{tsecond,0,1}])/.{tsecond-> tz0[zprojm,z0m,cval,pzGeV,EGeV]}//Simplify;*) +(*pzHelicalApproxTemp2[z0m_,pxGeV_,pzGeV_,BTl_,qsign_,zprojm_]=(Normal@Series[pzHelicalTemp1[pxGeV,pzGeV,BTl,qValSI*qsign,tsecond,GeVTokgVal],{tsecond,0,1}])/.{tsecond-> tz0[zprojm,z0m,cval,pzGeV,EGeV]}//Simplify;*) +(*pzHelicalApprox[z0m_,pxGeV_,pzGeV_,BTl_,qsign_,zprojm_]=If[pzGeV>pzKickApprox[BTl,zprojm,z0m],Evaluate[pzHelicalApproxTemp2[z0m,pxGeV,pzGeV,BTl,qsign,zprojm]],Evaluate[pzHelicalTemp2[z0m,pxGeV,pzGeV,BTl,qsign,zprojm]]];*) +(*pxHelicalApprox[z0m_,pxGeV_,pzGeV_,BTl_,qsign_,zprojm_]=If[pzGeV>pzKickApprox[BTl,zprojm,z0m],Evaluate[pxHelicalApproxTemp2[z0m,pxGeV,pzGeV,BTl,qsign,zprojm]],Evaluate[pxHelicalTemp2[z0m,pxGeV,pzGeV,BTl,qsign,zprojm]]];*) +(*xHelicalApprox[x0m_,z0m_,pxGeV_,pzGeV_,BTl_,qsign_,zprojm_]=If[pzGeV>pzKickApprox[BTl,zprojm,z0m],Evaluate[xHelicalApproxTemp2[x0m,z0m,pxGeV,pzGeV,BTl,qsign,zprojm]],Evaluate[xHelicalTemp2[x0m,z0m,pxGeV,pzGeV,BTl,qsign,zprojm]]];*) + + +(* ::Section:: *) +(*Pre-definitions*) + + +(* ::Input:: *) +(*(*Consider the table Subscript[E, LLP],Subscript[\[Theta], LLP],Subscript[z, LLP],Subscript[\[Epsilon], az],Subscript[\[Phi], LLP]. The compiled code below removes rows for which Subscript[E, LLP] < Subscript[m, LLP] or Subscript[\[Epsilon], azimuthal] = 0*)*) +(*TableLLPnonZeroCompiled=Hold@Compile[{{TableLLPgridWithELLP,_Real,2},{mLLP,_Real}},Select[TableLLPgridWithELLP,#[[indexELLP]]>mLLP(*&&#[[indexLLPazAcc]]\[NotEqual]0.*)&],CompilationTarget->"C",RuntimeOptions->"Speed"]/.OwnValues@indexELLP/.OwnValues@indexLLPazAcc//ReleaseHold;*) +(*TableLLPzeroCompiled=Hold@Compile[{{TableLLPgridWithELLP,_Real,2},{mLLP,_Real}},Select[TableLLPgridWithELLP,#[[indexELLP]]<=mLLP(*||#[[indexLLPazAcc]]\[Equal]0.*)& ],CompilationTarget->"C",RuntimeOptions->"Speed"]/.OwnValues@indexELLP/.OwnValues@indexLLPazAcc//ReleaseHold;*) +(*(*Consider a table of Subscript[\[Epsilon], decay], where each NofPhiVals values correspond to the same Subscript[E, LLP],Subscript[\[Theta], LLP],Subscript[z, LLP] but to different Subscript[\[Phi], LLP]. The compiled code below averages over \[Phi]*)*) +(*\[Epsilon]DecayE\[Theta]zcompiled=Hold@Compile[{{DecayAcceptanceE\[Theta]z\[Phi],_Real,2},{NofPhiVals,_Integer}},(1/NofPhiVals)Table[{Sum[DecayAcceptanceE\[Theta]z\[Phi][[i]][[1]],{i,(i0-1)*NofPhiVals+1,i0*NofPhiVals}]},{i0,1,Length[DecayAcceptanceE\[Theta]z\[Phi]]/NofPhiVals,1}],CompilationTarget->"C",RuntimeOptions->"Speed"]//ReleaseHold;*) +(*(*This code averages the decay acceptance over the domains where the LLP points/does not point to the detector*)*) +(*\[Epsilon]dec1Compiled= Compile[{{tabToDet,_Real,1},{tabNotToDet,_Real,1},{mLLP,_Real}},Module[{angles,energies,zs,\[Epsilon]azToDet,\[Epsilon]azNotToDet,\[Epsilon]DecToDet,\[Epsilon]DecNotToDet,\[Epsilon]DecAv},*) +(*angles=Compile`GetElement[tabToDet,1];*) +(*energies=Compile`GetElement[tabToDet,2];*) +(*zs=Compile`GetElement[tabToDet,3];*) +(*\[Epsilon]azToDet=Compile`GetElement[tabToDet,4];*) +(*\[Epsilon]azNotToDet=Compile`GetElement[tabNotToDet,4];*) +(*\[Epsilon]DecToDet=Compile`GetElement[tabToDet,5];*) +(*\[Epsilon]DecNotToDet=Compile`GetElement[tabNotToDet,5];*) +(*\[Epsilon]DecAv=(\[Epsilon]azToDet*\[Epsilon]DecToDet+\[Epsilon]azNotToDet*\[Epsilon]DecNotToDet)/(\[Epsilon]azToDet+\[Epsilon]azNotToDet+10^-90.)+10^-90.;*) +(*{mLLP,angles,energies,zs,\[Epsilon]azToDet+\[Epsilon]azNotToDet,\[Epsilon]DecAv}],CompilationTarget->"C",RuntimeOptions->"Speed",RuntimeAttributes->{Listable}];*) +(*\[Epsilon]dec2Compiled=Compile[{{tabToDet,_Real,2},{mLLP,_Real}},Join[Table[{mLLP},{i,1,Length[tabToDet],1}],tabToDet,2],CompilationTarget->"C",RuntimeOptions->"Speed"];*) + + +(* ::Subsection:: *) +(*Kinematic variables used for imposing cuts*) + + +(* ::Input:: *) +(*(*IP cut*)*) +(*(*Consider two particles originating from the same point Subscript[r, prod]. Their trajectory is given by the formula below*)*) +(*TrajectoryProducts[xprod_,yprod_,zprod_,px1_,px2_,py1_,py2_,pz1_,pz2_,zproj_]={xprod+(zproj-zprod)*(px1+px2)/(pz1+pz2),yprod+(zproj-zprod)*(py1+py2)/(pz1+pz2),zproj};*) +(*(*Transverse impact parameter*)*) +(*IPproductsSquared[xprod_,yprod_,zprod_,px1_,px2_,py1_,py2_,pz1_,pz2_,zproj_]=(TrajectoryProducts[xprod,yprod,zprod,px1,px2,py1,py2,pz1,pz2,zproj][[1]]^2+TrajectoryProducts[xprod,yprod,zprod,px1,px2,py1,py2,pz1,pz2,zproj][[2]]^2//Expand//Simplify);*) +(*IPproductzTargetSquared[xprod_,yprod_,zprod_,px1_,px2_,py1_,py2_,pz1_,pz2_]=IPproductsSquared[xprod,yprod,zprod,px1,px2,py1,py2,pz1,pz2,0]^2//Simplify;*) +(*(*Spatial separation cut: for photons*)*) +(*TrajectoryDifferenceProducts[xprod_,yprod_,zprod_,px1_,px2_,py1_,py2_,pz1_,pz2_,CoordProj_]={(CoordProj-zprod)*px1/pz1-(CoordProj-zprod)*px2/pz2,(CoordProj-zprod)*py1/pz1-(CoordProj-zprod)*py2/pz2,0.};*) +(*(*For the experiments for which the decay volume is detector, the ECAL position is formally assumed to be at the end of the decay volume*)*) +(*ecalpos=If[DecayVolumeAsDetectorGivenExperiment=="False",ECALpositionGivenExperiment,xLongMaxDetectorGivenExperiment];*) +(*SSproductsSquaredOld[zprod_,px1_,px2_,py1_,py2_,pz1_,pz2_,CoordProj_]=(TrajectoryDifferenceProducts[xprod,yprod,zprod,px1,px2,py1,py2,pz1,pz2,CoordProj][[1]]^2+TrajectoryDifferenceProducts[xprod,yprod,zprod,px1,px2,py1,py2,pz1,pz2,CoordProj][[2]]^2//Expand//Simplify);*) +(*SSproductsSquared[xfin1_,xfin2_,yfin1_,yfin2_]=(xfin1-xfin2)^2+(yfin1-yfin2)^2;*) +(*minvProductsSquared[px1_,py1_,pz1_,E1_,px2_,py2_,pz2_,E2_]=(E1+E2)^2-(px1+px2)^2-(py1+py2)^2-(pz1+pz2)^2;*) +(*CosAngleProducts[px1_,px2_,py1_,py2_,pz1_,pz2_]=With[{p1={px1,py1,pz1},p2={px2,py2,pz2}},p1 . p2/(Norm[p1]Norm[p2])];*) + + +(* ::Section:: *) +(*Routine of calculating the decay acceptance*) + + +(* ::Subsection:: *) +(*Trajectory of the decay products*) + + +(* ::Subsubsection:: *) +(*No magnetic field*) + + +(* ::Input:: *) +(*FinalPlaneSign=Sign[xLongMaxDetectorGivenExperiment];*) +(*MomDirection[py_,pz_]=If[DetectorPlaneOrientationGivenExperiment=="Transverse",pz,py];*) +(*(*LLP's decay poing as a function of z,\[Theta],\[Phi]*)*) +(*(*LLPdecayVertex[zLLP_,\[Theta]LLP_,\[Phi]LLP_]={LLPdecVTXatGivenZx[zLLP,\[Theta]LLP,\[Phi]LLP],LLPdecVTXatGivenZy[zLLP,\[Theta]LLP,\[Phi]LLP],zLLP};*)*) +(*LLPdecayVertexX[zLLP_,\[Theta]LLP_,\[Phi]LLP_]=LLPdecVTXatGivenZx[zLLP,\[Theta]LLP,\[Phi]LLP]/. Cot[x_]:>1/Tan[x]/. Csc[x_]:>1/Sin[x]/.Sec[x_]:>1/Cos[x];*) +(*LLPdecayVertexY[zLLP_,\[Theta]LLP_,\[Phi]LLP_]=LLPdecVTXatGivenZy[zLLP,\[Theta]LLP,\[Phi]LLP]/. Cot[x_]:>1/Tan[x]/. Csc[x_]:>1/Sin[x]/.Sec[x_]:>1/Cos[x];*) +(*LLPdecayVertexZ[zLLP_,\[Theta]LLP_,\[Phi]LLP_]=zLLP;*) +(*If[GivenExperiment!="ANUBIS-ceiling",*) +(*(*Trajectory of the daughter's particles given the LLP decay position and the daughter's 3-momenta in the lab frame of the decaying LLP - at the position of the final plane of the detector*)*) +(*DaughterTrajectory[xLLPdecay_,yLLPdecay_,zLLPdecay_,XlongProj_,px_,py_,pz_]=If[DetectorPlaneOrientationGivenExperiment=="Transverse",{xLLPdecay+(XlongProj-zLLPdecay)(px/pz),yLLPdecay+(XlongProj-zLLPdecay)(py/pz),XlongProj},{xLLPdecay+(XlongProj-yLLPdecay)(px/py),XlongProj,zLLPdecay+(XlongProj-yLLPdecay)(pz/py)}],*) +(*(*___________________________________________*)*) +(*(*Projection of the decay products trajectory onto the detector final surface - for ANUBIS-ceiling*)*) +(*(*___________________________________________*)*) +(*xx[x0_,vx_,t_]=x0+vx*t;*) +(*yy[y0_,vy_,t_]=y0+vy*t;*) +(*zz[z0_,vz_,t_]=z0+vz*t;*) +(*(*The condition that the trajectory intersects the surface of the cavern. Here, xshift, yshift are just the shiftings of the beamline from the center of the cavern where ATLAS is located*)*) +(*rho2[x0_,y0_,vx_,vy_,t_,xshift_,yshift_]=(xx[x0,vx,t]+xshift)^2+(yy[y0,vy,t]+yshift)^2//Expand//Simplify;*) +(*(*The moment of time at which the trajectory intersects the surface of the cavern*)*) +(*tsol[x0_,y0_,vx_,vy_,\[Rho]det_,xshift_,yshift_]=t/.Solve[rho2[x0,y0,vx,vy,t,xshift,yshift]==\[Rho]det^2,t];*) +(*(*The values of the coordinates of the decay product at this moment of time*)*) +(*DaughterTrajectory[xLLPdecay_,yLLPdecay_,zLLPdecay_,XlongProj_,px_,py_,pz_]={xx[xLLPdecay,px,tsol[xLLPdecay,yLLPdecay,px,py,RouterDecayVolumeGivenExperiment[z],xshiftval,yshiftval][[2]]]//Expand//Simplify,yy[yLLPdecay,py,tsol[xLLPdecay,yLLPdecay,px,py,RouterDecayVolumeGivenExperiment[z],xshiftval,yshiftval][[2]]]//Expand//Simplify,zz[zLLPdecay,pz,tsol[xLLPdecay,yLLPdecay,px,py,RouterDecayVolumeGivenExperiment[z],xshiftval,yshiftval][[2]]]//Expand//Simplify};*) +(*]*) +(*DaughterTrajectoryCoord1[xLLPdecay_,yLLPdecay_,zLLPdecay_,XlongProj_,px_,py_,pz_]=If[FinalPlaneSign*MomDirection[py,pz]>0,Evaluate[DaughterTrajectory[xLLPdecay,yLLPdecay,zLLPdecay,XlongProj,px,py,pz][[1]]],99999.];*) +(*DaughterTrajectoryCoord2[xLLPdecay_,yLLPdecay_,zLLPdecay_,XlongProj_,px_,py_,pz_]=If[FinalPlaneSign*MomDirection[py,pz]>0,Evaluate[DaughterTrajectory[xLLPdecay,yLLPdecay,zLLPdecay,XlongProj,px,py,pz][[pointSecondCoordinate]]],99999.];*) + + +(* ::Subsubsection:: *) +(*With magnetic field*) + + +(* ::Input:: *) +(*(*The magnetic field is assumed to be parallel to the y axis*)*) +(*(*_______________________________________*)*) +(*(*Trajectory of the daughter's particle before being affected by the magnet at z = zProj. It is a function of the LLP decay vertex and the daughter's kinematics before the magnet - Subscript[p, x],Subscript[p, y],Subscript[p, z]*)*) +(*(*For the x coordinate, the value of zProj is taken to be the beginning of the magnet/the LLP's Subscript[z, decay] (here and below, it is always assumed that Subscript[z, decay] > Subscript[z, magnet,max])*)*) +(*(*For the y coordinate, the value is taken to be the end of the magnet. This is because it is assumed for simplicity that the evolution of the y coordinate up to the end of the magnet is the same as it would be without the magnet*)*) +(*LarmorRadiusGivenExperiment[EGeV_]=If[DipoleMagnetOptionGivenExperiment=="False",0,LarmorRadius[EGeV,Bval]];*) +(*xAtMagnetStart[xLLPdecay_,yLLPdecay_,zLLPdecay_,px_,py_,pz_]=If[FinalPlaneSign*MomDirection[py,pz]>0,Evaluate[xLLPdecay+(Max[zMagnetMinGivenExperiment,zLLPdecay]-zLLPdecay)(px/pz)],99999.];*) +(*(*The coordinate 2 is assumed to be the same just after the magnet as if there would not be any magnetic field*)*) +(*yAtMagnetEnd[xLLPdecay_,yLLPdecay_,zLLPdecay_,px_,py_,pz_]=If[FinalPlaneSign*MomDirection[py,pz]>0,Evaluate[yLLPdecay+(zMagnetMaxGivenExperiment-zLLPdecay)(py/pz)],99999.];*) +(*(*____________________________________________*)*) +(*(*Trajectory of the daughter's particle after passing the domain with magnetic field*)*) +(*(*____________________________________________*)*) +(*(*The x-coordinate, as well as the momenta Subscript[p, x],Subscript[p, z] get changed depending on the charge sign of the particle. This is taken into account by kinking of their values*)*) +(*xAtDetectorEndMagnetEffectTemp[zLLPdecay_,xprojBeforeMagnet_,pxaftermagnet_,py_,pzaftermagnet_,qval_]=If[DipoleMagnetOptionGivenExperiment=="True",xHelicalApprox[xprojBeforeMagnet,Max[zMagnetMinGivenExperiment,zLLPdecay],pxaftermagnet,pzaftermagnet,Bval,qval,zMagnetMaxGivenExperiment]//Expand//Simplify,999999.];*) +(*yAtDetectorEndMagnetEffectTemp[zLLPdecay_,yprojAfterMagnet_,py_,pzaftermagnet_]=If[DipoleMagnetOptionGivenExperiment=="True",yprojAfterMagnet+(xLongMaxDetectorGivenExperiment-zMagnetMaxGivenExperiment)(py/pzaftermagnet),99999.];*) +(*pxAfterMagnet[zLLPdecay_,px_,pz_,qval_]=If[DipoleMagnetOptionGivenExperiment=="True",pxHelicalApprox[Max[zLLPdecay,zMagnetMinGivenExperiment],px,pz,Bval,qval,zMagnetMaxGivenExperiment],100000.];*) +(*pzAfterMagnet[zLLPdecay_,px_,pz_,qval_]=If[DipoleMagnetOptionGivenExperiment=="True",pzHelicalApprox[Max[zLLPdecay,zMagnetMinGivenExperiment],px,pz,Bval,qval,zMagnetMaxGivenExperiment],0.00001];*) +(*xAtDetectorEndMagnetEffect[zLLPdecay_,xprojBeforeMagnet_,px_,py_,pz_,qval_]=If[DipoleMagnetOptionGivenExperiment=="True",If[FinalPlaneSign*MomDirection[py,pz]>0,Evaluate[(xAtDetectorEndMagnetEffectTemp[zLLPdecay,xprojBeforeMagnet,pxAfterMagnet[zLLPdecay,px,pz,qval],py,pzAfterMagnet[zLLPdecay,px,pz,qval],qval]//Simplify)/. Cot[x_]:>1/Tan[x]/. Csc[x_]:>1/Sin[x]],99999.],999999.];*) +(*yAtDetectorEndMagnetEffect[zLLPdecay_,yprojAfterMagnet_,px_,py_,pz_,qval_]=If[DipoleMagnetOptionGivenExperiment=="True",If[FinalPlaneSign*MomDirection[py,pz]>0,Evaluate[yAtDetectorEndMagnetEffectTemp[zLLPdecay,yprojAfterMagnet,py,pzAfterMagnet[zLLPdecay,px,pz,qval]]/. Cot[x_]:>1/Tan[x]/. Csc[x_]:>1/Sin[x]//Simplify],99999.],999999.];*) + + +(* ::Subsection:: *) +(*Blocks computing various cuts*) + + +(* ::Subsubsection:: *) +(*Particular decay product - geometric part*) + + +(* ::Input:: *) +(*conditionDecayAcceptanceGeometric=Hold@Compile[{{charge1,_Real},{pdg1,_Real},{xdecayfip,_Real},{ydecayfip,_Real},{zfip,_Real},{px1lab,_Real},{py1lab,_Real},{pz1lab,_Real},{E1lab,_Real},{zmagnMzfip,_Real}},*) +(*Module[{cond=0.,FirstCoordinateProduct1,SecondCoordinateProduct1,xAtMagnetStartProduct1=0.,yAfterMagnetProduct1=0.,xFinalPlaneProduct1=0.,yFinalPlaneProduct1=0.,xLongProjVal=0.},*) +(*(*Depending on pdg id, the final plane required to be reached in order to be reconstructed*)*) +(*xLongProjVal=If[Abs[pdg1]==13.,xLongMuonPlaneGivenExperiment,xLongNonMuonPlaneGivenExperiment];*) +(*(*If product is uncharged OR there is no magnet OR the LLP decays after the region with the magnetic field, then the trajectory of the decay product is a straight line and the decay acceptance may be easily computed*)*) +(*If[Bval==0||charge1==0.||zmagnMzfip<0,*) +(*(*Coordinates of the decay products at the detector plane*)*) +(*xFinalPlaneProduct1=DaughterTrajectoryCoord1[xdecayfip,ydecayfip,zfip,xLongProjVal,px1lab,py1lab,pz1lab];*) +(*yFinalPlaneProduct1=DaughterTrajectoryCoord2[xdecayfip,ydecayfip,zfip,xLongProjVal,px1lab,py1lab,pz1lab];*) +(*(*Condition whether product1 intersects the detector*)*) +(*cond=DecayAcceptanceGeometry[xFinalPlaneProduct1,yFinalPlaneProduct1,xLongProjVal],*) +(*(*If the magnetic field and electric charge of the product are non-zero AND the LLP decays before the end of the magnet, then the trajectory is affected by the magnetic field. However, to be affected*)*) +(*(*If the product has large enough energy (== Larmor radius is smaller than the domain with the magnetic field), proceed to the acceptance routine calculation*)*) +(*If[LarmorRadiusGivenExperiment[E1lab]>zmagnMzfip,*) +(*(*x coordinate of the decay products just before the magnet (or at the LLP decay point if it is inside the magnet), and y coordinate at the end of the magnet. Due to the approximation, the mentioned y coordinate is unaffected by the magnet*)*) +(*xAtMagnetStartProduct1=xAtMagnetStart[xdecayfip,ydecayfip,zfip,px1lab,py1lab,pz1lab];*) +(*yAfterMagnetProduct1=yAtMagnetEnd[xdecayfip,ydecayfip,zfip,px1lab,py1lab,pz1lab];*) +(*(*These coordinates must be within the detector coverage. Here it is assumed that the transverse size of the magnet does not change from Subscript[z, magnet,min] to Subscript[z, magnet,max]*)*) +(*cond=DecayAcceptanceGeometry[xAtMagnetStartProduct1,yAfterMagnetProduct1,zMagnetMaxGivenExperiment];*) +(*(*If this is the case, then the routine below evaluates the change of the trajectory due to the magnetic field*)*) +(*If[cond==1,*) +(*(*Coordinates x,y at the final plane. Both of them are affected by magnet*)*) +(*(*The x coordinate gets affected by a kick in x,Subscript[p, x],Subscript[p, z] after the magnet*)*) +(*(*The y coordinate gets affected by a kick in Subscript[p, z] after the magnet*)*) +(*xFinalPlaneProduct1=xAtDetectorEndMagnetEffect[zfip,xAtMagnetStartProduct1,px1lab,py1lab,pz1lab,charge1];*) +(*yFinalPlaneProduct1=yAtDetectorEndMagnetEffect[zfip,yAfterMagnetProduct1,px1lab,py1lab,pz1lab,charge1];*) +(*(*Condition whether decay products intersect the detector and have large enough energy*)*) +(*(*The first condition corresponds to the requirement that x before the magnet and y after the magnet are within the detector*)*) +(*(*The second one requires that kicked x, y at Subscript[z, final ]are within the detector*)*) +(*cond=DecayAcceptanceGeometry[xFinalPlaneProduct1,yFinalPlaneProduct1,xLongProjVal]]*) +(*(*If the product has too low energy (== Larmor radius is smaller than the domain with the magnetic field), it would be trapped inside the magnetic field. In this case, acceptance = 0*)*) +(*,cond=0];*) +(*];*) +(*{cond,xFinalPlaneProduct1,yFinalPlaneProduct1}*) +(*],CompilationTarget->"C",RuntimeOptions->"Speed",RuntimeAttributes->{Listable},Parallelization->True]/.ruleDown[{DaughterTrajectoryCoord1,DaughterTrajectoryCoord2,DecayAcceptanceGeometry,xAtDetectorEndMagnetEffect,yAtDetectorEndMagnetEffect,xAtMagnetStart,yAtMagnetEnd,LarmorRadiusGivenExperiment}]/.ruleOwn[{Bval,xLongMuonPlaneGivenExperiment,xLongNonMuonPlaneGivenExperiment,zMagnetMaxGivenExperiment}]//ReleaseHold;*) +(*(*<"C",RuntimeOptions->"Speed",RuntimeAttributes->{Listable},Parallelization->True]/.ruleOwn[{eTotCutLowerZero,eTotCutUpperZero,IfEtotLowercuts,IfEtotUppercuts}]//ReleaseHold];*) +(*<"C",RuntimeOptions->"Speed",RuntimeAttributes->{Listable},Parallelization->True]//ReleaseHold];*) +(*<"C",RuntimeOptions->"Speed",RuntimeAttributes->{Listable},Parallelization->True]/.ruleDown[{IPproductzTargetSquared}]/.ruleOwn[{IPcutZero}]//ReleaseHold];*) +(*<"C",RuntimeOptions->"Speed",RuntimeAttributes->{Listable},Parallelization->True]/.ruleDown[{AngSepCutID,CosAngleProducts}]/.ruleOwn[{AngSepCutZero}]//ReleaseHold];*) +(*,*) +(*conditionAngSepCuts=With[{AngSepCutid=AngSepCutID},Hold@Compile[{{pdg1,_Real},{pdg2,_Real},{zfip,_Real},{px1lab,_Real},{px2lab,_Real},{py1lab,_Real},{py2lab,_Real},{pz1lab,_Real},{pz2lab,_Real}},Module[{cond=1.,angsepcut,ss12,u1=0.,u2=0.,z=0.},*) +(*(*Minimal separation in rad*)*) +(*angsepcut=AngSepCutid[pdg1,pdg2];*) +(*If[angsepcut!=AngSepCutZero,*) +(*(*cos(Subscript[\[Theta], between decay products]), including the gaussian smearing from detector's resolution*)*) +(*u1=RandomReal[{0.,1.}];*) +(*u2=RandomReal[{0.,1.}];*) +(*z=Sqrt[-2. Log[u1]] Cos[2. Pi u2];*) +(*ss12=ArcCos[Cos[ArcCos[CosAngleProducts[px1lab,px2lab,py1lab,py2lab,pz1lab,pz2lab]]+angres*z]];*) +(*(*Boolean condition*)*) +(*cond=Boole[ss12>angsepcut]];*) +(*cond*) +(*]*) +(*,CompilationTarget->"C",RuntimeOptions->"Speed",RuntimeAttributes->{Listable},Parallelization->True]/.ruleDown[{AngSepCutID,CosAngleProducts,InverseCDFffplus}]/.ruleOwn[{AngSepCutZero,angres}]//ReleaseHold];*) +(*]*) +(*<sscut^2]];*) +(*cond*) +(*]*) +(*,CompilationTarget->"C",RuntimeOptions->"Speed",RuntimeAttributes->{Listable},Parallelization->True,CompilationOptions->{"InlineExternalDefinitions"->True,"InlineCompiledFunctions"->True}]/.ruleDown[{SScutID,SSproductsSquaredOld}]/.ruleOwn[{SScutZero,ECALpositionGivenExperiment,zMaxDecayVolumeGivenExperiment}]//ReleaseHold];*) +(*<sscut^2]];*) +(*cond*) +(*]*) +(*,CompilationTarget->"C",RuntimeOptions->"Speed",RuntimeAttributes->{Listable},Parallelization->True,CompilationOptions->{"InlineExternalDefinitions"->True,"InlineCompiledFunctions"->True}]/.ruleDown[{SScutID,SSproductsSquared}]/.ruleOwn[{SScutZero}]//ReleaseHold];*) +(*<"C",RuntimeOptions->"Speed",RuntimeAttributes->{Listable},Parallelization->True]/.ruleDown[{minvProductsSquared}]/.ruleOwn[{minvCutLowerZero,minvCutUpperZero,IfminvLowerCuts,IfminvUpperCuts}]//ReleaseHold];*) +(*<10^-5.,cond=0.;Break[];];*)*) +(*(*Calculating the geometric part of the decay acceptance for the second decay product*)*) +(*pdg2=Compile`GetElement[TablePhaseSpaceDecayProducts,in2,indexpdg1];*) +(*{cond,Coord1FinProd2,Coord2FinProd2}=CondGeom[charge2,pdg2,xdecayfip,ydecayfip,zfip,px2lab,py2lab,pz2lab,E2lab,zmagnMzfip];*) +(*(*If other cuts are required and the geometric condition for product2 is 1 then evaluate the acceptance for these cuts*)*) +(*If[cond==1.&&WhetherCuts==1,*) +(*(*PDG identifiers of the decay products*)*) +(*(*Values of the energy cuts for the decay products*)*) +(*If[IfEcuts==1&&cond==1.,cond=CondE[pdg1,charge1,pdg2,E1lab,E2lab]];*) +(*(*The Subscript[p, T] cut. If it is present then evaluate the acceptance. If not then proceeding to the next cut*)*) +(*If[IfpTcuts==1&&cond==1.,cond=CondPT[pdg1,charge1,pdg2,px1lab,py1lab,px2lab,py2lab]];*) +(*(*The IP cut. If it is present then evaluate the acceptance. If not then proceeding to the next cut*)*) +(*If[IfIPcuts==1&&cond==1.,cond=CondIP[pdg1,pdg2,xdecayfip,ydecayfip,zfip,px1lab,px2lab,py1lab,py2lab,pz1lab,pz2lab]];*) +(*(*The spatial separation cut. If it is present then evaluate the acceptance. If not then proceeding to the next cut*)*) +(*If[IfAngSepCuts==1&&cond==1.,cond=CondAS[pdg1,pdg2,zfip,px1lab,px2lab,py1lab,py2lab,pz1lab,pz2lab]];*) +(*(*The spatial separation cut*)*) +(*If[IfSScuts==1&&cond==1.,cond=CondSS[pdg1,pdg2,Coord1FinProd1,Coord2FinProd1,Coord1FinProd2,Coord2FinProd2]];*) +(*(*The invariant mass cut*)*) +(*If[IfminvCuts==1&&cond==1.,cond=CondMinv[pdg1,charge1,pdg2,px1lab,py1lab,pz1lab,E1lab,px2lab,py2lab,pz2lab,E2lab]];*) +(*];*) +(*];*) +(*(*If the acceptance after all cuts is 1, then add it to the counter and break the cycle*)*) +(*If[cond==1.,count+=cond;Break[]],{f2,1,nproducts-f1-1,1}]*) +(*];*) +(*(*If the acceptance is 1 then exit the cycle*)*) +(*If[cond==1.,Break[]],{f1,0,f1max,1}]*) +(*,{j,1,len}];*) +(*,*) +(*count=0.*) +(*];*) +(*(*Returns the decay acceptance*)*) +(*{count/len}*) +(*],CompilationTarget->"C",RuntimeOptions->"Speed",RuntimeAttributes->{Listable},CompilationOptions->{"InlineCompiledFunctions"->True},Parallelization->True]/.ruleDown[{LLPdecayVertexX,LLPdecayVertexY,pproductLab1Cart,pproductLab2Cart,pproductLab3Cart,EproductLabCart}]/.ruleOwn[{indexpdg1,indexELLP,indexzLLP,index\[Theta]LLP,index\[Phi]LLP,indexLLPazAcc,indexpx1,indexpy1,indexpz1,indexE1,LengthDataProduct,WhetherCuts,indexcharge1,zMagnetMinGivenExperiment,zMagnetMaxGivenExperiment,IfEcuts,IfpTcuts,IfAngSepCuts,IfIPcuts,IfminvCuts,IfSScuts}]//ReleaseHold];*) +(*<=tracksmin,Break[]];*) +(*];*) +(*,{f1,0,f1max,1}];*) +(*If[trackcounter>=tracksmin,count+=cond];*) +(*,{j,1,len}];*) +(*,*) +(*count=0.*) +(*];*) +(*(*Returns the decay acceptance*)*) +(*{count/len}*) +(*],CompilationTarget->"C",RuntimeOptions->"Speed",RuntimeAttributes->{Listable},CompilationOptions->{"InlineCompiledFunctions"->True},Parallelization->True]/.ruleDown[{LLPdecayVertexX,LLPdecayVertexY,pproductLab1Cart,pproductLab2Cart,pproductLab3Cart,EproductLabCart}]/.ruleOwn[{indexpdg1,indexELLP,indexzLLP,index\[Theta]LLP,index\[Phi]LLP,indexLLPazAcc,indexpx1,indexpy1,indexpz1,indexE1,LengthDataProduct,WhetherCuts,indexcharge1,zMagnetMaxGivenExperiment,zMagnetMinGivenExperiment,IfEcuts,IfpTcuts,IfAngSepCuts,IfIPcuts,IfminvCuts}]//ReleaseHold];*) +(*<"C",RuntimeOptions->"Speed",RuntimeAttributes->{Listable},CompilationOptions->{"InlineCompiledFunctions"->True},Parallelization->True]/.ruleDown[{LLPdecayVertexX,LLPdecayVertexY,pproductLab1Cart,pproductLab2Cart,pproductLab3Cart,EproductLabCart}]/.ruleOwn[{indexpdg1,indexELLP,indexzLLP,index\[Theta]LLP,index\[Phi]LLP,indexLLPazAcc,indexpx1,indexpy1,indexpz1,indexE1,LengthDataProduct,WhetherCuts,indexcharge1,zMagnetMaxGivenExperiment,zMagnetMinGivenExperiment,IfEcuts,IfpTcuts,IfAngSepCuts,IfIPcuts,IfminvCuts}]//ReleaseHold];*) +(*<0.||condGood>2,cond=0.;Break[]];*) +(*If[condg1==1,If[condGood==1,e1=E1lab,If[condGood==2,e2=E1lab]]];*) +(*(*If other cuts are required and the geometric condition for product2 is 1 then evaluate the acceptance for these cuts*)*) +(*,{f1,0,f1max,1}];*) +(*If[condGood>0.&&WhetherCuts==1&&condBad==0.,*) +(*(*Values of the energy cuts for the decay products*)*) +(*If[IfEcuts==1,count+=CondE[22.,0.,22.,e1,e2]];*) +(*(*(*The Subscript[p, T] cut. If it is present then evaluate the acceptance. If not then proceeding to the next cut*)*) +(*If[IfpTcuts==1&&cond\[Equal]1,cond=CondPT[pdg1,pdg2,px1lab,py1lab,px2lab,py2lab]];*) +(*(*The IP cut. If it is present then evaluate the acceptance. If not then proceeding to the next cut*)*) +(*If[IfIPcuts==1&&cond\[Equal]1,cond=CondIP[pdg1,pdg2,xdecayfip,ydecayfip,zfip,px1lab,px2lab,py1lab,py2lab,pz1lab,pz2lab]];*) +(*(*The spatial separation cut. If it is present then evaluate the acceptance. If not then proceeding to the next cut*)*) +(*If[IfAngSepCuts==1&&cond\[Equal]1,cond=CondSS[pdg1,pdg2,zfip,px1lab,px2lab,py1lab,py2lab,pz1lab,pz2lab]];*) +(*(*The invariant mass cut*)*) +(*If[IfminvCuts==1&&cond\[Equal]1,cond=CondMinv[pdg1,pdg2,px1lab,py1lab,pz1lab,E1lab,px2lab,py2lab,pz2lab,E2lab]];*)*) +(*];*) +(*,{j,1,len}];*) +(*(*Returns the number of simulated acceptances divided by the number of simulated events. For the decays where more than one combination of decay products pair exists, this value may be > 1. It will be replaced with \[Equal] 1 in the next step*)*) +(*,*) +(*count=0.;*) +(*];*) +(*{count/len}*) +(*],CompilationTarget->"C",RuntimeOptions->"Speed",RuntimeAttributes->{Listable},CompilationOptions->{"InlineCompiledFunctions"->True},Parallelization->True]/.ruleDown[{LLPdecayVertexX,LLPdecayVertexY,pproductLab1Cart,pproductLab2Cart,pproductLab3Cart,EproductLabCart}]/.ruleOwn[{indexpdg1,indexELLP,indexzLLP,index\[Theta]LLP,index\[Phi]LLP,indexLLPazAcc,indexpx1,indexpy1,indexpz1,indexE1,LengthDataProduct,WhetherCuts,indexcharge1,zMagnetMaxGivenExperiment,IfEcuts,IfpTcuts,IfAngSepCuts,IfIPcuts,IfminvCuts}]//ReleaseHold];*) +(*<"C",RuntimeOptions->"Speed",RuntimeAttributes->{Listable},Parallelization->True]/.OwnValues@DetectablePDGsGivenExperiment//ReleaseHold*) +(*CompilePrint@detectableproducts;*) +(*(*This block generates the phase space per LLP decay by averaging over various decay channels*)*) +(*PhaseSpacePerDecay[LLP_,mLLP_,proclist_,isimlist_,HadronizationOption_]:=Block[{},*) +(*pss0=Developer`ToPackedArray@PadRight[Join[##]&@@Table[PhaseSpacePerDecayChannel[LLP,mLLP,proclist[[i]],isimlist[[i]],HadronizationOption],{i,1,Length[proclist],1}],Automatic,-999.];*) +(*(*List of decay products pdg IDs per decay*)*) +(*pdglists=pss0[[All,-LengthDataProduct+indexpdg1+LengthDataProduct*Range[1,Length[pss0[[1]]]/8]]];*) +(*(*The amount of particles that may be detected per given experiment*)*) +(*numdetectableproducts=detectableproducts[pdglists];*) +(*(*pss=Map[Flatten[SortBy[Partition[#,LengthDataProduct],-#[[indexE1]]&]]&,pss];*)*) +(*(*The phase space sorted in descending order by the number of detectable products*)*) +(*pss=pss0[[Ordering[numdetectableproducts,All,Greater]]];*) +(*pss*) +(*]*) +(*(*This block takes the phase space generated by the previous block and converts it in the form or rows decay product data,decay product data. To distinguish various decays, eventlengths is used*)*) +(*PhaseSpacePerDecayReshaped[LLP_,mLLP_,proclist_,isimlist_,HadronizationOption_]:=Block[{},*) +(*ps=PhaseSpacePerDecay[LLP,mLLP,proclist,isimlist,HadronizationOption];*) +(*ps1=ArrayReshape[Flatten[ps],{Length[ps] Length[ps[[1]]]/LengthDataProduct,LengthDataProduct}]//Developer`ToPackedArray;*) +(*ps1=Select[ps1,MemberQ[DetectablePDGsGivenExperiment,#[[indexpdg1]]]==True&]//Developer`ToPackedArray;*) +(*(*eventlengths=nprodscomp[ps];*) +(*eventlengths={Drop[Accumulate[Prepend[eventlengths,0]]+1,-1],eventlengths}//Transpose;*)*) +(*eventlengths=SortBy[numdetectableproducts,-#&];*) +(*eventlengths={Drop[Accumulate[Prepend[eventlengths,0]]+1,-1],eventlengths}//Transpose;*) +(*(*eventlengths={Range[1,isimlist//Total],SortBy[numdetectableproducts,-#&]}//Transpose;*)*) +(*{ps1,eventlengths}*) +(*]*) +(*(*Block computing decay acceptance*)*) +(*DecayAcceptanceELLP\[Theta]LLPzLLPoverall[LLP_,mLLP_,proclist_,isimlist_,gridNonZero_,HadronizationOption_,AllProductsWithinAcceptance_,ntracksmin_]:=Module[{(*PhaseSpaceGiven,*)},*) +(*(*Phase space of LLP decays at rest - up to stable decay products: charged pions, charged kaons, Subscript[K, L], and photons*)*) +(*{PhaseSpaceGiven,eventslengths}=PhaseSpacePerDecayReshaped[LLP,mLLP,proclist,isimlist,HadronizationOption];*) +(*(*Averaging over distinct decay products set for the given phase space*)*) +(*(*Computing the decay products acceptance: at this step, no averaging over \[Phi]*)*) +(*ifcharm=MemberQ[{"CHARM-photon"},GivenExperiment];*) +(*isimvv=isimlist//Total;*) +(*If[ifcharm==True,\[Epsilon]Decay\[Phi]Unaveraged=DecayAcceptanceCHARM\[Gamma]Comp[gridNonZero,PhaseSpaceGiven,mLLP,eventslengths]];*) +(*If[AllProductsWithinAcceptance==">=2"&&ifcharm==False,\[Epsilon]Decay\[Phi]Unaveraged=DecayAcceptanceComp[gridNonZero,PhaseSpaceGiven,mLLP,eventslengths]];*) +(*If[AllProductsWithinAcceptance==">=n"&&ifcharm==False,\[Epsilon]Decay\[Phi]Unaveraged=DecayAcceptancenProductsComp[gridNonZero,PhaseSpaceGiven,mLLP,eventslengths,ntracksmin]];*) +(*If[AllProductsWithinAcceptance=="All detectable"&&ifcharm==False,\[Epsilon]Decay\[Phi]Unaveraged=DecayAcceptanceAllProductsComp[gridNonZero,PhaseSpaceGiven,mLLP,eventslengths]];*) +(*(*And then averaging over \[Phi]*)*) +(*\[Epsilon]av=If[\[Epsilon]Decay\[Phi]Unaveraged!={},\[Epsilon]DecayE\[Theta]zcompiled[\[Epsilon]Decay\[Phi]Unaveraged,NofPhiVals],{}]*) +(*]*) + + +(* ::Subsection:: *) +(*If the LLP, its mass, and the grid Subscript[E, LLP],Subscript[\[Theta], LLP],Subscript[z, LLP] are fixed (uses the routine for the fixed phase space of decay products from the previous section)*) + + +(* ::Input:: *) +(*(*Block that takes the table {Subscript[E, LLP],Subscript[z, LLP],Subscript[\[Theta], LLP],Subscript[z, LLP],Subscript[\[Epsilon], az,LLP],Subscript[\[Phi], LLP]} and computes {Subscript[E, LLP],Subscript[z, LLP],Subscript[\[Theta], LLP],Subscript[z, LLP],Subscript[\[Epsilon], az,LLP],\!\(\(<\)*) +(*\*SubscriptBox[\(\[Epsilon]\), \(decay, LLP\)]*) +(*\*SubscriptBox[\(>\), *) +(*SubscriptBox[\(\[Phi]\), \(LLP\)]]\)} for the given LLP and mass. It averages over dominant LLP's decays.*)*) +(*DecayAcceptanceBlock[LLP_,mLLP_,proclist_,grid_,gridreduced_,isim_,HadronizationOption_,AllProductsWithinAcceptance_,ntracksmin_]:=Block[{},*) +(*(*List of processes for the given LLP*)*) +(*ProcessesListGivenComputation=proclist;*) +(*(*Br ratios associated with the given processes*)*) +(*ListBrRatiosGivenComputation=ListBrRatios[LLP,mLLP,#]&/@ProcessesListGivenComputation;*) +(*If[Total[ListBrRatiosGivenComputation]!=0,*) +(*(*Number of decays simulated for each particular channel, joined with the channel identifiers*)*) +(*isimulvalPerDecayChannelTemp=Join[Partition[NeventsSplitted[isim,ListBrRatiosGivenComputation],1],Partition[ProcessesListGivenComputation,1],2];*) +(*(*Selecting only those channels for which the number of simulated decays is > 10^-2Subscript[N, ev]*)*) +(*isimulvalPerDecayChannel=Select[isimulvalPerDecayChannelTemp,#[[1]]>IntegerPart[0.01*isim]&];*) +(*(*Removing rows for which Subscript[E, LLP] < Subscript[m, LLP] or Subscript[\[Epsilon], azimuthal] = 0*)*) +(*gridNonZero=TableLLPnonZeroCompiled[grid,mLLP];*) +(*(*The same table as gridNonZero but with removed column Subscript[\[Phi], LLP] (equivalent to DeleteDuplicatesBy[gridNonZero,{#[[1]],#[[2]],#[[[3]]}&][[All,{1,2,3,4}]])*)*) +(*gridReducedNonZero=TableLLPnonZeroCompiled[gridreduced,mLLP];*) +(*(*The table with the remaining grid for which Subscript[\[Epsilon], az] = 0*)*) +(*gridReducedZero=TableLLPzeroCompiled[gridreduced,mLLP];*) +(*If[Length[gridReducedNonZero]!=0,*) +(*(*__________________________________________*)*) +(*(*Evaluating decay acceptances per each channel and averaging over simulated decays. At this step, some values may be > 1 if the number of combinations of pairs of the decay products is > 1*)*) +(*(*__________________________________________*)*) +(*proclistgiven=isimulvalPerDecayChannel[[All,2]];*) +(*isimlistgiven=isimulvalPerDecayChannel[[All,1]];*) +(*DecayAcceptancesList=DecayAcceptanceELLP\[Theta]LLPzLLPoverall[LLP,mLLP,proclistgiven,isimlistgiven,gridNonZero,HadronizationOption,AllProductsWithinAcceptance,ntracksmin];*) +(*(*This code replaces the values > 1 with 1.*)*) +(*(*Table Subscript[E, LLP],Subscript[\[Theta], LLP],Subscript[z, LLP],Subscript[\[Epsilon], az,LLP],Subscript[\[Epsilon], decay], where the decay acceptance is averaged over channels*)*) +(*t1=Join[gridReducedNonZero,DecayAcceptancesList,2];*) +(*If[Length[gridReducedZero]!=0,*) +(*(*Merging the table computed above with tables with zero acceptance*)*) +(*t2=Join[gridReducedZero,Table[{0.},Length[gridReducedZero]],2];*) +(*(*Final output*)*) +(*finaldata=SortBy[Join[t1,t2],{#[[1]],#[[2]],#[[3]]}&],finaldata=SortBy[t1,{#[[1]],#[[2]],#[[3]]}&]],finaldata=Join[gridreduced,Table[{0.},Length[gridreduced]],2]]*) +(*];*) +(*finaldata*) +(*]*) + + +(* ::Input:: *) +(*(*fff=DecayAcceptanceBlock["HNL-mixing-e",20.,ProcessesListRefined["HNL-mixing-e","False"],gridLLPtoDet,gridReducedLLPtoDet,100,"True",">=2",4];*) +(*fff[[All,-1]]//MinMax*)*) + + +(* ::Subsection:: *) +(*If the LLP and mass only is fixed*) + + +(* ::Input:: *) +(*FinalBlockMass[LLP_,mLLP_,proclist_,isim_,HadronizationOption_,AllProductsWithinAcceptance_,ntracksmin_]:=*) +(*Module[{},*) +(*(*Block computing the decay acceptance for LLPs that point or not point to the detector*)*) +(*{tabAccToDet,tabAccNotToDet}=If[DecayVolumeAsDetectorGivenExperiment=="False"&&!(GivenExperiment=="ANUBIS-ceiling"),{DecayAcceptanceBlock[LLP,mLLP,proclist,gridLLPtoDet,gridReducedLLPtoDet,isim,HadronizationOption,AllProductsWithinAcceptance,ntracksmin],DecayAcceptanceBlock[LLP,mLLP,proclist,gridLLPnotToDet,gridReducedLLPnotToDet,isim,HadronizationOption,AllProductsWithinAcceptance,ntracksmin]},{DecayAcceptanceBlock[LLP,mLLP,proclist,gridLLPtoDet,gridReducedLLPtoDet,isim,HadronizationOption,AllProductsWithinAcceptance,ntracksmin],0}];*) +(*(*Table Subscript[m, LLP], Subscript[E, LLP], Subscript[\[Theta], LLP], Subscript[z, LLP], \!\(\(<\)*) +(*\*SubscriptBox[\(\[Epsilon]\), \(decay\)]*) +(*\*SubscriptBox[\(>\), \(\[Phi], \ to\ det\ + \ not\ to\ det\)]\), \!\(\(<\)\( *) +(*\*SubscriptBox[\(\[Epsilon]\), \(decay\)]**) +(*\*SubscriptBox[\(\[Epsilon]\), \(other\ cuts\)]\)*) +(*\*SubscriptBox[\(>\), \(\[Phi], \ to\ det\ + \ not\ to\ det\)]\)*) *) +(*(*\!\(\(By\)\(\ \)*) +(*\*SubscriptBox[\(<>\), \(\[Phi], \ to\ det\ + \ not\ to\ det\)]\), one averages over the LLP directions pointing to the end of detector and directions that do not point to it, with the weights being the azimuthal acceptance*)*) +(*If[Length[tabAccToDet]!=0,*) +(*If[DecayVolumeAsDetectorGivenExperiment=="False"&&!(GivenExperiment=="ANUBIS-ceiling"),\[Epsilon]dec1Compiled[tabAccToDet,tabAccNotToDet,mLLP],\[Epsilon]dec2Compiled[tabAccToDet,mLLP]]*) +(*]*) +(*]*) diff --git a/codes/wls/experiments.wls b/codes/wls/experiments.wls new file mode 100755 index 0000000..7893f1d --- /dev/null +++ b/codes/wls/experiments.wls @@ -0,0 +1,2865 @@ +#!/usr/bin/env wolframscript +(* ::Package:: *) + +(* ::Chapter::Closed:: *) +(*Definitions*) + + +(* ::Section:: *) +(*SM particles production cross-sections at various facilities*) + + +(* ::Input:: *) +(*theta[\[Eta]_]=2*ArcTan[Exp[-\[Eta]]];*) +(*\[Sigma]ppInpbFacility:=Association[{"FermilabBD"-> 40.*10^9, "SPS"->40.*10^9,"LHC"-> 72.*10^9,"FCC-hh"->104.*10^9,"Serpukhov"->40.*10^9,"ESS"->45.*10^9}]*) +(*LLHChighLumi=3000*10^3;*) +(*LFCChh=20000*10^3;*) +(*(*Cross-sections in pb of bOverscript[b, _] production. For Fermilab/FCC-hh taken from pythia, for SPS taken from http://cds.cern.ch/record/2115534/files/SHiP-NOTE-2015-009.pdf?version=1, for LHC taken from FONLL at the upper bound of uncertainty*)*) +(*\[Sigma]ppTobbInpbFacility:=Association[{"FermilabBD"->3.8,"SPS"->1.7*10^3,"LHC"->6.2*10^8,"FCC-hh"->3.4*10^9,"Serpukhov"->0.,"ESS"->0.}]*) +(*(*Cross-sections in pb of cOverscript[c, _] production. For Fermilab/FCC-hh taken from pythia, for SPS taken from http://cds.cern.ch/record/2115534/files/SHiP-NOTE-2015-009.pdf?version=1, for LHC taken from FONLL at the upper bound of uncertainty*)*) +(*\[Sigma]ppToccInpbFacility:=Association[{"FermilabBD"->0.5*10^6,"SPS"->1.8*10^7,"LHC"->1.8*10^10,"FCC-hh"->4*10^10,"Serpukhov"->0.,"ESS"->0.}]*) +(*(*Data for Higgs production. For LHC, used https://twiki.cern.ch/twiki/view/LHCPhysics/HiggsEuropeanStrategy. For FCC-hh, pythia8 is used*)*) +(*\[Sigma]ppTohInpbFacility:=Association[{"FermilabBD"-> 0.,"SPS"->0.,"LHC"->55,"FCC-hh"->552.,"Serpukhov"->0.,"ESS"->0.}]*) +(*(*Data for the production of light mesons. P means the fraction per collision*)*) +(*(*For SPS, the multiplicities are taken from https://lib-extopc.kek.jp/preprints/PDF/1991/9103/9103008.pdf*)*) +(*(*For Fermilab, obtained using the approach from https://arxiv.org/pdf/2201.05170.pdf*)*) +(*(*For Serpukhov (NuCal), the pythia8 simulation is used*)*) +(*(*For LHC/FCC-hh used EPOS-LHC*)*) +(*PppTo\[Pi]0Facility:=Association[{"FermilabBD"->2.9,"SPS"->4.1,"LHC"->32.03,"FCC-hh"->73.8,"Serpukhov"->2.37,"ESS"->0.59}]*) +(*PppTo\[Eta]Facility:=Association[{"FermilabBD"->0.32,"SPS"->0.4,"LHC"->3.51,"FCC-hh"->8.3,"Serpukhov"->0.211,"ESS"->0.}]*) +(*PppTo\[Eta]prFacility:=Association[{"FermilabBD"->0.033,"SPS"->0.079,"LHC"->0.5,"FCC-hh"->1.1,"Serpukhov"->0.027,"ESS"->0.}]*) +(*PppTo\[Rho]0Facility:=Association[{"FermilabBD"->0.36,"SPS"->0.548,"LHC"->4.51,"FCC-hh"->8.26,"Serpukhov"->0.294,"ESS"->0.}]*) +(*PppTo\[Omega]Facility:=Association[{"FermilabBD"->0.36,"SPS"->0.548,"LHC"->4.42,"FCC-hh"->7.75,"Serpukhov"->0.2983,"ESS"->0.}]*) +(*PppTo\[Omega]Facility:=Association[{"FermilabBD"->0.0123,"SPS"->0.022,"LHC"->0.2486,"FCC-hh"->0.51999,"Serpukhov"->0.0086,"ESS"->0.}]*) +(*(*Production probability of charged \[Pi] and \[Mu]. Currently, used only for ESS*)*) +(*PppTo\[Pi]chargedFacility:=Association[{"ESS"->0.3}]*) +(*PppTo\[Mu]Facility:=Association[{"ESS"->0.3}]*) +(*(*For J/\[Psi] and \[CapitalUpsilon], the FCC-hh data is to be updated*)*) +(*PppToJpsiFacility:=Association[{"FermilabBD"->5.24*10^-7,"SPS"->3.5*10^-6,"LHC"->0.001,"FCC-hh"->0.,"Serpukhov"->0.,"ESS"->0.}]*) +(*PppToUpsilonFacility:=Association[{"FermilabBD"->0.,"SPS"->0.,"LHC"->1.35*10^-5,"FCC-hh"->0.,"Serpukhov"->0.,"ESS"->0.}]*) +(*(*\[Phi] multiplicity - per p-p collision (currently)*)*) +(*PppToPhiFacility:=Association[{"FermilabBD"->0.0106,"SPS"->0.02,"LHC"->0.53,"FCC-hh"->1.13,"Serpukhov"->8.4*10^-3,"ESS"->0.}]*) +(*(*Data for W production*)*) +(*(*For LHC, https://arxiv.org/abs/1603.09222 is used. For FCC-hh, pythia8 is used*)*) +(*\[Sigma]ppToWInpbFacility:=Association[{"FermilabBD"-> 0.,"SPS"->0.,"LHC"->10^3*20.62/0.107,"FCC-hh"->1.1*10^6,"Serpukhov"->0.,"ESS"->0.}]*) +(*(*Maximal energy of LLP available at the given experiment*)*) +(*EmaxFacility:=Association[{"SPS"->400.,"FermilabBD"->120.,"LHC"->6500.,"FCC-hh"-> 50000.,"Serpukhov"->70.,"ESS"->2.4}]*) + + +(* ::Section::Closed:: *) +(*Generic definitions used to calculate acceptances*) + + +(* ::Input:: *) +(*Boxcylpar[experiment_]:=GeometryExperiment[experiment]=="Box"||(GeometryExperiment[experiment]=="Cylinder"&&DetectorPlaneOrientationExperiment[experiment]=="Parallel");*) +(*(*Condition to define whether the LLP is inside the decay volume*)*) +(*IfLLPinsideDecVolSimple[experiment_]:=Block[{},*) +(*If[Evaluate[Boxcylpar[experiment]],*) +(*XminDecVol[zLLP_]=xToDecayVolumeCenterExperiment[zLLP,experiment]-dxDecayVolumeExperiment[zLLP,experiment]/2.;*) +(*XmaxDecVol[zLLP_]=xToDecayVolumeCenterExperiment[zLLP,experiment]+dxDecayVolumeExperiment[zLLP,experiment]/2.;*) +(*YminDecVol[zLLP_]=yToDecayVolumeCenterExperiment[zLLP,experiment]-dyDecayVolumeExperiment[zLLP,experiment]/2.;*) +(*YmaxDecVol[zLLP_]=yToDecayVolumeCenterExperiment[zLLP,experiment]+dyDecayVolumeExperiment[zLLP,experiment]/2.;*) +(*(*If the experiment has box geometry, or if it has the cylinder geometry and the detector plane is oriented parallel to the beamline, then at the given z the LLP must be within a rectangle*)*) +(*(*Otherwise*)*) +(*cnd=Boole[XminDecVol[zLLP]0,Min[zvtxX,zvtxY],Max[zvtxX,zvtxY]];*) +(*(*The value of z at which \[CapitalDelta]x vanishes*)*) +(*zVtxFast=If[Sign[derx]>0,Max[zvtxX,zvtxY],Min[zvtxX,zvtxY]];*) +(*(*The z coordinate of the widest part of the pyramid*)*) +(*zO=If[FrustumDirection>0,zMax,zMin];*) +(*p1=Pyramid[{{xctr[zO]-dx[zO]/2,yctr[zO]-dy[zO]/2,zO},{xctr[zO]-dx[zO]/2,yctr[zO]+dy[zO]/2,zO},{xctr[zO]+dx[zO]/2,yctr[zO]+dy[zO]/2,zO},{xctr[zO]+dx[zO]/2,yctr[zO]-dy[zO]/2,zO},{xctr[zVtxSlow],yctr[zVtxSlow],zVtxSlow}}];*) +(*If[zVtxFast==zvtxY,*) +(*\[CapitalDelta]xFakeTemp[\[CapitalDelta]xIni_,z_]=If[FrustumDirection>0,\[CapitalDelta]xIni*(z-zMin)/(zMax-zMin)+dx[zMin]*(z-zMax)/(zMin-zMax),\[CapitalDelta]xIni*(z-zMax)/(zMin-zMax)+dx[zMax]*(z-zMin)/(zMax-zMin)];*) +(*\[CapitalDelta]xIniFake=\[CapitalDelta]xIni/.Solve[\[CapitalDelta]xFakeTemp[\[CapitalDelta]xIni,zVtxFast]==0,\[CapitalDelta]xIni][[1]];*) +(*\[CapitalDelta]xFake[z_]=\[CapitalDelta]xFakeTemp[\[CapitalDelta]xIniFake,z];*) +(*p2=Pyramid[{{xctr[zO]-\[CapitalDelta]xFake[zO]/2,yctr[zO]-dy[zO]/2,zO},{xctr[zO]-\[CapitalDelta]xFake[zO]/2,yctr[zO]+dy[zO]/2,zO},{xctr[zO]+\[CapitalDelta]xFake[zO]/2,yctr[zO]+dy[zO]/2,zO},{xctr[zO]+\[CapitalDelta]xFake[zO]/2,yctr[zO]-dy[zO]/2,zO},{xctr[zVtxFast],yctr[zVtxFast],zVtxFast}}]*) +(*,*) +(*\[CapitalDelta]yFakeTemp[\[CapitalDelta]yIni_,z_]=If[FrustumDirection>0,\[CapitalDelta]yIni*(z-zMin)/(zMax-zMin)+dy[zMin]*(z-zMax)/(zMin-zMax),\[CapitalDelta]yIni*(z-zMax)/(zMin-zMax)+dy[zMax]*(z-zMin)/(zMax-zMin)];*) +(*\[CapitalDelta]yIniFake=\[CapitalDelta]yIni/.Solve[\[CapitalDelta]yFakeTemp[\[CapitalDelta]yIni,zVtxFast]==0,\[CapitalDelta]yIni][[1]];*) +(*\[CapitalDelta]yFake[z_]=\[CapitalDelta]yFakeTemp[\[CapitalDelta]yIniFake,z];*) +(*p2=Pyramid[{{xctr[zO]-dx[zO]/2,yctr[zO]-\[CapitalDelta]yFake[zO]/2,zO},{xctr[zO]-dx[zO]/2,yctr[zO]+\[CapitalDelta]yFake[zO]/2,zO},{xctr[zO]+dx[zO]/2,yctr[zO]+\[CapitalDelta]yFake[zO]/2,zO},{xctr[zO]+dx[zO]/2,yctr[zO]-\[CapitalDelta]yFake[zO]/2,zO},{xctr[zVtxFast],yctr[zVtxFast],zVtxFast}}]];*) +(*zM=If[FrustumDirection>0,zMin,zMax];*) +(*cuboid=Cuboid[{xctr[zO]-dx[zO]/2,yctr[zO]-dy[zO]/2,zMin},{xctr[zO]+dx[zO]/2,yctr[zO]+dy[zO]/2,zMax}];*) +(*RegionIntersection[p2,RegionIntersection[cuboid,p1]]*) +(*]*) +(*(*Region[BlockDecayVolumePyramidalFrustum["CHARM-lepton"]]*) +(*Region[BlockDecayVolumePyramidalFrustum["SHiP-ECN3"]]*)*) + + +(* ::Subsubsection:: *) +(*LHCb-downstream*) + + +(* ::Input:: *) +(*LHCbfarDecayVolume[exp_]:=Block[{},*) +(*z\[Theta]ConicalFrustum[z1_,z2_,\[Theta]_]:=ConvexHullMesh[Join@@(Map[Append[#],CirclePoints[# Tan[\[Theta]],100]]&/@{z1,z2})];*) +(*foutAnnular=z\[Theta]ConicalFrustum[zToDecayVolumeExperiment[exp],zToDecayVolumeExperiment[exp]+dzDecayVolumeExperiment[exp],theta[2.]];*) +(*finAnnular=z\[Theta]ConicalFrustum[zToDecayVolumeExperiment[exp],zToDecayVolumeExperiment[exp]+dzDecayVolumeExperiment[exp],theta[5.]];*) +(*RegionDifference[foutAnnular,finAnnular]*) +(*]*) +(*(*Region[Style[LHCbfarDecayVolume,Opacity[0.1]],BoxRatios\[Rule]{1,1,1},Boxed\[Rule]True,Axes\[Rule]True]*)*) + + +(* ::Subsubsection:: *) +(*LHCb-muon chamber*) + + +(* ::Input:: *) +(*LHCbMuonVol2=Parallelepiped[{xToDecayVolumeCenterExperiment[z,"LHCb-muon-chamber"]-dxDecayVolumeExperiment[z,"LHCb-muon-chamber"]/2,yToDecayVolumeCenterExperiment[z,"LHCb-muon-chamber"]-dyDecayVolumeExperiment[z,"LHCb-muon-chamber"]/2,zToDecayVolumeExperiment["LHCb-muon-chamber"]},{{dxDecayVolumeExperiment[z,"LHCb-muon-chamber"],0,0},{0,dyDecayVolumeExperiment[z,"LHCb-muon-chamber"],0},{0,0,dzDecayVolumeExperiment["LHCb-muon-chamber"]}}];*) +(*LHCbMuonVol1=Parallelepiped[{-0.03,-0.025,zToDecayVolumeExperiment["LHCb-muon-chamber"]},{{0.06,0,0},{0,0.05,0},{0,0,dzDecayVolumeExperiment["LHCb-muon-chamber"]}}];*) +(*LHCbMuonVol=RegionDifference[LHCbMuonVol2,LHCbMuonVol1];*) + + +(* ::Input:: *) +(*(*SHADOWSlatestPart1=Parallelepiped[{xToDecayVolumeCenterExperiment[15,"SHADOWS-latest"]-dxDecayVolumeExperiment[15,"SHADOWS-latest"]/2,yToDecayVolumeCenterExperiment[15,"SHADOWS-latest"]-dyDecayVolumeExperiment[15,"SHADOWS-latest"]/2,zToDecayVolumeExperiment["SHADOWS-latest"]},{{dxDecayVolumeExperiment[15,"SHADOWS-latest"],0,0},{0,dyDecayVolumeExperiment[15,"SHADOWS-latest"],0},{0,0,12}}];*) +(*SHADOWSlatestPart2=Parallelepiped[{xToDecayVolumeCenterExperiment[14.5+13,"SHADOWS-latest"]-dxDecayVolumeExperiment[14.5+13,"SHADOWS-latest"]/2,yToDecayVolumeCenterExperiment[14.5+13,"SHADOWS-latest"]-dyDecayVolumeExperiment[14.5+13,"SHADOWS-latest"]/2,zToDecayVolumeExperiment["SHADOWS-latest"]+12},{{dxDecayVolumeExperiment[14.5+13,"SHADOWS-latest"],0,0},{0,dyDecayVolumeExperiment[14.5+13,"SHADOWS-latest"],0},{0,0,7.}}];*) +(*DecayVolumeSHADOWSlatest=RegionUnion[SHADOWSlatestPart1,SHADOWSlatestPart2];*)*) +(*(*Region[Style[LHCbfarDecayVolume,Opacity[0.1]],BoxRatios\[Rule]{1,1,1},Boxed\[Rule]True,Axes\[Rule]True]*)*) + + +(* ::Subsubsection:: *) +(*Total*) + + +(* ::Input:: *) +(*listgeometrynonstandard=Join[explistship,explistlhcb];*) +(*NonStandardDecayVolumeGeometry[experiment_]:=If[StringContainsQ[experiment,{"SHiP","CHARM"}]==True,BlockDecayVolumePyramidalFrustum[experiment],If[StringContainsQ[experiment,"LHCb-downstream"]==True,LHCbfarDecayVolume[experiment],LHCbMuonVol]]*) + + +(* ::Subsection:: *) +(*Combined - for standard and non-standard geometries*) + + +(* ::Input:: *) +(*DecayVolumeGeometry[experiment_]:=If[MemberQ[listgeometrynonstandard,experiment]==True,NonStandardDecayVolumeGeometry[experiment],StandardShapeDecayVolume[experiment,GeometryExperiment[experiment]]]*) +(*(*Region[Style[DecayVolumeGeometry["LHCb-downstream"],Blue,Opacity[0.1]],BoxRatios\[Rule]{1,1,1},Boxed\[Rule]True,Axes\[Rule]True]*)*) + + +(* ::Subsection:: *) +(*Slice of the decay volume*) + + +(* ::Input:: *) +(*(*Slice of the decay volume of the experiment in the plane parallel to detector plane*)*) +(*ExperimentDecayVolumeSlice[experiment_,z_,"Box"]:=Box[{xToDecayVolumeCenterExperiment[z,experiment]-dxDecayVolumeExperiment[z,experiment]/2,yToDecayVolumeCenterExperiment[z,experiment]-dyDecayVolumeExperiment[z,experiment]/2},{xToDecayVolumeCenterExperiment[z,experiment]+dxDecayVolumeExperiment[z,experiment]/2,yToDecayVolumeCenterExperiment[z,experiment]+dyDecayVolumeExperiment[z,experiment]/2}]*) +(*ExperimentDecayVolumeSlice[experiment_,z_,"Cylinder"]:=If[DetectorPlaneOrientationExperiment[experiment]=="Transverse",Disk[{xToDecayVolumeCenterExperiment[z,experiment],yToDecayVolumeCenterExperiment[z,experiment]},RouterDecayVolumeExperiment[experiment,z]],Box[{xToDecayVolumeCenterExperiment[z,experiment]-dxDecayVolumeExperiment[z,experiment]/2,yToDecayVolumeCenterExperiment[z,experiment]-dyDecayVolumeExperiment[z,experiment]/2},{xToDecayVolumeCenterExperiment[z,experiment]+dxDecayVolumeExperiment[z,experiment]/2,yToDecayVolumeCenterExperiment[z,experiment]+dyDecayVolumeExperiment[z,experiment]/2}]]*) +(*(*For annular cylinder. A priori assumed that the detector plane orientation is transverse to the beam axis*)*) +(*ExperimentDecayVolumeSlice[experiment_,z_,"Annular cylinder"]:=If[GeometryExperiment[experiment]=="Annular cylinder",RegionDifference[Disk[{xToDecayVolumeCenterExperiment[z,experiment],yToDecayVolumeCenterExperiment[z,experiment]},RouterDecayVolumeExperiment[experiment,z]],Disk[{xToDecayVolumeCenterExperiment[z,experiment],yToDecayVolumeCenterExperiment[z,experiment]},RinnerDecayVolumeExperiment[experiment,z]]],0];*) + + +(* ::Section:: *) +(*Full geometry of the detector (needed for visualization+determining angular coverage)*) + + +(* ::Subsection:: *) +(*Standard geometry*) + + +(* ::Subsubsection:: *) +(*Box*) + + +(* ::Input:: *) +(*(*\[Xi] = 0 for full detector, and say 0.99 if you are interested in the plane defining the end of the detector*)*) +(*StandardDetectorGeometry[experiment_,"Box",\[Xi]_]:=Block[{},*) +(*xlongmax=xLongMaxDetectorExperiment[experiment];*) +(*dxlong=dxLongDetectorExperiment[experiment];*) +(*zmaxdecvol=zMaxDecayVolumeExperiment[experiment];*) +(*ztodec=zToDecayVolumeExperiment[experiment];*) +(*dxdet=dxDetectorExperiment[experiment,xlongmax];*) +(*dydet=dyDetectorExperiment[experiment,xlongmax];*) +(*dzdet=dzDetectorExperiment[experiment];*) +(*xcent=xToDetectorCenterExperiment[experiment];*) +(*ycent=yToDetectorCenterExperiment[experiment];*) +(*If[DetectorPlaneOrientationExperiment[experiment]=="Transverse",Parallelepiped[{xcent-dxdet/2,ycent-dydet/2,xlongmax-(1-\[Xi])*dxlong},{{dxdet,0,0},{0,dydet,0},{0,0,(1-\[Xi])dxlong}}],Parallelepiped[{xcent-dxdet/2,xlongmax-(1-\[Xi])dxlong,ztodec},{{dxdet,0,0},{0,(1-\[Xi])dxlong,0},{0,0,dzdet}}]]*) +(*]*) + + +(* ::Subsubsection:: *) +(*Cylinder*) + + +(* ::Input:: *) +(*StandardDetectorGeometry[experiment_,"Cylinder",\[Xi]_]:=Block[{},*) +(*xlongmax=xLongMaxDetectorExperiment[experiment];*) +(*xcent=xToDetectorCenterExperiment[experiment];*) +(*ycent=yToDetectorCenterExperiment[experiment];*) +(*zmaxdecvol=zMaxDecayVolumeExperiment[experiment];*) +(*ztodec=zToDecayVolumeExperiment[experiment];*) +(*dxlong=dxLongDetectorExperiment[experiment];*) +(*dydet=dyDetectorExperiment[experiment,xlongmax];*) +(*rin=RinnerDetectorExperiment[experiment,xlongmax];*) +(*rout=RouterDetectorExperiment[experiment,xlongmax];*) +(*dzdec=dzDecayVolumeExperiment[experiment];*) +(*If[DetectorPlaneOrientationExperiment[experiment]=="Transverse",Cylinder[{{xcent,ycent,xlongmax-(1-\[Xi])dxlong},{xcent,ycent,xlongmax}},rout],Cylinder[{{xcent,xlongmax-(1-\[Xi])dxlong,ztodec+dzdec/2},{xcent,xlongmax,ztodec+dzdec/2}},rout]]*) +(*]*) + + +(* ::Subsubsection:: *) +(*Annular cylinder*) + + +(* ::Input:: *) +(*StandardDetectorGeometry[experiment_,"Annular cylinder",\[Xi]_]:=Block[{},*) +(*xlongmax=xLongMaxDetectorExperiment[experiment];*) +(*xcent=xToDetectorCenterExperiment[experiment];*) +(*ycent=yToDetectorCenterExperiment[experiment];*) +(*zmaxdecvol=zMaxDecayVolumeExperiment[experiment];*) +(*ztodec=zToDecayVolumeExperiment[experiment];*) +(*dxlong=dxLongDetectorExperiment[experiment];*) +(*rin=RinnerDetectorExperiment[experiment,xlongmax];*) +(*rout=RouterDetectorExperiment[experiment,xlongmax];*) +(*foutDetAnnular=If[DetectorPlaneOrientationExperiment[experiment]=="Transverse",Cylinder[{{xcent,ycent,zmaxdecvol+\[Xi]*dxlong},{xcent,ycent,xlongmax}},rout],Cylinder[{{xcent,zmaxdecvol+\[Xi]*dxlong,ycent},{xcent,xlongmax,ycent}},rout]];*) +(*finDetAnnular=If[DetectorPlaneOrientationExperiment[experiment]=="Transverse",Cylinder[{{xcent,ycent,zmaxdecvol+\[Xi]*dxlong},{xcent,ycent,xlongmax}},rin],Cylinder[{{xcent,zmaxdecvol+\[Xi]*dxlong,ycent},{xcent,xlongmax,ycent}},rin]];*) +(*RegionDifference[foutDetAnnular,finDetAnnular]*) +(*]*) +(*(*Region[Style[StandardDetectorGeometry["FACET",GeometryExperiment["FACET"],0],Opacity[0.1]],BoxRatios\[Rule]{1,1,1},Boxed\[Rule]True,Axes\[Rule]True]*)*) + + +(* ::Subsection:: *) +(*Non-standard geometry*) + + +(* ::Subsubsection:: *) +(*LHCb-downstream*) + + +(* ::Input:: *) +(*(*Assuming that the detector is a cone with a smaller cone deducted*)*) +(*LHCbfarDetectorVolumeTemp[exp_,\[Xi]_]:=Block[{},*) +(*z\[Theta]ConicalFrustum[z1_,z2_,\[Theta]_]:=ConvexHullMesh[Join@@(Map[Append[#],CirclePoints[# Tan[\[Theta]],100]]&/@{z1,z2})];*) +(*foutDetAnnular=z\[Theta]ConicalFrustum[zMaxDecayVolumeExperiment[exp]+(xLongMaxDetectorExperiment[exp]-zMaxDecayVolumeExperiment[exp])*\[Xi],xLongMaxDetectorExperiment[exp],theta[2.]];*) +(*finDetAnnular=z\[Theta]ConicalFrustum[zMaxDecayVolumeExperiment[exp]+(xLongMaxDetectorExperiment[exp]-zMaxDecayVolumeExperiment[exp])*\[Xi],xLongMaxDetectorExperiment[exp],theta[5.]];*) +(*RegionDifference[foutDetAnnular,finDetAnnular]*) +(*]*) +(*(*SciFi geometry*)*) +(*LHCbfarSciFiDetectorVolumeTemp[experiment_,\[Xi]_]:=Block[{},*) +(*xlongmax=xLongMaxDetectorExperiment[experiment];*) +(*xcent=xToDetectorCenterExperiment[experiment];*) +(*ycent=yToDetectorCenterExperiment[experiment];*) +(*zmaxdecvol=zMaxDecayVolumeExperiment[experiment];*) +(*ztodec=zToDecayVolumeExperiment[experiment];*) +(*dxlong=dxLongDetectorExperiment[experiment];*) +(*dydet=dyDetectorExperiment[experiment,xlongmax];*) +(*rin=RinnerDetectorExperiment[experiment,xlongmax];*) +(*rout=RouterDetectorExperiment[experiment,xlongmax];*) +(*dzdec=dzDecayVolumeExperiment[experiment];*) +(*dxdet=dxDetectorExperiment[experiment,xlongmax];*) +(*z\[Theta]ConicalFrustum[z1_,z2_,\[Theta]_]:=ConvexHullMesh[Join@@(Map[Append[#],CirclePoints[# Tan[\[Theta]],100]]&/@{z1,z2})];*) +(*Vol1=Parallelepiped[{xcent-dxdet/2,ycent-dydet/2,(xlongmax-dxlong)+\[Xi]*dxlong},{{dxdet,0,0},{0,dydet,0},{0,0,(1-\[Xi])dxlong}}];*) +(*Vol2=(*z\[Theta]ConicalFrustum[zmaxdecvol+(xlongmax-zmaxdecvol)*\[Xi],xlongmax,theta[5.]]*)Cylinder[{{0.,0.,(xlongmax-dxlong)+\[Xi]*dxlong},{0.,0.,xlongmax}},0.09];*) +(*RegionDifference[Vol1,Vol2]*) +(*]*) + + +(* ::Subsubsection:: *) +(*Common*) + + +(* ::Input:: *) +(*NonStandardDetectorGeometry[experiment_,\[Xi]_]:=Association[{{"LHCb-downstream-full",\[Xi]}->LHCbfarDetectorVolumeTemp["LHCb-downstream",\[Xi]],{"LHCb-downstream-T-tracks-only",\[Xi]}->LHCbfarSciFiDetectorVolumeTemp["LHCb-downstream-T-tracks-only",\[Xi]],{"LHCb-downstream",\[Xi]}->LHCbfarSciFiDetectorVolumeTemp["LHCb-downstream",\[Xi]],{"LHCb-downstream-Lesya",\[Xi]}->LHCbfarSciFiDetectorVolumeTemp["LHCb-downstream-Lesya",\[Xi]]}][{experiment,\[Xi]}]*) + + +(* ::Subsection:: *) +(*Common definition*) + + +(* ::Input:: *) +(*(*Full geometry of the detector*)*) +(*DetectorGeometry[experiment_]:=If[StringContainsQ[experiment,"LHCb-downstream"],NonStandardDetectorGeometry[experiment,0],StandardDetectorGeometry[experiment,GeometryExperiment[experiment],0]]*) +(*EndDetectorSliceGeometry[experiment_]:=If[MemberQ[explistlhcb,experiment],NonStandardDetectorGeometry[experiment,Max[Min[0.99,1-0.2/dxLongDetectorExperiment[experiment]],0]],StandardDetectorGeometry[experiment,GeometryExperiment[experiment],Max[Min[0.99,1-0.2/dxLongDetectorExperiment[experiment]],0]]]*) +(*(*Graphics3D[EndDetectorSliceGeometry["HIKE"]]*)*) +(*(*\[Theta]minmaxBlock[experiment_,NN_]:=Block[{},*) +(*DecayVolume=DecayVolumeGeometry[experiment,GeometryExperiment[experiment],DetectorPlaneOrientationExperiment[experiment]];*) +(*DetVol=If[DecayVolumeAsDetectorExperiment[experiment]\[Equal]"False",DetectorGeometry[experiment,DetectorPlaneOrientationExperiment[experiment],GeometryExperiment[experiment]]];*) +(*pointsDecayVolume={ArcCos[#[[3]]/(\[Sqrt](#[[1]]^2+#[[2]]^2+#[[3]]^2))]}&/@Table[RandomPoint[DecayVolume],NN]//Flatten;*) +(*pointsDet=If[DecayVolumeAsDetectorExperiment[experiment]\[Equal]"False",{ArcCos[#[[3]]/(\[Sqrt](#[[1]]^2+#[[2]]^2+#[[3]]^2))]}&/@Table[RandomPoint[DetVol],NN]//Flatten];*) +(*\[Theta]min=If[DecayVolumeAsDetectorExperiment[experiment]\[Equal]"False",Max[Min[pointsDecayVolume],Min[pointsDet]],Min[pointsDecayVolume]];*) +(*\[Theta]max=If[DecayVolumeAsDetectorExperiment[experiment]\[Equal]"False",Min[Max[pointsDecayVolume],Max[pointsDet]],Max[pointsDecayVolume]];*) +(*{\[Theta]min,\[Theta]max}*) +(*]*) +(*\[Theta]minmaxBlock["SHADOWS-Gaia",10^5]*)*) + + +(* ::Subsection:: *) +(*Plane of the end of the detector*) + + +(* ::Input:: *) +(*PlaneEndOfDetectorExperimentAxisTransverse[experiment_]:=Module[{dx,dy,geom,xlong,xc,yc},*) +(*geom=GeometryExperiment[experiment];*) +(*dx=If[geom=="Box",dxDetectorExperiment[experiment,xLongMaxDetectorExperiment[experiment]],RouterDetectorExperiment[experiment,xLongMaxDetectorExperiment[experiment]]];*) +(*dy=If[geom=="Box",dyDetectorExperiment[experiment,xLongMaxDetectorExperiment[experiment]],RouterDetectorExperiment[experiment,xLongMaxDetectorExperiment[experiment]]];*) +(*xlong=xLongMaxDetectorExperiment[experiment];*) +(*xc=xToDetectorCenterExperiment[experiment];*) +(*yc=yToDetectorCenterExperiment[experiment];*) +(*Polygon[{{xc+(1/2)dx,yc-(1/2)dy,xlong},{xc+(1/2)dx,yc+(1/2)dy,xlong},{xc-(1/2)dx,yc+(1/2)dy,xlong},{xc-(1/2)dx,yc-(1/2)dy,xlong}}]*) +(*]*) +(*PlaneEndOfDetectorExperimentAxisParallel[experiment_]:=Module[{dx,dz,geom,xlong,xc,zc},*) +(*geom=GeometryExperiment[experiment];*) +(*dx=If[geom=="Box",dxDetectorExperiment[experiment,xLongMaxDetectorExperiment[experiment]],RouterDetectorExperiment[experiment,xLongMaxDetectorExperiment[experiment]]];*) +(*dz=If[geom=="Box",dzDetectorExperiment[experiment],RouterDetectorExperiment[experiment,xLongMaxDetectorExperiment[experiment]]];*) +(*xlong=xLongMaxDetectorExperiment[experiment];*) +(*xc=xToDetectorCenterExperiment[experiment];*) +(*zc=zToDetectorCenterExperiment[experiment];*) +(*Polygon[{{xc+(1/2)dx,xlong,zc-(1/2)dz},{xc+(1/2)dx,xlong,zc+(1/2)dz},{xc-(1/2)dx,xlong,zc+(1/2)dz},{xc-(1/2)dx,xlong,zc-(1/2)dz}}]*) +(*]*) +(*PlaneEndOfDetectorExperiment[experiment_]:=*) +(*If[DetectorPlaneOrientationExperiment[experiment]=="Parallel",PlaneEndOfDetectorExperimentAxisParallel[experiment],PlaneEndOfDetectorExperimentAxisTransverse[experiment]]*) +(*DetectorEndCrossSectionExperiment[experiment_]:=RegionIntersection[PlaneEndOfDetectorExperiment[experiment],DetectorGeometry[experiment]]*) + + +(* ::Subsection:: *) +(*Subscript[\[Theta], min/max] - minimal and maximal angles covered by the end of the detector. If the decay volume is fully off-axis, than the minimal angle is defined by the minimal angle covered by end of the decay volume*) + + +(* ::Input:: *) +(*cellmeasure["CHARM"]=.1;*) +(*cellmeasure["NA62-dump"]=cellmeasure["NA62-dump"]=.05;*) +(*Do[cellmeasure[exp]=.05,{exp,explistship}]*) +(*Do[cellmeasure[exp]=.01,{exp,explistlhcb}]*) +(*cellkeys=Keys[DownValues@cellmeasure][[All,1,1]]*) +(*\[Theta]funcval[x_,y_,z_]=ArcCos[z/Sqrt[x^2+y^2+z^2]];*) +(*\[Theta]minmaxBlock[experiment_]:=Module[{(*ifdecdet,DecayVolume,DetectorVolume,EndDetectorVolume,WhetherLiesOnAxis,MaxCellMeasureVal,DiscretizedDecayVolume,DecayVolumeCoordinates,NonTrivialDecayVolumeCond,Point\[Theta]minDecayVolume1,\[Theta]minDecayVolume1,\[Theta]minDecayVolume2,\[Theta]minIndexDecayVolume,Point\[Theta]minDecayVolume2,\[Theta]minDecayVolume,Point\[Theta]minDecayVolume,\[Theta]maxDecayVolume,\[Theta]maxIndexDecayVolume,\[Theta]minmaxCoordinatesDecVol,\[Theta]minmaxDecVol,output,DiscretizedDetectorVolume,DetectorCoordinates,seccoord,DetEndCoordinates,Point\[Theta]minDetEnd1,\[Theta]minDetEnd1,\[Theta]minDetEnd2,\[Theta]minIndexDetEnd,Point\[Theta]minDetEnd2,\[Theta]minDetEnd,Point\[Theta]minDetEnd,\[Theta]maxDetEnd,\[Theta]maxIndexDetEnd,\[Theta]minmaxCoordinatesDet,\[Theta]minmaxDet*)},*) +(*ifdecdet=!(DecayVolumeAsDetectorExperiment[experiment]//Symbol);*) +(*(*Geometry of the decay volume, detector, and the cross-section of the end of the detector*)*) +(*DecayVolume=DecayVolumeGeometry[experiment];*) +(*If[ifdecdet,*) +(*{DetectorVolume,EndDetectorVolume}={DetectorGeometry[experiment],EndDetectorSliceGeometry[experiment]};*) +(*(*Whether the decay volume lies on-beamline*)*) +(*WhetherLiesOnAxis=If[DetectorPlaneOrientationExperiment[experiment]=="Transverse",RegionMeasure[RegionIntersection[DetectorVolume,Point[{0,0,xLongMaxDetectorExperiment[experiment]}]]],RegionMeasure[RegionIntersection[DetectorVolume,Point[{0,xLongMaxDetectorExperiment[experiment],0}]]]],*) +(*WhetherLiesOnAxis=RegionMeasure[RegionIntersection[DecayVolume,Point[{0,0,zMaxDecayVolumeExperiment[experiment]}]]];*) +(*];*) +(*(*Resolution of discretization (lower value is better, but slower)*)*) +(*MaxCellMeasureVal=If[MemberQ[cellkeys,experiment],cellmeasure[experiment],Automatic];*) +(*(*Discretization of the decay volume*)*) +(*DiscretizedDecayVolume=If[MemberQ[explistship,experiment],DiscretizeRegion[MeshRegion[DecayVolume],MaxCellMeasure->"Volume"->MaxCellMeasureVal],BoundaryDiscretizeRegion[DecayVolume,MaxCellMeasure->MaxCellMeasureVal]];*) +(*DecayVolumeCoordinates=MeshCoordinates[DiscretizedDecayVolume];*) +(*(*Find the smallest polar angle covered by the decay volume, and the corresponding coordinates*)*) +(*NonTrivialDecayVolumeCond=StringContainsQ[experiment,{"SHiP","LHCb-muon-chamber"}];*) +(*{Point\[Theta]minDecayVolume1}=RegionNearest[#,{0,0,0}]&/@{If[!NonTrivialDecayVolumeCond,DecayVolume,DiscretizedDecayVolume]};*) +(*{\[Theta]minDecayVolume1,\[Theta]minDecayVolume2}={\[Theta]funcval@@Point\[Theta]minDecayVolume1,Min[\[Theta]funcval@@@DecayVolumeCoordinates]};*) +(*\[Theta]minIndexDecayVolume=Position[\[Theta]funcval@@@DecayVolumeCoordinates,Min[\[Theta]funcval@@@DecayVolumeCoordinates]][[1]][[1]];*) +(*Point\[Theta]minDecayVolume2=DecayVolumeCoordinates[[\[Theta]minIndexDecayVolume]];*) +(*\[Theta]minDecayVolume=Min[\[Theta]minDecayVolume1,\[Theta]minDecayVolume2];*) +(*Point\[Theta]minDecayVolume=If[\[Theta]minDecayVolume==\[Theta]minDecayVolume1,Point\[Theta]minDecayVolume1,Point\[Theta]minDecayVolume2];*) +(*(*Finding the maximal polar angle and the corresponding coordinate*)*) +(*\[Theta]maxDecayVolume=Max[\[Theta]funcval@@@DecayVolumeCoordinates];*) +(*\[Theta]maxIndexDecayVolume=Position[\[Theta]funcval@@@DecayVolumeCoordinates,Max[\[Theta]funcval@@@DecayVolumeCoordinates]][[1]][[1]];*) +(*\[Theta]minmaxCoordinatesDecVol={Point\[Theta]minDecayVolume,DecayVolumeCoordinates[[\[Theta]maxIndexDecayVolume]]};*) +(*\[Theta]minmaxDecVol=If[WhetherLiesOnAxis==1,{0,\[Theta]maxDecayVolume},{\[Theta]minDecayVolume,\[Theta]maxDecayVolume}];*) +(*output={{\[Theta]minmaxCoordinatesDecVol,\[Theta]minmaxDecVol}};*) +(*If[ifdecdet,*) +(*(*Discretization of the detector*)*) +(*DiscretizedDetectorVolume=If[ifdecdet,BoundaryDiscretizeRegion[DetectorVolume,MaxCellMeasure->MaxCellMeasureVal]];*) +(*DetectorCoordinates=If[ifdecdet,MeshCoordinates[DiscretizedDetectorVolume]];*) +(*seccoord=If[DetectorPlaneOrientationExperiment[experiment]=="Transverse",3,2];*) +(*DetEndCoordinates=Select[DetectorCoordinates,#[[seccoord]]==Max[DetectorCoordinates[[All,seccoord]]]&];*) +(*(*DetEndCoordinates=If[ifdecdet,If[DetectorPlaneOrientationExperiment[experiment]\[Equal]"Transverse",Select[DetectorCoordinates,#[[3]]>0.995xLongMaxDetectorExperiment[experiment]&],Select[DetectorCoordinates,#[[2]]>0.995xLongMaxDetectorExperiment[experiment]&]]];*)*) +(*(*Find the smallest polar angle covered by the end of the detector, and the corresponding coordinates*)*) +(*EndDetectorVolume=If[StringContainsQ[experiment,"LHCb-downstream"],Rationalize[EndDetectorVolume],EndDetectorVolume];*) +(*{Point\[Theta]minDetEnd1}=RegionNearest[#,{0,0,0}]&/@{EndDetectorVolume}//N;*) +(*{\[Theta]minDetEnd1,\[Theta]minDetEnd2}={\[Theta]funcval@@Point\[Theta]minDetEnd1,Min[\[Theta]funcval@@@DetEndCoordinates]};*) +(*\[Theta]minIndexDetEnd=Position[\[Theta]funcval@@@DetEndCoordinates,\[Theta]minDetEnd2][[1]][[1]];*) +(*Point\[Theta]minDetEnd2=If[ifdecdet,DetEndCoordinates[[\[Theta]minIndexDetEnd]]];*) +(*\[Theta]minDetEnd=Min[\[Theta]minDetEnd1,\[Theta]minDetEnd2];*) +(*Point\[Theta]minDetEnd=If[\[Theta]minDetEnd==\[Theta]minDetEnd1,Point\[Theta]minDetEnd1,Point\[Theta]minDetEnd2];*) +(*(*Find the largest polar angle covered by the decay volume and the end of the detector, and the corresponding coordinates*)*) +(*\[Theta]maxDetEnd=Max[\[Theta]funcval@@@DetEndCoordinates];*) +(*\[Theta]maxIndexDetEnd=Position[\[Theta]funcval@@@DetEndCoordinates,Max[\[Theta]funcval@@@DetEndCoordinates]][[1]][[1]];*) +(*\[Theta]minmaxCoordinatesDet={Point\[Theta]minDetEnd,DetEndCoordinates[[\[Theta]maxIndexDetEnd]]};*) +(*\[Theta]minmaxDet=If[WhetherLiesOnAxis==1,{0,\[Theta]maxDetEnd},{\[Theta]minDetEnd,\[Theta]maxDetEnd}];*) +(*output={{\[Theta]minmaxCoordinatesDecVol,\[Theta]minmaxDecVol},{\[Theta]minmaxCoordinatesDet,\[Theta]minmaxDet}};*) +(*];*) +(**) +(*output*) +(*]*) +(*(*For test*)*) +(*(*blockexp[experiment_]:=Block[{},*) +(*data=\[Theta]minmaxBlock[experiment];*) +(*Join[{experiment},data]*) +(*]*) +(*experimentlist=Keys[DownValues[FacilityExperiment]][[All,1,1]](*Keys[DetectorPlaneOrientation]//Sort*);*) +(*tabb=Table[blockexp[experiment],{experiment,Take[experimentlist,{36,42}]}];*) +(*tabb//TableForm*)*) + + +(* ::Subsubsection:: *) +(*Polar angle grid*) + + +(* ::Input:: *) +(*\[Theta]grid[DecayVolumeAsDet_,\[Theta]decVolmin_,\[Theta]decVolmax_,\[Theta]detmin_,\[Theta]detmax_]:=Module[{\[Theta]detMinEff,\[Theta]detMaxEff,\[Theta]gridDetEnd},*) +(*(*Min/max angles covered by detector and belonging simultaneously to the decay volume acceptance*)*) +(*\[Theta]detMinEff=Max[\[Theta]detmin,\[Theta]decVolmin];*) +(*\[Theta]detMaxEff=Min[\[Theta]detmax,\[Theta]decVolmax];*) +(*(*Grid of polar angles for the end of the detector*)*) +(*\[Theta]gridDetEnd=If[DecayVolumeAsDet=="False",Table[x,{x,1.001\[Theta]detMinEff+10^-5.,0.99\[Theta]detMaxEff,(0.99\[Theta]detMaxEff-(1.001\[Theta]detMinEff+10^-5.))/16}]];*) +(*\[Theta]gridDecVolIfDet=If[DecayVolumeAsDet=="False",Table[x,{x,1.001\[Theta]decVolmin+10^-5.,0.999\[Theta]decVolmax,(0.999\[Theta]decVolmax-(1.001\[Theta]detMinEff+10^-5.))/13}]];*) +(*\[Theta]gridDecVolIfNoDet=If[DecayVolumeAsDet=="True",Table[x,{x,1.001\[Theta]decVolmin+10^-5.,0.999\[Theta]decVolmax,(0.999\[Theta]decVolmax-1.001\[Theta]detMinEff+10^-5.)/22}]];*) +(*(*Total grid for experiments where decay volume is not detector. Merging the grid for detector and decay volume, selecting for the latter only the angles outside the detector coverage*)*) +(*\[Theta]gridTotIfDet=If[DecayVolumeAsDet=="False",Sort[Join[\[Theta]gridDetEnd,Select[\[Theta]gridDecVolIfDet,!(\[Theta]detMinEff<=#<=\[Theta]detMaxEff)&]]]];*) +(*If[DecayVolumeAsDet=="False",\[Theta]gridTotIfDet,\[Theta]gridDecVolIfNoDet]*) +(*]*) + + +(* ::Section:: *) +(*Defining the list of experiments*) + + +(* ::Input:: *) +(*experimentlist=Select[Keys[DownValues[FacilityExperiment]][[All,1,1]],!StringContainsQ[#,{"Gaia","Lesya","farOld","LoI-up"}]&];*) + + +(* ::Section:: *) +(*Close sections*) + + +(* ::Input:: *) +(*(*FrontEndTokenExecute["SelectAll"];*) +(*FrontEndTokenExecute["SelectionCloseAllGroups"];*)*) diff --git a/prepare_wls_files.sh b/prepare_wls_files.sh new file mode 100755 index 0000000..4c0b33b --- /dev/null +++ b/prepare_wls_files.sh @@ -0,0 +1,8 @@ +#!/bin/bash + +# Find all .wls files recursively +find . -type f -name "*.wls" | while read -r file; do + # Use the macOS compatible sed command with an empty string for backup + sed -i '' 's/(\* ::Chapter:: \*)/(\* ::Chapter::Closed:: \*)/g' "$file" + sed -i '' 's/(\* ::Title:: \*)/(\* ::Title::Closed:: \*)/g' "$file" +done diff --git a/wls/1. Acceptances.wls b/wls/1. Acceptances.wls new file mode 100755 index 0000000..0d36f0a --- /dev/null +++ b/wls/1. Acceptances.wls @@ -0,0 +1,1017 @@ +#!/usr/bin/env wolframscript +(* ::Package:: *) + +(* ::Title::Closed:: *) +(*Just launch the code below to run the notebook (shift+enter)*) + + +(* ::Input:: *) +(*ClearAll["Global`*"]*) +(*nb=EvaluationNotebook[];*) +(*NotebookFind[nb,"Evaluation",All,CellTags];*) +(*SelectionEvaluate[nb]*) + + +(* ::Title::Closed:: *) +(*Definitions*) + + +(* ::Chapter::Closed:: *) +(*Critical definitions required to launch this notebook*) + + +(* ::Input:: *) +(*SetAttributes[ruleDown,HoldAll];*) +(*ruleDown[list_]:=Flatten[DownValues/@(Unevaluated@list)]*) +(*SetAttributes[ruleOwn,HoldAll];*) +(*ruleOwn[list_]:=Flatten[OwnValues/@(Unevaluated@list)]*) +(*dropdownDialog[list_,phrase_]:=DialogInput[{choice=""},Column[{TextCell[phrase],PopupMenu[Dynamic[choice],list],Button["OK",DialogReturn[choice]]}]]*) +(*choicesDialog[LLP_,spec_List]:=DialogInput[{choice=spec[[All,2,1]]},Column[Flatten@{{LLP},Table[With[{i=i},Column[{TextCell[spec[[i,1]]],PopupMenu[Dynamic[choice[[i]]],spec[[i,-1]]]}]],{i,Length@spec}],Button["OK",DialogReturn[choice]]}]]*) +(*selectionDialog[list_,phrase_]:=DialogInput[{choice={}},Column[{Row[{phrase}],Pane[TogglerBar[Dynamic[choice],list,Appearance->"Vertical"->{Automatic,5}],ImageSize->{Automatic,Automatic},Scrollbars->{False,True}],Button["OK",DialogReturn[choice]]}]]*) +(*infoDialog[phrase_]:=DialogInput[{choice=""},Column[{TextCell[phrase],Button["Proceed",DialogReturn[choice]]}]]*) +(*SetOptions[$FrontEnd,"DynamicEvaluationTimeout"->300]*) +(*SetSystemOptions["SimplificationOptions"->"AutosimplifyTrigs"->False]*) +(*<If[choice===opt,LightBlue,None],ImageSize->{maxWidth,Automatic} (*Set width to maxWidth*)]],{i,rows},{j,cols}],Spacings->{2,2}],{Automatic,paneHeight},Scrollbars->{False,True}],Button["OK",DialogReturn[choice],ImageSize->Automatic]}]]]*) +(*If[MemberQ[explistanub,GivenExperiment]==True,*) +(*infoDialog["One of the decay volumes of ANUBIS-shaft has been selected. The full sensitivity requires calculating the acceptances for all the three volumes. You need to generate them afterwards"]]*)*) +(*Print["Selected experiments:"]*) +(*SelectedExperimentList=If[Length[experimentlist]!=0,selectionDialog[experimentlist,"Select the experiments:"]]*) +(*icounter=1;*) +(*Do[*) +(*experimentBoundaries[exp]=\[Theta]minmaxBlock[exp]*) +(*,{exp,SelectedExperimentList}]*) + + +(* ::Chapter::Closed:: *) +(*Importing LLP decay data*) + + +(* ::Input:: *) +(*Block[{Print=Identity},Quiet[NotebookEvaluate[FileNameJoin[{NotebookDirectory[],"codes/llp-decays.nb"}]]]]*) +(*Print["List of implemented LLPs:"]*) +(*LLPlist*) + + +(* ::Chapter::Closed:: *) +(*Launching iterations over selected experiments*) + + +(* ::Input:: *) +(*BlockEvaluation[tag_]:=Block[{},*) +(*nb=EvaluationNotebook[];*) +(*NotebookFind[nb,tag,All,CellTags];*) +(*SelectionEvaluate[nb]*) +(*];*) +(*Do[*) +(*BlockEvaluation["Acceptance-computation"];*) +(*,{icounter,1,Length[SelectedExperimentList],1}]*) + + +(* ::Title::Closed:: *) +(*Given experiment (do not launch it manually)*) + + +(* ::Chapter::Closed:: *) +(*Setting geometry and cuts parameters*) + + +(* ::Input:: *) +(*GivenExperiment=SelectedExperimentList[[icounter++]]*) +(*FacilityGivenExperiment=FacilityExperiment[GivenExperiment];*) +(*EmaxGivenExperiment=EmaxFacility[FacilityGivenExperiment];*) +(*ECALoptionGivenExperiment=ECALoptionExperiment[GivenExperiment];*) +(*DipoleMagnetOptionGivenExperiment=DipoleMagnetOptionExperiment[GivenExperiment];*) +(*(*Decay volume as detector: True, False*)*) +(*DecayVolumeAsDetectorGivenExperiment=DecayVolumeAsDetectorExperiment[GivenExperiment];*) +(*(*Default list of detectable decay products at the given experiment*)*) +(*DetectablePDGsGivenExperiment=DetectablePDGsExperiment[GivenExperiment]//Sort;*) +(*(*___________________________________________________________*)*) +(*(*Box, Cylinder, Annular cylinder*)*) +(*GeometryGivenExperiment=GeometryExperiment[GivenExperiment];*) +(*(*Beam, Transverse*)*) +(*DetectorPlaneOrientationGivenExperiment=DetectorPlaneOrientationExperiment[GivenExperiment];*) +(*(*Decay volume parameters*)*) +(*xToDecayVolumeCenterGivenExperiment[z_]=xToDecayVolumeCenterExperiment[z,GivenExperiment];*) +(*yToDecayVolumeCenterGivenExperiment[z_]=yToDecayVolumeCenterExperiment[z,GivenExperiment];*) +(*dxDecayVolumeGivenExperiment[z_]=dxDecayVolumeExperiment[z,GivenExperiment];*) +(*dyDecayVolumeGivenExperiment[z_]=dyDecayVolumeExperiment[z,GivenExperiment];*) +(*zToDecayVolumeGivenExperiment=zToDecayVolumeExperiment[GivenExperiment];*) +(*dzFidGivenExperiment=dzDecayVolumeExperiment[GivenExperiment];*) +(*zMaxDecayVolumeGivenExperiment=zMaxDecayVolumeExperiment[GivenExperiment];*) +(*xLongMaxDetectorGivenExperiment=xLongMaxDetectorExperiment[GivenExperiment];*) +(*dxDecayVolumeGivenExperimentMax=dxDecayVolumeGivenExperiment[zMaxDecayVolumeGivenExperiment];*) +(*dyDecayVolumeGivenExperimentMax=dyDecayVolumeGivenExperiment[zMaxDecayVolumeGivenExperiment];*) +(*RinnerDecayVolumeGivenExperiment[z_]=RinnerDecayVolumeExperiment[GivenExperiment,z];*) +(*RouterDecayVolumeGivenExperiment[z_]=RouterDecayVolumeExperiment[GivenExperiment,z];*) +(*DecayVolumeGeometryGivenExperiment=DecayVolumeGeometry[GivenExperiment];*) +(*(*Detector parameters*)*) +(*dxDetectorGivenExperiment[z_]=dxDetectorExperiment[GivenExperiment,z];*) +(*dyDetectorGivenExperiment[z_]=dyDetectorExperiment[GivenExperiment,z];*) +(*dzDetectorGivenExperiment=dzDetectorExperiment[GivenExperiment];*) +(*dx2PerpDetectorGivenExperiment[z_]=If[DetectorPlaneOrientationGivenExperiment=="Transverse",dyDetectorGivenExperiment[z],dzDetectorGivenExperiment];*) +(*{xToDetectorCenterGivenExperiment,yToDetectorCenterGivenExperiment,zToDetectorCenterGivenExperiment}=(Symbol[#<>"ToDetectorCenterExperiment"][GivenExperiment]//N)&/@{"x","y","z"};*) +(*x2PerpToDetectorCenterGivenExperiment=If[DetectorPlaneOrientationGivenExperiment=="Transverse",yToDetectorCenterGivenExperiment,zToDetectorCenterGivenExperiment];*) +(*{RinnerDetectorGivenExperiment[z_],RouterDetectorGivenExperiment[z_]}={RinnerDetectorExperiment[GivenExperiment,z],RouterDetectorExperiment[GivenExperiment,z]};*) +(*(*____________________________________________________*)*) +(*(*Given experiment boundaries*)*) +(*(*____________________________________________________*)*) +(*GivenExperimentBoundaries=experimentBoundaries[GivenExperiment];*) +(*(*Min/max polar angles of the decay volume and detector, and the corresponding points*)*) +(*{ThetaDecVolGivenExperimentMin,ThetaDecVolGivenExperimentMax}={GivenExperimentBoundaries[[1]][[2]][[1]],GivenExperimentBoundaries[[1]][[2]][[2]]}//N;*) +(*{R\[Theta]minDecayVolume,R\[Theta]maxDecayVolume}={GivenExperimentBoundaries[[1]][[1]][[1]],GivenExperimentBoundaries[[1]][[1]][[2]]};*) +(*If[DecayVolumeAsDetectorGivenExperiment=="False",*) +(*{ThetaDetGivenExperimentMin,ThetaDetGivenExperimentMax}={GivenExperimentBoundaries[[2]][[2]][[1]],GivenExperimentBoundaries[[2]][[2]][[2]]}//N;*) +(*{R\[Theta]minEndDetector,R\[Theta]maxEndDetector}={GivenExperimentBoundaries[[2]][[1]][[1]],GivenExperimentBoundaries[[2]][[1]][[2]]}//N;*) +(*DetectorGeometryGivenExperiment=DetectorGeometry[GivenExperiment],*) +(*{ThetaDetGivenExperimentMin,ThetaDetGivenExperimentMax}={ThetaDecVolGivenExperimentMin,ThetaDecVolGivenExperimentMax}*) +(*];*) +(*FinalPlaneGivenExperiment=PlaneEndOfDetectorExperiment[GivenExperiment];*) +(*(*Parameters of the dipole magnet in the spectrometer (if present)*)*) +(*zMagnetMinGivenExperiment=zMagnetMinExperiment[GivenExperiment];*) +(*zMagnetMaxGivenExperiment=zMagnetMaxExperiment[GivenExperiment];*) +(*Bval=If[DipoleMagnetOptionGivenExperiment=="False",0,MagneticFieldExperiment[GivenExperiment]];*) +(*(*ECAL position*)*) +(*ECALpositionGivenExperiment=zECALminExperiment[GivenExperiment];*) +(*(*FinalPlaneGivenExperiment=If[finalPlaneGivenExperiment\[Equal]"EndOfDetector",EndOfDetectorGivenExperiment,PlaneDetectorGivenExperiment];*)*) +(*TableParticlesNumbersGivenExperiment=TableNumbersParticlesExperiment[GivenExperiment];*) +(*xLongMuonPlaneGivenExperiment=xLongMuonPlaneExperiment[GivenExperiment];*) +(*xLongNonMuonPlaneGivenExperiment=xLongNonMuonPlaneExperiment[GivenExperiment];*) +(*(*Geometric conditions*)*) +(*IfLLPinsideDecVol[zLLP_,xLLP_,yLLP_]=IfLLPinsideDecVol[zLLP,xLLP,yLLP,GivenExperiment];*) +(*{IfLLPtoDet[x1LLPproj_,x2LLPproj_,xLongProj_],IfLLPnotToDet[x1LLPproj_,x2LLPproj_,xLongProj_]}={IfLLPtoDet[x1LLPproj,x2LLPproj,xLongProj,GivenExperiment],IfLLPnotToDet[x1LLPproj,x2LLPproj,xLongProj,GivenExperiment]};*) +(*IfLLPdecVolToDet[zLLP_,xLLP_,yLLP_,x1LLPproj_,x2LLPproj_,xLongProj_]=IfLLPdecVolToDet[zLLP,xLLP,yLLP,x1LLPproj,x2LLPproj,xLongProj,GivenExperiment];*) +(*IfLLPdecVolNotToDet[zLLP_,xLLP_,yLLP_,x1LLPproj_,x2LLPproj_,xLongProj_]=IfLLPdecVolNotToDet[zLLP,xLLP,yLLP,x1LLPproj,x2LLPproj,xLongProj,GivenExperiment];*) +(*DecayAcceptanceGeometry[x1LLPproj_,x2LLPproj_,xLongProj_]=IfLLPtoDet[x1LLPproj,x2LLPproj,xLongProj];*) + + +(* ::Chapter::Closed:: *) +(*Specifying cuts on the decay products*) + + +(* ::Input:: *) +(*dropdownDialog[list_,phrase_]:=DialogInput[{choice=""},Column[{TextCell[phrase],PopupMenu[Dynamic[choice],list],Button["OK",DialogReturn[choice]]}]]*) +(*(*filenameGivenExperiment=filenameExperiment[finalPlaneGivenExperiment,GivenExperiment];*) +(*filenameGivenExperimentzN=filenameExperimentzN[finalPlaneGivenExperiment,GivenExperiment]*)*) +(*{{"Experiment","Facility","Decay volume as detector","If ECAL is present","If dipole magnet is present","\!\(\*SubscriptBox[\(E\), \(LLP, max\)]\)"},{GivenExperiment,FacilityGivenExperiment,DecayVolumeAsDetectorGivenExperiment,ECALoptionGivenExperiment,DipoleMagnetOptionGivenExperiment,EmaxGivenExperiment}}//TableForm*) +(*(*WhetherCutsTemp=dropdownDialog[{"Yes","No"},"Would you like to impose any cuts on acceptance of decay products other than geometric?"];*) +(*WhetherCuts=If[WhetherCutsTemp\[Equal]"Yes",1,0];*)*) +(*(*____________________________________________________*)*) +(*(*Imposing cuts on decay products*)*) +(*(*____________________________________________________*)*) +(*pTcutLowerZero=0.;*) +(*pTcutUpperZero=10^10.;*) +(*eCutLowerZero=0.;*) +(*eCutUpperZero=10^10.;*) +(*IPcutZero=10^10.;*) +(*AngSepCutZero=0.;*) +(*SScutZero=0.;*) +(*minvCutLowerZero=0.;*) +(*minvCutUpperZero=10^10.;*) +(*eTotCutLowerZero=0.;*) +(*eTotCutUpperZero=10^10.;*) +(*{pTelCutLower,pTelCutUpper,pT\[Mu]CutLower,pT\[Mu]CutUpper,pThadrCutLower,pThadrCutUpper,eElCutLower,eElCutUpper,e\[Mu]CutLower,e\[Mu]CutUpper,eHadrCutLower,eHadrCutUpper,EtotElCutLower,EtotElCutUpper,Etot\[Mu]CutLower,Etot\[Mu]CutUpper,EtotHadrCutLower,EtotHadrCutUpper,EtotMixedCutLower,EtotMixedCutUpper,e\[Gamma]CutLower,e\[Gamma]CutUpper,eh0CutLower,eh0CutUpper,Etot\[Gamma]\[Gamma]CutLower,Etot\[Gamma]\[Gamma]CutUpper,Etoth0h0CutLower,Etoth0h0CutUpper,EtotMixedNeutralCutLower,EtotMixedNeutralCutUpper,IPcut,AngSepCut,AngSepCutCharged,SScutCharged,SScutNeutral,minvElCutLower,minvElCutUpper,minv\[Mu]CutLower,minv\[Mu]CutUpper,minvHadrCutLower,minvHadrCutUpper,minvMixedCutLower,minvMixedCutUpper,minv\[Gamma]\[Gamma]CutLower,minv\[Gamma]\[Gamma]CutUpper,minvh0h0CutLower,minvh0h0CutUpper,minvMixedNeutralCutLower,minvMixedNeutralCutUpper}//Clear;*) +(*choice={"All"};*) +(*DynamicModule[{inputValues,labels,symbols,inputFields,submitButton},*) +(*labels={"Min/max \!\(\*SubscriptBox[\(p\), \(T\)]\) range of each charged decay product, in the form {\!\(\*SubscriptBox[\(p\), \(T, min\)]\), \!\(\*SubscriptBox[\(p\), \(T, max\)]\)}, for \!\(\*SuperscriptBox[\(e\), \(+\(\(/\)\(-\)\)\)]\), (1st bracket), \!\(\*SuperscriptBox[\(\[Mu]\), \(+\(\(/\)\(-\)\)\)]\) (2nd), hadrons \!\(\*SuperscriptBox[\(h\), \(+\(\(/\)\(-\)\)\)]\) (3rd)","Min/max energy of each charged decay product, in the form {\!\(\*SubscriptBox[\(E\), \(min\)]\), \!\(\*SubscriptBox[\(E\), \(max\)]\)}, for \!\(\*SuperscriptBox[\(e\), \(+\(\(/\)\(-\)\)\)]\) (1st bracket), \!\(\*SuperscriptBox[\(\[Mu]\), \(+\(\(/\)\(-\)\)\)]\) (2nd), \!\(\*SuperscriptBox[\(h\), \(+\(\(/\)\(-\)\)\)]\) (3rd)","Min/max total energy of two charged products, in the form {\!\(\*SubscriptBox[\(E\), \(min\)]\), \!\(\*SubscriptBox[\(E\), \(max\)]\)}, for \!\(\*SuperscriptBox[\(e\), \(+\)]\)\!\(\*SuperscriptBox[\(e\), \(-\)]\) (1st bracket), \!\(\*SuperscriptBox[\(\[Mu]\), \(+\)]\)\!\(\*SuperscriptBox[\(\[Mu]\), \(-\)]\) (2nd), \!\(\*SuperscriptBox[\(h\), \(+\)]\)\!\(\*SuperscriptBox[\(h\), \(-\)]\) (3rd), and mixed (4th)","Min/max energy of each neutral product, in the form {\!\(\*SubscriptBox[\(E\), \(min\)]\), \!\(\*SubscriptBox[\(E\), \(max\)]\)}, for \[Gamma] (1st bracket) and neutral hadrons \!\(\*SuperscriptBox[\(h\), \(0\)]\) (2nd)","Min/max total energy of a neutral pair, in the form {\!\(\*SubscriptBox[\(E\), \(min\)]\), \!\(\*SubscriptBox[\(E\), \(max\)]\)}, for \[Gamma]\[Gamma] (1st), \!\(\*SuperscriptBox[\(h\), \(0\)]\)\!\(\*SuperscriptBox[\(h\), \(0\)]\) (2nd), mixed (3rd)","Transerse impact parameter cut from above for charged tracks (in m)","Angular cut from below for photons/charged particles at the beginning of the calorimeter (in radians)",*) +(*"Transverse spatial separation cut from below at the beginning of the calorimeter (in m), {\!\(\*SubscriptBox[\(SS\), \(min, charged\)]\),\!\(\*SubscriptBox[\(SS\), \(min, photons\)]\)}","Invariant mass cut for the two charged products, in the form {\!\(\*SubscriptBox[\(m\), \(inv, lower\)]\), \!\(\*SubscriptBox[\(m\), \(inv, upper\)]\)}, for \!\(\*SuperscriptBox[\(e\), \(+\)]\)\!\(\*SuperscriptBox[\(e\), \(-\)]\) (1st), \!\(\*SuperscriptBox[\(\[Mu]\), \(+\)]\)\!\(\*SuperscriptBox[\(\[Mu]\), \(-\)]\) (2nd), \!\(\*SuperscriptBox[\(h\), \(+\)]\)\!\(\*SuperscriptBox[\(h\), \(-\)]\) (3rd), mixed (4th)","Invariant mass cut for the two neutral products, in the form {\!\(\*SubscriptBox[\(m\), \(inv, lower\)]\), \!\(\*SubscriptBox[\(m\), \(inv, upper\)]\)}, in the form {\!\(\*SubscriptBox[\(m\), \(inv, lower\)]\), \!\(\*SubscriptBox[\(m\), \(inv, upper\)]\)}, for \[Gamma]\[Gamma] (1st), \!\(\*SuperscriptBox[\(h\), \(0\)]\)\!\(\*SuperscriptBox[\(h\), \(0\)]\) (2nd), mixed (3rd)"};*) +(*inputValues=zeros={{{-999,-999},{-999,-999},{-999,-999}},{{-999,-999},{-999,-999},{-999,-999}},{{-999,-999},{-999,-999},{-999,-999},{-999,-999}},{{-999,-999},{-999,-999}},{{-999,-999},{-999,-999},{-999,-999}},-999,{-999,-999},{-999,-999},{{-999,-999},{-999,-999},{-999,-999},{-999,-999}},{{-999,-999},{-999,-999},{-999,-999}}}; *) +(*symbols={{{pTelCutLower,pTelCutUpper},{pT\[Mu]CutLower,pT\[Mu]CutUpper},{pThadrCutLower,pThadrCutUpper}},{{eElCutLower,eElCutUpper},{e\[Mu]CutLower,e\[Mu]CutUpper},{eHadrCutLower,eHadrCutUpper}},{{EtotElCutLower,EtotElCutUpper},{Etot\[Mu]CutLower,Etot\[Mu]CutUpper},{EtotHadrCutLower,EtotHadrCutUpper},{EtotMixedCutLower,EtotMixedCutUpper}},{{e\[Gamma]CutLower,e\[Gamma]CutUpper},{eh0CutLower,eh0CutUpper}},{{Etot\[Gamma]\[Gamma]CutLower,Etot\[Gamma]\[Gamma]CutUpper},{Etoth0h0CutLower,Etoth0h0CutUpper},{EtotMixedNeutralCutLower,EtotMixedNeutralCutUpper}},IPcut,{AngSepCut,AngSepCutCharged},{SScutCharged,SScutNeutral},{{minvElCutLower,minvElCutUpper},{minv\[Mu]CutLower,minv\[Mu]CutUpper},{minvHadrCutLower,minvHadrCutUpper},{minvMixedCutLower,minvMixedCutUpper}},{{minv\[Gamma]\[Gamma]CutLower,minv\[Gamma]\[Gamma]CutUpper},{minvh0h0CutLower,minvh0h0CutUpper},{minvMixedNeutralCutLower,minvMixedNeutralCutUpper}}};*) +(*zerosvalues={{{pTcutLowerZero,pTcutUpperZero},{pTcutLowerZero,pTcutUpperZero},{pTcutLowerZero,pTcutUpperZero}},{{eCutLowerZero,eCutUpperZero},{eCutLowerZero,eCutUpperZero},{eCutLowerZero,eCutUpperZero}},{{eCutLowerZero,eCutUpperZero},{eCutLowerZero,eCutUpperZero},{eCutLowerZero,eCutUpperZero},{eCutLowerZero,eCutUpperZero}},{{eCutLowerZero,eCutUpperZero},{eCutLowerZero,eCutUpperZero}},{{eCutLowerZero,eCutUpperZero},{eCutLowerZero,eCutUpperZero},{eCutLowerZero,eCutUpperZero}},IPcutZero,{AngSepCutZero,AngSepCutZero},{SScutZero,SScutZero},{{minvCutLowerZero,minvCutUpperZero},{minvCutLowerZero,minvCutUpperZero},{minvCutLowerZero,minvCutUpperZero},{minvCutLowerZero,minvCutUpperZero}},{{minvCutLowerZero,minvCutUpperZero},{minvCutLowerZero,minvCutUpperZero},{minvCutLowerZero,minvCutUpperZero}}};*) +(*If[Length[inputValues]!=Length[labels]!=Length[symbols],MessageDialog["Error: The number of initial values does not match the number of labels."];*) +(*Abort[]];*) +(*productionSelector=Column[{Style["Select the particles that are detectable at " <>GivenExperiment<>":",Bold],TogglerBar[Dynamic[choice],Join[{"All"},ParamPDGidToProduct[#]&/@(Abs[DetectablePDGsGivenExperiment]//DeleteDuplicates)],Appearance->"Horizontal"->{5,20}]}];*) +(*inputFields=Table[With[{i=i},Column[{labels[[i]]<>":",InputField[Dynamic[inputValues[[i]]],Expression,FieldSize->{40,Automatic}]}]],{i,Length[labels]}];*) +(*introphr={Style["Impose the cuts on decay products. If the given cut should not be imposed enter -999 for each value (default choice). All the energy/\!\(\*SubscriptBox[\(p\), \(T\)]\) cuts are in GeV",Bold]};*) +(*submitButton=Button["Submit",Evaluate[Sequence@@Flatten[MapThread[Set,{Flatten[symbols],MapThread[If[#1===#2,#3,#1]&,{Flatten[inputValues],Flatten[zeros],Flatten[zerosvalues]}]}]]]; DialogReturn[Null],ImageSize->Automatic];*) +(*(*submitButton=Button["Submit",Evaluate[Sequence@@Flatten[MapThread[Set,{Flatten[symbols,1],Flatten[inputValues,1]}]]]; DialogReturn[Null],ImageSize->Automatic];*)*) +(*DialogInput[Column[Flatten[{productionSelector,introphr," ",inputFields,submitButton}]]]*) +(*];*) +(*If[choice=={}||MemberQ[choice,"All"],choice={"All"}];*) +(*If[choice!={"All"},*) +(*DetectablePDGsGivenExperimentTemp=Join[ParamProductToPDGid[#]&/@choice,-ParamProductToPDGid[#]&/@choice];*) +(*DetectablePDGsGivenExperiment=Select[DetectablePDGsGivenExperimentTemp,FreeQ[ParamPDGidToProduct[#],Missing]&]//N//Sort;*) +(*];*) +(*Print["List of PDGs of detectable particles:"]*) +(*DetectablePDGsGivenExperiment*) + + +(* ::Section::Closed:: *) +(*Displaying cuts*) + + +(* ::Subsection::Closed:: *) +(*Creating functions with cuts*) + + +(* ::Input:: *) +(*createCompiledFunctionpT[zeroValue_,elcut_,\[Mu]cut_,hadrcut_]:=Hold@Compile[{{id,_Real},{charge,_Real}},Module[{cut,absid},*) +(*cut=zeroValue;*) +(*absid=Abs[id];*) +(*If[charge!=0.,*) +(*cut=If[absid==11.,elcut,If[absid==13.,\[Mu]cut,hadrcut]];*) +(*];*) +(*cut*) +(*],CompilationTarget->"C",RuntimeOptions->"Speed",RuntimeAttributes->{Listable},Parallelization->True]//ReleaseHold*) +(*pTcutLowerID=createCompiledFunctionpT[pTcutLowerZero,pTelCutLower,pT\[Mu]CutLower,pThadrCutLower];//AbsoluteTiming*) +(*pTcutUpperID=createCompiledFunctionpT[pTcutUpperZero,pTelCutUpper,pT\[Mu]CutUpper,pThadrCutUpper];//AbsoluteTiming*) +(*<"C",RuntimeOptions->"Speed",RuntimeAttributes->{Listable},Parallelization->True]//ReleaseHold*) +(*ecutLowerID=createCompiledFunctionE[eCutLowerZero,e\[Gamma]CutLower,eh0CutLower,eElCutLower,e\[Mu]CutLower,eHadrCutLower];//AbsoluteTiming*) +(*ecutUpperID=createCompiledFunctionE[eCutUpperZero,e\[Gamma]CutUpper,eh0CutUpper,eElCutUpper,e\[Mu]CutUpper,eHadrCutUpper];//AbsoluteTiming*) +(*<"C",RuntimeOptions->"Speed",RuntimeAttributes->{Listable},Parallelization->True](*/. ruleOwn[{zeroValue,h0h0Cut,gammaGammaCut,mixedNeutralCut,hadrCut,muCut,elCut,mixedCut}]*)//ReleaseHold;*) +(*EtotCutLowerID=createCompiledFunction[eTotCutLowerZero,Etoth0h0CutLower,Etot\[Gamma]\[Gamma]CutLower,EtotMixedNeutralCutLower,EtotHadrCutLower,Etot\[Mu]CutLower,EtotElCutLower,EtotMixedCutLower];//AbsoluteTiming*) +(*EtotCutUpperID=createCompiledFunction[eTotCutUpperZero,Etoth0h0CutUpper,Etot\[Gamma]\[Gamma]CutUpper,EtotMixedNeutralCutUpper,EtotHadrCutUpper,Etot\[Mu]CutUpper,EtotElCutUpper,EtotMixedCutUpper];//AbsoluteTiming*) +(*minvCutLowerID=createCompiledFunction[minvCutLowerZero,minvh0h0CutLower,minv\[Gamma]\[Gamma]CutLower,minvMixedNeutralCutLower,minvHadrCutLower,minv\[Mu]CutLower,minvElCutLower,minvMixedCutLower];//AbsoluteTiming*) +(*minvCutUpperID=createCompiledFunction[minvCutUpperZero,minvh0h0CutUpper,minv\[Gamma]\[Gamma]CutUpper,minvMixedNeutralCutUpper,minvHadrCutUpper,minv\[Mu]CutUpper,minvElCutUpper,minvMixedCutUpper];//AbsoluteTiming*) +(*<"C",RuntimeOptions->"Speed",RuntimeAttributes->{Listable},Parallelization->True]/.ruleOwn[{AngSepCut,AngSepCutZero,AngSepCutCharged}]//ReleaseHold;//AbsoluteTiming*) +(*SScutID=Hold@Compile[{{id1,_Real},{id2,_Real}},*) +(*If[id1==22.||id1==130.,SScutNeutral,SScutCharged],CompilationTarget->"C",RuntimeOptions->"Speed",RuntimeAttributes->{Listable},Parallelization->True]/.ruleOwn[{SScutNeutral,SScutZero,SScutCharged}]//ReleaseHold;//AbsoluteTiming*) +(*IPcutID=Hold@Compile[{{id1,_Real},{id2,_Real}},*) +(*If[id1!=22.&&id1!=2112.&&id1!=130.,IPcut,IPcutZero],CompilationTarget->"C",RuntimeAttributes->{Listable},RuntimeOptions->"Speed",Parallelization->True]/.ruleOwn[{IPcut,IPcutZero}]//ReleaseHold;//AbsoluteTiming*) + + +(* ::Subsection::Closed:: *) +(*Visualization of the cuts*) + + +(* ::Input:: *) +(*tabbcuts=SortBy[Select[Flatten[Table[{id1,id2,ParamPDGidToProduct[id1],ParamPDGidToProduct[id2],ParamProductCharge[id1],ParamProductCharge[id2],ecutLowerID[id1//N,ParamProductCharge[id1]//N],ecutUpperID[id1//N,ParamProductCharge[id1]//N],pTcutLowerID[id1//N,ParamProductCharge[id1]],pTcutUpperID[id1//N,ParamProductCharge[id1]//N],EtotCutLowerID[id1//N,ParamProductCharge[id1]//N,id2//N],EtotCutUpperID[id1//N,ParamProductCharge[id1]//N,id2//N],IPcutID[id1//N,id2//N],AngSepCutID[id1//N,id2//N],SScutID[id1//N,id2//N],minvCutLowerID[id1//N,ParamProductCharge[id1]//N,id2//N],minvCutUpperID[id1//N,ParamProductCharge[id1]//N,id2//N]},{id1,detectablepdgs},{id2,detectablepdgs}],1],#[[5]]+#[[6]]==0&&#[[1]]<=#[[2]]&],{#[[1]],#[[2]]}&];*) +(*cutsmeaning={"\!\(\*SubscriptBox[\(pdg\), \(1\)]\)","\!\(\*SubscriptBox[\(pdg\), \(2\)]\)","\!\(\*SubscriptBox[\(id\), \(1\)]\)","\!\(\*SubscriptBox[\(id\), \(2\)]\)","\!\(\*SubscriptBox[\(Q\), \(prod, 1\)]\)","\!\(\*SubscriptBox[\(Q\), \(prod, 2\)]\)","\!\(\*SubscriptBox[\(E\), \(min, 1\)]\) (GeV)","\!\(\*SubscriptBox[\(E\), \(max, 1\)]\) (GeV)","\!\(\*SubscriptBox[\(p\), \(T, min, 1\)]\) (GeV)","\!\(\*SubscriptBox[\(p\), \(T, max, 1\)]\) (GeV)","\!\(\*FractionBox[SubscriptBox[\(E\), \(min, 1 + 2\)], \(GeV\)]\)","\!\(\*FractionBox[SubscriptBox[\(E\), \(max, 1 + 2\)], \(GeV\)]\)","IP cut (m)","angular separation cut (rad)","Transverse spatial separation cut (m)","\!\(\*SubscriptBox[\(m\), \(inv, min\)]\) (GeV)","\!\(\*SubscriptBox[\(m\), \(inv, max\)]\) (GeV)"};*) +(*Join[{Range[1,Length[cutsmeaning]],cutsmeaning},tabbcuts]//TableForm*) +(*IfEcuts=If[Length[Select[tabbcuts,#[[7]]!=eCutLowerZero||#[[8]]!=eCutUpperZero||#[[11]]!=eTotCutLowerZero||#[[12]]!=eTotCutUpperZero&]]==0,0,1];*) +(*IfEtotLowercuts=If[Length[Select[tabbcuts,#[[11]]!=eTotCutLowerZero&]]==0,0,1];*) +(*IfEtotUppercuts=If[Length[Select[tabbcuts,#[[12]]!=eTotCutUpperZero&]]==0,0,1];*) +(*IfpTcuts=If[Length[Select[tabbcuts,#[[9]]!=pTcutLowerZero||#[[10]]!=pTcutUpperZero&]]==0,0,1];*) +(*IfAngSepCuts=If[Length[Select[tabbcuts,#[[14]]!=AngSepCutZero&]]==0,0,1];*) +(*IfSScuts=If[Length[Select[tabbcuts,#[[15]]!=AngSepCutZero&]]==0,0,1];*) +(*IfIPcuts=If[Length[Select[tabbcuts,#[[13]]!=IPcutZero&]]==0,0,1];*) +(*IfminvCuts=If[Length[Select[tabbcuts,#[[16]]!=minvCutLowerZero||#[[17]]!=minvCutUpperZero&]]==0,0,1];*) +(*IfminvLowerCuts=If[Length[Select[tabbcuts,#[[16]]!=minvCutLowerZero&]]==0,0,1];*) +(*IfminvUpperCuts=If[Length[Select[tabbcuts,#[[17]]!=minvCutUpperZero&]]==0,0,1];*) +(*WhetherCuts=If[Total[{IfEcuts,IfEtotLowercuts,IfEtotUppercuts,IfpTcuts,IfAngSepCuts,IfIPcuts,IfminvCuts,IfminvLowerCuts,IfminvUpperCuts}]==0,0.,1.];*) +(*{{"Any E cut","Tot \!\(\*SubscriptBox[\(E\), \(lower\)]\) cut","Tot \!\(\*SubscriptBox[\(E\), \(upper\)]\) cut","\!\(\*SubscriptBox[\(p\), \(T\)]\) cut","Angular cut","SS cut","IP cuts","Any \!\(\*SubscriptBox[\(m\), \(inv\\\ cut\)]\)","\!\(\*SubscriptBox[\(m\), \(inv, lower\)]\) cuts","\!\(\*SubscriptBox[\(m\), \(inv, upper\)]\) cuts"},{IfEcuts,IfEtotLowercuts,IfEtotUppercuts,IfpTcuts,IfAngSepCuts,IfSScuts,IfIPcuts,IfminvCuts,IfminvLowerCuts,IfminvUpperCuts}}//TableForm*) + + +(* ::Chapter::Closed:: *) +(*Azimuthal acceptance calculation*) + + +(* ::Section::Closed:: *) +(*Geometry visualization*) + + +(* ::Input:: *) +(*Print["List of geometric parameters:"]*) +(*If[GeometryGivenExperiment=="Cylinder"||GeometryGivenExperiment=="Annular cylinder",{{"Orientation of the detector cross section wrt beamline","Decay volume geometry type","\!\(\*FractionBox[SubscriptBox[\(l\), \(to\\\ fid\)], \(m\)]\)","\!\(\*FractionBox[SubscriptBox[\(l\), \(fid\)], \(m\)]\)","\!\(\*FractionBox[SubscriptBox[\(l\), \(fid + det\)], \(m\)]\)","\!\(\*FractionBox[SubscriptBox[\(R\), \(inner, dec\\\ vol\)], \(m\)]\)","\!\(\*FractionBox[SubscriptBox[\(R\), \(outer, dec\\\ vol\)], \(m\)]\)","\!\(\*FractionBox[SubscriptBox[\(R\), \(inner, det\)], \(m\)]\)","\!\(\*FractionBox[SubscriptBox[\(R\), \(outer, det\)], \(m\)]\)","\!\(\*FractionBox[SubscriptBox[\(\[Theta]\), \(min, decay\\\ volume\)], \(rad\)]\)","\!\(\*FractionBox[SubscriptBox[\(\[Theta]\), \(max, decay\\\ volume\)], \(rad\)]\)","\!\(\*FractionBox[SubscriptBox[\(\[Theta]\), \(min, det\)], \(rad\)]\)","\!\(\*FractionBox[SubscriptBox[\(\[Theta]\), \(max, det\)], \(rad\)]\)"},{DetectorPlaneOrientationGivenExperiment,GeometryGivenExperiment,zToDecayVolumeGivenExperiment,dzFidGivenExperiment,xLongMaxDetectorGivenExperiment,RinnerDecayVolumeGivenExperiment[z],RouterDecayVolumeGivenExperiment[z],RinnerDetectorGivenExperiment,RouterDetectorGivenExperiment,ThetaDecVolGivenExperimentMin,ThetaDecVolGivenExperimentMax,ThetaDetGivenExperimentMin,ThetaDetGivenExperimentMax}}//TableForm,{{"Orientation of the detector cross section wrt beamline","Decay volume geometry type","\!\(\*FractionBox[SubscriptBox[\(l\), \(to\\\ fid\)], \(m\)]\)","\!\(\*FractionBox[SubscriptBox[\(l\), \(fid\)], \(m\)]\)","\!\(\*FractionBox[SubscriptBox[\(l\), \(fid + det\)], \(m\)]\)","\!\(\*FractionBox[SubscriptBox[\(\[CapitalDelta]x\), \(1\\\ dec . vol . \)], \(m\)]\)","\!\(\*FractionBox[SubscriptBox[\(\[CapitalDelta]x\), \(2\\\ dec . vol . \)], \(m\)]\)","\!\(\*FractionBox[SubscriptBox[\(\[CapitalDelta]x\), \(1 \( \(det\)\(.\)\)\)], \(m\)]\)","\!\(\*FractionBox[SubscriptBox[\(\[CapitalDelta]x\), \(2 \( \(det\)\(.\)\)\)], \(m\)]\)","\!\(\*FractionBox[SubscriptBox[\(\[Theta]\), \(min, decay\\\ volume\)], \(rad\)]\)","\!\(\*FractionBox[SubscriptBox[\(\[Theta]\), \(max, decay\\\ volume\)], \(rad\)]\)","\!\(\*FractionBox[SubscriptBox[\(\[Theta]\), \(min, det\)], \(rad\)]\)","\!\(\*FractionBox[SubscriptBox[\(\[Theta]\), \(max, det\)], \(rad\)]\)"},{DetectorPlaneOrientationGivenExperiment,GeometryGivenExperiment,zToDecayVolumeGivenExperiment,dzFidGivenExperiment,xLongMaxDetectorGivenExperiment,dxDecayVolumeGivenExperiment[z],dyDecayVolumeGivenExperiment[z],dxDetectorGivenExperimentMax,dyDetectorGivenExperimentMax,ThetaDecVolGivenExperimentMin,ThetaDecVolGivenExperimentMax,ThetaDetGivenExperimentMin,ThetaDetGivenExperimentMax}}//TableForm]*) +(*Print["Experiment geometry. Black point - collision point. The blue domain - decay volume. The red domain - detector. The green plane - final plane:"]*) +(*(*Block defining relevant plots*)*) +(*ExperimentPlots:=Block[{},*) +(*BoxRatioz=3;*) +(*PlotOrigin=(*If[DecayVolumeAsDetectorGivenExperiment\[Equal]"False",*)Graphics3D[{PointSize[0.05],Black,Point[{0,0,0}]},Axes->True,AxesLabel->{Style["x",24,Bold,Black],Style["y",24,Bold,Black],Style["z",24,Bold,Black]},AxesOrigin->{0,0,0},ViewProjection->"Orthographic",ViewCenter->{0,0,0},ViewPoint->{-0.7,0.25,-2},ViewVertical->{0,1,0},BoxRatios->{1,1,BoxRatioz},AxesStyle->{Thickness[0.03]},LabelStyle->{Directive[Black,20]}](*,Graphics3D[{PointSize[0.05],Black,Point[{0,0,0}]},Axes\[Rule]True,AxesLabel\[Rule]{Style["x",24,Bold,Black],Style["y",24,Bold,Black],Style["z",24,Bold,Black]},AxesOrigin\[Rule]{0,0,0},ViewProjection\[Rule]"Orthographic",ViewCenter\[Rule]{0,0,0},ViewPoint\[Rule]{-0.7,0.25,-2},ViewVertical\[Rule]{0,1,0},BoxRatios\[Rule]{1,1,BoxRatioz},AxesStyle\[Rule]{Thickness[0.03]},LabelStyle\[Rule]{Directive[Black,20]}]]*);*) +(*PlotFinalPlane=If[DecayVolumeAsDetectorGivenExperiment=="False",Graphics3D[{Green,Opacity[0.2],FinalPlaneGivenExperiment}]];*) +(*PlotDecayVolume=If[GeometryGivenExperiment=="Annular cylinder"&&MemberQ[explistlhcb,GivenExperiment]==False,Show[Region[Style[finAnnular,White,Opacity[1],EdgeForm[Directive[Thickness[0.01],Blue,Opacity-> 1]]]],Region[Style[foutAnnular,Blue,Opacity[0.3],EdgeForm[Directive[Thickness[0.01],Blue,Opacity-> 0.1]]]]],Region[Style[DecayVolumeGeometryGivenExperiment,Blue,Opacity[0.2],EdgeForm[{Thick,Blue}]],BoxRatios->{1,1,BoxRatioz},Boxed->True,Axes->True]];*) +(*If[DecayVolumeAsDetectorGivenExperiment=="False",*) +(*PlotDetector=If[GeometryGivenExperiment=="Annular cylinder"&&MemberQ[explistlhcb,GivenExperiment]==False,Show[Region[Style[finDetAnnular,White,Opacity[1],EdgeForm[Directive[Thickness[0.01],Red,Opacity-> 1]]]],Region[Style[foutDetAnnular,Red,Opacity[0.2],EdgeForm[Directive[Thickness[0.01],Red,Opacity-> 0.1]]]]],Region[Style[DetectorGeometryGivenExperiment,Red,Opacity[0.3],EdgeForm[{Thick,Red}]],BoxRatios->{1,1,BoxRatioz},Boxed->True,Axes->True]]];*) +(*PlotFullGeometry=If[DecayVolumeAsDetectorGivenExperiment=="False",Show[PlotOrigin,PlotFinalPlane,PlotDecayVolume,PlotDetector],Show[PlotOrigin,PlotDecayVolume]];*) +(*Plot\[Theta]minmaxDecayVolume=Show[PlotOrigin,PlotDecayVolume,Graphics3D[{Thick,Black,Arrowheads[Large],Arrow[{{0,0,0},{x,y,z}@@@R\[Theta]minDecayVolume}],Thick,Darker@Darker@Green,Arrow[{{0,0,0},{x,y,z}@@@R\[Theta]maxDecayVolume}]},ViewPoint->Right]];*) +(*Plot\[Theta]minmaxDetector=If[DecayVolumeAsDetectorGivenExperiment=="False",Show[PlotOrigin,PlotDetector,Graphics3D[{Thick,Black,Arrowheads[Large],Arrow[{{0,0,0},{x,y,z}@@@R\[Theta]minEndDetector}],Thick,Darker@Darker@Green,Arrow[{{0,0,0},{x,y,z}@@@R\[Theta]maxEndDetector}]},ViewPoint->Right]]];*) +(*If[DecayVolumeAsDetectorGivenExperiment=="False",{PlotFullGeometry,Plot\[Theta]minmaxDecayVolume,Plot\[Theta]minmaxDetector},{PlotFullGeometry,Plot\[Theta]minmaxDecayVolume}]*) +(*]*) +(*expplots=ExperimentPlots;*) +(*expplots[[1]]*) +(*Print["Plots checking the correctness of evaluation of \!\(\*SubscriptBox[\(\[Theta]\), \(min\)]\), \!\(\*SubscriptBox[\(\[Theta]\), \(max\)]\) of detector and decay volume. The coordinates defining these angles are shown by arrows (black - \!\(\*SubscriptBox[\(\[Theta]\), \(min\)]\), green - \!\(\*SubscriptBox[\(\[Theta]\), \(max\)]\)):"]*) +(*expplots[[2]]*) +(*If[DecayVolumeAsDetectorGivenExperiment=="False",expplots[[3]]]*) + + +(* ::Input:: *) +(*(*BoxRatioz=5;*) +(*PlotOrigin=(*If[DecayVolumeAsDetectorGivenExperiment\[Equal]"False",*)Graphics3D[{PointSize[0.05],Black,Point[{0,0,0}]},Axes\[Rule]True,AxesLabel\[Rule]{Style["x",24,Bold,Black],Style["y",24,Bold,Black],Style["z",24,Bold,Black]},AxesOrigin\[Rule]{0,0,0},ViewProjection\[Rule]"Orthographic",ViewCenter\[Rule]{0,0,0},ViewPoint\[Rule]{-0.7,0.25,-2},ViewVertical\[Rule]{0,1,0},BoxRatios\[Rule]{1,1,BoxRatioz},AxesStyle\[Rule]{Thickness[0.03]},LabelStyle\[Rule]{Directive[Black,20]}](*,Graphics3D[{PointSize[0.05],Black,Point[{0,0,0}]},Axes\[Rule]True,AxesLabel\[Rule]{Style["x",24,Bold,Black],Style["y",24,Bold,Black],Style["z",24,Bold,Black]},AxesOrigin\[Rule]{0,0,0},ViewProjection\[Rule]"Orthographic",ViewCenter\[Rule]{0,0,0},ViewPoint\[Rule]{-0.7,0.25,-2},ViewVertical\[Rule]{0,1,0},BoxRatios\[Rule]{1,1,BoxRatioz},AxesStyle\[Rule]{Thickness[0.03]},LabelStyle\[Rule]{Directive[Black,20]}]]*);*) +(*PlotFinalPlane=If[DecayVolumeAsDetectorGivenExperiment\[Equal]"False",Graphics3D[{Green,Opacity[0.2],FinalPlaneGivenExperiment}]];*) +(*PlotDecayVolume=If[GeometryGivenExperiment\[Equal]"Annular cylinder",Show[Region[Style[finAnnular,White,Opacity[1](*,EdgeForm[Directive[Thickness[0.01],Blue,Opacity\[Rule] 1]]*)]],Region[Style[foutAnnular,Blue,Opacity[0.3](*,EdgeForm[Directive[Thickness[0.01],Blue,Opacity\[Rule] 0.1]]*)]]],Region[Style[DecayVolumeGeometryGivenExperiment,Blue,Opacity[0.2](*,EdgeForm[{Thick,Blue}]*)],BoxRatios\[Rule]{1,1,BoxRatioz},Boxed\[Rule]True,Axes\[Rule]True]];*) +(*PlotDetector=If[DecayVolumeAsDetectorGivenExperiment\[Equal]"False",If[GeometryGivenExperiment\[Equal]"Annular cylinder"&&GivenExperiment!="LHCb-downstream-SciFi",Show[Region[Style[finDetAnnular,White,Opacity[1](*,EdgeForm[Directive[Thickness[0.01],Red,Opacity\[Rule] 1]]*)]],Region[Style[foutDetAnnular,Red,Opacity[0.2](*,EdgeForm[Directive[Thickness[0.01],Red,Opacity\[Rule] 0.1]]*)]]],Region[Style[DetectorGeometryGivenExperiment,Red,Opacity[0.3](*,EdgeForm[{Thick,Red}]*)],BoxRatios\[Rule]{1,1,BoxRatioz},Boxed\[Rule]True,Axes\[Rule]True]]];*) +(*PlotFullGeometry=If[DecayVolumeAsDetectorGivenExperiment\[Equal]"False",Show[PlotOrigin(*,PlotFinalPlane*),PlotDecayVolume,PlotDetector],Show[PlotOrigin,PlotDecayVolume]]*)*) + + +(* ::Input:: *) +(*(*BoxRatioz=3;*) +(*PlotOrigin=(*If[DecayVolumeAsDetectorGivenExperiment\[Equal]"False",*)Graphics3D[{PointSize[0.05],Black,Point[{0,0,0}]},Axes\[Rule]True,AxesLabel\[Rule]{Style["x",24,Bold,Black],Style["y",24,Bold,Black],Style["z",24,Bold,Black]},AxesOrigin\[Rule]{0,0,0},ViewProjection\[Rule]"Orthographic",ViewCenter\[Rule]{0,0,0},ViewPoint\[Rule]{-0.7,0.25,-2},ViewVertical\[Rule]{0,1,0},BoxRatios\[Rule]{1,0.75,BoxRatioz},AxesStyle\[Rule]{Thickness[0.03]},LabelStyle\[Rule]{Directive[Black,20]}];*) +(*UT=Polygon[{{-1,-1,2.5},{-1,1,2.5},{1,1,2.5},{1,-1,2.5}}];*) +(*PlotUT=If[DecayVolumeAsDetectorGivenExperiment\[Equal]"False",Graphics3D[{Green,Opacity[0.2],UT}]];*) +(*PlotDecayVolume=If[GeometryGivenExperiment\[Equal]"Annular cylinder"&&MemberQ[explistlhcb,GivenExperiment]==False,Show[Region[Style[finAnnular,White,Opacity[1],EdgeForm[Directive[Thickness[0.01],Blue,Opacity\[Rule] 1]]]],Region[Style[foutAnnular,Blue,Opacity[0.3],EdgeForm[Directive[Thickness[0.01],Blue,Opacity\[Rule] 0.1]]]]],Region[Style[DecayVolumeGeometryGivenExperiment,Blue,Opacity[0.2]],BoxRatios\[Rule]{1,1,BoxRatioz},Boxed\[Rule]True,Axes\[Rule]True]];*) +(*PlotDetector=If[DecayVolumeAsDetectorGivenExperiment\[Equal]"False",If[GeometryGivenExperiment\[Equal]"Annular cylinder"&&MemberQ[explistlhcb,GivenExperiment]==False,Show[Region[Style[finDetAnnular,White,Opacity[1],EdgeForm[Directive[Thickness[0.01],Red,Opacity\[Rule] 1]]]],Region[Style[foutDetAnnular,Red,Opacity[0.2],EdgeForm[Directive[Thickness[0.01],Red,Opacity\[Rule] 0.1]]]]],Region[Style[DetectorGeometryGivenExperiment,Red,Opacity[0.3]],BoxRatios\[Rule]{1,1,BoxRatioz},Boxed\[Rule]True,Axes\[Rule]True]]];*) +(*PlotFullGeometry=If[DecayVolumeAsDetectorGivenExperiment\[Equal]"False",Show[PlotOrigin,PlotUT,PlotDecayVolume,PlotDetector],Show[PlotOrigin,PlotDecayVolume]]*)*) + + +(* ::Subsection::Closed:: *) +(*Adjustable plot*) + + +(* ::Input:: *) +(*(*BoxRatioz=10;*) +(*PlotOrigin=(*If[DecayVolumeAsDetectorGivenExperiment\[Equal]"False",*)Graphics3D[{PointSize[0.05],Black,Point[{0,0,0}]},Axes\[Rule]True,AxesLabel\[Rule]{Style["x",24,Bold,Black],Style["y",24,Bold,Black],Style["z",24,Bold,Black]},AxesOrigin\[Rule]{0,0,0},ViewProjection\[Rule]"Orthographic",ViewCenter\[Rule]{0,0,0},ViewPoint\[Rule]{-0.7,0.25,-2},ViewVertical\[Rule]{0,1,0},BoxRatios\[Rule]{1,1.8,BoxRatioz},AxesStyle\[Rule]{Thickness[0.03]},LabelStyle\[Rule]{Directive[Black,20]}](*,Graphics3D[{PointSize[0.05],Black,Point[{0,0,0}]},Axes\[Rule]True,AxesLabel\[Rule]{Style["x",24,Bold,Black],Style["y",24,Bold,Black],Style["z",24,Bold,Black]},AxesOrigin\[Rule]{0,0,0},ViewProjection\[Rule]"Orthographic",ViewCenter\[Rule]{0,0,0},ViewPoint\[Rule]{-0.7,0.25,-2},ViewVertical\[Rule]{0,1,0},BoxRatios\[Rule]{1,1,BoxRatioz},AxesStyle\[Rule]{Thickness[0.03]},LabelStyle\[Rule]{Directive[Black,20]}]]*);*) +(*PlotFinalPlane=If[DecayVolumeAsDetectorGivenExperiment\[Equal]"False",Graphics3D[{Green,Opacity[0.2],FinalPlaneGivenExperiment}]];*) +(*PlotDecayVolume=If[GeometryGivenExperiment\[Equal]"Annular cylinder"&&MemberQ[explistlhcb,GivenExperiment]==False,Show[Region[Style[finAnnular,White,Opacity[1],EdgeForm[Directive[Thickness[0.01],Blue,Opacity\[Rule] 1]]]],Region[Style[foutAnnular,Blue,Opacity[0.3],EdgeForm[Directive[Thickness[0.01],Blue,Opacity\[Rule] 0.1]]]]],Region[Style[DecayVolumeGeometryGivenExperiment,Blue,Opacity[0.2],EdgeForm[{Thick,Blue}]],BoxRatios\[Rule]{1,1,BoxRatioz},Boxed\[Rule]True,Axes\[Rule]True]];*) +(*PlotDetector=If[DecayVolumeAsDetectorGivenExperiment\[Equal]"False",If[GeometryGivenExperiment\[Equal]"Annular cylinder"&&MemberQ[explistlhcb,GivenExperiment]==False,Show[Region[Style[finDetAnnular,White,Opacity[1],EdgeForm[Directive[Thickness[0.01],Red,Opacity\[Rule] 1]]]],Region[Style[foutDetAnnular,Red,Opacity[0.2],EdgeForm[Directive[Thickness[0.01],Red,Opacity\[Rule] 0.1]]]]],Region[Style[DetectorGeometryGivenExperiment,Red,Opacity[0.3],EdgeForm[{Thick,Red}]],BoxRatios\[Rule]{1,1,BoxRatioz},Boxed\[Rule]True,Axes\[Rule]True]]];*) +(*PlotFullGeometry=If[DecayVolumeAsDetectorGivenExperiment\[Equal]"False",Show[PlotOrigin,PlotDecayVolume,PlotDetector],Show[PlotOrigin,PlotDecayVolume]];*) +(*PlotFullGeometry*)*) + + +(* ::Section::Closed:: *) +(*Defining \[Theta],E,z grid for the tabulation*) + + +(* ::Input:: *) +(*(*Grid of energies for which the decay products acceptance will be generated*)*) +(*ELLPvaluesFacility["FermilabBD"]=Join[{0.005,0.01,0.021,0.05,0.1,0.25,0.5,0.75,1.,1.5,2.,2.5,3.,3.5,4.,4.5,5.},Table[10^ELLP,{ELLP,Log10[5.5],Log10[EmaxFacility["FermilabBD"]],(Log10[EmaxFacility["FermilabBD"]]-Log10[5.5])/50}]]//N;*) +(*ELLPvaluesFacility["ESS"]=Join[Table[e,{e,0.00501,0.14001,0.001}],{0.141,0.145,0.15,16,0.17,0.18,0.19,0.2,0.23,0.25,0.27,0.3,0.35,0.4,0.45,0.5,0.55,0.6,0.65,0.7,0.75,0.8,0.85,0.9,0.95,1.,1.1,1.3,1.5,2.,2.4}]//N;*) +(*ELLPvaluesFacility["Serpukhov"]=Join[{0.005,0.01,0.021,0.05,0.1,0.25,0.5,0.75,1.,1.5,2.,2.5,3.,3.5,4.,4.5,5.},Table[10^ELLP,{ELLP,Log10[5.5],Log10[EmaxFacility["Serpukhov"]],(Log10[EmaxFacility["Serpukhov"]]-Log10[5.5])/40}]]//N;*) +(*ELLPvaluesFacility["SPS"]=Join[{0.005,0.01,0.021,0.05,0.1,0.25,0.5,0.75,1.,1.5,2.,2.5,3.,3.5,4.,4.5,5.},Table[10^ELLP,{ELLP,Log10[5.5],Log10[EmaxFacility["SPS"]],(Log10[EmaxFacility["SPS"]]-Log10[5.5])/50}]]//N;*) +(*ELLPvaluesFacility["LHC"]=Join[{0.005,0.01,0.021,0.05,0.1,0.25,0.5,0.75,1.,1.5,2.,2.5,3.,3.5,4.,4.5,5.},Table[10^ELLP,{ELLP,Log10[5.5],Log10[1000],(Log10[1000]-Log10[5.5])/50}],Table[10^ELLP,{ELLP,Log10[1100.],Log10[EmaxFacility["LHC"]],(Log10[EmaxFacility["LHC"]]-Log10[1100.])/30}]]//N;*) +(*ELLPvaluesFacility["FCC-hh"]=Join[{0.005,0.011,0.021,0.05,0.1,0.25,0.5,0.75,1.,1.5,2.,2.5,3.,3.5,4.,4.5,5.},Table[10^ELLP,{ELLP,Log10[5.5],Log10[1000],(Log10[1000]-Log10[5.5])/30}],Table[10^ELLP,{ELLP,Log10[1100.],Log10[10000.],(Log10[10000.]-Log10[1100.])/30}],Table[10^ELLP,{ELLP,Log10[11000.],Log10[EmaxFacility["FCC-hh"]],(Log10[EmaxFacility["FCC-hh"]]-Log10[11000.])/30}]]//N;*) +(*(*Grid of Subscript[\[Theta], LLP],Subscript[z, LLP]*)*) +(*\[Theta]LLPrange=\[Theta]grid[DecayVolumeAsDetectorGivenExperiment,ThetaDecVolGivenExperimentMin,ThetaDecVolGivenExperimentMax,ThetaDetGivenExperimentMin,ThetaDetGivenExperimentMax];*) +(*\[CapitalDelta]zVal[\[CapitalDelta]z_]=Min[\[CapitalDelta]z/10,Max[0.5,\[CapitalDelta]z/45.]];*) +(*zLLPrangeTemp=Table[zLLP,{zLLP,zToDecayVolumeGivenExperiment,zMaxDecayVolumeGivenExperiment,\[CapitalDelta]zVal[zMaxDecayVolumeGivenExperiment-zToDecayVolumeGivenExperiment]}]//N;*) +(*zLLPrange=If[zLLPrangeTemp[[-1]]!=zMaxDecayVolumeGivenExperiment,Join[zLLPrangeTemp,{zMaxDecayVolumeGivenExperiment}],zLLPrangeTemp];*) +(*TableLLPgrid\[Theta]z=Flatten[Table[{\[Theta]LLP,zLLP},{\[Theta]LLP,\[Theta]LLPrange},{zLLP,zLLPrange}],{1,2}];*) +(*(*List of Subscript[E, LLP]*)*) +(*ELLPvalues=ELLPvaluesFacility[FacilityGivenExperiment];*) + + +(* ::Section::Closed:: *) +(*Azimuthal acceptance calculations*) + + +(* ::Input:: *) +(*NotebookEvaluate[FileNameJoin[{NotebookDirectory[],"codes/azimuthal-acceptance.nb"}]];*) +(*TableAzimuthalAcceptancesToDet=Table[Block\[Theta]zLLP\[Epsilon]Az\[Phi][EpsilonAzPhiListToDet,j],{j,1,Length[TableLLPgrid\[Theta]z],1}];//AbsoluteTiming*) +(*TableAzimuthalAcceptancesNotToDet=If[DecayVolumeAsDetectorGivenExperiment=="False",Table[Block\[Theta]zLLP\[Epsilon]Az\[Phi][EpsilonAzPhiListNotToDet,j],{j,1,Length[TableLLPgrid\[Theta]z],1}]];//AbsoluteTiming*) +(*TableLLPgridWithELLPtemp[dat_]:=Flatten[Table[{dat[[i]][[1]],ELLPvalues[[k]],dat[[i]][[2]],dat[[i]][[3]],dat[[i]][[4]][[j]]},{i,1,Length[dat],1},{k,1,Length[ELLPvalues],1},{j,1,NofPhiVals,1}],{1,2,3}];//AbsoluteTiming*) +(*(*Grid Subscript[E, LLP], Subscript[\[Theta], LLP], Subscript[x, long,LLP],Subscript[\[Epsilon], azimuthal,LLP],Subscript[\[Phi], LLP] within the decay volume, assuming that LLP points to the end of detector, or not points to the end of detector*)*) +(*gridLLPtoDet=TableLLPgridWithELLPtemp[TableAzimuthalAcceptancesToDet];//AbsoluteTiming*) +(*gridLLPnotToDet=If[DecayVolumeAsDetectorGivenExperiment=="False",TableLLPgridWithELLPtemp[TableAzimuthalAcceptancesNotToDet],gridLLPtoDet];//AbsoluteTiming*) +(*(*The same but without the column Subscript[\[Phi], LLP]*)*) +(*{gridReducedLLPtoDet,gridReducedLLPnotToDet}={DeleteDuplicatesBy[gridLLPtoDet,{#[[1]],#[[2]],#[[3]],#[[4]]}&][[All,{1,2,3,4}]],If[DecayVolumeAsDetectorGivenExperiment=="False",DeleteDuplicatesBy[gridLLPnotToDet,{#[[1]],#[[2]],#[[3]],#[[4]]}&][[All,{1,2,3,4}]]]};*) +(*(*Meaning of columns in the tables gridLLPtoDet,gridLLPnotToDet*)*) +(*index\[Theta]LLP=1;*) +(*indexELLP=2;*) +(*indexzLLP=3;*) +(*indexLLPazAcc=4;*) +(*index\[Phi]LLP=5;*) +(*Print["\[Theta] grid:"]*) +(*thgrid=DeleteDuplicates[gridLLPtoDet[[All,1]]]*) +(*Print["E grid:"]*) +(*egrid=DeleteDuplicates[gridLLPtoDet[[All,2]]]*) +(*Print["z grid:"]*) +(*zgrid=DeleteDuplicates[gridLLPtoDet[[All,3]]]*) +(*azaccdata=Join[gridReducedLLPtoDet[[All,{1,3}]],If[DecayVolumeAsDetectorGivenExperiment=="False",gridReducedLLPtoDet[[All,{4}]]+gridReducedLLPnotToDet[[All,{4}]],gridReducedLLPtoDet[[All,{4}]]],2];*) +(*Print["The volume of the decay volume (in \!\(\*SuperscriptBox[\(m\), \(3\)]\)) calculated by the azimuthal acceptance (compare with the true volume obtained using simple formulas):"]*) +(*azacc[th_,z_]=Interpolation[DeleteDuplicatesBy[azaccdata,{#[[1]],#[[2]]}&],InterpolationOrder->1][th,z];*) +(*{{"Meaning","Volume - computed as \[Integral]2\!\(\*SubscriptBox[\(\[Pi]\[Epsilon]\), \(az\)]\)(\[Theta],z)sin(\[Theta]) \!\(\*SuperscriptBox[\(r\), \(2\)]\)(z)d\[Theta]dr", "Volume - computed internally as Volume[Decay Volume]", "Volume - computed as \[Integral]IfLLPinsideDecVol dx dy dz"},{"Comment","","Must match the 2nd column with O(few %) precision","Must match the 2nd column with O(few %) precision"},{"Value",NIntegrate[2*Pi*azacc[th,z]*Sin[th] z^2/Cos[th]^3,{th,thgrid[[1]],thgrid[[-1]]},{z,zgrid[[1]],zgrid[[-1]]}],Volume[DecayVolumeGeometryGivenExperiment],VolumeFromIf[GivenExperiment]}}//TableForm*) + + +(* ::Subsubsection::Closed:: *) +(*Visualization of the generated acceptance points*) + + +(* ::Input:: *) +(*(*_______________________________________________________*)*) +(*(*Visualization of the generated LLP decay points. Uncomment if needed*)*) +(*(*_______________________________________________________*)*) +(*AzimuthalAcceptanceVisualizationChoice="No";*) +(*(*AzimuthalAcceptanceVisualizationChoice=dropdownDialog[{"Yes","No"},"Do you want to visualize the generated grid of the LLP decay points inside the decay volume?"];*)*) +(*If[AzimuthalAcceptanceVisualizationChoice=="Yes",Print["Green points - the decay points of the LLPs pointing to the end of the detector. Cyan points - for the LLPs that do not point to the detector (less dense grid)"]]*) +(*If[AzimuthalAcceptanceVisualizationChoice=="Yes",*) +(*anglestocart=Compile[{{tab,_Real,2}},{#[[3]]/Cos[#[[1]]] Sin[#[[1]]]Cos[#[[5]]],#[[3]]/Cos[#[[1]]] Sin[#[[1]]]Sin[#[[5]]],#[[3]]}&/@tab,CompilationTarget->"C",RuntimeOptions->"Speed"];*) +(*pointstodet=anglestocart[Select[gridLLPtoDet,#[[4]]!=0&]];*) +(*pointsnottodet=If[Length[gridLLPnotToDet]!=0,anglestocart[Select[gridLLPnotToDet,#[[4]]!=0&]]];*) +(*(*The commented code explicitly checks whether the generate point ivall belongs to the decay volume. The result must always be "True"*)*) +(*(*ivall=3;*) +(*RegionMember[DecayVolumeGeometryGivenExperiment,pointstodet[[3]]]*)*) +(*PlotDetector1=If[DecayVolumeAsDetectorGivenExperiment=="False",If[GeometryGivenExperiment=="Annular cylinder"&&StringContainsQ[GivenExperiment,"LHCb-downstream-SciFi"]==True,Show[Region[Style[finDetAnnular,White,Opacity[1],EdgeForm[Directive[Thickness[0.01],Red,Opacity-> 1]]]],Region[Style[foutDetAnnular,Red,Opacity[0.1],EdgeForm[Directive[Thickness[0.01],Red,Opacity-> 0.1]]]]],Region[Style[DetectorGeometryGivenExperiment,Red,Opacity[0.1],EdgeForm[{Thick,Red}]],BoxRatios->{1,1,BoxRatioz},Boxed->True,Axes->True]]];*) +(*PlotDecayVolume1=If[GeometryGivenExperiment=="Annular cylinder"&&MemberQ[explistlhcb,GivenExperiment]==False,Show[Region[Style[finAnnular,White,Opacity[1],EdgeForm[Directive[Thickness[0.01],Blue,Opacity-> 1]]]],Region[Style[foutAnnular,Blue,Opacity[0.1],EdgeForm[Directive[Thickness[0.01],Blue,Opacity-> 0.1]]]]],Region[Style[DecayVolumeGeometryGivenExperiment,Blue,Opacity[0.1],EdgeForm[{Thick,Blue}]],BoxRatios->{1,0.2,1},Boxed->True,Axes->True]];*) +(*fig=Show[PlotOrigin,PlotDecayVolume1,PlotDetector,ListPointPlot3D[{pointstodet},PlotStyle->{{PointSize[0.005],Darker@Green},{PointSize[0.02],Darker@Green},{Black}},BoxRatios->{1,1,1},Boxed->True,Axes->True],ListPointPlot3D[{pointsnottodet},PlotStyle->{{PointSize[0.005],Cyan},{PointSize[0.03],Darker@Red},{PointSize[0.02],Darker@Green},{Black}}]]*) +(*(*Export[FileNameJoin[{NotebookDirectory[],"temp1/mathusla-points.pdf"}],fig]*)]*) + + +(* ::Title::Closed:: *) +(*Computing the decay products acceptance (do not launch it manually)*) + + +(* ::Chapter::Closed:: *) +(*Definitions*) + + +(* ::Section::Closed:: *) +(*Initializing decay acceptance routines*) + + +(* ::Input:: *) +(*Quiet[NotebookEvaluate[FileNameJoin[{NotebookDirectory[],"codes/decay-acceptance.nb"}]]];*) + + +(* ::Section::Closed:: *) +(*Refining possible decay channels*) + + +(* ::Input:: *) +(*Do[*) +(*ProcessesListRefined[LLP,ECALoptionGivenExperiment]=ProcessesList[LLP,ECALoptionGivenExperiment];*) +(*,{LLP,LLPlist}]*) +(*If[MemberQ[{"CHARM-lepton","CHARM-approx-lepton","BEBC"},GivenExperiment]==True,*) +(*relevantprocesses={{"\!\(\*SuperscriptBox[\(e\), \(+\)]\)","\!\(\*SuperscriptBox[\(e\), \(-\)]\)","Null","Null"},{"\!\(\*SuperscriptBox[\(\[Mu]\), \(+\)]\)","\!\(\*SuperscriptBox[\(\[Mu]\), \(-\)]\)","Null","Null"},{"\!\(\*SuperscriptBox[\(\[Mu]\), \(+\)]\)","\!\(\*SuperscriptBox[\(e\), \(-\)]\)","\!\(\*SubscriptBox[OverscriptBox[\(\[Nu]\), \(_\)], \(e\)]\)","Null"},{"\!\(\*SuperscriptBox[\(\[Mu]\), \(-\)]\)","\!\(\*SuperscriptBox[\(e\), \(+\)]\)","\!\(\*SubscriptBox[\(\[Nu]\), \(e\)]\)","Null"},{"\!\(\*SuperscriptBox[\(\[Mu]\), \(+\)]\)","\!\(\*SuperscriptBox[\(e\), \(-\)]\)","\!\(\*SubscriptBox[\(\[Nu]\), \(\[Mu]\)]\)","Null"},{"\!\(\*SuperscriptBox[\(\[Mu]\), \(-\)]\)","\!\(\*SuperscriptBox[\(e\), \(+\)]\)","\!\(\*SubscriptBox[OverscriptBox[\(\[Nu]\), \(_\)], \(\[Mu]\)]\)","Null"},{"\!\(\*SuperscriptBox[\(\[Mu]\), \(+\)]\)","\!\(\*SuperscriptBox[\(\[Mu]\), \(-\)]\)","\!\(\*SubscriptBox[\(\[Nu]\), \(e\)]\)","Null"},{"\!\(\*SuperscriptBox[\(\[Mu]\), \(+\)]\)","\!\(\*SuperscriptBox[\(\[Mu]\), \(-\)]\)","\!\(\*SubscriptBox[\(\[Nu]\), \(\[Mu]\)]\)","Null"},{"\!\(\*SuperscriptBox[\(\[Mu]\), \(+\)]\)","\!\(\*SuperscriptBox[\(\[Mu]\), \(-\)]\)","\!\(\*SubscriptBox[\(\[Nu]\), \(\[Tau]\)]\)","Null"},{"\!\(\*SuperscriptBox[\(\[Mu]\), \(+\)]\)","\!\(\*SuperscriptBox[\(\[Mu]\), \(-\)]\)","\!\(\*SubscriptBox[OverscriptBox[\(\[Nu]\), \(_\)], \(e\)]\)","Null"},{"\!\(\*SuperscriptBox[\(\[Mu]\), \(+\)]\)","\!\(\*SuperscriptBox[\(\[Mu]\), \(-\)]\)","\!\(\*SubscriptBox[OverscriptBox[\(\[Nu]\), \(_\)], \(\[Mu]\)]\)","Null"},{"\!\(\*SuperscriptBox[\(\[Mu]\), \(+\)]\)","\!\(\*SuperscriptBox[\(\[Mu]\), \(-\)]\)","\!\(\*SubscriptBox[OverscriptBox[\(\[Nu]\), \(_\)], \(\[Tau]\)]\)","Null"},{"\!\(\*SuperscriptBox[\(e\), \(+\)]\)","\!\(\*SuperscriptBox[\(e\), \(-\)]\)","\!\(\*SubscriptBox[\(\[Nu]\), \(e\)]\)","Null"},{"\!\(\*SuperscriptBox[\(e\), \(+\)]\)","\!\(\*SuperscriptBox[\(e\), \(-\)]\)","\!\(\*SubscriptBox[\(\[Nu]\), \(\[Mu]\)]\)","Null"},{"\!\(\*SuperscriptBox[\(e\), \(+\)]\)","\!\(\*SuperscriptBox[\(e\), \(-\)]\)","\!\(\*SubscriptBox[\(\[Nu]\), \(\[Tau]\)]\)","Null"},{"\!\(\*SuperscriptBox[\(e\), \(+\)]\)","\!\(\*SuperscriptBox[\(e\), \(-\)]\)","\!\(\*SubscriptBox[OverscriptBox[\(\[Nu]\), \(_\)], \(e\)]\)","Null"},{"\!\(\*SuperscriptBox[\(e\), \(+\)]\)","\!\(\*SuperscriptBox[\(e\), \(-\)]\)","\!\(\*SubscriptBox[OverscriptBox[\(\[Nu]\), \(_\)], \(\[Mu]\)]\)","Null"},{"\!\(\*SuperscriptBox[\(e\), \(+\)]\)","\!\(\*SuperscriptBox[\(e\), \(-\)]\)","\!\(\*SubscriptBox[OverscriptBox[\(\[Nu]\), \(_\)], \(\[Tau]\)]\)","Null"}};*) +(*If[MemberQ[{"BEBC"},GivenExperiment]==True,relevantprocesses=Join[relevantprocesses,{{"\!\(\*SuperscriptBox[\(\[Pi]\), \(0\)]\)","\!\(\*SubscriptBox[\(\[Nu]\), \(e\)]\)","Null","Null"},{"\!\(\*SuperscriptBox[\(\[Pi]\), \(0\)]\)","\!\(\*SubscriptBox[\(\[Nu]\), \(\[Mu]\)]\)","Null","Null"},{"\!\(\*SuperscriptBox[\(\[Pi]\), \(0\)]\)","\!\(\*SubscriptBox[\(\[Nu]\), \(\[Tau]\)]\)","Null","Null"},{"\!\(\*SuperscriptBox[\(\[Pi]\), \(0\)]\)","\!\(\*SubscriptBox[OverscriptBox[\(\[Nu]\), \(_\)], \(e\)]\)","Null","Null"},{"\!\(\*SuperscriptBox[\(\[Pi]\), \(0\)]\)","\!\(\*SubscriptBox[OverscriptBox[\(\[Nu]\), \(_\)], \(\[Mu]\)]\)","Null","Null"},{"\!\(\*SuperscriptBox[\(\[Pi]\), \(0\)]\)","\!\(\*SubscriptBox[OverscriptBox[\(\[Nu]\), \(_\)], \(\[Tau]\)]\)","Null","Null"}{"\!\(\*SuperscriptBox[\(\[Pi]\), \(0\)]\)","\[Nu]","Null","Null"},{"\[Gamma]","\[Gamma]","Null","Null"},{"\!\(\*SuperscriptBox[\(\[Pi]\), \(0\)]\)","\[Gamma]","Null","Null"},{"\!\(\*SuperscriptBox[\(\[Mu]\), \(+\)]\)","\!\(\*SuperscriptBox[\(\[Pi]\), \(-\)]\)","Null","Null"},{"\!\(\*SuperscriptBox[\(\[Mu]\), \(-\)]\)","\!\(\*SuperscriptBox[\(\[Pi]\), \(+\)]\)","Null","Null"},{"\!\(\*SuperscriptBox[\(e\), \(+\)]\)","\!\(\*SuperscriptBox[\(\[Pi]\), \(-\)]\)","Null","Null"},{"\!\(\*SuperscriptBox[\(e\), \(-\)]\)","\!\(\*SuperscriptBox[\(\[Pi]\), \(+\)]\)","Null","Null"}}]];*) +(*Do[*) +(*ProcessesListRefined[LLP,ECALoptionGivenExperiment]=Select[ProcessesList[LLP,ECALoptionGivenExperiment],MemberQ[Sort/@relevantprocesses,Sort[ListDecayProducts[LLP,#]]]==True&];*) +(*,{LLP,LLPlist}]*) +(*]*) + + +(* ::Section::Closed:: *) +(*Mass range for the acceptance computation*) + + +(* ::Input:: *) +(*(*Mass range for scalars. If the facility is not FCC-hh/LHC (where scalars heavier than B may be produced), then the mass range is bounded by Subscript[m, B] - Subscript[m, \[Pi]]. Otherwise, it is up to Subscript[m, h]/2*)*) +(*mLLPlistTemp["Scalar"]=Join[{0.02,0.05,0.1,0.2,0.22,0.3,0.4,0.5,0.7,0.9,1.05,1.3,1.6,1.99},mjetsrange["Scalar"]];*) +(*mLLPlist["Scalar"]=If[MemberQ[{"LHC","FCC-hh"},FacilityGivenExperiment]==False,Select[mLLPlistTemp["Scalar"],#<=5.1&],mLLPlistTemp["Scalar"]];*) +(*(*For HNLs - similarly*)*) +(*Do[*) +(*mLLPlistTemp[LLP]=Join[Select[{0.02,0.05,0.1,0.17,0.35,0.5,0.75,1.,1.19,1.5},#0.14*2&],mLLPlistTemp["ALP-gluon"]];*) +(*(*ALPs coupled to fermions*)*) +(*mLLPlist["ALP-fermion"]=Join[Select[{0.02,0.05,0.1,0.22,0.3,0.5,0.6,0.7,0.8,0.9,1.1,1.5,1.8,2.3},#0.22&]];*) +(*If[FacilityGivenExperiment=="ESS",*) +(*Do[mLLPlist[LLP]=Join[Select[mLLPlist[LLP],#<2.&],{0.01,0.02,0.03,0.04,0.06,0.07,0.08,0.09,0.1,0.105,0.11,0.115,0.12,0.125,0.13,0.135,0.15,0.18,0.2,0.22,0.3,0.35,0.4,0.45,0.55}]//DeleteDuplicates//Sort,{LLP,{"ALP-gluon","ALP-fermion","ALP-photon","DP","B-L","Scalar"}}];*) +(*Do[mLLPlist[LLP]={0.005,0.01,0.015,0.02,0.025,0.03,0.035,0.04,0.045,0.05,0.055,0.06,0.065,0.07,0.075,0.08,0.085,0.09,0.095,0.1,0.103,0.105,0.11,0.115,0.12,0.125,0.13,0.135,0.14},{LLP,{"HNL-mixing-e","HNL-mixing-mu","HNL-mixing-tau"}}];*) +(*]*) + + +(* ::Section::Closed:: *) +(*Final block*) + + +(* ::Input:: *) +(*phr0="Use old phenomenology from 1901.09966, or the new one from 2310.03524?";*) +(*a0={"New","Old"};*) +(*phr1[LLP_]:=Row[{"Default decay chanels: ",ProcessesListRefined[LLP,ECALoptionGivenExperiment],". Keep them?"}];*) +(*a1={"Yes","No"};*) +(*phr2="How many decay products that in principle may be detected must pass all the criteria?";*) +(*a2={">=2",">=n","All detectable"};*) +(*phr3="Heavy LLPs decay into partons. Would you like to use the phase space of hadronized decay products of the LLPs, or use partons instead?";*) +(*a3={"Hadronized products","Partons"};*) +(*FinalBlock[LLP_,isim_]:=Block[{},*) +(*masslist=mLLPlist[LLP];*) +(*(*If[LLP=="ALP-fermion",*) +(*alpfermionselection=dropdownDialog[{"New","Old"},Row[{"Use old phenomenology from 1901.09966, or the new one from 2310.03524?"}]];*) +(*LLPchoiceForComputation=If[alpfermionselection=="New","ALP-fermion","ALP-fermion-no-hadronic-decays"],*) +(*LLPchoiceForComputation=LLP;*) +(*];*)*) +(*If[LLP=="ALP-fermion",*) +(*{alpfermionselection}=choicesDialog[Style[LLP,Bold],{{phr0,a0}}];*) +(*LLPchoiceForComputation=If[alpfermionselection=="New","ALP-fermion","ALP-fermion-no-hadronic-decays"];*) +(*If[GivenExperiment!="CHARM-photon",*) +(*{decaychannelschoice,acceptancetypechoice,HadronizationOptionChoice}=choicesDialog[Style[LLP,Bold],{{phr1[LLPchoiceForComputation],a1},{phr2,a2},{phr3,a3}}],{decaychannelschoice,HadronizationOptionChoice}=choicesDialog[Style[LLP,Bold],{{phr1[LLPchoiceForComputation],a1},{phr3,a3}}]];*) +(*,*) +(*LLPchoiceForComputation=LLP;*) +(*If[GivenExperiment!="CHARM-photon",*) +(*{decaychannelschoice,acceptancetypechoice,HadronizationOptionChoice}=choicesDialog[Style[LLP,Bold],{{phr1[LLPchoiceForComputation],a1},{phr2,a2},{phr3,a3}}],*) +(*{decaychannelschoice,HadronizationOptionChoice}=choicesDialog[Style[LLP,Bold],{{phr1[LLPchoiceForComputation],a1},{phr3,a3}}]];*) +(*];*) +(*hadropt=If[HadronizationOptionChoice=="Hadronized products","True","False"];*) +(*If[acceptancetypechoice==">=n",DynamicModule[{input1=2,list,phrase},*) +(*DialogInput[Column[{TextCell["Enter the minimal number of detectable tracks:"],InputField[Dynamic[input1],Expression],Button["Submit",DialogReturn[{ntracksmin}={input1}],ImageSize->Automatic]}]]];];*) +(*(*decaychannelschoice=dropdownDialog[{"Yes","No"},Row[{"Default decay chanels: ",ProcessesListRefined[LLPchoiceForComputation,ECALoptionGivenExperiment],". Keep them?"}]];*)*) +(*(*List of decay processes considered as visible for the given calculation*)*) +(*proclist=If[decaychannelschoice=="No", selectionDialog[ProcessesListRefined[LLPchoiceForComputation,ECALoptionGivenExperiment],"Select decay channels:"],ProcessesListRefined[LLPchoiceForComputation,ECALoptionGivenExperiment]];*) +(*(*The total branching ratio of the selected visible channels*)*) +(*BrVisibleExport[mLLP_]=BrVisibleGivenSetup[LLPchoiceForComputation,mLLP,proclist,ECALoptionGivenExperiment];*) +(*(*Redefining the mass list such that it matches the domain where the br ratio of selected channels is non-zero*)*) +(*tabbrvis=Table[{mLLP,BrVisibleExport[mLLP]},{mLLP,masslist[[1]],masslist[[-1]],(masslist[[-1]]-masslist[[1]])/100}];*) +(*{mminnonzero,mmaxnonzero}=Select[tabbrvis,#[[2]]>10^-15.&][[All,1]]//MinMax;*) +(*masslist=Join[{mminnonzero},Select[masslist,mminnonzero<#"-no-hadronization"];*) +(*filenameexport=ToString@StringForm["Acceptance_``_for_``.m",Sequence@@{GivenExperimentNameFin,LLP}];*) +(*Flatten[tabcomp,1],*) +(*Print["No processes for the given LLP/ECAL availability!"]]*) +(*]*) +(*BlockExport[LLP_,isim_]:=Block[{},*) +(*datatemp=FinalBlock[LLP,isim];*) +(*Export[FileNameJoin[{NotebookDirectory[],"Acceptances",GivenExperimentNameFin,filenameexport}],{FacilityGivenExperiment,ECALoptionGivenExperiment,datatemp,TableParticlesNumbersGivenExperiment,BrVisibleExport[mLLP]},"MX"]*) +(*]*) + + +(* ::Subsection::Closed:: *) +(*Silent run*) + + +(* ::Input:: *) +(*SilentOption=0;*) +(*If[SilentOption!=0,*) +(*alpfermionselection="New";*) +(*acceptancetypechoice=">=n";*) +(*decaychannelschoice="Yes";*) +(*HadronizationOptionChoice="Hadronized products";*) +(*ntracksmin=4;*) +(*FinalBlock[LLP_,isim_]:=Block[{},*) +(*masslist=mLLPlist[LLP];*) +(*(*If[LLP=="ALP-fermion",*) +(*alpfermionselection=dropdownDialog[{"New","Old"},Row[{"Use old phenomenology from 1901.09966, or the new one from 2310.03524?"}]];*) +(*LLPchoiceForComputation=If[alpfermionselection=="New","ALP-fermion","ALP-fermion-no-hadronic-decays"],*) +(*LLPchoiceForComputation=LLP;*) +(*];*)*) +(*If[LLP=="ALP-fermion",*) +(*LLPchoiceForComputation=If[alpfermionselection=="New","ALP-fermion","ALP-fermion-no-hadronic-decays"];*) +(*,*) +(*LLPchoiceForComputation=LLP;*) +(*];*) +(*hadropt=If[HadronizationOptionChoice=="Hadronized products","True","False"];*) +(*(*decaychannelschoice=dropdownDialog[{"Yes","No"},Row[{"Default decay chanels: ",ProcessesListRefined[LLPchoiceForComputation,ECALoptionGivenExperiment],". Keep them?"}]];*)*) +(*(*List of decay processes considered as visible for the given calculation*)*) +(*proclist=If[decaychannelschoice=="No", selectionDialog[ProcessesListRefined[LLPchoiceForComputation,ECALoptionGivenExperiment],"Select decay channels:"],ProcessesListRefined[LLPchoiceForComputation,ECALoptionGivenExperiment]];*) +(*(*The total branching ratio of the selected visible channels*)*) +(*BrVisibleExport[mLLP_]=BrVisibleGivenSetup[LLPchoiceForComputation,mLLP,proclist,ECALoptionGivenExperiment];*) +(*(*Redefining the mass list such that it matches the domain where the br ratio of selected channels is non-zero*)*) +(*tabbrvis=Table[{mLLP,BrVisibleExport[mLLP]},{mLLP,masslist[[1]],masslist[[-1]],(masslist[[-1]]-masslist[[1]])/100}];*) +(*{mminnonzero,mmaxnonzero}=Select[tabbrvis,#[[2]]>10^-15.&][[All,1]]//MinMax;*) +(*masslist=Join[{mminnonzero},Select[masslist,mminnonzero<#"-no-hadronization"];*) +(*filenameexport=ToString@StringForm["Acceptance_``_for_``.m",Sequence@@{GivenExperimentNameFin,LLP}];*) +(*Flatten[tabcomp,1],*) +(*Print["No processes for the given LLP/ECAL availability!"]]*) +(*];*) +(*BlockExport[LLP_,isim_]:=Block[{},*) +(*datatemp=FinalBlock[LLP,isim];*) +(*Export[FileNameJoin[{NotebookDirectory[],"Acceptances",GivenExperimentNameFin,filenameexport}],{FacilityGivenExperiment,ECALoptionGivenExperiment,datatemp,TableParticlesNumbersGivenExperiment,BrVisibleExport[mLLP]},"MX"]*) +(*]*) +(*]*) + + +(* ::Input:: *) +(*fdf=FinalBlockMass["DP",0.01,proclist,100,"True",">=2",2];*) + + +(* ::Input:: *) +(*Select[fdf,#[[3]]>350&][[All,-1]]//Mean*) + + +(* ::Chapter::Closed:: *) +(*Actual computation of the decay acceptance*) + + +(* ::Input:: *) +(*BlockAcceptanceComputation[LLP_]:=Module[{},*) +(*nb=EvaluationNotebook[];*) +(*NotebookFind[nb,LLP,All,CellTags];*) +(*SelectionEvaluate[nb]*) +(*]*) +(*Print["List of LLPs:"]*) +(*LLPlistReduced=Join[Select[LLPlist,!MemberQ[{"HNL-mixing-e","HNL-mixing-mu","HNL-mixing-tau","ALP-fermion-no-hadronic-decays"},#]&],{"HNL"}]//Sort*) +(*selectionDialog[list_,phrase_]:=DialogInput[{choice={}},Column[{Row[{phrase}],TogglerBar[Dynamic[choice],list,Appearance->"Vertical"],Button["OK",DialogReturn[choice]]}]]*) +(*Print["List of LLPs for which the acceptance will be computed:"]*) +(*SelectedLLPlistTemp=selectionDialog[Join[LLPlistReduced]//Sort,"Select LLPs for which acceptances will be computed:"]*) +(*SelectedLLPlist=Join[SelectedLLPlistTemp(*,{"Technical"}*)];*) +(*GivenExperimentName=DialogInput[{cut=GivenExperiment},Column[{"Enter the name of the experiment for exporting:",InputField[Dynamic[cut],String],Button["Proceed",DialogReturn[cut],ImageSize->Automatic]}]];*) +(*If[(DirectoryQ["Acceptances"]//ToString)=="False",CreateDirectory["Acceptances"]];*) +(*If[(DirectoryQ[FileNameJoin[{"Acceptances",GivenExperimentName}]]//ToString)=="False",CreateDirectory[FileNameJoin[{"Acceptances",GivenExperimentName}]]];*) +(*(*ChoiceDialog["Choose the LLP for which acceptances will be computed:",Join[LLPlistReduced,{"All"}],Appearance\[Rule]"Vertical"\[Rule]{Automatic,3}]*)*) +(*ivaltest=If[GivenExperiment=="SHiNESS",10^4,1000];*) +(*(*Do[BlockAcceptanceComputation[SelectedLLPlist[[i]]],{i,1,Length[SelectedLLPlist],1}]*)*) + + +(* ::Title::Closed:: *) +(*Chapter to be automatically launched by the previous chapter. No need to launch it manually*) + + +(* ::Chapter::Closed:: *) +(*Scalar*) + + +(* ::Input:: *) +(*If[MemberQ[SelectedLLPlist,"Scalar"]||MemberQ[SelectedLLPlist,"All"],*) +(*dataS=BlockExport["Scalar",ivaltest];//AbsoluteTiming*) +(*]*) + + +(* ::Chapter::Closed:: *) +(*HNL*) + + +(* ::Section::Closed:: *) +(*e mixing*) + + +(* ::Input:: *) +(*If[MemberQ[SelectedLLPlist,"HNL"]||MemberQ[SelectedLLPlist,"All"],*) +(*dataS=BlockExport["HNL-mixing-e",ivaltest];//AbsoluteTiming*) +(*]*) + + +(* ::Section::Closed:: *) +(*\[Mu] mixing*) + + +(* ::Input:: *) +(*If[MemberQ[SelectedLLPlist,"HNL"]||MemberQ[SelectedLLPlist,"All"],*) +(*dataS=BlockExport["HNL-mixing-mu",10^3];//AbsoluteTiming*) +(*]*) + + +(* ::Section::Closed:: *) +(*\[Tau] mixing*) + + +(* ::Input:: *) +(*If[MemberQ[SelectedLLPlist,"HNL"]||MemberQ[SelectedLLPlist,"All"],*) +(*dataS=BlockExport["HNL-mixing-tau",10^3];//AbsoluteTiming*) +(*]*) + + +(* ::Chapter::Closed:: *) +(*Dark photon*) + + +(* ::Input:: *) +(*If[MemberQ[SelectedLLPlist,"DP"]||MemberQ[SelectedLLPlist,"All"],*) +(*dataS=BlockExport["DP",ivaltest];//AbsoluteTiming*) +(*]*) + + +(* ::Chapter::Closed:: *) +(*ALP-fermion*) + + +(* ::Input:: *) +(*If[MemberQ[SelectedLLPlist,"ALP-fermion"]||MemberQ[SelectedLLPlist,"All"],*) +(*dataS=BlockExport["ALP-fermion",ivaltest];//AbsoluteTiming*) +(*]*) + + +(* ::Chapter::Closed:: *) +(*ALP-gluon*) + + +(* ::Input:: *) +(*If[MemberQ[SelectedLLPlist,"ALP-gluon"]||MemberQ[SelectedLLPlist,"All"],*) +(*dataS=BlockExport["ALP-gluon",ivaltest];//AbsoluteTiming*) +(*]*) + + +(* ::Chapter::Closed:: *) +(*ALP-photon*) + + +(* ::Input:: *) +(*If[MemberQ[SelectedLLPlist,"ALP-photon"]||MemberQ[SelectedLLPlist,"All"],*) +(*dataS=BlockExport["ALP-photon",ivaltest];//AbsoluteTiming*) +(*]*) + + +(* ::Chapter::Closed:: *) +(*B-L mediator*) + + +(* ::Input:: *) +(*If[MemberQ[SelectedLLPlist,"B-L"]||MemberQ[SelectedLLPlist,"All"],*) +(*dataS=BlockExport["B-L",ivaltest];//AbsoluteTiming*) +(*]*) + + +(* ::Chapter::Closed:: *) +(*B-3Subscript[L, \[Mu]] mediator*) + + +(* ::Input:: *) +(*If[MemberQ[SelectedLLPlist,"B-3Lmu"]||MemberQ[SelectedLLPlist,"All"],*) +(*dataS=BlockExport["B-3Lmu",ivaltest];//AbsoluteTiming*) +(*]*) + + +(* ::Chapter::Closed:: *) +(*B-3Subscript[L, e]-Subscript[L, \[Mu]]+Subscript[L, \[Tau]] mediator*) + + +(* ::Input:: *) +(*If[MemberQ[SelectedLLPlist,"B-3Le-Lmu+Ltau"]||MemberQ[SelectedLLPlist,"All"],*) +(*dataS=BlockExport["B-3Le-Lmu+Ltau",ivaltest];//AbsoluteTiming*) +(*]*) + + +(* ::Chapter::Closed:: *) +(*B-Subscript[L, e]-3Subscript[L, \[Mu]]+Subscript[L, \[Tau]] mediator*) + + +(* ::Input:: *) +(*If[MemberQ[SelectedLLPlist,"B-Le-3Lmu+Ltau"]||MemberQ[SelectedLLPlist,"All"],*) +(*dataS=BlockExport["B-Le-3Lmu+Ltau",ivaltest];//AbsoluteTiming*) +(*]*) + + +(* ::Title::Closed:: *) +(*Deleting generated cells*) + + +(* ::Input:: *) +(*FrontEndTokenExecute["DeleteGeneratedCells"];*) +(*FrontEndTokenExecute["SelectAll"];*) +(*FrontEndTokenExecute["SelectionCloseAllGroups"];*) + + +(* ::Title::Closed:: *) +(*Some tests*) + + +(* ::Section::Closed:: *) +(*Some tests*) + + +(* ::Subsection::Closed:: *) +(*SHiNESS*) + + +(* ::Subsubsection::Closed:: *) +(*Definitions*) + + +(* ::Input:: *) +(*ENdistrFrom\[Mu][mN_,EN_]=(1/(1.*EN - 4.761904761904762*mN^2 - 0.05249999999999999)^3)**) +(* (Sqrt[(EN^2 - mN^2)*(0.04409999999999999*EN^2 + EN*(-(0.42*mN^2) - 0.004630394999999999) + mN^4 + 0.022049499999999996*mN^2 + 0.00012154511256249997)]**) +(* (2.2399999999999998*EN^4 + EN^3*(-(37.33333333333331*mN^2) - 0.4115986666666664) + EN^2*(203.17460317460308*mN^4 + 5.599993650793649*mN^2 + 0.024695929998412688) + *) +(* EN*(-(362.8117913832198*mN^6) - 22.666666666666657*mN^4 - 0.24990133331065745*mN^2 - 0.00048620249974999755) + 25.396825396825378*mN^6 + 0.5600063492063486*mN^4 + 0.0030870699968253965*mN^2 - *) +(* 3.825065264528859*^-20));*) +(*ENmaxFrom\[Mu][mN_]=(0.105^2+mN^2-(0.5*10^-3)^2)/(0.105*2);*) +(*energysampling=Hold@Compile[{{mN,_Real},{nevents,_Integer}},Module[{enrand,weights},*) +(*enrand=RandomReal[{mN,ENmaxFrom\[Mu][mN]},Max[10^6,nevents]];*) +(*weights=ENdistrFrom\[Mu][mN,enrand];*) +(*RandomChoice[weights->enrand,nevents]*) +(*],CompilationTarget->"C",RuntimeOptions->"Speed",RuntimeAttributes->{Listable},Parallelization->True]/.ruleDown[{ENdistrFrom\[Mu],ENmaxFrom\[Mu]}]//ReleaseHold;*) +(*<"C",RuntimeAttributes->{Listable},RuntimeOptions->"Speed",Parallelization->True]/.ruleDown[{pproductLab1Cart,pproductLab2Cart,pproductLab3Cart,EproductLabCart}]/.ruleOwn[{LengthDataProduct,indexpx1,indexpy1,indexpz1,indexE1,indexm1}]//ReleaseHold;*) +(*\[Alpha]Smearing=Hold@Compile[{{daughtermomenta,_Real,1}},Module[{energy1,energy2,mass1,mass2,px1,px2,py1,py2,pz1,pz2,\[Theta]1,\[Theta]2,\[Phi]1,\[Phi]2,\[Theta]smeared1,\[Theta]smeared2,\[Alpha]Kelly,\[Alpha]My,u1,u2,z1,z2,\[Alpha]Unsmeared},*) +(*energy1=Compile`GetElement[daughtermomenta,indexE1];*) +(*energy2=Compile`GetElement[daughtermomenta,indexm1+indexE1];*) +(*mass1=Compile`GetElement[daughtermomenta,indexm1];*) +(*mass2=Compile`GetElement[daughtermomenta,indexm1+indexm1];*) +(*px1=Compile`GetElement[daughtermomenta,indexpx1];*) +(*py1=Compile`GetElement[daughtermomenta,indexpy1];*) +(*pz1=Compile`GetElement[daughtermomenta,indexpz1];*) +(*px2=Compile`GetElement[daughtermomenta,indexm1+indexpx1];*) +(*py2=Compile`GetElement[daughtermomenta,indexm1+indexpy1];*) +(*pz2=Compile`GetElement[daughtermomenta,indexm1+indexpz1];*) +(*\[Theta]1=\[Theta]Val[px1,py1,pz1];*) +(*\[Theta]2=\[Theta]Val[px2,py2,pz2];*) +(*\[Phi]1=\[Phi]Val[px1,py1];*) +(*\[Phi]2=\[Phi]Val[px1,py1];*) +(*u1=RandomReal[{0,1}];*) +(*u2=RandomReal[{0,1}];*) +(*z1=Sqrt[-2. Log[u1]] Cos[2. Pi u2];*) +(*u1=RandomReal[{0,1}];*) +(*u2=RandomReal[{0,1}];*) +(*z2=Sqrt[-2. Log[u1]] Cos[2. Pi u2];*) +(*\[Theta]smeared1=\[Theta]1+Pi/180.*10*z1;*) +(*\[Theta]smeared2=\[Theta]2+Pi/180.*10*z2;*) +(*u1=RandomReal[{0,1}];*) +(*u2=RandomReal[{0,1}];*) +(*z2=Sqrt[-2. Log[u1]] Cos[2. Pi u2];*) +(*\[Alpha]Kelly=ArcCos[Cos[\[Phi]2-\[Phi]1]Sin[\[Theta]smeared1]Sin[\[Theta]smeared2]+Cos[\[Theta]smeared1]*Cos[\[Theta]smeared2]];*) +(*(*\[Alpha]Kelly=ArcCos[Cos[\[Phi]2-\[Phi]1+Pi/180.*10*z2]Sin[\[Theta]smeared1]Sin[\[Theta]smeared2]+Cos[\[Theta]smeared1]*Cos[\[Theta]smeared2]];*)*) +(*u1=RandomReal[{0,1}];*) +(*u2=RandomReal[{0,1}];*) +(*z2=Sqrt[-2. Log[u1]] Cos[2. Pi u2];*) +(*\[Alpha]Unsmeared=ArcCos[Cos[\[Phi]2-\[Phi]1]Sin[\[Theta]1]Sin[\[Theta]2]+Cos[\[Theta]1]*Cos[\[Theta]2]];*) +(*\[Alpha]My=(*Min[Pi,Max[0.,\[Alpha]Unsmeared+Pi/180.*10*z2]]*)ArcCos[Cos[\[Alpha]Unsmeared+Pi/180.*10*z2]];*) +(*{\[Alpha]Unsmeared,\[Alpha]My,\[Alpha]Kelly}*) +(*],CompilationTarget->"C",RuntimeAttributes->{Listable},RuntimeOptions->"Speed",Parallelization->True]/.ruleDown[{\[Theta]Val,\[Phi]Val}]/.ruleOwn[{indexm1,indexE1,indexpx1,indexpy1,indexpz1}]//ReleaseHold;*) +(*selection=Hold@Compile[{{finaldata,_Real,2},{Ecut,_Real},{\[Theta]cut,_Real},{index,_Integer}},Module[{datasel,len},*) +(*datasel=Select[finaldata,#[[indexE1]]>Ecut&&#[[indexE1+indexm1]]>Ecut&&#[[-index]]>\[Theta]cut&];*) +(*Total[datasel[[All,-4]]]/Total[finaldata[[All,-4]]]*) +(*]*) +(*,CompilationTarget->"C",RuntimeOptions->"Speed",RuntimeAttributes->{Listable},Parallelization->True]/.ruleOwn[{indexE1,indexm1}]//ReleaseHold*) +(*(*\[Theta]\[Phi]Vals=Select[gridLLPtoDet//N//Developer`ToPackedArray,#[[4]]!=0.&][[All,{1,-1}]];*)*) +(*(*\[Theta]\[Phi]Vals={ArcCos[RandomReal[{-1,1},5*10^5]],RandomReal[{-Pi,Pi},5*10^5]}//Transpose;*)*) +(*pts=RandomPoint[DecayVolumeGeometryGivenExperiment,3*10^5];//AbsoluteTiming*) +(*\[Theta]\[Phi]ValsRand=Hold@Compile[{{ptscyl,_Real,1}},Module[{},*) +(*{\[Theta]Val[Compile`GetElement[ptscyl,1],Compile`GetElement[ptscyl,2],Compile`GetElement[ptscyl,3]],\[Phi]Val[Compile`GetElement[ptscyl,1],Compile`GetElement[ptscyl,2]]}*) +(*]*) +(*,CompilationTarget->"C",RuntimeOptions->"Speed",RuntimeAttributes->{Listable},Parallelization->True]/.ruleDown[{\[Theta]Val,\[Phi]Val}]//ReleaseHold*) +(*\[Theta]\[Phi]Vals=\[Theta]\[Phi]ValsRand[pts];//AbsoluteTiming*) + + +(* ::Subsubsection::Closed:: *) +(*Phase space: HNLs, decay products*) + + +(* ::Input:: *) +(*nn=Length[\[Theta]\[Phi]Vals];*) +(*mass=0.02;*) +(*phasespace=PhaseSpacePerDecayChannel["HNL-mixing-mu",mass,"ee\[Nu]",nn,"True"];*) +(*(*\[Theta],\[Phi] for which HNLs would fly to the detector*)*) +(*angles=Take[\[Theta]\[Phi]Vals,{1,nn}];*) +(*(*HNL energies*)*) +(*prod="Fake \[Mu]";*) +(*energies=EnergySampling[prod,mass,nn];*) +(*momenta=Sqrt[energies^2-mass^2]*({Sin[angles[[All,1]]]Cos[angles[[All,2]]],Sin[angles[[All,1]]]Sin[angles[[All,2]]],Cos[angles[[All,1]]]}//Transpose);*) +(*daughtermomenta=boosting[energies,momenta,phasespace,mass];*) +(*Histogram[{daughtermomenta[[All,indexE1]],daughtermomenta[[All,indexE1+indexm1]],daughtermomenta[[All,indexE1]]+daughtermomenta[[All,indexE1+indexm1]]}]*) +(**) + + +(* ::Subsubsection::Closed:: *) +(*Smearing*) + + +(* ::Input:: *) +(*\[Alpha]Vals=\[Alpha]Smearing[daughtermomenta];*) +(*Histogram[{\[Alpha]Vals[[All,1]],\[Alpha]Vals[[All,2]],\[Alpha]Vals[[All,3]]},100,"ProbabilityDensity",Frame-> True,FrameStyle->Directive[Black, 22],PlotRange->All,ImageSize->Large,FrameLabel->{"\[Alpha] [rad]","Fraction"},ChartLegends->Placed[Style[#,18]&/@{"Unsmeared","Smeared \[Alpha]","Smeared \!\(\*SubscriptBox[\(\[Theta]\), \(1, 2\)]\)"},{0.2,0.8}],ChartStyle->{Opacity[.15,Red],Opacity[.15,Blue],Opacity[.3,Darker@Green]},PlotLabel->Style[Row[{prod<>"->N+X, N->ee\[Nu]"}],18,Black]]*) +(*weights=1/Sqrt[energies^2-mass^2](*Sin[angles[[All,1]]]/(Abs[Cos[angles[[All,1]]]]Sqrt[energies^2-mass^2])*)(*Table[1.,Length[angles]]*);*) +(*finaldata=Join[daughtermomenta,Partition[weights,1],\[Alpha]Vals,2];*) +(*{selection[finaldata,0.017,15*Pi/180.,3],selection[finaldata,0.017,15*Pi/180.,2],selection[finaldata,0.017,15*Pi/180.,1],*) +(*selection[finaldata,0.017,0.,3]}*) +(*{selection[finaldata,0.01,15*Pi/180.,3],selection[finaldata,0.01,15*Pi/180.,2],selection[finaldata,0.01,15*Pi/180.,1],*) +(*selection[finaldata,0.01,0.,3]}*) + + +(* ::Subsubsection::Closed:: *) +(*Comparing with Soleti*) + + +(* ::Input:: *) +(*phasespaceSoleti={#[[2]],#[[3]],#[[4]],#[[1]],0.5*10^-3,#[[4+2]],#[[4+3]],#[[4+4]],#[[4+1]],0.5*10^-3}&/@Import[FileNameJoin[{"temp1/shiness/phasespace_0.02.txt"}],"Table"];*) + + +(* ::Input:: *) +(*pt1=Histogram[{daughtermomenta[[All,indexE1]],phasespaceSoleti[[All,indexE1]]},100,"ProbabilityDensity",Frame-> True,FrameStyle->Directive[Black, 22],PlotRange->All,ImageSize->Large,FrameLabel->{"\!\(\*SubscriptBox[\(E\), \(e1\)]\) [GeV]","Fraction"},ChartLegends->Placed[Style[#,18]&/@{"SensCalc","Roberto"},{0.8,0.8}],ChartStyle->{Opacity[.15,Red],Opacity[.15,Blue],Opacity[.3,Darker@Green]},PlotLabel->Style[Row[{prod<>"->N+X, N->ee\[Nu]"}],18,Black]];*) +(*pt2=Histogram[{daughtermomenta[[All,indexm1+indexE1]],phasespaceSoleti[[All,indexm1+indexE1]]},100,"ProbabilityDensity",Frame-> True,FrameStyle->Directive[Black, 22],PlotRange->All,ImageSize->Large,FrameLabel->{"\!\(\*SubscriptBox[\(E\), \(e2\)]\) [GeV]","Fraction"},ChartLegends->Placed[Style[#,18]&/@{"SensCalc","Roberto"},{0.8,0.8}],ChartStyle->{Opacity[.15,Red],Opacity[.15,Blue],Opacity[.3,Darker@Green]},PlotLabel->Style[Row[{prod<>"->N+X, N->ee\[Nu]"}],18,Black]];*) +(*pt3=Histogram[{daughtermomenta[[All,indexE1]]+daughtermomenta[[All,indexm1+indexE1]],phasespaceSoleti[[All,indexm1+indexE1]]+phasespaceSoleti[[All,indexE1]]},100,"ProbabilityDensity",Frame-> True,FrameStyle->Directive[Black, 22],PlotRange->All,ImageSize->Large,FrameLabel->{"\!\(\*SubscriptBox[\(E\), \(e1\)]\)+\!\(\*SubscriptBox[\(E\), \(e2\)]\) [GeV]","Fraction"},ChartLegends->Placed[Style[#,18]&/@{"SensCalc","Roberto"},{0.15,0.8}],ChartStyle->{Opacity[.15,Red],Opacity[.15,Blue],Opacity[.3,Darker@Green]},PlotLabel->Style[Row[{prod<>"->N+X, N->ee\[Nu]"}],18,Black]];*) +(*Style[Row[{pt1,pt2,pt3}],ImageSizeMultipliers->{1, 1,1}]*) +(**) +(**) + + +(* ::Subsection::Closed:: *) +(*Final state multiplicity*) + + +(* ::Input:: *) +(*(*(*Multiplicity per given particle*)*) +(*mtp[mt_]:=Switch[mt,111.,2,310.,2,221.,(2*0.4+6*0.32+4*0.23)/(0.4+0.32+0.23),113.,2,213.,3,331.,2+(2*0.4+6*0.32+4*0.23)/(0.4+0.32+0.23),223.,4,12.,0.,-12.,0,14.,0,-14.,0,16.,0,-16.,0,_,1]*) +(*mtpNoECAL[mt_]:=Switch[mt,111.,2,310.,2,221.,(2*0.4+6*0.32+4*0.23)/(0.4+0.32+0.23),113.,2,213.,3,331.,2+(2*0.4+6*0.32+4*0.23)/(0.4+0.32+0.23),223.,4,12.,0.,-12.,0,14.,0,-14.,0,16.,0,-16.,0,22.,0,130.,0,_,1]*) +(*mtp[210.]*) +(*listphasespaces[LLP_,mLLP_]:=Block[{},procslist=Table[{proc,ListBrRatios[LLP,mLLP,proc],If[ListBrRatios[LLP,mLLP,proc]>10^-3.,If[JetsPresence[LLP,proc]=="Yes",TakingHadronizedPhaseSpace[PhaseSpaceDecaysRestJets[LLP,proc,mLLP],30],{PhaseSpaceDecaysRest[LLP,proc,mLLP,30,"True"]}],{0}]},{proc,ProcessesList[LLP,"True"]}];*) +(*procslist=Select[procslist,#[[2]]>10^-3&];*) +(*multiplicity[i_]:=Module[{},*) +(*Do[*) +(*DATA[j]=procslist[[i]][[3]][[j]];*) +(*len[j]=Length[DATA[j]];*) +(*numparts=Length[DATA[j][[1]]]/8;*) +(*pdgpos=Table[8*(m-1)+6,{m,1,numparts,1}];*) +(*pdgs=DATA[j][[All,pdgpos]][[1]];*) +(*mtpval[j]=Sum[mtp[pdgs[[m]]],{m,1,Length[pdgs],1}];*) +(*mtpNoECALval[j]=Sum[mtpNoECAL[pdgs[[m]]],{m,1,Length[pdgs],1}];*) +(*,{j,1,Length[procslist[[i]][[3]]],1}];*) +(*{Sum[len[j]*mtpval[j],{j,1,Length[procslist[[i]][[3]]],1}]/Sum[len[j],{j,1,Length[procslist[[i]][[3]]],1}],Sum[len[j]*mtpNoECALval[j],{j,1,Length[procslist[[i]][[3]]],1}]/Sum[len[j],{j,1,Length[procslist[[i]][[3]]],1}]}*) +(*];*) +(*list=Sum[procslist[[i]][[2]]multiplicity[i],{i,1,Length[procslist],1}]/Sum[procslist[[i]][[2]],{i,1,Length[procslist],1}]*) +(*]*) +(*mulslist[LLP_]:=Block[{},*) +(*ttt2=Table[{mLLPlist[LLP][[k]],listphasespaces[LLP,mLLPlist[LLP][[k]]]},{k,1,Length[mLLPlist[LLP]],1}];*) +(*{Table[{ttt2[[i]][[1]],ttt2[[i]][[2]][[1]]},{i,1,Length[ttt2],1}],Table[{ttt2[[i]][[1]],ttt2[[i]][[2]][[2]]},{i,1,Length[ttt2],1}]}*) +(*]*) +(*fipsformult={"Scalar","HNL-mixing-e","ALP-gluon"};*) +(*multlist=Table[mulslist[LLP],{LLP,fipsformult}];*) +(*Show[ListPlot[{multlist[[1]][[1]],multlist[[1]][[2]],multlist[[2]][[1]],multlist[[2]][[2]],multlist[[3]][[1]],multlist[[3]][[2]]},Joined->True,PlotStyle->{{Thick,Blue},{Thick,Blue,Dashing[0.02]},{Thick,Darker@Red},{Thick,Darker@Red,Dashing[0.02]},{Thick,Darker@Darker@Green},{Thick,Darker@Darker@Green,Dashing[0.02]}},Frame\[Rule] True,FrameLabel\[Rule]{"Subscript[m, LLP] [GeV]" , "Subscript[n, per decay]"},FrameStyle\[Rule]Directive[Black, 23],ImageSize->Large,PlotRange\[Rule]{{0.05,4.5},{1,12}},PlotLabel\[Rule]Style[Row[{"Dashed: charged only. Solid: incl. \[Gamma],Subscript[K^0, L]"}],18,Black]],Plot[{0.9,0.9,0.9,0.9,0.9},{x,0,1},PlotStyle->{{Thick,Blue},{Thick,Darker@Red},{Thick,Darker@Darker@Green}},PlotLegends\[Rule]Placed[Style[#,18]&/@fipsformult,{0.24,0.8}]]]*)*) + + +(* ::Subsection::Closed:: *) +(*In the limit Subscript[E, LLP]/Subscript[m, LLP] >> 1 and in absence of energy cut and magnetic field etc ., Subscript[\[Epsilon], decay] must tend to 1 for the LLPs pointing to the detector and to 0 for those that do not point to the detector*) + + +(* ::Input:: *) +(*(*mtest=1.9;*) +(*LLPtest="Scalar";*) +(*test1=FinalBlockMass[LLPtest,mtest,ProcessesListRefined[LLPtest,ECALoptionGivenExperiment],1000,"True",">=2"];//AbsoluteTiming*) +(*{TableAzDecayAcceptanceToDet[[All,5]]//Mean,Select[TableAzDecayAcceptanceToDet,#[[2]]>40&][[All,5]]//Mean,Select[TableAzDecayAcceptanceToDet,#[[2]]>40&&#[[4]]!=0&][[All,5]]//Mean}*) +(*If[DecayVolumeAsDetectorGivenExperiment\[Equal]"False",TableAzDecayAcceptanceNotToDet[[All,5]]//Mean]*) +(*hist1=Histogram[Select[TableAzDecayAcceptanceToDet,#[[2]]>50*mtest&&#[[4]]!=0&][[All,5]],100]*) +(*hist2=If[DecayVolumeAsDetectorGivenExperiment\[Equal]"False",Histogram[Select[TableAzDecayAcceptanceNotToDet,#[[2]]>10*mtest&&#[[4]]!=0&][[All,5]],100]]*)*) diff --git a/wls/2. LLP distribution.wls b/wls/2. LLP distribution.wls new file mode 100755 index 0000000..4124788 --- /dev/null +++ b/wls/2. LLP distribution.wls @@ -0,0 +1,3031 @@ +#!/usr/bin/env wolframscript +(* ::Package:: *) + +(* ::Title::Closed:: *) +(*Launch this section to run the notebook*) + + +(* ::Input:: *) +(*ClearAll["Global`*"]*) +(*ParallelEvaluate[ClearAll["Global`*"]];*) +(*CloseKernels[];*) +(*LaunchKernels[];*) +(*FrontEndTokenExecute["SelectAll"]*) +(*FrontEndTokenExecute["SelectionCloseAllGroups"]*) +(*nb=EvaluationNotebook[];*) +(*NotebookFind[nb,"Evaluation",All,CellTags];*) +(*SelectionEvaluate[nb]*) + + +(* ::Title::Closed:: *) +(*Preliminary code: various definitions*) + + +(* ::Chapter::Closed:: *) +(*Creating relevant directories and critical definitions*) + + +(* ::Input:: *) +(*SetAttributes[ruleDown,HoldAll];*) +(*ruleDown[list_]:=Flatten[DownValues/@(Unevaluated@list)]*) +(*SetAttributes[ruleOwn,HoldAll];*) +(*ruleOwn[list_]:=Flatten[OwnValues/@(Unevaluated@list)]*) +(*<EcmFacility[Facility],0,1];*) +(*,{Facility,FacilitiesList}]*) +(*,{particle,SMparticles}]*) +(*Do[If[fbtobc[Facility]==0.,IfSMatFacility["Bc",Facility]=0],{Facility,FacilitiesList}]*) +(*Print["List of facilities:"]*) +(*Join[{{"Facility","Sqrt[s], GeV"}},{#,EmaxFacility[#]}&/@FacilitiesList]*) +(**) + + +(* ::Section::Closed:: *) +(*Loading kinematics*) + + +(* ::Input:: *) +(*Inactivate[Quiet[NotebookEvaluate[FileNameJoin[{NotebookDirectory[],"codes/kinematics.nb"}]]],Print];*) + + +(* ::Title::Closed:: *) +(*Preliminary code: mother particles sampling*) + + +(* ::Chapter::Closed:: *) +(*Importing tabulated mother particles distributions*) + + +(* ::Input:: *) +(*(*List all files matching the distribution name pattern*)*) +(*files=FileNames["DoubleDistr_*_*.txt",FileNameJoin[{NotebookDirectory[],"spectra/SM particles"}],Infinity];*) +(*(*Extracting the information about the facility and particle from the filename*)*) +(*extractData[filename_]:=StringCases[FileNameTake[filename],"DoubleDistr_"~~facility:(Shortest[___])~~"_"~~particle:(ShortestMatch[___])~~".txt":>{facility,particle}][[1]]*) +(*(*Extract, pairs and remove duplicates*)*) +(*dataPairs=extractData[#]&/@files;*) +(*(*Sort the pairs by Facility*)*) +(*sortedDataPairs=SortBy[dataPairs,{#[[1]],#[[2]]}&];*) +(*(*Importing all the distributions*)*) +(*MotherImportingBlock[Facility_,Particle_]:=Block[{},*) +(*filenameimport=ToString@StringForm["DoubleDistr_``_``.txt",Sequence@@{Facility,Particle}];*) +(*dataimport=Import[FileNameJoin[{NotebookDirectory[],"spectra/SM particles",filenameimport}],"Table"]*) +(*]*) +(*Do[DataDistr[sortedDataPairs[[i]][[1]],sortedDataPairs[[i]][[2]]]=MotherImportingBlock[sortedDataPairs[[i]][[1]],sortedDataPairs[[i]][[2]]],{i,1,Length[sortedDataPairs]}]//AbsoluteTiming*) +(*sortedDataPairs=SortBy[Join[sortedDataPairs,Table[{Facility,"p"},{Facility,FacilitiesList}],{{"ESS","PiCharged"},{"ESS","mu"}}],{#[[1]],#[[2]]}&];*) +(*(*In case some of the distributions are absent, the notebook will replace them with the distribution of the "similar" particle*)*) +(*SimilarParticle["FCC-hh","Bc"]=SimilarParticle["LHC","Bc"]=SimilarParticle["SPS","Bc"]=SimilarParticle["FermilabBD","Bc"]="Bplus";*) +(*SimilarParticle["FCC-hh","B0"]=SimilarParticle["LHC","B0"]=SimilarParticle["SPS","B0"]=SimilarParticle["FermilabBD","B0"]="Bplus";*) +(*SimilarParticle["FCC-hh","Bs"]=SimilarParticle["LHC","Bs"]=SimilarParticle["SPS","Bs"]=SimilarParticle["FermilabBD","Bs"]="Bplus";*) +(*SimilarParticle["FCC-hh","tau"]=SimilarParticle["LHC","tau"]=SimilarParticle["SPS","tau"]=SimilarParticle["FermilabBD","tau"]="Ds";*) +(*SimilarParticle["FCC-hh","D0"]=SimilarParticle["FCC-hh","Ds"]="Dplus";*) + + +(* ::Chapter::Closed:: *) +(*Sampling 4-momenta of mother particles from tabulated distribution*) + + +(* ::Section::Closed:: *) +(*Preliminary definitions*) + + +(* ::Subsection::Closed:: *) +(*Quick mapping the data {x,y,f[x,y]} ->{x',y',f[x',y']} for some structured grids {x,y} and {x', y'}*) + + +(* ::Input:: *) +(*nd=2;*) +(*cf2=Module[{xgvars=Unique["xg"]&/@slist@@Range@nd,igvars=Unique["ig"]&/@slist@@Range@nd,tgvars=Unique["tg"]&/@slist@@Range@nd,ivars=Unique["i"]&/@slist@@Range@nd,svars=Unique["s"]&/@slist@@Range@nd,tvars=Unique["t"]&/@slist@@Range@nd,jvars=Unique["j"]&/@slist@@Range@nd},Inactivate[Compile[{seq@{xgvars,_Real,1},{y,_Real,nd}},Module[{seq@igvars,seq@tgvars,seq@ivars,seq@svars,seq@tvars},seq[igvars=Floor[xgvars]-UnitStep[xgvars-indexed@Dimensions@y]];*) +(*seq[tgvars=xgvars-igvars];*) +(*Table[seq[tvars=Compile`GetElement[tgvars,jvars]];*) +(*seq[ivars=Compile`GetElement[igvars,jvars]];*) +(*seq[svars=1.-tvars];*) +(*eval@Total[Times@@#[[All,1]] Compile`GetElement[y,Sequence@@#[[All,2]]]&/@Tuples@Transpose[{{svars,ivars},{tvars,ivars+1}},{2,3,1}]],seq@{jvars,Length@igvars}]],CompilationTarget->"C",RuntimeAttributes->{Listable},Parallelization->True,RuntimeOptions->"Speed"],Except[seq|eval|indexed]]/.seq[expr_]:>RuleCondition@(Sequence@@Table[Inactivate[expr,Except[slist|indexed]]/.{l_slist:>l[[i]],indexed[l_]:>Inactive[Compile`GetElement][l,i]},{i,nd}])/.eval@expr_:>RuleCondition[Activate[expr/.slist->List]]]//Activate;*) + + +(* ::Subsection::Closed:: *) +(*Compiled linear interpolations - for mapping from {x,y,f[x,y]} to {Subscript[x, random],Subscript[y, random],f[Subscript[x, random],Subscript[y, random]]}*) + + +(* ::Input:: *) +(*(*Random Log[\[Theta]] points, random Log[E] points, *)*) +(*linint2=Compile[{{rand\[Theta]log,_Real},{randElog,_Real},{grid\[Theta]log,_Real,1},{gridElog,_Real,1},{index\[Theta],_Integer},{indexE,_Integer},{distrlog,_Real,2}},Module[{\[Theta]el,Eel,x1,x2,y1,y2,z11,z21,z12,z22,\[CapitalDelta],indexlarger\[Theta],indexlargerE,lenE},*) +(*(*Finding the index of the grids with the elements larged than the given random point*)*) +(*\[Theta]el=Compile`GetElement[grid\[Theta]log,index\[Theta]];*) +(*indexlarger\[Theta]=index\[Theta]+UnitStep[rand\[Theta]log-\[Theta]el];*) +(*Eel=Compile`GetElement[gridElog,indexE];*) +(*indexlargerE=indexE+UnitStep[randElog-Eel];*) +(*(*The two points x1, x2 with x1 < x < x2*)*) +(*x1=Compile`GetElement[grid\[Theta]log,indexlarger\[Theta]-1];*) +(*x2=Compile`GetElement[grid\[Theta]log,indexlarger\[Theta]];*) +(*y1=Compile`GetElement[gridElog,indexlargerE-1];*) +(*y2=Compile`GetElement[gridElog,indexlargerE];*) +(*(*Corresponding values of the function*)*) +(*lenE=Length[gridElog];*) +(*z11=Compile`GetElement[distrlog,(indexlarger\[Theta]-2)*lenE+indexlargerE-1,3];*) +(*z21=Compile`GetElement[distrlog,(indexlarger\[Theta]-1)*lenE+indexlargerE-1,3];*) +(*z12=Compile`GetElement[distrlog,(indexlarger\[Theta]-2)*lenE+indexlargerE,3];*) +(*z22=Compile`GetElement[distrlog,(indexlarger\[Theta]-1)*lenE+indexlargerE,3];*) +(*\[CapitalDelta]=(x2-x1)(y2-y1);*) +(*Exp[(*{rand\[Theta]log,x1,x2,randElog,y1,y2,z11,z21,z12,z22,*)((x2-rand\[Theta]log)*(y2-randElog))/\[CapitalDelta]*z11+((rand\[Theta]log-x1)*(y2-randElog))/\[CapitalDelta] z21+((x2-rand\[Theta]log)(randElog-y1))/\[CapitalDelta]*z12+((rand\[Theta]log-x1)(randElog-y1))/((x2-x1)(y2-y1)) z22(*}*)]*) +(*],CompilationTarget->"C",RuntimeOptions->"Speed",RuntimeAttributes->{Listable},Parallelization->True]*) +(*<"C",RuntimeOptions->"Speed",RuntimeAttributes->{Listable},Parallelization->True]*) +(*<10^-30.,*) +(*tot=\[Theta]summed[[All,2]]//Total;*) +(*accum=(tot-Accumulate[\[Theta]summed[[All,2]]])/tot;*) +(*sel=Select[accum,#>=10^-order&];*) +(*If[Length[sel]!=0.,*) +(*emaxpos=Min[Position[accum,sel[[-1]]][[1]][[1]]+1,Length[accum]];*) +(*emaxval=\[Theta]summed[[emaxpos]][[1]],*) +(*emaxval=\[Theta]summed[[1]][[1]]]];*) +(*emaxval*) +(*]*) +(*DataLogarithmiedComp=Compile[{{data,_Real,1}},{Log[Compile`GetElement[data,1]],Log[Compile`GetElement[data,2]],If[Compile`GetElement[data,3]==0,Log[10^-90.],Log[Compile`GetElement[data,3]]]},CompilationTarget->"C",RuntimeOptions->"Speed",RuntimeAttributes->{Listable}];*) +(*Do[*) +(*\[Theta]gridForEmax[fac]={10^-5.,10^-4.,0.001,0.005,0.008,0.01,0.02,0.03,0.04,0.06,0.08,0.1,0.11,0.12,0.13,0.15,0.17,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9,1.,1.2,1.3,Pi/2}//N;*) +(*If[fac=="LHC",\[Theta]gridForEmax[fac]=Join[\[Theta]gridForEmax[fac],{3*10^-4.,6*10^-4.,2*10^-3,3*10^-3,4*10^-3,6*10^-3,7*10^-3,9*10^-3.,0.011,0.013,0.016,0.018,0.022,0.024,0.027,0.033,0.036,0.045,0.05,0.07,0.09}//N]//Sort//DeleteDuplicates];*) +(*If[fac=="FCC-hh",\[Theta]gridForEmax[fac]=Join[\[Theta]gridForEmax[fac],{5*10^-5.,2*10^-4.,4*10^-4.,6*10^-4.,8*10^-4.,2*10^-3,3*10^-3,4*10^-3.}//N]//Sort//DeleteDuplicates];*) +(*,{fac,FacilitiesList}];*) +(*FindingEmax\[Theta][data_,Facility_,order_]:=Module[{(*\[Theta]minmax,eminmax,GridIn,distrv,GridOut,xigDistr,distrvals,mappeddistr,\[Theta]emax,emax,\[Theta]ranges,distrdatalog*)},*) +(*IfCollider=MemberQ[{"LHC","FCC-hh"},Facility];*) +(*distrdatalog=DataLogarithmiedComp[data];*) +(*GridIn=(DeleteDuplicates[distrdatalog[[All,#]]]&/@{1,2})//N;*) +(*distrv=ArrayReshape[distrdatalog[[All,3]],{Length[GridIn[[1]]],Length[GridIn[[2]]]}];*) +(*{\[Theta]minmax,eminmax}=MinMax[data[[All,#]]]&/@{1,2};*) +(*\[Theta]ranges=If[IfCollider,Select[\[Theta]gridForEmax[Facility],\[Theta]minmax[[1]]<=#&],Select[Flatten[Join[{#,Pi-#}&/@Join[\[Theta]gridForEmax[Facility],{\[Theta]minmax[[2]]}]]]//N//Sort//DeleteDuplicates,\[Theta]minmax[[1]]<=#<=\[Theta]minmax[[2]]&]]//N;*) +(*\[Theta]emax={{}};*) +(*Do[*) +(*nintervals=If[\[Theta]ranges[[i+1]]-\[Theta]ranges[[i]]>10^-3,10,3];*) +(*GridOut={Table[th,{th,\[Theta]ranges[[i]],\[Theta]ranges[[i+1]],(\[Theta]ranges[[i+1]]-\[Theta]ranges[[i]])/nintervals}],Join[Table[Exp[e],{e,Log[eminmax[[1]]],Log[eminmax[[2]]],Max[0.1,(Log[eminmax[[2]]]-Log[eminmax[[1]]])/100]}],{eminmax[[2]]}]//DeleteDuplicates}//Log;*) +(*xigDistr=MapThread[Interpolation[Transpose@{#,Range@Length@#},InterpolationOrder->1][#2]&,{GridIn,GridOut}];*) +(*distrvals=Flatten@cf2[Sequence@@xigDistr,distrv];*) +(*mappeddistr=Exp[Join[Tuples[GridOut],Partition[distrvals,1],2]];*) +(*emax=FindingMaxEnergy[mappeddistr,order];*) +(*\[Theta]emax=Join[\[Theta]emax,{{(\[Theta]ranges[[i]]+\[Theta]ranges[[i+1]])/2,emax}}];*) +(*,{i,1,Length[\[Theta]ranges]-1,1}];*) +(*\[Theta]emax=Drop[\[Theta]emax,1];*) +(*\[Theta]emax=Log[If[IfCollider,Flatten[Join[{#,{Pi-#[[1]],#[[2]]}&/@#}&/@{Join[{{\[Theta]minmax[[1]],\[Theta]emax[[1]][[2]]}},\[Theta]emax]}][[1]],1],Join[{{\[Theta]minmax[[1]],\[Theta]emax[[1]][[2]]}},\[Theta]emax,{{\[Theta]minmax[[2]],\[Theta]emax[[-1]][[2]]}}]]//Sort//DeleteDuplicates//N]*) +(*]*) + + +(* ::Section::Closed:: *) +(*Sampling points*) + + +(* ::Input:: *) +(*erandcomp=Compile[{{eminv,_Real},{emaxv,_Real},{Nev,_Integer}},Log[RandomReal[{Exp[eminv],Exp[emaxv]}]],CompilationTarget->"C",RuntimeOptions->"Speed",RuntimeAttributes->{Listable}]//ReleaseHold;*) +(*MotherDataCompiled=Compile[{{Events,_Real,1},{m,_Real}},Module[{thv,ev,\[Phi]v,pv},*) +(*thv=Compile`GetElement[Events,1];*) +(*ev=Compile`GetElement[Events,2];*) +(*\[Phi]v=RandomReal[{-Pi,Pi}];*) +(*pv=Sqrt[ev^2-m^2];*) +(*{pv*Cos[\[Phi]v]*Sin[thv],pv*Sin[\[Phi]v]*Sin[thv],pv*Cos[thv],ev,m}*) +(*],CompilationTarget->"C",RuntimeOptions->"Speed",RuntimeAttributes->{Listable},Parallelization->True]*) +(*BlockPointsFromSmoothDistribution1[data_,m_,Nevents_,order_,Facility_]:=Module[{Emaxlist,\[Theta]minmax,Data\[Phi],Nev,eminmax,NevSampl},*) +(*IfCollider=MemberQ[{"LHC","FCC-hh"},Facility];*) +(*distrdatalog=DataLogarithmiedComp[data];*) +(*GridIn=(DeleteDuplicates[distrdatalog[[All,#]]]&/@{1,2})//N;*) +(*\[Theta]minmax=({Min[#],If[IfCollider,Pi/2.,Max[#]]}&/@{data[[All,1]]})[[1]];*) +(*emin=Log[Min[data[[All,2]]]];*) +(*(*Computing table Subscript[E, max](\[Theta])*)*) +(*Nev=If[!IfCollider,Nevents,IntegerPart[Nevents/2]];*) +(*NevSampl=Max[3*Nev,10^6];*) +(*\[Theta]emaxdata=FindingEmax\[Theta][data,Facility,order];*) +(*(*__________________________________*)*) +(*(*Generating the grid of Subscript[\[Theta], rand],Subscript[E, rand]*)*) +(*(*__________________________________*)*) +(*(*Generating random \[Theta]*)*) +(*\[Theta]rand=Log[RandomReal[\[Theta]minmax,NevSampl]];*) +(*(*For each \[Theta], generaring random E\[Element]{Subscript[E, min],Subscript[E, max](\[Theta])}*)*) +(*nf\[Theta]Emaxlog=Nearest[\[Theta]emaxdata[[All,1]]->"Index"];*) +(*index\[Theta]Emaxlog=nf\[Theta]Emaxlog[\[Theta]rand]//Flatten;*) +(*emaxrand=linint1[\[Theta]rand,\[Theta]emaxdata[[All,1]],index\[Theta]Emaxlog,\[Theta]emaxdata];*) +(*erand=erandcomp[emin,emaxrand,NevSampl];*) +(*(*Now, calculating the weights for the generated Subscript[\[Theta], rand],Subscript[E, rand]*)*) +(*nf\[Theta]log=Nearest[GridIn[[1]]->"Index"];*) +(*nfElog=Nearest[GridIn[[2]]->"Index"];*) +(*{index\[Theta]rand,indexerand}={nf\[Theta]log[\[Theta]rand]//Flatten,nfElog[erand]//Flatten};*) +(*weights=(Exp[emaxrand]-Exp[emin])*linint2[\[Theta]rand,erand,GridIn[[1]],GridIn[[2]],index\[Theta]rand,indexerand,distrdatalog];*) +(*(*Generating "True" \[Theta],E based on the weights*)*) +(*PTS=RandomChoice[weights->Transpose[Exp[{\[Theta]rand,erand}]],Nev];*) +(*motherdata=MotherDataCompiled[PTS,m];*) +(*If[IfCollider,*) +(*motherdataExtended=motherdata;*) +(*motherdataExtended[[All,3]]=-motherdataExtended[[All,3]];*) +(*motherdata=Join[motherdata,motherdataExtended]];*) +(*If[Length[motherdata]!=Nevents,motherdata=Join[motherdata,{motherdata[[-1]]}]]//Developer`ToPackedArray;*) +(*motherdata*) +(*]*) +(*DataConverted=Compile[{{data,_Real,1},{m,_Real}},Module[{px,py,pz,e},*) +(*px=Compile`GetElement[data,1];*) +(*py=Compile`GetElement[data,2];*) +(*pz=Compile`GetElement[data,3];*) +(*e=Sqrt[px^2+py^2+pz^2+m^2];*) +(*{px,py,pz,e,m}],CompilationTarget->"C",RuntimeOptions->"Speed",RuntimeAttributes->{Listable},Parallelization->True]*) + + +(* ::Chapter::Closed:: *) +(*Interpolation and phase space sampling*) + + +(* ::Section::Closed:: *) +(*Phase space sampling*) + + +(* ::Input:: *) +(*MotherInterpolation[Facility_,Particle_]:=Module[{data,datalog},*) +(*data=DataDistr[Facility,Particle];*) +(*datalog=DataLogarithmiedComp[data];*) +(*\[Theta]MinMax[Facility,Particle]=MinMax[data[[All,1]]];*) +(*Emax[\[Theta]X_,Facility,Particle]=Interpolation[FindingEmax\[Theta][DataDistr[Facility,Particle],Facility,7],InterpolationOrder->1][Log[\[Theta]X]]//Exp;*) +(*DoubleDistrMotherInt[\[Theta]X_,EX_,Facility,Particle]=If[mSM[Particle]<=EX<=Emax[\[Theta]X,Facility,Particle]&&\[Theta]MinMax[Facility,Particle][[1]]<=\[Theta]X<=\[Theta]MinMax[Facility,Particle][[2]],Evaluate[Exp[Interpolation[datalog,InterpolationOrder->1][Log[\[Theta]X],Log[EX]]]],0.];*) +(*]*) +(*MotherInterpolation["LHC","Upsilon"];*) +(*IfMotherInterpolated[Facility_,Mother_]:=MemberQ[{Keys[DownValues@DoubleDistrMotherInt][[All,1,-2]],Keys[DownValues@DoubleDistrMotherInt][[All,1,-1]]}//Transpose,{Facility,Mother}]*) +(*{IfMotherInterpolated["LHC","Upsilon"],IfMotherInterpolated["SPS","Kplus"]}*) +(*PointsSampler[Facility_,Particle_,Nevents_,IfTwo_]:=Module[{data,Nev,IfPresent,particle,motherpoints,datafin},*) +(*(*For the moment, for some distributions that are absent, they will be approximated by the distributions of similar particles*)*) +(*If[Facility=="ESS"&&MemberQ[{"PiCharged","mu"},Particle],*) +(*datafin=ConstantArray[{0.,0.,0.,mSM[Particle],mSM[Particle]},Nevents]*) +(*,*) +(*IfPresent=If[Length[DataDistr[Facility,Particle]]==2,"False","True"];*) +(*particle=If[IfPresent=="True",Particle,SimilarParticle[Facility,Particle]];*) +(*data=DataDistr[Facility,particle];*) +(*(*Option IfTwo: if "True", then the mother particle is supposed to decay into two LLPs. If "False", then it will produce only one LLP*)*) +(*(*If "True", then Subscript[N, events]/2 mother particles will be sampled, and then the data will be doubled*)*) +(*Nev=If[IfTwo=="True",Nevents/2,Nevents];*) +(*datafin=BlockPointsFromSmoothDistribution1[data,mSM[particle],Nev,9,Facility];*) +(*If[IfTwo=="True",datafin=Riffle[datafin,datafin]];*) +(*If[particle!=Particle,datafin=DataConverted[datafin,mSM[Particle]],datafin];*) +(*];*) +(*datafin*) +(*]*) + + +(* ::Section::Closed:: *) +(*Test*) + + +(* ::Input:: *) +(*(*factest="Serpukhov";*) +(*ptest="EtaPr";*) +(*If[Length[DataDistr[factest,ptest]]!=2,*) +(*pts=PointsSampler[factest,ptest,10^6,"False"];*) +(*MotherInterpolation[factest,ptest];*) +(*angdistrIntDat=With[{thmin=\[Theta]MinMax[factest,ptest][[1]],thmax=\[Theta]MinMax[factest,ptest][[2]]},ParallelTable[{10^x,Quiet[NIntegrate[DoubleDistrMotherInt[10^x,Exp[e],factest,ptest]Exp[e],{e,Log[pts[[All,4]]//Min],Log[pts[[All,4]]//Max]},Method->"InterpolationPointsSubdivision"]]},{x,Log10[thmin],Log10[thmax],(Log10[thmax]-Log10[thmin])/100}]];*) +(*angdistrInt[\[Theta]X_]=Interpolation[angdistrIntDat,InterpolationOrder->1][\[Theta]X];*) +(*norm1=NIntegrate[angdistrInt[Exp[x]]Exp[x],{x,Log[Min[PTS[[All,1]]]],Log[Max[PTS[[All,1]]]]},Method->"InterpolationPointsSubdivision"];*) +(*thvs=\[Theta]Nlist[factest];*) +(*angles=PTS[[All,1]];*) +(*bns=BinCounts[angles,{thvs}];*) +(*tabpdf=Table[{Log[(thvs[[i]]+thvs[[i+1]])/2],Log[Max[10^-90.,bns[[i]]/(thvs[[i+1]]-thvs[[i]])]]},{i,1,Length[thvs]-1,1}];*) +(*pdfint[x_]=If[Min[PTS[[All,1]]]<=x<=Max[PTS[[All,1]]],Evaluate[Exp[Interpolation[tabpdf,InterpolationOrder->1][Log[x]]]],0.];*) +(*norm2=Quiet[NIntegrate[pdfint[Exp[x]]Exp[x],{x,Log[Min[PTS[[All,1]]]],Log[Max[PTS[[All,1]]]]},Method->"InterpolationPointsSubdivision"]];*) +(*]//AbsoluteTiming*) +(*Quiet[{NIntegrate[pdfint[x]x,{x,10^-5,Pi/2}]/NIntegrate[pdfint[x],{x,10^-5,Pi/2}],NIntegrate[angdistrInt[Exp[x]]Exp[2x],{x,Log[Min[PTS[[All,1]]]],Min[Pi/2,Log[Max[PTS[[All,1]]]]]}]/NIntegrate[angdistrInt[Exp[x]],{x,Log[Min[PTS[[All,1]]]],Min[Pi/2,Log[Max[PTS[[All,1]]]]]}]}]*) +(*Quiet[LogLogPlot[{1/norm1angdistrInt[x]/x,1/norm2pdfint[x]/x},{x,10^-5.,Pi/2}]]*)*) + + +(* ::Title::Closed:: *) +(*Preliminary code: LLP production phenomenology*) + + +(* ::Chapter::Closed:: *) +(*Preliminary definitions*) + + +(* ::Section::Closed:: *) +(*Kinematics of 3-body decays in terms of energies Subscript[E, 1],Subscript[E, 3]*) + + +(* ::Input:: *) +(*(*Kinematics of 3-body decays*)*) +(*pPar[En_,mn_]=\[Sqrt](En^2-mn^2);*) +(*E2valEnergies[m_,E1_,E3_]=m-E1-E3;*) +(*(*cos between particles 1,2 and 1,3 at rest frame of decaying particle 0 \[Rule] 1+2+3 parametrized in terms of Subscript[E, 1],Subscript[E, 3]*)*) +(*(*For example, cos(Subscript[\[Theta], 12]) = ((Subscript[Overscript[p, _], 1]*Subscript[Overscript[p, _], 2])/(|Subscript[p, 1]||Subscript[p, 2]|)). We have Subscript[Overscript[p, _], 1]+Subscript[Overscript[p, _], 2]+Subscript[Overscript[p, _], 3] = 0, or Subscript[Overscript[p, _]^2, 1]+Subscript[Overscript[p, _]^2, 2]+2Subscript[Overscript[p, _], 1]*Subscript[Overscript[p, _], 2] = Subscript[Overscript[p, _]^2, 3] = Subscript[E^2, 3]-Subscript[m^2, 3]*)*) +(*cos\[Theta]12[E1_,E3_,m_,m1_,m2_,m3_]=(pPar[E3,m3]^2-pPar[E1,m1]^2-pPar[E2valEnergies[m,E1,E3],m2]^2)/(2pPar[E1,m1]*pPar[E2valEnergies[m,E1,E3],m2]);*) +(*cos\[Theta]13[E1_,E3_,m_,m1_,m2_,m3_]=(pPar[E2valEnergies[m,E1,E3],m2]^2-pPar[E1,m1]^2-pPar[E3,m3]^2)/(2pPar[E1,m1]*pPar[E3,m3]);*) +(*\[Theta]12[E1_,E3_,m_,m1_,m2_,m3_]=ArcCos[cos\[Theta]12[E1,E3,m,m1,m2,m3]];*) +(*\[Theta]13[E1_,E3_,m_,m1_,m2_,m3_]=ArcCos[cos\[Theta]13[E1,E3,m,m1,m2,m3]];*) +(*(*Domain of definition of Subscript[E, 1] and Subscript[E, 3] in decay 0\[Rule]1+2+3 at rest frame of 0*)*) +(*E3domain[E1_,m_,m1_,m2_,m3_]=E3/.Simplify[Solve[cos\[Theta]12[E1,E3,m,m1,m2,m3]==1,E3]]*) +(*E3domain1[E1_,m_,m1_,m2_,m3_]=E3domain[E1,m,m1,m2,m3][[1]];*) +(*E3domain2[E1_,m_,m1_,m2_,m3_]=E3domain[E1,m,m1,m2,m3][[2]];*) +(*\[CapitalDelta]E3[E1_,m_,m1_,m2_,m3_]=E3domain2[E1,m,m1,m2,m3]-E3domain1[E1,m,m1,m2,m3]//Simplify*) +(*{E1domainMin[m_,m1_,m2_,m3_],E1domainMax[m_,m1_,m2_,m3_]}=E1domain[m_,m1_,m2_,m3_]={E1/.Solve[\[CapitalDelta]E3[E1,m,m1,m2,m3]==0,E1][[2]],E1/.Solve[\[CapitalDelta]E3[E1,m,m1,m2,m3]==0,E1][[3]]}//Simplify*) +(*(*Domain of definition of Subscript[E, 1] and Subscript[E, 3] in decay 0\[Rule]1+2+3 at rest frame of 0 - Subscript[E, 3] is main function*)*) +(*E1domain1[E3_,m_,m1_,m2_,m3_]=E1/.Simplify[Solve[cos\[Theta]12[E1,E3,m,m1,m2,m3]==1,E1]]//Simplify*) +(*E3domain1[m_,m1_,m2_,m3_]={E3/.Solve[E1domain1[E3,m,m1,m2,m3][[1]]-E1domain1[E3,m,m1,m2,m3][[2]]==0,E3][[2]],E3/.Solve[E1domain1[E3,m,m1,m2,m3][[1]]-E1domain1[E3,m,m1,m2,m3][[2]]==0,E3][[3]]}//Simplify*) +(*(*Mandelstam invariants Subscript[m, ij] = (Subscript[p, i]+Subscript[p, j])^2 in terms of Subscript[E, 1],Subscript[E, 3]*)*) +(*M13[E1_,E3_]=(E1+E3)^2-(pPar[E1,m1]^2+pPar[E3,m3]^2+2*pPar[E1,m1]*pPar[E3,m3]*cos\[Theta]13[E1,E3,m,m1,m2,m3])//Expand//Simplify*) +(*M12[E1_,E3_]=(E1+E2valEnergies[m,E1,E3])^2-(pPar[E1,m1]^2+pPar[E2valEnergies[m,E1,E3],m2]^2+2*pPar[E1,m1]*pPar[E2valEnergies[m,E1,E3],m2]*cos\[Theta]12[E1,E3,m,m1,m2,m3])//Expand//Simplify*) +(*Q2[E1_,E3_,m_,m2_]=(m^2+m2^2-2*m*E2valEnergies[m,E1,E3]);*) + + +(* ::Subsection::Closed:: *) +(*Scalar products for 3-body decays at rest*) + + +(* ::Input:: *) +(*ProductKK=m^2;*) +(*ProductK2K2=m2^2;*) +(*ProductK3K3=m3^2;*) +(*ProductK1K1=m1^2;*) +(*ProductKK2energy=m*E2valEnergies[m,E1,E3];*) +(*ProductKK1energy=m*E1;*) +(*ProductKK3energy=m*E3;*) +(*ProductK1K3energy=(M13[E1,E3]-m1^2-m3^2)/2;*) +(*ProductK1K2energy=(M12[E1,E3]-m1^2-m2^2)/2;*) +(*ProductK2K3energy=(m^2+m1^2-2*m*E1-m2^2-m3^2)/2;*) + + +(* ::Section::Closed:: *) +(*Coherent EM processes (WW approximation)*) + + +(* ::Subsection::Closed:: *) +(*EM elastic form-factors*) + + +(* ::Input:: *) +(*(*Helm*)*) +(*svalfm=0.9;*) +(*fmtoGeVm1=5;*) +(*(*Effective radius of the nucleus*)*) +(*R1[Anucleus_]=fmtoGeVm1 Sqrt[(1.23*Anucleus^(1/3)-0.6)^2+7/3 Pi^2*0.52^2-5*svalfm^2];*) +(*FHelm[q2_,Anucleus_,Znucleus_]=3*Znucleus*(*SphericalBesselJ[1,Sqrt[q2]*R1[Anucleus]]*)(Sin[x]/x^2-Cos[x]/x/.{x->Sqrt[q2]*R1[Anucleus]})/(Sqrt[q2]*R1[Anucleus]) Exp[-((q2*(svalfm*fmtoGeVm1)^2)/2)];*) +(*FHelm1[q2_,Rnucl_,Znucleus_]=3*Znucleus*(*SphericalBesselJ[1,Sqrt[q2]*R1[Anucleus]]*)(Sin[x]/x^2-Cos[x]/x/.{x->Sqrt[q2]*Rnucl})/(Sqrt[q2]*Rnucl) Exp[-((q2*(svalfm*fmtoGeVm1)^2)/2)]*) +(*(*Proton*)*) +(*GE[q2_]=1/(1+q2/0.843^2)^2;*) +(*GM[q2_]=Sqrt[7.78]/(1+q2/0.843^2)^2;*) +(*F1[q2_]=(4*mp^2*GE[q2]+q2*GM[q2])/(4*mSM["p"]^2+q2);*) +(*F2[q2_]=(GM[q2]-GE[q2])/(4*mSM["p"]^2+q2);*) +(*Dval[q2_]=(4*mSM["p"]^2*GE[q2]^2+q2*GM[q2]^2)/(4*mSM["p"]^2+q2);*) +(**) + + +(* ::Subsection::Closed:: *) +(*Equivalent photon distribution functions*) + + +(* ::Input:: *) +(*(*Magnitude of the momentum transfer between particle and photon*)*) +(*q2pTxVal[x_,pT_,m_]=(pT^2+x^2*m^2)/(1-x);*) +(*fEPAp[pT_,x_,\[Alpha]EM_]=\[Alpha]EM/(2*Pi) (1+(1-x)^2)/x (pT^2/(pT^2+x^2*mSM["p"]^2)^2 Dval[q2pTxVal[x,pT,mSM["p"]]]+x^2/2 GM[q2pTxVal[x,pT,mSM["p"]]]^2);*) +(*fEPAnucleus[pT_,x_,\[Alpha]EM_,mNucleus_,Anucleus_,Znucleus_]=\[Alpha]EM/(2*Pi) (1+(1-x)^2)/x (pT^2/(pT^2+x^2*mNucleus^2)^2 FHelm[q2pTxVal[x,pT,mNucleus],Anucleus,Znucleus]^2)//Simplify;*) +(*fEPAnucleus1[pT_,x_,\[Alpha]EM_,mNucleus_,Rnucl_,Znucleus_]=\[Alpha]EM/(2*Pi) (1+(1-x)^2)/x (pT^2/(pT^2+x^2*mNucleus^2)^2 FHelm1[q2pTxVal[x,pT,mNucleus],Rnucl,Znucleus]^2)//Simplify;*) +(**) + + +(* ::Chapter::Closed:: *) +(*HNL*) + + +(* ::Section::Closed:: *) +(*Relevant processes*) + + +(* ::Input:: *) +(*ListHNLs={"HNL-mixing-e","HNL-mixing-mu","HNL-mixing-tau"};*) +(*(*__________________________________*)*) +(*(*HNLs with e mixing*)*) +(*(*__________________________________*)*) +(*(*List of processes*)*) +(*LLPname=ListHNLs[[1]];*) +(*ProcessesListAll[LLPname]={"B-3-body","B-2-body","Bc","D-3-body","D-2-body","K","W","mu","PiCharged"};*) +(*(*Topology of the process*)*) +(*MapThread[(ProductionType[LLPname,#1]=#2)&,{ProcessesListAll[LLPname],Table["Decay",Length[ProcessesListAll[LLPname]]]}];*) +(*ProductionType[LLPname,"B"]=ProductionType[LLPname,"D"]=ProductionType[LLPname,"K"]="Decay";*) +(*(*Particle content: mother particle, decay products*)*) +(*(*For 3-body decays of B, one reference decay process is used: B -> N + D^* + l, which dominates the production*)*) +(*MapThread[(ReactionProductsList[LLPname,#1]=#2)&,{ProcessesListAll[LLPname],{{"Bplus","Dstar","e",LLPname},{"Bplus","e",LLPname},{"Bc","e",LLPname},{"Dplus","K0","e",LLPname},{"Ds","e",LLPname},{"Kplus","e",LLPname},{"W","e",LLPname},{"mu","e","neutrino",LLPname},{"PiCharged","e",LLPname}}}];*) +(*(*__________________________________*)*) +(*(*HNLs with \[Mu] mixing*)*) +(*(*__________________________________*)*) +(*LLPname=ListHNLs[[2]];*) +(*ProcessesListAll[LLPname]={"B-3-body","B-2-body","Bc","D-3-body","D-2-body","K","W","mu","PiCharged"};*) +(*MapThread[(ProductionType[LLPname,#1]=#2)&,{ProcessesListAll[LLPname],Table["Decay",Length[ProcessesListAll[LLPname]]]}];*) +(*ProductionType[LLPname,"B"]=ProductionType[LLPname,"D"]=ProductionType[LLPname,"K"]="Decay";*) +(*MapThread[(ReactionProductsList[LLPname,#1]=#2)&,{ProcessesListAll[LLPname],{{"Bplus","Dstar","mu",LLPname},{"Bplus","mu",LLPname},{"Bc","mu",LLPname},{"Dplus","K0","mu",LLPname},{"Ds","mu",LLPname},{"Kplus","mu",LLPname},{"W","mu",LLPname},{"mu","e","neutrino",LLPname},{"PiCharged","mu",LLPname}}}];*) +(*(*__________________________________*)*) +(*(*HNLs with \[Tau] mixing*)*) +(*(*__________________________________*)*) +(*LLPname=ListHNLs[[3]];*) +(*ProcessesListAll[LLPname]={"B-3-body","B-2-body","Bc","D-2-body","\[Tau]-3-body","\[Tau]-2-body","W"};*) +(*MapThread[(ProductionType[LLPname,#1]=#2)&,{ProcessesListAll[LLPname],Table["Decay",Length[ProcessesListAll[LLPname]]]}];*) +(*ProductionType[LLPname,"B"]=ProductionType[LLPname,"D"]=ProductionType[LLPname,"K"]="Decay";*) +(*MapThread[(ReactionProductsList[LLPname,#1]=#2)&,{ProcessesListAll[LLPname],{{"Bplus","Dstar","tau",LLPname},{"Bplus","tau",LLPname},{"Bc","tau",LLPname},{"Ds","tau",LLPname},{"tau","neutrino","e",LLPname},{"tau","PiCharged",LLPname},{"W","tau",LLPname}}}];*) +(*LLPname//Clear*) + + +(* ::Section::Closed:: *) +(*Weights for the different processes of D/B decays*) + + +(* ::Subsection::Closed:: *) +(*From B*) + + +(* ::Input:: *) +(*brint[mN_,file_]:= Interpolation[Import[FileNameJoin[{NotebookDirectory[],"phenomenology/HNL/Production probabilities",file}]],InterpolationOrder->1][mN];*) +(*brsum[proclist_]:=Sum[brint[mN,proc],{proc,proclist}];*) +(*Do[*) +(*(*Dominant decays of Subscript[B, c]*)*) +(*MapThread[(\[Omega]HNL[#1,Facility,"Bc",mN_]=#2)&,{ListHNLs,fbtobc[Facility]*brint[mN,#]&/@{"bc-eN.m","bc-muN.m","bc-tauN.m"}}];*) +(*(*2-body decays of B^+*)*) +(*MapThread[(\[Omega]HNL[#1,Facility,"B-2-body",mN_]=#2)&,{ListHNLs,(fbtobplus[Facility]+fbtob0[Facility])brint[mN,#]&/@{"bplus-eN.m","bplus-muN.m","bplus-tauN.m"}}];*) +(*(*3-body decays of B. br ratios for other 3-body processes are included here as well*)*) +(*{mMax[ListHNLs[[1]],"B-3-body"],mMax[ListHNLs[[2]],"B-3-body"],mMax[ListHNLs[[3]],"B-3-body"]}={mSM["Bplus"]-mSM["Dstar"]-mSM["e"],mSM["Bplus"]-mSM["Dstar"]-mSM["mu"],mSM["Bplus"]-mSM["Dstar"]-mSM["tau"]};*) +(*MapThread[(\[Omega]HNL[#1,Facility,"B-3-body",mN_]=#2)&,{ListHNLs,*) +(*(fbtobplus[Facility]+fbtob0[Facility]){UnitStep[mMax[ListHNLs[[1]],"B-3-body"]-mN]*brsum[{"bplus-D0bareN.m","bplus-D0starbareN.m","b0-DeN.m","b0-DminusstareN.m"}],UnitStep[mMax[ListHNLs[[2]],"B-3-body"]-mN]*brsum[{"bplus-D0barmuN.m","bplus-D0starbarmuN.m","b0-DmuN.m","b0-DminusstarmuN.m"}],UnitStep[mMax[ListHNLs[[3]],"B-3-body"]-mN]*brsum[{"bplus-D0bartauN.m","bplus-D0starbartauN.m","b0-DtauN.m","b0-DminusstartauN.m"}]}}];*) +(*,{Facility,FacilitiesList}]*) +(**) + + +(* ::Subsection::Closed:: *) +(*Decays of D/\[Tau]*) + + +(* ::Input:: *) +(*Do[*) +(*MapThread[(\[Omega]HNL[#1,Facility,"D-2-body",mN_]=#2)&,{ListHNLs,{fctods[Facility]*brint[mN,"ds-eN.m"]+fctodplus[Facility]*brint[mN,"dplus-eN.m"],fctods[Facility]*brint[mN,"ds-muN.m"]+fctodplus[Facility]*brint[mN,"dplus-muN.m"],fctods[Facility]*brint[mN,"ds-tauN.m"]+fctodplus[Facility]*brint[mN,"dplus-tauN.m"]}}];*) +(*MapThread[(\[Omega]HNL[#1,Facility,"D-3-body",mN_]=#2)&,{ListHNLs,{fctodplus[Facility]*brsum[{"dplus-K0eN.m","dplus-K0stareN.m"}]+fctod0[Facility]*brsum[{"d0-KplusstareN.m","d0-KpluseN.m"}],fctodplus[Facility]*brsum[{"dplus-K0muN.m","dplus-K0starmuN.m"}]+fctod0[Facility]*brsum[{"d0-KplusstarmuN.m","d0-KplusmuN.m"}],0.}}];*) +(*\[Omega]HNL[ListHNLs[[3]],Facility,"\[Tau]-3-body",mN_]=fctods[Facility]*fdstau*brint[mN,"tau-lbarnuN.m"];*) +(*\[Omega]HNL[ListHNLs[[3]],Facility,"\[Tau]-2-body",mN_]=fctods[Facility]*fdstau*brsum[{"tau-piN.m","tau-KN.m"}];*) +(*,{Facility,FacilitiesList}]*) +(*(*Given Subscript[N, events], for the given processes list it is splitted into fractions corresponding to the weights*)*) +(*NeventsSplitterHNL[HNL_,Facility_,proclist_,mN_,Nevents_]:=Block[{},*) +(*proclistsel=Select[proclist,MemberQ[ProcessesListAll[HNL],#]==True&];*) +(*\[Omega]list={proclistsel,\[Omega]HNL[HNL,Facility,#,mN]&/@proclistsel}//Transpose;*) +(*Nevlist=SortBy[{#[[1]],IntegerPart[(Nevents #[[2]])/(\[Omega]list[[All,2]]//Total)]}&/@\[Omega]list,-#[[2]]&];*) +(*Nevlist[[1]][[2]]=Nevlist[[1]][[2]]+Nevents-(Nevlist[[All,2]]//Total);*) +(*Select[Nevlist,#[[2]]>0&]*) +(*]*) +(*NeventsSplitterHNL[ListHNLs[[3]],"SPS",{"D-2-body","D-3-body","\[Tau]-2-body","\[Tau]-3-body"},0.9,20]*) +(*NeventsSplitterHNL[ListHNLs[[3]],"LHC",{"B-2-body","B-3-body","Bc"},2.9,20]*) + + +(* ::Section::Closed:: *) +(*Squared matrix elements for 3-body processes (Figs. 4,5 + Appendix A.2 from https://arxiv.org/pdf/1805.08567.pdf)*) + + +(* ::Subsection::Closed:: *) +(*Definitions*) + + +(* ::Input:: *) +(*MV=Association[{Kplus->0.892 ,Dplus->2.01,D0->2.01,Ds->2.11,Bplus->5.32,B0->5.32,Bs->5.415,Bc->6.33}];*) +(*fH=Association[{piplus-> 0.13,Kplus-> 0.156,Dplus-> 0.212,Ds-> 0.249,Bplus-> 0.187,Bs-> 0.227,B0-> 0.191,Bc-> 0.48}];*) +(*MH=Association[{piplus-> 0.1396,pi0->0.135 ,Kplus-> 0.494,K0->0.498,eta-> 0.548,rho0->0.775,rhoplus->0.775,Dplus-> 1.87,D0-> 1.865,Ds-> 1.97,Dsstar-> 2.11,etac->2.98 ,Bplus-> 5.279,B0->5.279 ,Bs-> 5.37,Bc->6.28,Dplusstar->2.01,D0star->2.007, Kplusstar->0.892,K0star->0.892}];*) +(*MV=Association[{Kplus->0.892 ,Dplus->2.01,D0->2.01,Ds->2.11,Bplus->5.32,B0->5.32,Bs->5.415,Bc->6.33}];*) +(*MS=Association[{Kplus-> 1.43,Dplus->2.4,D0->2.4,Ds->2.32,Bplus->5.68,B0->5.68,Bs->5.68,Bc->6.42}];*) + + +(* ::Subsection::Closed:: *) +(*B->SuperStar[D]+N+l*) + + +(* ::Input:: *) +(*(*Form-factors*)*) +(*ParsDtoK = {1.03,0.76,0.66,0.49, 0.27,0.17,0.30,0.67,0,0,0.20, 0.16,1.969,2.112};*) +(*ParsBtoD = {0.76,0.69,0.66,0.62,0.57,0.59,0.78,1.40,0,0,0,0.41,6.275,6.331};*) +(*ParsBto\[Rho] = {0.295,0.231,0.269,0.282,0.875,0.796,0.54,1.34,0,0.055,0,-0.21,5.279,5.325};*) +(*ParsBstoDs = {0.95,0.67,0.70,0.75,0.372,0.350,0.463,1.04,0.561,0.600,0.510,0.070,6.275,6.331};*) +(*ParsBstoK = {0.291,0.289,0.287,0.286,-0.516,-0.383,0,1.05,2.10,1.58,1.06,-0.074,5.367,5.415};*) +(*ParsHtoV[H_,V_]:=Association[{{Dplus,K0star}-> ParsDtoK,{D0,Kplusstar}-> ParsDtoK,{Bplus,D0star}->ParsBtoD,{B0,Dplusstar}->ParsBtoD,{Bplus,rho0}->ParsBto\[Rho],{B0,rhoplus}->ParsBto\[Rho],{Bs,Dsstar}->ParsBstoDs,{Bs,Kplusstar}->ParsBstoK}][{H,V}]*) +(*DipoleForm[a_, b_, mhv_, q2_]:=1/(1-a q2/ (mhv^2)-b q2^2/ (mhv^4));*) +(*gVHtoV[H_, V_,q2_]:=ParsHtoV[H,V][[1]]/((1 - q2/ParsHtoV[H,V][[14]]^2)(MH[H]+ MH[V] )) DipoleForm[ParsHtoV[H,V][[5]], ParsHtoV[H,V][[9]],ParsHtoV[H,V][[14]], q2];*) +(*fVHtoV[H_, V_, q2_]:=(MH[H]+ MH[V] ) ParsHtoV[H,V][[3]]*DipoleForm[ParsHtoV[H,V][[7]], ParsHtoV[H,V][[11]],ParsHtoV[H,V][[14]],q2];*) +(*aplHtoV[H_, V_, q2_]:= -1/(MH[H]+ MH[V] ) ParsHtoV[H,V][[4]]*DipoleForm[ParsHtoV[H,V][[8]], ParsHtoV[H,V][[12]],ParsHtoV[H,V][[14]],q2];*) +(*aminHtoV[H_, V_, q2_]:= 1/q2 (2 MH[V] ParsHtoV[H,V][[2]]/(1 - q2/ParsHtoV[H,V][[13]]^2) DipoleForm[ParsHtoV[H,V][[6]],ParsHtoV[H,V][[10]],ParsHtoV[H,V][[14]], q2]- fVHtoV[H,V,q2]- (MH[H]^2- MH[V] ^2)aplHtoV[H,V,q2]);*) +(*(*Squared matrix elements*)*) +(*HadronicCurrentVectorPart=I*g*LeviCivita[\[Mu],\[Nu],\[Sigma],\[Rho]]*PolarizationVector[k1,\[Nu]]*FV[k+k1,\[Sigma]]*FV[k-k1,\[Rho]]//Contract;*) +(*HadronicCurrentAxialPart=f*PolarizationVector[k1,\[Mu]]+aplus*PolarizationVector[k1,\[Kappa]]*FV[k,\[Kappa]]*FV[k+k1,\[Mu]]+aminus*PolarizationVector[k1,\[Kappa]]*FV[k,\[Kappa]]*FV[k-k1,\[Mu]]//Contract;*) +(*MBdecay3Body=SpinorVBar[k2,m2] . GA[\[Mu]] . (1-GA5) . SpinorU[k3,m3](HadronicCurrentVectorPart-HadronicCurrentAxialPart)//Contract;*) +(*MBdecay3BodyStar=MBdecay3Body//ComplexConjugate;*) +(*MBdecay3BodySquaredTemp=((Simplify[Expand[DoPolarizationSums[FermionSpinSum[MBdecay3Body*MBdecay3BodyStar]/.DiracTrace->TR//Contract//Simplify,k1]]]/.{aminus->aminHtoV[Bplus, D0star, ScalarProduct[k-k1,k-k1]//ExpandScalarProduct],aplus->aplHtoV[Bplus, D0star, ScalarProduct[k-k1,k-k1]//ExpandScalarProduct],g->gVHtoV[Bplus, D0star, ScalarProduct[k-k1,k-k1]//ExpandScalarProduct],f->fVHtoV[Bplus, D0star, ScalarProduct[k-k1,k-k1]//ExpandScalarProduct] }//Contract)/.{ScalarProduct[k,k]->ProductKK,ScalarProduct[k1,k1]->ProductK1K1,ScalarProduct[k2,k2]->ProductK2K2,ScalarProduct[k3,k3]->ProductK3K3}/.{ScalarProduct[k,k1]-> ProductKK1energy,ScalarProduct[k2,k3]->ProductK2K3energy,ScalarProduct[k1,k3]->ProductK1K3energy,ScalarProduct[k,k3]->ProductKK3energy,ScalarProduct[k1,k2]->ProductK1K2energy,ScalarProduct[k,k2]->ProductKK2energy});*) +(*Msquared3Body[ListHNLs[[1]],"B-3-body",mLLP_,E1_,E3_]=MBdecay3BodySquaredTemp/.{m->mSM["Bplus"],m1-> mSM["Dstar"],m2->mSM["e"],m3->mLLP}//Simplify;*) +(*Msquared3Body[ListHNLs[[2]],"B-3-body",mLLP_,E1_,E3_]=MBdecay3BodySquaredTemp/.{m->mSM["Bplus"],m1-> mSM["Dstar"],m2->mSM["mu"],m3->mLLP}//Simplify;*) +(*Msquared3Body[ListHNLs[[3]],"B-3-body",mLLP_,E1_,E3_]=MBdecay3BodySquaredTemp/.{m->mSM["Bplus"],m1-> mSM["Dstar"],m2->mSM["tau"],m3->mLLP}//Simplify;*) + + +(* ::Subsection::Closed:: *) +(*SuperPlus[D]->K^0+N+l*) + + +(* ::Input:: *) +(*(*Form-factors*)*) +(*fplus0[H_,H1_]:=Association[{*) +(*{Kplus,pi0}-> 0,*) +(*{Dplus,K0}-> 0.75,{D0,Kplus}-> 0.75,{Ds,eta}-> 0,*) +(*{Dplus,pi0}-> 0.61,{D0,piplus}-> 0.61,{Ds,K0}-> 0,*) +(*{Bplus,D0}-> 0.66,{B0,Dplus}-> 0.66,{Bs,Ds}-> 0.57,{Bc,etac}-> 0,*) +(*{Bplus,pi0}-> 0.27,{B0,piplus}-> 0.27,{Bs,Kplus}-> 0.323,{Bc,D0}-> 0, {Bc,B0}->-0.58,{Bc,Bs}->-0.61}][{H,H1}]*) +(*fplus[H_,H1_,q2_]:=fplus0[H,H1]/(1-q2/MV[H]^2);*) +(*fminus[H_,H1_,q2_]:=fplus0[H,H1] (((MH[H]^2-MH[H1]^2)(MV[H]^2-MS[H]^2))/((MS[H]^2-q2)(MV[H]^2-q2)));*) +(*(*Squared matrix elements*)*) +(*HadronicCurrentDvectorPart=fp*FV[k+k1,\[Mu]]+fm*FV[k-k1,\[Mu]];*) +(*MDdecay3Body=SpinorVBar[k2,m2] . GA[\[Mu]] . (1-GA5) . SpinorU[k3,m3]HadronicCurrentDvectorPart//Contract//ExpandScalarProduct;*) +(*MDdecay3BodyStar=MDdecay3Body//ComplexConjugate;*) +(*MDdecay3BodySquaredTemp=(Simplify[Expand[FermionSpinSum[MDdecay3Body*MDdecay3BodyStar]/.DiracTrace->TR//Contract//Simplify]/.{fp-> fplus[Dplus,K0,ScalarProduct[k-k1,k-k1]//ExpandScalarProduct],fm-> fminus[Dplus,K0,ScalarProduct[k-k1,k-k1]//ExpandScalarProduct]}]/.{ScalarProduct[k,k]->ProductKK,ScalarProduct[k1,k1]->ProductK1K1,ScalarProduct[k2,k2]->ProductK2K2,ScalarProduct[k3,k3]->ProductK3K3}/.{ScalarProduct[k,k1]-> ProductKK1energy,ScalarProduct[k2,k3]->ProductK2K3energy,ScalarProduct[k1,k3]->ProductK1K3energy,ScalarProduct[k,k3]->ProductKK3energy,ScalarProduct[k1,k2]->ProductK1K2energy,ScalarProduct[k,k2]->ProductKK2energy});*) +(*Msquared3Body[ListHNLs[[1]],"D-3-body",mLLP_,E1_,E3_]=MDdecay3BodySquaredTemp/.{m->mSM["Dplus"],m1-> mSM["K0"],m2->mSM["e"],m3->mLLP}//Simplify;*) +(*Msquared3Body[ListHNLs[[2]],"D-3-body",mLLP_,E1_,E3_]=MDdecay3BodySquaredTemp/.{m->mSM["Dplus"],m1-> mSM["K0"],m2->mSM["mu"],m3->mLLP}//Simplify;*) + + +(* ::Subsection::Closed:: *) +(*\[Tau] ->Subscript[\!\(\*OverscriptBox[\(\[Nu]\), \(_\)]\), l]+l+N*) + + +(* ::Input:: *) +(*M\[Tau]decay3Body=SpinorVBar[k2,m2] . GA[\[Mu]] . (1-GA5) . SpinorU[k1,m1]*SpinorUBar[k3,m3] . GA[\[Mu]] . (1-GA5) . SpinorU[k,m]//Contract;*) +(*M\[Tau]decay3BodyStar=M\[Tau]decay3Body//ComplexConjugate;*) +(*M\[Tau]decay3BodySquaredTemp=(Simplify[Expand[1/2 FermionSpinSum[M\[Tau]decay3Body*M\[Tau]decay3BodyStar]/.DiracTrace->TR//Contract//Simplify]]/.{ScalarProduct[k,k]->ProductKK,ScalarProduct[k1,k1]->ProductK1K1,ScalarProduct[k2,k2]->ProductK2K2,ScalarProduct[k3,k3]->ProductK3K3}/.{ScalarProduct[k,k1]-> ProductKK1energy,ScalarProduct[k2,k3]->ProductK2K3energy,ScalarProduct[k1,k3]->ProductK1K3energy,ScalarProduct[k,k3]->ProductKK3energy,ScalarProduct[k1,k2]->ProductK1K2energy,ScalarProduct[k,k2]->ProductKK2energy});*) +(*Msquared3Body[ListHNLs[[3]],"\[Tau]-3-body",mLLP_,E1_,E3_]=M\[Tau]decay3BodySquaredTemp/.{m->mSM["tau"],m1->0,m2->mSM["e"],m3->mLLP}//Simplify;*) + + +(* ::Subsection::Closed:: *) +(*\[Mu] ->Subscript[\!\(\*OverscriptBox[\(\[Nu]\), \(_\)]\), e]+e+N/Subscript[\[Nu], \[Mu]]+e+N*) + + +(* ::Input:: *) +(*M\[Mu]decay3Body=SpinorVBar[k2,m2] . GA[\[Mu]] . (1-GA5) . SpinorU[k1,m1]*SpinorUBar[k3,m3] . GA[\[Mu]] . (1-GA5) . SpinorU[k,m]//Contract;*) +(*M\[Mu]decay3BodyStar=M\[Mu]decay3Body//ComplexConjugate;*) +(*M\[Mu]decay3BodySquaredTemp=(Simplify[Expand[1/2 FermionSpinSum[M\[Mu]decay3Body*M\[Mu]decay3BodyStar]/.DiracTrace->TR//Contract//Simplify]]/.{ScalarProduct[k,k]->ProductKK,ScalarProduct[k1,k1]->ProductK1K1,ScalarProduct[k2,k2]->ProductK2K2,ScalarProduct[k3,k3]->ProductK3K3}/.{ScalarProduct[k,k1]-> ProductKK1energy,ScalarProduct[k2,k3]->ProductK2K3energy,ScalarProduct[k1,k3]->ProductK1K3energy,ScalarProduct[k,k3]->ProductKK3energy,ScalarProduct[k1,k2]->ProductK1K2energy,ScalarProduct[k,k2]->ProductKK2energy});*) +(*Msquared3Body[ListHNLs[[2]],"mu",mLLP_,E1_,E3_]=M\[Mu]decay3BodySquaredTemp/.{m->mSM["mu"],m1->0,m2->mSM["e"],m3->mLLP}//Simplify;*) +(*M\[Mu]decay3Body=SpinorVBar[k2,m2] . GA[\[Mu]] . (1-GA5) . SpinorU[k3,m3]*SpinorVBar[k,m] . GA[\[Mu]] . (1-GA5) . SpinorV[k1,m1]//Contract;*) +(*(*M\[Mu]decay3Body=SpinorVBar[k3,m3].GA[\[Mu]].(1-GA5).SpinorU[k2,m2]*SpinorUBar[k1,m1].GA[\[Mu]].(1-GA5).SpinorU[k,m]//Contract;*)*) +(*M\[Mu]decay3BodyStar=M\[Mu]decay3Body//ComplexConjugate;*) +(*M\[Mu]decay3BodySquaredTemp=(Simplify[Expand[1/2 FermionSpinSum[M\[Mu]decay3Body*M\[Mu]decay3BodyStar]/.DiracTrace->TR//Contract//Simplify]]/.{ScalarProduct[k,k]->ProductKK,ScalarProduct[k1,k1]->ProductK1K1,ScalarProduct[k2,k2]->ProductK2K2,ScalarProduct[k3,k3]->ProductK3K3}/.{ScalarProduct[k,k1]-> ProductKK1energy,ScalarProduct[k2,k3]->ProductK2K3energy,ScalarProduct[k1,k3]->ProductK1K3energy,ScalarProduct[k,k3]->ProductKK3energy,ScalarProduct[k1,k2]->ProductK1K2energy,ScalarProduct[k,k2]->ProductKK2energy});*) +(*Msquared3Body[ListHNLs[[1]],"mu",mLLP_,E1_,E3_]=M\[Mu]decay3BodySquaredTemp/.{m->mSM["mu"],m1->0,m2->mSM["e"],m3->mLLP}//Simplify;*) + + +(* ::Section::Closed:: *) +(*Angle-energy distributions of LLPs if mother particle is at rest*) + + +(* ::Subsubsection::Closed:: *) +(*\[Mu] ->Subscript[\!\(\*OverscriptBox[\(\[Nu]\), \(_\)]\), e]+e+N/N+e+Subscript[\[Nu], \[Mu]]*) + + +(* ::Input:: *) +(*Do[EdistrTemp[HNL,"mu",mLLP_,E3_]=(Integrate[Msquared3Body[HNL,"mu",mLLP,E1,E3],E1]/.{E1->E1domain1[E3,mSM["mu"],0.,mSM["e"],mLLP][[2]]})-(Integrate[Msquared3Body[HNL,"mu",mLLP,E1,E3],E1]/.{E1->E1domain1[E3,mSM["mu"],0.,mSM["e"],mLLP][[1]]})//Simplify;*) +(*WidthNorm[HNL,"mu",mLLP_]=Interpolation[ParallelTable[With[{m=mLLP},{m,If[m==mSM["mu"],0.,Quiet[NIntegrate[EdistrTemp[HNL,"mu",m,E3],{E3,E3domain1[mSM["mu"],0,mSM["e"],m][[1]],E3domain1[mSM["mu"],0,mSM["e"],m][[2]]}]]]//Re}],{mLLP,0.,mSM["mu"],mSM["mu"]/300.}],InterpolationOrder->1][mLLP];*) +(*\[Theta]EdistrRest[HNL,"mu",mLLP_,\[Theta]LLP_,ELLP_]=If[mLLP<=ELLP<=E3domain1[mSM["mu"],0,mSM["e"],mLLP][[2]],Evaluate[Sin[\[Theta]LLP]/2 EdistrTemp[HNL,"mu",mLLP,ELLP]/WidthNorm[HNL,"mu",mLLP]],0];*) +(*,{HNL,Drop[ListHNLs,-1]}]*) + + +(* ::Subsection::Closed:: *) +(*\[Pi] -> N + l *) + + +(* ::Input:: *) +(*Do[*) +(*mlv=If[HNL=="HNL-mixing-e",0.5*10^-3,0.105];*) +(*\[CapitalDelta]Eapprox=10^-5.;*) +(*\[Theta]EdistrRest[HNL,"PiCharged",mLLP_,\[Theta]LLP_,ELLP_]=If[(mSM["PiCharged"]^2-mlv^2+mLLP^2)/(2mSM["PiCharged"])-\[CapitalDelta]Eapprox/2<=ELLP<=(mSM["PiCharged"]^2-mlv^2+mLLP^2)/(2mSM["PiCharged"])+\[CapitalDelta]Eapprox/2,Evaluate[1/\[CapitalDelta]Eapprox Sin[\[Theta]LLP]/2],0];*) +(*,{HNL,Drop[ListHNLs,-1]}]*) + + +(* ::Chapter::Closed:: *) +(*ALP-gluon*) + + +(* ::Section::Closed:: *) +(*Relevant processes*) + + +(* ::Input:: *) +(*(*List of processes*)*) +(*LLPname="ALP-gluon";*) +(*(*There are production channels via mixing with neutral light mesons, ##-mixing. Drell-Yan is computed externally (MadGraph+pythia)*)*) +(*ProcessesListAll[LLPname]={"B","Mixing-Pi0-Old","Mixing-Eta-Old","Mixing-EtaPr-Old"};*) +(*(*Topology of the process*)*) +(*MapThread[(ProductionType[LLPname,#1]=#2)&,{ProcessesListAll[LLPname],{"Decay","Mixing","Mixing","Mixing"}}];*) +(*(*Particle content: mother particle, decay products*)*) +(*MapThread[(ReactionProductsList[LLPname,#1]=#2)&,{ProcessesListAll[LLPname],{{"Bplus","PiCharged",LLPname},{"Pi0",LLPname},{"Eta",LLPname},{"EtaPr",LLPname}}}];*) +(*LLPname//Clear*) +(**) + + +(* ::Chapter::Closed:: *) +(*ALP-photon*) + + +(* ::Section::Closed:: *) +(*Relevant processes*) + + +(* ::Input:: *) +(*(*List of processes*)*) +(*LLPname="ALP-photon";*) +(*(*There are production channels via scattering of protons or photons, called "photon fusion" and "Primakov"*)*) +(*ProcessesListAll[LLPname]={"Pi0","Eta","Primakov","Photon-fusion"};*) +(*(*Topology of the process*)*) +(*MapThread[(ProductionType[LLPname,#1]=#2)&,{ProcessesListAll[LLPname],{"Decay","Decay","Scattering","Scattering"}}];*) +(*(*Particle content: mother particle, decay products*)*) +(*MapThread[(ReactionProductsList[LLPname,#1]=#2)&,{ProcessesListAll[LLPname],{{"Pi0","photon","photon",LLPname},{"Eta","photon","photon",LLPname},{"photon",LLPname},{"p",LLPname}}}];*) +(*(*____________________________________*)*) +(*(*List of possible nuclei targets depending on the facility*)*) +(*(*____________________________________*)*) +(*NucleiList["SPS","Primakov"]=NucleiList["SPS","Photon-fusion"]={"Mo","Fe","C"};*) +(*NucleiList["FermilabBD","Primakov"]=NucleiList["FermilabBD","Photon-fusion"]={"Fe","C"};*) +(*NucleiList["Serpukhov","Primakov"]=NucleiList["Serpukhov","Photon-fusion"]={"Fe"};*) +(*(*For LHC: colliding of photons with TAX. Relevant only for FASER/FASER2*)*) +(*NucleiList["LHC","Primakov"]={"Fe"};*) +(*NucleiList["LHC","Photon-fusion"]=NucleiList["FCC-hh","Photon-fusion"]={"p"};*) + + +(* ::Section::Closed:: *) +(*Matrix elements of 3-body decays*) + + +(* ::Subsection::Closed:: *) +(*Decay of \[Pi]^0/\[Eta]*) + + +(* ::Input:: *) +(*LLPname="ALP-photon";*) +(*(*3-body decays \[Pi]^0/\[Eta] -> ALP+\[Gamma]+\[Gamma]*)*) +(*FileM2ALPprod=FileNameJoin[{NotebookDirectory[],"phenomenology/"<>LLPname<>"/Production-probabilities/M2Pi0Eta.mx"}];*) +(*If[!FileExistsQ[FileM2ALPprod],*) +(*FFvac[p_,\[Mu]_,\[Nu]_,\[Alpha]_,\[Beta]_]:=(-FV[p,\[Mu]]*FV[p,\[Alpha]]*MT[\[Nu],\[Beta]]-FV[p,\[Nu]]*FV[p,\[Beta]]*MT[\[Mu],\[Alpha]]+FV[p,\[Mu]]*FV[p,\[Beta]]*MT[\[Nu],\[Alpha]]+FV[p,\[Nu]]*FV[p,\[Alpha]]*MT[\[Mu],\[Beta]])/ScalarProduct[p,p]//ExpandScalarProduct;*) +(*FFfinal[p\[Gamma]1_,p\[Gamma]2_,\[Mu]_,\[Nu]_,\[Alpha]_,\[Beta]_]:=(FV[p\[Gamma]1,\[Mu]]*PolarizationVector[p\[Gamma]1,\[Nu]]-FV[p\[Gamma]1,\[Nu]]*PolarizationVector[p\[Gamma]1,\[Mu]])*(FV[p\[Gamma]2,\[Alpha]]*PolarizationVector[p\[Gamma]2,\[Beta]]-FV[p\[Gamma]2,\[Beta]]*PolarizationVector[p\[Gamma]2,\[Alpha]]);*) +(*ScalarProduct[p\[Gamma]2,p\[Gamma]2]=ScalarProduct[p\[Gamma]1,p\[Gamma]1]=0;*) +(*MdecayMesonToALPphoton=(1/4 ga\[Gamma]\[Gamma]*g\[Pi]\[Gamma]\[Gamma]*2*LeviCivita[\[Mu]1,\[Nu]1,\[Mu]2,\[Nu]2]*LeviCivita[\[Mu]3,\[Nu]3,\[Mu]4,\[Nu]4](FFvac[p\[Gamma]2+p3,\[Mu]1,\[Nu]1,\[Mu]2,\[Nu]2]*FFfinal[p\[Gamma]1,p\[Gamma]2,\[Mu]3,\[Nu]3,\[Mu]4,\[Nu]4]+FFvac[p\[Gamma]2+p3,\[Mu]1,\[Nu]1,\[Mu]3,\[Nu]3]*FFfinal[p\[Gamma]1,p\[Gamma]2,\[Mu]2,\[Nu]2,\[Mu]4,\[Nu]4]+FFvac[p\[Gamma]2+p3,\[Mu]1,\[Nu]1,\[Mu]4,\[Nu]4]*FFfinal[p\[Gamma]1,p\[Gamma]2,\[Mu]3,\[Nu]3,\[Mu]2,\[Nu]2]+FFvac[p\[Gamma]2+p3,\[Mu]2,\[Nu]2,\[Mu]3,\[Nu]3]*FFfinal[p\[Gamma]1,p\[Gamma]2,\[Mu]1,\[Nu]1,\[Mu]4,\[Nu]4]+FFvac[p\[Gamma]2+p3,\[Mu]3,\[Nu]3,\[Mu]4,\[Nu]4]*FFfinal[p\[Gamma]1,p\[Gamma]2,\[Mu]1,\[Nu]1,\[Mu]2,\[Nu]2]+FFvac[p\[Gamma]2+p3,\[Mu]2,\[Nu]2,\[Mu]4,\[Nu]4]*FFfinal[p\[Gamma]1,p\[Gamma]2,\[Mu]1,\[Nu]1,\[Mu]3,\[Nu]3])//Contract//Simplify);*) +(*MdecayMesonToALPphotonSquared=(DoPolarizationSums[DoPolarizationSums[MdecayMesonToALPphoton*ComplexConjugate[MdecayMesonToALPphoton],p\[Gamma]1,0],p\[Gamma]2,0]//Contract//Simplify)/.{ScalarProduct[p3,p3]->ProductK3K3,ScalarProduct[p\[Gamma]2,p\[Gamma]2]->ProductK2K2,ScalarProduct[p\[Gamma]1,p\[Gamma]1]->ProductK1K1,ScalarProduct[p\[Gamma]2,p3]->ProductK2K3energy,ScalarProduct[p\[Gamma]1,p3]->ProductK1K3energy,ScalarProduct[p\[Gamma]1,p\[Gamma]2]-> ProductK1K2energy}/.{m1->0,m2->0,m3->ma,m->mmeson}//Simplify;*) +(*Msquared3Body[LLPname,"Pi0",mLLP_,E1_,E3_]=MdecayMesonToALPphotonSquared/.{mmeson->mSM["Pi0"],ma->mLLP,ga\[Gamma]\[Gamma]->1,g\[Pi]\[Gamma]\[Gamma]->1};*) +(*Msquared3Body[LLPname,"Eta",mLLP_,E1_,E3_]=MdecayMesonToALPphotonSquared/.{mmeson->mSM["Eta"],ma->mLLP,ga\[Gamma]\[Gamma]->1,g\[Pi]\[Gamma]\[Gamma]->1};*) +(*Export[FileM2ALPprod,{Msquared3Body[LLPname,"Pi0",mLLP,E1,E3],Msquared3Body[LLPname,"Eta",mLLP,E1,E3]},"MX"]*) +(*,*) +(*{Msquared3Body[LLPname,"Pi0",mLLP_,E1_,E3_],Msquared3Body[LLPname,"Eta",mLLP_,E1_,E3_]}=Import[FileM2ALPprod,"MX"];*) +(*]*) +(*LLPname//Clear*) + + +(* ::Section::Closed:: *) +(*Primakov cross-section*) + + +(* ::Subsection::Closed:: *) +(*Kinematics*) + + +(* ::Input:: *) +(*sinv[E\[Gamma]_,mt_]=2*mt*E\[Gamma]+mt^2;*) +(*tmin[ma_,E\[Gamma]_,mt_]=ma^4/(4*sinv[E\[Gamma],mt])-((sinv[E\[Gamma],mt]-mt^2)/(2*Sqrt[sinv[E\[Gamma],mt]])+Sqrt[(sinv[E\[Gamma],mt]+ma^2-mt^2)^2/(4*sinv[E\[Gamma],mt])-ma^2])^2;*) +(*tmaxTemp[ma_,E\[Gamma]_,mt_]=ma^4/(4*sinv[E\[Gamma],mt])-((sinv[E\[Gamma],mt]-mt^2)/(2*Sqrt[sinv[E\[Gamma],mt]])-Sqrt[(sinv[E\[Gamma],mt]+ma^2-mt^2)^2/(4*sinv[E\[Gamma],mt])-ma^2])^2;*) +(*tmaxLimit[ma_,E\[Gamma]_]=Assuming[E\[Gamma]>0&&mt>0,Simplify[Normal@Series[tmaxTemp[ma,E\[Gamma],mt],{ma,0,4}]]];*) +(*tmax[ma_,E\[Gamma]_,mt_]=If[ma/E\[Gamma]>0.01,Evaluate[tmaxTemp[ma,E\[Gamma],mt]],Evaluate[tmaxLimit[ma,E\[Gamma]]]];*) +(*Print["Expression for \!\(\*SubscriptBox[\(E\), \(a\)]\) in terms of \!\(\*SubscriptBox[\(E\), \(\[Gamma]\)]\),\!\(\*SubscriptBox[\(m\), \(T\)]\),\!\(\*SuperscriptBox[\(q\), \(2\)]\) = -t:"]*) +(*(*Expression for the squared momentum transfer evaluated via -q^2 = (Subscript[p, \[Nu]]-Subscript[p, N])^2. Depends on Subscript[E, \[Nu]],Subscript[E, N],cos(Subscript[\[Theta], \[Nu]N])*)*) +(*Q2p\[Nu]pN[E\[Gamma]_,Ea_,ma_,cos\[Theta]_]=-(ma^2-2*Ea*E\[Gamma]+2*\[Sqrt](Ea^2-ma^2)*E\[Gamma]*cos\[Theta]);*) +(*(*Expression for the squared momentum transfer evaluated via -q^2 = (Subscript[p, T']-Subscript[p, T])^2. Depends on Subscript[E, T] = Subscript[m, T], Subscript[E, T'] = Subscript[E, \[Gamma]]+Subscript[m, T]-Subscript[E, a]*)*) +(*Q2pTprimepT[E\[Gamma]_,Ea_,ma_,mT_]=-(2mT^2-2*mT(E\[Gamma]+mT-Ea));*) +(*(*cos\[Theta] expressed via q^2, Subscript[E, \[Nu]],Subscript[E, N]*)*) +(*cos\[Theta]\[Gamma]a[q2_,E\[Gamma]_,Ea_,ma_]=cos\[Theta]/.Solve[Q2p\[Nu]pN[E\[Gamma],Ea,ma,cos\[Theta]]==q2,cos\[Theta]][[1]];*) +(*(*Finally, expression for Subscript[E, N] in terms of Subscript[E, \[Nu]],Subscript[m, T],q^2*)*) +(*EavalE\[Gamma]q2[E\[Gamma]_,q2_,mT_]=Ea/.Solve[Q2p\[Nu]pN[E\[Gamma],Ea,ma,cos\[Theta]\[Gamma]a[q2,E\[Gamma],Ea,ma]]==Q2pTprimepT[E\[Gamma],Ea,ma,mT],Ea][[1]]*) +(*Print["Jacobian \!\(\*SuperscriptBox[\(Q\), \(2\)]\)\[Rule] \!\(\*SubscriptBox[\(E\), \(N\)]\):"]*) +(*JacobianQ2E\[Gamma]ToEaE\[Gamma][E\[Gamma]_,mT_,ma_]=-(D[Q2pTprimepT[E\[Gamma],Ea,ma,mT],Ea]*D[E\[Gamma],E\[Gamma]]-D[Q2pTprimepT[E\[Gamma],Ea,ma,mT],E\[Gamma]]*D[E\[Gamma],Ea])*) +(*Print["\!\(\*SubscriptBox[\(E\), \(N, min\)]\),\!\(\*SubscriptBox[\(E\), \(N, max\)]\) in terms of \!\(\*SubscriptBox[\(E\), \(\[Nu]\)]\): obtained as \!\(\*SubscriptBox[\(E\), \(N\)]\)(\!\(\*SuperscriptBox[\(q\), \(2\)]\) = (\!\(\*SuperscriptBox[\(q\), \(2\)]\)\!\(\*SubscriptBox[\()\), \(max\)]\)),\!\(\*SubscriptBox[\(E\), \(N\)]\)(\!\(\*SuperscriptBox[\(q\), \(2\)]\) = (\!\(\*SuperscriptBox[\(q\), \(2\)]\)\!\(\*SubscriptBox[\()\), \(min\)]\))"]*) +(*Eamin[E\[Gamma]_,mT_,ma_]=Assuming[E\[Gamma]>E\[Gamma]min[mT,ma]&&mT>0&&ma>0,Simplify[EavalE\[Gamma]q2[E\[Gamma],-tmin[ma,E\[Gamma],mT],mT]]]*) +(*Eamax[E\[Gamma]_,mT_,ma_]=EavalE\[Gamma]q2[E\[Gamma],-tmaxTemp[ma,E\[Gamma],mT],mT]//Simplify*) +(*EamaxLimit[E\[Gamma]_,mT_,ma_]=Assuming[E\[Gamma]>0&&mT>0,Simplify[Normal@Series[Eamax[E\[Gamma],mT,ma],{ma,0,4}]]];*) +(*EamaxNumeric[E\[Gamma]_,mT_,ma_]=If[ma/E\[Gamma]>10^-3,Eamax[E\[Gamma],mT,ma],EamaxLimit[E\[Gamma],mT,ma]];*) +(*E\[Gamma]min[ma_,mt_]=(ma^2+2*mt*ma)/(2*mt);*) + + +(* ::Subsection::Closed:: *) +(*Primakov cross-section*) + + +(* ::Input:: *) +(*(*Differential cross sections from https://arxiv.org/pdf/2010.15712.pdf+https://arxiv.org/pdf/1903.03586.pdf*)*) +(*d\[Sigma]PrimakovdtNucleus[ma_,t_,E\[Gamma]_,mNucleus_,Anucleus_,Znucleus_]=(2*\[Alpha]EM*FHelm[-t,Anucleus,Znucleus]^2*mNucleus^4/(t^2*(mNucleus^2-s)^2 (t-4*mNucleus^2)^2) (ma^2*t(mNucleus^2+s)-ma^4 mNucleus^2-t*((mNucleus^2-s)^2+s*t))/.{s->sinv[E\[Gamma],mNucleus]}//Simplify)/.{\[Alpha]EM->\[Alpha]EMval};*) +(*d\[Sigma]PrimakovdEaNucleus[ma_,Ea_,E\[Gamma]_,mNucleus_,Anucleus_,Znucleus_]=JacobianQ2E\[Gamma]ToEaE\[Gamma][E\[Gamma],mNucleus,ma]*d\[Sigma]PrimakovdtNucleus[ma,-Q2pTprimepT[E\[Gamma],Ea,ma,mNucleus],E\[Gamma],mNucleus,Anucleus,Znucleus];*) +(*d\[Sigma]PrimakovdtNucleons[ma_,t_,E\[Gamma]_,Znucleus_]=(Znucleus*\[Alpha]EM)/(32*mp^2*t^2 (mp^2-s)^2) (2*mp^2 (2*ma^2*t(mp^2+s+t)-ma^4*(2*mp^2+t)-t*(2*(mp^2-s)^2+2*s*t+t^2))*F1[-t]^2+F1[-t]*F2[-t]*t*(t*(mp^4-2*mp^2*(s+t)+s*(s+t))+t*ma^2*(3*mp^2-s)-ma^4 mp^2)+F2[-t]^2*4*mp^2*t (ma^2-t)^2)/.{s->sinv[E\[Gamma],mp]}/.{\[Alpha]EM->\[Alpha]EMval,mp->mSM["p"]};*) +(*q2maxEff[Anucleus_]=20(4.49/R1[Anucleus])^2;*) +(*(*\[Sigma]PrimakovNucleus1[ma_,E\[Gamma]_,mNucleus_,Anucleus_,Znucleus_]:=If[E\[Gamma]>E\[Gamma]min[ma,mNucleus], NIntegrate[d\[Sigma]PrimakovdtNucleus[ma,t,E\[Gamma],mNucleus,Anucleus,Znucleus],{t,Max[tmin[ma,E\[Gamma],mNucleus],-q2maxEff[Anucleus]],tmax[ma,E\[Gamma],mNucleus]}],0.]*)*) +(*\[Sigma]PrimakovNucleus[ma_,E\[Gamma]_,mNucleus_,Anucleus_,Znucleus_]:=If[E\[Gamma]>E\[Gamma]min[ma,mNucleus], NIntegrate[-Exp[u]*d\[Sigma]PrimakovdtNucleus[ma,-Exp[u],E\[Gamma],mNucleus,Anucleus,Znucleus],{u,Log[-tmin[ma,E\[Gamma],mNucleus]],Log[-tmax[ma,E\[Gamma],mNucleus]]}],0.]*) +(*(*EaminEffective[E\[Gamma]_,mT_,Anucleus_]=EavalE\[Gamma]q2[E\[Gamma],q2maxEff[Anucleus],mT];*) +(*EaminNumeric[E\[Gamma]_,mT_,ma_,Anucleus_]=If[ma/E\[Gamma]>0.05,Eamin[E\[Gamma],mT,ma],EaminEffective[E\[Gamma],mT,Anucleus]];*) +(*\[Sigma]PrimakovNucleusAlt[ma_,E\[Gamma]_,mNucleus_,Anucleus_,Znucleus_]:=If[E\[Gamma]>E\[Gamma]min[ma,mMo], NIntegrate[d\[Sigma]PrimakovdEaNucleus[ma,Ea,E\[Gamma],mNucleus,Anucleus,Znucleus],{Ea,EaminNumeric[E\[Gamma],mNucleus,ma,Anucleus],EamaxNumeric[E\[Gamma],mNucleus,ma]}],0.]*)*) +(*\[Sigma]PrimakovNucleons[ma_,E\[Gamma]_,Znucleus_]:=If[E\[Gamma]>E\[Gamma]min[ma,mSM["p"]],NIntegrate[d\[Sigma]PrimakovdtNucleons[ma,t,E\[Gamma],Znucleus],{t,tmin[ma,E\[Gamma],mSM["p"]],tmax[ma,E\[Gamma],mSM["p"]]}],0.]*) +(*(*Table[{E\[Gamma],\[Sigma]PrimakovNucleusAlt[1,E\[Gamma]],\[Sigma]PrimakovNucleus[1,E\[Gamma]]},{E\[Gamma],3,200,10}];*)*) + + +(* ::Section::Closed:: *) +(*Photon fusion (following Felix and https://arxiv.org/abs/1512.03069)*) + + +(* ::Subsection::Closed:: *) +(*Effective maximal and minimal energy fractions of equivalent photons *) + + +(* ::Input:: *) +(*(*Effective maximal Subscript[p, T] of photons from protons and nucleus*)*) +(*q2nucleusMax[Anucleus_]=(4.49/R1[Anucleus])^2;*) +(*q2pMax=1;*) +(*pTmaxEPA[x_,m_,q2max_]=Sqrt[pT2/.Assuming[00};*) +(*xminNucleusEPA[mNucleus_]=xminmaxEPA[mNucleus,q2nucleusMin];*) +(*\[Epsilon]Regularization=10^-9.;*) + + +(* ::Subsection::Closed:: *) +(*Differential cross-section - beam dumps*) + + +(* ::Input:: *) +(*(*CM kinematics of proton-target collisions at beam dump*)*) +(*vLabToCM[EpLab_,MP_,mNucleus_]=v/.Solve[Sqrt[EpLab^2-MP^2]-v*EpLab==mNucleus*v,v][[1]];*) +(*pCMprotonZ[EpLab_,MP_,mNucleus_]=Assuming[EpLab>0&&mNucleus>0,Simplify[(Sqrt[EpLab^2-MP^2]-vLabToCM[EpLab,MP,mNucleus]*EpLab)/Sqrt[1-vLabToCM[EpLab,MP,mNucleus]^2]]];*) +(*EpCMvalBD[EpLab_,mNucleus_]=Sqrt[pCMprotonZ[EpLab,mSM["p"],mNucleus]^2+mSM["p"]^2];*) +(*EnucleusCMvalBD[EpLab_,mNucleus_]=Sqrt[pCMprotonZ[EpLab,mSM["p"],mNucleus]^2+mNucleus^2];*) +(*(*Solutions for energy fractions Subscript[x, 1],Subscript[x, 2] carried by photons from protons and the nucleus Z in terms of the ALP mass and its transverse momentum*)*) +(*max1x2[x1_,x2_,EpCM_,EnucleusCM_]=2 Sqrt[x1*x2]*Sqrt[EpCM*EnucleusCM];*) +(*kzx1x2[x1_,x2_,EpCM_,EnucleusCM_]=x1*EpCM-x2*EnucleusCM;*) +(*sols[kzCM_,ma_,EpCM_,EnucleusCM_]=Assuming[ma>0&&kZ>0&&EpCM>0&&kzCM>0&&EnucleusCM>0,Simplify[Solve[{max1x2[x1,x2,EpCM,EnucleusCM]==ma&&kzx1x2[x1,x2,EpCM,EnucleusCM]==kzCM},{x1,x2}]]][[2]];*) +(*{xpkz[kzCM_,ma_,EpCM_],xNucleuskz[kzCM_,ma_,EnucleusCM_]}={x1/.sols[kzCM,ma,EpCM,EnucleusCM],x2/.sols[kzCM,ma,EpCM,EnucleusCM]};*) +(*(*differential cross section d\[Sigma]/Subscript[dk, T]Subscript[dk, Z]Subscript[dp, T,1]Subscript[dp, T,2]*)*) +(*IntegrandFusionBeamDumpCMframe[ma_,kzCM_,kT_,pT1_,pT2_,EpCM_,EnucleusCM_,mNucleus_,Anucleus_,Znucleus_]=2*kT*2*pT1*2*pT2*ma^2/(32*EpCM*EnucleusCM Sqrt[kzCM^2+ma^2]) ((fEPAp[pT1,xpkz[kzCM,ma,EpCM],\[Alpha]EMval]*fEPAnucleus[pT2,xNucleuskz[kzCM,ma,EnucleusCM],\[Alpha]EMval,mNucleus,Anucleus,Znucleus])/(Sqrt[2*kT^2 (pT1^2+pT2^2)-kT^4-(pT1^2-pT2^2)^2]));*) +(*(*Jacobian of transformation Subscript[k, z,CM],Subscript[k, T] \[Rule] Subscript[E, a],Subscript[\[Theta], a]*)*) +(*kTto\[Theta]a[ma_,\[Theta]a_,Ea_]=Sqrt[Ea^2-ma^2]*Sin[\[Theta]a];*) +(*kzCMtoEa[ma_,\[Theta]a_,Ea_,EpLab_,mNucleus_]=(Sqrt[Ea^2-ma^2-kTto\[Theta]a[ma,\[Theta]a,Ea]^2]-vLabToCM[EpLab,mSM["p"],mNucleus]*Ea)/Sqrt[1-vLabToCM[EpLab,mSM["p"],mNucleus]^2];*) +(*JacobiankzCMkTto\[Theta]aEa[ma_,\[Theta]a_,Ea_,EpLab_,mNucleus_]=(D[kzCMtoEa[ma,\[Theta]a,Ea,EpLab,mNucleus],\[Theta]a]*D[kTto\[Theta]a[ma,\[Theta]a,Ea],Ea]-D[kzCMtoEa[ma,\[Theta]a,Ea,EpLab,mNucleus],Ea]*D[kTto\[Theta]a[ma,\[Theta]a,Ea],\[Theta]a])//Simplify*) +(*(*Differential probability d^2P/Subscript[d\[Theta], a]Subscript[dE, a]*)*) +(*IntegrandFusionBeamDump[ma_,\[Theta]a_,Ea_,pT1_,pT2_,EpLab_,mNucleus_,Anucleus_,Znucleus_]=Abs[JacobiankzCMkTto\[Theta]aEa[ma,\[Theta]a,Ea,EpLab,mNucleus]]*IntegrandFusionBeamDumpCMframe[ma,kzCMtoEa[ma,\[Theta]a,Ea,EpLab,mNucleus],kTto\[Theta]a[ma,\[Theta]a,Ea],pT1,pT2,EpCMvalBD[EpLab,mNucleus],EnucleusCMvalBD[EpLab,mNucleus],mNucleus,Anucleus,Znucleus];*) + + +(* ::Subsubsection::Closed:: *) +(*Explicit form (with all parameters inserted)*) + + +(* ::Input:: *) +(*Do[*) +(*Module[{Z,Facility},*) +(*Z=z;*) +(*Facility=facility;*) +(*IntegrandFusionTemp[ma_,\[Theta]a_,Ea_,pT1_,pT2_,Facility,Z]=IntegrandFusionBeamDump[ma,\[Theta]a,Ea,pT1,pT2,EmaxFacility[Facility],mnucleus[Z],anucleus[Z],znucleus[Z]];*) +(*IntegrandFusion[ma_,\[Theta]a_,Ea_,pT1_,pT2_,Facility,Z]=If[Abs[pT1-pT2](1+\[Epsilon]Regularization)mnucleus[Z],EpLab->EmaxFacility[Facility],Anucleus->anucleus[Z]};*) +(*(*Converting the integrand to the variables m = (Subscript[p, T,1]+Subscript[p, T,2]),t=(Subscript[p, T,1]-Subscript[p, T,2])*)*) +(*tmax[ma_,\[Theta]a_,Ea_,Facility,Z]=Min[kTto\[Theta]a[ma,\[Theta]a,Ea],(pTprotonMaxEPAexpl[ma,\[Theta]a,Ea,Facility,Z]-pTnucleusMinEPA[mnucleus[Z]])];*) +(*tmin[ma_,\[Theta]a_,Ea_,Facility,Z]=-Min[pTnucleusMaxEPAexpl[ma,\[Theta]a,Ea,Facility,Z],kTto\[Theta]a[ma,\[Theta]a,Ea]];*) +(*mmax[ma_,\[Theta]a_,Ea_,Facility,Z]=(pTprotonMaxEPAexpl[ma,\[Theta]a,Ea,Facility,Z]+pTnucleusMaxEPAexpl[ma,\[Theta]a,Ea,Facility,Z]);*) +(*mmin[ma_,\[Theta]a_,Ea_,Facility,Z]=Max[pTnucleusMinEPA[mnucleus[Z]],kTto\[Theta]a[ma,\[Theta]a,Ea]];*) +(*IntegrandFusionConverted[ma_,\[Theta]a_,Ea_,m_,t_,Facility,Z]=1/2 IntegrandFusion[ma,\[Theta]a,Ea,(m+t)/2,(m-t)/2,Facility,Z][[2]];*) +(*\[Epsilon]v=10^-9;*) +(*(*d2\[Sigma]d\[Theta]adEaFusionFast[ma_,\[Theta]a_,Ea_,Facility,Z]:=With[{MMAX=mmax[ma,\[Theta]a,Ea,Facility,Z],MMIN=mmin[ma,\[Theta]a,Ea,Facility,Z]},GeVm2Topb*If[ma"AdaptiveMonteCarlo"],0.]];*) +(*d2\[Sigma]d\[Theta]adEaFusionSlow[ma_,\[Theta]a_,Ea_,Facility,Z]:=With[{MMAX=mmax[ma,\[Theta]a,Ea,Facility,Z],MMIN=mmin[ma,\[Theta]a,Ea,Facility,Z]},GeVm2Topb*If[ma"DoubleExponential"],0.]];*) +(*d2\[Sigma]d\[Theta]adEaFusion1[ma_,\[Theta]a_,Ea_,Facility,Z]:=With[{MMAX=mmax[ma,\[Theta]a,Ea,Facility,Z],MMIN=mmin[ma,\[Theta]a,Ea,Facility,Z]},GeVm2Topb*If[ma"DoubleExponential"],0.]];*) +(*(*Because of numeric inaccuracy, Mathematica will return some imaginary part. This is omitted by taking Re*)*) +(*d2Pd\[Theta]adEaFusion[ma_,\[Theta]a_,Ea_,Facility,Z]:=If[Ea>ma,Re[d2\[Sigma]d\[Theta]adEaFusion[ma,\[Theta]a,Ea,Facility,Z]/\[Sigma]pNucleus[Z]],0.];*) +(*d2Pd\[Theta]adEaFusion1[ma_,\[Theta]a_,Ea_,Facility,Z]:=If[Ea>ma,Re[d2\[Sigma]d\[Theta]adEaFusion1[ma,\[Theta]a,Ea,Facility,Z]/\[Sigma]pNucleus[Z]],0.];*) +(*(*d2Pd\[Theta]adEaFusionSlow[ma_,\[Theta]a_,Ea_,Facility,Z]:=If[Ea>ma,d2\[Sigma]d\[Theta]adEaFusionSlow[ma,\[Theta]a,Ea,Facility,Z]/\[Sigma]pNucleus[Z],0.];*) +(*d2Pd\[Theta]adEaFusionFast[ma_,\[Theta]a_,Ea_,Facility,Z]:=If[Ea>ma,d2\[Sigma]d\[Theta]adEaFusionFast[ma,\[Theta]a,Ea,Facility,Z]/\[Sigma]pNucleus[Z],0.];*)*) +(**) +(*];*) +(*,{z,{"Fe","Mo","C"}},{facility,{"SPS","FermilabBD","Serpukhov"}}]*) +(*Quiet[d2Pd\[Theta]adEaFusion[1,10^-4.,100,"SPS","Mo"]]//AbsoluteTiming*) +(*(*Quiet[d2Pd\[Theta]adEaFusionSlow[0.02,10^-4.,10,"SPS","Mo"]]//AbsoluteTiming*) +(*Quiet[d2Pd\[Theta]adEaFusionFast[0.02,10^-4.,10,"SPS","Mo"]]//AbsoluteTiming*)*) +(*(*{#,d2Pd\[Theta]adEaFusion[1.3,0.0005,#,"SPS","Mo"]}&/@Table[x,{x,1.31,400,5}]*) +(*d2Pd\[Theta]adEaFusion1[1.3,0.0005,45,"SPS","Mo"]//AbsoluteTiming*)*) + + +(* ::Subsubsection::Closed:: *) +(*Tests (compare with Fig. 4 from https://arxiv.org/abs/1512.03069, results should be larger by the factor (Subscript[Z, mo]/Subscript[Z, copper])^2=2.1)*) + + +(* ::Item::Closed:: *) +(*Test 1*) + + +(* ::Input:: *) +(*(*gatest=10^-4;*) +(*\[Theta]atest=10^-2;*) +(*ZmoZcopper2=2.1;*) +(*tabb=Join[ParallelTable[{Ea,1/ZmoZcopper2Quiet[d2\[Sigma]d\[Theta]adEaFusion1[0.05,\[Theta]atest,Ea,"SPS","Mo"]/\[Theta]atest*gatest^2]},{Ea,Table[10^x,{x,Log10[0.08],2,0.1}]}]];//AbsoluteTiming*) +(*tabb2=Join[ParallelTable[{Ea,1/ZmoZcopper2Quiet[d2\[Sigma]d\[Theta]adEaFusion1[0.5,\[Theta]atest,Ea,"SPS","Mo"]/\[Theta]atest*gatest^2]},{Ea,Table[10^x,{x,Log10[0.7],2,0.1}]}]];//AbsoluteTiming*) +(*ListLogLogPlot[{tabb,tabb2},PlotRange\[Rule]{{1,100},{5,1100}},Joined\[Rule]True,ImageSize\[Rule]Large,Frame\[Rule]True,GridLines\[Rule]Automatic]*)*) + + +(* ::Item::Closed:: *) +(*Test 2*) + + +(* ::Input:: *) +(*(*Eatest=10;*) +(*gatest=10^-4;*) +(*tabb=Join[ParallelTable[{10^x,1/ZmoZcopper2Quiet[d2\[Sigma]d\[Theta]adEaFusion1[0.05,10^x,Eatest,"SPS","Mo"]/Sin[10^x]*gatest^2]},{x,-4,-1,0.2}]];//AbsoluteTiming*) +(*tabb2=Join[ParallelTable[{10^x,1/ZmoZcopper2Quiet[d2\[Sigma]d\[Theta]adEaFusion1[0.5,10^x,Eatest,"SPS","Mo"]/Sin[10^x]*gatest^2]},{x,-4,-1,0.2}]];//AbsoluteTiming*) +(*ListLogLogPlot[Evaluate[{tabb,tabb2}],Joined\[Rule]True,ImageSize\[Rule]Large,Frame\[Rule]True,PlotRange->{{10^-4.,0.1},{1,1000}},GridLines\[Rule]Automatic]*)*) +(**) + + +(* ::Subsection::Closed:: *) +(*Differential cross-section - colliders*) + + +(* ::Input:: *) +(*(*Solutions for energy fractions Subscript[x, 1],Subscript[x, 2] carried by photons from protons in terms of the ALP mass and its transverse momentum*)*) +(*max1x2Colliders[x1_,x2_,EpCM_]=2 Sqrt[x1*x2]*EpCM;*) +(*kzx1x2Colliders[x1_,x2_,EpCM_]=EpCM*(x1-x2);*) +(*solsColliders[kzCM_,ma_,EpCM_]=Assuming[ma>0&&kZ>0&&EpCM>0&&kzCM>0,Simplify[Solve[{max1x2Colliders[x1,x2,EpCM]==ma&&kzx1x2Colliders[x1,x2,EpCM]==kzCM},{x1,x2}]]][[2]];*) +(*{xp1kzColliders[kzCM_,ma_,EpCM_],xp2kzColliders[kzCM_,ma_,EpCM_]}={x1/.solsColliders[kzCM,ma,EpCM],x2/.solsColliders[kzCM,ma,EpCM]};*) +(*(*Diff. cross-section of the ALP production in terms of Subscript[k, T] and Subscript[k, z] of the ALP*)*) +(*IntegrandFusionCollidersTemp[ma_,kzCM_,kT_,pT1_,pT2_,EpCM_]=2*kT*2*pT1*2*pT2*ma^2/(32*EpCM*EpCM Sqrt[kzCM^2+ma^2]) (fEPAp[pT1,xp1kzColliders[kzCM,ma,EpCM],\[Alpha]EMval]*fEPAp[pT2,xp2kzColliders[kzCM,ma,EpCM],\[Alpha]EMval])/Sqrt[2*kT^2 (pT1^2+pT2^2)-kT^4-(pT1^2-pT2^2)^2]//Simplify;*) +(*kTto\[Theta]aCMEaCM[ma_,\[Theta]a_,Ea_]=Sqrt[Ea^2-ma^2]Sin[\[Theta]a];*) +(*kzCMto\[Theta]aCMEaCM[ma_,\[Theta]a_,Ea_]=Sqrt[Ea^2-ma^2]Cos[\[Theta]a];*) +(*JacobiankTkzCMto\[Theta]aCMEaCM[ma_,\[Theta]a_,Ea_]=D[kTto\[Theta]aCMEaCM[ma,\[Theta]a,Ea],\[Theta]a]*D[kzCMto\[Theta]aCMEaCM[ma,\[Theta]a,Ea],Ea]-D[kTto\[Theta]aCMEaCM[ma,\[Theta]a,Ea],Ea]*D[kzCMto\[Theta]aCMEaCM[ma,\[Theta]a,Ea],\[Theta]a]//Simplify;*) +(*(*Diff. cross-section of the ALP production in terms of Subscript[\[Theta], a] and Subscript[E, a] of the ALP*)*) +(*IntegrandFusionColliders[ma_,\[Theta]a_,Ea_,pT1_,pT2_,EpCM_]=JacobiankTkzCMto\[Theta]aCMEaCM[ma,\[Theta]a,Ea]*IntegrandFusionCollidersTemp[ma,kzCMto\[Theta]aCMEaCM[ma,\[Theta]a,Ea],kTto\[Theta]aCMEaCM[ma,\[Theta]a,Ea],pT1,pT2,EpCM];*) +(*xp1\[Theta]aEaColliders[ma_,\[Theta]a_,Ea_,EpCM_]=xp1kzColliders[kzCMto\[Theta]aCMEaCM[ma,\[Theta]a,Ea],ma,EpCM];*) +(*xp2\[Theta]aEaColliders[ma_,\[Theta]a_,Ea_,EpCM_]=xp2kzColliders[kzCMto\[Theta]aCMEaCM[ma,\[Theta]a,Ea],ma,EpCM];*) + + +(* ::Subsubsection::Closed:: *) +(*Explicit form (with all parameters inserted)*) + + +(* ::Input:: *) +(*Do[*) +(*Module[{Facility},*) +(*Facility=facility;*) +(*\[Epsilon]Regularization=(*10^-10.*)0.;*) +(*IntegrandFusionTemp1[ma_,\[Theta]a_,Ea_,pT1_,pT2_,Facility,"p"]=IntegrandFusionColliders[ma,\[Theta]a,Ea,pT1,pT2,EmaxFacility[Facility]];*) +(*IntegrandFusionTemp2[ma_,\[Theta]a_,Ea_,pT1_,pT2_,Facility,"p"]=If[Abs[pT1-pT2](1+\[Epsilon]Regularization)Automatic],0.]]//Re*) +(*];*) +(*d2\[Sigma]d\[Theta]adEaFusionFast[ma_,\[Theta]a_,Ea_,Facility,"p"]:=With[{MMIN=mmin[ma,\[Theta]a,Ea,Facility,"p"],MMAX=mmax[ma,\[Theta]a,Ea,Facility,"p"]},*) +(*GeVm2Topb*If[ma"AdaptiveMonteCarlo"],0.]]//Re;*)*) +(*d2\[Sigma]d\[Theta]adEaFusion[ma_,\[Theta]a_,Ea_,Facility,"p"]:=With[{MMIN=mmin[ma,\[Theta]a,Ea,Facility,"p"],MMAX=mmax[ma,\[Theta]a,Ea,Facility,"p"]},*) +(*GeVm2Topb*If[ma"DoubleExponential"],0.]]//Re;*) +(*d2Pd\[Theta]adEaFusion[ma_,\[Theta]a_,Ea_,Facility,"p"]:=1/\[Sigma]pp[Facility] If[Ea>ma,d2\[Sigma]d\[Theta]adEaFusion[ma,\[Theta]a,Ea,Facility,"p"],0.];*) +(*(*d2Pd\[Theta]adEaFusionFast[ma_,\[Theta]a_,Ea_,Facility,"p"]:=1/\[Sigma]pp[Facility]If[Ea>ma,d2\[Sigma]d\[Theta]adEaFusionFast[ma,\[Theta]a,Ea,Facility,"p"],0.];*) +(*d2Pd\[Theta]adEaFusionSlow[ma_,\[Theta]a_,Ea_,Facility,"p"]:=1/\[Sigma]pp[Facility]If[Ea>ma,d2\[Sigma]d\[Theta]adEaFusionSlow[ma,\[Theta]a,Ea,Facility,"p"],0.];*)*) +(*]*) +(*,{facility,{"LHC","FCC-hh"}}]*) +(*mf=0.3;*) +(*thf=10^-3.;*) +(*Ef=500;*) +(*xp2\[Theta]aEaColliders[mf,thf,Ef,EmaxFacility["LHC"]]*) +(*d2Pd\[Theta]adEaFusion[mf,thf,Ef,"LHC","p"]//AbsoluteTiming*) +(*(*d2Pd\[Theta]adEaFusionSlow[mf,thf,Ef,"LHC","p"]//AbsoluteTiming*) +(*d2Pd\[Theta]adEaFusionFast[mf,thf,Ef,"LHC","p"]//AbsoluteTiming*)*) +(*(*nsim=100;*) +(*thvals=10^RandomReal[{-5,Log10[Pi/2]},nsim]//N*) +(*fac="LHC";*) +(*mf=0.02;*) +(*evals=10^RandomReal[{Log10[mf],Log10[EmaxFacility[fac]]},nsim]//N*) +(*tabb=Select[ParallelTable[{thvals[[i]],evals[[i]],If[evals[[i]]>mf,xp1\[Theta]aEaColliders[mf,thvals[[i]],evals[[i]],EmaxFacility[fac]],0.],If[evals[[i]]>mf,xp2\[Theta]aEaColliders[mf,thvals[[i]],evals[[i]],EmaxFacility[fac]],0.],Quiet[d2Pd\[Theta]adEaFusion[mf,thvals[[i]],evals[[i]],fac,"p"]]//AbsoluteTiming,Table[Quiet[d2Pd\[Theta]adEaFusionFast[mf,thvals[[i]],evals[[i]],fac,"p"]],3]//Mean//AbsoluteTiming,Quiet[d2Pd\[Theta]adEaFusionSlow[mf,thvals[[i]],evals[[i]],fac,"p"]]//AbsoluteTiming,{mmin[mf,thvals[[i]],evals[[i]],fac,"p"],mmax[mf,thvals[[i]],evals[[i]],fac,"p"]},{tmin[mf,thvals[[i]],evals[[i]],fac,"p"],tmax[mf,thvals[[i]],evals[[i]],fac,"p"]},kTto\[Theta]aCMEaCM[mf,thvals[[i]],evals[[i]]]},{i,1,nsim,1}],#[[5,2]]!=0.&];//AbsoluteTiming*) +(*tttt1=Take[SortBy[tabb,-#[[5,1]]&],{1,Min[50,Length[tabb]]}];*) +(*tttt2=Take[SortBy[tabb,-Abs[(#[[5,2]]-#[[7,2]])/#[[5,2]]]&],{1,Min[50,Length[tabb]]}]*)*) + + +(* ::Chapter::Closed:: *) +(*ALP-fermion*) + + +(* ::Section::Closed:: *) +(*Relevant processes*) + + +(* ::Input:: *) +(*(*List of processes*)*) +(*LLPname="ALP-fermion";*) +(*(*There are production channels via mixing with neutral light mesons, ##-mixing*)*) +(*ProcessesListAll[LLPname]={"B","Pi0","Eta","EtaPr"};*) +(*(*Topology of the process*)*) +(*MapThread[(ProductionType[LLPname,#1]=#2)&,{ProcessesListAll[LLPname],{"Decay","Mixing","Mixing","Mixing"}}];*) +(*(*Particle content: mother particle, decay products*)*) +(*MapThread[(ReactionProductsList[LLPname,#1]=#2)&,{ProcessesListAll[LLPname],{{"Bplus","PiCharged",LLPname},{"Pi0",LLPname},{"Eta",LLPname},{"EtaPr",LLPname}}}];*) +(*LLPname//Clear*) + + +(* ::Chapter::Closed:: *) +(*DP*) + + +(* ::Section::Closed:: *) +(*Relevant processes*) + + +(* ::Input:: *) +(*(*List of processes*)*) +(*LLPname="DP";*) +(*(*Only decays, mixing with \[Rho]^0, and proton bremsstrahlung are listed. Drell-Yan is computed externally (MadGraph+pythia)*)*) +(*ProcessesListAll[LLPname]={"Pi0","Eta","EtaPr","Bremsstrahlung","Mixing-Old"};*) +(*(*Topology of the process*)*) +(*MapThread[(ProductionType[LLPname,#1]=#2)&,{ProcessesListAll[LLPname],{"Decay","Decay","Decay","Scattering","Mixing"}}];*) +(*(*Particle content: mother particle, decay products*)*) +(*MapThread[(ReactionProductsList[LLPname,#1]=#2)&,{ProcessesListAll[LLPname],{{"Pi0","photon",LLPname},{"Eta","photon",LLPname},{"EtaPr","photon",LLPname},{"p",LLPname},{"Rho0",LLPname}}}];*) +(*LLPname//Clear*) + + +(* ::Chapter::Closed:: *) +(*B-Subscript[L, \[Alpha]]*) + + +(* ::Section::Closed:: *) +(*Relevant processes*) + + +(* ::Input:: *) +(*BLlist={"B-L","B-3Lmu","B-Le-3Lmu+Ltau","B-3Le-Lmu+Ltau"};*) +(*Do[*) +(*(*List of processes*)*) +(*LLPname=fipname;*) +(*(*Only decays, mixing with \[Omega], and proton bremsstrahlung are listed. Drell-Yan is computed externally (MadGraph+pythia)*)*) +(*ProcessesListAll[LLPname]={"Pi0","Eta","EtaPr","Bremsstrahlung","Mixing-Old"};*) +(*(*Topology of the process*)*) +(*MapThread[(ProductionType[LLPname,#1]=#2)&,{ProcessesListAll[LLPname],{"Decay","Decay","Decay","Scattering","Mixing"}}];*) +(*(*Particle content: mother particle, decay products*)*) +(*MapThread[(ReactionProductsList[LLPname,#1]=#2)&,{ProcessesListAll[LLPname],{{"Pi0","photon",LLPname},{"Eta","photon",LLPname},{"EtaPr","photon",LLPname},{"p",LLPname},{"Omega",LLPname}}}];*) +(*,{fipname,BLlist}]*) +(*LLPname//Clear*) + + +(* ::Chapter::Closed:: *) +(*Scalar*) + + +(* ::Section::Closed:: *) +(*Relevant processes*) + + +(* ::Input:: *) +(*(*List of processes*)*) +(*LLPname="Scalar";*) +(*(*The kinematics of 2-body decays of B via the mixing channel is approximated by B -> \[Pi]+S. This is reasonable since at low scalar masses the accompanying meson mass is irrelevant, while at higher masses, only \[Pi],K may be*)*) +(*ProcessesListAll[LLPname]={"B-mixing","Bs-quartic","B-quartic","h-quartic","K-mixing","Bremsstrahlung"};*) +(*(*Topology of the process*)*) +(*MapThread[(ProductionType[LLPname,#1]=#2)&,{ProcessesListAll[LLPname],{"Decay","Decay","Decay","Decay","Decay","Scattering"}}];*) +(*(*Particle content: mother particle, decay products*)*) +(*MapThread[(ReactionProductsList[LLPname,#1]=#2)&,{ProcessesListAll[LLPname],{{"Bplus","PiCharged",LLPname},{"Bs",LLPname,LLPname},{"Bplus","Kplus",LLPname,LLPname},{"h",LLPname,LLPname},{"Kplus","PiCharged",LLPname},{"p",LLPname}}}];*) + + +(* ::Section::Closed:: *) +(*Squared matrix elements for 3-body processes (https://arxiv.org/abs/1904.10447)*) + + +(* ::Input:: *) +(*MBpole=Sqrt[38.];*) +(*Msquared3Body[LLPname,"B-quartic",mLLP_,E1_,E3_]=(1/(1-ScalarProduct[k-k1,k-k1]/MBpole^2)^2//ExpandScalarProduct)/.{ScalarProduct[k,k]->ProductKK,ScalarProduct[k1,k1]->ProductK1K1,ScalarProduct[k,k1]-> ProductKK1energy}/.{m->mSM["Bplus"],m1->mSM["PiCharged"]}*) +(*LLPname//Clear*) + + +(* ::Chapter::Closed:: *) +(*MCPs*) + + +(* ::Section::Closed:: *) +(*Relevant processes*) + + +(* ::Input:: *) +(*LLPname="MCP";*) +(*(*Only decays are listed. Drell-Yan is computed externally (MadGraph+pythia)*)*) +(*ProcessesListAll[LLPname]={"Pi0","Eta","Phi","JPsi","Rho0","Omega","Upsilon"};*) +(*(*Topology of the process*)*) +(*MapThread[(ProductionType[LLPname,#1]=#2)&,{ProcessesListAll[LLPname],Table["Decay",Length[ProcessesListAll[LLPname]]]}];*) +(*(*Particle content: mother particle, decay products*)*) +(*MapThread[(ReactionProductsList[LLPname,#1]=#2)&,{ProcessesListAll[LLPname],{{"Pi0","photon",LLPname,LLPname},{"Eta","photon",LLPname,LLPname},{"Phi",LLPname,LLPname},{"JPsi",LLPname,LLPname},{"Rho0",LLPname,LLPname},{"Omega",LLPname,LLPname},{"Upsilon",LLPname,LLPname}}}];*) + + +(* ::Section::Closed:: *) +(*Matrix elements of 3-body decays*) + + +(* ::Subsection::Closed:: *) +(*Decay of \[Pi]^0/\[Eta]*) + + +(* ::Input:: *) +(*LLPname="MCP";*) +(*FileM2MCPprod=FileNameJoin[{NotebookDirectory[],"phenomenology/"<>LLPname<>"/Production probabilities/M2Pi0Eta.mx"}];*) +(*If[!FileExistsQ[FileM2MCPprod],*) +(*MmesonDecayMCP3Body=LeviCivita[\[Mu],\[Nu],\[Alpha],\[Beta]]/ScalarProduct[k2+k3,k2+k3] (FV[k1,\[Mu]]*PolarizationVector[k1,\[Nu]]-FV[k1,\[Nu]]*PolarizationVector[k1,\[Mu]])(-FV[k2+k3,\[Alpha]]*MT[\[Beta],\[Delta]]+FV[k2+k3,\[Beta]]*MT[\[Alpha],\[Delta]])SpinorVBar[k2,m2] . GA[\[Delta]] . SpinorU[k3,m3]//Contract;*) +(*MmesonDecayMCP3BodyStar=MmesonDecayMCP3Body//ComplexConjugate;*) +(*MmesonDecayMCP3BodySquaredTemp=(Simplify[Expand[DoPolarizationSums[FermionSpinSum[MmesonDecayMCP3Body*MmesonDecayMCP3BodyStar]/.DiracTrace->TR,k1]//Contract//Simplify]]/.{ScalarProduct[k,k]->ProductKK,ScalarProduct[k1,k1]->ProductK1K1,ScalarProduct[k2,k2]->ProductK2K2,ScalarProduct[k3,k3]->ProductK3K3}/.{ScalarProduct[k,k1]-> ProductKK1energy,ScalarProduct[k2,k3]->ProductK2K3energy,ScalarProduct[k1,k3]->ProductK1K3energy,ScalarProduct[k,k3]->ProductKK3energy,ScalarProduct[k1,k2]->ProductK1K2energy,ScalarProduct[k,k2]->ProductKK2energy});*) +(*Msquared3Body[LLPname,"Pi0",mLLP_,E1_,E3_]=MmesonDecayMCP3BodySquaredTemp/.{m->mSM["Pi0"],m1->0,m2->mLLP,m3->mLLP}//Simplify;*) +(*Msquared3Body[LLPname,"Eta",mLLP_,E1_,E3_]=MmesonDecayMCP3BodySquaredTemp/.{m->mSM["Eta"],m1->0,m2->mLLP,m3->mLLP}//Simplify;*) +(*Export[FileM2MCPprod,{Msquared3Body[LLPname,"Pi0",mLLP,E1,E3],Msquared3Body[LLPname,"Eta",mLLP,E1,E3]},"MX"]*) +(*,*) +(*{Msquared3Body[LLPname,"Pi0",mLLP_,E1_,E3_],Msquared3Body[LLPname,"Eta",mLLP_,E1_,E3_]}=Import[FileM2MCPprod,"MX"];*) +(*]*) +(*LLPname//Clear*) + + +(* ::Chapter::Closed:: *) +(*Common definitions*) + + +(* ::Section::Closed:: *) +(*Bremsstrahlung*) + + +(* ::Input:: *) +(*Quiet[NotebookEvaluate[FileNameJoin[{NotebookDirectory[],"codes/Bremsstrahlung.nb"}]]];*) + + +(* ::Section::Closed:: *) +(*Threshold mass for all processes*) + + +(* ::Input:: *) +(*(*The list with all particular LLPs*)*) +(*LLPlist=Keys[DownValues@ProcessesListAll][[All,1,1]]//Sort;*) +(*(*The list where HNL-mixing-e, HNL-mixing-mu, HNL-mixing-tau is replaced with single HNL*)*) +(*LLPlistEffective=Join[Select[LLPlist,!StringContainsQ[#,"HNL"]&],{"HNL"}]//Sort;*) +(*(*Maximal LLP mass for the implemented production channels*)*) +(*Do[*) +(*Do[*) +(*Module[{partlist,mother,nfips},*) +(*partlist=ReactionProductsList[LLP,mode];*) +(*mother=partlist[[1]];*) +(*(*If the production is via mixing or the mother particle is proton, no robust estimate of the threshold exists*)*) +(*If[Length[partlist]==2||mother=="p",MaxMass[LLP,Facility,mode]=Min[4.,EcmFacility[Facility]-2*0.938],*) +(*(*If the mother particle cannot be produced at the given facility, then MaxMass = 0*)*) +(*If[IfSMatFacility[mother,Facility]==0,MaxMass[LLP,Facility,mode]=0.];*) +(*(*If it may be produced, then calculating the max mass as (Subscript[m, mother]-\[Sum]Subscript[m, SM products])/Subscript[n, LLPs,per decay]*)*) +(*If[IfSMatFacility[mother,Facility]!=0,*) +(*nfips=Select[partlist,#==LLP&]//Length;*) +(*MaxMass[LLP,Facility,mode]=mSM[partlist[[1]]]-Sum[mSM[partlist[[i]]],{i,2,Length[partlist]-nfips}];*) +(*If[nfips>1,MaxMass[LLP,Facility,mode]=MaxMass[LLP,Facility,mode]/nfips];*) +(*]];*) +(*],{mode,ProcessesListAll[LLP]}],{Facility,FacilitiesList},{LLP,LLPlist}]*) +(*(*_______________*)*) +(*(*For averaged HNL production*)*) +(*(*_______________*)*) +(*(*Max mass for averaged production from B*)*) +(*Do[MaxMass[HNL,Facility,"B"]=Max[MaxMass[HNL,Facility,#]&/@{"B-3-body","Bc","B-2-body"}],{HNL,ListHNLs},{Facility,FacilitiesList}]*) +(*(*Max mass for averaged production from D*)*) +(*Do[*) +(*prl=Select[{"D-3-body","D-2-body","\[Tau]-2-body","\[Tau]-3-body"},MemberQ[ProcessesListAll[HNL],#]==True&];*) +(*MaxMass[HNL,Facility,"D"]=Max[MaxMass[HNL,Facility,#]&/@prl],{HNL,ListHNLs},{Facility,FacilitiesList}]*) + + +(* ::Section::Closed:: *) +(*List of facility-specific channels*) + + +(* ::Input:: *) +(*(*Selecting only those channels for which:*)*) +(*(*1. Is kinematically possible to produce LLP at the given facility (==max LLP mass at the given facility is > 0)*)*) +(*(*2. There is available mother particle distribution*)*) +(*Do[*) +(*Module[{proc,mother},*) +(*If[!StringContainsQ[LLP,"HNL"],*) +(*(*First, filtering to processes which are kinematically possible*)*) +(*ProcessesListFacilityTemp[LLP,Facility]=Select[ProcessesListAll[LLP],MaxMass[LLP,Facility,#]>0&];*) +(*(*Second, checking if the mother distribution is present*)*) +(*ProcessesListFacility[LLP,Facility]={};*) +(*Do[*) +(*proc=ProcessesListFacilityTemp[LLP,Facility][[i]];*) +(*mother=ReactionProductsList[LLP,proc][[1]];*) +(*(*Specific condition is to *)*) +(*If[Select[sortedDataPairs,#[[1]]==Facility&&MemberQ[{mother,SimilarParticle[Facility,mother]},#[[2]]]&]!={},*) +(*ProcessesListFacility[LLP,Facility]=Join[ProcessesListFacility[LLP,Facility],{proc}]*) +(*];*) +(*,{i,1,Length[ProcessesListFacilityTemp[LLP,Facility]],1}]*) +(*];*) +(*If[StringContainsQ[LLP,"HNL"],*) +(*ProcessesListFacilityTemp[LLP,Facility]=Select[{"W","K","D","B","mu","PiCharged"},MaxMass[LLP,Facility,#]>0&];*) +(*ProcessesListFacility[LLP,Facility]={};*) +(*Do[*) +(*proc=ProcessesListFacilityTemp[LLP,Facility][[i]];*) +(*mother=If[proc=="D","tau",If[proc=="B","Bplus",ReactionProductsList[LLP,proc][[1]]]];*) +(*(*Specific condition is to *)*) +(*If[Select[sortedDataPairs,#[[1]]==Facility&&MemberQ[{mother,SimilarParticle[Facility,mother]},#[[2]]]&]!={},*) +(*ProcessesListFacility[LLP,Facility]=Join[ProcessesListFacility[LLP,Facility],{proc}]*) +(*];*) +(*,{i,1,Length[ProcessesListFacilityTemp[LLP,Facility]],1}]*) +(*];*) +(*];*) +(*,{LLP,LLPlist},{Facility,FacilitiesList}]*) +(*Do[ProcessesListFacility["HNL",Facility]=Table[ProcessesListFacility[LLP,Facility],{LLP,ListHNLs}]//Flatten//DeleteDuplicates,{Facility,FacilitiesList}]*) +(*Print["List of all implemented channels:"]*) +(*TabProcesses=Flatten[Table[{LLP,Facility,ProcessesListFacility[LLP,Facility]},{LLP,LLPlist},{Facility,FacilitiesList}],1]*) + + +(* ::Title::Closed:: *) +(*Preliminary code: PDFs of LLPs*) + + +(* ::Chapter::Closed:: *) +(*Production via decays: sampling boosted LLPs*) + + +(* ::Section::Closed:: *) +(*Generic code for phase space of 2-body and 3-body decays at rest frame of the decaying particle*) + + +(* ::Subsection::Closed:: *) +(*2-body*) + + +(* ::Input:: *) +(*tabPS2bodyCompiled=Hold@Compile[{{MASSM,_Real},{mLLP,_Real},{m1,_Real},{\[Theta]rand,_Real},{\[Phi]rand,_Real}},Module[{pval,px1,py1,pz1,E12body,E22body},*) +(*(*Energies of particles 1 (E12body) and 2 (E22body) at the rest frame of decaying particle*)*) +(*E12body=(MASSM^2-mLLP^2+m1^2)/(2*MASSM);*) +(*E22body=(MASSM^2-m1^2+mLLP^2)/(2*MASSM);*) +(*pval=pPar[E22body,mLLP];*) +(*px1=pval*Cos[\[Phi]rand]*Sin[\[Theta]rand];*) +(*py1=pval*Sin[\[Phi]rand]*Sin[\[Theta]rand];*) +(*pz1=pval*Cos[\[Theta]rand];*) +(*{-px1,-py1,-pz1,E12body,m1,px1,py1,pz1,E22body,mLLP}*) +(*],CompilationTarget->"C",RuntimeOptions->"Speed",RuntimeAttributes->{Listable},Parallelization->True]/.DownValues@pPar//ReleaseHold;*) +(*<=4*(E1r^2-m1^2)*(E3r^2-m3^2)];*) +(*{E1r,E3r}],CompilationTarget->"C",RuntimeOptions->"Speed",RuntimeAttributes->{Listable},Parallelization->True];*) +(*(*The routine that computes the weights M^2(Subscript[E, 1],Subscript[E, 3])Subscript[\[CapitalDelta]E, 3](Subscript[E, 1]) for the given uniformly distributed Subscript[E, 1],Subscript[E, 3]*)*) +(*weightsNonUniformComp:=Hold@Compile[{{tabe1e3,_Real,1},MASSM,MASS1,MASS2,MASS3},Module[{e1,e3},*) +(*e1=Compile`GetElement[tabe1e3,1];*) +(*e3=Compile`GetElement[tabe1e3,2];*) +(*Abs[distr[e1,e3]*\[CapitalDelta]E3[e1,MASSM,MASS1,MASS2,MASS3]]*) +(*],CompilationTarget->"MVM",RuntimeOptions->"Speed",RuntimeAttributes->{Listable},Parallelization->True]/.ruleDown[{distr,\[CapitalDelta]E3}]//ReleaseHold;*) +(*weightsUniformComp=Hold@Compile[{{tabe1e3,_Real,1},MASSM,MASS1,MASS2,MASS3},Module[{e1,e3},*) +(*e1=Compile`GetElement[tabe1e3,1];*) +(*Abs[\[CapitalDelta]E3[e1,MASSM,MASS1,MASS2,MASS3]]*) +(*],CompilationTarget->"C",RuntimeOptions->"Speed",RuntimeAttributes->{Listable},Parallelization->True]/.ruleDown[{\[CapitalDelta]E3}]//ReleaseHold;*) +(*E3valsComp=Hold@Compile[{{E1vals,_Real},MASSM,MASS1,MASS2,MASS3},Module[{e3max,e3min},*) +(*e3min=Abs[E3domain1[E1vals,MASSM,MASS1,MASS2,MASS3]];*) +(*e3max=Abs[E3domain2[E1vals,MASSM,MASS1,MASS2,MASS3]];*) +(*RandomReal[{e3min,e3max}]*) +(*],CompilationTarget->"C",RuntimeOptions->"Speed",RuntimeAttributes->{Listable},Parallelization->True]/.ruleDown[{E3domain2,E3domain1}]//ReleaseHold*) +(*NN=10^6;*) +(*BlockRandomEnergies[LLP_,Process_,mLLP_,Nevents_]:=Module[{partcontent,m,m1,m2,m3},*) +(*partcontent=ReactionProductsList[LLP,Process];*) +(*{m,m1,m2,m3}={mSM[partcontent[[1]]],mSM[partcontent[[2]]],If[partcontent[[3]]==LLP,mLLP,mSM[partcontent[[3]]]],mLLP};*) +(*distr[E1_,E3_]=Msquared3Body[LLP,Process,m,E1,E3]//Simplify;*) +(*E1maxval=E1domain[m,m1,m2,m3][[2]];*) +(*E1vals=RandomReal[{m1,E1maxval},Max[NN,Nevents]];*) +(*E3vals=E3valsComp[E1vals,m,m1,m2,m3];*) +(*tabE1E3unweighted={E1vals,E3vals}//Transpose;*) +(*(*Weights for the generated values of {E1,E3} from matrix element squared*)*) +(*If[distr[tabE1E3unweighted[[1]][[1]],tabE1E3unweighted[[1]][[2]]]!=1,*) +(*(*Table with random energies distributed in the Dalitz range before accounting for weights*)*) +(*weights1=weightsNonUniformComp;*) +(*(*Weights from matrix element. Near the boundary values of E1, E3, they may become negative (Mathematica's numeric inaccuracy). Because of that, I will just replace such weights by zero*)*) +(*weights=weights1[tabE1E3unweighted,m,m1,m2,m3](*/._?Negative\[Rule]0*);*) +(*,*) +(*weights1=weightsUniformComp;*) +(*weights=weights1[tabE1E3unweighted,m,m1,m2,m3](*/._?Negative\[Rule]0*);*) +(*];*) +(*(*True random energies. Computed via empirical distribution from the weigthed data*)*) +(*RandomChoice[weights->tabE1E3unweighted,Nevents]*) +(*(*(*Weighted random points*)*) +(*weightedData=WeightedData[tabE1E3unweighted,weights];*) +(*(*True random energies. Computed via empirical distribution from the weigthed data*)*) +(*edist=EmpiricalDistribution[weightedData];*) +(*RandomVariate[edist,Nevents];*)*) +(*]*) +(*(*Temp*)*) +(*E12E23domain[m_,m1_,m2_,m3_,Emin_,Emax_]:=NIntegrate[UnitStep[E3v-Emin]*UnitStep[Emax-E3v],{E1v,E1domain[m,m1,m2,m3][[1]],E1domain[m,m1,m2,m3][[2]]},{E3v,Max[E3domain[E1v,m,m1,m2,m3][[1]],Emin],Min[Emax,E3domain[E1v,m,m1,m2,m3][[2]]]},Method->"AdaptiveMonteCarlo"]*) +(*(*The block that returns the phase space of 3-body decays 0 -> 1+2+3 given the set of energies Subscript[E, 1],Subscript[E, 3] (obtained after re-sampling with the true M^2), the angles \[Theta],\[Phi]*)*) +(*tabPS3bodyCompiled=Hold@Compile[{{tabPSenergies,_Real,1},{MASSM,_Real},{MASS1,_Real},{MASS2,_Real},{MASS3,_Real}},Module[{e1,e3,p1x,p1y,p1z,p2x,p2y,p2z,p3x,p3y,p3z,\[Theta]randTab,\[Phi]randTab,\[Kappa]randTab},*) +(*e1=Compile`GetElement[tabPSenergies,1];*) +(*e3=Compile`GetElement[tabPSenergies,2];*) +(*(*Angles relating generated energies to the 4-momenta*)*) +(*\[Theta]randTab=ArcCos[RandomReal[{-1,1}]];*) +(*\[Phi]randTab=RandomReal[{-Pi,Pi}];*) +(*\[Kappa]randTab=RandomReal[{-Pi,Pi}];*) +(*p2x=p2rotatedX[e1,e3,MASSM,MASS1,MASS2,MASS3,\[Theta]randTab,\[Phi]randTab,\[Kappa]randTab];*) +(*p2y=p2rotatedY[e1,e3,MASSM,MASS1,MASS2,MASS3,\[Theta]randTab,\[Phi]randTab,\[Kappa]randTab];*) +(*p2z=p2rotatedZ[e1,e3,MASSM,MASS1,MASS2,MASS3,\[Theta]randTab,\[Phi]randTab,\[Kappa]randTab];*) +(*p3x=p3rotatedX[e1,e3,MASSM,MASS1,MASS2,MASS3,\[Theta]randTab,\[Phi]randTab,\[Kappa]randTab];*) +(*p3y=p3rotatedY[e1,e3,MASSM,MASS1,MASS2,MASS3,\[Theta]randTab,\[Phi]randTab,\[Kappa]randTab];*) +(*p3z=p3rotatedZ[e1,e3,MASSM,MASS1,MASS2,MASS3,\[Theta]randTab,\[Phi]randTab,\[Kappa]randTab];*) +(*p1x=-p2x-p3x;*) +(*p1y=-p2y-p3y;*) +(*p1z=-p2z-p3z;*) +(*{p1x,p1y,p1z,e1,MASS1,p2x,p2y,p2z,MASSM-e1-e3,MASS2,p3x,p3y,p3z,e3,MASS3}*) +(*],CompilationTarget->"C",RuntimeOptions->"Speed",RuntimeAttributes->{Listable},Parallelization->True]/.ruleDown[{p2rotatedX,p2rotatedY,p2rotatedZ,p3rotatedX,p3rotatedY,p3rotatedZ}]//ReleaseHold;*) +(*<1+2+3*)*) +(*(*___________________________________*)*) +(*tabE1E3true=BlockRandomEnergies[LLP,Process,mLLP,Nevents];*) +(*(*_____________________________________________*)*) +(*(*Final phase space*)*) +(*(*_____________________________________________*)*) +(*tabPS3bodyTemp=tabPS3bodyCompiled[tabE1E3true,MASSM,MASS1,MASS2,MASS3];*) +(*(*If there are two LLPs, then the code below extracts their data and combines in a way such that the data for two LLPs from each decay is neighboring. Otherwise, it just extracts the data per one LLP*)*) +(*tabPS3body=If[partcontent[[3]]==LLP,Riffle[tabPS3bodyTemp[[All,Range[6,10]]],tabPS3bodyTemp[[All,Range[11,15]]]],tabPS3bodyTemp[[All,Range[11,15]]]];*) +(*tabPS3body*) +(*]*) + + +(* ::Subsubsection::Closed:: *) +(*Test - Dalitz plot for spinless decays*) + + +(* ::Input:: *) +(*(*mtest=0.3;*) +(*TestPhaseSpace=ThreeBodyDecaysEventsAtRest[mtest,0,"test","test",10^4];//AbsoluteTiming*) +(*m12test[E1_,E2_,p1x_,p1y_,p1z_,p2x_,p2y_,p2z_,m1_,m2_]=m1^2+m2^2+2*(E1*E2-p1x*p2x-p1y*p2y-p1z*p2z);*) +(*m23test[E2_,E3_,p2x_,p2y_,p2z_,p3x_,p3y_,p3z_,m2_,m3_]=m2^2+m3^2+2*(E2*E3-p2x*p3x-p2y*p3y-p2z*p3z);*) +(*Testm12m23Compiled=Hold@Compile[{{TestPhaseSpace,_Real,2},m1,m2,m3},Table[{m12test[TestPhaseSpace[[i]][[4]],TestPhaseSpace[[i]][[8]],TestPhaseSpace[[i]][[1]],TestPhaseSpace[[i]][[2]],TestPhaseSpace[[i]][[3]],TestPhaseSpace[[i]][[5]],TestPhaseSpace[[i]][[6]],TestPhaseSpace[[i]][[7]],m1,m2],m23test[TestPhaseSpace[[i]][[8]],TestPhaseSpace[[i]][[12]],TestPhaseSpace[[i]][[5]],TestPhaseSpace[[i]][[6]],TestPhaseSpace[[i]][[7]],TestPhaseSpace[[i]][[9]],TestPhaseSpace[[i]][[10]],TestPhaseSpace[[i]][[11]],m2,m3]},{i,1,Length[TestPhaseSpace],1}],CompilationTarget\[Rule]"C",RuntimeOptions\[Rule]"Speed"]/.DownValues@m12test/.DownValues@m23test//ReleaseHold*) +(*Testm12m23=Testm12m23Compiled[TestPhaseSpace,mass13bodyProcess["test","test"],mass23bodyProcess["test","test",0,0],mtest];//AbsoluteTiming*) +(*ListPlot[{Testm12m23,Table[{(mass13bodyProcess["test","test"]+mass23bodyProcess["test","test",0,0])^2,x},{x,0,massM3bodyProcess["test","test"],0.05}],Table[{x,(mass23bodyProcess["test","test",0,0]+mtest)^2},{x,0,massM3bodyProcess["test","test"],0.05}],Table[{x,(massM3bodyProcess["test","test"]-mass13bodyProcess["test","test"])^2},{x,0,massM3bodyProcess["test","test"],0.05}],Table[{(massM3bodyProcess["test","test"]-mtest)^2,x},{x,0,massM3bodyProcess["test","test"],0.05}]},Frame\[Rule]True,Joined\[Rule]{False,True,True,True,True},FrameLabel\[Rule]{"Subscript[m, 12] [GeV^2]" , "Subscript[m, 23] [GeV^2]"},FrameStyle\[Rule]Directive[Black, 23],PlotStyle\[Rule]{{Thick,Blue},{Thick,Black,Dashing[0.01]},{Thick,Black,Dashing[0.02]},{Thick,Black,Dashing[0.03]},{Thick,Black,Dashing[0.04]},{Thick,Darker@Cyan,PointSize[0.01]},{Thick,Darker@Red,Dashing[0.02]},{Thick,Darker@Darker@Green,Dashing[0.02]},{Darker@Red,PointSize[0.04]}},ImageSize\[Rule]Large,PlotRange\[Rule]{{0,massM3bodyProcess["test","test"]},All},PlotLabel\[Rule]Style[Row[{"Dalitz plot for M^2 = const, Subscript[m, mother] = ",massM3bodyProcess["test","test"]," GeV, Subscript[m, 1] = ",mass13bodyProcess["test","test"]," GeV, Subscript[m, 2] = ",mass23bodyProcess["test","test",0,0] ," GeV, Subscript[m, 3] = ",mtest, " GeV"}],15,Black],PlotLegends\[Rule]Placed[Style[#,15]&/@{"Dalitz plot","(Subscript[m, 1]+Subscript[m, 2])^2","(Subscript[m, 2]+Subscript[m, 3])^2","(m - Subscript[m, 1])^2","(m - Subscript[m, 3])^2"},Right]]*)*) + + +(* ::Section::Closed:: *) +(*Lorentz boosts*) + + +(* ::Subsection::Closed:: *) +(*Table with 4-momentum of boosted LLPs*) + + +(* ::Input:: *) +(*(*Table Subscript[p, product,x], Subscript[p, product,y], Subscript[p, product,z], Subscript[E, product]*)*) +(*indexpx=1;*) +(*indexpy=2;*) +(*indexpz=3;*) +(*indexE=4;*) +(*indexm=5;*) +(*BoostedLLPsFromDecaysTable=Hold@Compile[{{tablemother,_Real,1},{tabledaughter,_Real,1}},Module[{motherE,motherpx,motherpy,motherpz,daughterErest,daughterpxrest,daughterpyrest,daughterpzrest,daughterElab,daughterpxlab,daughterpylab,daughterpzlab,mmother},*) +(*mmother=Compile`GetElement[tablemother,indexm];*) +(*motherE=Compile`GetElement[tablemother,indexE];*) +(*motherpx=Compile`GetElement[tablemother,indexpx];*) +(*motherpy=Compile`GetElement[tablemother,indexpy];*) +(*motherpz=Compile`GetElement[tablemother,indexpz];*) +(*daughterErest=Compile`GetElement[tabledaughter,indexE];*) +(*daughterpxrest=Compile`GetElement[tabledaughter,indexpx];*) +(*daughterpyrest=Compile`GetElement[tabledaughter,indexpy];*) +(*daughterpzrest=Compile`GetElement[tabledaughter,indexpz];*) +(*daughterElab=EproductLabCart[motherpx,motherpy,motherpz,motherE,mmother,daughterpxrest,daughterpyrest,daughterpzrest,daughterErest];*) +(*daughterpxlab=pproductLab1Cart[motherpx,motherpy,motherpz,motherE,mmother,daughterpxrest,daughterpyrest,daughterpzrest,daughterErest];*) +(*daughterpylab=pproductLab2Cart[motherpx,motherpy,motherpz,motherE,mmother,daughterpxrest,daughterpyrest,daughterpzrest,daughterErest];*) +(*daughterpzlab=pproductLab3Cart[motherpx,motherpy,motherpz,motherE,mmother,daughterpxrest,daughterpyrest,daughterpzrest,daughterErest];*) +(*{daughterpxlab,daughterpylab,daughterpzlab,daughterElab}*) +(*],CompilationTarget->"C",RuntimeOptions->"Speed",RuntimeAttributes->{Listable}]/.ruleDown[{pproductLab1Cart,pproductLab2Cart,pproductLab3Cart,EproductLabCart}]/.ruleOwn[{indexpx,indexpy,indexpz,indexE,indexm}]//ReleaseHold;*) +(*(*This code converts the data in the form {Subscript[p, x],Subscript[p, y],Subscript[p, z],E,m} into {\[Theta],E}. If the facility is based on symmetric pp collisions, it also converts everything to the forward hemisphere to increase the statistics*)*) +(*BoostedLLPsAngleEnergyData=Hold@Compile[{{BoostedLLPs,_Real,1},{mLLP,_Real},{abs,_Integer}},Module[{pzvals,Evals},*) +(*pzvals=If[abs==1,Abs[Compile`GetElement[BoostedLLPs,indexpz]],Compile`GetElement[BoostedLLPs,indexpz]];*) +(*Evals=Compile`GetElement[BoostedLLPs,indexE];*) +(*{ArcCos[pzvals/Sqrt[Evals^2-mLLP^2]],Evals}],CompilationTarget->"C",RuntimeOptions->"Speed",RuntimeAttributes->{Listable}]/.ruleOwn[{indexpz,indexE}]//ReleaseHold*) +(**) + + +(* ::Subsection::Closed:: *) +(*Block computing the phase space at rest and boosting it*) + + +(* ::Subsubsection::Closed:: *) +(*If no averaging over various channels is performed*) + + +(* ::Input:: *) +(*BoostedLLPsBlock[LLP_,Facility_,mLLP_,process_,Nevents_]:=Module[{(*MotherMass,topology,mother,IfTwoLLPs,partcontent*)},*) +(*partcontent=ReactionProductsList[LLP,process];*) +(*mother=partcontent[[1]];*) +(*IfTwoLLPs=If[Length[Select[partcontent,#==LLP&]]==2,"True","False"];*) +(*nproducts=Length[partcontent]-1;*) +(*If[Length[MotherPoints[mother,Facility,IfTwoLLPs]]!=Nevents,*) +(*MotherPoints[mother,Facility,IfTwoLLPs]=PointsSampler[Facility,mother,Nevents,IfTwoLLPs]];*) +(*NevSampl=If[IfTwoLLPs=="True",1/2,1]Nevents;*) +(*(*Phase space of HNLs at the rest frame of the decaying particle*)*) +(*DataRest=If[nproducts==3,ThreeBodyDecaysEventsAtRest[LLP,process,mLLP,NevSampl],TwoBodyDecaysEventsAtRest[LLP,process,mLLP,NevSampl]];*) +(*(*Boosting and returning the data in the form Log[\[Theta]],Log[E]*)*) +(*If[Facility=="ESS"&&MemberQ[{"PiCharged","mu"},mother],*) +(*datafinal=BoostedLLPsAngleEnergyData[DataRest,mLLP,0]*) +(*,*) +(*DataBoosted=BoostedLLPsFromDecaysTable[MotherPoints[mother,Facility,IfTwoLLPs],DataRest];*) +(*datafinal=BoostedLLPsAngleEnergyData[DataBoosted,mLLP,If[MemberQ[{"LHC","FCC-hh"},Facility]==True,1,0]];*) +(*];*) +(*datafinal*) +(*]*) +(*(*pts=PointsSampler["LHC","Bplus",10^6,"False"];//AbsoluteTiming*) +(*BoostedLLPsBlock["HNL-mixing-e","B-2-body",5.2,pts];//AbsoluteTiming*) +(*Histogram[{DataBoosted[[All,4]],pts[[All,4]]},1000,ScalingFunctions->{"Log","Log"}]*)*) + + +(* ::Subsubsection::Closed:: *) +(*Averaging over several production channels (complicated HNL case)*) + + +(* ::Input:: *) +(*BoostedHNLsBlockTemp[LLP_,Facility_,mLLP_,process_,MotherData_]:=Module[{MotherMass,topology,Nev},*) +(*partcontent=ReactionProductsList[LLP,process];*) +(*nproducts=Length[partcontent]-1;*) +(*Nev=Length[MotherData];*) +(*(*Phase space of HNLs at the rest frame of the decaying particle*)*) +(*DataRest=If[nproducts==3,ThreeBodyDecaysEventsAtRest[LLP,process,mLLP,Nev],TwoBodyDecaysEventsAtRest[LLP,process,mLLP,Nev]];*) +(*(*Boosting and returning the data in the form Log[\[Theta]],Log[E]*)*) +(*DataBoosted=BoostedLLPsFromDecaysTable[MotherData,DataRest];*) +(*BoostedLLPsAngleEnergyData[DataBoosted,mLLP,If[MemberQ[{"LHC","FCC-hh"},Facility]==True,1,0]]*) +(*]*) +(*BoostedHNLsBlock[HNL_,Facility_,mN_,process_,Nevents_]:=Module[{IfTwoLLPs,proc,nev,proclist,mother},*) +(*IfTwoLLPs="False";*) +(*If[process=="B",*) +(*proclist={"B-3-body","B-2-body","Bc"};*) +(*If[Length[MotherPoints["Bplus",Facility,IfTwoLLPs]]!=Nevents,*) +(*MotherPoints["Bplus",Facility,IfTwoLLPs]=PointsSampler[Facility,"Bplus",Nevents,IfTwoLLPs]];*) +(*If[Length[MotherPoints["Bc",Facility,IfTwoLLPs]]!=Nevents,*) +(*MotherPoints["Bc",Facility,IfTwoLLPs]=DataConverted[MotherPoints["Bplus",Facility,IfTwoLLPs],mSM["Bc"]]];*) +(*];*) +(*If[process=="D",*) +(*proclist={"D-3-body","D-2-body","\[Tau]-2-body","\[Tau]-3-body"};*) +(*If[Length[MotherPoints["Ds",Facility,IfTwoLLPs]]!=Nevents,*) +(*MotherPoints["Ds",Facility,IfTwoLLPs]=PointsSampler[Facility,"Ds",Nevents,IfTwoLLPs]];*) +(*If[Length[MotherPoints["Dplus",Facility,IfTwoLLPs]]!=Nevents,*) +(*MotherPoints["Dplus",Facility,IfTwoLLPs]=DataConverted[MotherPoints["Ds",Facility,IfTwoLLPs],mSM["Dplus"]]];*) +(*If[Length[MotherPoints["tau",Facility,IfTwoLLPs]]!=Nevents,*) +(*MotherPoints["tau",Facility,IfTwoLLPs]=DataConverted[MotherPoints["Ds",Facility,IfTwoLLPs],mSM["tau"]]];*) +(*];*) +(*If[MemberQ[{"B","D"},process],*) +(*proclistspl=NeventsSplitterHNL[HNL,Facility,proclist,mN,Nevents];*) +(*boosteddata={{}};*) +(*Do[*) +(*{proc,nev}={proclistspl[[i]][[1]],proclistspl[[i]][[2]]};*) +(*mother=ReactionProductsList[HNL,proc][[1]];*) +(*boosteddata=Join[boosteddata,BoostedHNLsBlockTemp[HNL,Facility,mN,proc,Take[MotherPoints[mother,Facility,IfTwoLLPs],nev]]];*) +(*,{i,1,Length[proclistspl],1}];*) +(*boosteddata=Drop[boosteddata,1];*) +(*];*) +(*If[!MemberQ[{"B","D"},process],*) +(*boosteddata=BoostedLLPsBlock[HNL,Facility,mN,process,Nevents];*) +(*];*) +(*boosteddata*) +(*]*) + + +(* ::Chapter::Closed:: *) +(*Production via decays: converting boosted LLPs data into PDF*) + + +(* ::Section::Closed:: *) +(*Converting data Log[\[Theta]], Log[E] into PDF*) + + +(* ::Input:: *) +(*\[Theta]listBinning["SPS"]=\[Theta]listBinning["Serpukhov"]=\[Theta]listBinning["FermilabBD"]=Join[{10^-6.,10^-5.,(*3*10^-5.,6*10^-5.,*),10^-4.,5*10^-4.,10^-3.,2*10^-3.,4*10^-3.,6*10^-3.,8*10^-3.},Table[10^\[Theta]N,{\[Theta]N,Log10[10^-2],Log10[0.5],0.025}],Table[10^\[Theta]N,{\[Theta]N,Log10[0.52],Log10[Pi],0.015}],{Pi}]//N//DeleteDuplicates//Developer`ToPackedArray;*) +(*\[Theta]listBinning["LHC"]=Join[{10^-6.,10^-5.,(*3*10^-5.,6*10^-5.,*)5*10^-5.,10^-4.,3*10^-4.,6*10^-4.,10^-3.,2*10^-3.,4*10^-3.,6*10^-3.,8*10^-3.},Table[10^\[Theta]N,{\[Theta]N,Log10[10^-2.],Log10[0.5],0.025}],Table[10^\[Theta]N,{\[Theta]N,Log10[0.52],Log10[1.],0.015}],Table[10^\[Theta]N,{\[Theta]N,Log10[1.02],Log10[Pi/2],0.01}],{Pi/2}]//N//DeleteDuplicates//Developer`ToPackedArray;*) +(*\[Theta]listBinning["FCC-hh"]=Join[{10^-6.,10^-5.,(*3*10^-5.,6*10^-5.,*)7*10^-5.,10^-4.,3*10^-4.,6*10^-4.,10^-3.,2*10^-3.,4*10^-3.,6*10^-3.,8*10^-3.},Table[10^\[Theta]N,{\[Theta]N,Log10[10^-2],Log10[0.5],0.025}],Table[10^\[Theta]N,{\[Theta]N,Log10[0.52],Log10[Pi/2],0.02}],{Pi/2}]//N//DeleteDuplicates//Developer`ToPackedArray;*) +(*\[Theta]listBinning["ESS"]=Join[{10^-6.,10^-5.,(*3*10^-5.,6*10^-5.,*)10^-4.,10^-3.,10^-2.},Table[10^\[Theta]N,{\[Theta]N,Log10[3*10^-2.],Log10[0.5],0.25}],Table[10^\[Theta]N,{\[Theta]N,Log10[0.52],Log10[Pi],0.1}],{Pi}]//N//DeleteDuplicates//Developer`ToPackedArray;*) +(*(*The block that computes the smooth pdf Subscript[f, \[Theta],E] from the data BoostedData in the form Log[\[Theta]],Log[E]*)*) +(*FromDataToSmoothDistribution[BoostedData_,mass_,Facility_,IfTesting_]:=Block[{},*) +(*{\[Theta]minDistr,\[Theta]maxDistr}=MinMax[BoostedData[[All,1]]];*) +(*{EminDistr,EmaxDistr}=MinMax[BoostedData[[All,2]]];*) +(*vals\[Theta]=Join[Select[\[Theta]listBinning[Facility],#<\[Theta]maxDistr&],{\[Theta]maxDistr}];*) +(*If[Facility=="ESS",*) +(*valsE=ENlist["ESS"],*) +(*valsE=Join[{0.97EminDistr},With[{start=EminDistr,end=EmaxDistr},*) +(*NestWhileList[#+StepEtemp[#]&,start,#<=end&,1,\[Infinity],-1]],{EmaxDistr,1.03EmaxDistr}]//N//DeleteDuplicates;*) +(*];*) +(*bcc=BinCounts[BoostedData,{vals\[Theta]},{valsE}];*) +(*tabpdf=Flatten[Table[{(vals\[Theta][[i]]+vals\[Theta][[i+1]])/2,(valsE[[j]]+valsE[[j+1]])/2,Max[10^-90.,bcc[[i]][[j]]/((valsE[[j+1]]-valsE[[j]])*(vals\[Theta][[i+1]]-vals\[Theta][[i]]))]},{i,1,Length[vals\[Theta]]-1,1},{j,1,Length[valsE]-1,1}],1];*) +(*{thmin,thmax,emin,emax}={tabpdf[[All,1]]//Min,Min[Pi,tabpdf[[All,1]]//Max],tabpdf[[All,2]]//MinMax}//Flatten//N;*) +(*(*DoubleDistr[\[Theta]LLP_,ELLP_]=If[emin<=ELLP<=emax&&thmin<=\[Theta]LLP<=thmax,Evaluate[1/Length[BoostedData]Interpolation[tabpdf,InterpolationOrder->1][\[Theta]LLP,ELLP]],10^-90.];*)*) +(*DoubleDistr[\[Theta]LLP_,ELLP_]=If[emin<=ELLP<=emax&&thmin<=\[Theta]LLP<=thmax,Evaluate[1/Length[BoostedData] Interpolation[{Log[#[[1]]],Log[#[[2]]],#[[3]]}&/@tabpdf,InterpolationOrder->1][Log[\[Theta]LLP],Log[ELLP]]],10^-90.];*) +(*(*DoubleDistr[\[Theta]LLP_,ELLP_]=If[emin<=ELLP<=emax&&thmin<=\[Theta]LLP<=thmax,Evaluate[1/Length[BoostedData]10^(Interpolation[Log10[tabpdf],InterpolationOrder->1][Log10[\[Theta]LLP],Log10[ELLP]])],10^-90.];*)*) +(*collopt=MemberQ[{"LHC","FCC-hh"},Facility];*) +(*If[collopt,DoubleDistr[\[Theta]LLP_,ELLP_]=1/2 (DoubleDistr[\[Theta]LLP,ELLP]+DoubleDistr[Pi-\[Theta]LLP,ELLP])];*) +(*(*_______________________________________*)*) +(*(*For cross-checks. Uncomment if needed*)*) +(*(*_______________________________________*)*) +(*If[IfTesting=="True",*) +(*normPDF=If[collopt,2,1]*NIntegrate[DoubleDistr[Exp[x],Exp[y]]Exp[x+y],{x,Log[thmin],Log[thmax]},{y,Log[emin],Log[emax]},Method->"InterpolationPointsSubdivision"];*) +(*{tabpdf\[Theta]temp,tabpdfEtemp}={BinCounts[BoostedData[[All,1]],{vals\[Theta]}],BinCounts[BoostedData[[All,2]],{valsE}]};*) +(*tabpdf\[Theta]=Table[{(vals\[Theta][[i]]+vals\[Theta][[i+1]])/2,Max[10^-90.,tabpdf\[Theta]temp[[i]]/(vals\[Theta][[i+1]]-vals\[Theta][[i]])]},{i,1,Length[vals\[Theta]]-1,1}];*) +(*tabpdfE=Table[{(valsE[[i]]+valsE[[i+1]])/2,Max[10^-90.,tabpdfEtemp[[i]]/(valsE[[i+1]]-valsE[[i]])]},{i,1,Length[valsE]-1,1}];*) +(*AngleDistr[\[Theta]LLP_]=If[thmin<=\[Theta]LLP<=thmax,Evaluate[1/Length[BoostedData] (Interpolation[Log[tabpdf\[Theta]],InterpolationOrder->1][Log[\[Theta]LLP]]//Exp)],0.];*) +(*EnergyDistr[ELLP_]=If[emin<= ELLP<=emax,Evaluate[1/Length[BoostedData] Interpolation[tabpdfE,InterpolationOrder->1][ELLP]],0.];*) +(*If[MemberQ[{"LHC","FCC-hh"},Facility]==True,AngleDistr[\[Theta]LLP_]=1/2 (AngleDistr[\[Theta]LLP]+AngleDistr[Pi-\[Theta]LLP])];*) +(*];*) +(*(*_______________________________________*)*) +(*(*Old method. Much slower*)*) +(*(*_______________________________________*)*) +(*(*smoothkerneldistrX=SmoothKernelDistribution[BoostedData,"LeastSquaresCrossValidation",{"Bounded",{{Log\[Theta]minDistr,Log\[Theta]maxDistr},{LogEminDistr,LogEmaxDistr}},"Gaussian"},MaxMixtureKernels\[Rule]All,InterpolationPoints\[Rule]300,MaxExtraBandwidths\[Rule]0];*) +(*(*Double and marginal PDFs*)*) +(*DoubleDistr[\[Theta]LLP_,ELLP_]=If[Exp[Log\[Theta]minDistr]\[LessEqual]\[Theta]LLP\[LessEqual]Exp[Log\[Theta]maxDistr]&&mass\[LessEqual] ELLP\[LessEqual]Exp[LogEmaxDistr],Evaluate[1/\[Theta]LLP1/ELLPPDF[smoothkerneldistrX,{Log[\[Theta]LLP],Log[ELLP]}],0]];*) +(*AngleDistr[\[Theta]LLP_]=If[Exp[Log\[Theta]minDistr]\[LessEqual]\[Theta]LLP\[LessEqual]Exp[Log\[Theta]maxDistr],Evaluate[1/\[Theta]LLPPDF[MarginalDistribution[smoothkerneldistrX,1],Log[\[Theta]LLP]],0]];*) +(*EnergyDistr[ELLP_]=If[mass\[LessEqual] ELLP\[LessEqual]Exp[LogEmaxDistr],Evaluate[1/ELLPPDF[MarginalDistribution[smoothkerneldistrX,2],Log[ELLP]],0]];*)*) +(*]*) + + +(* ::Section::Closed:: *) +(*Tabulated distribution and its exporting*) + + +(* ::Input:: *) +(*TabZeroDistr[mLLP_,\[Theta]list_,Elist_]:=Flatten[Table[{mLLP,\[Theta]N,EN,10^-90.},{\[Theta]N,\[Theta]list},{EN,Elist}],1]*) +(*(*This block produces the tabulated PDF for the fixed mass mLLP. Tabulation is for the values of \[Theta],E belonging to \[Theta]list, Elist*)*) +(*(*The argument Subscript[\[Theta], extr] defines the angle below which the angular distribution is just ~sin(\[Theta]) (the true distribution has wiggles there due to low statistics*)*) +(*BlockTabulatedPDFsFromDecaysMass[LLP_,Facility_,mLLP_,process_,Nevents_,\[Theta]list_,Elist_,\[Theta]minExtr_,IfTesting_]:=Module[{tab1,(*boosteddata,*)maxmass},*) +(*maxmass=MaxMass[LLP,Facility,process];*) +(*If[mLLP=maxmass,*) +(*tab1=TabZeroDistr[mLLP,\[Theta]list,Elist];*) +(*];*) +(*tab1*) +(*]*) +(*(*filenameToExport["HNL-mixing-e","B","LHC"]*)*) + + +(* ::Subsection::Closed:: *) +(*Test*) + + +(* ::Input:: *) +(*TestingBlock[LLP_,Facility_,mLLP_,process_,Nev_,\[Theta]list_,Elist_,\[Theta]extr_]:=Block[{},*) +(*Quiet[BlockTabulatedPDFsFromDecaysMass[LLP,Facility,mLLP,process,Nev,\[Theta]list,Elist,\[Theta]extr,"True"]];*) +(*normtab={{"\!\(\*SubscriptBox[\(Normalization\), \(PDF[\[Theta], E]\)]\)", "\!\(\*SubscriptBox[\(Normalization\), \(PDF[\[Theta]]\)]\)","\!\(\*SubscriptBox[\(Normalization\), \(PDF[E]\)]\)"},{normPDF,If[collopt,2,1]*NIntegrate[AngleDistr[\[Theta]LLP],{\[Theta]LLP,thmin,Min[thmax,Pi]},Method->"InterpolationPointsSubdivision"],NIntegrate[EnergyDistr[ELLP],{ELLP,emin,emax},Method->"InterpolationPointsSubdivision"]}};*) +(*angdistr2data=ParallelTable[{10^x,If[collopt,1/2,1]*Quiet[NIntegrate[DoubleDistr[10^x,Exp[y]]Exp[y],{y,Log[emin],Log[emax]},Method->"AdaptiveMonteCarlo"]]},{x,Log10[thmin],Log10[Pi/2.],0.05}];*) +(*angdistr2[\[Theta]X_]=Interpolation[Log[angdistr2data],InterpolationOrder->1][Log[\[Theta]X]]//Exp;*) +(*pt1=LogLogPlot[Evaluate[{If[collopt,1/2,1]*AngleDistr[x],If[xTrue,FrameStyle->Directive[Black, 20],PlotRange->{{thmin,Pi/2},{10^-4,2*(angdistr2data[[All,2]]//Max)}},ImageSize->Large,FrameLabel->{"\[Theta] [rad]","PDF[\[Theta]]"},PlotLegends->Placed[Style[#,16]&/@{"data->PDF[\[Theta]]","data->PDF[\[Theta],E]->PDF[\[Theta]]"},{0.25,0.2}],PlotStyle->{{Thickness[0.003],Blue},{Thickness[0.003],Darker@Red},{Thickness[0.003],Darker@Green},{Thickness[0.003],Darker@Red,Dashing[0.02]},{Thickness[0.003],Blue,Dashing[0.02]},{Thickness[0.003],Darker@Green,Dashing[0.02]}}(*,PlotLabel\[Rule]Style[Row[{"Normalized on events with 2"AdaptiveMonteCarlo"]]},{x,Log10[emin],Log10[emax],0.015}];*) +(*endistr2[EX_]=Interpolation[Log[endistr2data],InterpolationOrder->1][Log[EX]]//Exp;*) +(*pt2=LogLogPlot[Evaluate[{EnergyDistr[x],endistr2[x]}],{x,emin,emax},Frame->True,FrameStyle->Directive[Black, 20],PlotRange->{{emin,emax},{10^-10,2*(endistr2data[[All,2]]//Max)}},ImageSize->Large,FrameLabel->{"E [GeV]","PDF[E]"},PlotLegends->Placed[Style[#,16]&/@{"data->PDF[E]","data->PDF[\[Theta],E]->PDF[E]"},{0.25,0.2}],PlotStyle->{{Thickness[0.003],Blue},{Thickness[0.003],Darker@Red},{Thickness[0.003],Darker@Green},{Thickness[0.003],Darker@Red,Dashing[0.02]},{Thickness[0.003],Blue,Dashing[0.02]},{Thickness[0.003],Darker@Green,Dashing[0.02]}}(*,PlotLabel\[Rule]Style[Row[{"Normalized on events with 2{1, 1}];*) +(*histoenergy=With[{min=Min[boosteddata[[All,2]]],max=Max[PTS[[All,2]]]},Histogram[Evaluate[{(*erand//Exp,*)PTS[[All,2]],boosteddata[[All,2]]}],{min,max,(max-min)/100},"ProbabilityDensity",ScalingFunctions->{"Log","Log"},PlotRange->{{min,max},All},Frame-> True,ChartStyle->{Opacity[.25,Red],Opacity[.25,Blue],Opacity[.25,Darker@Darker@Green]},FrameStyle->Directive[Black, 22],ImageSize->Large,FrameLabel->{"E, GeV","Fraction"},PlotLabel->Style[Row[{LLPtest,", ",fac,", production: ",prodtest,", \!\(\*SubscriptBox[\(m\), \(LLP\)]\) = ", masstest," GeV"}],18,Black],ChartLegends->Placed[{(*"Subscript[mother, unweighted]",*)"mother",LLPtest},Bottom]]];*) +(*histoangle=With[{min=Min[PTS[[All,1]]],max=Max[boosteddata[[All,1]]]},Histogram[Evaluate[{(*\[Theta]rand//Exp,*)PTS[[All,1]],boosteddata[[All,1]]}],{min,max,(max-min)/100},"ProbabilityDensity",ScalingFunctions->{"Log","Log"},PlotRange->{{min,max},All},Frame-> True,ChartStyle->{Opacity[.25,Red],Opacity[.25,Blue],Opacity[.25,Darker@Darker@Green]},FrameStyle->Directive[Black, 22],ImageSize->Large,FrameLabel->{"\[Theta], rad","Fraction"},PlotLabel->Style[Row[{LLPtest,", ",fac,", production: ",prodtest,", \!\(\*SubscriptBox[\(m\), \(LLP\)]\) = ", masstest," GeV"}],18,Black],ChartLegends->Placed[{(*"Subscript[mother, unweighted]",*)"mother",LLPtest},Bottom]]];*) +(*histoplots=Style[Row[{histoangle,histoenergy}],ImageSizeMultipliers->{1, 1}];*) +(*testdata={histoplots,normtab,pdfplots}*) +(*]*) +(*IfTest=0;*) +(*If[IfTest==1,*) +(*fac="LHC";*) +(*num=10^7;*) +(*masstest=3.;*) +(*LLPtest="Scalar";*) +(*prodtest="B-mixing";*) +(*thextr=0.5*10^-3;*) +(*TestingBlock[LLPtest,fac,masstest,prodtest,num,\[Theta]Nlist[fac],ENlist[fac],thextr]*) +(*]*) + + +(* ::Chapter::Closed:: *) +(*Production via mixing (following 2201.05170): PDF*) + + +(* ::Section::Closed:: *) +(*Subscript[\[Theta], mother],Subscript[E, mother]->Subscript[\[Theta], LLP],Subscript[E, LLP], following 2201.05170*) + + +(* ::Input:: *) +(*LLPkinematicsMixing=Hold@Compile[{{mdata,_Real,1},{mLLP,_Real},{Eplab,_Real},{IfCollider,True|False},{IfESS,True|False}},Module[{\[Theta]llpFin=0.,ellpFin=0.,pboost=0.,emes=0.,pxmes=0.,pymes=0.,pzmes=0.,mmes=0.,pzmesCM=0.,pzllpCM=0.,ellpCM=0.,pxllpLab=0.,pyllpLab=0.,pzllpLab=0.},*) +(*pboost=Sqrt[Eplab^2-0.938^2];*) +(*emes=Compile`GetElement[mdata,4];*) +(*pxmes=Compile`GetElement[mdata,1];*) +(*pymes=Compile`GetElement[mdata,2];*) +(*pzmes=Compile`GetElement[mdata,3];*) +(*mmes=Compile`GetElement[mdata,5];*) +(*(*If the facility is beam dump, then boost the meson's kinematics to CM frame, relate it to the LLP's kinematics, and boost back. Otherwise (if it is collider), simply renormalize the LLP energy*)*) +(*If[!IfCollider,*) +(*(*Meson's and LLP's kinematics at CM frame, assuming that their CM momenta are the same. It is also assumed that the boost is in the z direction*)*) +(*pzmesCM=pzllpCM=pproductLab3Cart[0.,0.,-pboost,Eplab,0.938,pxmes,pymes,pzmes,emes];*) +(*ellpCM=Sqrt[pxmes^2+pymes^2+pzllpCM^2+mLLP^2];*) +(*(*LLP's kinematics at lab frame*)*) +(*pxllpLab=pxmes;*) +(*pyllpLab=pymes;*) +(*pzllpLab=pproductLab3Cart[0.,0.,pboost,Eplab,0.938,pxmes,pymes,pzllpCM,ellpCM];*) +(*ellpFin=Sqrt[pxllpLab^2+pyllpLab^2+pzllpLab^2+mLLP^2];*) +(*(*Warning! If relating the angle of the LLP to the meson angle by boosting to CM frame, inadequate results may be produced. I am working on improved approach of the production via mixing*)*) +(*\[Theta]llpFin=If[!IfESS,ArcCos[pzllpLab/Sqrt[pxllpLab^2+pyllpLab^2+pzllpLab^2]],ArcCos[pzmes/Sqrt[pxmes^2+pymes^2+pzmes^2]]];*) +(*,*) +(*ellpFin=Sqrt[pxmes^2+pymes^2+pzmes^2+mLLP^2];*) +(*\[Theta]llpFin=ArcCos[Abs[pzmes]/Sqrt[pxmes^2+pymes^2+pzmes^2]];*) +(*];*) +(*{\[Theta]llpFin,ellpFin}*) +(*]*) +(*,CompilationTarget->"C",RuntimeOptions->"Speed",RuntimeAttributes->{Listable},Parallelization->True]/.ruleDown[{pproductLab3Cart}]//ReleaseHold;*) +(*<0&&Eplab>0,Simplify[\[Gamma]CMbeamDump[Eplab,mp](plab-vCMbeamDump[Eplab,mp]*Sqrt[plab^2+m^2])]];*) +(*(*inverse relation*)*) +(*PlabPcm[pcm_,m_,Eplab_,mp_]=plab/.Solve[PcmPlab[plab,m,Eplab,mp]\[Equal]pcm,plab][[2]]//Simplify;*) +(*(*Relation between the meson and DP energies and angles in the CM frame. Obtained under assumption that at the CM frame of proton-proton collisions the meson and DP |momenta| are the same*)*) +(*EcmMesonEcmLLP[EV_,mV_,mmeson_]=Sqrt[EV^2-mV^2+mmeson^2];*) +(*(*Relation between meson and DP kinematics in lab frame. Obtained under assumption that at the CM frame of proton-proton collisions the meson and DP |momenta| are the same*)*) +(*plabMesonElabLLP[EV_,mmeson_,mV_,Eplab_,mp_]=Assuming[EV>0,Simplify[PlabPcm[PcmPlab[Sqrt[EV^2-mV^2],mV,Eplab,mp],mmeson,Eplab,mp]]];*) +(*ElabMesonElabDP[EV_,mmeson_,mV_,Eplab_,mp_]=Sqrt[plabMesonElabLLP[EV,mmeson,mV,Eplab,mp]^2+mmeson^2];*) +(*\[Theta]labMeson\[Theta]ElabDP[EV_,\[Theta]V_,mmeson_,mV_,Eplab_,mp_]=ArcSin[Sin[\[Theta]V]Sqrt[EV^2-mV^2]/plabMesonElabLLP[EV,mmeson,mV,Eplab,mp]];*) +(*(*If Subscript[E, a] < Subscript[E, a,min], then there is no solution Subscript[E, meson](Subscript[E, a])*)*) +(*EVminBeamDump[mmeson_,mV_,Eplab_,mp_]=EV/.Solve[plabMesonElabLLP[EV,mmeson,mV,Eplab,mp]\[Equal]0,EV][[4]];*) +(*EVminCM[mmeson_,mV_]=If[mV>mmeson,Evaluate[EV/.Solve[EcmMesonEcmLLP[EV,mV,mmeson]\[Equal]0,EV][[2]]],mV];*) +(*(*Jacobian Subscript[E, meson],Subscript[\[Theta], meson] \[Rule] Subscript[E, a],Subscript[\[Theta], a]*)*) +(*Jacobian\[Theta]mesonEmesonTo\[Theta]VEVBeamDump[Eplab_,mp_,mmeson_,mV_,\[Theta]V_,EV_]=Abs[D[\[Theta]labMeson\[Theta]ElabDP[EV,\[Theta]V,mmeson,mV,Eplab,mp],\[Theta]V]*D[ElabMesonElabDP[EV,mmeson,mV,Eplab,mp],EV]-D[\[Theta]labMeson\[Theta]ElabDP[EV,\[Theta]V,mmeson,mV,Eplab,mp],EV]*D[ElabMesonElabDP[EV,mmeson,mV,Eplab,mp],\[Theta]V]]//Simplify;*) +(*JacobianEmesonToEVCollider[EV_,mV_,mmeson_]=D[EcmMesonEcmLLP[EV,mV,mmeson],EV];*)*) + + +(* ::Section::Closed:: *) +(*Distribution of LLPs obtained using the transformation Subscript[E, meson],Subscript[\[Theta], meson] ->Subscript[E, LLP], Subscript[\[Theta], LLP]*) + + +(* ::Input:: *) +(*BlockTabulatedPDFsFromMixingsMass[LLP_,Facility_,mLLP_,process_,Nevents_,\[Theta]list_,Elist_,\[Theta]minExtr_]:=Module[{},*) +(*maxmass=MaxMass[LLP,Facility,process];*) +(*If[mLLP=maxmass,*) +(*tab1=TabZeroDistr[mLLP,\[Theta]list,Elist];*) +(*];*) +(*tab1*) +(*]*) +(*(*DoubleDistrLLPfromMixing[mLLP_,meson_,Facility_]:=Module[{mmeson,elab},*) +(*(*This block produces the interpolation of the mother distribution function *)*) +(*mmeson=mSM[meson];*) +(*elab=EmaxFacility[Facility];*) +(*distr[th_,e_]=DoubleDistrMotherInt[th,e,Facility,meson];*) +(*If[!MemberQ[{"FCC-hh","LHC"},Facility],*) +(*If[Facility!="ESS",*) +(*distrmixing[\[Theta]LLP_,ELLP_]=If[ELLP>Max[mLLP,EVminBeamDump[mmeson,mLLP,elab,mSM["p"]]]&&0mLLP,Evaluate[distr[\[Theta]LLP,ELLP]],0.];*) +(*distrmixingNorm=NIntegrate[distrmixingTemp[Exp[\[Theta]LLP],Exp[ELLP]]Exp[\[Theta]LLP+ELLP],{\[Theta]LLP,Log[10^-5.],Log[Pi-10^-5.]},{ELLP,Log[mLLP],Log[elab]},Method->"InterpolationPointsSubdivision"];*) +(*distrmixing[\[Theta]LLP_,ELLP_]=distrmixingTemp[\[Theta]LLP,ELLP]/distrmixingNorm;*)*) +(*distrmixing[\[Theta]LLP_,ELLP_]=If[ELLP>Max[mLLP,EVminBeamDump[mmeson,mLLP,elab,mSM["p"]]]&&0Max[mLLP,EVminCM[mmeson,mLLP]],Evaluate[JacobianEmesonToEVCollider[ELLP,mLLP,mmeson]*distr[\[Theta]LLP,EcmMesonEcmLLP[ELLP,mLLP,mmeson]]],0.];*) +(*];*) +(*distrmixing[\[Theta]LLP,ELLP]*) +(*]*) +(*BlockTabulatedPDFsFromMixing[LLP_,Facility_,mLLP_,mode_,\[Theta]list_,Elist_]:=Module[{(*meson,distr,tab1,maxmass*)},*) +(*meson=ReactionProductsList[LLP,mode][[1]];*) +(*If[!IfMotherInterpolated[Facility,meson],MotherInterpolation[Facility,meson]];*) +(*distrMixing[\[Theta]LLP_,ELLP_]=DoubleDistrLLPfromMixing[mLLP,meson,Facility];*) +(*maxmass=MaxMass[LLP,Facility,mode];*) +(*If[mLLP=maxmass,*) +(*tab1=TabZeroDistr[mLLP,\[Theta]list,Elist];*) +(*];*) +(*tab1*) +(*]*)*) + + +(* ::Chapter::Closed:: *) +(*Production via bremsstrahlung: PDF and normalization*) + + +(* ::Input:: *) +(*mVminFromBrem=0.02;*) +(*mVmaxFromBrem["SPS"]=mVmaxFromBrem["LHC"]=mVmaxFromBrem["FCC-hh"]=5.;*) +(*mVmaxFromBrem["Serpukhov"]=mVmaxFromBrem["FermilabBD"]=3.;*) +(*BlockTabulatedPDFsFromBrem[LLP_,Facility_,Description_]:=Module[{ProdBremExportName,DistrBremName,scales,mmax,mrangeProdProb,mrangeDistr,distrbrem,pbeam,eminbrem,normdata,tabdistrbrem,\[Theta]maxAbs,\[Theta]gridBrem,ELLPgridBrem(*pbeam,eminbrem,\[Theta]Vlistbrem,EvlistBremTemp,EvlistBrem,\[Theta]list1*),mlistbrem},*) +(*pbeam=EmaxFacility[Facility];*) +(*eminbrem=ELLPminBrem[Facility];*) +(*intmethod="AdaptiveMonteCarlo";*) +(*ProdBremExportName=FileNameJoin[{NotebookDirectory[],"phenomenology/"<>LLP<>"/Production probabilities/Pbrem_"<>LLP<>"_"<>Description<>"_"<>Facility<>".m"}];*) +(*DistrBremName=If[LLP=="Scalar","Bremsstrahlung-"<>Description<>"-mixing","Bremsstrahlung-"<>Description];*) +(*If[Description=="Baseline",*) +(*(*Defining non-normalized distribution*)*) +(*distrbrem[mV_,\[Theta]V_,EV_]=FluxBrem[mV,\[Theta]V,EV,LLP,Description,Facility]/FormFactorSquaredBrem[mV,LLP];*) +(*(*Computing the normalization*)*) +(*mlistbrem=Join[{10^-3.},Table[mV,{mV,mVminFromBrem,mVmaxFromBrem[Facility],(mVmaxFromBrem[Facility]-mVminFromBrem)/25}]];*) +(*normdata=ParallelTable[{mV,NIntegrate[distrbrem[mV,\[Theta]V,EV],{\[Theta]V,10^-6.,\[Theta]maxBremBaseline[Facility]},{EV,eminbrem,Max[eminbrem,ELLPmaxBremBaseline[Facility,mV,\[Theta]V]]},Method->intmethod]},{mV,mlistbrem}];*) +(*normBrem[mV_]=Interpolation[normdata//Log,InterpolationOrder->1][Log[mV]]//Exp;*) +(*(*The distribution normalized by 1*)*) +(*DoubleDistrBrem[mV_,\[Theta]V_,EV_]=If[EVintmethod]],5]]},{mV,mrangeProdProb[ff]}];*)*) +(*normdata[ff]=ParallelTable[{mV,Quiet[NIntegrate[distrbrem[mV,\[Theta]V,EV,ff],{\[Theta]V,10^-6.,\[Theta]maxAbs[ff]},{EV,eminbrem,ELLPmaxBremAP[Facility,mV,\[Theta]V,\[CapitalLambda]pVal[ff]]},Method->"QuasiMonteCarlo"]]},{mV,mrangeProdProb[ff]}];*) +(*normBrem[mV_,ff]=Interpolation[normdata[ff]//Log,InterpolationOrder->1][Log[mV]]//Exp;*) +(*DoubleDistrBrem[mV_,\[Theta]V_,EV_,ff]=distrbrem[mV,\[Theta]V,EV,ff]/normBrem[mV,ff];*) +(*tabdistrbrem[ff]=Flatten[Table[{mV,\[Theta]V,EV,If[\[Theta]V<=1.3\[Theta]maxAbs[ff],DoubleDistrBrem[mV,\[Theta]V,EV,ff],0.]},{mV,mrangeDistr[ff]},{\[Theta]V,\[Theta]gridBrem[ff]},{EV,ELLPgridBrem[ff]}],{1,2,3}];*) +(*,{ff,scales}];*) +(*Export[ProdBremExportName,{#,If[LLP=="DP",1,FormFactorSquaredBrem[mLLP,LLP]]*normBrem[mLLP,#],eminbrem,\[Theta]maxAbs[#],ELLPmaxBremAP[Facility,mLLP,\[Theta]LLP,\[CapitalLambda]pVal[#]]}&/@scales,"MX"];*) +(*Export[filenameToExport[LLP,DistrBremName,Facility],{#,tabdistrbrem[#]}&/@scales,"MX"]*) +(*];*) +(*]*) + + +(* ::Chapter::Closed:: *) +(*Production via Primakov process: PDF and normalization*) + + +(* ::Input:: *) +(*BlockTabulatedPDFsFromPrimakov[Facility_,Nucleus_,\[Theta]list_,Elist_]:=Module[{\[Theta]min,\[Theta]max,mlist,filename1,filename2,proc,fipn},*) +(*proc="Primakov";*) +(*fipn="ALP-photon";*) +(*mlist=MassList[fipn,proc,Facility];*) +(*ProbPrimakovTab=Flatten[ParallelTable[{ma,E\[Gamma],Max[10^-90.,1/\[Sigma]\[Gamma]Abs[Nucleus] (Quiet[\[Sigma]PrimakovNucleus[ma,E\[Gamma],mnucleus[Nucleus],anucleus[Nucleus],znucleus[Nucleus]]]+Quiet[\[Sigma]PrimakovNucleons[ma,E\[Gamma],znucleus[Nucleus]]])]},{ma,mlist},{E\[Gamma],ENlist[Facility]}],{1,2}];*) +(*(*Approximation: Subscript[E, a] = Subscript[E, \[Gamma]], Subscript[\[Theta], a] = Subscript[\[Theta], \[Gamma]]*)*) +(*ProbPrimakov[ma_,Ea_]=Exp[Interpolation[Log[ProbPrimakovTab],InterpolationOrder->1][Log[ma],Log[Ea]]];*) +(*MotherInterpolation[Facility,"photon"];*) +(*ALPdoubleFlux[ma_,\[Theta]a_,Ea_]=DoubleDistrMotherInt[\[Theta]a,Ea,Facility,"photon"]*ProbPrimakov[ma,Ea];*) +(*{\[Theta]min,\[Theta]max}=\[Theta]MinMax[Facility,"photon"][[#]]&/@{1,2};*) +(*NormalizationALP[ma_]=Interpolation[ParallelTable[{ma,Quiet[NIntegrate[ALPdoubleFlux[ma,Exp[t],Exp[e]]Exp[t+e],{t,Log[\[Theta]min],Log[\[Theta]max]},{e,Log[ma],Log[Emax[\[Theta]min,Facility,"photon"]]},Method->"InterpolationPointsSubdivision"]]},{ma,mlist}],InterpolationOrder->1][ma];*) +(*DoubleDistrALP[ma_,\[Theta]a_,Ea_]=ALPdoubleFlux[ma,\[Theta]a,Ea]/NormalizationALP[ma];*) +(*filename1=FileNameJoin[{NotebookDirectory[],"spectra/New physics particles spectra",LLPfolder["ALP-photon"],ToString@StringForm["DoubleDistr_``_``-``_``.m",Sequence@@{fipn,proc,Nucleus,Facility}]}];*) +(*filename2=FileNameJoin[{NotebookDirectory[],"phenomenology/",LLPfolder[fipn],"Production probabilities",ToString@StringForm["Pprod_``_``-``_``.m",Sequence@@{fipn,proc,Nucleus,Facility}]}];*) +(*Export[filename1,Flatten[Table[{ma,\[Theta]a,Ea,DoubleDistrALP[ma,\[Theta]a,Ea]},{ma,mlist},{\[Theta]a,\[Theta]list},{Ea,Elist}],{1,2,3}]//Developer`ToPackedArray,"MX"];*) +(*Export[filename2,NormalizationALP[ma],"MX"];*) +(*]*) + + +(* ::Chapter::Closed:: *) +(*Production via photon fusion: PDF and normalization*) + + +(* ::Input:: *) +(*TabulatedDistrFusion[m_,Facility_,Nucleus_,\[Theta]list_,Elist_]:=Module[{(*norm,tabulateddistr,distr*)logemin,logemax,logthmin,logthmax},*) +(*distrprob[th_,e_]:=If[!MemberQ[{"LHC","FCC-hh"},Facility],d2Pd\[Theta]adEaFusion1[m,th,e,Facility,Nucleus],d2Pd\[Theta]adEaFusion[m,th,e,Facility,Nucleus]];*) +(*tabulateddistr=Flatten[ParallelTable[{m,th,e,Max[Quiet[distrprob[th,e]],10^-90.]},{th,\[Theta]list},{e,Elist}],1];*) +(*distr[logth_,loge_]=Interpolation[Log[tabulateddistr[[All,{2,3,4}]]],InterpolationOrder->1][logth,loge]//Exp;*) +(*{logthmin,logthmax,logemin,logemax}=Log[Flatten[{MinMax[tabulateddistr[[All,2]]],MinMax[tabulateddistr[[All,3]]]}]];*) +(*norm=Quiet[NIntegrate[distr[logth,loge]Exp[logth+loge],{logth,logthmin,logthmax},{loge,Max[Log[m],logemin],logemax},Method->"InterpolationPointsSubdivision"]];*) +(*{{#[[1]],#[[2]],#[[3]],#[[4]]/norm}&/@tabulateddistr,{m,norm}}*) +(*];*) +(*BlockTabulatedPDFsFromFusion[Facility_,Nucleus_,\[Theta]list_,Elist_]:=Module[{\[Theta]min,\[Theta]max,mlist,filename1,filename2,fipn,procn},*) +(*fipn="ALP-photon";*) +(*procn="Photon-fusion";*) +(*mlist=MassList[fipn,procn,Facility];*) +(*tabphoton=Monitor[Table[TabulatedDistrFusion[mlist[[t]],Facility,Nucleus,\[Theta]list,Elist],{t,1,Length[mlist],1}],Row[{ProgressIndicator[t,{1,Length[mlist]}]," \!\(\*SubscriptBox[\(m\), \(LLP\)]\) = ",mlist[[t]]," GeV"," (",t,"/",Length[mlist],")"}," "]];*) +(*(*Approximation: Subscript[E, a] = Subscript[E, \[Gamma]], Subscript[\[Theta], a] = Subscript[\[Theta], \[Gamma]]*)*) +(*ProbFusion[ma_]=Interpolation[Log[tabphoton[[All,2]]],InterpolationOrder->1][Log[ma]]//Exp;*) +(*DoubleDistrDataTemp=Join[##]&@@tabphoton[[All,1]];*) +(*filename1=FileNameJoin[{NotebookDirectory[],"spectra/New physics particles spectra",LLPfolder[fipn],ToString@StringForm["DoubleDistr_``_``-``_``.m",Sequence@@{fipn,procn,Nucleus,Facility}]}];*) +(*filename2=FileNameJoin[{NotebookDirectory[],"phenomenology/",LLPfolder[fipn],"Production probabilities",ToString@StringForm["Pprod_``_``-``_``.m",Sequence@@{fipn,procn,Nucleus,Facility}]}];*) +(*Export[filename1,DoubleDistrDataTemp//Developer`ToPackedArray,"MX"];*) +(*Export[filename2,ProbFusion[ma],"MX"];*) +(*]*) + + +(* ::Title::Closed:: *) +(*Choose LLP and run*) + + +(* ::Chapter::Closed:: *) +(*Some definitions*) + + +(* ::Input:: *) +(*infoDialog[phrase_]:=DialogInput[{choice=""},Column[{TextCell[phrase],Button["Proceed",DialogReturn[choice]]}]]*) +(*(*The code which evaluates the sections whose tags are included in the list listproduction*)*) +(*headstypes={"Title","Chapter","Section","Subsection","Subsubsection"};*) +(*cells=Association[Table[type->Select[Cells[],CurrentValue[#,"CellStyle"]=={type}&],{type,headstypes}]];*) +(*inp=(#->First@NotebookRead[#])&/@cells["Section"];*) +(*SectionEvaluator[section_]:=Block[{},*) +(*SectionCell=Select[inp,#[[2]]==section&][[1]][[1]];*) +(*If[!(SectionCell=!=$Canceled),infoDialog[Column[{"There is no section/section name associated with the given LLP and production channel: ",section,"Add them"}]],*) +(*If[SectionCell=!=$Canceled,*) +(*SelectionMove[SectionCell,All,CellGroup];*) +(*SelectionEvaluate[InputNotebook[]]];*) +(*]*) +(*]*) +(*BlockProductionComputation[LLP_,prodlist_]:=Module[{seclist},*) +(*seclist=LLP<>"_"<>#&/@prodlist;*) +(*Do[SectionEvaluator[sec],{sec,seclist}]]*) +(*(*Pattern for filename of the tabulated distribution*)*) +(*filenameToExport[LLP_,mode_,facility_]:=FileNameJoin[{NotebookDirectory[],"spectra/New physics particles spectra",LLPfolder[LLP],ToString@StringForm["DoubleDistr_``_``_``.m",Sequence@@{LLP,mode,facility}]}]*) +(*(*This block produces the table m,\[Theta],E,distr for m belonging to mlist. function is BlockTabulatedPDFsFromDecays/Mixing where all the arguments except for mLLP are fixed*)*) +(*tabulatedblock[function_,mlist_,filename_]:=Module[{},*) +(*tabb=Monitor[Table[function[mlist[[t]]],{t,1,Length[mlist],1}],Row[{ProgressIndicator[t,{1,Length[mlist]}],"i = ",t,"/",Length[mlist],", m = ",mlist[[t]]," GeV"}," "]];*) +(*tabb=Flatten[tabb,1]//Developer`ToPackedArray;*) +(*Export[filename,tabb,"MX"];*) +(*]*) +(*(*List of the directories associated with the given LLP*)*) +(*Do[*) +(*If[!StringContainsQ[LLP,"HNL"],LLPfolder[LLP]=LLP,LLPfolder[LLP]="HNL"];*) +(*,{LLP,LLPlist}];*) +(*directories=Join[FileNameJoin[{NotebookDirectory[],#}]&/@{"spectra","spectra/New physics particles spectra"},FileNameJoin[{NotebookDirectory[],"spectra/New physics particles spectra",LLPfolder[#]}]&/@Keys[DownValues@LLPfolder][[All,1,1]]]//DeleteDuplicates;*) +(*Do[If[!DirectoryQ[dir],CreateDirectory[dir]],{dir,directories}]*) + + +(* ::Chapter::Closed:: *) +(*Selecting LLP, facility, and production channels*) + + +(* ::Input:: *) +(*NotebookDirectory[]//ParentDirectory;*) +(*(*Facilities*)*) +(*Print["List of implemented LLPs:"]*) +(*LLPlist*) +(*Print["Selected facility:"]*) +(*dropdownDialog[list_,phrase_]:=DialogInput[{choice=""},Column[{TextCell[phrase],PopupMenu[Dynamic[choice],list],Button["OK",DialogReturn[choice]]}]]*) +(*SelectedFacility=dropdownDialog[FacilitiesList,"Select the facility:"]*) +(*Print["Selected LLP:"]*) +(*LLPlistFacility=Select[LLPlistEffective,Length[ProcessesListFacility[#,SelectedFacility]]!=0&];*) +(*SelectedLLP=dropdownDialog[LLPlistFacility,"Select the LLP:"]*) +(*Print["Implemented production channels:"]*) +(*listproductionall=ProcessesListFacility[SelectedLLP,SelectedFacility];*) +(*listproductionall//TableForm*) +(*selectionDialog[list_]:=DialogInput[{choice={}},Column[{Row[{"Select the production channels by clicking on them:"}],TogglerBar[Dynamic[choice],list,Appearance->"Vertical"],Button["OK",DialogReturn[choice]]}]]*) +(*listproductionForComputation=selectionDialog[Join[{"All channels"},listproductionall]];*) +(*If[listproductionForComputation=={"All channels"},listproductionForComputation=listproductionall];*) +(*Print["Production channels selected for the computation:"]*) +(*listproductionForComputation//TableForm*) +(*(*BlockProductionComputation[listproduction_]:=Module[{facility},*) +(*nb=EvaluationNotebook[];*) +(*Do[NotebookFind[nb,listproduction[[index]],All,CellTags];*) +(*SelectionEvaluate[nb],{index,1,Length[listproduction],1}]*) +(*]*)*) + + +(* ::Chapter::Closed:: *) +(*Launching the computation of the distributions of LLPs*) + + +(* ::Input:: *) +(**) +(**) +(*CondSelLLP[prod_]:=If[SelectedLLP!="HNL",StringContainsQ[ProductionType[SelectedLLP,prod],{"Decay","Mixing-Old"}],StringContainsQ[ProductionType[ListHNLs[[1]],prod],{"Decay","Mixing-Old"}]]*) +(*If[Select[Table[CondSelLLP[prod],{prod,listproductionForComputation}],#==True&]!={},*) +(*Print["Number of simulated decays:"];*) +(*nsim=DialogInput[{br=10^6},Column[{"Enter the number of simulated decays (for decays only) in the form y*10^x. Reasonable values are ~\!\(\*SuperscriptBox[\(10\), \(6\)]\)-\!\(\*SuperscriptBox[\(10\), \(7\)]\)",InputField[Dynamic[br],Expression],Button["Proceed",DialogReturn[br],ImageSize->Automatic]}]]//IntegerPart;*) +(*nsim=Ceiling[nsim-0.5]+Mod[Ceiling[nsim-0.5],2]*) +(*]*) +(*(*Empirical estimate of the angles below which the distribution d^2f/d\[Theta]dE ~ sin(\[Theta])df/dE*)*) +(*modes=Table[ProcessesListFacility[LLP,Facility],{LLP,LLPlistEffective},{Facility,FacilitiesList}]//Flatten//DeleteDuplicates;*) +(*Do[*) +(*\[Theta]minExtrFacility["ESS",mode]=0.1;*) +(*\[Theta]minExtrFacility["Serpukhov",mode]=10^-1.3;*) +(*\[Theta]minExtrFacility["SPS",mode]=If[StringContainsQ[mode,"Pi0"]||StringContainsQ[mode,"Primakov"]||StringContainsQ[mode,"Eta"]||StringContainsQ[mode,"Rho0"]||StringContainsQ[mode,"Omega"],0.5*10^-3.,10^-3.];*) +(*\[Theta]minExtrFacility["FermilabBD",mode]=\[Theta]minExtrFacility["Serpukhov",mode]=10^-3.;*) +(*\[Theta]minExtrFacility["LHC",mode]=If[StringContainsQ[mode,"Pi0"]||StringContainsQ[mode,"Primakov"]||StringContainsQ[mode,"Eta"]||StringContainsQ[mode,"Rho0"]||StringContainsQ[mode,"Omega"]||StringContainsQ[mode,"EtaPr"],10^-4,0.5*10^-3.];*) +(*\[Theta]minExtrFacility["FCC-hh",mode]=If[StringContainsQ[mode,"Pi0"]||StringContainsQ[mode,"Primakov"]||StringContainsQ[mode,"Eta"]||StringContainsQ[mode,"Rho0"]||StringContainsQ[mode,"Omega"]||StringContainsQ[mode,"EtaPr"],0.7*10^-4,2*10^-4.];*) +(*,{mode,modes}]*) +(*(*Launch if you are interested in all production channels implemented in this notebook for the given LLP *)*) +(*BlockProductionComputation[SelectedLLP,listproductionForComputation]*) +(**) + + +(* ::Input:: *) +(**) + + +(* ::Title::Closed:: *) +(*Actual computation of the distributions*) + + +(* ::Chapter::Closed:: *) +(*HNL*) + + +(* ::Section::Closed:: *) +(*HNL_W*) + + +(* ::Input:: *) +(*If[MemberQ[{"LHC","FCC-hh"},SelectedFacility]==True,*) +(*proc="W";*) +(*(*List of masses for which the distribution will be tabulated*)*) +(*Do[*) +(*MassList["HNL",proc,Facility]={0.02,0.05,1,2,5,7,10,15,20,25,30,35,40,50,60,65,70,75,mSM["W"]-mSM["e"]-0.1}//N;*) +(*,{Facility,{"LHC","FCC-hh"}}];*) +(*Do[*) +(*TabulatedPDF[mLLP_]:=BlockTabulatedPDFsFromDecaysMass[LLP,SelectedFacility,mLLP,proc,nsim,\[Theta]Nlist[SelectedFacility],ENlist[SelectedFacility],\[Theta]minExtrFacility[SelectedFacility,proc],"False"];*) +(*filename=filenameToExport[LLP,proc,SelectedFacility];*) +(*mlist=MassList["HNL",proc,SelectedFacility];*) +(*tabulatedblock[TabulatedPDF,mlist,filename]*) +(*,{LLP,ListHNLs}*) +(*]*) +(*]//AbsoluteTiming*) +(*{proc,mlist}//Clear*) + + +(* ::Section::Closed:: *) +(*HNL_B*) + + +(* ::Input:: *) +(*Module[{LLPn,LLP,mlist,proc},*) +(*LLPn="HNL";*) +(*proc="B";*) +(*(*List of masses for which the distribution will be tabulated*)*) +(*Do[*) +(*MassList[LLPn,proc,Facility]=If[MemberQ[{"LHC","FCC-hh"},Facility]==True,{0.02,0.05,0.1,0.15,0.2,0.5,1,1.5,2.,2.5,2.8,3.,3.45,4.,4.5,5.16,5.27,5.8,6.25},{0.05,0.2,0.5,1,1.5,2.,2.5,2.8,3.,3.45,4.,4.5,5.16,5.27}]//N;*) +(*,{Facility,FacilitiesList}];*) +(*Monitor[*) +(*Do[*) +(*LLP=ListHNLs[[k]];*) +(*TabulatedPDF[mLLP_]:=BlockTabulatedPDFsFromDecaysMass[LLP,SelectedFacility,mLLP,proc,nsim,\[Theta]Nlist[SelectedFacility],ENlist[SelectedFacility],\[Theta]minExtrFacility[SelectedFacility,proc],"False"];*) +(*filename=filenameToExport[LLP,proc,SelectedFacility];*) +(*mlist=MassList[LLPn,proc,SelectedFacility];*) +(*tabulatedblock[TabulatedPDF,mlist,filename]*) +(*,{k,1,Length[ListHNLs],1}],*) +(*Row[{ProgressIndicator[k,{1,Length[ListHNLs]}]," ","HNL = ",ListHNLs[[k]]," (",k,"/",Length[ListHNLs],")"}]]//AbsoluteTiming*) +(*]*) + + +(* ::Section::Closed:: *) +(*HNL_D*) + + +(* ::Input:: *) +(*Module[{LLPn,LLP,mlist,proc},*) +(*LLPn="HNL";*) +(*proc="D";*) +(*Do[*) +(*MassList[LLPn,proc,Facility]={0.02,0.05`,0.1,0.15,0.17,0.1825,0.2`,0.5`,0.7`,1.,1.2`,1.5`,1.75`,1.84,1.95`};*) +(*,{Facility,FacilitiesList}];*) +(*Monitor[*) +(*Do[*) +(*LLP=ListHNLs[[k]];*) +(*TabulatedPDF[mLLP_]:=BlockTabulatedPDFsFromDecaysMass[LLP,SelectedFacility,mLLP,proc,nsim,\[Theta]Nlist[SelectedFacility],ENlist[SelectedFacility],\[Theta]minExtrFacility[SelectedFacility,proc],"False"];*) +(*filename=filenameToExport[LLP,proc,SelectedFacility];*) +(*mlist=MassList[LLPn,proc,SelectedFacility];*) +(*tabulatedblock[TabulatedPDF,mlist,filename]*) +(*,{k,1,Length[ListHNLs],1}],*) +(*Row[{ProgressIndicator[k,{1,Length[ListHNLs]}]," ","HNL = ",ListHNLs[[k]]," (",k,"/",Length[ListHNLs],")"}]]//AbsoluteTiming*) +(*]*) + + +(* ::Section::Closed:: *) +(*HNL_K*) + + +(* ::Input:: *) +(*If[MemberQ[{"SPS"},SelectedFacility],*) +(*proc="K";*) +(*Do[*) +(*MassList["HNL",proc,Facility]={0.05`,0.1,0.2,0.4,0.99*MaxMass[ListHNLs[[2]],SelectedFacility,proc],0.99*MaxMass[ListHNLs[[1]],SelectedFacility,proc]};*) +(*,{Facility,FacilitiesList}];*) +(*Do[*) +(*TabulatedPDF[mLLP_]:=BlockTabulatedPDFsFromDecaysMass[LLP,SelectedFacility,mLLP,proc,nsim,\[Theta]Nlist[SelectedFacility],ENlist[SelectedFacility],\[Theta]minExtrFacility[SelectedFacility,proc],"False"];*) +(*filename=filenameToExport[LLP,proc,SelectedFacility];*) +(*mlist=MassList["HNL",proc,SelectedFacility];*) +(*tabulatedblock[TabulatedPDF,mlist,filename]*) +(*,{LLP,Drop[ListHNLs,-1]}*) +(*]*) +(*]//AbsoluteTiming*) +(*{proc,mlist}//Clear;*) + + +(* ::Section::Closed:: *) +(*HNL_mu*) + + +(* ::Input:: *) +(*If[MemberQ[{"ESS"},SelectedFacility],*) +(*proc="mu";*) +(*Do[*) +(*MassList["HNL",proc,Facility]={0.005,0.01,0.015,0.02,0.025,0.03,0.035,0.04,0.045,0.05,0.055,0.06,0.065,0.07,0.075,0.08,0.085,0.09,0.095,0.1,0.99*MaxMass[ListHNLs[[1]],SelectedFacility,proc]}//Sort//DeleteDuplicates;*) +(*,{Facility,FacilitiesList}];*) +(*Do[*) +(*mlist=MassList["HNL",proc,SelectedFacility];*) +(*mlistExt=Join[mlist,Table[With[{mass=mlist[[i]],mmax=(mSM["mu"]^2-mSM["e"]^2+mlist[[i]]^2)/(2mSM["mu"])},Table[m,{m,mass+0.01(mmax-mass),mass+0.99(mmax-mass),(0.9(mmax-mass))/20}]],{i,1,Length[mlist],1}]//Flatten]//Sort//DeleteDuplicates;*) +(*elist=Join[Table[e,{e,10^-3.,mSM["mu"],0.001}],mlistExt,{mSM["mu"]}]//DeleteDuplicates//Sort;*) +(*TabulatedPDF[mLLP_]:=BlockTabulatedPDFsFromDecaysMass[LLP,SelectedFacility,mLLP,proc,nsim,\[Theta]Nlist[SelectedFacility],elist,\[Theta]minExtrFacility[SelectedFacility,proc],"False"];*) +(*filename=filenameToExport[LLP,proc,SelectedFacility];*) +(**) +(*tabulatedblock[TabulatedPDF,mlist,filename]*) +(*,{LLP,Drop[ListHNLs,-1]}*) +(*]//AbsoluteTiming*) +(*]*) +(*{proc,mlist}//Clear;*) + + +(* ::Section::Closed:: *) +(*HNL_PiCharged*) + + +(* ::Input:: *) +(*If[MemberQ[{"ESS"},SelectedFacility],*) +(*proc="PiCharged";*) +(*Do[*) +(*MassList["HNL",proc,Facility]={0.001,0.005,0.01,0.015,0.02,0.027,0.032,0.04,0.05,0.06,0.07,0.08,0.09,0.1,0.11,0.115,0.12,0.125,0.13,0.135};*) +(*,{Facility,{"ESS"}}];*) +(*Do[*) +(*elist=Join[(mSM["PiCharged"]^2-mSM["e"]^2+MassList["HNL",proc,"ESS"]^2)/(2mSM["PiCharged"]),(mSM["PiCharged"]^2-mSM["mu"]^2+MassList["HNL",proc,"ESS"]^2)/(2mSM["PiCharged"])]//DeleteDuplicates//Sort;*) +(*TabulatedPDF[mLLP_]:=BlockTabulatedPDFsFromDecaysMass[LLP,SelectedFacility,mLLP,proc,nsim,\[Theta]Nlist[SelectedFacility],elist,\[Theta]minExtrFacility[SelectedFacility,proc],"False"];*) +(*filename=filenameToExport[LLP,proc,SelectedFacility];*) +(*mlist=MassList["HNL",proc,SelectedFacility];*) +(*tabulatedblock[TabulatedPDF,mlist,filename]*) +(*,{LLP,Drop[ListHNLs,-1]}*) +(*]*) +(*]//AbsoluteTiming*) +(*{proc,mlist}//Clear;*) + + +(* ::Chapter::Closed:: *) +(*Scalar*) + + +(* ::Section::Closed:: *) +(*Scalar_B-mixing*) + + +(* ::Input:: *) +(*proc="B-mixing";*) +(*LLPv="Scalar";*) +(*(*List of masses for which the distribution will be tabulated*)*) +(*Do[*) +(*MassList[LLPv,proc,Facility]={0.02,0.05,0.2,0.5,1,1.3,1.5,1.7,2.,2.3,2.5,2.7,3.,3.3,3.6,4.,4.4,4.8,5.13};*) +(*,{Facility,FacilitiesList}];*) +(*TabulatedPDF[mLLP_]:=BlockTabulatedPDFsFromDecaysMass[LLPv,SelectedFacility,mLLP,proc,nsim,\[Theta]Nlist[SelectedFacility],ENlist[SelectedFacility],\[Theta]minExtrFacility[SelectedFacility,proc],"False"];*) +(*filename=filenameToExport[LLPv,proc,SelectedFacility];*) +(*mlist=MassList[LLPv,proc,SelectedFacility];*) +(*tabulatedblock[TabulatedPDF,mlist,filename]//AbsoluteTiming*) +(*{LLPv,proc,mlist}//Clear*) + + +(* ::Section::Closed:: *) +(*Scalar_B-quartic*) + + +(* ::Input:: *) +(*LLPv="Scalar";*) +(*proc="B-quartic";*) +(*(*List of masses for which the distribution will be tabulated*)*) +(*Do[*) +(*MassList[LLPv,proc,Facility]=Select[{0.02,0.05,0.2,0.5,1,1.5,2.,2.2,2.39},#"Vertical"->{Automatic,5}],ImageSize->{Automatic,Automatic},Scrollbars->{False,True}],Button["OK",DialogReturn[choice]]}]]*) +(*(*chbar*)*) +(*chbar= 6.6*10^-25*3*10^8;*) +(*(*Decay width of mesons*)*) +(*\[Tau]\[Pi]0=8.52*10^-17;*) +(*\[CapitalGamma]\[Pi]0=chbar/\[Tau]\[Pi]0;*) +(*\[Tau]B=1.64*10^-12;*) +(*hbar=6.58*10^-25;*) +(*\[CapitalGamma]BdecayGeV=hbar/\[Tau]B;*) +(*(*Bare quark masses from pdg*)*) +(*md=4.67*10^-3;*) +(*mu=2.16*10^-3;*) +(*ms=0.093;*) +(*(*Scales*)*) +(*\[CapitalLambda]wVal=80;*) +(*\[CapitalLambda]QCDval=0.34;*) +(*(*Coupling constants*)*) +(*\[Alpha]EM=1/137;*) +(*\[Alpha]W=1/29.;*) +(*f\[Pi]=0.093;*) +(*\[Theta]\[Eta]\[Eta]pr=ArcSin[-1/3.];*) +(*(*Cross-sections*)*) +(*\[Sigma]pNucleonInpb[Atarget_]=51*Atarget^-0.29*10^9;*) +(*\[Sigma]ppLHC=72*10^9;*) +(*(*Masses of various SM particles*)*) +(*{mSM["Bplus"],mSM["Kplus"],mSM["PiPlus"],mSM["h"],mSM["Bs"]}={5.279,0.495,0.139,62.5,5.366};*) +(*(*\[Alpha]S[ma_] = Interpolation[Import[FileNameJoin[{NotebookDirectory[],"phenomenology/AlphaS.txt"}],"Table"],InterpolationOrder\[Rule]1][ma];*)*) +(*(*____________________*)*) +(*(*B/K fragmentation fractions*)*) +(*(*____________________*)*) +(*(*Fragmentation fractions at the LHC. For the moment, the same fractions are assumed to be at the FCC-hh*)*) +(*fbtob0["LHC"]=fbtobplus["LHC"]=fbtob0["FCC-hh"]=fbtobplus["FCC-hh"]=0.324;*) +(*fbtobs["LHC"]=fbtobs["FCC-hh"]=0.09;*) +(*(*Fragmentation fractions at SPS. From SHiP physics paper*)*) +(*fbtobs["SPS"]=0.11;*) +(*fbtob0["SPS"]=fbtobplus["SPS"]=0.411;*) +(*fstokplus["SPS"]=0.5;*) +(*fstok0l["SPS"]=0.25;*) +(*(*Fraction of K^+/- decaying in-flight at SPS, from https://arxiv.org/pdf/2004.07974.pdf*)*) +(*fractionDecayInFlightKplusKminus=(0.29+0.07);*) +(*(*Fragmentation fractions at FermilabBD. Assumed to be the same as at SPS*)*) +(*fbtobs["FermilabBD"]=0.11;*) +(*fbtob0["FermilabBD"]=fbtobplus["FermilabBD"]=0.411;*) +(*(*Fragmentation fractions at Serpukhov. Assumed to be zero*)*) +(*fbtobs["Serpukhov"]=0.;*) +(*fbtob0["Serpukhov"]=fbtobplus["Serpukhov"]=0.;*) + + +(* ::Chapter::Closed:: *) +(*LLP phenomenology: prodution probabilities, decay widths (y = 2Subscript[v, h]/Subscript[f, a])*) + + +(* ::Section::Closed:: *) +(*Scanning for tabulated distributions*) + + +(* ::Input:: *) +(*(*Define the file pattern*)*) +(*pattern="DoubleDistr_*_*_*.m";*) +(*(*Search for files matching the pattern in the directory and its subdirectories*)*) +(*matchingFiles=FileNames[pattern,{directory["Distribution"]},Infinity];*) +(*(*List of LLPs, production modes, and facilities for which the tabulated distributions have been computed at the previous stage of using SensCalc*)*) +(*ExtractedProductionParameters=Function[filename,parts=StringSplit[FileNameTake[filename],"_"];*) +(*{parts[[2]],parts[[3]],StringDrop[parts[[4]],-2]} ];*) +(*(*combinations selected LLP, production channel, facility for which the tabulated distributions are present*)*) +(*DistrCombinations=(ExtractedProductionParameters/@matchingFiles)//Sort*) +(*Print["Phenomenology choice:"]*) +(*phen=dropdownDialog[{"Revised","Old"},"Use the revised phenomenology (2310.03524), or the old one (1901.09966; no hadronic decays, production only via B->K/K*)? Must be consistent with the choice made in 1. Acceptances.nb"];*) +(*If[phen==Null,phen="Revised"];*) +(*phen*) +(*If[phen=="Old",DistrCombinations=Select[DistrCombinations,#[[2]]=="B"&]]*) + + +(* ::Section::Closed:: *) +(*Production probabilities*) + + +(* ::Input:: *) +(*ProductionProbabilitiesCoefs=Import[FileNameJoin[{directory["Production weights"],"Coefs-production-Fermion universal-scale-1000.-GeV.m"}],"MX"];*) +(*vh=246.;*) +(*{\[Theta]am02["Pi0",ma_,y_],\[Theta]am02["Eta",ma_,y_],\[Theta]am02["EtaPr",ma_,y_],BrBtoALPtotal[ma_,y_],cGGeff[ma_,y_],BrBtoALPKplus[ma_,y_],BrBtoALPKstar[ma_,y_]}=ProductionProbabilitiesCoefs/.{f->(2vh)/y};*) +(*LogLogPlot[Evaluate[{\[Theta]am02["Pi0",ma,1],\[Theta]am02["Eta",ma,1],\[Theta]am02["EtaPr",ma,1]}],{ma,0.1,10},Frame->True,ImageSize->Large]*) +(*FacilitiesList={"SPS","FermilabBD","LHC","FCC-hh","Serpukhov","ESS"};*) +(*Do[*) +(*PmotherToLLP[mLLP_,y_,part,Facility]=If[phen=="Revised",\[Theta]am02[part,mLLP,y],0.];*) +(*,{part,{"Pi0","Eta","EtaPr"}},{Facility,FacilitiesList}]*) +(*Do[*) +(*PmotherToLLP[mLLP_,y_,"B",Facility]=(fbtob0[Facility]+fbtobplus[Facility])If[phen=="Revised",BrBtoALPtotal[mLLP,y],BrBtoALPKplus[mLLP,y]+BrBtoALPKstar[mLLP,y]];*) +(*,{Facility,FacilitiesList}]*) +(**) +(*(*Production from Drell-Yan process*)*) +(*\[Sigma]DrellYanData[Facility_]:=Block[{},*) +(*dat=Import[FileNameJoin[{directory["Production weights"],"sigmaDrellYan_ALP-fermion_"<>Facility<>".txt"}],"Table"];*) +(*MinMaxMassesDrellYan[Facility]={Min[dat[[All,1]]],Min[4,Max[dat[[All,1]]]]};*) +(*int[ma_]=If[MinMaxMassesDrellYan[Facility][[1]]<= ma<=MinMaxMassesDrellYan[Facility][[2]],Evaluate[10^(Interpolation[{Log10[#[[1]]],Log10[#[[2]]+10^-90]}&/@dat,InterpolationOrder->1][Log10[ma]])],0];*) +(*PmotherToLLP[mLLP_,y_,"DrellYan",Facility]=Abs[cGGeff[mLLP,y]]^2*int[mLLP]/\[Sigma]pNucleonInpb[Atarget]*) +(*]*) +(*Do[\[Sigma]DrellYanData[Facility],{Facility,{"SPS","FermilabBD","LHC"}}]*) +(*WeightsCombinations=Cases[Keys[DownValues@PmotherToLLP][[All,1,#]]&/@{3,4}//Transpose//Sort,_?(MemberQ[DistrCombinations[[All,{2,3}]],#]&)];*) +(*Print["If there are production weights to all available distributions:"]*) +(*IfCondDistrToWeights=DistrCombinations[[All,{2,3}]]==WeightsCombinations*) +(*If[!IfCondDistrToWeights,infoDialog["You have not provided the production probabilities PmotherToLLP to all the generated tabulated distributions! Please do this first to avoid problems"];]*) + + +(* ::Section::Closed:: *) +(*LLP lifetime and branching ratios*) + + +(* ::Subsection::Closed:: *) +(*Lifetimes and branching ratios*) + + +(* ::Input:: *) +(*(*List of widths of the ALP into various final states*)*) +(*DecayWidthsDataTemp=Import[FileNameJoin[{directory["Decays"],"Widths-model-Fermion universal-scale-1000.-GeV.m"}],"MX"];*) +(*DecayWidthsDataTemp2=DecayWidthsDataTemp[[4]];*) +(*{Table[i,{i,1,Length[DecayWidthsDataTemp2[[1]]],1}],DecayWidthsDataTemp2[[1]]}//TableForm*) +(*DecayWidthsData=Drop[DecayWidthsDataTemp2,3];*) +(*(*Total decay width and lifetime*)*) +(*totalwidthdata=If[phen=="Revised",DecayWidthsData[[All,{1,-1}]],Join[DecayWidthsData[[All,{1}]],DecayWidthsData[[All,{2}]]+DecayWidthsData[[All,{4}]]+DecayWidthsData[[All,{5}]],2]];*) +(*\[CapitalGamma]LLP[mLLP_,y_]=(1/(2vh))^2 y^2 Interpolation[totalwidthdata,InterpolationOrder->1][mLLP];*) +(*c\[Tau]LLP[mLLP_,y_]=chbar/\[CapitalGamma]LLP[mLLP,y];*) +(*ldecayLLP[mLLP_,y_,ELLP_]=c\[Tau]LLP[mLLP,y] Sqrt[ELLP^2-mLLP^2]/mLLP;*) + + +(* ::Chapter::Closed:: *) +(*Loading necessary routines*) + + +(* ::Input:: *) +(*If[Length[inecessary]==0,*) +(*NotebookEvaluate[FileNameJoin[{NotebookDirectory[],"codes/generic.nb"}]];*) +(*NotebookEvaluate[FileNameJoin[{NotebookDirectory[],"codes/for-sensitivities.nb"}]];*) +(*inecessary={1,2,3};*) +(*]*) + + +(* ::Title::Closed:: *) +(*Specifying the experiments*) + + +(* ::Input:: *) +(*SetDirectory[NotebookDirectory[]];*) +(*(*Parent directory*)*) +(*NotebookDirectory[]//ParentDirectory;*) +(*ExperimentDirectoriesList=Select[FileNames["*",directory["Acceptances"],1],DirectoryQ];*) +(*(*List of available experiments (for which the geometry has been implemented)*)*) +(*ExperimentsListTemp=Table[FileNameTake[ExperimentDirectoriesList[[i]],-1],{i,1,Length[ExperimentDirectoriesList],1}];*) +(*ExperimentsListTemp2=Join[Partition[ExperimentsListTemp,1],Table[{TrueQ@FileExistsQ@FileNameJoin[{directory["Acceptances"],ExperimentsListTemp[[i]],ToString@StringForm["Acceptance_``_for_``.m",Sequence@@{ExperimentsListTemp[[i]],LLPdirName}]}]},{i,1,Length[ExperimentsListTemp]}],2];*) +(*ExperimentsList=Select[ExperimentsListTemp2,#[[2]]==True&][[All,1]]//Sort*) +(*If[Length[ExperimentsList]==0,Print["No experiment is available, generate first the acceptance for the given experiment using module 1"]]*) +(*Print["Selected experiments:"]*) +(*SelectedExperimentList=If[Length[ExperimentsList]!=0,selectionDialog[ExperimentsList,"Select the experiments:"]]*) +(*icounter=1;*) +(**) + + +(* ::Chapter::Closed:: *) +(*Running block for next sections*) + + +(* ::Input:: *) +(*BlockEvaluation[tag_]:=Block[{},*) +(*nb=EvaluationNotebook[];*) +(*NotebookFind[nb,tag,All,CellTags];*) +(*SelectionEvaluate[nb]*) +(*]*) +(*If[tagselected=="Number-of-events+sensitivity",*) +(*Do[*) +(*BlockEvaluation["Number-of-events-computation+sensitivity"];*) +(*,{icounter,1,Length[SelectedExperimentList],1}],*) +(*If[tagselected=="Acceptance",*) +(*Do[*) +(*BlockEvaluation["Acceptance-computation"];*) +(*,{icounter,1,Length[SelectedExperimentList],1}]*) +(*]*) +(*]*) + + +(* ::Title::Closed:: *) +(*Number of events*) + + +(* ::Chapter::Closed:: *) +(*Particular experiment*) + + +(* ::Input:: *) +(*SelectedExperiment=SelectedExperimentList[[icounter++]];*) + + +(* ::Chapter::Closed:: *) +(*Cross-sections, acceptances*) + + +(* ::Input:: *) +(*dataAcceptances=Import[FileNameJoin[{FileNameJoin[{directory["Acceptances"],SelectedExperiment,ToString@StringForm["Acceptance_``_for_``.m",Sequence@@{SelectedExperiment,LLPdirName}]}]}],"MX"];//AbsoluteTiming*) +(*{FacilityGivenExperiment,FullAcceptanceData0,BrVis[mLLP_]}=dataAcceptances[[#]]&/@{1,3,5};*) +(*LogLogPlot[Evaluate[BrVis[mLLP]],{mLLP,0.02,10},Frame->True,ImageSize->Large,FrameStyle->Directive[Black, 22],PlotStyle->{{Thickness[0.003],Blue},{Thickness[0.003],Darker@Red},{Thickness[0.003],Darker@Darker@Green},{Thickness[0.003],Black}},GridLines->Automatic,PlotRange->{{0.1,10},{0.01,1.2}},Frame->True,ImageSize->Large,FrameLabel->{"m [GeV]","\!\(\*SubscriptBox[\(Br\), \(vis\)]\)"},PlotLabel-> Style[Row[{"For ",SelectedExperiment}], 20, Black]]*) +(*(*___________________________*)*) +(*(*Interpolation of the tabulated azimuthal acceptance, extracting Subscript[\[Theta], min/max], etc.*)*) +(*(*___________________________*)*) +(*{AzimuthalAcceptanceInt[\[Theta]LLP_,zLLP_],\[Theta]minExpAll,\[Theta]maxExpAll,\[Theta]minExp,\[Theta]maxExp,zminExp,zmaxExp,zmin\[Theta][\[Theta]LLP_],zmax\[Theta][\[Theta]LLP_]}=Block\[Epsilon]Azimuthal[FullAcceptanceData0];*) +(*(*Logarithmized data with full acceptance, and also decay acceptance and full acceptance interpolations*)*) +(*{FullAcceptanceData,DecayAcceptanceInt[mLLP_,\[Theta]LLP_,ELLP_,zLLP_],FullAcceptanceInt[mLLP_,\[Theta]LLP_,ELLP_,zLLP_],InGridm\[Epsilon],InGrid\[Theta]\[Epsilon],InGridE\[Epsilon],InGridz\[Epsilon],\[Epsilon]vals,\[Epsilon]azvals,mmin\[Epsilon],mmax\[Epsilon]}=Block\[Epsilon]Decay[FullAcceptanceData0,zminExp,BrVis];*) +(*CrossSectionData=dataAcceptances[[4]]//Transpose;*) +(*NpotGivenExperiment=Select[CrossSectionData,#[[1]]=="Npot"&][[1]][[2]]//N;*) +(*ProbMother["B"]=Select[CrossSectionData,#[[1]]=="Pb"&][[1]][[2]];*) +(*ProbMother["Pi0"]=Select[CrossSectionData,#[[1]]=="PPi0"&][[1]][[2]];*) +(*ProbMother["Eta"]=Select[CrossSectionData,#[[1]]=="PEta"&][[1]][[2]];*) +(*ProbMother["EtaPr"]=Select[CrossSectionData,#[[1]]=="PEtapr"&][[1]][[2]];*) +(*ProbMother["DrellYan"]=1.;*) +(*AtargetVal=Select[CrossSectionData,#[[1]]=="Atarget"&][[1]][[2]];*) +(*{{"\!\(\*SubscriptBox[\(\[Chi]\), \(b\\\ or\\\ \*OverscriptBox[\(b\), \(_\)]\)]\)","\!\(\*SubscriptBox[\(\[Chi]\), SuperscriptBox[\(\[Pi]\), \(0\)]]\)","\!\(\*SubscriptBox[\(\[Chi]\), \(\[Eta]\)]\)","\!\(\*SubscriptBox[\(\[Chi]\), \(\[Eta]'\)]\)"},{ProbMother["B"],ProbMother["Pi0"],ProbMother["Eta"],ProbMother["EtaPr"]}}//TableForm*) +(*(*infoDialog[Row[{"The number of proton collisions is ", NpotGivenExperiment,". You may change it at the stage of computing the sensitivities"}]]*)*) +(*Row[{"Search for "<>LLPdirName <>" at ", SelectedExperiment, " located at ",FacilityGivenExperiment,". \!\(\*SubscriptBox[\(N\), \(collisions\)]\) = ",NpotGivenExperiment}]*) +(*{{"Quantity","\!\(\*SubscriptBox[\(\[Theta]\), \(min\)]\), rad","\!\(\*SubscriptBox[\(\[Theta]\), \(max\)]\), rad","\!\(\*SubscriptBox[\(\[Theta]\), \(min\)]\)(\!\(\*SubscriptBox[\(\[Epsilon]\), \(dec\)]\)), rad","\!\(\*SubscriptBox[\(\[Theta]\), \(max\)]\)(\!\(\*SubscriptBox[\(\[Epsilon]\), \(dec\)]\)), rad","\!\(\*SubscriptBox[\(z\), \(min\)]\), m","\!\(\*SubscriptBox[\(z\), \(max\)]\), m"},{"Description","Min angle covered by experiment","Max angle covered by experiment","Min angle where \!\(\*SubscriptBox[\(\[Epsilon]\), \(decay\)]\)\[NotEqual]0","Max angle where \!\(\*SubscriptBox[\(\[Epsilon]\), \(decay\)]\)\[NotEqual]0","Min long. displacement of the decay volume","Max long. displacement of the decay volume"},{"Value",\[Theta]minExpAll,\[Theta]maxExpAll,\[Theta]minExp,\[Theta]maxExp,zminExp,zmaxExp}}//TableForm*) +(**) + + +(* ::Chapter::Closed:: *) +(*Angle-energy distributions for the given experiment*) + + +(* ::Input:: *) +(*ProductionPatternSelected=Select[DistrCombinations,#[[3]]==FacilityGivenExperiment&];*) +(*Print["Production list:"]*) +(*ProductionList=ProductionPatternSelected[[All,2]]//DeleteDuplicates*) +(*Do[*) +(*Module[{prod},*) +(*prod=ProductionPatternSelected[[i]][[2]];*) +(*(*Importing the data with distribution*)*) +(*dirimp=If[prod=="DrellYan",FileNameJoin[{directory["Distribution"],"Pregenerated"}],directory["Distribution"]];*) +(*DistrDataImport[prod]=Import[FileNameJoin[{dirimp,"DoubleDistr_"<>LLPdirName<>"_"<>prod<>"_"<>FacilityGivenExperiment<>".m"}],"MX"];*) +(*If[prod=="DrellYan",*) +(*DistrDataImport[prod]=Select[DistrDataImport[prod],MinMaxMassesDrellYan[FacilityGivenExperiment][[1]]<=#[[1]]<=MinMaxMassesDrellYan[FacilityGivenExperiment][[2]]&];*) +(*];*) +(*(*Min/mass mass of the LLP from the data*)*) +(*mlistDistr[prod]=DeleteDuplicates[DistrDataImport[prod][[All,1]]];*) +(*{mLLPmin[prod],mLLPmax[prod]}=MinMax[mlistDistr[prod]];*) +(*(*Interpolation of the tabulated distribution*)*) +(*DoubleDistrLLPint[mLLP_,\[Theta]LLP_,ELLP_,prod]=10^(Interpolation[distrlogComp[DistrDataImport[prod]],InterpolationOrder->1][Log10[mLLP],Log10[\[Theta]LLP],Log10[ELLP]]);*) +(*(*Probability to produce LLP*)*) +(*ProbLLP[mLLP_,finv_,prod]=ProbMother[prod]*PmotherToLLP[mLLP,finv,prod,FacilityGivenExperiment]/.{Atarget->AtargetVal};*) +(*]*) +(*,{i,1,Length[ProductionPatternSelected],1}]*) +(*directory["Auxiliary-experiment"]=FileNameJoin[{directory["Auxiliary"],SelectedExperiment}];*) +(*If[!DirectoryQ[directory["Auxiliary-experiment"]],CreateDirectory[directory["Auxiliary-experiment"]]];*) +(*Export[FileNameJoin[{directory["Auxiliary-experiment"],"Double-Distr-Averaged-"<>LLPdirName<>".m"}],{Sum[If[mLLPmin[prod]True,ImageSize->Large,PlotLegends->Placed[Style[#,15]&/@ProductionList,Right]];*) +(*ptprodprob=LogLogPlot[Evaluate[Table[ProbLLP[ma,1,prod],{prod,ProductionList}]],{ma,mmin\[Epsilon],mmax\[Epsilon]},Frame->True,ImageSize->Large,PlotLegends->Placed[Style[#,15]&/@ProductionList,Right]];*) +(*Style[Row[{ptprodprob,ptenergies}],ImageSizeMultipliers->{1, 1}]*) + + +(* ::Chapter::Closed:: *) +(*Number of events*) + + +(* ::Section::Closed:: *) +(*Number of events - using the mapping method *) + + +(* ::Subsection::Closed:: *) +(*Initializing all routines*) + + +(* ::Input:: *) +(*Do[{OutGrid\[Theta]final[prod],\[CapitalDelta]\[Theta]vals[prod]}=OutGrid\[Theta]Temp[InGrid\[Theta]\[Epsilon],30,prod,\[Theta]maxBrem],{prod,ProductionList}]*) +(*{OutGridzfinal,\[CapitalDelta]zvals}=OutGridszTemp[InGridz\[Epsilon],30,zminExp];*) +(*(*Final energy grid. Mass- and production channel-dependent*)*) +(*If[FacilityGivenExperiment!="ESS",*) +(*StepEtemp[Efip_]=Piecewise[{{0.3,Efip<=2.5},{0.5,2.5Directive[Black, 22],PlotStyle->{{Thickness[0.003],Blue},{Thickness[0.003],Darker@Red},{Thickness[0.003],Darker@Darker@Green},{Thickness[0.003],Black}},GridLines->Automatic,PlotRange->{MinMax[\[Epsilon]GeomTabs[ProdChannel][[All,1]]],{Max[0.9Min[Min[\[Epsilon]GeomTabs[ProdChannel][[All,4]]],Min[\[Epsilon]GeomTabs[ProdChannel][[All,3]]]],10^-5],1.1Max[Max[\[Epsilon]GeomTabs[ProdChannel][[All,2]]],Max[\[Epsilon]GeomTabs[ProdChannel][[All,4]]]]}},Joined->True,Frame->True,ImageSize->Large,FrameLabel->{"m [GeV]","Acceptance"},PlotLabel-> Style[Row[{"From ",ProdChannel}], 20, Black],PlotLegends->Placed[{Style[#, 18]&/@{"<\!\(\*SubscriptBox[\(\[Epsilon]\), \(LLP\)]\)>","<\!\(\*SubscriptBox[\(\[Epsilon]\), \(LLP\)]\)\!\(\*SubscriptBox[\(\[Epsilon]\), \(decay\)]\)>","c\[Tau]<\!\(\*SubscriptBox[\(\[Epsilon]\), \(LLP\)]\)\!\(\*SubscriptBox[\(P\), \(decay\)]\)>","c\[Tau]<\!\(\*SubscriptBox[\(\[Epsilon]\), \(LLP\)]\)\!\(\*SubscriptBox[\(P\), \(decay\)]\)\!\(\*SubscriptBox[\(\[Epsilon]\), \(decay\)]\)>"}},{0.75,0.2}]]*) +(*Style[Row[Evaluate[Table[PlotAcc[prod],{prod,ProductionList}]]],ImageSizeMultipliers->{1,1,1,1}]*) +(*(*Do[FilenameAcceptance[prod]=ToString@StringForm["Acceptance_ALP-fermion_at_``_From_``.dat",Sequence@@{SelectedExperiment,ExportList[prod]}];*) +(*Export[FileNameJoin[{NotebookDirectory[],"Auxiliary data/ALPs with fermion coupling",SelectedExperiment,FilenameAcceptance[prod]}],\[Epsilon]GeomTabs[prod][[All,{1,2,4,5}]],"Table"]*) +(*,{prod,ProductionList}]*)*) +(*AccAveraged[mLLP_,c\[Tau]_]=NpotGivenExperiment{Sum[If[mLLPmin[prod]1][mLLP]],0],{prod,ProductionList}],Sum[If[Max[mLLPmin[prod],mmin\[Epsilon]]1][mLLP]],0],{prod,ProductionList}],Sum[If[Max[mLLPmin[prod],mmin\[Epsilon]]1][mLLP]],0],{prod,ProductionList}]};*) +(*Export[FileNameJoin[{directory["Auxiliary-experiment"],"AcceptanceAveraged-"<>LLPdirName<>".m"}],AccAveraged[mLLP,c\[Tau]],"MX"];*) + + +(* ::Subsection::Closed:: *) +(*Rough estimates of the upper and lower bounds*) + + +(* ::Subsubsection::Closed:: *) +(*Definitions*) + + +(* ::Input:: *) +(*Do[LowerBoundEstimate[mLLP_,prod]=((NpotGivenExperiment*ProbLLP[mLLP,1,prod]*Interpolation[\[Epsilon]GeomTabs[prod][[All,{1,5}]],InterpolationOrder->1][mLLP])/(2.3ldecayLLP[mLLP,1,ELLP] mLLP/Sqrt[ELLP^2-mLLP^2]))^(-(1/4));*) +(*UpperBoundEstimate[mLLP_,prod]=(Abs[Re[Evaluate[-(ProductLog[-1,-2.3*b/a]/b)/.{a-> NpotGivenExperiment*ProbLLP[mLLP,1,prod]*Interpolation[\[Epsilon]GeomTabs[prod][[All,{1,3}]],InterpolationOrder->1][mLLP],b->zminExp/ldecayLLP[mLLP,1,ELLPmax[0.5,\[Theta]minExp,prod]]}]]])^(1/2),{prod,ProductionList}]*) +(*ProdTest=ProductionList[[1]];*) +(*LogLogPlot[Evaluate[{0.3LowerBoundEstimate[mLLP,ProdTest],1.8UpperBoundEstimate[mLLP,ProdTest]}],{mLLP,Max[mLLPmin[ProdTest],mmin\[Epsilon]],Min[mLLPmax[ProdTest],mmax\[Epsilon]]},Frame->True,ImageSize->Large]*) + + +(* ::Subsection::Closed:: *) +(*Number of events - fast*) + + +(* ::Input:: *) +(*FactorLowerBound=If[MemberQ[{"ANUBIS-shaft-volume-1","ANUBIS-shaft-volume-2","ANUBIS-shaft-volume-3"},SelectedExperiment]==True,0.1,0.3];*) +(*NeventsDiscret[m_,ProdChannel_,couplinglist_]:=Module[{NevDiscret,NpotTimes\[Chi]val,zshift},*) +(*If[Max[mLLPmin[ProdChannel],mmin\[Epsilon]]"AdaptiveMonteCarlo"]*) +(*(*IntegralLLP[mLLP_,finv_,ProdChannel_]:=NIntegrate[Abs[IntegrandLLP[mLLP,finv,Exp[\[Theta]LLP],Exp[ELLP],Exp[zLLP],ProdChannel]]Exp[\[Theta]LLP+ELLP+zLLP],{\[Theta]LLP,Log[\[Theta]minExp],Log[\[Theta]maxExp]},{ELLP,Log[mLLP],Log[ELLPmax[mLLP,Exp[\[Theta]LLP],ProdChannel]]},{zLLP,Log[zmin\[Theta][Exp[\[Theta]LLP]]],Log[zmax\[Theta][Exp[\[Theta]LLP]]]},Method\[Rule]"AdaptiveMonteCarlo"]*)*) +(*NeventsInt[mLLP_,coupling_,ProdChannel_]:=If[mLLPmin[ProdChannel]<=mLLP<=mLLPmax[ProdChannel]&&BrVis[mLLP]!=0,If[0.1LowerBoundEstimate[mLLP,ProdChannel]"AdaptiveMonteCarlo"]*) +(*NeventsDiffInt[mLLP_,coupling_,ProdChannel_,ELLP_]:=If[mLLPmin[ProdChannel]<=mLLP<=mLLPmax[ProdChannel]&&BrVis[mLLP]!=0&&mLLP2,"\!\(\*SubscriptBox[\(\[Theta]\), \(X\)]\)"->1,"\!\(\*SubscriptBox[\(z\), \(X\)]\)"->3}]*) +(*\[CapitalDelta]xvals["\!\(\*SubscriptBox[\(E\), \(X\)]\)"]:=\[CapitalDelta]Evals;*) +(*\[CapitalDelta]xvals["\!\(\*SubscriptBox[\(z\), \(X\)]\)"]=\[CapitalDelta]zvals;*) +(*Do[\[CapitalDelta]xvals["\!\(\*SubscriptBox[\(\[Theta]\), \(X\)]\)",prod]=\[CapitalDelta]\[Theta]vals[prod],{prod,ProductionList}];*) +(*LegendX:=Association[{"\!\(\*SubscriptBox[\(E\), \(X\)]\)"->"\!\(\*SubscriptBox[\(E\), \(X\)]\) [GeV]","\!\(\*SubscriptBox[\(\[Theta]\), \(X\)]\)"->"\!\(\*SubscriptBox[\(\[Theta]\), \(X\)]\) [rad]","\!\(\*SubscriptBox[\(z\), \(X\)]\)"-> "\!\(\*SubscriptBox[\(z\), \(X\)]\) [m]"}]*) +(*LegendY:=Association[{"\!\(\*SubscriptBox[\(E\), \(X\)]\)"->"\!\(\*SubscriptBox[\(dN\), \(ev\)]\)/\!\(\*SubscriptBox[\(dE\), \(X\)]\) [\!\(\*SuperscriptBox[\(GeV\), \(-1\)]\)]","\!\(\*SubscriptBox[\(\[Theta]\), \(X\)]\)"->"\!\(\*SubscriptBox[\(dN\), \(ev\)]\)/\!\(\*SubscriptBox[\(d\[Theta]\), \(X\)]\) [\!\(\*SuperscriptBox[\(rad\), \(-1\)]\)]","\!\(\*SubscriptBox[\(z\), \(X\)]\)"-> "\!\(\*SubscriptBox[\(dN\), \(ev\)]\)/\!\(\*SubscriptBox[\(dz\), \(X\)]\) [\!\(\*SuperscriptBox[\(m\), \(-1\)]\)]"}]*) +(*(*Differential number of events*)*) +(*NeventsDifferentialDiscretProd[m_,ProdChannel_,coupling_,Variable_]:=Module[{NpotTimes\[Chi]val},*) +(*ival=iVal[Variable];*) +(*NpotTimes\[Chi]val=NpotGivenExperiment*ProbLLP[m,coupling,ProdChannel];*) +(*tablegrid0=TableIntegrandDiscret[m,ProdChannel,"True"];*) +(*OutGridEfinalTemp=OutGridEnergy[N[m],ProdChannel];*) +(*\[CapitalDelta]Evals=(Rest[10^OutGridEfinalTemp]-Most[10^OutGridEfinalTemp]);*) +(*\[CapitalDelta]xval=\[CapitalDelta]xvals[Variable];*) +(*c\[Tau]Val=c\[Tau]LLP[m,coupling];*) +(*brvis=BrVis[m];*) +(*ilist=DeleteDuplicates[{ival,1,2,3}];*) +(*tablegrid1=SortBy[{#[[ilist[[1]]]],#[[ilist[[2]]]],#[[ilist[[3]]]],#[[4]]}&/@tableGridPrefac[tablegrid0,m,c\[Tau]Val,0.],{#[[1]],#[[2]],#[[3]]}&];*) +(*GridQuantity=tablegrid1[[All,1]]//DeleteDuplicates;*) +(*LengthPerVariable=Length[tablegrid1]/Length[GridQuantity];*) +(*tab1=NdiffCompiled[tablegrid1,GridQuantity,LengthPerVariable,NpotTimes\[Chi]val*brvis];*) +(*Join[tab1[[All,{1}]],Partition[tab1[[All,2]]*\[CapitalDelta]xval^-1,1],2]*) +(*]*) +(*NeventsDifferentialDiscret[m_,coupling_,Variable_]:=Module[{NdiffInt,LegendList,QuantityMinMax,ValueMinMax},*) +(*prodlisttemp={};*) +(*Do[If[Max[mLLPmin[prod],mmin\[Epsilon]]10^-40&][[All,1]]//MinMax;*) +(*NdiffInt[X_,prod]=If[XvalminmaxNdiff[[1]]1][Log10[X]]],0]],{prod,ProductionList}];*) +(*NdiffInt[X_,"Total"]=Sum[NdiffInt[X,prod],{prod,prodlisttemp}];*) +(*LegendList=Join[{"Total"},prodlisttemp];*) +(*QuantityMinMax=Flatten[Table[MinMax[NdiffData[prod][[All,1]]],{prod,prodlisttemp}],1]//MinMax;*) +(*ValueMinMax=Max[Max[NdiffData[#][[All,2]]]&/@prodlisttemp];*) +(*{Table[NdiffInt[X,prod],{prod,LegendList}],LegendList,QuantityMinMax,ValueMinMax}*) +(*]*) +(*mvaltest=If[FacilityGivenExperiment=="ESS",0.04,0.2];*) +(*couplingvaltest=1.4LowerBoundEstimate[mvaltest,ProductionList[[1]]];*) +(*quantity="\!\(\*SubscriptBox[\(E\), \(X\)]\)";*) +(*{NdiffTab[X_],LegendList,QuantityMinMax,ValueMinMax}=NeventsDifferentialDiscret[mvaltest,couplingvaltest,quantity];*) +(*Do[*) +(*prch=LegendList[[i]];*) +(*NdiffInt[X_,prch]=NdiffTab[X][[i]];*) +(*,{i,1,Length[LegendList]}];*) +(*plotdiff=LogLogPlot[Evaluate[Table[NdiffInt[X,prod],{prod,LegendList}]],{X,QuantityMinMax[[1]],QuantityMinMax[[2]]},Frame->True,ImageSize->Large,PlotRange->{All,{10^-5,2ValueMinMax}},PlotStyle->{{Thick,Black},{Thick,Blue},{Thick,Darker@Red},{Thick,Darker@Darker@Green},{Thick,Darker@Cyan},{Thick,Magenta},{Thick,Blue,Dashing[0.02]},{Thick,Darker@Red,Dashing[0.02]},{Thick,Darker@Darker@Green,Dashing[0.02]}},PlotLegends->Placed[Style[#,20]&/@LegendList,Right],FrameLabel->{LegendX[quantity] ,LegendY[quantity]},FrameStyle->Directive[Black, 18],PlotLabel->Style[Row[{SelectedExperiment,". \!\(\*SubscriptBox[\(m\), \(a\)]\) = ",mvaltest," GeV, \!\(\*SubscriptBox[\(g\), \(Y\)]\) = ",couplingvaltest//N}],14,Black]]*) + + +(* ::Title::Closed:: *) +(*Exporting tabulated number of events*) + + +(* ::Chapter::Closed:: *) +(*Definitions*) + + +(* ::Input:: *) +(*directory["Nevents"]=FileNameJoin[{NotebookDirectory[],"Tabulated Nevents"}];*) +(*directory["Nevents-LLP"]=FileNameJoin[{NotebookDirectory[],"Tabulated Nevents",LLPdirName}];*) +(*directory["Nevents-LLP-experiment"]=FileNameJoin[{NotebookDirectory[],"Tabulated Nevents",LLPdirName,SelectedExperiment}];*) +(*If[!DirectoryQ[directory[#]],CreateDirectory[directory[#]]]&/@{"Nevents","Nevents-LLP","Nevents-LLP-experiment"};*) +(*Print["Filenames with tabulated \!\(\*SubscriptBox[\(N\), \(events\)]\):"]*) +(*Do[FilenameNevents[prod]=ToString@StringForm["Nevents_``_``_at_``_Npot=``.dat",Sequence@@{LLPdirName,prod,SelectedExperiment,NpotGivenExperiment//CForm//ToString}],{prod,ProductionList}]*) +(*FilenameNevents[#]&/@ProductionList*) +(*Do[mRangeExport[prod]={0.02,0.03,0.04,0.05,0.06,0.07,0.08,0.09,0.1,0.11,0.12,0.13,0.14,0.151,0.2,0.21,0.215,0.218,0.22,0.225,0.23,0.24,0.25,0.27,0.301,0.35,0.4,0.425,0.45,0.47,0.5,0.51,0.52,0.53,0.535,0.54,0.543,0.544,0.545,0.546,0.55,0.56,0.57,0.58,0.59,0.6,0.61,0.62,0.63,0.64,0.65,0.67,0.7,0.725,0.75,0.77,0.8,0.825,0.85,0.87,0.88,0.89,0.9,0.91,0.92,0.93,0.94,0.95,0.953,0.954,0.955,0.956,0.96,0.961,0.962,0.963,0.966,0.97,0.973,0.975,0.98,1.,1.01,1.02,1.03,1.05,1.07,1.1,1.12,1.15,1.2,1.25,1.3,1.4,1.5,1.6,1.7,1.8,1.9,2.,2.1,2.2,2.3,2.4,2.5,2.6,2.7,2.9,3.2,3.3,3.4,3.5,3.6,3.7,3.8,3.9,4.,4.1,4.2,4.3,4.4,4.5,4.6,4.7,4.76}//N;*) +(*,{prod,ProductionList}]*) +(*couplingsRangeExport=Table[10^x,{x,-7,-1,0.017}]//N;*) + + +(* ::Chapter::Closed:: *) +(*Exporting*) + + +(* ::Section::Closed:: *) +(*Common definition*) + + +(* ::Input:: *) +(*BlockExport[ProdChannel_]:=Module[{mlist},*) +(*mlist=mRangeExport[ProdChannel];*) +(*TabFrom=ParallelTable[Quiet[NeventsDiscret[mlist[[k]],ProdChannel,couplingsRangeExport]],{k,1,Length[mlist],1}];*) +(*Export[FileNameJoin[{directory["Nevents-LLP-experiment"],FilenameNevents[ProdChannel]}],Flatten[TabFrom,1],"Table"]*) +(*]*) +(*Monitor[*) +(*Do[*) +(*prod=ProductionList[[j]];*) +(*BlockExport[prod],{j,1,Length[ProductionList],1}],*) +(*Row[{ProgressIndicator[j,{1,Length[ProductionList]}]," Production mode = ",ProductionList[[j]]," (", j,"/",Length[ProductionList],")"}]]//AbsoluteTiming*) +(*If[icounter>Length[SelectedExperimentList],BlockEvaluation["Sensitivity"]]*) + + +(* ::Title::Closed:: *) +(*Computing sensitivities*) + + +(* ::Chapter::Closed:: *) +(*Basic definitions*) + + +(* ::Input:: *) +(*LLPdirName="ALP-fermion";*) +(*directory["Sensitivity"]=FileNameJoin[{NotebookDirectory[],"Sensitivity domains"}];*) +(*directory["Sensitivity-LLP"]=FileNameJoin[{directory["Sensitivity"],LLPdirName}];*) +(*If[!DirectoryQ[directory[#]],CreateDirectory[directory[#]]]&/@{"Sensitivity","Sensitivity-LLP"};*) +(*directory["Nevents-LLP"]=FileNameJoin[{NotebookDirectory[],"Tabulated Nevents",LLPdirName}];*) +(*dropdownDialog[list_,phrase_]:=DialogInput[{choice=""},Column[{TextCell[phrase],PopupMenu[Dynamic[choice],list],Button["OK",DialogReturn[choice]]}]]*) +(*infoDialog[phrase_]:=DialogInput[{choice=""},Column[{TextCell[phrase],Button["Proceed",DialogReturn[choice]]}]]*) +(*selectionDialog[list_,phrase_]:=DialogInput[{choice={}},Column[{Row[{phrase}],Pane[TogglerBar[Dynamic[choice],list,Appearance->"Vertical"->{Automatic,5}],ImageSize->{Automatic,Automatic},Scrollbars->{False,True}],Button["OK",DialogReturn[choice]]}]]*) +(*ExperimentDirectoriesListNevents=Select[FileNames["*",directory["Nevents-LLP"],1],DirectoryQ];*) +(*Print["List of available experiments with tabulated \!\(\*SubscriptBox[\(N\), \(events\)]\) for " <>LLPdirName<>":"]*) +(*ExperimentsListNevents=Table[FileNameTake[ExperimentDirectoriesListNevents[[i]],-1],{i,1,Length[ExperimentDirectoriesListNevents],1}]//Sort;*) +(*ExperimentsListNevents//TableForm*) +(*If[Length[ExperimentsListNevents]==0,Print["No experiment is available, generate first the acceptance for the given experiment using module 1"],*) +(*SelectedExperimentList=If[Length[ExperimentsListNevents]!=0,selectionDialog[ExperimentsListNevents,"Select the experiments for which the sensitivity will be computed:"]];*) +(*icounter=1;*) +(*BlockEvaluation[tag_]:=Block[{},*) +(*nb=EvaluationNotebook[];*) +(*NotebookFind[nb,tag,All,CellTags];*) +(*SelectionEvaluate[nb]*) +(*];*) +(*Do[*) +(*BlockEvaluation["Sensitivity-computation"];*) +(*,{icounter,1,Length[SelectedExperimentList],1}]*) +(*]*) + + +(* ::Input:: *) +(**) + + +(* ::Chapter::Closed:: *) +(*Specifying the experiment and interpolating the tabulated number of events*) + + +(* ::Section::Closed:: *) +(*Selecting the experiment*) + + +(* ::Input:: *) +(*Print["Selected experiment:"]*) +(*GivenExperimentForSensitivityComputation=SelectedExperimentList[[icounter++]]*) +(*CondANUBIS=MemberQ[{"ANUBIS-shaft-volume-1","ANUBIS-shaft-volume-2","ANUBIS-shaft-volume-3"},GivenExperimentForSensitivityComputation];*) +(*If[CondANUBIS==True,infoDialog[Row[{"One of the modules of ANUBIS-shaft is chosen. The full sensitivity includes three modules. The importing will be over all modules, so for all ot the the sensitivity has to be computed"}]]]*) +(*If[CondANUBIS==False,GivenExperimentForSensitivityComputationList={GivenExperimentForSensitivityComputation},GivenExperimentForSensitivityComputationList={"ANUBIS-shaft-volume-1","ANUBIS-shaft-volume-2","ANUBIS-shaft-volume-3"}];*) +(*directoriesNeventsSelected={};*) +(*Do[directoriesNeventsSelected=Join[directoriesNeventsSelected,FileNames["*.dat",FileNameJoin[{directory["Nevents-LLP"],exp}]]],{exp,GivenExperimentForSensitivityComputationList}];*) +(*(*Creating the directory for exporting sensitivity curves*)*) +(*ExperimentFolder=If[CondANUBIS==True,"ANUBIS",GivenExperimentForSensitivityComputation];*) +(*directory["Sensitivity-LLP-exp"]=FileNameJoin[{directory["Sensitivity-LLP"],ExperimentFolder}];*) +(*If[!DirectoryQ[directory["Sensitivity-LLP-exp"]],CreateDirectory[directory["Sensitivity-LLP-exp"]]]*) + + +(* ::Section::Closed:: *) +(*Importing and interpolations*) + + +(* ::Input:: *) +(*Print["List of production channels:"]*) +(*FilenamesNevents=Table[Last@FileNameSplit@directoriesNeventsSelected[[i]],{i,1,Length[directoriesNeventsSelected],1}];*) +(*FilenameParameters[i_]:=StringCases[FilenamesNevents[[i]],"Nevents_"<>LLPdirName<>"_"~~mother__~~"_at_"~~experiment__~~"_Npot="~~Npot__~~".dat":>{mother,experiment,Npot}][[1]]*) +(*(*______________________________________________________*)*) +(*(*Importing and interpolation*)*) +(*(*______________________________________________________*)*) +(*ProductionInfoList=Table[FilenameParameters[i],{i,1,Length[FilenamesNevents],1}];*) +(*Join[{{"Mother","Experiment","\!\(\*SubscriptBox[\(N\), \(PoT\)]\)"}},ProductionInfoList]//TableForm*) +(*ProductionChannelsList=ProductionInfoList[[All,1]];*) +(*NpotDefault=Interpreter["Number"][ProductionInfoList[[1]][[3]]];*) +(*NeventsTabulated//Clear;*) +(*\[Epsilon]reco[mLLP_]=1;*) +(*If[StringContainsQ[GivenExperimentForSensitivityComputation,"LHCb-downstream"],*) +(*\[Epsilon]reco[mLLP_]=0.4];*) +(*If[StringContainsQ[GivenExperimentForSensitivityComputation,"CHARM-lepton"],\[Epsilon]reco[mLLP_]=If[mLLP<0.105*2,0.51,0.85]];*) +(*If[StringContainsQ[GivenExperimentForSensitivityComputation,"NuCal"],\[Epsilon]reco[mLLP_]=If[mLLP<0.105*2,0.7,0.8]];*) +(*Do[*) +(*Module[{prod},*) +(*prod=ProductionChannelsList[[i]];*) +(*(*The condition if one sums the number of events for the same production mode over several experiments*)*) +(*IfprodExists=MemberQ[Keys[DownValues@NeventsTabulated][[All,1,1]],prod];*) +(*NeventsTabulated[prod]=If[!IfprodExists,Import[directoriesNeventsSelected[[i]],"Table"],Join[NeventsTabulated[prod][[All,{1,2}]],NeventsTabulated[prod][[All,{3}]]+Import[directoriesNeventsSelected[[i]],"Table"][[All,{3}]]]];*) +(*{mminmax[prod],couplingminmax[prod]}=(NeventsTabulated[prod][[All,#]]//MinMax)&/@{1,2};*) +(*NevMax[prod]=NeventsTabulated[prod][[All,3]]//Max;*) +(*NevInt[mLLP_,y_,prod]=\[Epsilon]reco[mLLP]*If[mminmax[prod][[1]]<= mLLP<=mminmax[prod][[2]]&&couplingminmax[prod][[1]]<=y<=couplingminmax[prod][[2]],Evaluate[10^(Interpolation[{Log10[#[[1]]],Log10[#[[2]]],Log10[#[[3]]+10^-90]}&/@NeventsTabulated[prod],InterpolationOrder->1][Log10[mLLP],Log10[y]])],0];*) +(*]*) +(*,{i,1,Length[ProductionInfoList],1}]*) +(*{mminmaxOverall,couplingminmaxOverall}=MinMax[Table[#[prod],{prod,ProductionChannelsList}]//Flatten]&/@{mminmax,couplingminmax};*) +(*NevMaxOverall=Max[Table[NevMax[prod],{prod,ProductionChannelsList}]];*) +(*NevIntOverall[mLLP_,y_]=Sum[NevInt[mLLP,y,prod],{prod,ProductionChannelsList}];*) +(*pt[mLLP_]:=LogLogPlot[Evaluate[Table[NevInt[mLLP,y,prod],{prod,ProductionChannelsList}]],{y,couplingminmaxOverall[[1]],couplingminmaxOverall[[2]]},PlotLegends->Placed[Style[#,15]&/@ProductionChannelsList,Right],PlotRange->{couplingminmaxOverall,{10^-2,NevMaxOverall}},Frame->True,ImageSize->Large,FrameLabel->{"y" , "\!\(\*SubscriptBox[\(N\), \(events\)]\)[\!\(\*SubscriptBox[\(m\), \(a\)]\),y]"},FrameStyle->Directive[Black, 23],PlotStyle->{{Thick,Blue},{Thick,Darker@Red},{Thick,Darker@Darker@Green},{Thick,Black},{Thick,Blue,Dashing[0.02]},{Thick,Darker@Red,Dashing[0.02]},{Thick,Darker@Darker@Green,Dashing[0.02]},{Thick,Black,Dashing[0.02]}},PlotLabel->Style[Row[{GivenExperimentForSensitivityComputation,". \!\(\*SubscriptBox[\(m\), \(a\)]\) = ",mLLP, " GeV"}],20,Black]]*) +(*pt[0.6]*) + + +(* ::Chapter::Closed:: *) +(*Sensitivity computation*) + + +(* ::Section::Closed:: *) +(*Subscript[N, events] density plot*) + + +(* ::Input:: *) +(*plot=DensityPlot[Evaluate[Log10[NevIntOverall[mLLP,y]]],{mLLP,mminmaxOverall[[1]],mminmaxOverall[[2]]},{y,couplingminmaxOverall[[1]],couplingminmaxOverall[[2]]},ScalingFunctions->{"Log","Log"},AspectRatio->0.78,PlotRange->{All,All,{Log10[2.3],Log10[NevMaxOverall]}},ImageSize->Large,FrameLabel->{"\!\(\*SubscriptBox[\(m\), \(a\)]\) [GeV]","y"}, Frame-> True, FrameStyle->Directive[Black, 25],PlotPoints->100,PlotLegends->Placed[BarLegend[{Automatic,{Log10[2.3],Log10[NevMaxOverall]}},LegendMarkerSize->340,LegendLabel->Placed["\!\(\*SubscriptBox[\(Log\), \(10\)]\)[\!\(\*SubscriptBox[\(N\), \(ev\)]\)]",Bottom],LabelStyle->{FontSize->22},Method->{FrameStyle->Black,AxesStyle->None,TicksStyle->Black}],Right],PlotLabel->Style[Row[{ExperimentFolder}],20,Black](*,FrameTicks->{{Automatic,Automatic},{TicksPlotx,None}}*)]*) +(*(*Export[FileNameJoin[{NotebookDirectory[],"plots/SensCalc/NeventsDensityPlotExample.pdf"}],plot,"AllowRasterization"->False]*)*) + + +(* ::Section::Closed:: *) +(*Constraints importing*) + + +(* ::Input:: *) +(*importformat["txt"]=importformat["dat"]="Table";*) +(*importformat["m"]=importformat["mx"]="MX";*) +(*importformat["xls"]="XLS";*) +(*dir=FileNameJoin[{NotebookDirectory[],"contours",LLPdirName}];*) +(*If[DirectoryQ[dir],*) +(*filenames=FileNames[LLPdirName<>"-excluded*",dir,Infinity];*) +(*ExcludedRegions[LLPdirName]=Import[#,importformat[FileExtension[#]]]&/@FileNames[LLPdirName<>"-excluded*",dir,Infinity];*) +(*];*) +(*If[!DirectoryQ[dir],*) +(*ExcludedRegions[LLPdirName]={{{10.,10.}}};*) +(*]*) + + +(* ::Section::Closed:: *) +(*Sensitivity*) + + +(* ::Input:: *) +(*SensitivityBlock[Nev_,Npot_,SelectedProduction_]:=Block[{},*) +(*NevTot[mLLP_,y_]=Sum[NevInt[mLLP,y,prod],{prod,SelectedProduction}];*) +(*RegSens1=RegionPlot[Npot/NpotDefault NevTot[10^mLLP,10^ga]*Boole[!(0.125<10^mLLP<0.14||0.538<10^mLLP<0.555||0.94<10^mLLP<0.974)]>=Nev,{mLLP,Log10[mminmaxOverall[[1]]],Log10[0.125]},{ga,Log10[couplingminmaxOverall[[1]]],Log10[couplingminmaxOverall[[2]]]},PlotPoints->200];*) +(*RegSens2=RegionPlot[Npot/NpotDefault NevTot[10^mLLP,10^ga]*Boole[!(0.125<10^mLLP<0.14||0.538<10^mLLP<0.555||0.94<10^mLLP<0.974)]>=Nev,{mLLP,Log10[0.14],Log10[0.538]},{ga,Log10[couplingminmaxOverall[[1]]],Log10[couplingminmaxOverall[[2]]]},PlotPoints->200];*) +(*RegSens3=RegionPlot[Npot/NpotDefault NevTot[10^mLLP,10^ga]*Boole[!(0.125<10^mLLP<0.14||0.538<10^mLLP<0.555||0.94<10^mLLP<0.974)]>=Nev,{mLLP,Log10[0.538],Log10[0.94]},{ga,Log10[couplingminmaxOverall[[1]]],Log10[couplingminmaxOverall[[2]]]},PlotPoints->200];*) +(*RegSens4=RegionPlot[Npot/NpotDefault NevTot[10^mLLP,10^ga]*Boole[!(0.125<10^mLLP<0.14||0.538<10^mLLP<0.555||0.94<10^mLLP<0.974)]>=Nev,{mLLP,Log10[0.974],Log10[mminmaxOverall[[2]]]},{ga,Log10[couplingminmaxOverall[[1]]],Log10[couplingminmaxOverall[[2]]]},PlotPoints->200];*) +(*(*Sens={10^#[[1]],10^#[[2]]}&/@Partition[Flatten[Cases[Normal@RegSens,Line[x_]\[RuleDelayed]x,Infinity]],2];*)*) +(*SensTemp=Cases[Normal@#,Line[x_]:>x,Infinity]&/@{RegSens1,RegSens2,RegSens3,RegSens4};*) +(*SensTemp1=Join[SensTemp[[1]],SensTemp[[2]],SensTemp[[3]],SensTemp[[4]]];*) +(*Sens=Table[{10^#[[1]],10^#[[2]]}&/@SensTemp1[[i]],{i,1,Length[SensTemp1],1}];*) +(*Export[FileNameJoin[{directory["Sensitivity-LLP-exp"],ToString@StringForm["Sensitivity_``_at_``_Nev=``_Npot=``.xls",Sequence@@{LLPdirName,ExperimentFolder,Nev//ToString,Npot//CForm//ToString}]}],Sens];*) +(*Sens*) +(*]*) +(*productionlist=Join[{"All"},ProductionChannelsList];*) +(*DynamicModule[{input1=NpotDefault,input2=2.3,choice={"All"},list,phrase},*) +(*DialogInput[Column[{Style[GivenExperimentForSensitivityComputation,Bold],TextCell["Enter the number of proton collisions:"],InputField[Dynamic[input1],Expression],TextCell["Enter the value of N_ev,min for which the sensitivity will be computed:"],InputField[Dynamic[input2],Expression],Row[{"Select the production channels to be used for the sensitivity calculation:"}],Pane[TogglerBar[Dynamic[choice],productionlist,Appearance->"Vertical"->{Automatic,1}],ImageSize->{Automatic,Automatic},Scrollbars->{False,True}],Button["Submit",DialogReturn[{NpotVal,NevMinVal,SelectedProduction}={input1,input2,choice}//N],ImageSize->Automatic]}]]];*) +(*If[MemberQ[SelectedProduction,"All"],SelectedProduction=ProductionChannelsList;]*) +(*{{"\!\(\*SubscriptBox[\(N\), \(PoT\)]\) for computation","\!\(\*SubscriptBox[\(N\), \(ev, min\)]\)","Selected production modes"},{NpotVal,NevMinVal,SelectedProduction}}//TableForm*) +(*sens=SensitivityBlock[NevMinVal,NpotVal,SelectedProduction];*) +(*Show[ListLogLogPlot[Cases[ExcludedRegions[LLPdirName],_?MatrixQ,All],Joined->{True,True,True,True},Frame-> True,FrameLabel->{"\!\(\*SubscriptBox[\(m\), \(a\)]\) [GeV]" , "\!\(\*SubscriptBox[\(g\), \(y\)]\) = 2\!\(\*SubscriptBox[\(v\), \(h\)]\)/\!\(\*SubscriptBox[\(f\), \(a\)]\)"},FrameStyle->Directive[Black, 23],PlotStyle->ConstantArray[{Thick,Gray},If[MatrixQ[ExcludedRegions[LLPdirName]],1,Length@ExcludedRegions[LLPdirName]]],Filling->Table[i->{True,Directive[Gray,Opacity[0.3]]},{i,1,10,1}],ImageSize->Large,PlotRange->{{1.01mminmaxOverall[[1]],1.1mminmaxOverall[[2]]},{0.3Min[Flatten[Sens]],8*10^-2}},PlotLabel->Style[Row[{"\!\(\*SubscriptBox[\(N\), \(events\)]\) \[GreaterEqual] ",NevMinVal}],18,Black]],ListLogLogPlot[Cases[sens,_?MatrixQ,All],Joined->{True,True,True,True},Frame-> True,FrameLabel->{"\!\(\*SubscriptBox[\(m\), \(a\)]\) [GeV]" , "\!\(\*SubscriptBox[\(g\), \(y\)]\) = 2\!\(\*SubscriptBox[\(v\), \(h\)]\)/\!\(\*SubscriptBox[\(f\), \(a\)]\)"},FrameStyle->Directive[Black, 23],PlotStyle->ConstantArray[{Thick,Blue},If[MatrixQ[sens],1,Length@sens]],ImageSize->Large,PlotRange->{{1.01mminmaxOverall[[1]],1.1mminmaxOverall[[2]]},{0.3Min[Flatten[Sens]],0.99couplingminmaxOverall[[2]]}},PlotLabel->Style[Row[{"\!\(\*SubscriptBox[\(N\), \(events\)]\) \[GreaterEqual] ",NevMinVal}],18,Black],PlotLegends->Placed[Style[#,15]&/@{ExperimentFolder},{0.2,0.15}]](*,LogLogPlot[{x,x^2,x^3,x^4,x^5,x^6},{x,0.05,62.49},PlotStyle\[Rule]{{Thickness[0.006],Blue},{Thickness[0.006],Darker@Red},{Thickness[0.006],Darker@Red,Dashing[0.02]},{Thickness[0.006],Black},{Thickness[0.01],Darker@Cyan,Dashing[0.007]},{Thick,Darker@Darker@Green,Dashing[0.02]},{Thick,Darker@Red}},PlotLegends\[Rule]Placed[Style[#,15]&/@{"SHiP","Subscript[SHADOWS, specified in LoI]","Subscript[SHADOWS, specified by Gaia]", "Subscript[SHADOWS, collab estimate]"},{0.26,0.15}]]*),Graphics[{Text[Style["Excluded",24,Black],Scaled[{0.7,0.95}]]}]]*) + + +(* ::Title::Closed:: *) +(*Deleting generated cells*) + + +(* ::Input:: *) +(*FrontEndTokenExecute["DeleteGeneratedCells"];*) +(*FrontEndTokenExecute["SelectAll"];*) +(*FrontEndTokenExecute["SelectionCloseAllGroups"];*) diff --git a/wls/3. ALP-gluon sensitivity.wls b/wls/3. ALP-gluon sensitivity.wls new file mode 100755 index 0000000..ddb9c86 --- /dev/null +++ b/wls/3. ALP-gluon sensitivity.wls @@ -0,0 +1,725 @@ +#!/usr/bin/env wolframscript +(* ::Package:: *) + +(* ::Title::Closed:: *) +(*Just launch the code below to run the notebook (shift+enter)*) + + +(* ::Input:: *) +(*ClearAll["Global`*"]*) +(*ParallelEvaluate[ClearAll["Global`*"]];*) +(*BlockEvaluation[tag_]:=Block[{},*) +(*nb=EvaluationNotebook[];*) +(*NotebookFind[nb,tag,All,CellTags];*) +(*SelectionEvaluate[nb]*) +(*]*) +(*CloseKernels[];*) +(*LaunchKernels[];*) +(*dropdownDialog[list_,phrase_]:=DialogInput[{choice=""},Column[{TextCell[phrase],PopupMenu[Dynamic[choice],list],Button["OK",DialogReturn[choice]]}]]*) +(*infoDialog[phrase_]:=DialogInput[{choice=""},Column[{TextCell[phrase],Button["Proceed",DialogReturn[choice]]}]]*) +(*If[(DirectoryQ[FileNameJoin[{NotebookDirectory[],"Auxiliary data"}]]//ToString)=="False",CreateDirectory[FileNameJoin[{NotebookDirectory[],"Auxiliary data"}]]];*) +(*choiceslist={"Tabulated Nevents+sensitivity","Sensitivity only (tabulated Nevents must be produced before)","Acceptance"};*) +(*taglist["Acceptance"]="Acceptance";*) +(*taglist["Tabulated Nevents+sensitivity"]="Number-of-events+sensitivity";*) +(*taglist["Sensitivity only (tabulated Nevents must be produced before)"]="Sensitivity";*) +(*computationchoice=dropdownDialog[choiceslist,"Do you want to compute the tabulated number of events and then sensitivity, or just sensitivity (if the tabulated number of events has been already produced)?"];*) +(*tagselected=taglist[computationchoice]*) +(*BlockEvaluation[tagselected]*) + + +(* ::Title::Closed:: *) +(*Preliminary definitions*) + + +(* ::Chapter::Closed:: *) +(*Various directories*) + + +(* ::Input:: *) +(*LLPdirName="ALP-gluon";*) +(*(*Set the directory for the search where tabulated acceptances are located*)*) +(*directory["Acceptances"]=FileNameJoin[{NotebookDirectory[],"Acceptances"}];*) +(*(*Set the directory for the search where tabulated angle-energy distributions are located*)*) +(*directory["Distribution"]=FileNameJoin[{NotebookDirectory[],"spectra/New physics particles spectra",LLPdirName}]; *) +(*(*The directory storing production weights of the given LLP*)*) +(*directory["Production weights"]=FileNameJoin[{NotebookDirectory[],"phenomenology",LLPdirName,"Production probabilities"}]; *) +(*(*Directory to which various auxillary datasets will be stored*)*) +(*directory["Auxiliary"]=FileNameJoin[{NotebookDirectory[],"Auxiliary data",LLPdirName}]; *) +(*If[!DirectoryQ[directory["Auxiliary"]],CreateDirectory[directory["Auxiliary"]]];*) +(*(*Directory containing decay widths of the LLPs*)*) +(*directory["Decays"]=FileNameJoin[{NotebookDirectory[],"phenomenology",LLPdirName,"decay widths"}]; *) + + +(* ::Chapter::Closed:: *) +(*Parameters and various functions*) + + +(* ::Input:: *) +(*dropdownDialog[list_,phrase_]:=DialogInput[{choice=""},Column[{TextCell[phrase],PopupMenu[Dynamic[choice],list],Button["OK",DialogReturn[choice]]}]]*) +(*infoDialog[phrase_]:=DialogInput[{choice=""},Column[{TextCell[phrase],Button["Proceed",DialogReturn[choice]]}]]*) +(*selectionDialog[list_,phrase_]:=DialogInput[{choice={}},Column[{Row[{"Select the experiments for which the number of events will be computed:"}],Pane[TogglerBar[Dynamic[choice],list,Appearance->"Vertical"->{Automatic,5}],ImageSize->{Automatic,Automatic},Scrollbars->{False,True}],Button["OK",DialogReturn[choice]]}]]*) +(*(*chbar*)*) +(*chbar= 6.6*10^-25*3*10^8;*) +(*(*Decay width of mesons*)*) +(*\[Tau]\[Pi]0=8.52*10^-17;*) +(*\[CapitalGamma]\[Pi]0=chbar/\[Tau]\[Pi]0;*) +(*\[Tau]B=1.64*10^-12;*) +(*hbar=6.58*10^-25;*) +(*\[CapitalGamma]BdecayGeV=hbar/\[Tau]B;*) +(*(*Bare quark masses from pdg*)*) +(*md=4.67*10^-3;*) +(*mu=2.16*10^-3;*) +(*ms=0.093;*) +(*(*Scales*)*) +(*\[CapitalLambda]wVal=80;*) +(*\[CapitalLambda]QCDval=0.34;*) +(*(*Coupling constants*)*) +(*\[Alpha]EM=1/137;*) +(*\[Alpha]W=1/29.;*) +(*f\[Pi]=0.093;*) +(*\[Theta]\[Eta]\[Eta]pr=ArcSin[-1/3.];*) +(*(*Cross-sections*)*) +(*\[Sigma]pNucleonInpb[Atarget_]=51*Atarget^-0.29*10^9;*) +(*\[Sigma]ppLHC=72*10^9;*) +(*(*Masses of various SM particles*)*) +(*{mSM["Bplus"],mSM["Kplus"],mSM["PiPlus"],mSM["h"],mSM["Bs"]}={5.279,0.495,0.139,62.5,5.366};*) +(*(*\[Alpha]S[ma_] = Interpolation[Import[FileNameJoin[{NotebookDirectory[],"phenomenology/AlphaS.txt"}],"Table"],InterpolationOrder\[Rule]1][ma];*)*) +(*(*____________________*)*) +(*(*B/K fragmentation fractions*)*) +(*(*____________________*)*) +(*(*Fragmentation fractions at the LHC. For the moment, the same fractions are assumed to be at the FCC-hh*)*) +(*fbtob0["LHC"]=fbtobplus["LHC"]=fbtob0["FCC-hh"]=fbtobplus["FCC-hh"]=0.324;*) +(*fbtobs["LHC"]=fbtobs["FCC-hh"]=0.09;*) +(*(*Fragmentation fractions at SPS. From SHiP physics paper*)*) +(*fbtobs["SPS"]=0.11;*) +(*fbtob0["SPS"]=fbtobplus["SPS"]=0.411;*) +(*fstokplus["SPS"]=0.5;*) +(*fstok0l["SPS"]=0.25;*) +(*(*Fraction of K^+/- decaying in-flight at SPS, from https://arxiv.org/pdf/2004.07974.pdf*)*) +(*fractionDecayInFlightKplusKminus=(0.29+0.07);*) +(*(*Fragmentation fractions at FermilabBD. Assumed to be the same as at SPS*)*) +(*fbtobs["FermilabBD"]=0.11;*) +(*fbtob0["FermilabBD"]=fbtobplus["FermilabBD"]=0.411;*) +(*(*Fragmentation fractions at Serpukhov. Assumed to be zero*)*) +(*fbtobs["Serpukhov"]=0.;*) +(*fbtob0["Serpukhov"]=fbtobplus["Serpukhov"]=0.;*) + + +(* ::Section::Closed:: *) +(*Subscript[\[Alpha], strong] (a rough fit from https://arxiv.org/abs/2201.05170)*) + + +(* ::Input:: *) +(*fitfunc[a1_,a2_,a3_,a4_,ma_]=a1+a2*ma+a3*ma^2+a4*ma^3;*) +(*coefsols=Solve[{fitfunc[a1,a2,a3,a4,1]==1&&(D[fitfunc[a1,a2,a3,a4,ma],ma]/.{ma->1})==0&&fitfunc[a1,a2,a3,a4,1.5]==(4*Pi)/(7*2*Log[1.5/0.34])&&(D[fitfunc[a1,a2,a3,a4,ma],ma]/.{ma->1.5})==(D[(4*Pi)/(7*2*Log[ma/0.34]),ma]/.{ma->1.5})},{a1,a2,a3,a4}];*) +(*\[Alpha]S[ma_]=Piecewise[{{1,ma<=1},{fitfunc[a1/.coefsols,a2/.coefsols,a3/.coefsols,a4/.coefsols,ma][[1]],11.5}}];*) +(*LogLogPlot[\[Alpha]S[ma],{ma,0.5,3}]*) + + +(* ::Chapter::Closed:: *) +(*LLP phenomenology: production probabilities, decay widths (finv == Subscript[f^-1, G])*) + + +(* ::Section::Closed:: *) +(*Scanning for tabulated distributions*) + + +(* ::Input:: *) +(*(*Define the file pattern*)*) +(*pattern="DoubleDistr_*_*_*.m";*) +(*(*Search for files matching the pattern in the directory and its subdirectories*)*) +(*matchingFiles=FileNames[pattern,{directory["Distribution"]},Infinity];*) +(*(*List of LLPs, production modes, and facilities for which the tabulated distributions have been computed at the previous stage of using SensCalc*)*) +(*ExtractedProductionParameters=Function[filename,parts=StringSplit[FileNameTake[filename],"_"];*) +(*{parts[[2]],parts[[3]],StringDrop[parts[[4]],-2]} ];*) +(*(*combinations selected LLP, production channel, facility for which the tabulated distributions are present*)*) +(*DistrCombinations=(ExtractedProductionParameters/@matchingFiles)//Sort*) + + +(* ::Section::Closed:: *) +(*Production probabilities*) + + +(* ::Input:: *) +(*ProductionProbabilitiesCoefs=Import[FileNameJoin[{directory["Production weights"],"Coefs-production-Gluon-scale-1000.-GeV.m"}],"MX"];*) +(*vh=246.;*) +(*{\[Theta]am02["Pi0",ma_,finv_],\[Theta]am02["Eta",ma_,finv_],\[Theta]am02["EtaPr",ma_,finv_],BrBtoALPtotal[ma_,finv_],cGGeff[ma_,finv_],BrBtoALPKplus[ma_,finv_],BrBtoALPKstar[ma_,finv_]}=ProductionProbabilitiesCoefs/.{f->finv^-1};*) +(*LogLogPlot[Evaluate[{\[Theta]am02["Pi0",ma,1],\[Theta]am02["Eta",ma,1],\[Theta]am02["EtaPr",ma,1]}],{ma,0.1,10},Frame->True,ImageSize->Large]*) +(*FacilitiesList={"ESS","SPS","FermilabBD","LHC","FCC-hh","Serpukhov"};*) +(*Do[*) +(*PmotherToLLP[mLLP_,finv_,part,Facility]=\[Theta]am02[part,mLLP,finv];*) +(*,{part,{"Pi0","Eta","EtaPr"}},{Facility,FacilitiesList}]*) +(*Do[*) +(*PmotherToLLP[mLLP_,finv_,"B",Facility]=(fbtob0[Facility]+fbtobplus[Facility])BrBtoALPtotal[mLLP,finv];*) +(*,{Facility,FacilitiesList}]*) +(*(*Production from Drell-Yan process*)*) +(*\[Sigma]DrellYanData[Facility_]:=Block[{},*) +(*dat=Import[FileNameJoin[{directory["Production weights"],"sigmaDrellYan_ALP-gluon_"<>Facility<>".txt"}],"Table"];*) +(*MinMaxMassesDrellYan[Facility]={Min[dat[[All,1]]],Min[4,Max[dat[[All,1]]]]};*) +(*int[ma_]=If[MinMaxMassesDrellYan[Facility][[1]]<= ma<=MinMaxMassesDrellYan[Facility][[2]],Evaluate[10^(Interpolation[{Log10[#[[1]]],Log10[#[[2]]+10^-90]}&/@dat,InterpolationOrder->1][Log10[ma]])],0];*) +(*PmotherToLLP[mLLP_,finv_,"DrellYan",Facility]=Abs[cGGeff[mLLP,finv]]^2*int[mLLP]/\[Sigma]pNucleonInpb[Atarget]*) +(*]*) +(*Do[\[Sigma]DrellYanData[Facility],{Facility,{"SPS","FermilabBD","LHC"}}]*) +(*WeightsCombinations=Cases[Keys[DownValues@PmotherToLLP][[All,1,#]]&/@{3,4}//Transpose//Sort,_?(MemberQ[DistrCombinations[[All,{2,3}]],#]&)];*) +(*Print["If there are production weights to all available distributions:"]*) +(*IfCondDistrToWeights=DistrCombinations[[All,{2,3}]]==WeightsCombinations*) +(*If[!IfCondDistrToWeights,infoDialog["You have not provided the production probabilities PmotherToLLP to all the generated tabulated distributions! Please do this first to avoid problems"];]*) + + +(* ::Section::Closed:: *) +(*ALP lifetime and branching ratios*) + + +(* ::Subsection::Closed:: *) +(*Lifetimes and branching ratios*) + + +(* ::Input:: *) +(*(*List of widths of the ALP into various final states*)*) +(*DecayWidthsDataTemp=Import[FileNameJoin[{directory["Decays"],"Widths-model-Gluon-scale-1000.-GeV.m"}],"MX"];*) +(*DecayWidthsDataTemp2=DecayWidthsDataTemp[[4]];*) +(*{Table[i,{i,1,Length[DecayWidthsDataTemp2[[1]]],1}],DecayWidthsDataTemp2[[1]]}//TableForm*) +(*DecayWidthsData=Drop[DecayWidthsDataTemp2,3];*) +(*(*Total decay width and lifetime*)*) +(*totalwidthdata=DecayWidthsData[[All,{1,-1}]];*) +(*\[CapitalGamma]LLP[mLLP_,finv_]=finv^2*Interpolation[totalwidthdata,InterpolationOrder->1][mLLP];*) +(*c\[Tau]LLP[mLLP_,finv_]=chbar/\[CapitalGamma]LLP[mLLP,finv];*) +(*ldecayLLP[mLLP_,finv_,ELLP_]=c\[Tau]LLP[mLLP,finv] Sqrt[ELLP^2-mLLP^2]/mLLP;*) + + +(* ::Chapter::Closed:: *) +(*Loading necessary routines*) + + +(* ::Input:: *) +(*If[Length[inecessary]==0,*) +(*NotebookEvaluate[FileNameJoin[{NotebookDirectory[],"codes/generic.nb"}]];*) +(*NotebookEvaluate[FileNameJoin[{NotebookDirectory[],"codes/for-sensitivities.nb"}]];*) +(*inecessary={1,2,3};*) +(*]*) + + +(* ::Title::Closed:: *) +(*Specifying the experiments*) + + +(* ::Input:: *) +(*SetDirectory[NotebookDirectory[]];*) +(*(*Parent directory*)*) +(*NotebookDirectory[]//ParentDirectory;*) +(*ExperimentDirectoriesList=Select[FileNames["*",directory["Acceptances"],1],DirectoryQ];*) +(*(*List of available experiments (for which the geometry has been implemented)*)*) +(*ExperimentsListTemp=Table[FileNameTake[ExperimentDirectoriesList[[i]],-1],{i,1,Length[ExperimentDirectoriesList],1}];*) +(*ExperimentsListTemp2=Join[Partition[ExperimentsListTemp,1],Table[{TrueQ@FileExistsQ@FileNameJoin[{directory["Acceptances"],ExperimentsListTemp[[i]],ToString@StringForm["Acceptance_``_for_``.m",Sequence@@{ExperimentsListTemp[[i]],LLPdirName}]}]},{i,1,Length[ExperimentsListTemp]}],2];*) +(*ExperimentsList=Select[ExperimentsListTemp2,#[[2]]==True&][[All,1]]//Sort*) +(*If[Length[ExperimentsList]==0,Print["No experiment is available, generate first the acceptance for the given experiment using module 1"]]*) +(*Print["Selected experiments:"]*) +(*SelectedExperimentList=If[Length[ExperimentsList]!=0,selectionDialog[ExperimentsList,"Select the experiments:"]]*) +(*icounter=1;*) + + +(* ::Chapter::Closed:: *) +(*Running block for next sections*) + + +(* ::Input:: *) +(*BlockEvaluation[tag_]:=Block[{},*) +(*nb=EvaluationNotebook[];*) +(*NotebookFind[nb,tag,All,CellTags];*) +(*SelectionEvaluate[nb]*) +(*]*) +(*If[tagselected=="Number-of-events+sensitivity",*) +(*Do[*) +(*BlockEvaluation["Number-of-events-computation+sensitivity"];*) +(*,{icounter,1,Length[SelectedExperimentList],1}],*) +(*If[tagselected=="Acceptance",*) +(*Do[*) +(*BlockEvaluation["Acceptance-computation"];*) +(*,{icounter,1,Length[SelectedExperimentList],1}]*) +(*]*) +(*]*) + + +(* ::Title::Closed:: *) +(*Number of events*) + + +(* ::Chapter::Closed:: *) +(*Particular experiment*) + + +(* ::Input:: *) +(*SelectedExperiment=SelectedExperimentList[[icounter++]];*) + + +(* ::Chapter::Closed:: *) +(*Cross-sections, acceptances*) + + +(* ::Input:: *) +(*dataAcceptances=Import[FileNameJoin[{FileNameJoin[{directory["Acceptances"],SelectedExperiment,ToString@StringForm["Acceptance_``_for_``.m",Sequence@@{SelectedExperiment,LLPdirName}]}]}],"MX"];//AbsoluteTiming*) +(*{FacilityGivenExperiment,FullAcceptanceData0,BrVis[mLLP_]}=dataAcceptances[[#]]&/@{1,3,5};*) +(*LogLogPlot[Evaluate[BrVis[mLLP]],{mLLP,0.02,10},Frame->True,ImageSize->Large,FrameStyle->Directive[Black, 22],PlotStyle->{{Thickness[0.003],Blue},{Thickness[0.003],Darker@Red},{Thickness[0.003],Darker@Darker@Green},{Thickness[0.003],Black}},GridLines->Automatic,PlotRange->{{0.1,10},{0.01,1.2}},Frame->True,ImageSize->Large,FrameLabel->{"m [GeV]","\!\(\*SubscriptBox[\(Br\), \(vis\)]\)"},PlotLabel-> Style[Row[{"For ",SelectedExperiment}], 20, Black]]*) +(*(*___________________________*)*) +(*(*Interpolation of the tabulated azimuthal acceptance, extracting Subscript[\[Theta], min/max], etc.*)*) +(*(*___________________________*)*) +(*{AzimuthalAcceptanceInt[\[Theta]LLP_,zLLP_],\[Theta]minExpAll,\[Theta]maxExpAll,\[Theta]minExp,\[Theta]maxExp,zminExp,zmaxExp,zmin\[Theta][\[Theta]LLP_],zmax\[Theta][\[Theta]LLP_]}=Block\[Epsilon]Azimuthal[FullAcceptanceData0];*) +(*(*Logarithmized data with full acceptance, and also decay acceptance and full acceptance interpolations*)*) +(*{FullAcceptanceData,DecayAcceptanceInt[mLLP_,\[Theta]LLP_,ELLP_,zLLP_],FullAcceptanceInt[mLLP_,\[Theta]LLP_,ELLP_,zLLP_],InGridm\[Epsilon],InGrid\[Theta]\[Epsilon],InGridE\[Epsilon],InGridz\[Epsilon],\[Epsilon]vals,\[Epsilon]azvals,mmin\[Epsilon],mmax\[Epsilon]}=Block\[Epsilon]Decay[FullAcceptanceData0,zminExp,BrVis];*) +(*CrossSectionData=dataAcceptances[[4]]//Transpose;*) +(*NpotGivenExperiment=Select[CrossSectionData,#[[1]]=="Npot"&][[1]][[2]]//N;*) +(*ProbMother["B"]=Select[CrossSectionData,#[[1]]=="Pb"&][[1]][[2]];*) +(*ProbMother["Pi0"]=Select[CrossSectionData,#[[1]]=="PPi0"&][[1]][[2]];*) +(*ProbMother["Eta"]=Select[CrossSectionData,#[[1]]=="PEta"&][[1]][[2]];*) +(*ProbMother["EtaPr"]=Select[CrossSectionData,#[[1]]=="PEtapr"&][[1]][[2]];*) +(*ProbMother["DrellYan"]=1.;*) +(*AtargetVal=Select[CrossSectionData,#[[1]]=="Atarget"&][[1]][[2]];*) +(*{{"\!\(\*SubscriptBox[\(\[Chi]\), \(b\\\ or\\\ \*OverscriptBox[\(b\), \(_\)]\)]\)","\!\(\*SubscriptBox[\(\[Chi]\), SuperscriptBox[\(\[Pi]\), \(0\)]]\)","\!\(\*SubscriptBox[\(\[Chi]\), \(\[Eta]\)]\)","\!\(\*SubscriptBox[\(\[Chi]\), \(\[Eta]'\)]\)"},{ProbMother["B"],ProbMother["Pi0"],ProbMother["Eta"],ProbMother["EtaPr"]}}//TableForm*) +(*(*infoDialog[Row[{"The number of proton collisions is ", NpotGivenExperiment,". You may change it at the stage of computing the sensitivities"}]]*)*) +(*Row[{"Search for "<>LLPdirName <>" at ", SelectedExperiment, " located at ",FacilityGivenExperiment,". \!\(\*SubscriptBox[\(N\), \(collisions\)]\) = ",NpotGivenExperiment}]*) +(*{{"Quantity","\!\(\*SubscriptBox[\(\[Theta]\), \(min\)]\), rad","\!\(\*SubscriptBox[\(\[Theta]\), \(max\)]\), rad","\!\(\*SubscriptBox[\(\[Theta]\), \(min\)]\)(\!\(\*SubscriptBox[\(\[Epsilon]\), \(dec\)]\)), rad","\!\(\*SubscriptBox[\(\[Theta]\), \(max\)]\)(\!\(\*SubscriptBox[\(\[Epsilon]\), \(dec\)]\)), rad","\!\(\*SubscriptBox[\(z\), \(min\)]\), m","\!\(\*SubscriptBox[\(z\), \(max\)]\), m"},{"Description","Min angle covered by experiment","Max angle covered by experiment","Min angle where \!\(\*SubscriptBox[\(\[Epsilon]\), \(decay\)]\)\[NotEqual]0","Max angle where \!\(\*SubscriptBox[\(\[Epsilon]\), \(decay\)]\)\[NotEqual]0","Min long. displacement of the decay volume","Max long. displacement of the decay volume"},{"Value",\[Theta]minExpAll,\[Theta]maxExpAll,\[Theta]minExp,\[Theta]maxExp,zminExp,zmaxExp}}//TableForm*) +(**) + + +(* ::Chapter::Closed:: *) +(*Angle-energy distributions for the given experiment*) + + +(* ::Input:: *) +(*ProductionPatternSelected=Select[DistrCombinations,#[[3]]==FacilityGivenExperiment&];*) +(*Print["Production list:"]*) +(*ProductionList=ProductionPatternSelected[[All,2]]//DeleteDuplicates*) +(*Do[*) +(*Module[{prod},*) +(*prod=ProductionPatternSelected[[i]][[2]];*) +(*(*Importing the data with distribution*)*) +(*dirimp=If[prod=="DrellYan",FileNameJoin[{directory["Distribution"],"Pregenerated"}],directory["Distribution"]];*) +(*DistrDataImport[prod]=Import[FileNameJoin[{dirimp,"DoubleDistr_"<>LLPdirName<>"_"<>prod<>"_"<>FacilityGivenExperiment<>".m"}],"MX"];*) +(*If[prod=="DrellYan",*) +(*DistrDataImport[prod]=Select[DistrDataImport[prod],MinMaxMassesDrellYan[FacilityGivenExperiment][[1]]<=#[[1]]<=MinMaxMassesDrellYan[FacilityGivenExperiment][[2]]&];*) +(*];*) +(*(*Min/mass mass of the LLP from the data*)*) +(*mlistDistr[prod]=DeleteDuplicates[DistrDataImport[prod][[All,1]]];*) +(*{mLLPmin[prod],mLLPmax[prod]}=MinMax[mlistDistr[prod]];*) +(*(*Interpolation of the tabulated distribution*)*) +(*DoubleDistrLLPint[mLLP_,\[Theta]LLP_,ELLP_,prod]=10^(Interpolation[distrlogComp[DistrDataImport[prod]],InterpolationOrder->1][Log10[mLLP],Log10[\[Theta]LLP],Log10[ELLP]]);*) +(*(*Probability to produce LLP*)*) +(*ProbLLP[mLLP_,finv_,prod]=ProbMother[prod]*PmotherToLLP[mLLP,finv,prod,FacilityGivenExperiment]/.{Atarget->AtargetVal};*) +(*]*) +(*,{i,1,Length[ProductionPatternSelected],1}]*) +(*directory["Auxiliary-experiment"]=FileNameJoin[{directory["Auxiliary"],SelectedExperiment}];*) +(*If[!DirectoryQ[directory["Auxiliary-experiment"]],CreateDirectory[directory["Auxiliary-experiment"]]];*) +(*Export[FileNameJoin[{directory["Auxiliary-experiment"],"Double-Distr-Averaged-"<>LLPdirName<>".m"}],{Sum[If[mLLPmin[prod]True,ImageSize->Large,PlotLegends->Placed[Style[#,15]&/@ProductionList,Right]];*) +(*ptprodprob=LogLogPlot[Evaluate[Table[ProbLLP[ma,1,prod],{prod,ProductionList}]],{ma,mmin\[Epsilon],mmax\[Epsilon]},Frame->True,ImageSize->Large,PlotLegends->Placed[Style[#,15]&/@ProductionList,Right]];*) +(*Style[Row[{ptprodprob,ptenergies}],ImageSizeMultipliers->{1, 1}]*) + + +(* ::Chapter::Closed:: *) +(*Number of events*) + + +(* ::Section:: *) +(*Number of events *) + + +(* ::Subsection:: *) +(*Initializing all routines*) + + +(* ::Input:: *) +(*Do[{OutGrid\[Theta]final[prod],\[CapitalDelta]\[Theta]vals[prod]}=OutGrid\[Theta]Temp[InGrid\[Theta]\[Epsilon],30,prod,\[Theta]maxBrem],{prod,ProductionList}]*) +(*{OutGridzfinal,\[CapitalDelta]zvals}=OutGridszTemp[InGridz\[Epsilon],30,zminExp];*) +(*(*Final energy grid. Mass- and production channel-dependent*)*) +(*If[FacilityGivenExperiment!="ESS",*) +(*StepEtemp[Efip_]=Piecewise[{{0.3,Efip<=2.5},{0.5,2.5Directive[Black, 22],PlotStyle->{{Thickness[0.003],Blue},{Thickness[0.003],Darker@Red},{Thickness[0.003],Darker@Darker@Green},{Thickness[0.003],Black}},GridLines->Automatic,PlotRange->{MinMax[\[Epsilon]GeomTabs[ProdChannel][[All,1]]],{Max[0.9Min[Min[\[Epsilon]GeomTabs[ProdChannel][[All,4]]],Min[\[Epsilon]GeomTabs[ProdChannel][[All,3]]]],10^-5],1.1Max[Max[\[Epsilon]GeomTabs[ProdChannel][[All,2]]],Max[\[Epsilon]GeomTabs[ProdChannel][[All,4]]]]}},Joined->True,Frame->True,ImageSize->Large,FrameLabel->{"m [GeV]","Acceptance"},PlotLabel-> Style[Row[{"From ",ProdChannel}], 20, Black],PlotLegends->Placed[{Style[#, 18]&/@{"<\!\(\*SubscriptBox[\(\[Epsilon]\), \(LLP\)]\)>","<\!\(\*SubscriptBox[\(\[Epsilon]\), \(LLP\)]\)\!\(\*SubscriptBox[\(\[Epsilon]\), \(decay\)]\)>","c\[Tau]<\!\(\*SubscriptBox[\(\[Epsilon]\), \(LLP\)]\)\!\(\*SubscriptBox[\(P\), \(decay\)]\)>","c\[Tau]<\!\(\*SubscriptBox[\(\[Epsilon]\), \(LLP\)]\)\!\(\*SubscriptBox[\(P\), \(decay\)]\)\!\(\*SubscriptBox[\(\[Epsilon]\), \(decay\)]\)>"}},{0.75,0.2}]]*) +(*Style[Row[Evaluate[Table[PlotAcc[prod],{prod,ProductionList}]]],ImageSizeMultipliers->{1,1,1,1}]*) +(*(*Do[FilenameAcceptance[prod]=ToString@StringForm["Acceptance_ALP-fermion_at_``_From_``.dat",Sequence@@{SelectedExperiment,ExportList[prod]}];*) +(*Export[FileNameJoin[{NotebookDirectory[],"Auxiliary data/ALPs with fermion coupling",SelectedExperiment,FilenameAcceptance[prod]}],\[Epsilon]GeomTabs[prod][[All,{1,2,4,5}]],"Table"]*) +(*,{prod,ProductionList}]*)*) +(*AccAveraged[mLLP_,c\[Tau]_]=NpotGivenExperiment{Sum[If[mLLPmin[prod]1][mLLP]],0],{prod,ProductionList}],Sum[If[Max[mLLPmin[prod],mmin\[Epsilon]]1][mLLP]],0],{prod,ProductionList}],Sum[If[Max[mLLPmin[prod],mmin\[Epsilon]]1][mLLP]],0],{prod,ProductionList}]};*) +(*Export[FileNameJoin[{directory["Auxiliary-experiment"],"AcceptanceAveraged-"<>LLPdirName<>".m"}],AccAveraged[mLLP,c\[Tau]],"MX"];*) + + +(* ::Subsection::Closed:: *) +(*Rough estimates of the upper and lower bounds*) + + +(* ::Subsubsection::Closed:: *) +(*Definitions*) + + +(* ::Input:: *) +(*Do[LowerBoundEstimate[mLLP_,prod]=((NpotGivenExperiment*ProbLLP[mLLP,1,prod]*Interpolation[\[Epsilon]GeomTabs[prod][[All,{1,5}]],InterpolationOrder->1][mLLP])/(2.3ldecayLLP[mLLP,1,ELLP] mLLP/Sqrt[ELLP^2-mLLP^2]))^(-(1/4));*) +(*UpperBoundEstimate[mLLP_,prod]=(Abs[Re[Evaluate[-(ProductLog[-1,-2.3*b/a]/b)/.{a-> NpotGivenExperiment*ProbLLP[mLLP,1,prod]*Interpolation[\[Epsilon]GeomTabs[prod][[All,{1,3}]],InterpolationOrder->1][mLLP],b->zminExp/ldecayLLP[mLLP,1,ELLPmax[0.5,\[Theta]minExp,prod]]}]]])^(1/2),{prod,ProductionList}]*) +(*ProdTest="Pi0";*) +(*LogLogPlot[Evaluate[{0.3LowerBoundEstimate[mLLP,ProdTest],1.8UpperBoundEstimate[mLLP,ProdTest]}],{mLLP,Max[mLLPmin[ProdTest],mmin\[Epsilon]],Min[mLLPmax[ProdTest],mmax\[Epsilon]]},Frame->True,ImageSize->Large]*) + + +(* ::Subsection::Closed:: *) +(*Number of events - fast*) + + +(* ::Input:: *) +(*FactorLowerBound=If[MemberQ[{"ANUBIS-shaft-volume-1","ANUBIS-shaft-volume-2","ANUBIS-shaft-volume-3"},SelectedExperiment]==True,0.1,0.3];*) +(*NeventsDiscret[m_,ProdChannel_,couplinglist_]:=Module[{NevDiscret,NpotTimes\[Chi]val,zshift},*) +(*If[Max[mLLPmin[ProdChannel],mmin\[Epsilon]]"AdaptiveMonteCarlo"]*) +(*NeventsInt[mLLP_,coupling_,ProdChannel_]:=If[mLLPmin[ProdChannel]<=mLLP<=mLLPmax[ProdChannel]&&BrVis[mLLP]!=0,If[0.1LowerBoundEstimate[mLLP,ProdChannel]"AdaptiveMonteCarlo"]*) +(*NeventsDiffInt[mLLP_,coupling_,ProdChannel_,ELLP_]:=If[mLLPmin[ProdChannel]<=mLLP<=mLLPmax[ProdChannel]&&BrVis[mLLP]!=0&&mLLP2,"\!\(\*SubscriptBox[\(\[Theta]\), \(X\)]\)"->1,"\!\(\*SubscriptBox[\(z\), \(X\)]\)"->3}]*) +(*\[CapitalDelta]xvals["\!\(\*SubscriptBox[\(E\), \(X\)]\)"]:=\[CapitalDelta]Evals;*) +(*\[CapitalDelta]xvals["\!\(\*SubscriptBox[\(z\), \(X\)]\)"]=\[CapitalDelta]zvals;*) +(*Do[\[CapitalDelta]xvals["\!\(\*SubscriptBox[\(\[Theta]\), \(X\)]\)",prod]=\[CapitalDelta]\[Theta]vals[prod],{prod,ProductionList}];*) +(*LegendX:=Association[{"\!\(\*SubscriptBox[\(E\), \(X\)]\)"->"\!\(\*SubscriptBox[\(E\), \(X\)]\) [GeV]","\!\(\*SubscriptBox[\(\[Theta]\), \(X\)]\)"->"\!\(\*SubscriptBox[\(\[Theta]\), \(X\)]\) [rad]","\!\(\*SubscriptBox[\(z\), \(X\)]\)"-> "\!\(\*SubscriptBox[\(z\), \(X\)]\) [m]"}]*) +(*LegendY:=Association[{"\!\(\*SubscriptBox[\(E\), \(X\)]\)"->"\!\(\*SubscriptBox[\(dN\), \(ev\)]\)/\!\(\*SubscriptBox[\(dE\), \(X\)]\) [\!\(\*SuperscriptBox[\(GeV\), \(-1\)]\)]","\!\(\*SubscriptBox[\(\[Theta]\), \(X\)]\)"->"\!\(\*SubscriptBox[\(dN\), \(ev\)]\)/\!\(\*SubscriptBox[\(d\[Theta]\), \(X\)]\) [\!\(\*SuperscriptBox[\(rad\), \(-1\)]\)]","\!\(\*SubscriptBox[\(z\), \(X\)]\)"-> "\!\(\*SubscriptBox[\(dN\), \(ev\)]\)/\!\(\*SubscriptBox[\(dz\), \(X\)]\) [\!\(\*SuperscriptBox[\(m\), \(-1\)]\)]"}]*) +(*(*Differential number of events*)*) +(*NeventsDifferentialDiscretProd[m_,ProdChannel_,coupling_,Variable_]:=Module[{NpotTimes\[Chi]val},*) +(*ival=iVal[Variable];*) +(*NpotTimes\[Chi]val=NpotGivenExperiment*ProbLLP[m,coupling,ProdChannel];*) +(*tablegrid0=TableIntegrandDiscret[m,ProdChannel,"True"];*) +(*OutGridEfinalTemp=OutGridEnergy[N[m],ProdChannel];*) +(*\[CapitalDelta]Evals=(Rest[10^OutGridEfinalTemp]-Most[10^OutGridEfinalTemp]);*) +(*\[CapitalDelta]xval=\[CapitalDelta]xvals[Variable];*) +(*c\[Tau]Val=c\[Tau]LLP[m,coupling];*) +(*brvis=BrVis[m];*) +(*ilist=DeleteDuplicates[{ival,1,2,3}];*) +(*tablegrid1=SortBy[{#[[ilist[[1]]]],#[[ilist[[2]]]],#[[ilist[[3]]]],#[[4]]}&/@tableGridPrefac[tablegrid0,m,c\[Tau]Val,0.],{#[[1]],#[[2]],#[[3]]}&];*) +(*GridQuantity=tablegrid1[[All,1]]//DeleteDuplicates;*) +(*LengthPerVariable=Length[tablegrid1]/Length[GridQuantity];*) +(*tab1=NdiffCompiled[tablegrid1,GridQuantity,LengthPerVariable,NpotTimes\[Chi]val*brvis];*) +(*Join[tab1[[All,{1}]],Partition[tab1[[All,2]]*\[CapitalDelta]xval^-1,1],2]*) +(*]*) +(*NeventsDifferentialDiscret[m_,coupling_,Variable_]:=Module[{NdiffInt,LegendList,QuantityMinMax,ValueMinMax},*) +(*prodlisttemp={};*) +(*Do[If[Max[mLLPmin[prod],mmin\[Epsilon]]10^-40&][[All,1]]//MinMax;*) +(*NdiffInt[X_,prod]=If[XvalminmaxNdiff[[1]]1][Log10[X]]],0]],{prod,ProductionList}];*) +(*NdiffInt[X_,"Total"]=Sum[NdiffInt[X,prod],{prod,prodlisttemp}];*) +(*LegendList=Join[{"Total"},prodlisttemp];*) +(*QuantityMinMax=Flatten[Table[MinMax[NdiffData[prod][[All,1]]],{prod,prodlisttemp}],1]//MinMax;*) +(*ValueMinMax=Max[Max[NdiffData[#][[All,2]]]&/@prodlisttemp];*) +(*{Table[NdiffInt[X,prod],{prod,LegendList}],LegendList,QuantityMinMax,ValueMinMax}*) +(*]*) +(*mvaltest=If[FacilityGivenExperiment=="ESS",0.04,0.2];*) +(*couplingvaltest=1.4LowerBoundEstimate[mvaltest,"Pi0"];*) +(*quantity="\!\(\*SubscriptBox[\(E\), \(X\)]\)";*) +(*{NdiffTab[X_],LegendList,QuantityMinMax,ValueMinMax}=NeventsDifferentialDiscret[mvaltest,couplingvaltest,quantity];*) +(*Do[*) +(*prch=LegendList[[i]];*) +(*NdiffInt[X_,prch]=NdiffTab[X][[i]];*) +(*,{i,1,Length[LegendList]}];*) +(*plotdiff=LogLogPlot[Evaluate[Table[NdiffInt[X,prod],{prod,LegendList}]],{X,QuantityMinMax[[1]],QuantityMinMax[[2]]},Frame->True,ImageSize->Large,PlotRange->{All,{10^-5,2ValueMinMax}},PlotStyle->{{Thick,Black},{Thick,Blue},{Thick,Darker@Red},{Thick,Darker@Darker@Green},{Thick,Darker@Cyan},{Thick,Magenta},{Thick,Blue,Dashing[0.02]},{Thick,Darker@Red,Dashing[0.02]},{Thick,Darker@Darker@Green,Dashing[0.02]}},PlotLegends->Placed[Style[#,20]&/@LegendList,Right],FrameLabel->{LegendX[quantity] ,LegendY[quantity]},FrameStyle->Directive[Black, 18],PlotLabel->Style[Row[{SelectedExperiment,". \!\(\*SubscriptBox[\(m\), \(a\)]\) = ",mvaltest," GeV, \!\(\*SubscriptBox[SuperscriptBox[\(f\), \(-1\)], \(G\)]\) = ",couplingvaltest//N}],14,Black]]*) + + +(* ::Title::Closed:: *) +(*Exporting tabulated number of events*) + + +(* ::Chapter::Closed:: *) +(*Definitions*) + + +(* ::Input:: *) +(*directory["Nevents"]=FileNameJoin[{NotebookDirectory[],"Tabulated Nevents"}];*) +(*directory["Nevents-LLP"]=FileNameJoin[{NotebookDirectory[],"Tabulated Nevents",LLPdirName}];*) +(*directory["Nevents-LLP-experiment"]=FileNameJoin[{NotebookDirectory[],"Tabulated Nevents",LLPdirName,SelectedExperiment}];*) +(*If[!DirectoryQ[directory[#]],CreateDirectory[directory[#]]]&/@{"Nevents","Nevents-LLP","Nevents-LLP-experiment"};*) +(*Print["Filenames with tabulated \!\(\*SubscriptBox[\(N\), \(events\)]\):"]*) +(*Do[FilenameNevents[prod]=ToString@StringForm["Nevents_``_``_at_``_Npot=``.dat",Sequence@@{LLPdirName,prod,SelectedExperiment,NpotGivenExperiment//CForm//ToString}],{prod,ProductionList}]*) +(*FilenameNevents[#]&/@ProductionList*) +(*Do[mRangeExport[prod]=Select[{0.01,0.015,0.02,0.025,0.03,0.035,0.04,0.045,0.05,0.06,0.07,0.08,0.09,0.1,0.11,0.12,0.13,0.14,0.143,0.148,0.151,0.18,0.2,0.21,0.215,0.218,0.22,0.225,0.23,0.24,0.25,0.27,0.301,0.33,0.35,0.38,0.4,0.425,0.45,0.47,0.5,0.51,0.52,0.53,0.535,0.54,0.543,0.544,0.545,0.546,0.55,0.56,0.57,0.58,0.59,0.6,0.61,0.62,0.63,0.64,0.65,0.67,0.7,0.725,0.75,0.77,0.8,0.825,0.85,0.87,0.88,0.89,0.9,0.91,0.92,0.93,0.94,0.95,0.953,0.954,0.955,0.956,0.96,0.961,0.962,0.963,0.966,0.97,0.973,0.975,0.98,1.,1.01,1.02,1.03,1.05,1.07,1.1,1.12,1.15,1.2,1.25,1.3,1.4,1.5,1.6,1.7,1.8,1.9,2.,2.1,2.2,2.3,2.4,2.5,2.6,2.7,2.9,3.2,3.3,3.4,3.5,3.6,3.7,3.8,3.9,4.,4.1,4.2,4.3,4.4,4.5,4.6,4.7,4.76}//N,#>=mmin\[Epsilon]&];*) +(*,{prod,ProductionList}]*) +(*couplingsRangeExport=Table[10^x,{x,-11.,-1,0.017}]//N;*) + + +(* ::Chapter::Closed:: *) +(*Exporting*) + + +(* ::Input:: *) +(*BlockExport[ProdChannel_]:=Module[{mlist},*) +(*mlist=mRangeExport[ProdChannel];*) +(*TabFrom=ParallelTable[Quiet[NeventsDiscret[mlist[[k]],ProdChannel,couplingsRangeExport]],{k,1,Length[mlist],1}];*) +(*Export[FileNameJoin[{directory["Nevents-LLP-experiment"],FilenameNevents[ProdChannel]}],Flatten[TabFrom,1],"Table"]*) +(*]*) +(*Monitor[*) +(*Do[*) +(*Module[{prod},*) +(*prod=ProductionList[[j]];*) +(*BlockExport[prod]*) +(*],{j,1,Length[ProductionList],1}],*) +(*Row[{ProgressIndicator[j,{1,Length[ProductionList]}]," Production mode = ",ProductionList[[j]]," (", j,"/",Length[ProductionList],")"}]]//AbsoluteTiming*) +(*If[icounter>Length[SelectedExperimentList],BlockEvaluation["Sensitivity"]]*) + + +(* ::Title::Closed:: *) +(*Computing sensitivities*) + + +(* ::Chapter::Closed:: *) +(*Basic definitions*) + + +(* ::Input:: *) +(*LLPdirName="ALP-gluon";*) +(*directory["Sensitivity"]=FileNameJoin[{NotebookDirectory[],"Sensitivity domains"}];*) +(*directory["Sensitivity-LLP"]=FileNameJoin[{directory["Sensitivity"],LLPdirName}];*) +(*If[!DirectoryQ[directory[#]],CreateDirectory[directory[#]]]&/@{"Sensitivity","Sensitivity-LLP"};*) +(*directory["Nevents-LLP"]=FileNameJoin[{NotebookDirectory[],"Tabulated Nevents",LLPdirName}];*) +(*dropdownDialog[list_,phrase_]:=DialogInput[{choice=""},Column[{TextCell[phrase],PopupMenu[Dynamic[choice],list],Button["OK",DialogReturn[choice]]}]]*) +(*infoDialog[phrase_]:=DialogInput[{choice=""},Column[{TextCell[phrase],Button["Proceed",DialogReturn[choice]]}]]*) +(*selectionDialog[list_,phrase_]:=DialogInput[{choice={}},Column[{Row[{phrase}],Pane[TogglerBar[Dynamic[choice],list,Appearance->"Vertical"->{Automatic,5}],ImageSize->{Automatic,Automatic},Scrollbars->{False,True}],Button["OK",DialogReturn[choice]]}]]*) +(*ExperimentDirectoriesListNevents=Select[FileNames["*",directory["Nevents-LLP"],1],DirectoryQ];*) +(*Print["List of available experiments with tabulated \!\(\*SubscriptBox[\(N\), \(events\)]\) for" <>LLPdirName<>":"]*) +(*ExperimentsListNevents=Table[FileNameTake[ExperimentDirectoriesListNevents[[i]],-1],{i,1,Length[ExperimentDirectoriesListNevents],1}]//Sort;*) +(*ExperimentsListNevents//TableForm*) +(*If[Length[ExperimentsListNevents]==0,Print["No experiment is available, generate first the acceptance for the given experiment using module 1"],*) +(*SelectedExperimentList=If[Length[ExperimentsListNevents]!=0,selectionDialog[ExperimentsListNevents,"Select the experiments for which the sensitivity will be computed:"]];*) +(*icounter=1;*) +(*BlockEvaluation[tag_]:=Block[{},*) +(*nb=EvaluationNotebook[];*) +(*NotebookFind[nb,tag,All,CellTags];*) +(*SelectionEvaluate[nb]*) +(*];*) +(*Do[*) +(*BlockEvaluation["Sensitivity-computation"];*) +(*,{icounter,1,Length[SelectedExperimentList],1}]*) +(*]*) +(**) + + +(* ::Chapter::Closed:: *) +(*Specifying the experiment and interpolating the tabulated number of events*) + + +(* ::Section::Closed:: *) +(*Specifying the experiment*) + + +(* ::Input:: *) +(*Print["Selected experiment:"]*) +(*GivenExperimentForSensitivityComputation=SelectedExperimentList[[icounter++]];*) +(*CondANUBIS=MemberQ[{"ANUBIS-shaft-volume-1","ANUBIS-shaft-volume-2","ANUBIS-shaft-volume-3"},GivenExperimentForSensitivityComputation];*) +(*If[CondANUBIS==True,infoDialog[Row[{"One of the modules of ANUBIS-shaft is chosen. The full sensitivity includes three modules. The importing will be over all modules, so for all ot the the sensitivity has to be computed"}]]]*) +(*If[CondANUBIS==False,GivenExperimentForSensitivityComputationList={GivenExperimentForSensitivityComputation},GivenExperimentForSensitivityComputationList={"ANUBIS-shaft-volume-1","ANUBIS-shaft-volume-2","ANUBIS-shaft-volume-3"}];*) +(*PathsNeventsSelected={};*) +(*Do[PathsNeventsSelected=Join[PathsNeventsSelected,FileNames["*.dat",FileNameJoin[{directory["Nevents-LLP"],exp}]]],{exp,GivenExperimentForSensitivityComputationList}];*) +(*(*Creating the directory for exporting sensitivity curves*)*) +(*ExperimentFolder=If[CondANUBIS==True,"ANUBIS",GivenExperimentForSensitivityComputation];*) +(*directory["Sensitivity-LLP-exp"]=FileNameJoin[{directory["Sensitivity-LLP"],ExperimentFolder}];*) +(*If[!DirectoryQ[directory["Sensitivity-LLP-exp"]],CreateDirectory[directory["Sensitivity-LLP-exp"]]]*) + + +(* ::Section::Closed:: *) +(*Importing and interpolations*) + + +(* ::Input:: *) +(*Print["List of production channels:"]*) +(*FilenamesNevents=Table[Last@FileNameSplit@PathsNeventsSelected[[i]],{i,1,Length[PathsNeventsSelected],1}];*) +(*FilenameParameters[i_]:=StringCases[FilenamesNevents[[i]],"Nevents_"<>LLPdirName<>"_"~~mother__~~"_at_"~~experiment__~~"_Npot="~~Npot__~~".dat":>{mother,experiment,Npot}][[1]]*) +(*(*______________________________________________________*)*) +(*(*Importing and interpolation*)*) +(*(*______________________________________________________*)*) +(*ProductionInfoList=Table[FilenameParameters[i],{i,1,Length[FilenamesNevents],1}];*) +(*Join[{{"Mother","Experiment","\!\(\*SubscriptBox[\(N\), \(PoT\)]\)"}},ProductionInfoList]//TableForm*) +(*ProductionChannelsList=ProductionInfoList[[All,1]];*) +(*NpotDefault=Interpreter["Number"][ProductionInfoList[[1]][[3]]];*) +(*NeventsTabulated//Clear;*) +(*\[Epsilon]reco[mLLP_]=If[StringContainsQ[GivenExperimentForSensitivityComputation,"CHARM-photon"]==True,0.51,If[StringContainsQ[GivenExperimentForSensitivityComputation,"LHCb-downstream"]==True,0.4,1]];*) +(*Do[*) +(*Module[{prod},*) +(*prod=ProductionChannelsList[[i]];*) +(*(*The condition if one sums the number of events for the same production mode over several experiments*)*) +(*IfprodExists=MemberQ[Keys[DownValues@NeventsTabulated][[All,1,1]],prod];*) +(*NeventsTabulated[prod]=If[!IfprodExists,Import[PathsNeventsSelected[[i]],"Table"],Join[NeventsTabulated[prod][[All,{1,2}]],NeventsTabulated[prod][[All,{3}]]+Import[PathsNeventsSelected[[i]],"Table"][[All,{3}]]]];*) +(*{mminmax[prod],couplingminmax[prod]}=(NeventsTabulated[prod][[All,#]]//MinMax)&/@{1,2};*) +(*NevMax[prod]=NeventsTabulated[prod][[All,3]]//Max;*) +(*NevInt[mLLP_,finv_,prod]=\[Epsilon]reco[mLLP]*If[mminmax[prod][[1]]<= mLLP<=mminmax[prod][[2]]&&couplingminmax[prod][[1]]<=finv<=couplingminmax[prod][[2]],Evaluate[10^(Interpolation[{Log10[#[[1]]],Log10[#[[2]]],Log10[#[[3]]+10^-90]}&/@NeventsTabulated[prod],InterpolationOrder->1][Log10[mLLP],Log10[finv]])],0];*) +(*]*) +(*,{i,1,Length[ProductionInfoList],1}]*) +(*{mminmaxOverall,couplingminmaxOverall}=MinMax[Table[#[prod],{prod,ProductionChannelsList}]//Flatten]&/@{mminmax,couplingminmax};*) +(*NevMaxOverall=Max[Table[NevMax[prod],{prod,ProductionChannelsList}]];*) +(*NevIntOverall[mLLP_,finv_]=Sum[NevInt[mLLP,finv,prod],{prod,ProductionChannelsList}];*) +(*plotNev[mLLP_]:=LogLogPlot[Evaluate[Table[NevInt[mLLP,finv,prod],{prod,ProductionChannelsList}]],{finv,couplingminmaxOverall[[1]],couplingminmaxOverall[[2]]},PlotLegends->Placed[Style[#,15]&/@ProductionChannelsList,Right],PlotRange->{couplingminmaxOverall,{10^-3,NevMaxOverall}},Frame->True,ImageSize->Large,FrameLabel->{"\!\(\*SubscriptBox[SuperscriptBox[\(f\), \(-1\)], \(G\)]\) [\!\(\*SuperscriptBox[\(GeV\), \(-1\)]\)]" , "\!\(\*SubscriptBox[\(N\), \(events\)]\)[\!\(\*SubscriptBox[\(m\), \(a\)]\),\!\(\*SubscriptBox[\(f\), \(G\)]\)]"},FrameStyle->Directive[Black, 23],PlotStyle->{{Thick,Blue},{Thick,Darker@Red},{Thick,Darker@Darker@Green},{Thick,Black},{Thick,Blue,Dashing[0.02]},{Thick,Darker@Red,Dashing[0.02]},{Thick,Darker@Darker@Green,Dashing[0.02]},{Thick,Black,Dashing[0.02]}},PlotLabel->Style[Row[{GivenExperimentForSensitivityComputation,". \!\(\*SubscriptBox[\(m\), \(a\)]\) = ",mLLP, " GeV"}],20,Black]]*) +(*plotNev[0.6]*) + + +(* ::Chapter::Closed:: *) +(*Sensitivity computation*) + + +(* ::Section::Closed:: *) +(*Subscript[N, events] density plot*) + + +(* ::Input:: *) +(*plot=DensityPlot[Evaluate[Log10[NevIntOverall[mLLP,y]]],{mLLP,mminmaxOverall[[1]],mminmaxOverall[[2]]},{y,couplingminmaxOverall[[1]],couplingminmaxOverall[[2]]},ScalingFunctions->{"Log","Log"},AspectRatio->0.78,PlotRange->{All,All,{Log10[2.3],Log10[NevMaxOverall]}},ImageSize->Large,FrameLabel->{"\!\(\*SubscriptBox[\(m\), \(a\)]\) [GeV]","\!\(\*SubscriptBox[SuperscriptBox[\(f\), \(-1\)], \(G\)]\) [\!\(\*SuperscriptBox[\(GeV\), \(-1\)]\)]"}, Frame-> True, FrameStyle->Directive[Black, 25],PlotPoints->100,PlotLegends->Placed[BarLegend[{Automatic,{Log10[2.3],Log10[NevMaxOverall]}},LegendMarkerSize->340,LegendLabel->Placed["\!\(\*SubscriptBox[\(Log\), \(10\)]\)[\!\(\*SubscriptBox[\(N\), \(ev\)]\)]",Bottom],LabelStyle->{FontSize->22},Method->{FrameStyle->Black,AxesStyle->None,TicksStyle->Black}],Right],PlotLabel->Style[Row[{ExperimentFolder}],20,Black](*,FrameTicks->{{Automatic,Automatic},{TicksPlotx,None}}*)]*) +(*(*Export[FileNameJoin[{NotebookDirectory[],"plots/SensCalc/NeventsDensityPlotExample.pdf"}],plot,"AllowRasterization"->False]*)*) + + +(* ::Section::Closed:: *) +(*Constraints importing*) + + +(* ::Input:: *) +(*importformat["txt"]=importformat["dat"]="Table";*) +(*importformat["m"]=importformat["mx"]="MX";*) +(*importformat["xls"]="XLS";*) +(*dir=FileNameJoin[{NotebookDirectory[],"contours",LLPdirName}];*) +(*If[DirectoryQ[dir],*) +(*filenames=FileNames[LLPdirName<>"-excluded*",dir,Infinity];*) +(*ExcludedRegions[LLPdirName]=Import[#,importformat[FileExtension[#]]]&/@FileNames[LLPdirName<>"-excluded*",dir,Infinity];*) +(*];*) +(*If[!DirectoryQ[dir],*) +(*ExcludedRegions[LLPdirName]={{{10.,10.}}};*) +(*]*) + + +(* ::Section::Closed:: *) +(*Sensitivity*) + + +(* ::Input:: *) +(*SensitivityBlock[Nev_,Npot_,SelectedProduction_]:=Block[{},*) +(*NevTot[mLLP_,finv_]=Sum[NevInt[mLLP,finv,prod],{prod,SelectedProduction}];*) +(*RegSens1=RegionPlot[Npot/NpotDefault NevTot[10^mLLP,10^ga]*Boole[!(0.125<10^mLLP<0.14||0.538<10^mLLP<0.555||0.94<10^mLLP<0.974)]>=Nev,{mLLP,Log10[mminmaxOverall[[1]]],Log10[0.125]},{ga,Log10[couplingminmaxOverall[[1]]],Log10[couplingminmaxOverall[[2]]]},PlotPoints->200];*) +(*RegSens2=RegionPlot[Npot/NpotDefault NevTot[10^mLLP,10^ga]*Boole[!(0.125<10^mLLP<0.14||0.538<10^mLLP<0.555||0.94<10^mLLP<0.974)]>=Nev,{mLLP,Log10[0.14],Log10[0.538]},{ga,Log10[couplingminmaxOverall[[1]]],Log10[couplingminmaxOverall[[2]]]},PlotPoints->200];*) +(*RegSens3=RegionPlot[Npot/NpotDefault NevTot[10^mLLP,10^ga]*Boole[!(0.125<10^mLLP<0.14||0.538<10^mLLP<0.555||0.94<10^mLLP<0.974)]>=Nev,{mLLP,Log10[0.538],Log10[0.94]},{ga,Log10[couplingminmaxOverall[[1]]],Log10[couplingminmaxOverall[[2]]]},PlotPoints->200];*) +(*RegSens4=RegionPlot[Npot/NpotDefault NevTot[10^mLLP,10^ga]*Boole[!(0.125<10^mLLP<0.14||0.538<10^mLLP<0.555||0.94<10^mLLP<0.974)]>=Nev,{mLLP,Log10[0.974],Log10[mminmaxOverall[[2]]]},{ga,Log10[couplingminmaxOverall[[1]]],Log10[couplingminmaxOverall[[2]]]},PlotPoints->200];*) +(*(*Sens={10^#[[1]],10^#[[2]]}&/@Partition[Flatten[Cases[Normal@RegSens,Line[x_]\[RuleDelayed]x,Infinity]],2];*)*) +(*SensTemp=Cases[Normal@#,Line[x_]:>x,Infinity]&/@{RegSens1,RegSens2,RegSens3,RegSens4};*) +(*SensTemp1=Join[SensTemp[[1]],SensTemp[[2]],SensTemp[[3]],SensTemp[[4]]];*) +(*Sens=Table[{10^#[[1]],10^#[[2]]}&/@SensTemp1[[i]],{i,1,Length[SensTemp1],1}];*) +(*Export[FileNameJoin[{directory["Sensitivity-LLP-exp"],ToString@StringForm["Sensitivity_``_at_``_Nev=``_Npot=``.xls",Sequence@@{LLPdirName,ExperimentFolder,Nev//ToString,Npot//CForm//ToString}]}],Sens];*) +(*Sens*) +(*]*) +(*productionlist=Join[{"All"},ProductionChannelsList];*) +(*DynamicModule[{input1=NpotDefault,input2=2.3,choice={"All"},list,phrase},*) +(*DialogInput[Column[{Style[ExperimentFolder,Bold],TextCell["Enter the number of proton collisions:"],InputField[Dynamic[input1],Expression],TextCell["Enter the value of N_ev,min for which the sensitivity will be computed:"],InputField[Dynamic[input2],Expression],Row[{"Select the production channels to be used for the sensitivity calculation:"}],Pane[TogglerBar[Dynamic[choice],productionlist,Appearance->"Vertical"->{Automatic,1}],ImageSize->{Automatic,Automatic},Scrollbars->{False,True}],Button["Submit",DialogReturn[{NpotVal,NevMinVal,SelectedProduction}={input1,input2,choice}//N],ImageSize->Automatic]}]]];*) +(*If[MemberQ[SelectedProduction,"All"],SelectedProduction=ProductionChannelsList;]*) +(*{{"\!\(\*SubscriptBox[\(N\), \(PoT\)]\) for computation","\!\(\*SubscriptBox[\(N\), \(ev, min\)]\)","Selected production modes"},{NpotVal,NevMinVal,SelectedProduction}}//TableForm*) +(*sens=SensitivityBlock[NevMinVal,NpotVal,SelectedProduction];*) +(*Show[ListLogLogPlot[Cases[ExcludedRegions[LLPdirName][[1]],_?MatrixQ,All],Joined->{True,True,True,True},Frame-> True,FrameLabel->{"\!\(\*SubscriptBox[\(m\), \(a\)]\) [GeV]" , "\!\(\*SuperscriptBox[SubscriptBox[\(f\), \(G\)], \(-1\)]\) [\!\(\*SuperscriptBox[\(GeV\), \(-1\)]\)]"},FrameStyle->Directive[Black, 23],PlotStyle->{{Thick,Gray}},Filling->{1->{True,Directive[Gray,Opacity[0.3]]},2->{True,Directive[Gray,Opacity[0.3]]},3->{True,Directive[Gray,Opacity[0.3]]},4->{True,Directive[Gray,Opacity[0.3]]}},ImageSize->Large,PlotRange->{{1.01mminmaxOverall[[1]],1.1mminmaxOverall[[2]]},{couplingminmaxOverall[[1]],Max[0.2,0.99couplingminmaxOverall[[2]]]}},PlotLabel->Style[Row[{"\!\(\*SubscriptBox[\(N\), \(events\)]\) \[GreaterEqual] ",NevMinVal}],18,Black]],*) +(*ListLogLogPlot[Cases[sens,_?MatrixQ,All],Joined->{True,True,True,True},PlotStyle->Flatten[{ConstantArray[{Thick,Blue},If[MatrixQ[sens],1,Length@sens]]},1],ImageSize->Large,PlotRange->{{1.01mminmaxOverall[[1]],1.1mminmaxOverall[[2]]},{0.3Min[Flatten[Sens]],0.99couplingminmaxOverall[[2]]}},PlotLabel->Style[Row[{"\!\(\*SubscriptBox[\(N\), \(events\)]\) \[GreaterEqual] ",NevMinVal}],18,Black],PlotLegends->Placed[Style[#,15]&/@{GivenExperimentForSensitivityComputation},{0.2,0.15}]],Graphics[{Text[Style["Excluded",24,Black],Scaled[{0.7,0.95}]]}]]*) + + +(* ::Title::Closed:: *) +(*Deleting generated cells*) + + +(* ::Input:: *) +(*FrontEndTokenExecute["DeleteGeneratedCells"];*) +(*FrontEndTokenExecute["SelectAll"];*) +(*FrontEndTokenExecute["SelectionCloseAllGroups"];*) + + +(* ::Input:: *) +(**) + + +(* ::Input:: *) +(**) diff --git a/wls/3. ALP-photon sensitivity.wls b/wls/3. ALP-photon sensitivity.wls new file mode 100755 index 0000000..4882c6c --- /dev/null +++ b/wls/3. ALP-photon sensitivity.wls @@ -0,0 +1,660 @@ +#!/usr/bin/env wolframscript +(* ::Package:: *) + +(* ::Title::Closed:: *) +(*Just launch the code below to run the notebook (shift+enter)*) + + +(* ::Input:: *) +(*ClearAll["Global`*"]*) +(*ParallelEvaluate[ClearAll["Global`*"]];*) +(*BlockEvaluation[tag_]:=Block[{},*) +(*nb=EvaluationNotebook[];*) +(*NotebookFind[nb,tag,All,CellTags];*) +(*SelectionEvaluate[nb]*) +(*]*) +(*CloseKernels[];*) +(*LaunchKernels[];*) +(*dropdownDialog[list_,phrase_]:=DialogInput[{choice=""},Column[{TextCell[phrase],PopupMenu[Dynamic[choice],list],Button["OK",DialogReturn[choice]]}]]*) +(*infoDialog[phrase_]:=DialogInput[{choice=""},Column[{TextCell[phrase],Button["Proceed",DialogReturn[choice]]}]]*) +(*If[(DirectoryQ[FileNameJoin[{NotebookDirectory[],"Auxiliary data"}]]//ToString)=="False",CreateDirectory[FileNameJoin[{NotebookDirectory[],"Auxiliary data"}]]];*) +(*choiceslist={"Tabulated Nevents+sensitivity","Sensitivity only (tabulated Nevents must be produced before)","Acceptance"};*) +(*taglist["Acceptance"]="Acceptance";*) +(*taglist["Tabulated Nevents+sensitivity"]="Number-of-events+sensitivity";*) +(*taglist["Sensitivity only (tabulated Nevents must be produced before)"]="Sensitivity";*) +(*computationchoice=dropdownDialog[choiceslist,"Do you want to compute the tabulated number of events and then sensitivity, or just sensitivity (if the tabulated number of events has been already produced)?"];*) +(*tagselected=taglist[computationchoice]*) +(*BlockEvaluation[tagselected]*) + + +(* ::Title::Closed:: *) +(*Preliminary definitions (launch first)*) + + +(* ::Chapter::Closed:: *) +(*Critical definitions*) + + +(* ::Input:: *) +(*dropdownDialog[list_,phrase_]:=DialogInput[{choice=""},Column[{TextCell[phrase],PopupMenu[Dynamic[choice],list],Button["OK",DialogReturn[choice]]}]]*) +(*infoDialog[phrase_]:=DialogInput[{choice=""},Column[{TextCell[phrase],Button["Proceed",DialogReturn[choice]]}]]*) +(*selectionDialog[list_,phrase_]:=DialogInput[{choice={}},Column[{Row[{"Select the experiments for which the number of events will be computed:"}],Pane[TogglerBar[Dynamic[choice],list,Appearance->"Vertical"->{Automatic,5}],ImageSize->{Automatic,Automatic},Scrollbars->{False,True}],Button["OK",DialogReturn[choice]]}]]*) + + +(* ::Chapter::Closed:: *) +(*Various directories*) + + +(* ::Input:: *) +(*LLPdirName="ALP-photon";*) +(*(*Set the directory for the search where tabulated acceptances are located*)*) +(*directory["Acceptances"]=FileNameJoin[{NotebookDirectory[],"Acceptances"}];*) +(*(*Set the directory for the search where tabulated angle-energy distributions are located*)*) +(*directory["Distribution"]=FileNameJoin[{NotebookDirectory[],"spectra/New physics particles spectra",LLPdirName}]; *) +(*(*The directory storing production weights of the given LLP*)*) +(*directory["Production weights"]=FileNameJoin[{NotebookDirectory[],"phenomenology",LLPdirName,"Production probabilities"}]; *) +(*(*Directory to which various auxillary datasets will be stored*)*) +(*directory["Auxiliary"]=FileNameJoin[{NotebookDirectory[],"Auxiliary data",LLPdirName}]; *) +(*If[!DirectoryQ[directory["Auxiliary"]],CreateDirectory[directory["Auxiliary"]]];*) +(*(*Directory containing decay widths of the LLPs*)*) +(*directory["Decays"]=FileNameJoin[{NotebookDirectory[],"phenomenology",LLPdirName,"decay widths"}]; *) + + +(* ::Chapter::Closed:: *) +(*LLP phenomenology: production probabilities, decay widths*) + + +(* ::Section::Closed:: *) +(*Scanning for tabulated distributions*) + + +(* ::Input:: *) +(*(*Define the file pattern*)*) +(*pattern="DoubleDistr_*_*_*.m";*) +(*(*Search for files matching the pattern in the directory and its subdirectories*)*) +(*matchingFiles=FileNames[pattern,{directory["Distribution"]},Infinity];*) +(*(*List of LLPs, production modes, and facilities for which the tabulated distributions have been computed at the previous stage of using SensCalc*)*) +(*ExtractedProductionParameters=Function[filename,parts=StringSplit[FileNameTake[filename],"_"];*) +(*{parts[[2]],parts[[3]],StringDrop[parts[[4]],-2]} ];*) +(*(*combinations selected LLP, production channel, facility for which the tabulated distributions are present*)*) +(*DistrCombinations=(ExtractedProductionParameters/@matchingFiles)//Sort*) + + +(* ::Section::Closed:: *) +(*Production probabilities*) + + +(* ::Input:: *) +(*FacilitiesList={"SPS","FermilabBD","LHC","FCC-hh","Serpukhov"};*) +(*Br\[Pi]0ToALP[ma_]=If[ma<0.135,Evaluate[Interpolation[Import[FileNameJoin[{directory["Production weights"],"BrPi0ToALP.txt"}],"Table"],InterpolationOrder->1][ma]],0];*) +(*Br\[Eta]ToALP[ma_]=If[ma<0.547,Evaluate[Interpolation[Import[FileNameJoin[{directory["Production weights"],"BrEtaToALP.txt"}],"Table"],InterpolationOrder->1][ma]],0];*) +(*Do[*) +(*PmotherToLLP[mLLP_,ga_,"Pi0",Facility]=Br\[Pi]0ToALP[mLLP]*ga^2;*) +(*PmotherToLLP[mLLP_,ga_,"Eta",Facility]=Br\[Eta]ToALP[mLLP]*ga^2;*) +(*,{Facility,FacilitiesList}]*) +(*(*_________________*)*) +(*(*Photon fusion*)*) +(*(*_________________*)*) +(*fusionfacilities=Select[DistrCombinations,StringContainsQ[#[[2]],"Photon-fusion"]&][[All,3]]//DeleteDuplicates;*) +(*FusionProd[Facility_]:=Module[{},*) +(*procs=Select[DistrCombinations,StringContainsQ[#[[2]],"Photon-fusion"]&&#[[3]]==Facility&][[All,2]];*) +(*Do[*) +(*datimp=ga^2*Import[FileNameJoin[{directory["Production weights"],"Pprod_"<>LLPdirName<>"_"<>procs[[i]]<>"_"<>Facility<>".m"}],"MX"];*) +(*PmotherToLLP[ma_,ga_,procs[[i]],Facility]=datimp;*) +(*ProbMother[procs[[i]]]=1.;*) +(*,{i,1,Length[procs],1}];*) +(*]*) +(*Do[*) +(*FusionProd[Facility],{Facility,fusionfacilities}]*) +(*(*_________________*)*) +(*(*Primakov*)*) +(*(*_________________*)*) +(*primakovfacilities=Select[DistrCombinations,StringContainsQ[#[[2]],"Primakov"]&][[All,3]]//DeleteDuplicates;*) +(*PrimakovProd[Facility_]:=Module[{},*) +(*procs=Select[DistrCombinations,StringContainsQ[#[[2]],"Primakov"]&&#[[3]]==Facility&][[All,2]];*) +(*Do[*) +(*datimp=ga^2 Evaluate[Import[FileNameJoin[{directory["Production weights"],"Pprod_"<>LLPdirName<>"_"<>procs[[i]]<>"_"<>Facility<>".m"}],"MX"]];*) +(*PmotherToLLP[ma_,ga_,procs[[i]],Facility]=datimp;*) +(*,{i,1,Length[procs],1}];*) +(*]*) +(*Do[*) +(*PrimakovProd[Facility],{Facility,primakovfacilities}]*) +(*WeightsCombinations=Cases[Keys[DownValues@PmotherToLLP][[All,1,#]]&/@{3,4}//Transpose//Sort,_?(MemberQ[DistrCombinations[[All,{2,3}]],#]&)];*) +(*Print["If there are production weights to all available distributions:"]*) +(*IfCondDistrToWeights=DistrCombinations[[All,{2,3}]]==WeightsCombinations*) +(*If[!IfCondDistrToWeights,infoDialog["You have not provided the production probabilities PmotherToLLP to all the generated tabulated distributions! Please do this first to avoid problems"];]*) +(**) + + +(* ::Section::Closed:: *) +(*LLP lifetime*) + + +(* ::Input:: *) +(*<ma^2/2,ScalarProduct[p\[Gamma]1,p\[Gamma]1]->0,ScalarProduct[p\[Gamma]2,p\[Gamma]2]-> 0}//Simplify;*) +(*Print["ALP decay width:"]*) +(*(*chbar*)*) +(*chbar= 6.6*10^-25*3*10^8;*) +(*(*1/2 from indistinguishability of two photons*)*) +(*\[CapitalGamma]LLP[ma_,ga_]=1/(8Pi)*1/2 MALPdecaySquared*1/(2ma)*) +(*c\[Tau]LLP[ma_,ga_]=chbar/\[CapitalGamma]LLP[ma,ga];*) +(*ldecayLLP[ma_,ga_,Ea_]=c\[Tau]LLP[ma,ga]*Sqrt[Ea^2-ma^2]/ma;*) + + +(* ::Chapter::Closed:: *) +(*Loading necessary routines*) + + +(* ::Input:: *) +(*If[Length[inecessary]==0,*) +(*NotebookEvaluate[FileNameJoin[{NotebookDirectory[],"codes/generic.nb"}]];*) +(*NotebookEvaluate[FileNameJoin[{NotebookDirectory[],"codes/for-sensitivities.nb"}]];*) +(*inecessary={1,2,3};*) +(*]*) + + +(* ::Title::Closed:: *) +(*Specifying the experiment*) + + +(* ::Input:: *) +(*SetDirectory[NotebookDirectory[]];*) +(*(*Parent directory*)*) +(*NotebookDirectory[]//ParentDirectory;*) +(*ExperimentDirectoriesList=Select[FileNames["*",directory["Acceptances"],1],DirectoryQ];*) +(*(*List of available experiments (for which the geometry has been implemented)*)*) +(*ExperimentsListTemp=Table[FileNameTake[ExperimentDirectoriesList[[i]],-1],{i,1,Length[ExperimentDirectoriesList],1}];*) +(*ExperimentsListTemp2=Join[Partition[ExperimentsListTemp,1],Table[{TrueQ@FileExistsQ@FileNameJoin[{directory["Acceptances"],ExperimentsListTemp[[i]],ToString@StringForm["Acceptance_``_for_``.m",Sequence@@{ExperimentsListTemp[[i]],LLPdirName}]}]},{i,1,Length[ExperimentsListTemp]}],2];*) +(*ExperimentsList=Select[ExperimentsListTemp2,#[[2]]==True&][[All,1]]//Sort*) +(*If[Length[ExperimentsList]==0,Print["No experiment is available, generate first the acceptance for the given experiment using module 1"]]*) +(*Print["Selected experiments:"]*) +(*SelectedExperimentList=If[Length[ExperimentsList]!=0,selectionDialog[ExperimentsList,"Select the experiments:"]]*) +(*icounter=1;*) + + +(* ::Chapter::Closed:: *) +(*Running block for next sections*) + + +(* ::Input:: *) +(*BlockEvaluation[tag_]:=Block[{},*) +(*nb=EvaluationNotebook[];*) +(*NotebookFind[nb,tag,All,CellTags];*) +(*SelectionEvaluate[nb]*) +(*]*) +(*If[tagselected=="Number-of-events+sensitivity",*) +(*Do[*) +(*BlockEvaluation["Number-of-events-computation+sensitivity"];*) +(*,{icounter,1,Length[SelectedExperimentList],1}],*) +(*If[tagselected=="Acceptance",*) +(*Do[*) +(*BlockEvaluation["Acceptance-computation"];*) +(*,{icounter,1,Length[SelectedExperimentList],1}]*) +(*]*) +(*]*) + + +(* ::Title::Closed:: *) +(*Number of events*) + + +(* ::Chapter::Closed:: *) +(*Particular experiment*) + + +(* ::Input:: *) +(*SelectedExperiment=SelectedExperimentList[[icounter++]];*) + + +(* ::Chapter::Closed:: *) +(*Cross-sections, acceptances*) + + +(* ::Input:: *) +(*dataAcceptances=Import[FileNameJoin[{FileNameJoin[{directory["Acceptances"],SelectedExperiment,ToString@StringForm["Acceptance_``_for_``.m",Sequence@@{SelectedExperiment,LLPdirName}]}]}],"MX"];//AbsoluteTiming*) +(*{FacilityGivenExperiment,FullAcceptanceData0,BrVis[mLLP_]}=dataAcceptances[[#]]&/@{1,3,5};*) +(*LogLogPlot[Evaluate[BrVis[mLLP]],{mLLP,0.02,10},Frame->True,ImageSize->Large,FrameStyle->Directive[Black, 22],PlotStyle->{{Thickness[0.003],Blue},{Thickness[0.003],Darker@Red},{Thickness[0.003],Darker@Darker@Green},{Thickness[0.003],Black}},GridLines->Automatic,PlotRange->{{0.1,10},{0.01,1.2}},Frame->True,ImageSize->Large,FrameLabel->{"m [GeV]","\!\(\*SubscriptBox[\(Br\), \(vis\)]\)"},PlotLabel-> Style[Row[{"For ",SelectedExperiment}], 20, Black]]*) +(*(*___________________________*)*) +(*(*Interpolation of the tabulated azimuthal acceptance, extracting Subscript[\[Theta], min/max], etc.*)*) +(*(*___________________________*)*) +(*{AzimuthalAcceptanceInt[\[Theta]LLP_,zLLP_],\[Theta]minExpAll,\[Theta]maxExpAll,\[Theta]minExp,\[Theta]maxExp,zminExp,zmaxExp,zmin\[Theta][\[Theta]LLP_],zmax\[Theta][\[Theta]LLP_]}=Block\[Epsilon]Azimuthal[FullAcceptanceData0];*) +(*(*Logarithmized data with full acceptance, and also decay acceptance and full acceptance interpolations*)*) +(*{FullAcceptanceData,DecayAcceptanceInt[mLLP_,\[Theta]LLP_,ELLP_,zLLP_],FullAcceptanceInt[mLLP_,\[Theta]LLP_,ELLP_,zLLP_],InGridm\[Epsilon],InGrid\[Theta]\[Epsilon],InGridE\[Epsilon],InGridz\[Epsilon],\[Epsilon]vals,\[Epsilon]azvals,mmin\[Epsilon],mmax\[Epsilon]}=Block\[Epsilon]Decay[FullAcceptanceData0,zminExp,BrVis];*) +(*CrossSectionData=dataAcceptances[[4]]//Transpose;*) +(*NpotGivenExperiment=Select[CrossSectionData,#[[1]]=="Npot"&][[1]][[2]]//N;*) +(*ProbMother["Pi0"]=Select[CrossSectionData,#[[1]]=="PPi0"&][[1]][[2]];*) +(*ProbMother["Eta"]=Select[CrossSectionData,#[[1]]=="PEta"&][[1]][[2]];*) +(*AtargetVal=Select[CrossSectionData,#[[1]]=="Atarget"&][[1]][[2]];*) +(*{{"\!\(\*SubscriptBox[\(\[Chi]\), \(b\\\ or\\\ \*OverscriptBox[\(b\), \(_\)]\)]\)","\!\(\*SubscriptBox[\(\[Chi]\), SuperscriptBox[\(\[Pi]\), \(0\)]]\)","\!\(\*SubscriptBox[\(\[Chi]\), \(\[Eta]\)]\)"},{ProbMother["B"],ProbMother["Pi0"],ProbMother["Eta"]}}//TableForm*) +(*(*infoDialog[Row[{"The number of proton collisions is ", NpotGivenExperiment,". You may change it at the stage of computing the sensitivities"}]]*)*) +(*Row[{"Search for "<>LLPdirName<>" at ", SelectedExperiment, " located at ",FacilityGivenExperiment,". \!\(\*SubscriptBox[\(N\), \(collisions\)]\) = ",NpotGivenExperiment}]*) +(*{{"Quantity","\!\(\*SubscriptBox[\(\[Theta]\), \(min\)]\), rad","\!\(\*SubscriptBox[\(\[Theta]\), \(max\)]\), rad","\!\(\*SubscriptBox[\(\[Theta]\), \(min\)]\)(\!\(\*SubscriptBox[\(\[Epsilon]\), \(dec\)]\)), rad","\!\(\*SubscriptBox[\(\[Theta]\), \(max\)]\)(\!\(\*SubscriptBox[\(\[Epsilon]\), \(dec\)]\)), rad","\!\(\*SubscriptBox[\(z\), \(min\)]\), m","\!\(\*SubscriptBox[\(z\), \(max\)]\), m"},{"Description","Min angle covered by experiment","Max angle covered by experiment","Min angle where \!\(\*SubscriptBox[\(\[Epsilon]\), \(decay\)]\)\[NotEqual]0","Max angle where \!\(\*SubscriptBox[\(\[Epsilon]\), \(decay\)]\)\[NotEqual]0","Min long. displacement of the decay volume","Max long. displacement of the decay volume"},{"Value",\[Theta]minExpAll,\[Theta]maxExpAll,\[Theta]minExp,\[Theta]maxExp,zminExp,zmaxExp}}//TableForm*) + + +(* ::Chapter::Closed:: *) +(*Angle-energy distributions for the given experiment*) + + +(* ::Input:: *) +(*Print["Production list:"]*) +(*ProductionPatternSelectedTemp=Select[DistrCombinations,#[[3]]==FacilityGivenExperiment&]*) +(*TargetsA={{"Mo",96.},{"C",12.},{"Fe",56.},{"p",1.}};*) +(*TargetPrimakov=Select[TargetsA,#[[2]]==If[StringContainsQ[SelectedExperiment,"FASER"],56,AtargetVal]&][[1]][[1]]*) +(*Target=Select[TargetsA,#[[2]]==AtargetVal&][[1]][[1]]*) +(*ProductionPatternSelected=Select[ProductionPatternSelectedTemp,!StringContainsQ[#[[2]],{"Primakov","Photon-fusion"}]||StringContainsQ[#[[2]],{"Primakov-"<>TargetPrimakov,"Photon-fusion-"<>Target}]&]*) +(*If[FacilityGivenExperiment=="LHC"&&!StringContainsQ[SelectedExperiment,"FASER"],ProductionPatternSelected=Select[ProductionPatternSelected,!StringContainsQ[#[[2]],"Primakov"]&]]*) +(*ProductionList=ProductionPatternSelected[[All,2]]*) +(*procprim=Select[ProductionList,StringContainsQ[#,"Primakov"]&];*) +(*If[procprim!={},*) +(*ProbMother[procprim[[1]]]=2*ProbMother["Pi0"]+0.71*ProbMother["Eta"];*) +(*];*) +(*Do[*) +(*Module[{prod},*) +(*prod=ProductionPatternSelected[[i]][[2]];*) +(*(*Importing the data with distribution*)*) +(*dirimp=If[prod=="DrellYan",FileNameJoin[{directory["Distribution"],"Pregenerated"}],directory["Distribution"]];*) +(*DistrDataImport[prod]=Import[FileNameJoin[{dirimp,"DoubleDistr_"<>LLPdirName<>"_"<>prod<>"_"<>FacilityGivenExperiment<>".m"}],"MX"];*) +(*If[prod=="DrellYan",*) +(*DistrDataImport[prod]=Select[DistrDataImport[prod],MinMaxMassesDrellYan[FacilityGivenExperiment][[1]]<=#[[1]]<=MinMaxMassesDrellYan[FacilityGivenExperiment][[2]]&];*) +(*];*) +(*(*Min/mass mass of the LLP from the data*)*) +(*mlistDistr[prod]=DeleteDuplicates[DistrDataImport[prod][[All,1]]];*) +(*{mLLPmin[prod],mLLPmax[prod]}=MinMax[mlistDistr[prod]];*) +(*(*Interpolation of the tabulated distribution*)*) +(*DoubleDistrLLPint[mLLP_,\[Theta]LLP_,ELLP_,prod]=10^(Interpolation[distrlogComp[DistrDataImport[prod]],InterpolationOrder->1][Log10[mLLP],Log10[\[Theta]LLP],Log10[ELLP]]);*) +(*(*Probability to produce LLP*)*) +(*ProbLLP[mLLP_,ga_,prod]=ProbMother[prod]*PmotherToLLP[mLLP,ga,prod,FacilityGivenExperiment]/.{Atarget->AtargetVal};*) +(*]*) +(*,{i,1,Length[ProductionPatternSelected],1}]*) +(*directory["Auxiliary-experiment"]=FileNameJoin[{directory["Auxiliary"],SelectedExperiment}];*) +(*If[!DirectoryQ[directory["Auxiliary-experiment"]],CreateDirectory[directory["Auxiliary-experiment"]]];*) +(*Export[FileNameJoin[{directory["Auxiliary-experiment"],"Double-Distr-Averaged-"<>LLPdirName<>".m"}],{Sum[If[mLLPmin[prod]True,ImageSize->Large,PlotLegends->Placed[Style[#,15]&/@ProductionList,Right]];*) +(*ptprodprob=LogLogPlot[Evaluate[Table[ProbLLP[ma,1,prod],{prod,ProductionList}]],{ma,mmin\[Epsilon],mmax\[Epsilon]},Frame->True,ImageSize->Large,PlotLegends->Placed[Style[#,15]&/@ProductionList,Right]];*) +(*Style[Row[{ptprodprob,ptenergies}],ImageSizeMultipliers->{1, 1}]*) + + +(* ::Chapter::Closed:: *) +(*Number of events*) + + +(* ::Section::Closed:: *) +(*Number of events - using the mapping method *) + + +(* ::Subsection::Closed:: *) +(*Initializing all routines*) + + +(* ::Input:: *) +(*Do[{OutGrid\[Theta]final[prod],\[CapitalDelta]\[Theta]vals[prod]}=OutGrid\[Theta]Temp[InGrid\[Theta]\[Epsilon],30,prod,\[Theta]maxBrem],{prod,ProductionList}]*) +(*{OutGridzfinal,\[CapitalDelta]zvals}=OutGridszTemp[InGridz\[Epsilon],30,zminExp];*) +(*(*Final energy grid. Mass- and production channel-dependent*)*) +(*If[FacilityGivenExperiment!="ESS",*) +(*StepEtemp[Efip_]=Piecewise[{{0.2,Efip<=2.5},{0.3,2.5Directive[Black, 22],PlotStyle->{{Thickness[0.003],Blue},{Thickness[0.003],Darker@Red},{Thickness[0.003],Darker@Darker@Green},{Thickness[0.003],Black}},GridLines->Automatic,PlotRange->{MinMax[\[Epsilon]GeomTabs[ProdChannel][[All,1]]],{Max[0.9Min[Min[\[Epsilon]GeomTabs[ProdChannel][[All,4]]],Min[\[Epsilon]GeomTabs[ProdChannel][[All,3]]]],10^-5],1.1Max[Max[\[Epsilon]GeomTabs[ProdChannel][[All,2]]],Max[\[Epsilon]GeomTabs[ProdChannel][[All,4]]]]}},Joined->True,Frame->True,ImageSize->Large,FrameLabel->{"m [GeV]","Acceptance"},PlotLabel-> Style[Row[{"From ",ProdChannel}], 20, Black],PlotLegends->Placed[{Style[#, 18]&/@{"<\!\(\*SubscriptBox[\(\[Epsilon]\), \(LLP\)]\)>","<\!\(\*SubscriptBox[\(\[Epsilon]\), \(LLP\)]\)\!\(\*SubscriptBox[\(\[Epsilon]\), \(decay\)]\)>","c\[Tau]<\!\(\*SubscriptBox[\(\[Epsilon]\), \(LLP\)]\)\!\(\*SubscriptBox[\(P\), \(decay\)]\)>","c\[Tau]<\!\(\*SubscriptBox[\(\[Epsilon]\), \(LLP\)]\)\!\(\*SubscriptBox[\(P\), \(decay\)]\)\!\(\*SubscriptBox[\(\[Epsilon]\), \(decay\)]\)>"}},{0.75,0.2}]]*) +(*Style[Row[Evaluate[Table[PlotAcc[prod],{prod,ProductionList}]]],ImageSizeMultipliers->{1,1,1,1}]*) +(*(*Do[FilenameAcceptance[prod]=ToString@StringForm["Acceptance_ALP-fermion_at_``_From_``.dat",Sequence@@{SelectedExperiment,ExportList[prod]}];*) +(*Export[FileNameJoin[{NotebookDirectory[],"Auxiliary data/ALPs with fermion coupling",SelectedExperiment,FilenameAcceptance[prod]}],\[Epsilon]GeomTabs[prod][[All,{1,2,4,5}]],"Table"]*) +(*,{prod,ProductionList}]*)*) +(*AccAveraged[mLLP_,c\[Tau]_]=NpotGivenExperiment{Sum[If[mLLPmin[prod]1][mLLP]],0],{prod,ProductionList}],Sum[If[Max[mLLPmin[prod],mmin\[Epsilon]]1][mLLP]],0],{prod,ProductionList}],Sum[If[Max[mLLPmin[prod],mmin\[Epsilon]]1][mLLP]],0],{prod,ProductionList}]};*) +(*Export[FileNameJoin[{directory["Auxiliary-experiment"],"AcceptanceAveraged-"<>LLPdirName<>".m"}],AccAveraged[mLLP,c\[Tau]],"MX"];*) + + +(* ::Subsection::Closed:: *) +(*Rough estimates of the upper and lower bounds*) + + +(* ::Subsubsection::Closed:: *) +(*Definitions*) + + +(* ::Input:: *) +(*Do[LowerBoundEstimate[mLLP_,prod]=((NpotGivenExperiment*ProbLLP[mLLP,1,prod]*Interpolation[\[Epsilon]GeomTabs[prod][[All,{1,5}]],InterpolationOrder->1][mLLP])/(2.3ldecayLLP[mLLP,1,ELLP] mLLP/Sqrt[ELLP^2-mLLP^2]))^(-(1/4));*) +(*UpperBoundEstimate[mLLP_,prod]=(Abs[Re[Evaluate[-(ProductLog[-1,-2.3*b/a]/b)/.{a-> NpotGivenExperiment*ProbLLP[mLLP,1,prod]*Interpolation[\[Epsilon]GeomTabs[prod][[All,{1,3}]],InterpolationOrder->1][mLLP],b->(zminExp-zShiftProd[prod])/ldecayLLP[mLLP,1,ELLPmax[0.5,\[Theta]minExp,prod]]}]]])^(1/2),{prod,ProductionList}]*) +(*ProdTest="Pi0";*) +(*LogLogPlot[Evaluate[{0.3LowerBoundEstimate[mLLP,ProdTest],1.8UpperBoundEstimate[mLLP,ProdTest]}],{mLLP,Max[mLLPmin[ProdTest],mmin\[Epsilon]],Min[mLLPmax[ProdTest],mmax\[Epsilon]]},Frame->True,ImageSize->Large]*) + + +(* ::Subsection::Closed:: *) +(*Number of events - fast*) + + +(* ::Input:: *) +(*FactorLowerBound=If[MemberQ[{"ANUBIS-shaft-volume-1","ANUBIS-shaft-volume-2","ANUBIS-shaft-volume-3"},SelectedExperiment]==True,0.1,0.3];*) +(*NeventsDiscret[m_,ProdChannel_,couplinglist_]:=Module[{NevDiscret,NpotTimes\[Chi]val,zshift},*) +(*If[Max[mLLPmin[ProdChannel],mmin\[Epsilon]]"AdaptiveMonteCarlo"]*) +(*(*IntegralLLP[mLLP_,finv_,ProdChannel_]:=NIntegrate[Abs[IntegrandLLP[mLLP,finv,Exp[\[Theta]LLP],Exp[ELLP],Exp[zLLP],ProdChannel]]Exp[\[Theta]LLP+ELLP+zLLP],{\[Theta]LLP,Log[\[Theta]minExp],Log[\[Theta]maxExp]},{ELLP,Log[mLLP],Log[ELLPmax[mLLP,Exp[\[Theta]LLP],ProdChannel]]},{zLLP,Log[zmin\[Theta][Exp[\[Theta]LLP]]],Log[zmax\[Theta][Exp[\[Theta]LLP]]]},Method\[Rule]"AdaptiveMonteCarlo"]*)*) +(*NeventsInt[mLLP_,coupling_,ProdChannel_]:=If[mLLPmin[ProdChannel]<=mLLP<=mLLPmax[ProdChannel]&&BrVis[mLLP]!=0,If[0.1LowerBoundEstimate[mLLP,ProdChannel]2,"\!\(\*SubscriptBox[\(\[Theta]\), \(X\)]\)"->1,"\!\(\*SubscriptBox[\(z\), \(X\)]\)"->3}]*) +(*\[CapitalDelta]xvals["\!\(\*SubscriptBox[\(E\), \(X\)]\)"]:=\[CapitalDelta]Evals;*) +(*\[CapitalDelta]xvals["\!\(\*SubscriptBox[\(z\), \(X\)]\)"]=\[CapitalDelta]zvals;*) +(*Do[\[CapitalDelta]xvals["\!\(\*SubscriptBox[\(\[Theta]\), \(X\)]\)",prod]=\[CapitalDelta]\[Theta]vals[prod],{prod,ProductionList}];*) +(*LegendX:=Association[{"\!\(\*SubscriptBox[\(E\), \(X\)]\)"->"\!\(\*SubscriptBox[\(E\), \(X\)]\) [GeV]","\!\(\*SubscriptBox[\(\[Theta]\), \(X\)]\)"->"\!\(\*SubscriptBox[\(\[Theta]\), \(X\)]\) [rad]","\!\(\*SubscriptBox[\(z\), \(X\)]\)"-> "\!\(\*SubscriptBox[\(z\), \(X\)]\) [m]"}]*) +(*LegendY:=Association[{"\!\(\*SubscriptBox[\(E\), \(X\)]\)"->"\!\(\*SubscriptBox[\(dN\), \(ev\)]\)/\!\(\*SubscriptBox[\(dE\), \(X\)]\) [\!\(\*SuperscriptBox[\(GeV\), \(-1\)]\)]","\!\(\*SubscriptBox[\(\[Theta]\), \(X\)]\)"->"\!\(\*SubscriptBox[\(dN\), \(ev\)]\)/\!\(\*SubscriptBox[\(d\[Theta]\), \(X\)]\) [\!\(\*SuperscriptBox[\(rad\), \(-1\)]\)]","\!\(\*SubscriptBox[\(z\), \(X\)]\)"-> "\!\(\*SubscriptBox[\(dN\), \(ev\)]\)/\!\(\*SubscriptBox[\(dz\), \(X\)]\) [\!\(\*SuperscriptBox[\(m\), \(-1\)]\)]"}]*) +(*(*Differential number of events*)*) +(*NeventsDifferentialDiscretProd[m_,ProdChannel_,coupling_,Variable_]:=Module[{NpotTimes\[Chi]val},*) +(*ival=iVal[Variable];*) +(*NpotTimes\[Chi]val=NpotGivenExperiment*ProbLLP[m,coupling,ProdChannel];*) +(*tablegrid0=TableIntegrandDiscret[m,ProdChannel,"True"];*) +(*OutGridEfinalTemp=OutGridEnergy[N[m],ProdChannel];*) +(*\[CapitalDelta]Evals=(Rest[10^OutGridEfinalTemp]-Most[10^OutGridEfinalTemp]);*) +(*\[CapitalDelta]xval=\[CapitalDelta]xvals[Variable];*) +(*c\[Tau]Val=c\[Tau]LLP[m,coupling];*) +(*brvis=BrVis[m];*) +(*ilist=DeleteDuplicates[{ival,1,2,3}];*) +(*tablegrid1=SortBy[{#[[ilist[[1]]]],#[[ilist[[2]]]],#[[ilist[[3]]]],#[[4]]}&/@tableGridPrefac[tablegrid0,m,c\[Tau]Val,0.],{#[[1]],#[[2]],#[[3]]}&];*) +(*GridQuantity=tablegrid1[[All,1]]//DeleteDuplicates;*) +(*LengthPerVariable=Length[tablegrid1]/Length[GridQuantity];*) +(*tab1=NdiffCompiled[tablegrid1,GridQuantity,LengthPerVariable,NpotTimes\[Chi]val*brvis];*) +(*Join[tab1[[All,{1}]],Partition[tab1[[All,2]]*\[CapitalDelta]xval^-1,1],2]*) +(*]*) +(*NeventsDifferentialDiscret[m_,coupling_,Variable_]:=Module[{NdiffInt,LegendList,QuantityMinMax,ValueMinMax},*) +(*prodlisttemp={};*) +(*Do[If[Max[mLLPmin[prod],mmin\[Epsilon]]10^-40&][[All,1]]//MinMax;*) +(*NdiffInt[X_,prod]=If[XvalminmaxNdiff[[1]]1][Log10[X]]],0]],{prod,ProductionList}];*) +(*NdiffInt[X_,"Total"]=Sum[NdiffInt[X,prod],{prod,prodlisttemp}];*) +(*LegendList=Join[{"Total"},prodlisttemp];*) +(*QuantityMinMax=Flatten[Table[MinMax[NdiffData[prod][[All,1]]],{prod,prodlisttemp}],1]//MinMax;*) +(*ValueMinMax=Max[Max[NdiffData[#][[All,2]]]&/@prodlisttemp];*) +(*{Table[NdiffInt[X,prod],{prod,LegendList}],LegendList,QuantityMinMax,ValueMinMax}*) +(*]*) +(*mvaltest=If[FacilityGivenExperiment=="ESS",0.04,0.05];*) +(*couplingvaltest=1.4LowerBoundEstimate[mvaltest,"Pi0"];*) +(*quantity="\!\(\*SubscriptBox[\(E\), \(X\)]\)";*) +(*{NdiffTab[X_],LegendList,QuantityMinMax,ValueMinMax}=NeventsDifferentialDiscret[mvaltest,couplingvaltest,quantity];*) +(*Do[*) +(*prch=LegendList[[i]];*) +(*NdiffInt[X_,prch]=NdiffTab[X][[i]];*) +(*,{i,1,Length[LegendList]}];*) +(*plotdiff=LogLogPlot[Evaluate[Table[NdiffInt[X,prod],{prod,LegendList}]],{X,QuantityMinMax[[1]],QuantityMinMax[[2]]},Frame->True,ImageSize->Large,PlotRange->{All,{10^-5,4ValueMinMax}},PlotStyle->{{Thick,Black},{Thick,Blue},{Thick,Darker@Red},{Thick,Darker@Darker@Green},{Thick,Darker@Cyan},{Thick,Magenta},{Thick,Blue,Dashing[0.02]},{Thick,Darker@Red,Dashing[0.02]},{Thick,Darker@Darker@Green,Dashing[0.02]}},PlotLegends->Placed[Style[#,20]&/@LegendList,Right],FrameLabel->{LegendX[quantity] ,LegendY[quantity]},FrameStyle->Directive[Black, 18],PlotLabel->Style[Row[{SelectedExperiment,". \!\(\*SubscriptBox[\(m\), \(a\)]\) = ",mvaltest," GeV, \!\(\*SubscriptBox[\(g\), \(a\)]\) = ",couplingvaltest//N, " \!\(\*SuperscriptBox[\(GeV\), \(-1\)]\)"}],14,Black]]*) + + +(* ::Title::Closed:: *) +(*Exporting tabulated number of events*) + + +(* ::Chapter::Closed:: *) +(*Definitions*) + + +(* ::Input:: *) +(*directory["Nevents"]=FileNameJoin[{NotebookDirectory[],"Tabulated Nevents"}];*) +(*directory["Nevents-LLP"]=FileNameJoin[{NotebookDirectory[],"Tabulated Nevents",LLPdirName}];*) +(*directory["Nevents-LLP-experiment"]=FileNameJoin[{NotebookDirectory[],"Tabulated Nevents",LLPdirName,SelectedExperiment}];*) +(*If[!DirectoryQ[directory[#]],CreateDirectory[directory[#]]]&/@{"Nevents","Nevents-LLP","Nevents-LLP-experiment"};*) +(*Print["Filenames with tabulated \!\(\*SubscriptBox[\(N\), \(events\)]\):"]*) +(*Do[FilenameNevents[prod]=ToString@StringForm["Nevents_``_``_at_``_Npot=``.dat",Sequence@@{LLPdirName,prod,SelectedExperiment,NpotGivenExperiment//CForm//ToString}],{prod,ProductionList}]*) +(*FilenameNevents[#]&/@ProductionList*) +(*Do[mRangeExport[prod]={0.021,0.025,0.03,0.035,0.04,0.045,0.05,0.055,0.06,0.065,0.07,0.08,0.09,0.1,0.11,0.12,0.13,0.15,0.2,0.22,0.25,0.3,0.35,0.4,0.5,0.55,0.6,0.7,0.8,0.9,1,1.1,1.2,1.3,1.4,1.5,1.6,1.7,1.8,1.9,2.,2.1,2.2,2.3,2.4,2.5,2.6,2.7,2.8,2.9,3.,3.1,3.2,3.3,3.4,3.5}//N;*) +(*,{prod,ProductionList}]*) +(*couplingsRangeExport=Table[10^x,{x,-12,-2,0.02}];*) + + +(* ::Chapter::Closed:: *) +(*Exporting*) + + +(* ::Input:: *) +(*BlockExport[ProdChannel_]:=Module[{mlist},*) +(*mlist=mRangeExport[ProdChannel];*) +(*TabFrom=ParallelTable[Quiet[NeventsDiscret[mlist[[k]],ProdChannel,couplingsRangeExport]],{k,1,Length[mlist],1}];*) +(*Export[FileNameJoin[{directory["Nevents-LLP-experiment"],FilenameNevents[ProdChannel]}],Flatten[TabFrom,1],"Table"]*) +(*]*) +(*Monitor[*) +(*Do[*) +(*prod=ProductionList[[j]];*) +(*BlockExport[prod],{j,1,Length[ProductionList],1}],*) +(*Row[{ProgressIndicator[j,{1,Length[ProductionList]}]," Production mode = ",ProductionList[[j]]," (", j,"/",Length[ProductionList],")"}]]//AbsoluteTiming*) +(*If[icounter>Length[SelectedExperimentList],BlockEvaluation["Sensitivity"]]*) + + +(* ::Title::Closed:: *) +(*Computing sensitivities*) + + +(* ::Chapter::Closed:: *) +(*Basic definitions*) + + +(* ::Input:: *) +(*LLPdirName="ALP-photon";*) +(*directory["Sensitivity"]=FileNameJoin[{NotebookDirectory[],"Sensitivity domains"}];*) +(*directory["Sensitivity-LLP"]=FileNameJoin[{directory["Sensitivity"],LLPdirName}];*) +(*If[!DirectoryQ[directory[#]],CreateDirectory[directory[#]]]&/@{"Sensitivity","Sensitivity-LLP"};*) +(*directory["Nevents-LLP"]=FileNameJoin[{NotebookDirectory[],"Tabulated Nevents",LLPdirName}];*) +(*dropdownDialog[list_,phrase_]:=DialogInput[{choice=""},Column[{TextCell[phrase],PopupMenu[Dynamic[choice],list],Button["OK",DialogReturn[choice]]}]]*) +(*infoDialog[phrase_]:=DialogInput[{choice=""},Column[{TextCell[phrase],Button["Proceed",DialogReturn[choice]]}]]*) +(*selectionDialog[list_,phrase_]:=DialogInput[{choice={}},Column[{Row[{phrase}],Pane[TogglerBar[Dynamic[choice],list,Appearance->"Vertical"->{Automatic,5}],ImageSize->{Automatic,Automatic},Scrollbars->{False,True}],Button["OK",DialogReturn[choice]]}]]*) +(*ExperimentDirectoriesListNevents=Select[FileNames["*",directory["Nevents-LLP"],1],DirectoryQ];*) +(*Print["List of available experiments with tabulated \!\(\*SubscriptBox[\(N\), \(events\)]\) for" <>LLPdirName<>":"]*) +(*ExperimentsListNevents=Table[FileNameTake[ExperimentDirectoriesListNevents[[i]],-1],{i,1,Length[ExperimentDirectoriesListNevents],1}]//Sort;*) +(*ExperimentsListNevents//TableForm*) +(*If[Length[ExperimentsListNevents]==0,Print["No experiment is available, generate first the acceptance for the given experiment using module 1"],*) +(*SelectedExperimentList=If[Length[ExperimentsListNevents]!=0,selectionDialog[ExperimentsListNevents,"Select the experiments for which the sensitivity will be computed:"]];*) +(*icounter=1;*) +(*BlockEvaluation[tag_]:=Block[{},*) +(*nb=EvaluationNotebook[];*) +(*NotebookFind[nb,tag,All,CellTags];*) +(*SelectionEvaluate[nb]*) +(*];*) +(*Do[*) +(*BlockEvaluation["Sensitivity-computation"];*) +(*,{icounter,1,Length[SelectedExperimentList],1}]*) +(*]*) + + +(* ::Chapter::Closed:: *) +(*Specifying the experiment and interpolating the tabulated number of events*) + + +(* ::Section::Closed:: *) +(*Selecting the experiment*) + + +(* ::Input:: *) +(*Print["Selected experiment:"]*) +(*GivenExperimentForSensitivityComputation=SelectedExperimentList[[icounter++]]*) +(*CondANUBIS=MemberQ[{"ANUBIS-shaft-volume-1","ANUBIS-shaft-volume-2","ANUBIS-shaft-volume-3"},GivenExperimentForSensitivityComputation];*) +(*If[CondANUBIS==True,infoDialog[Row[{"One of the modules of ANUBIS-shaft is chosen. The full sensitivity includes three modules. The importing will be over all modules, so for all ot the the sensitivity has to be computed"}]]]*) +(*If[CondANUBIS==False,GivenExperimentForSensitivityComputationList={GivenExperimentForSensitivityComputation},GivenExperimentForSensitivityComputationList={"ANUBIS-shaft-volume-1","ANUBIS-shaft-volume-2","ANUBIS-shaft-volume-3"}];*) +(*PathsNeventsSelected={};*) +(*Do[PathsNeventsSelected=Join[PathsNeventsSelected,FileNames["*.dat",FileNameJoin[{directory["Nevents-LLP"],exp}]]],{exp,GivenExperimentForSensitivityComputationList}];*) +(*(*Creating the directory for exporting sensitivity curves*)*) +(*ExperimentFolder=If[CondANUBIS==True,"ANUBIS",GivenExperimentForSensitivityComputation];*) +(*directory["Sensitivity-LLP-exp"]=FileNameJoin[{directory["Sensitivity-LLP"],ExperimentFolder}];*) +(*If[!DirectoryQ[directory["Sensitivity-LLP-exp"]],CreateDirectory[directory["Sensitivity-LLP-exp"]]]*) + + +(* ::Section::Closed:: *) +(*Importing and interpolations*) + + +(* ::Input:: *) +(*Print["List of production channels:"]*) +(*FilenamesNevents=Table[Last@FileNameSplit@PathsNeventsSelected[[i]],{i,1,Length[PathsNeventsSelected],1}];*) +(*FilenameParameters[i_]:=StringCases[FilenamesNevents[[i]],"Nevents_"<>LLPdirName<>"_"~~mother__~~"_at_"~~experiment__~~"_Npot="~~Npot__~~".dat":>{mother,experiment,Npot}][[1]]*) +(*(*______________________________________________________*)*) +(*(*Importing and interpolation*)*) +(*(*______________________________________________________*)*) +(*ProductionInfoList=Table[FilenameParameters[i],{i,1,Length[FilenamesNevents],1}];*) +(*Join[{{"Mother","Experiment","\!\(\*SubscriptBox[\(N\), \(PoT\)]\)"}},ProductionInfoList]//TableForm*) +(*ProductionChannelsList=ProductionInfoList[[All,1]];*) +(*NpotDefault=Interpreter["Number"][ProductionInfoList[[1]][[3]]];*) +(*NeventsTabulated//Clear;*) +(*\[Epsilon]reco[mLLP_]=If[StringContainsQ[GivenExperimentForSensitivityComputation,"LHCb-downstream"]==True,0.4,If[StringContainsQ[GivenExperimentForSensitivityComputation,"CHARM-lepton"]==True,If[mLLP<0.105*2,0.51,0.85],1]];*) +(*Do[*) +(*Module[{prod},*) +(*prod=ProductionChannelsList[[i]];*) +(*(*The condition if one sums the number of events for the same production mode over several experiments*)*) +(*IfprodExists=MemberQ[Keys[DownValues@NeventsTabulated][[All,1,1]],prod];*) +(*NeventsTabulated[prod]=If[!IfprodExists,Import[PathsNeventsSelected[[i]],"Table"],Join[NeventsTabulated[prod][[All,{1,2}]],NeventsTabulated[prod][[All,{3}]]+Import[PathsNeventsSelected[[i]],"Table"][[All,{3}]]]];*) +(*{mminmax[prod],couplingminmax[prod]}=(NeventsTabulated[prod][[All,#]]//MinMax)&/@{1,2};*) +(*NevMax[prod]=NeventsTabulated[prod][[All,3]]//Max;*) +(*NevInt[mLLP_,y_,prod]=\[Epsilon]reco[mLLP]*If[mminmax[prod][[1]]<= mLLP<=mminmax[prod][[2]]&&couplingminmax[prod][[1]]<=y<=couplingminmax[prod][[2]],Evaluate[10^(Interpolation[{Log10[#[[1]]],Log10[#[[2]]],Log10[#[[3]]+10^-90]}&/@NeventsTabulated[prod],InterpolationOrder->1][Log10[mLLP],Log10[y]])],0];*) +(*]*) +(*,{i,1,Length[ProductionInfoList],1}]*) +(*{mminmaxOverall,couplingminmaxOverall}=MinMax[Table[#[prod],{prod,ProductionChannelsList}]//Flatten]&/@{mminmax,couplingminmax};*) +(*NevMaxOverall=Max[Table[NevMax[prod],{prod,ProductionChannelsList}]];*) +(*NevIntOverall[mLLP_,y_]=Sum[NevInt[mLLP,y,prod],{prod,ProductionChannelsList}];*) +(*pt[mLLP_]:=LogLogPlot[Evaluate[Table[NevInt[mLLP,y,prod],{prod,ProductionChannelsList}]],{y,couplingminmaxOverall[[1]],couplingminmaxOverall[[2]]},PlotLegends->Placed[Style[#,15]&/@ProductionChannelsList,Right],PlotRange->{couplingminmaxOverall,{10^-2,NevMaxOverall}},Frame->True,ImageSize->Large,FrameLabel->{"\!\(\*SubscriptBox[\(g\), \(a\)]\) [\!\(\*SuperscriptBox[\(GeV\), \(-1\)]\)]" , "\!\(\*SubscriptBox[\(N\), \(events\)]\)[\!\(\*SubscriptBox[\(m\), \(a\)]\),\!\(\*SubscriptBox[\(g\), \(a\)]\)]"},FrameStyle->Directive[Black, 23],PlotStyle->{{Thick,Blue},{Thick,Darker@Red},{Thick,Darker@Darker@Green},{Thick,Black},{Thick,Blue,Dashing[0.02]},{Thick,Darker@Red,Dashing[0.02]},{Thick,Darker@Darker@Green,Dashing[0.02]},{Thick,Black,Dashing[0.02]}},PlotLabel->Style[Row[{ExperimentFolder,". \!\(\*SubscriptBox[\(m\), \(a\)]\) = ",mLLP, " GeV"}],20,Black]]*) +(*pt[0.6]*) + + +(* ::Chapter::Closed:: *) +(*Sensitivity computation*) + + +(* ::Section::Closed:: *) +(*Subscript[N, events] density plot*) + + +(* ::Input:: *) +(*plot=DensityPlot[Evaluate[Log10[NevIntOverall[mLLP,y]]],{mLLP,mminmaxOverall[[1]],mminmaxOverall[[2]]},{y,couplingminmaxOverall[[1]],couplingminmaxOverall[[2]]},ScalingFunctions->{"Log","Log"},AspectRatio->0.78,PlotRange->{All,All,{Log10[2.3],Log10[NevMaxOverall]}},ImageSize->Large,FrameLabel->{"\!\(\*SubscriptBox[\(m\), \(a\)]\) [GeV]","\!\(\*SubscriptBox[\(g\), \(a\)]\) [\!\(\*SuperscriptBox[\(GeV\), \(-1\)]\)]"}, Frame-> True, FrameStyle->Directive[Black, 25],PlotPoints->100,PlotLegends->Placed[BarLegend[{Automatic,{Log10[2.3],Log10[NevMaxOverall]}},LegendMarkerSize->340,LegendLabel->Placed["\!\(\*SubscriptBox[\(Log\), \(10\)]\)[\!\(\*SubscriptBox[\(N\), \(ev\)]\)]",Bottom],LabelStyle->{FontSize->22},Method->{FrameStyle->Black,AxesStyle->None,TicksStyle->Black}],Right],PlotLabel->Style[Row[{ExperimentFolder}],20,Black](*,FrameTicks->{{Automatic,Automatic},{TicksPlotx,None}}*)]*) +(*(*Export[FileNameJoin[{NotebookDirectory[],"plots/SensCalc/NeventsDensityPlotExample.pdf"}],plot,"AllowRasterization"->False]*)*) + + +(* ::Section::Closed:: *) +(*Constraints importing*) + + +(* ::Input:: *) +(*importformat["txt"]=importformat["dat"]="Table";*) +(*importformat["m"]=importformat["mx"]="MX";*) +(*importformat["xls"]="XLS";*) +(*dir=FileNameJoin[{NotebookDirectory[],"contours",LLPdirName}];*) +(*If[DirectoryQ[dir],*) +(*filenames=FileNames[LLPdirName<>"-excluded*",dir,Infinity];*) +(*ExcludedRegions[LLPdirName]=Import[#,importformat[FileExtension[#]]]&/@FileNames[LLPdirName<>"-excluded*",dir,Infinity];*) +(*];*) +(*If[!DirectoryQ[dir],*) +(*ExcludedRegions[LLPdirName]={{{10.,10.}}};*) +(*]*) + + +(* ::Section::Closed:: *) +(*Sensitivity*) + + +(* ::Input:: *) +(*SensitivityBlock[Nev_,Npot_,SelectedProduction_]:=Block[{},*) +(*NevTot[mLLP_,ga_]=Sum[NevInt[mLLP,ga,prod],{prod,SelectedProduction}];*) +(*RegSens=RegionPlot[Npot/NpotDefault*NevTot[10^ma,10^ga]>=Nev,{ma,Log10[mminmaxOverall[[1]]],Log10[mminmaxOverall[[2]]]},{ga,Log10[couplingminmaxOverall[[1]]],Log10[couplingminmaxOverall[[2]]]},PlotPoints->30];*) +(*SensTemp=Cases[Normal@RegSens,Line[x_]:>x,Infinity];*) +(*Sens=Table[{10^#[[1]],10^#[[2]]}&/@SensTemp[[i]],{i,1,Length[SensTemp],1}];*) +(*Export[FileNameJoin[{directory["Sensitivity-LLP-exp"],ToString@StringForm["Sensitivity_``_at_``_Nev=``_Npot=``.xls",Sequence@@{LLPdirName,ExperimentFolder,Nev//ToString,Npot//CForm//ToString}]}],Sens];*) +(*Sens*) +(*]*) +(*productionlist=Join[{"All"},ProductionChannelsList];*) +(*DynamicModule[{input1=NpotDefault,input2=2.3,choice={"All"},list,phrase},*) +(*DialogInput[Column[{Style[ExperimentFolder,Bold],TextCell["Enter the number of proton collisions:"],InputField[Dynamic[input1],Expression],TextCell["Enter the value of N_ev,min for which the sensitivity will be computed:"],InputField[Dynamic[input2],Expression],Row[{"Select the production channels to be used for the sensitivity calculation:"}],Pane[TogglerBar[Dynamic[choice],productionlist,Appearance->"Vertical"->{Automatic,1}],ImageSize->{Automatic,Automatic},Scrollbars->{False,True}],Button["Submit",DialogReturn[{NpotVal,NevMinVal,SelectedProduction}={input1,input2,choice}//N],ImageSize->Automatic]}]]];*) +(*If[MemberQ[SelectedProduction,"All"],SelectedProduction=ProductionChannelsList;]*) +(*{{"\!\(\*SubscriptBox[\(N\), \(PoT\)]\) for computation","\!\(\*SubscriptBox[\(N\), \(ev, min\)]\)","Selected production modes"},{NpotVal,NevMinVal,SelectedProduction}}//TableForm*) +(*sens=SensitivityBlock[NevMinVal,NpotVal,SelectedProduction];*) +(*Show[ListLogLogPlot[Cases[ExcludedRegions[LLPdirName],_?MatrixQ,All],Joined->{True,True,True,True},Frame-> True,FrameLabel->{"\!\(\*SubscriptBox[\(m\), \(a\)]\) [GeV]" , "\!\(\*SubscriptBox[\(g\), \(a\)]\) [\!\(\*SuperscriptBox[\(GeV\), \(-1\)]\)]"},FrameStyle->Directive[Black, 23],PlotStyle->{{Thick,Gray}},Filling->{1->{True,Directive[Gray,Opacity[0.3]]},2->{True,Directive[Gray,Opacity[0.3]]},3->{True,Directive[Gray,Opacity[0.3]]},4->{True,Directive[Gray,Opacity[0.3]]}},ImageSize->Large,PlotRange->{{1.01mminmaxOverall[[1]],1.1mminmaxOverall[[2]]},{0.3Min[Flatten[Sens]],0.99couplingminmaxOverall[[2]]}},PlotLabel->Style[Row[{"\!\(\*SubscriptBox[\(N\), \(events\)]\) \[GreaterEqual] ",NevMinVal}],18,Black]],*) +(*ListLogLogPlot[Cases[sens,_?MatrixQ,All],Joined->{True,True,True,True},PlotStyle->Flatten[{ConstantArray[{Thick,Blue},If[MatrixQ[sens],1,Length@sens]]},1],ImageSize->Large,PlotRange->{{1.01mminmaxOverall[[1]],1.1mminmaxOverall[[2]]},{couplingminmaxOverall[[1]],0.99couplingminmaxOverall[[2]]}},PlotLabel->Style[Row[{"\!\(\*SubscriptBox[\(N\), \(events\)]\) \[GreaterEqual] ",NevMinVal}],18,Black],PlotLegends->Placed[Style[#,15]&/@{ExperimentFolder},{0.2,0.15}]],Graphics[{Text[Style["Excluded",24,Black],Scaled[{0.7,0.95}]]}]]*) + + +(* ::Title::Closed:: *) +(*Deleting generated cells*) + + +(* ::Input:: *) +(*FrontEndTokenExecute["DeleteGeneratedCells"];*) +(*FrontEndTokenExecute["SelectAll"];*) +(*FrontEndTokenExecute["SelectionCloseAllGroups"];*) diff --git a/wls/3. B mediators sensitivity.wls b/wls/3. B mediators sensitivity.wls new file mode 100755 index 0000000..6df5e2e --- /dev/null +++ b/wls/3. B mediators sensitivity.wls @@ -0,0 +1,862 @@ +#!/usr/bin/env wolframscript +(* ::Package:: *) + +(* ::Title::Closed:: *) +(*Just launch the code below to run the notebook (shift+enter)*) + + +(* ::Input:: *) +(*ClearAll["Global`*"]*) +(*ParallelEvaluate[ClearAll["Global`*"]];*) +(*CloseKernels[];*) +(*LaunchKernels[];*) +(*BlockEvaluation[tag_]:=Block[{},*) +(*nb=EvaluationNotebook[];*) +(*NotebookFind[nb,tag,All,CellTags];*) +(*SelectionEvaluate[nb]*) +(*]*) +(*dropdownDialog[list_,phrase_]:=DialogInput[{choice=""},Column[{TextCell[phrase],PopupMenu[Dynamic[choice],list],Button["OK",DialogReturn[choice]]}]]*) +(*infoDialog[phrase_]:=DialogInput[{choice=""},Column[{TextCell[phrase],Button["Proceed",DialogReturn[choice]]}]]*) +(*If[(DirectoryQ[FileNameJoin[{NotebookDirectory[],"Auxiliary data"}]]//ToString)=="False",CreateDirectory[FileNameJoin[{NotebookDirectory[],"Auxiliary data"}]]];*) +(*choiceslist={"Tabulated Nevents+sensitivity","Sensitivity only (tabulated Nevents must be produced before)","Acceptance"};*) +(*taglist["Acceptance"]="Acceptance";*) +(*taglist["Tabulated Nevents+sensitivity"]="Number-of-events+sensitivity";*) +(*taglist["Sensitivity only (tabulated Nevents must be produced before)"]="Sensitivity";*) +(*computationchoice=dropdownDialog[choiceslist,"Do you want to compute the tabulated number of events and then sensitivity, or just sensitivity (if the tabulated number of events has been already produced)?"];*) +(*tagselected=taglist[computationchoice]*) +(*BlockEvaluation[tagselected]*) + + +(* ::Title::Closed:: *) +(*Definitions*) + + +(* ::Chapter::Closed:: *) +(*Various directories*) + + +(* ::Input:: *) +(*dropdownDialog[list_,phrase_]:=DialogInput[{choice=""},Column[{TextCell[phrase],PopupMenu[Dynamic[choice],list],Button["OK",DialogReturn[choice]]}]]*) +(*LLPdirName=dropdownDialog[{"B-L","B-3Lmu","B-3Le-Lmu+Ltau","B-Le-3Lmu+Ltau"},"Select the type of the mediator:"]*) +(*(*Set the directory for the search where tabulated acceptances are located*)*) +(*directory["Acceptances"]=FileNameJoin[{NotebookDirectory[],"Acceptances"}];*) +(*(*Set the directory for the search where tabulated angle-energy distributions are located*)*) +(*directory["Distribution"]=FileNameJoin[{NotebookDirectory[],"spectra/New physics particles spectra",LLPdirName}]; *) +(*(*The directory storing production weights of the given LLP*)*) +(*directory["Production weights"]=FileNameJoin[{NotebookDirectory[],"phenomenology",LLPdirName,"Production probabilities"}]; *) +(*(*Directory to which various auxillary datasets will be stored*)*) +(*directory["Auxiliary"]=FileNameJoin[{NotebookDirectory[],"Auxiliary data",LLPdirName}]; *) +(*If[!DirectoryQ[directory["Auxiliary"]],CreateDirectory[directory["Auxiliary"]]];*) +(*(*Directory containing decay widths of the LLPs*)*) +(*directory["Decays"]=FileNameJoin[{NotebookDirectory[],"phenomenology",LLPdirName,"decay widths"}]; *) + + +(* ::Chapter::Closed:: *) +(*Parameters and critical definitions*) + + +(* ::Input:: *) +(*dropdownDialog[list_,phrase_]:=DialogInput[{choice=""},Column[{TextCell[phrase],PopupMenu[Dynamic[choice],list],Button["OK",DialogReturn[choice]]}]]*) +(*infoDialog[phrase_]:=DialogInput[{choice=""},Column[{TextCell[phrase],Button["Proceed",DialogReturn[choice]]}]]*) +(*selectionDialog[list_,phrase_]:=DialogInput[{choice={}},Column[{Row[{phrase}],Pane[TogglerBar[Dynamic[choice],list,Appearance->"Vertical"->{Automatic,5}],ImageSize->{Automatic,Automatic},Scrollbars->{False,True}],Button["OK",DialogReturn[choice]]}]]*) +(*(*Conversion units*)*) +(*GeVMinusOneTom=2*10^-16;*) +(*chbarval=3*10^8*6.58*10^-25;*) +(*(*EM coupling*)*) +(*\[Alpha]EMval=1/137;*) +(*(*Mesons masses*)*) +(*{mSM["Omega"],mSM["Pi0"],mSM["Eta"],mSM["EtaPr"],mSM["p"]}={0.78,0.135,0.547,0.958,0.939};*) +(*\[CapitalGamma]SM["Omega"]=0.0084;*) +(*(*Various br ratios*)*) +(*Br\[Pi]To\[Gamma]\[Gamma]=0.98799;*) +(*Br\[Eta]To\[Gamma]\[Gamma]=0.3931181;*) +(*(*Br\[Omega]To\[Pi]\[Gamma]=0.0834941;*)*) +(*Br\[Eta]prTo\[Gamma]\[Gamma]=0.0219297;*) +(**) +(*\[Sigma]pNucleonInpb[Atarget_]=51*Atarget^-0.29*10^9;*) + + +(* ::Chapter::Closed:: *) +(*LLP phenomenology: production probabilities, decay widths*) + + +(* ::Section::Closed:: *) +(*Production probabilities*) + + +(* ::Subsection::Closed:: *) +(*Via decays of mesons and mixing*) + + +(* ::Input:: *) +(*PmotherToLLP//Clear;*) +(*Qel=DiagonalMatrix[{2/3,-(1/3),-(1/3)}];*) +(*T\[Omega] = (1/2)DiagonalMatrix[{1,1,0}];*) +(*T\[Phi] = (1/(\[Sqrt]2))DiagonalMatrix[{0,0,1}];*) +(*f\[Omega]N=17.2;*) +(*g\[Omega]=17.1*(((1/3)Tr[T\[Omega]])/Tr[Qel . T\[Omega]]);*) +(*Br\[Pi]0ToV[mV_]=If[mVLLPdirName<>"_"<>Facility<>".txt"}],"Table"];*) +(*MinMaxMassesDrellYan[Facility]={Min[dat[[All,1]]],Min[4,Max[dat[[All,1]]]]};*) +(*int[ma_]=If[MinMaxMassesDrellYan[Facility][[1]]<= ma<=MinMaxMassesDrellYan[Facility][[2]],Evaluate[10^(Interpolation[{Log10[#[[1]]],Log10[#[[2]]+10^-90]}&/@dat,InterpolationOrder->1][Log10[ma]])],0];*) +(*PmotherToLLP[mLLP_,\[Alpha]B_,"DrellYan",Facility]=\[Alpha]B*int[mLLP]/\[Sigma]pNucleonInpb[Atarget]*) +(*]*) +(*Do[\[Sigma]DrellYanData[Facility],{Facility,{"SPS","FermilabBD","LHC"}}]*) + + +(* ::Subsection::Closed:: *) +(*Via bremsstrahlung*) + + +(* ::Input:: *) +(*(*________________*)*) +(*(*Bremsstrahlung*)*) +(*(*________________*)*) +(*BremProd[Facility_]:=Module[{},*) +(*bremprobfiles=FileNames["Pbrem*_"<>Facility<>".m",directory["Production weights"]];*) +(*If[bremprobfiles!={},*) +(*(*Scanning over all available files with the bremsstrahlung probability. They describe different descriptions of the bremsstrahlung*)*) +(*(*Extract the bremsstrahlung description from the filename*)*) +(*bremprobfilenames=Last@FileNameSplit[#]&/@bremprobfiles;*) +(*bremdescription=("Bremsstrahlung-"<>(StringSplit[#,{"Pbrem_"<>LLPdirName<>"_","_"}][[1]])&/@bremprobfilenames);*) +(*Do[*) +(*datbrem[mLLP_,\[Theta]LLP_]=Import[bremprobfiles[[i]],"MX"];*) +(*If[StringContainsQ[bremdescription[[i]],"Baseline"],*) +(*PmotherToLLP[mLLP_,\[Alpha]B_,bremdescription[[i]],Facility]=datbrem[mLLP,\[Theta]LLP][[1]]*\[Alpha]B;*) +(*ELLPmin[bremdescription[[i]],Facility]=Evaluate[datbrem[mLLP,\[Theta]LLP][[2]]];*) +(*\[Theta]maxBrem[bremdescription[[i]],Facility]=Evaluate[datbrem[mLLP,\[Theta]LLP][[3]]];*) +(*ELLPmax[mLLP_,\[Theta]LLP_,bremdescription[[i]],Facility]=Evaluate[datbrem[mLLP,\[Theta]LLP][[4]]];*) +(*,*) +(*Do[*) +(*PmotherToLLP[mLLP_,\[Alpha]B_,bremdescription[[i]]<>"-"<>datbrem[mLLP,\[Theta]LLP][[j]][[1]],Facility]=datbrem[mLLP,\[Theta]LLP][[j]][[2]]*\[Alpha]B;*) +(*ELLPmin[bremdescription[[i]]<>"-"<>datbrem[mLLP,\[Theta]LLP][[j]][[1]],Facility]=Evaluate[datbrem[mLLP,\[Theta]LLP][[j]][[3]]];*) +(*\[Theta]maxBrem[bremdescription[[i]]<>"-"<>datbrem[mLLP,\[Theta]LLP][[j]][[1]],Facility]=Evaluate[datbrem[mLLP,\[Theta]LLP][[j]][[4]]];*) +(*ELLPmax[mLLP_,\[Theta]LLP_,bremdescription[[i]]<>"-"<>datbrem[mLLP,\[Theta]LLP][[j]][[1]],Facility]=Evaluate[datbrem[mLLP,\[Theta]LLP][[j]][[5]]];*) +(*,{j,1,Length[datbrem[mLLP,\[Theta]LLP]],1}]*) +(*]*) +(*,{i,1,Length[bremdescription],1}]*) +(*]*) +(*]*) +(*Do[*) +(*BremProd[Facility],{Facility,{"FCC-hh","Serpukhov","SPS","FermilabBD","LHC"}}]*) +(*WeightsCombinations=Keys[DownValues@PmotherToLLP][[All,1,#]]&/@{3,4}//Transpose//Sort*) + + +(* ::Section::Closed:: *) +(*Scanning for tabulated distributions*) + + +(* ::Input:: *) +(*(*Define the file pattern*)*) +(*pattern="DoubleDistr_*_*_*.m";*) +(*(*Search for files matching the pattern in the directory and its subdirectories*)*) +(*matchingFiles=FileNames[pattern,{directory["Distribution"]},Infinity];*) +(*(*List of LLPs, production modes, and facilities for which the tabulated distributions have been computed at the previous stage of using SensCalc*)*) +(*ExtractedProductionParameters=Function[filename,parts=StringSplit[FileNameTake[filename],"_"];*) +(*{parts[[2]],parts[[3]],StringDrop[parts[[4]],-2]} ];*) +(*(*combinations selected LLP, production channel, facility for which the tabulated distributions are present*)*) +(*DistrCombinations=(ExtractedProductionParameters/@matchingFiles)//Sort;*) +(*If[SelectedMixingChoice=="Revised",*) +(*DistrCombinations=Select[DistrCombinations,#[[2]]!="Mixing-Old"&]*) +(*,*) +(*DistrCombinations=Select[DistrCombinations,#[[2]]!="Mixing"&]*) +(*];*) +(*If[MemberQ[DistrCombinations[[All,2]],"Bremsstrahlung-FR"]||MemberQ[DistrCombinations[[All,2]],"Bremsstrahlung-AP"],*) +(*FacilitiesFR=Select[DistrCombinations,StringContainsQ[#[[2]],{"FR"}]&][[All,3]];*) +(*FacilitiesAP=Select[DistrCombinations,StringContainsQ[#[[2]],{"AP"}]&][[All,3]];*) +(*DistrCombinationsToCheck=Select[DistrCombinations,!StringContainsQ[#[[2]],{"FR","AP"}]&];*) +(*DistrCombinationsToCheck=Join[DistrCombinationsToCheck,Flatten[Table[{LLPdirName,brem,fac},{fac,FacilitiesFR},{brem,Select[WeightsCombinations,#[[2]]==fac&&StringContainsQ[#[[1]],"FR"]&][[All,1]]}],1],Flatten[Table[{LLPdirName,brem,fac},{fac,FacilitiesAP},{brem,Select[WeightsCombinations,#[[2]]==fac&&StringContainsQ[#[[1]],"AP"]&][[All,1]]}],1]]//Sort;*) +(*,*) +(*DistrCombinationsToCheck=DistrCombinations*) +(*];*) +(*Print["If there are production weights to all available distributions:"]*) +(*IfCondDistrToWeights=True;*) +(*Do[*) +(*IfCondDistrToWeights=Select[WeightsCombinations,#[[1]]==DistrCombinationsToCheck[[i]][[2]]&&#[[2]]==DistrCombinationsToCheck[[i]][[3]]&]!={};*) +(*If[IfCondDistrToWeights==False,Break[]];*) +(*,{i,1,Length[DistrCombinationsToCheck],1}]*) +(*IfCondDistrToWeights*) +(*If[!IfCondDistrToWeights,infoDialog["You have not provided the production probabilities PmotherToLLP to all the generated tabulated distributions! Please do this first to avoid problems"];]*) + + +(* ::Section::Closed:: *) +(*Decays*) + + +(* ::Input:: *) +(*(*Decay width in GeV*)*) +(*\[CapitalGamma]LLP[mLLP_,\[Alpha]B_]=\[Alpha]B*10^(Interpolation[{Log10[#[[1]]],Log10[#[[2]]]}&/@Import[FileNameJoin[{directory["Decays"],"GammaTotBL.txt"}],"Table"],InterpolationOrder->1][Log10[mLLP]]);*) +(*LogLogPlot[\[CapitalGamma]LLP[mLLP,1],{mLLP,0.05,5},Frame->True,ImageSize->Large]*) +(*(*Decay length*)*) +(*c\[Tau]LLP[mLLP_,\[Alpha]B_]=chbarval/\[CapitalGamma]LLP[mLLP,\[Alpha]B];*) +(*ldecayLLP[mLLP_,\[Alpha]B_,ELLP_]=c\[Tau]LLP[mLLP,\[Alpha]B]*Sqrt[ELLP^2-mLLP^2]/mLLP;*) + + +(* ::Chapter::Closed:: *) +(*Loading necessary routines*) + + +(* ::Input:: *) +(*If[Length[inecessary]==0,*) +(*NotebookEvaluate[FileNameJoin[{NotebookDirectory[],"codes/generic.nb"}]];*) +(*NotebookEvaluate[FileNameJoin[{NotebookDirectory[],"codes/for-sensitivities.nb"}]];*) +(*inecessary={1,2,3};*) +(*]*) + + +(* ::Title::Closed:: *) +(*Specifying the experiment*) + + +(* ::Input:: *) +(*SetDirectory[NotebookDirectory[]];*) +(*(*Parent directory*)*) +(*NotebookDirectory[]//ParentDirectory;*) +(*ExperimentDirectoriesList=Select[FileNames["*",directory["Acceptances"],1],DirectoryQ];*) +(*(*List of available experiments (for which the geometry has been implemented)*)*) +(*ExperimentsListTemp=Table[FileNameTake[ExperimentDirectoriesList[[i]],-1],{i,1,Length[ExperimentDirectoriesList],1}];*) +(*ExperimentsListTemp2=Join[Partition[ExperimentsListTemp,1],Table[{TrueQ@FileExistsQ@FileNameJoin[{directory["Acceptances"],ExperimentsListTemp[[i]],ToString@StringForm["Acceptance_``_for_``.m",Sequence@@{ExperimentsListTemp[[i]],LLPdirName}]}]},{i,1,Length[ExperimentsListTemp]}],2];*) +(*ExperimentsList=Select[ExperimentsListTemp2,#[[2]]==True&][[All,1]]//Sort*) +(*If[Length[ExperimentsList]==0,Print["No experiment is available, generate first the acceptance for the given experiment using module 1"]]*) +(*Print["Selected experiments:"]*) +(*SelectedExperimentList=If[Length[ExperimentsList]!=0,selectionDialog[ExperimentsList,"Select the experiments:"]]*) +(*icounter=1;*) + + +(* ::Chapter::Closed:: *) +(*Running block for next sections*) + + +(* ::Input:: *) +(*BlockEvaluation[tag_]:=Block[{},*) +(*nb=EvaluationNotebook[];*) +(*NotebookFind[nb,tag,All,CellTags];*) +(*SelectionEvaluate[nb]*) +(*]*) +(*If[tagselected=="Number-of-events+sensitivity",*) +(*Do[*) +(*BlockEvaluation["Number-of-events-computation+sensitivity"];*) +(*,{icounter,1,Length[SelectedExperimentList],1}],*) +(*If[tagselected=="Acceptance",*) +(*Do[*) +(*BlockEvaluation["Acceptance-computation"];*) +(*,{icounter,1,Length[SelectedExperimentList],1}]*) +(*]*) +(*]*) + + +(* ::Title::Closed:: *) +(*Number of events*) + + +(* ::Chapter::Closed:: *) +(*Particular experiment*) + + +(* ::Input:: *) +(*SelectedExperiment=SelectedExperimentList[[icounter++]];*) + + +(* ::Chapter::Closed:: *) +(*Cross-sections, acceptances*) + + +(* ::Input:: *) +(*dataAcceptances=Import[FileNameJoin[{FileNameJoin[{directory["Acceptances"],SelectedExperiment,ToString@StringForm["Acceptance_``_for_``.m",Sequence@@{SelectedExperiment,LLPdirName}]}]}],"MX"];//AbsoluteTiming*) +(*{FacilityGivenExperiment,FullAcceptanceData0,BrVis[mLLP_]}=dataAcceptances[[#]]&/@{1,3,5};*) +(*LogLogPlot[Evaluate[BrVis[mLLP]],{mLLP,0.02,10},Frame->True,ImageSize->Large,FrameStyle->Directive[Black, 22],PlotStyle->{{Thickness[0.003],Blue},{Thickness[0.003],Darker@Red},{Thickness[0.003],Darker@Darker@Green},{Thickness[0.003],Black}},GridLines->Automatic,PlotRange->{{0.1,10},{0.01,1.2}},Frame->True,ImageSize->Large,FrameLabel->{"m [GeV]","\!\(\*SubscriptBox[\(Br\), \(vis\)]\)"},PlotLabel-> Style[Row[{"For ",SelectedExperiment}], 20, Black]]*) +(*(*___________________________*)*) +(*(*Interpolation of the tabulated azimuthal acceptance, extracting Subscript[\[Theta], min/max], etc.*)*) +(*(*___________________________*)*) +(*{AzimuthalAcceptanceInt[\[Theta]LLP_,zLLP_],\[Theta]minExpAll,\[Theta]maxExpAll,\[Theta]minExp,\[Theta]maxExp,zminExp,zmaxExp,zmin\[Theta][\[Theta]LLP_],zmax\[Theta][\[Theta]LLP_]}=Block\[Epsilon]Azimuthal[FullAcceptanceData0];*) +(*(*Logarithmized data with full acceptance, and also decay acceptance and full acceptance interpolations*)*) +(*{FullAcceptanceData,DecayAcceptanceInt[mLLP_,\[Theta]LLP_,ELLP_,zLLP_],FullAcceptanceInt[mLLP_,\[Theta]LLP_,ELLP_,zLLP_],InGridm\[Epsilon],InGrid\[Theta]\[Epsilon],InGridE\[Epsilon],InGridz\[Epsilon],\[Epsilon]vals,\[Epsilon]azvals,mmin\[Epsilon],mmax\[Epsilon]}=Block\[Epsilon]Decay[FullAcceptanceData0,zminExp,BrVis];*) +(*CrossSectionData=dataAcceptances[[4]]//Transpose;*) +(*listquantities=((#//ToString)&/@{Npot,PPi0,PEta,PEtapr,POmega,Atarget});*) +(*quantityselector[quantity_]:=Select[CrossSectionData,#[[1]]==quantity&][[1]][[2]]//N;*) +(*{NpotGivenExperiment,ProbMother["Pi0"],ProbMother["Eta"],ProbMother["EtaPr"],ProbMother["Omega"],AtargetVal}=Table[quantityselector[quantity],{quantity,listquantities}]*) +(*(*infoDialog[Row[{"The number of proton collisions is ", NpotGivenExperiment,". You may change it at the stage of computing the sensitivities"}]]*)*) +(*Row[{"Search for dark photons at ", SelectedExperiment, " located at ",FacilityGivenExperiment,". \!\(\*SubscriptBox[\(N\), \(collisions\)]\) = ",NpotGivenExperiment}]*) +(*{{"Quantity","\!\(\*SubscriptBox[\(\[Theta]\), \(min\)]\), rad","\!\(\*SubscriptBox[\(\[Theta]\), \(max\)]\), rad","\!\(\*SubscriptBox[\(\[Theta]\), \(min\)]\)(\!\(\*SubscriptBox[\(\[Epsilon]\), \(dec\)]\)), rad","\!\(\*SubscriptBox[\(\[Theta]\), \(max\)]\)(\!\(\*SubscriptBox[\(\[Epsilon]\), \(dec\)]\)), rad","\!\(\*SubscriptBox[\(z\), \(min\)]\), m","\!\(\*SubscriptBox[\(z\), \(max\)]\), m"},{"Description","Min angle covered by experiment","Max angle covered by experiment","Min angle where \!\(\*SubscriptBox[\(\[Epsilon]\), \(decay\)]\)\[NotEqual]0","Max angle where \!\(\*SubscriptBox[\(\[Epsilon]\), \(decay\)]\)\[NotEqual]0","Min long. displacement of the decay volume","Max long. displacement of the decay volume"},{"Value",\[Theta]minExpAll,\[Theta]maxExpAll,\[Theta]minExp,\[Theta]maxExp,zminExp,zmaxExp}}//TableForm*) + + +(* ::Chapter::Closed:: *) +(*Angle-energy distributions and differential yields for the given experiment*) + + +(* ::Section::Closed:: *) +(*Importing and definitions*) + + +(* ::Subsection::Closed:: *) +(*Specifying production channels*) + + +(* ::Input:: *) +(*(*List of production channels for the selected facility*)*) +(*ProductionPatternSelectedDistr=Select[DistrCombinations,#[[3]]==FacilityGivenExperiment&];*) +(*ProductionPatternSelected=Select[DistrCombinationsToCheck,#[[3]]==FacilityGivenExperiment&];*) +(*ProductionListTemp=ProductionPatternSelected[[All,2]]//DeleteDuplicates;*) +(*(*Selecting only those bremsstrahlung channels for which the distribution is non-zero*)*) +(*BremVariantsGivenFacility=Select[WeightsCombinations[[All,{1,2}]],#[[2]]==FacilityGivenExperiment&&StringContainsQ[#[[1]],"Bremsstrahlung"]&][[All,1]];*) +(*Do[*) +(*ProbMother[channel]=1;*) +(*,{channel,Join[{"DrellYan"},BremVariantsGivenFacility,{"Mixing","Mixing-Old"}]}]*) +(*Print["Production list:"]*) +(*(*Deciding if the bremsstrahlung contributes to the production by comparing Subscript[\[Theta], max,brem] with Subscript[\[Theta], min,experiment]*)*) +(*Do[*) +(*ELLPmax[mLLP_,\[Theta]LLP_,ch]=ELLPmax[mLLP,\[Theta]LLP,ch,FacilityGivenExperiment];*) +(*ELLPmin[ch]=ELLPmin[ch,FacilityGivenExperiment];*) +(*\[Theta]maxBrem[ch]=\[Theta]maxBrem[ch,FacilityGivenExperiment]*) +(*,{ch,BremVariantsGivenFacility}]*) +(*ProdListBrem=Select[ProductionListTemp,StringContainsQ[#,"Bremsstrahlung"]&];*) +(*(*ProdListBremSelected=Select[ProdListBrem,\[Theta]maxBrem[#]>\[Theta]minExp&];*)*) +(*ProdListBremSelected=ProdListBrem;*) +(*ProductionList=Join[ProdListBremSelected,Select[ProductionListTemp,!StringContainsQ[#,"Bremsstrahlung"]&]]*) +(*(*Production list with only baseline bremsstrahlung description*)*) +(*BremSelected="Bremsstrahlung-AP-Central";*) +(*ProductionListBaseline=Select[ProductionList,!StringContainsQ[#,"Bremsstrahlung"]||#==BremSelected&];*) +(*Do[*) +(*If[!MemberQ[ProductionList,_String?(StringContainsQ[#,pattern]&)],*) +(*ProductionPatternSelectedDistr=Select[ProductionPatternSelectedDistr,!StringContainsQ[#[[2]],pattern]&]*) +(*];*) +(*,{pattern,{"AP","Fouroghi-Ritz","Baseline"}}]*) +(*BremVariantsGivenFacility=Select[ProductionList,StringContainsQ[#,"Bremsstrahlung"]&];*) + + +(* ::Subsection::Closed:: *) +(*Importing distributions*) + + +(* ::Input:: *) +(*Do[*) +(*Module[{prod,prodbrem},*) +(*prod=ProductionPatternSelectedDistr[[i]][[2]];*) +(*dirimp=If[StringContainsQ[prod,{"DrellYan","Mixing"}]&&!StringContainsQ[prod,{"Mixing-Old"}],FileNameJoin[{directory["Distribution"],"Pregenerated"}],directory["Distribution"]];*) +(*(*Importing the data with distribution*)*) +(*If[!StringContainsQ[prod,{"AP","FR"}],*) +(*DistrDataImport[prod]=Abs[Import[FileNameJoin[{dirimp,"DoubleDistr_"<>LLPdirName<>"_"<>prod<>"_"<>FacilityGivenExperiment<>".m"}],"MX"]];*) +(*If[prod=="DrellYan",*) +(*DistrDataImport[prod]=Select[DistrDataImport[prod],MinMaxMassesDrellYan[FacilityGivenExperiment][[1]]<=#[[1]]<=MinMaxMassesDrellYan[FacilityGivenExperiment][[2]]&];*) +(*];*) +(*,*) +(*(*If the selected channel is Bremsstrahlung under the description of AP or FR, then there are variants for the description parametrizing the theoretical uncertainty*)*) +(*DistrDataImportTemp[prod]=Import[FileNameJoin[{dirimp,"DoubleDistr_"<>LLPdirName<>"_"<>prod<>"_"<>FacilityGivenExperiment<>".m"}],"MX"];*) +(*Do[*) +(*prodbrem=prod<>"-"<>DistrDataImportTemp[prod][[j]][[1]];*) +(*DistrDataImport[prodbrem]=DistrDataImportTemp[prod][[j]][[2]];*) +(*mlistDistr[prodbrem]=DeleteDuplicates[DistrDataImport[prodbrem][[All,1]]];*) +(*{mLLPmin[prodbrem],mLLPmax[prodbrem]}=MinMax[mlistDistr[prodbrem]];*) +(*,{j,1,Length[DistrDataImportTemp[prod]],1}];*) +(*];*) +(*]*) +(*,{i,1,Length[ProductionPatternSelectedDistr],1}]*) +(*Do[*) +(*Module[{},*) +(*mlistDistr[prod]=DeleteDuplicates[DistrDataImport[prod][[All,1]]];*) +(*{mLLPmin[prod],mLLPmax[prod]}=MinMax[mlistDistr[prod]];*) +(*DoubleDistrLLPint[mLLP_,\[Theta]LLP_,ELLP_,prod]=10^(Interpolation[distrlogComp[DistrDataImport[prod]],InterpolationOrder->1][Log10[mLLP],Log10[\[Theta]LLP],Log10[ELLP]]);*) +(*If[StringContainsQ[prod,"Bremsstrahlung"],*) +(*DoubleDistrLLPint[mLLP_,\[Theta]LLP_,ELLP_,prod]=If[ELLP<=ELLPmax[mLLP,\[Theta]LLP,prod],Evaluate[DoubleDistrLLPint[mLLP,\[Theta]LLP,ELLP,prod]],0.]];*) +(*(*Probability to produce LLP*)*) +(*ProbLLP[mLLP_,finv_,prod]=ProbMother[prod]*PmotherToLLP[mLLP,finv,prod,FacilityGivenExperiment]/.{Atarget->AtargetVal,Yield\[Omega]->ProbMother["Omega"]};*) +(*]*) +(*,{prod,ProductionList}]*) +(*Do[{GridInFinal[prod],DistrVals[prod]}=BlockGridsValsDistr[prod,DistrDataImport],{prod,ProductionList}];//AbsoluteTiming*) +(*(*____________________________*)*) +(*(*Finding Subscript[E, max](Subscript[m, LLP],Subscript[\[Theta], LLP]) for the angular range at the given experiment*)*) +(*(*____________________________*)*) +(*Do[ELLPmax[mfip_,\[Theta]fip_,prod]=EmaxBlock[prod,8,DistrDataImport,FacilityGivenExperiment],{prod,Select[ProductionList,!StringContainsQ[#,"Bremsstrahlung"]&]}]//AbsoluteTiming*) + + +(* ::Subsection::Closed:: *) +(*Exporting averaged distribution*) + + +(* ::Input:: *) +(*directory["Auxiliary-experiment"]=FileNameJoin[{directory["Auxiliary"],SelectedExperiment}];*) +(*If[!DirectoryQ[directory["Auxiliary-experiment"]],CreateDirectory[directory["Auxiliary-experiment"]]];*) +(*Export[FileNameJoin[{directory["Auxiliary-experiment"],"Double-Distr-Averaged-"<>LLPdirName<>".m"}],{Sum[If[mLLPmin[prod]True,ImageSize->Large,PlotLegends->Placed[Style[#,15]&/@ProductionListBaseline,Right]];*) +(*ptprodprob=LogLogPlot[Evaluate[Table[ProbLLP[ma,1,prod],{prod,ProductionListBaseline}]],{ma,mmin\[Epsilon],mmax\[Epsilon]},Frame->True,ImageSize->Large,PlotLegends->Placed[Style[#,16]&/@ProductionListBaseline,{0.2,0.28}], FrameStyle->Directive[Black, 25],PlotRange->{{0.02,3},{10^-4,10^5}},PlotStyle->{{Thick,Blue},{Thick,Darker@Red},{Thick,Darker@Darker@Green},{Thick,Darker@Cyan},{Thick,Magenta},{Thick,Brown}},AspectRatio->0.66,ImageSize->Large,FrameLabel->{"\!\(\*SubscriptBox[\(m\), \(LLP\)]\) [GeV]","\!\(\*SubscriptBox[\(P\), \(prod\)]\)/\!\(\*SubscriptBox[\(\[Alpha]\), \(B\)]\)"},PlotLabel->Style[Row[{"Production probabilities of ",LLPdirName," at ",SelectedExperiment}],18,Black]];*) +(*ptprodprobbrem=LogLogPlot[Evaluate[Table[ProbLLP[ma,1,prod],{prod,BremVariantsGivenFacility}]],{ma,mmin\[Epsilon],mmax\[Epsilon]},Frame->True,ImageSize->Large,PlotLegends->Placed[Style[#,16]&/@BremVariantsGivenFacility,Right], FrameStyle->Directive[Black, 25],PlotRange->{{0.02,2},{0.01,10000}},PlotStyle->{{Thick,Blue},{Thick,Darker@Red},{Thick,Darker@Darker@Green},{Thick,Darker@Cyan},{Thick,Magenta},{Thick,Brown}},AspectRatio->0.66,ImageSize->Large,FrameLabel->{"\!\(\*SubscriptBox[\(m\), \(LLP\)]\) [GeV]","\!\(\*SubscriptBox[\(P\), \(prod\)]\)/\!\(\*SubscriptBox[\(\[Alpha]\), \(B\)]\)"},PlotLabel->Style[Row[{"Production probabilities of ",LLPdirName," at ",SelectedExperiment}],18,Black]];*) +(*Style[Row[{ptprodprob,ptenergies,ptprodprobbrem}],ImageSizeMultipliers->{1, 1,1}]*) + + +(* ::Chapter::Closed:: *) +(*Number of events*) + + +(* ::Section:: *) +(*Number of events - using the mapping method *) + + +(* ::Subsection:: *) +(*Initializing all routines*) + + +(* ::Input:: *) +(*Do[{OutGrid\[Theta]final[prod],\[CapitalDelta]\[Theta]vals[prod]}=OutGrid\[Theta]Temp[InGrid\[Theta]\[Epsilon],30,prod,\[Theta]maxBrem[prod]],{prod,ProductionList}]*) +(*{OutGridzfinal,\[CapitalDelta]zvals}=OutGridszTemp[InGridz\[Epsilon],30,zminExp];*) +(*(*Final energy grid. Mass- and production channel-dependent*)*) +(*If[FacilityGivenExperiment!="ESS",*) +(*StepEtemp[Efip_]=Piecewise[{{0.3,Efip<=2.5},{0.5,2.5"C",RuntimeOptions->"Speed",RuntimeAttributes->{Listable},Parallelization->True]/. DownValues@func//ReleaseHold*) +(*];*) +(*(*Generate a dictionary of compiled functions for each variant*)compiledBremCutter=AssociationThread[BremVariantsGivenFacility,createCompiledFunctionBrem/@BremVariantsGivenFacility];*) +(*BremCut[OutGrid\[Theta]final_,OutGridEfinal_,distr_,mLLP_,bremChoice_]:=Block[{},*) +(*angleenergy=Join[10^Tuples[{OutGrid\[Theta]final,OutGridEfinal}],Partition[distr,1],2];*) +(*compiledFunc=compiledBremCutter[bremChoice];*) +(*compiledFunc[angleenergy,mLLP]*) +(*];*) +(*TableIntegrandDiscret[m_,ProdChannel_,\[Epsilon]DecOp_]:=TableIntegrandDiscretTemp[m,ProdChannel,\[Epsilon]DecOp,\[Epsilon]vals,\[Epsilon]azvals,OutGrid\[Theta]final[ProdChannel],OutGridzfinal,OutGridEnergy,InGridm\[Epsilon],InGrid\[Theta]\[Epsilon],InGridE\[Epsilon],InGridz\[Epsilon],\[CapitalDelta]\[Theta]vals[ProdChannel],\[CapitalDelta]zvals,zminExp,GridInFinal,DistrVals,FacilityGivenExperiment,ELLPmax,\[Theta]minExp]*) + + +(* ::Subsection:: *) +(*Generalized acceptances*) + + +(* ::Input:: *) +(*(*Tabulated acceptance*)*) +(*FactorANUBISceiling=If[SelectedExperiment=="ANUBIS-ceiling",2,1];*) +(*AcceptanceDiscret[m_,ProdChannel_,\[Epsilon]decOp_,decProb_]:=AcceptanceDiscretTemp[m,ProdChannel,\[Epsilon]decOp,decProb,mLLPmin,mmin\[Epsilon],mLLPmax,mmax\[Epsilon],ELLPmax,\[Theta]minExp,TableIntegrandDiscret,BrVis,zmaxExp,zminExp,FactorANUBISceiling,0.]*) +(*Do[mlistAcceptance[prod]=Join[Table[m,{m,1.01Max[mLLPmin[prod],mmin\[Epsilon]],0.95Min[mLLPmax[prod],mmax\[Epsilon]],Min[(0.95Min[mLLPmax[prod],mmax\[Epsilon]]-1.01Max[mLLPmin[prod],mmin\[Epsilon]])/20,2]}],{0.99Min[mLLPmax[prod],mmax\[Epsilon]]}],{prod,ProductionList}];*) +(*Do[*) +(*\[Epsilon]GeomTabs[prod]=ParallelTable[{m,AcceptanceDiscret[m,prod,"False",0],AcceptanceDiscret[m,prod,"True",0],AcceptanceDiscret[m,prod,"False",1],AcceptanceDiscret[m,prod,"True",1]},{m,mlistAcceptance[prod]}];*) +(*\[Epsilon]GeomTabs[prod]=Join[{Join[{Max[mLLPmin[prod],mmin\[Epsilon]]},Drop[\[Epsilon]GeomTabs[prod][[1]],1]]},\[Epsilon]GeomTabs[prod],{Join[{Min[mLLPmax[prod],mmax\[Epsilon]]},Drop[\[Epsilon]GeomTabs[prod][[-1]],1]]}];*) +(*,{prod,ProductionList}];//AbsoluteTiming*) +(*PlotAcc[ProdChannel_]:=ListLogPlot[Evaluate[{\[Epsilon]GeomTabs[ProdChannel][[All,{1,2}]],\[Epsilon]GeomTabs[ProdChannel][[All,{1,3}]],\[Epsilon]GeomTabs[ProdChannel][[All,{1,4}]],\[Epsilon]GeomTabs[ProdChannel][[All,{1,5}]]}],FrameStyle->Directive[Black, 22],PlotStyle->{{Thickness[0.003],Blue},{Thickness[0.003],Darker@Red},{Thickness[0.003],Darker@Darker@Green},{Thickness[0.003],Black}},GridLines->Automatic,PlotRange->{MinMax[\[Epsilon]GeomTabs[ProdChannel][[All,1]]],{Max[0.9Min[Min[\[Epsilon]GeomTabs[ProdChannel][[All,4]]],Min[\[Epsilon]GeomTabs[ProdChannel][[All,3]]]],10^-5],1.1Max[Max[\[Epsilon]GeomTabs[ProdChannel][[All,2]]],Max[\[Epsilon]GeomTabs[ProdChannel][[All,4]]]]}},Joined->True,Frame->True,ImageSize->Large,FrameLabel->{"m [GeV]","Acceptance"},PlotLabel-> Style[Row[{"From ",ProdChannel}], 20, Black],PlotLegends->Placed[{Style[#, 18]&/@{"<\!\(\*SubscriptBox[\(\[Epsilon]\), \(LLP\)]\)>","<\!\(\*SubscriptBox[\(\[Epsilon]\), \(LLP\)]\)\!\(\*SubscriptBox[\(\[Epsilon]\), \(decay\)]\)>","c\[Tau]<\!\(\*SubscriptBox[\(\[Epsilon]\), \(LLP\)]\)\!\(\*SubscriptBox[\(P\), \(decay\)]\)>","c\[Tau]<\!\(\*SubscriptBox[\(\[Epsilon]\), \(LLP\)]\)\!\(\*SubscriptBox[\(P\), \(decay\)]\)\!\(\*SubscriptBox[\(\[Epsilon]\), \(decay\)]\)>"}},{0.75,0.2}]]*) +(*Style[Row[Evaluate[Table[PlotAcc[prod],{prod,ProductionList}]]],ImageSizeMultipliers->{1,1,1,1}]*) +(*(*Do[FilenameAcceptance[prod]=ToString@StringForm["Acceptance_ALP-fermion_at_``_From_``.dat",Sequence@@{SelectedExperiment,ExportList[prod]}];*) +(*Export[FileNameJoin[{NotebookDirectory[],"Auxiliary data/ALPs with fermion coupling",SelectedExperiment,FilenameAcceptance[prod]}],\[Epsilon]GeomTabs[prod][[All,{1,2,4,5}]],"Table"]*) +(*,{prod,ProductionList}]*)*) +(*AccAveraged[mLLP_,c\[Tau]_]=NpotGivenExperiment{Sum[If[mLLPmin[prod]1][mLLP]],0],{prod,ProductionListBaseline}],Sum[If[Max[mLLPmin[prod],mmin\[Epsilon]]1][mLLP]],0],{prod,ProductionListBaseline}],Sum[If[Max[mLLPmin[prod],mmin\[Epsilon]]1][mLLP]],0],{prod,ProductionListBaseline}]};*) +(*Export[FileNameJoin[{directory["Auxiliary-experiment"],"AcceptanceAveraged-"<>LLPdirName<>".m"}],AccAveraged[mLLP,c\[Tau]],"MX"];*) + + +(* ::Subsection::Closed:: *) +(*Rough estimates of the upper and lower bounds*) + + +(* ::Input:: *) +(*Do[LowerBoundEstimate[mLLP_,prod]=((NpotGivenExperiment*ProbLLP[mLLP,1,prod]*Interpolation[\[Epsilon]GeomTabs[prod][[All,{1,5}]],InterpolationOrder->1][mLLP])/(2.3ldecayLLP[mLLP,1,ELLP] mLLP/Sqrt[ELLP^2-mLLP^2]))^(-(1/2));*) +(*UpperBoundEstimate[mLLP_,prod]=(Abs[Re[Evaluate[-(ProductLog[-1,-2.3*b/a]/b)/.{a-> NpotGivenExperiment*ProbLLP[mLLP,1,prod]*Interpolation[\[Epsilon]GeomTabs[prod][[All,{1,3}]],InterpolationOrder->1][mLLP],b->zminExp/ldecayLLP[mLLP,1,ELLPmax[0.5,\[Theta]minExp,prod]]}]]]),{prod,ProductionList}]*) +(*ProdTest=ProductionList[[1]];*) +(*LogLogPlot[Evaluate[{0.3LowerBoundEstimate[mLLP,ProdTest],1.8UpperBoundEstimate[mLLP,ProdTest]}],{mLLP,Max[mLLPmin[ProdTest],mmin\[Epsilon]],Min[mLLPmax[ProdTest],mmax\[Epsilon]]},Frame->True,ImageSize->Large]*) + + +(* ::Subsection::Closed:: *) +(*Number of events - fast*) + + +(* ::Input:: *) +(*FactorLowerBound=If[MemberQ[{"ANUBIS-shaft-volume-1","ANUBIS-shaft-volume-2","ANUBIS-shaft-volume-3"},SelectedExperiment]==True,0.1,0.3];*) +(*NeventsDiscret[m_,ProdChannel_,couplinglist_]:=Module[{NevDiscret,NpotTimes\[Chi]val,zshift},*) +(*If[Max[mLLPmin[ProdChannel],mmin\[Epsilon]]"AdaptiveMonteCarlo"]*) +(*(*IntegralLLP[mLLP_,finv_,ProdChannel_]:=NIntegrate[Abs[IntegrandLLP[mLLP,finv,Exp[\[Theta]LLP],Exp[ELLP],Exp[zLLP],ProdChannel]]Exp[\[Theta]LLP+ELLP+zLLP],{\[Theta]LLP,Log[\[Theta]minExp],Log[\[Theta]maxExp]},{ELLP,Log[mLLP],Log[ELLPmax[mLLP,Exp[\[Theta]LLP],ProdChannel]]},{zLLP,Log[zmin\[Theta][Exp[\[Theta]LLP]]],Log[zmax\[Theta][Exp[\[Theta]LLP]]]},Method\[Rule]"AdaptiveMonteCarlo"]*)*) +(*NeventsInt[mLLP_,coupling_,ProdChannel_]:=If[mLLPmin[ProdChannel]<=mLLP<=mLLPmax[ProdChannel]&&BrVis[mLLP]!=0,If[0.1LowerBoundEstimate[mLLP,ProdChannel]2,"\!\(\*SubscriptBox[\(\[Theta]\), \(X\)]\)"->1,"\!\(\*SubscriptBox[\(z\), \(X\)]\)"->3}]*) +(*\[CapitalDelta]xvals["\!\(\*SubscriptBox[\(E\), \(X\)]\)"]:=\[CapitalDelta]Evals;*) +(*\[CapitalDelta]xvals["\!\(\*SubscriptBox[\(z\), \(X\)]\)"]=\[CapitalDelta]zvals;*) +(*Do[\[CapitalDelta]xvals["\!\(\*SubscriptBox[\(\[Theta]\), \(X\)]\)",prod]=\[CapitalDelta]\[Theta]vals[prod],{prod,ProductionList}];*) +(*LegendX:=Association[{"\!\(\*SubscriptBox[\(E\), \(X\)]\)"->"\!\(\*SubscriptBox[\(E\), \(X\)]\) [GeV]","\!\(\*SubscriptBox[\(\[Theta]\), \(X\)]\)"->"\!\(\*SubscriptBox[\(\[Theta]\), \(X\)]\) [rad]","\!\(\*SubscriptBox[\(z\), \(X\)]\)"-> "\!\(\*SubscriptBox[\(z\), \(X\)]\) [m]"}]*) +(*LegendY:=Association[{"\!\(\*SubscriptBox[\(E\), \(X\)]\)"->"\!\(\*SubscriptBox[\(dN\), \(ev\)]\)/\!\(\*SubscriptBox[\(dE\), \(X\)]\) [\!\(\*SuperscriptBox[\(GeV\), \(-1\)]\)]","\!\(\*SubscriptBox[\(\[Theta]\), \(X\)]\)"->"\!\(\*SubscriptBox[\(dN\), \(ev\)]\)/\!\(\*SubscriptBox[\(d\[Theta]\), \(X\)]\) [\!\(\*SuperscriptBox[\(rad\), \(-1\)]\)]","\!\(\*SubscriptBox[\(z\), \(X\)]\)"-> "\!\(\*SubscriptBox[\(dN\), \(ev\)]\)/\!\(\*SubscriptBox[\(dz\), \(X\)]\) [\!\(\*SuperscriptBox[\(m\), \(-1\)]\)]"}]*) +(*(*Differential number of events*)*) +(*NeventsDifferentialDiscretProd[m_,ProdChannel_,coupling_,Variable_]:=Module[{NpotTimes\[Chi]val},*) +(*ival=iVal[Variable];*) +(*NpotTimes\[Chi]val=NpotGivenExperiment*ProbLLP[m,coupling,ProdChannel];*) +(*tablegrid0=TableIntegrandDiscret[m,ProdChannel,"True"];*) +(*OutGridEfinalTemp=OutGridEnergy[N[m],ProdChannel];*) +(*\[CapitalDelta]Evals=(Rest[10^OutGridEfinalTemp]-Most[10^OutGridEfinalTemp]);*) +(*\[CapitalDelta]xval=\[CapitalDelta]xvals[Variable];*) +(*c\[Tau]Val=c\[Tau]LLP[m,coupling];*) +(*brvis=BrVis[m];*) +(*ilist=DeleteDuplicates[{ival,1,2,3}];*) +(*tablegrid1=SortBy[{#[[ilist[[1]]]],#[[ilist[[2]]]],#[[ilist[[3]]]],#[[4]]}&/@tableGridPrefac[tablegrid0,m,c\[Tau]Val,0.],{#[[1]],#[[2]],#[[3]]}&];*) +(*GridQuantity=tablegrid1[[All,1]]//DeleteDuplicates;*) +(*LengthPerVariable=Length[tablegrid1]/Length[GridQuantity];*) +(*tab1=NdiffCompiled[tablegrid1,GridQuantity,LengthPerVariable,NpotTimes\[Chi]val*brvis];*) +(*Join[tab1[[All,{1}]],Partition[tab1[[All,2]]*\[CapitalDelta]xval^-1,1],2]*) +(*]*) +(*NeventsDifferentialDiscret[m_,coupling_,Variable_]:=Module[{NdiffInt,LegendList,QuantityMinMax,ValueMinMax},*) +(*prodlisttemp={};*) +(*Do[If[Max[mLLPmin[prod],mmin\[Epsilon]]10^-40&][[All,1]]//MinMax;*) +(*NdiffInt[X_,prod]=If[XvalminmaxNdiff[[1]]1][Log10[X]]],0]],{prod,ProductionListBaseline}];*) +(*NdiffInt[X_,"Total"]=Sum[NdiffInt[X,prod],{prod,prodlisttemp}];*) +(*LegendList=Join[{"Total"},prodlisttemp];*) +(*QuantityMinMax=Flatten[Table[MinMax[NdiffData[prod][[All,1]]],{prod,prodlisttemp}],1]//MinMax;*) +(*ValueMinMax=Max[Max[NdiffData[#][[All,2]]]&/@prodlisttemp];*) +(*{Table[NdiffInt[X,prod],{prod,LegendList}],LegendList,QuantityMinMax,ValueMinMax}*) +(*]*) +(*mvaltest=If[FacilityGivenExperiment=="ESS",0.04,0.05];*) +(*couplingvaltest=1.4LowerBoundEstimate[mvaltest,"Pi0"];*) +(*quantity="\!\(\*SubscriptBox[\(E\), \(X\)]\)";*) +(*{NdiffTab[X_],LegendList,QuantityMinMax,ValueMinMax}=NeventsDifferentialDiscret[mvaltest,couplingvaltest,quantity];*) +(*Do[*) +(*prch=LegendList[[i]];*) +(*NdiffInt[X_,prch]=NdiffTab[X][[i]];*) +(*,{i,1,Length[LegendList]}];*) +(*plotdiff=LogLogPlot[Evaluate[Table[NdiffInt[X,prod],{prod,LegendList}]],{X,QuantityMinMax[[1]],QuantityMinMax[[2]]},Frame->True,ImageSize->Large,PlotRange->{All,{10^-5,2ValueMinMax}},PlotStyle->{{Thick,Black},{Thick,Blue},{Thick,Darker@Red},{Thick,Darker@Darker@Green},{Thick,Darker@Cyan},{Thick,Magenta},{Thick,Blue,Dashing[0.02]},{Thick,Darker@Red,Dashing[0.02]},{Thick,Darker@Darker@Green,Dashing[0.02]}},PlotLegends->Placed[Style[#,20]&/@LegendList,Right],FrameLabel->{LegendX[quantity] ,LegendY[quantity]},FrameStyle->Directive[Black, 18],PlotLabel->Style[Row[{SelectedExperiment,". \!\(\*SubscriptBox[\(m\), \(V\)]\) = ",mvaltest," GeV, \!\(\*SubscriptBox[\(\[Alpha]\), \(B\)]\) = ",couplingvaltest//N}],14,Black]]*) + + +(* ::Title::Closed:: *) +(*Exporting tabulated number of events*) + + +(* ::Chapter::Closed:: *) +(*Definitions*) + + +(* ::Input:: *) +(*directory["Nevents"]=FileNameJoin[{NotebookDirectory[],"Tabulated Nevents"}];*) +(*directory["Nevents-LLP"]=FileNameJoin[{NotebookDirectory[],"Tabulated Nevents",LLPdirName}];*) +(*directory["Nevents-LLP-experiment"]=FileNameJoin[{NotebookDirectory[],"Tabulated Nevents",LLPdirName,SelectedExperiment}];*) +(*If[!DirectoryQ[directory[#]],CreateDirectory[directory[#]]]&/@{"Nevents","Nevents-LLP","Nevents-LLP-experiment"};*) +(*Print["Filenames with tabulated \!\(\*SubscriptBox[\(N\), \(events\)]\):"]*) +(*Do[FilenameNeventsInt[prod]=ToString@StringForm["Nevents_``_``_at_``_Npot=``.dat",Sequence@@{LLPdirName,prod,SelectedExperiment,NpotGivenExperiment//CForm//ToString}],{prod,ProductionList}]*) +(*FilenameNeventsInt[#]&/@ProductionList*) +(*Do[mRangeExport[prod]=Join[{0.021,0.03,0.035,0.04,0.045,0.05,0.055,0.06,0.07,0.08,0.09,0.1,0.11,0.12,0.125,0.13,0.14,0.15,0.17,0.2,0.215,0.25,0.3,0.35,0.4,0.45,0.5,0.54,0.55,0.6,0.65,0.7,0.72,0.73,0.74,0.75,0.76,0.77,0.775,0.78,0.785,0.79,0.795,0.8,0.81,0.82,0.84,0.9,0.95,0.97,1,1.005,1.01,1.012,1.015,1.017,1.02,1.025,1.03,1.05,1.07,1.09,1.1,1.2,1.3,1.4,1.5,1.6,1.7,1.8,1.9,2.,2.1,2.2,2.3,2.4,2.5,2.6,2.7,2.8,2.9,3.,3.05,3.1},Table[mLLP,{mLLP,3.21,Max[Table[mLLPmax[prod],{prod,ProductionList}]],(Max[Table[mLLPmax[prod],{prod,ProductionList}]]-3)/20}]]//N*) +(*,{prod,ProductionList}];*) +(*couplingsRangeExport=Table[10^x,{x,-20.8,-6,0.03}]//N;*) + + +(* ::Chapter::Closed:: *) +(*Exporting*) + + +(* ::Section::Closed:: *) +(*Common definition*) + + +(* ::Input:: *) +(*BlockExport[ProdChannel_]:=Module[{mlist},*) +(*mlist=mRangeExport[ProdChannel];*) +(*TabFrom=ParallelTable[Quiet[NeventsDiscret[mlist[[k]],ProdChannel,couplingsRangeExport]],{k,1,Length[mlist],1}];*) +(*Export[FileNameJoin[{directory["Nevents-LLP-experiment"],FilenameNeventsInt[ProdChannel]}],Flatten[TabFrom,1],"Table"]*) +(*]*) +(*Monitor[*) +(*Do[*) +(*prod=ProductionList[[j]];*) +(*BlockExport[prod],{j,1,Length[ProductionList],1}],*) +(*Row[{ProgressIndicator[j,{1,Length[ProductionList]}]," Production mode = ",ProductionList[[j]]," (", j,"/",Length[ProductionList],")"}]]//AbsoluteTiming*) +(*If[icounter>Length[SelectedExperimentList],BlockEvaluation["Sensitivity"]]*) + + +(* ::Title::Closed:: *) +(*Computing sensitivities*) + + +(* ::Chapter::Closed:: *) +(*Basic definitions*) + + +(* ::Input:: *) +(*dropdownDialog[list_,phrase_]:=DialogInput[{choice=""},Column[{TextCell[phrase],PopupMenu[Dynamic[choice],list],Button["OK",DialogReturn[choice]]}]]*) +(*LLPdirName=dropdownDialog[{"B-L","B-3Lmu","B-3Le-Lmu+Ltau","B-Le-3Lmu+Ltau"},"Select the type of the mediator:"]*) +(*directory["Sensitivity"]=FileNameJoin[{NotebookDirectory[],"Sensitivity domains"}];*) +(*directory["Sensitivity-LLP"]=FileNameJoin[{directory["Sensitivity"],LLPdirName}];*) +(*If[!DirectoryQ[directory[#]],CreateDirectory[directory[#]]]&/@{"Sensitivity","Sensitivity-LLP"};*) +(*directory["Nevents-LLP"]=FileNameJoin[{NotebookDirectory[],"Tabulated Nevents",LLPdirName}];*) +(*dropdownDialog[list_,phrase_]:=DialogInput[{choice=""},Column[{TextCell[phrase],PopupMenu[Dynamic[choice],list],Button["OK",DialogReturn[choice]]}]]*) +(*infoDialog[phrase_]:=DialogInput[{choice=""},Column[{TextCell[phrase],Button["Proceed",DialogReturn[choice]]}]]*) +(*selectionDialog[list_,phrase_]:=DialogInput[{choice={}},Column[{Row[{phrase}],Pane[TogglerBar[Dynamic[choice],list,Appearance->"Vertical"->{Automatic,5}],ImageSize->{Automatic,Automatic},Scrollbars->{False,True}],Button["OK",DialogReturn[choice]]}]]*) +(*ExperimentDirectoriesListNevents=Select[FileNames["*",directory["Nevents-LLP"],1],DirectoryQ];*) +(*Print["List of available experiments with tabulated \!\(\*SubscriptBox[\(N\), \(events\)]\) for" <>LLPdirName<>":"]*) +(*ExperimentsListNevents=Table[FileNameTake[ExperimentDirectoriesListNevents[[i]],-1],{i,1,Length[ExperimentDirectoriesListNevents],1}]//Sort;*) +(*ExperimentsListNevents//TableForm*) +(*If[Length[ExperimentsListNevents]==0,Print["No experiment is available, generate first the acceptance for the given experiment using module 1"],*) +(*SelectedExperimentList=If[Length[ExperimentsListNevents]!=0,selectionDialog[ExperimentsListNevents,"Select the experiments for which the sensitivity will be computed:"]];*) +(*icounter=1;*) +(*BlockEvaluation[tag_]:=Block[{},*) +(*nb=EvaluationNotebook[];*) +(*NotebookFind[nb,tag,All,CellTags];*) +(*SelectionEvaluate[nb]*) +(*];*) +(*Do[*) +(*BlockEvaluation["Sensitivity-computation"];*) +(*,{icounter,1,Length[SelectedExperimentList],1}]*) +(*]*) + + +(* ::Chapter::Closed:: *) +(*Specifying the experiment and interpolating tabulated number of events*) + + +(* ::Section::Closed:: *) +(*Selecting the experiment*) + + +(* ::Input:: *) +(*Print["Selected experiment:"]*) +(*GivenExperimentForSensitivityComputation=SelectedExperimentList[[icounter++]]*) +(*CondANUBIS=MemberQ[{"ANUBIS-shaft-volume-1","ANUBIS-shaft-volume-2","ANUBIS-shaft-volume-3"},GivenExperimentForSensitivityComputation];*) +(*If[CondANUBIS==True,infoDialog[Row[{"One of the modules of ANUBIS-shaft is chosen. The full sensitivity includes three modules. The importing will be over all modules, so for all ot the the sensitivity has to be computed"}]]]*) +(*If[CondANUBIS==False,GivenExperimentForSensitivityComputationList={GivenExperimentForSensitivityComputation},GivenExperimentForSensitivityComputationList={"ANUBIS-shaft-volume-1","ANUBIS-shaft-volume-2","ANUBIS-shaft-volume-3"}];*) +(*PathsNeventsSelected={};*) +(*Do[PathsNeventsSelected=Join[PathsNeventsSelected,FileNames["*.dat",FileNameJoin[{directory["Nevents-LLP"],exp}]]],{exp,GivenExperimentForSensitivityComputationList}];*) +(*(*Creating the directory for exporting sensitivity curves*)*) +(*ExperimentFolder=If[CondANUBIS==True,"ANUBIS",GivenExperimentForSensitivityComputation];*) +(*directory["Sensitivity-LLP-exp"]=FileNameJoin[{directory["Sensitivity-LLP"],ExperimentFolder}];*) +(*If[!DirectoryQ[directory["Sensitivity-LLP-exp"]],CreateDirectory[directory["Sensitivity-LLP-exp"]]]*) + + +(* ::Section::Closed:: *) +(*Importing data and interpolations*) + + +(* ::Input:: *) +(*Print["List of production channels:"]*) +(*FilenamesNevents=Table[Last@FileNameSplit@PathsNeventsSelected[[i]],{i,1,Length[PathsNeventsSelected],1}];*) +(*FilenameParameters[i_]:=StringCases[FilenamesNevents[[i]],"Nevents_"<>LLPdirName<>"_"~~mother__~~"_at_"~~experiment__~~"_Npot="~~Npot__~~".dat":>{mother,experiment,Npot}][[1]]*) +(*(*______________________________________________________*)*) +(*(*Importing and interpolation*)*) +(*(*______________________________________________________*)*) +(*ProductionInfoList=Table[FilenameParameters[i],{i,1,Length[FilenamesNevents],1}];*) +(*Join[{{"Mother","Experiment","\!\(\*SubscriptBox[\(N\), \(PoT\)]\)"}},ProductionInfoList]//TableForm*) +(*ProductionChannelsList=ProductionInfoList[[All,1]];*) +(*NpotDefault=Interpreter["Number"][ProductionInfoList[[1]][[3]]];*) +(*NeventsTabulated//Clear;*) +(*\[Epsilon]reco[mLLP_]=If[StringContainsQ[GivenExperimentForSensitivityComputation,"LHCb-downstream"]==True,0.4,1];*) +(*Do[*) +(*Module[{prod},*) +(*prod=ProductionChannelsList[[i]];*) +(*(*The condition if one sums the number of events for the same production mode over several experiments*)*) +(*IfprodExists=MemberQ[Keys[DownValues@NeventsTabulated][[All,1,1]],prod];*) +(*NeventsTabulated[prod]=If[!IfprodExists,Import[PathsNeventsSelected[[i]],"Table"],Join[NeventsTabulated[prod][[All,{1,2}]],NeventsTabulated[prod][[All,{3}]]+Import[PathsNeventsSelected[[i]],"Table"][[All,{3}]]]];*) +(*{mminmax[prod],couplingminmax[prod]}=(NeventsTabulated[prod][[All,#]]//MinMax)&/@{1,2};*) +(*NevMax[prod]=NeventsTabulated[prod][[All,3]]//Max;*) +(*NevInt[mLLP_,\[Alpha]B_,prod]=\[Epsilon]reco[mLLP]*If[mminmax[prod][[1]]<= mLLP<=mminmax[prod][[2]]&&couplingminmax[prod][[1]]<=\[Alpha]B<=couplingminmax[prod][[2]],Evaluate[10^(Interpolation[{Log10[#[[1]]],Log10[#[[2]]],Log10[#[[3]]+10^-90]}&/@NeventsTabulated[prod],InterpolationOrder->1][Log10[mLLP],Log10[\[Alpha]B]])],0];*) +(*]*) +(*,{i,1,Length[ProductionInfoList],1}]*) +(*{mminmaxOverall,couplingminmaxOverall}=MinMax[Table[#[prod],{prod,ProductionChannelsList}]//Flatten]&/@{mminmax,couplingminmax};*) +(*NevMaxOverall=Max[Table[NevMax[prod],{prod,ProductionChannelsList}]];*) + + +(* ::Subsection::Closed:: *) +(*Accounting for various bremsstrahlung descriptions*) + + +(* ::Input:: *) +(*Print["List of various bremsstrahlung channels:"]*) +(*BremChannelsList=Select[ProductionChannelsList,StringContainsQ[#,"Bremsstrahlung"]&]//Sort*) +(*(*Defining the baseline bremsstrahlung setup*)*) +(*BremChannelBaseline="Bremsstrahlung-AP-Central";*) +(*If[BremChannelsList=={},*) +(*ProductionChannelsListUnified=ProductionChannelsList;*) +(*,*) +(*If[MemberQ[BremChannelsList,BremChannelBaseline],*) +(*ProductionChannelsBaseline=Join[Select[ProductionChannelsList,!StringContainsQ[#,"Bremsstrahlung"]&],{BremChannelBaseline}];*) +(*,*) +(*ProductionChannelsBaseline=Join[Select[ProductionChannelsList,!StringContainsQ[#,"Bremsstrahlung"]&],{BremChannelsList[[1]]}]*) +(*];*) +(*ProductionChannelsListUnified=Join[Select[ProductionChannelsList,!StringContainsQ[#,"Bremsstrahlung"]&],{"Bremsstrahlung"}];*) +(*];*) +(*MapThread[(BremNameExportPattern[#1]=#2)&,{("Bremsstrahlung-"<>#)&/@{"FR-Upper","FR-Central","FR-Lower","Baseline","AP-Upper","AP-Central","AP-Lower"},{"FR-Upper","FR-Central","FR-Lower","Baseline","AP-Upper","AP-Central","AP-Lower"}}];*) +(*NevIntOverall[mLLP_,\[Alpha]B_]=Sum[NevInt[mLLP,\[Alpha]B,prod],{prod,ProductionChannelsBaseline}];*) +(*pt[mLLP_]:=LogLogPlot[Evaluate[Table[NevInt[mLLP,y,prod],{prod,ProductionChannelsBaseline}]],{y,couplingminmaxOverall[[1]],couplingminmaxOverall[[2]]},PlotLegends->Placed[Style[#,15]&/@ProductionChannelsBaseline,Right],PlotRange->{couplingminmaxOverall,{10^-2,NevMaxOverall}},Frame->True,ImageSize->Large,FrameLabel->{"\!\(\*SubscriptBox[\(\[Alpha]\), \(B\)]\)" , "\!\(\*SubscriptBox[\(N\), \(events\)]\)[\!\(\*SubscriptBox[\(m\), \(V\)]\),\!\(\*SubscriptBox[\(\[Alpha]\), \(B\)]\)]"},FrameStyle->Directive[Black, 23],PlotStyle->{{Thick,Blue},{Thick,Darker@Red},{Thick,Darker@Darker@Green},{Thick,Black},{Thick,Blue,Dashing[0.02]},{Thick,Darker@Red,Dashing[0.02]},{Thick,Darker@Darker@Green,Dashing[0.02]},{Thick,Black,Dashing[0.02]}},PlotLabel->Style[Row[{ExperimentFolder,". \!\(\*SubscriptBox[\(m\), \(V\)]\) = ",mLLP, " GeV"}],20,Black]]*) +(*pt[0.7]*) + + +(* ::Chapter::Closed:: *) +(*Sensitivity*) + + +(* ::Section::Closed:: *) +(*Events density plot*) + + +(* ::Input:: *) +(*plot=DensityPlot[Evaluate[Log10[NevIntOverall[mLLP,\[Alpha]B]]],{mLLP,mminmaxOverall[[1]],mminmaxOverall[[2]]},{\[Alpha]B,couplingminmaxOverall[[1]],couplingminmaxOverall[[2]]},ScalingFunctions->{"Log","Log"},AspectRatio->0.78,PlotRange->{All,All,{Log10[2.3],Log10[NevMaxOverall]}},ImageSize->Large,FrameLabel->{"\!\(\*SubscriptBox[\(m\), \(V\)]\) [GeV]","\!\(\*SubscriptBox[\(\[Alpha]\), \(B\)]\)"}, Frame-> True, FrameStyle->Directive[Black, 25],PlotPoints->100,PlotLegends->Placed[BarLegend[{Automatic,{Log10[2.3],Log10[NevMaxOverall]}},LegendMarkerSize->340,LegendLabel->Placed["\!\(\*SubscriptBox[\(Log\), \(10\)]\)[\!\(\*SubscriptBox[\(N\), \(ev\)]\)]",Bottom],LabelStyle->{FontSize->22},Method->{FrameStyle->Black,AxesStyle->None,TicksStyle->Black}],Right],PlotLabel->Style[Row[{ExperimentFolder}],20,Black](*,FrameTicks->{{Automatic,Automatic},{TicksPlotx,None}}*)]*) +(*Export[FileNameJoin[{NotebookDirectory[],"plots/SensCalc/NeventsDensityPlotExample.pdf"}],plot,"AllowRasterization"->False]*) + + +(* ::Section:: *) +(*Importing constraints*) + + +(* ::Input:: *) +(*importformat["txt"]=importformat["dat"]="Table";*) +(*importformat["m"]=importformat["mx"]="MX";*) +(*importformat["xls"]="XLS";*) +(*dir=FileNameJoin[{NotebookDirectory[],"contours",LLPdirName}];*) +(*If[DirectoryQ[dir],*) +(*filenames=FileNames[LLPdirName<>"-excluded*",dir,Infinity];*) +(*ExcludedRegions[LLPdirName]=Import[#,importformat[FileExtension[#]]]&/@FileNames[LLPdirName<>"-excluded*",dir,Infinity];*) +(*];*) +(*If[!DirectoryQ[dir],*) +(*ExcludedRegions[LLPdirName]={{{10.,10.}}};*) +(*]*) + + +(* ::Section:: *) +(*Sensitivity evaluation*) + + +(* ::Subsection:: *) +(*Sensitivity calculator block*) + + +(* ::Input:: *) +(*SensitivityExtractor[SelectedProduction_,Npot_,NevMin_]:=Module[{RegSens,SensTemp},*) +(*NevTot[mLLP_,\[Epsilon]2_]=Sum[NevInt[mLLP,\[Epsilon]2,prod],{prod,SelectedProduction}];*) +(*RegSens=RegionPlot[Npot/NpotDefault NevTot[10^mLLP,10^\[Epsilon]2]>=NevMin,{mLLP,Log10[mminmaxOverall[[1]]],Log10[mminmaxOverall[[2]]]},{\[Epsilon]2,Log10[couplingminmaxOverall[[1]]],Log10[couplingminmaxOverall[[2]]]},PlotPoints->300];*) +(*SensTemp=Cases[Normal@RegSens,Line[x_]:>x,Infinity];*) +(*Table[{10^#[[1]],10^#[[2]]}&/@SensTemp[[i]],{i,1,Length[SensTemp],1}]*) +(*]*) +(*SensitivityExtractorBrem[SelectedProduction_,i_,Npot_,NevMin_]:=Module[{bremch,selprod},*) +(*bremch=BremChannelsList[[i]];*) +(*selprod=Join[Select[SelectedProduction,#!="Bremsstrahlung"&],{bremch}];*) +(*{i,selprod,BremNameExportPattern[bremch],SensitivityExtractor[selprod,Npot,NevMin]}*) +(*]*) +(*SensitivityBlock[NevMin_,Npot_,SelectedProduction_]:=Block[{},*) +(*If[!MemberQ[SelectedProduction,"Bremsstrahlung"],*) +(*TabSens={{1,SelectedProduction,"None",SensitivityExtractor[SelectedProduction,Npot,NevMin]}};*) +(*,*) +(*TabSens=Table[SensitivityExtractorBrem[SelectedProduction,i,Npot,NevMin],{i,1,Length[BremChannelsList],1}];*) +(*];*) +(*filenameexport=FileNameJoin[{directory["Sensitivity-LLP-exp"],ToString@StringForm["Sensitivity_``_at_``_Nev=``_Npot=``.",Sequence@@{LLPdirName,ExperimentFolder,NevMin//ToString,N[Npot]//CForm//ToString}]}];*) +(*assocData=Map[Association["Index"->#[[1]],"Production modes"->#[[2]],"Bremsstrahlung description"->#[[3]],"Sensitivity domains"->#[[4]]]&,TabSens];*) +(*Export[filenameexport<>"mx",TabSens,"MX"];*) +(*Export[filenameexport<>"json",assocData,"JSON"];*) +(*(*TabSens*)*) +(*Import[filenameexport<>"mx","MX"]*) +(*]*) + + +(* ::Subsection::Closed:: *) +(*Sensitivity setup and plot*) + + +(* ::Input:: *) +(*productionlist=Join[{"All"},ProductionChannelsListUnified];*) +(*DynamicModule[{input1=NpotDefault,input2=2.3,choice={"All"},list,phrase},*) +(*DialogInput[Column[{Style[ExperimentFolder,Bold],TextCell["Enter the number of proton collisions:"],InputField[Dynamic[input1],Expression],TextCell["Enter the value of N_ev,min for which the sensitivity will be computed:"],InputField[Dynamic[input2],Expression],Row[{"Select the production channels to be used for the sensitivity calculation:"}],Pane[TogglerBar[Dynamic[choice],productionlist,Appearance->"Vertical"->{Automatic,1}],ImageSize->{Automatic,Automatic},Scrollbars->{False,True}],Button["Submit",DialogReturn[{NpotVal,NevMinVal,SelectedProduction}={input1,input2,choice}//N],ImageSize->Automatic]}]]];*) +(*If[MemberQ[SelectedProduction,"All"],SelectedProduction=ProductionChannelsListUnified;]*) +(*{{"\!\(\*SubscriptBox[\(N\), \(PoT\)]\) for computation","\!\(\*SubscriptBox[\(N\), \(ev, min\)]\)","Selected production modes"},{NpotVal,NevMinVal,SelectedProduction}}//TableForm*) +(*sens=SensitivityBlock[NevMinVal,NpotVal,SelectedProduction];*) +(*legends=sens[[All,-2]];*) +(*sensregions=sens[[All,-1]];*) +(*ColorsForPlot={{Thick,Blue},{Thick,Darker@Red},{Thick,Darker@Darker@Green},{Thick,Darker@Cyan},{Thick,Magenta},{Thick, Black},{Thick,Lighter@Brown},{Thick,Lighter@Blue},{Thick,Lighter@Red},{Thick,Lighter@Green},{Thick,Blue,Dashing[0.02]},{Thick,Darker@Red,Dashing[0.02]},{Thick,Darker@Darker@Green,Dashing[0.02]},{Thick,Darker@Cyan,Dashing[0.02]},{Thick,Magenta,Dashing[0.02]},{Thick,Black,Dashing[0.02]},{Thick,Lighter@Brown,Dashing[0.02]},{Thick,Lighter@Blue,Dashing[0.02]},{Thick,Lighter@Red,Dashing[0.02]},{Thick,Lighter@Green,Dashing[0.02]}};*) +(*plotstylelist=Flatten[Table[ConstantArray[ColorsForPlot[[i]],If[MatrixQ[sensregions[[i]]],1,Length@sensregions[[i]]]],{i,1,Length[sensregions],1}],1];*) +(*Show[ListLogLogPlot[Cases[ExcludedRegions[LLPdirName],_?MatrixQ,All],Joined->{True,True,True,True},Frame-> True,FrameLabel->{"\!\(\*SubscriptBox[\(m\), \(V\)]\) [GeV]" , "\!\(\*SubscriptBox[\(\[Alpha]\), \(B\)]\)"},FrameStyle->Directive[Black, 23],PlotStyle->{{Thick,Gray}},Filling->{1->{True,Directive[Gray,Opacity[0.3]]},2->{True,Directive[Gray,Opacity[0.3]]},3->{True,Directive[Gray,Opacity[0.3]]},4->{True,Directive[Gray,Opacity[0.3]]}},ImageSize->Large,PlotRange->{{1.01mminmaxOverall[[1]],1.1mminmaxOverall[[2]]},{0.3Min[Flatten[sensregions]],0.99couplingminmaxOverall[[2]]}},PlotLabel->Style[Row[{"\!\(\*SubscriptBox[\(N\), \(events\)]\) \[GreaterEqual] ",NevMinVal}],18,Black]],*) +(*ListLogLogPlot[Cases[sensregions,_?MatrixQ,All],Joined->{True,True,True,True},PlotStyle->plotstylelist,ImageSize->Large,PlotRange->{{1.01mminmaxOverall[[1]],1.1mminmaxOverall[[2]]},{couplingminmaxOverall[[1]],Max[0.2,0.99couplingminmaxOverall[[2]]]}},PlotLabel->Style[Row[{GivenExperimentForSensitivityComputation,", \!\(\*SubscriptBox[\(N\), \(events\)]\) \[GreaterEqual] ",NevMinVal}],18,Black]],Graphics[{Text[Style["Excluded",24,Black],Scaled[{0.7,0.95}]]}],LogLogPlot[{1,1,1,1,1,1},{x,1,10},PlotStyle->DeleteDuplicates[plotstylelist],ImageSize->Large,PlotRange->{{1.01mminmaxOverall[[1]],1.1mminmaxOverall[[2]]},{couplingminmaxOverall[[1]],Max[0.2,0.99couplingminmaxOverall[[2]]]}},PlotLabel->Style[Row[{GivenExperimentForSensitivityComputation,", \!\(\*SubscriptBox[\(N\), \(events\)]\) \[GreaterEqual] ",NevMinVal}],18,Black],PlotLegends->Placed[Style[#,15]&/@legends,{0.2,0.15}]],Graphics[{Text[Style["Excluded",24,Black],Scaled[{0.7,0.95}]]}]]*) + + +(* ::Title::Closed:: *) +(*Deleting generated cells*) + + +(* ::Input:: *) +(*FrontEndTokenExecute["DeleteGeneratedCells"];*) +(*FrontEndTokenExecute["SelectAll"];*) +(*FrontEndTokenExecute["SelectionCloseAllGroups"];*) diff --git a/wls/3. DP sensitivity.wls b/wls/3. DP sensitivity.wls new file mode 100755 index 0000000..96e589a --- /dev/null +++ b/wls/3. DP sensitivity.wls @@ -0,0 +1,903 @@ +#!/usr/bin/env wolframscript +(* ::Package:: *) + +(* ::Title::Closed:: *) +(*Just launch the code below to run the notebook (shift+enter)*) + + +(* ::Input:: *) +(*ClearAll["Global`*"]*) +(*ParallelEvaluate[ClearAll["Global`*"]];*) +(*BlockEvaluation[tag_]:=Block[{},*) +(*nb=EvaluationNotebook[];*) +(*NotebookFind[nb,tag,All,CellTags];*) +(*SelectionEvaluate[nb]*) +(*]*) +(*CloseKernels[];*) +(*LaunchKernels[];*) +(*dropdownDialog[list_,phrase_]:=DialogInput[{choice=""},Column[{TextCell[phrase],PopupMenu[Dynamic[choice],list],Button["OK",DialogReturn[choice]]}]]*) +(*infoDialog[phrase_]:=DialogInput[{choice=""},Column[{TextCell[phrase],Button["Proceed",DialogReturn[choice]]}]]*) +(*If[(DirectoryQ[FileNameJoin[{NotebookDirectory[],"Auxiliary data"}]]//ToString)=="False",CreateDirectory[FileNameJoin[{NotebookDirectory[],"Auxiliary data"}]]];*) +(*choiceslist={"Tabulated Nevents+sensitivity","Sensitivity only (tabulated Nevents must be produced before)","Acceptance"};*) +(*taglist["Acceptance"]="Acceptance";*) +(*taglist["Tabulated Nevents+sensitivity"]="Number-of-events+sensitivity";*) +(*taglist["Sensitivity only (tabulated Nevents must be produced before)"]="Sensitivity";*) +(*computationchoice=dropdownDialog[choiceslist,"Do you want to compute the tabulated number of events and then sensitivity, or just sensitivity (if the tabulated number of events has been already produced)?"];*) +(*tagselected=taglist[computationchoice]*) +(*BlockEvaluation[tagselected]*) + + +(* ::Title::Closed:: *) +(*Definitions*) + + +(* ::Chapter::Closed:: *) +(*Various directories*) + + +(* ::Input:: *) +(*LLPdirName="DP";*) +(*(*Set the directory for the search where tabulated acceptances are located*)*) +(*directory["Acceptances"]=FileNameJoin[{NotebookDirectory[],"Acceptances"}];*) +(*(*Set the directory for the search where tabulated angle-energy distributions are located*)*) +(*directory["Distribution"]=FileNameJoin[{NotebookDirectory[],"spectra/New physics particles spectra",LLPdirName}]; *) +(*(*The directory storing production weights of the given LLP*)*) +(*directory["Production weights"]=FileNameJoin[{NotebookDirectory[],"phenomenology",LLPdirName,"Production probabilities"}]; *) +(*(*Directory to which various auxillary datasets will be stored*)*) +(*directory["Auxiliary"]=FileNameJoin[{NotebookDirectory[],"Auxiliary data",LLPdirName}]; *) +(*If[!DirectoryQ[directory["Auxiliary"]],CreateDirectory[directory["Auxiliary"]]];*) +(*(*Directory containing decay widths of the LLPs*)*) +(*directory["Decays"]=FileNameJoin[{NotebookDirectory[],"phenomenology",LLPdirName,"decay widths"}]; *) + + +(* ::Chapter::Closed:: *) +(*Parameters and critical definitions*) + + +(* ::Input:: *) +(*dropdownDialog[list_,phrase_]:=DialogInput[{choice=""},Column[{TextCell[phrase],PopupMenu[Dynamic[choice],list],Button["OK",DialogReturn[choice]]}]]*) +(*infoDialog[phrase_]:=DialogInput[{choice=""},Column[{TextCell[phrase],Button["Proceed",DialogReturn[choice]]}]]*) +(*selectionDialog[list_,phrase_]:=DialogInput[{choice={}},Column[{Row[{phrase}],Pane[TogglerBar[Dynamic[choice],list,Appearance->"Vertical"->{Automatic,5}],ImageSize->{Automatic,Automatic},Scrollbars->{False,True}],Button["OK",DialogReturn[choice]]}]]*) +(*(*Conversion units*)*) +(*GeVMinusOneTom=2*10^-16;*) +(*chbarval=3*10^8*6.58*10^-25;*) +(*(*EM coupling*)*) +(*\[Alpha]EM=1/137;*) +(*(*Mesons masses*)*) +(*{mSM["Rho0"],mSM["Pi0"],mSM["Eta"],mSM["EtaPr"],mSM["p"]}={0.775,0.135,0.547,0.958,0.939};*) +(*\[CapitalGamma]SM["\[Rho]780"]=0.149;*) +(*\[Sigma]pNucleonInpb[Atarget_]=51*Atarget^-0.29*10^9;*) + + +(* ::Chapter::Closed:: *) +(*LLP phenomenology: production probabilities, decay widths*) + + +(* ::Section::Closed:: *) +(*Production probabilities*) + + +(* ::Subsection::Closed:: *) +(*Via decays of mesons*) + + +(* ::Input:: *) +(*PmotherToLLP//Clear;*) +(*(*Production from decays of mesons and mixing with \[Rho]^0*)*) +(*Br\[Pi]To\[Gamma]\[Gamma]=0.98799;*) +(*Br\[Eta]To\[Gamma]\[Gamma]=0.3931181;*) +(*(*Br\[Omega]To\[Pi]\[Gamma]=0.0834941;*)*) +(*Br\[Eta]prTo\[Gamma]\[Gamma]=0.0219297;*) +(*Br\[Pi]0ToV[mLLP_]=If[mLLPFacility<>".txt"}],"Table"];*) +(*MinMaxMassesDrellYan[Facility]={Min[dat[[All,1]]],Max[dat[[All,1]]]};*) +(*int[ma_]=If[MinMaxMassesDrellYan[Facility][[1]]<= ma<=MinMaxMassesDrellYan[Facility][[2]],Evaluate[10^(Interpolation[{Log10[#[[1]]],Log10[#[[2]]+10^-90]}&/@dat,InterpolationOrder->1][Log10[ma]])],0];*) +(*PmotherToLLP[mLLP_,\[Epsilon]2_,"DrellYan",Facility]=If[Facility=="SPS",kfactorNLO,1]*\[Epsilon]2*int[mLLP]/\[Sigma]pNucleonInpb[Atarget]*) +(*]*) +(*Do[\[Sigma]DrellYanData[Facility],{Facility,{"SPS","FermilabBD","LHC"}}]*) + + +(* ::Subsection::Closed:: *) +(*Via bremsstrahlung*) + + +(* ::Input:: *) +(**) +(*(*________________*)*) +(*(*Bremsstrahlung*)*) +(*(*________________*)*) +(*BremProd[Facility_]:=Module[{},*) +(*bremprobfiles=FileNames["Pbrem*_"<>Facility<>".m",directory["Production weights"]];*) +(*If[bremprobfiles!={},*) +(*(*Scanning over all available files with the bremsstrahlung probability. They describe different descriptions of the bremsstrahlung*)*) +(*(*Extract the bremsstrahlung description from the filename*)*) +(*bremprobfilenames=Last@FileNameSplit[#]&/@bremprobfiles;*) +(*bremdescription=("Bremsstrahlung-"<>(StringSplit[#,{"Pbrem_"<>LLPdirName<>"_","_"}][[1]])&/@bremprobfilenames);*) +(*Do[*) +(*datbrem[mLLP_,\[Theta]LLP_]=Import[bremprobfiles[[i]],"MX"];*) +(*If[StringContainsQ[bremdescription[[i]],"Baseline"],*) +(*PmotherToLLP[mLLP_,\[Epsilon]2_,bremdescription[[i]],Facility]=datbrem[mLLP,\[Theta]LLP][[1]]*\[Epsilon]2;*) +(*ELLPmin[bremdescription[[i]],Facility]=Evaluate[datbrem[mLLP,\[Theta]LLP][[2]]];*) +(*\[Theta]maxBrem[bremdescription[[i]],Facility]=Evaluate[datbrem[mLLP,\[Theta]LLP][[3]]];*) +(*ELLPmax[mLLP_,\[Theta]LLP_,bremdescription[[i]],Facility]=Evaluate[datbrem[mLLP,\[Theta]LLP][[4]]];*) +(*,*) +(*Do[*) +(*PmotherToLLP[mLLP_,\[Epsilon]2_,bremdescription[[i]]<>"-"<>datbrem[mLLP,\[Theta]LLP][[j]][[1]],Facility]=datbrem[mLLP,\[Theta]LLP][[j]][[2]]*\[Epsilon]2;*) +(*ELLPmin[bremdescription[[i]]<>"-"<>datbrem[mLLP,\[Theta]LLP][[j]][[1]],Facility]=Evaluate[datbrem[mLLP,\[Theta]LLP][[j]][[3]]];*) +(*\[Theta]maxBrem[bremdescription[[i]]<>"-"<>datbrem[mLLP,\[Theta]LLP][[j]][[1]],Facility]=Evaluate[datbrem[mLLP,\[Theta]LLP][[j]][[4]]];*) +(*ELLPmax[mLLP_,\[Theta]LLP_,bremdescription[[i]]<>"-"<>datbrem[mLLP,\[Theta]LLP][[j]][[1]],Facility]=Evaluate[datbrem[mLLP,\[Theta]LLP][[j]][[5]]];*) +(*,{j,1,Length[datbrem[mLLP,\[Theta]LLP]],1}]*) +(*]*) +(*,{i,1,Length[bremdescription],1}]*) +(*]*) +(*]*) +(*Do[*) +(*BremProd[Facility],{Facility,{"FCC-hh","Serpukhov","SPS","FermilabBD","LHC"}}]*) +(**) + + +(* ::Subsection::Closed:: *) +(*Via mixing*) + + +(* ::Input:: *) +(*YieldsMixing[mLLP_]=Import[FileNameJoin[{directory["Production weights"],"Yield-Mixing_DP.mx"}],"MX"];*) +(*(*Old description a-la 2201.05170*)*) +(*(*Mixing angle \[Rho]^0-DP. Following https://arxiv.org/pdf/1810.01879.pdf*)*) +(*g\[Rho]0=5;*) +(*\[Theta]DP\[Rho]02[mLLP_,\[Epsilon]2_]=\[Epsilon]2*(4Pi*\[Alpha]EM)/g\[Rho]0^2 mSM["Rho0"]^4/((mLLP^2-mSM["Rho0"]^2)^2+\[CapitalGamma]SM["\[Rho]780"]^2*mSM["Rho0"]^2);*) +(*Print["Description of the production via mixing"]*) +(*SelectedMixingChoice=dropdownDialog[{"Revised","Old (2201.05170)"},"Select the description of the DP production via mixing with vector mesons:"]*) +(*If[SelectedMixingChoice=="Revised",*) +(*Do[*) +(*PmotherToLLP[mLLP_,\[Epsilon]2_,"Mixing",YieldsMixing[mLLP][[i]][[1]]]=\[Epsilon]2*YieldsMixing[mLLP][[i]][[2]]*) +(*,{i,1,Length[YieldsMixing[mLLP]],1}];*) +(*,*) +(*Do[*) +(*PmotherToLLP[mLLP_,\[Epsilon]2_,"Mixing-Old",facility]=Yield\[Rho]0*\[Theta]DP\[Rho]02[mLLP,\[Epsilon]2]*) +(*,{facility,{"SPS","Serpukhov","FermilabBD","LHC","FCC-hh"}}];*) +(*]*) +(*WeightsCombinations=Keys[DownValues@PmotherToLLP][[All,1,#]]&/@{3,4}//Transpose//Sort;*) + + +(* ::Section::Closed:: *) +(*Scanning for tabulated distributions*) + + +(* ::Input:: *) +(*(*Define the file pattern*)*) +(*pattern="DoubleDistr_*_*_*.m";*) +(*(*Search for files matching the pattern in the directory and its subdirectories*)*) +(*matchingFiles=FileNames[pattern,{directory["Distribution"]},Infinity];*) +(*(*List of LLPs, production modes, and facilities for which the tabulated distributions have been computed at the previous stage of using SensCalc*)*) +(*ExtractedProductionParameters=Function[filename,parts=StringSplit[FileNameTake[filename],"_"];*) +(*{parts[[2]],parts[[3]],StringDrop[parts[[4]],-2]} ];*) +(*(*combinations selected LLP, production channel, facility for which the tabulated distributions are present*)*) +(*DistrCombinations=(ExtractedProductionParameters/@matchingFiles)//Sort;*) +(*If[SelectedMixingChoice=="Revised",*) +(*DistrCombinations=Select[DistrCombinations,#[[2]]!="Mixing-Old"&]*) +(*,*) +(*DistrCombinations=Select[DistrCombinations,#[[2]]!="Mixing"&]*) +(*];*) +(*If[MemberQ[DistrCombinations[[All,2]],"Bremsstrahlung-FR"]||MemberQ[DistrCombinations[[All,2]],"Bremsstrahlung-AP"],*) +(*FacilitiesFR=Select[DistrCombinations,StringContainsQ[#[[2]],{"FR"}]&][[All,3]];*) +(*FacilitiesAP=Select[DistrCombinations,StringContainsQ[#[[2]],{"AP"}]&][[All,3]];*) +(*DistrCombinationsToCheck=Select[DistrCombinations,!StringContainsQ[#[[2]],{"FR","AP"}]&];*) +(*DistrCombinationsToCheck=Join[DistrCombinationsToCheck,Flatten[Table[{LLPdirName,brem,fac},{fac,FacilitiesFR},{brem,Select[WeightsCombinations,#[[2]]==fac&&StringContainsQ[#[[1]],"FR"]&][[All,1]]}],1],Flatten[Table[{LLPdirName,brem,fac},{fac,FacilitiesAP},{brem,Select[WeightsCombinations,#[[2]]==fac&&StringContainsQ[#[[1]],"AP"]&][[All,1]]}],1]]//Sort;*) +(*,*) +(*DistrCombinationsToCheck=DistrCombinations*) +(*];*) +(*IfCondDistrToWeights=True;*) +(*Do[*) +(*IfCondDistrToWeights=Select[WeightsCombinations,#[[1]]==DistrCombinationsToCheck[[i]][[2]]&&#[[2]]==DistrCombinationsToCheck[[i]][[3]]&]!={};*) +(*If[IfCondDistrToWeights==False,Break[]];*) +(*,{i,1,Length[DistrCombinationsToCheck],1}]*) +(*IfCondDistrToWeights*) +(*If[!IfCondDistrToWeights,infoDialog["You have not provided the production probabilities PmotherToLLP to all the generated tabulated distributions! Please do this first to avoid problems"];]*) + + +(* ::Section::Closed:: *) +(*Decays*) + + +(* ::Input:: *) +(*(*Decay width in GeV*)*) +(*\[CapitalGamma]LLP[mLLP_,\[Epsilon]2_]=\[Epsilon]2*10^(Interpolation[{Log10[#[[1]]],Log10[#[[2]]]}&/@Import[FileNameJoin[{directory["Decays"],"GammaDarkPhoton.txt"}],"Table"],InterpolationOrder->1][Log10[mLLP]]);*) +(*(*Decay length*)*) +(*c\[Tau]LLP[mLLP_,\[Epsilon]2_]=chbarval/\[CapitalGamma]LLP[mLLP,\[Epsilon]2];*) +(*ldecayLLP[mLLP_,\[Epsilon]2_,ELLP_]=c\[Tau]LLP[mLLP,\[Epsilon]2]*Sqrt[ELLP^2-mLLP^2]/mLLP;*) +(*\[Epsilon]2val=10^-14;*) +(*LogLogPlot[Evaluate[c\[Tau]LLP[mLLP,10^-14]],{mLLP,0.05,4},Frame->True,ImageSize->Large, FrameStyle->Directive[Black, 22],PlotRange->{{0.05,4},All},PlotStyle->{{Thick,Blue},{Thick,Darker@Red},{Thick,Darker@Darker@Green},{Thick,Darker@Cyan},{Thick,Magenta},{Thick,Brown}},AspectRatio->0.66,ImageSize->Large,FrameLabel->{"\!\(\*SubscriptBox[\(m\), \(V\)]\) [GeV]","\!\(\*SubscriptBox[\(c\[Tau]\), \(V\)]\) [m]"},PlotLabel->Style[Row[{"Proper lifetime of dark photon. \!\(\*SuperscriptBox[\(\[Epsilon]\), \(2\)]\) = ",N[\[Epsilon]2val]}],18,Black]]*) +(**) + + +(* ::Chapter::Closed:: *) +(*Loading necessary routines*) + + +(* ::Input:: *) +(*If[Length[inecessary]==0,*) +(*NotebookEvaluate[FileNameJoin[{NotebookDirectory[],"codes/generic.nb"}]];*) +(*NotebookEvaluate[FileNameJoin[{NotebookDirectory[],"codes/for-sensitivities.nb"}]];*) +(*inecessary={1,2,3};*) +(*]*) + + +(* ::Title::Closed:: *) +(*Specifying the experiment and run next sections*) + + +(* ::Chapter::Closed:: *) +(*Specifying the experiment*) + + +(* ::Input:: *) +(*SetDirectory[NotebookDirectory[]];*) +(*(*Parent directory*)*) +(*NotebookDirectory[]//ParentDirectory;*) +(*ExperimentDirectoriesList=Select[FileNames["*",directory["Acceptances"],1],DirectoryQ];*) +(*(*List of available experiments (for which the geometry has been implemented)*)*) +(*ExperimentsListTemp=Table[FileNameTake[ExperimentDirectoriesList[[i]],-1],{i,1,Length[ExperimentDirectoriesList],1}];*) +(*ExperimentsListTemp2=Join[Partition[ExperimentsListTemp,1],Table[{TrueQ@FileExistsQ@FileNameJoin[{directory["Acceptances"],ExperimentsListTemp[[i]],ToString@StringForm["Acceptance_``_for_``.m",Sequence@@{ExperimentsListTemp[[i]],LLPdirName}]}]},{i,1,Length[ExperimentsListTemp]}],2];*) +(*ExperimentsList=Select[ExperimentsListTemp2,#[[2]]==True&][[All,1]]//Sort*) +(*If[Length[ExperimentsList]==0,Print["No experiment is available, generate first the acceptance for the given experiment using module 1"]]*) +(*Print["Selected experiments:"]*) +(*SelectedExperimentList=If[Length[ExperimentsList]!=0,selectionDialog[ExperimentsList,"Select the experiments:"]]*) +(*icounter=1;*) + + +(* ::Chapter::Closed:: *) +(*Running block for next sections*) + + +(* ::Input:: *) +(*BlockEvaluation[tag_]:=Block[{},*) +(*nb=EvaluationNotebook[];*) +(*NotebookFind[nb,tag,All,CellTags];*) +(*SelectionEvaluate[nb]*) +(*]*) +(*If[tagselected=="Number-of-events+sensitivity",*) +(*Do[*) +(*BlockEvaluation["Number-of-events-computation+sensitivity"];*) +(*,{icounter,1,Length[SelectedExperimentList],1}],*) +(*If[tagselected=="Acceptance",*) +(*Do[*) +(*BlockEvaluation["Acceptance-computation"];*) +(*,{icounter,1,Length[SelectedExperimentList],1}]*) +(*]*) +(*]*) + + +(* ::Title::Closed:: *) +(*Number of events*) + + +(* ::Chapter::Closed:: *) +(*Particular experiment*) + + +(* ::Input:: *) +(*SelectedExperiment=SelectedExperimentList[[icounter++]];*) +(*Print[Row[{"Experiment ",icounter-1,"/",Length[SelectedExperimentList]}]];*) + + +(* ::Chapter::Closed:: *) +(*Cross-sections, acceptances*) + + +(* ::Input:: *) +(*dataAcceptances=Import[FileNameJoin[{FileNameJoin[{directory["Acceptances"],SelectedExperiment,ToString@StringForm["Acceptance_``_for_``.m",Sequence@@{SelectedExperiment,LLPdirName}]}]}],"MX"];//AbsoluteTiming*) +(*{FacilityGivenExperiment,FullAcceptanceData0,BrVis[mLLP_]}=dataAcceptances[[#]]&/@{1,3,5};*) +(*Print["Total branching ratio of visible decays (computed by notebook 1):"]*) +(*LogLogPlot[Evaluate[BrVis[mLLP]],{mLLP,0.02,10},Frame->True,ImageSize->Large,FrameStyle->Directive[Black, 22],PlotStyle->{{Thickness[0.003],Blue},{Thickness[0.003],Darker@Red},{Thickness[0.003],Darker@Darker@Green},{Thickness[0.003],Black}},GridLines->Automatic,PlotRange->{{0.1,10},{0.01,1.2}},Frame->True,ImageSize->Large,FrameLabel->{"m [GeV]","\!\(\*SubscriptBox[\(Br\), \(vis\)]\)"},PlotLabel-> Style[Row[{"For ",SelectedExperiment}], 20, Black]]*) +(*(*___________________________*)*) +(*(*Interpolation of the tabulated azimuthal acceptance, extracting Subscript[\[Theta], min/max], etc.*)*) +(*(*___________________________*)*) +(*{AzimuthalAcceptanceInt[\[Theta]LLP_,zLLP_],\[Theta]minExpAll,\[Theta]maxExpAll,\[Theta]minExp,\[Theta]maxExp,zminExp,zmaxExp,zmin\[Theta][\[Theta]LLP_],zmax\[Theta][\[Theta]LLP_]}=Block\[Epsilon]Azimuthal[FullAcceptanceData0];*) +(*(*Logarithmized data with full acceptance, and also decay acceptance and full acceptance interpolations*)*) +(*{FullAcceptanceData,DecayAcceptanceInt[mLLP_,\[Theta]LLP_,ELLP_,zLLP_],FullAcceptanceInt[mLLP_,\[Theta]LLP_,ELLP_,zLLP_],InGridm\[Epsilon],InGrid\[Theta]\[Epsilon],InGridE\[Epsilon],InGridz\[Epsilon],\[Epsilon]vals,\[Epsilon]azvals,mmin\[Epsilon],mmax\[Epsilon]}=Block\[Epsilon]Decay[FullAcceptanceData0,zminExp,BrVis];*) +(*CrossSectionData=dataAcceptances[[4]]//Transpose;*) +(*listquantities=((#//ToString)&/@{Npot,PPi0,PEta,PEtapr,PRho0,Atarget});*) +(*quantityselector[quantity_]:=Select[CrossSectionData,#[[1]]==quantity&][[1]][[2]]//N;*) +(*{NpotGivenExperiment,ProbMother["Pi0"],ProbMother["Eta"],ProbMother["EtaPr"],ProbMother["Rho0"],AtargetVal}=Table[quantityselector[quantity],{quantity,listquantities}];*) +(*(*infoDialog[Row[{"The number of proton collisions is ", NpotGivenExperiment,". You may change it at the stage of computing the sensitivities"}]]*)*) +(*Row[{"Search for "<>LLPdirName<>" at ", SelectedExperiment, " located at ",FacilityGivenExperiment,". \!\(\*SubscriptBox[\(N\), \(collisions\)]\) = ",NpotGivenExperiment}]*) +(*{{"Quantity","\!\(\*SubscriptBox[\(\[Theta]\), \(min\)]\), rad","\!\(\*SubscriptBox[\(\[Theta]\), \(max\)]\), rad","\!\(\*SubscriptBox[\(\[Theta]\), \(min\)]\)(\!\(\*SubscriptBox[\(\[Epsilon]\), \(dec\)]\)), rad","\!\(\*SubscriptBox[\(\[Theta]\), \(max\)]\)(\!\(\*SubscriptBox[\(\[Epsilon]\), \(dec\)]\)), rad","\!\(\*SubscriptBox[\(z\), \(min\)]\), m","\!\(\*SubscriptBox[\(z\), \(max\)]\), m"},{"Description","Min angle covered by experiment","Max angle covered by experiment","Min angle where \!\(\*SubscriptBox[\(\[Epsilon]\), \(decay\)]\)\[NotEqual]0","Max angle where \!\(\*SubscriptBox[\(\[Epsilon]\), \(decay\)]\)\[NotEqual]0","Min long. displacement of the decay volume","Max long. displacement of the decay volume"},{"Value",\[Theta]minExpAll,\[Theta]maxExpAll,\[Theta]minExp,\[Theta]maxExp,zminExp,zmaxExp}}//TableForm*) + + +(* ::Chapter::Closed:: *) +(*Angle-energy distributions and differential yields for the given experiment*) + + +(* ::Section::Closed:: *) +(*Importing and definitions*) + + +(* ::Subsection::Closed:: *) +(*Specifying production channels*) + + +(* ::Input:: *) +(*(*List of production channels for the selected facility*)*) +(*ProductionPatternSelectedDistr=Select[DistrCombinations,#[[3]]==FacilityGivenExperiment&];*) +(*ProductionPatternSelected=Select[DistrCombinationsToCheck,#[[3]]==FacilityGivenExperiment&];*) +(*ProductionListTemp=ProductionPatternSelected[[All,2]]//DeleteDuplicates;*) +(*(*Selecting only those bremsstrahlung channels for which the distribution is non-zero*)*) +(*BremVariantsGivenFacility=Select[WeightsCombinations[[All,{1,2}]],#[[2]]==FacilityGivenExperiment&&StringContainsQ[#[[1]],"Bremsstrahlung"]&][[All,1]];*) +(*Do[*) +(*ProbMother[channel]=1;*) +(*,{channel,Join[{"DrellYan"},BremVariantsGivenFacility,{"Mixing","Mixing-Old"}]}]*) +(*Print["Production list:"]*) +(*(*Deciding if the bremsstrahlung contributes to the production by comparing Subscript[\[Theta], max,brem] with Subscript[\[Theta], min,experiment]*)*) +(*Do[*) +(*ELLPmax[mLLP_,\[Theta]LLP_,ch]=ELLPmax[mLLP,\[Theta]LLP,ch,FacilityGivenExperiment];*) +(*ELLPmin[ch]=ELLPmin[ch,FacilityGivenExperiment];*) +(*\[Theta]maxBrem[ch]=\[Theta]maxBrem[ch,FacilityGivenExperiment]*) +(*,{ch,BremVariantsGivenFacility}]*) +(*ProdListBrem=Select[ProductionListTemp,StringContainsQ[#,"Bremsstrahlung"]&];*) +(*(*ProdListBremSelected=Select[ProdListBrem,\[Theta]maxBrem[#]>\[Theta]minExp&];*)*) +(*ProdListBremSelected=ProdListBrem;*) +(*ProductionList=Join[ProdListBremSelected,Select[ProductionListTemp,!StringContainsQ[#,"Bremsstrahlung"]&]]*) +(*(*Production list with only baseline bremsstrahlung description*)*) +(*BremSelected="Bremsstrahlung-FR-Central";*) +(*ProductionListBaseline=Select[ProductionList,!StringContainsQ[#,"Bremsstrahlung"]||#==BremSelected&];*) +(*Do[*) +(*If[!MemberQ[ProductionList,_String?(StringContainsQ[#,pattern]&)],*) +(*ProductionPatternSelectedDistr=Select[ProductionPatternSelectedDistr,!StringContainsQ[#[[2]],pattern]&]*) +(*];*) +(*,{pattern,{"AP","Fouroghi-Ritz","Baseline"}}]*) +(*BremVariantsGivenFacility=Select[ProductionList,StringContainsQ[#,"Bremsstrahlung"]&];*) + + +(* ::Subsection::Closed:: *) +(*Importing distributions*) + + +(* ::Input:: *) +(*Do[*) +(*Module[{prod,prodbrem},*) +(*prod=ProductionPatternSelectedDistr[[i]][[2]];*) +(*dirimp=If[StringContainsQ[prod,{"DrellYan","Mixing"}]&&!StringContainsQ[prod,"Mixing-Old"],FileNameJoin[{directory["Distribution"],"Pregenerated"}],directory["Distribution"]];*) +(*(*Importing the data with distribution*)*) +(*If[!StringContainsQ[prod,{"AP","FR"}],*) +(*DistrDataImport[prod]=Abs[Import[FileNameJoin[{dirimp,"DoubleDistr_"<>LLPdirName<>"_"<>prod<>"_"<>FacilityGivenExperiment<>".m"}],"MX"]];*) +(*If[prod=="DrellYan",*) +(*DistrDataImport[prod]=Select[DistrDataImport[prod],MinMaxMassesDrellYan[FacilityGivenExperiment][[1]]<=#[[1]]<=MinMaxMassesDrellYan[FacilityGivenExperiment][[2]]&];*) +(*];*) +(*,*) +(*(*If the selected channel is Bremsstrahlung under the description of AP or FR, then there are variants for the description parametrizing the theoretical uncertainty*)*) +(*DistrDataImportTemp[prod]=Import[FileNameJoin[{dirimp,"DoubleDistr_"<>LLPdirName<>"_"<>prod<>"_"<>FacilityGivenExperiment<>".m"}],"MX"];*) +(*Do[*) +(*prodbrem=prod<>"-"<>DistrDataImportTemp[prod][[j]][[1]];*) +(*DistrDataImport[prodbrem]=DistrDataImportTemp[prod][[j]][[2]];*) +(*mlistDistr[prodbrem]=DeleteDuplicates[DistrDataImport[prodbrem][[All,1]]];*) +(*{mLLPmin[prodbrem],mLLPmax[prodbrem]}=MinMax[mlistDistr[prodbrem]];*) +(*,{j,1,Length[DistrDataImportTemp[prod]],1}];*) +(*];*) +(*]*) +(*,{i,1,Length[ProductionPatternSelectedDistr],1}]*) +(*Do[*) +(*Module[{},*) +(*mlistDistr[prod]=DeleteDuplicates[DistrDataImport[prod][[All,1]]];*) +(*{mLLPmin[prod],mLLPmax[prod]}=MinMax[mlistDistr[prod]];*) +(*DoubleDistrLLPint[mLLP_,\[Theta]LLP_,ELLP_,prod]=10^(Interpolation[distrlogComp[DistrDataImport[prod]],InterpolationOrder->1][Log10[mLLP],Log10[\[Theta]LLP],Log10[ELLP]]);*) +(*If[StringContainsQ[prod,"Bremsstrahlung"],*) +(*DoubleDistrLLPint[mLLP_,\[Theta]LLP_,ELLP_,prod]=If[ELLP<=ELLPmax[mLLP,\[Theta]LLP,prod],Evaluate[DoubleDistrLLPint[mLLP,\[Theta]LLP,ELLP,prod]],0.]];*) +(*(*Probability to produce LLP*)*) +(*ProbLLP[mLLP_,finv_,prod]=ProbMother[prod]*PmotherToLLP[mLLP,finv,prod,FacilityGivenExperiment]/.{Atarget->AtargetVal,Yield\[Rho]0->ProbMother["Rho0"]};*) +(*]*) +(*,{prod,ProductionList}]*) +(*Do[{GridInFinal[prod],DistrVals[prod]}=BlockGridsValsDistr[prod,DistrDataImport],{prod,ProductionList}];//AbsoluteTiming*) +(*(*____________________________*)*) +(*(*Finding Subscript[E, max](Subscript[m, LLP],Subscript[\[Theta], LLP]) for the angular range at the given experiment*)*) +(*(*____________________________*)*) +(*Do[ELLPmax[mfip_,\[Theta]fip_,prod]=EmaxBlock[prod,8,DistrDataImport,FacilityGivenExperiment],{prod,Select[ProductionList,!StringContainsQ[#,"Bremsstrahlung"]&]}]//AbsoluteTiming*) + + +(* ::Subsection::Closed:: *) +(*Exporting averaged distribution*) + + +(* ::Input:: *) +(*directory["Auxiliary-experiment"]=FileNameJoin[{directory["Auxiliary"],SelectedExperiment}];*) +(*If[!DirectoryQ[directory["Auxiliary-experiment"]],CreateDirectory[directory["Auxiliary-experiment"]]];*) +(*Export[FileNameJoin[{directory["Auxiliary-experiment"],"Double-Distr-Averaged-"<>LLPdirName<>".m"}],{Sum[If[mLLPmin[prod]True,ImageSize->Large,PlotLegends->Placed[Style[#,15]&/@ProductionListBaseline,Right]];*) +(*ptprodprob=With[{prl=(ProductionListBaseline/.{"Bremsstrahlung-FR-Central"->"Bremsstrahlung"}//Sort)},LogLogPlot[Evaluate[Table[ProbLLP[ma,1,prod],{prod,Sort[ProductionListBaseline]}]],{ma,mmin\[Epsilon],mmax\[Epsilon]},Frame->True,ImageSize->Large,PlotLegends->Placed[Style[#,16]&/@prl,{0.2,0.28}], FrameStyle->Directive[Black, 25],PlotRange->{{0.02,3},{10^-8,100}},PlotStyle->{{Thick,Blue},{Thick,Darker@Red},{Thick,Darker@Darker@Green},{Thick,Darker@Cyan},{Thick,Magenta},{Thick,Brown}},AspectRatio->0.66,ImageSize->Large,FrameLabel->{"\!\(\*SubscriptBox[\(m\), \(LLP\)]\) [GeV]","\!\(\*SubscriptBox[\(P\), \(prod\)]\)/\!\(\*SuperscriptBox[\(\[Epsilon]\), \(2\)]\)"},PlotLabel->Style[Row[{"Production probabilities of ",LLPdirName," at ",FacilityGivenExperiment}],18,Black]]];*) +(*ptprodprobbrem=With[{prl=Select[BremVariantsGivenFacility,#!="Bremsstrahlung-FR-Central"&]},LogLogPlot[Evaluate[Table[ProbLLP[ma,1,prod],{prod,prl}]],{ma,mmin\[Epsilon],mmax\[Epsilon]},Frame->True,ImageSize->Large,FrameStyle->Directive[Black, 25],PlotRange->{{0.02,2},{10^-8,1000}},PlotStyle->{{Thick,Blue,Dashing[0.01]},{Thick,Lighter@Lighter@Blue},{Thick,Lighter@Lighter@Blue},{Thick,Darker@Cyan},{Thick,Magenta},{Thick,Brown}},AspectRatio->0.66,ImageSize->Large,FrameLabel->{"\!\(\*SubscriptBox[\(m\), \(LLP\)]\) [GeV]","\!\(\*SubscriptBox[\(P\), \(prod\)]\)/\!\(\*SuperscriptBox[\(\[Epsilon]\), \(2\)]\)"},PlotLabel->Style[Row[{"Production probabilities of ",LLPdirName," at ",FacilityGivenExperiment}],18,Black],Filling->{2->{{3},Directive[Lighter@Blue,Opacity[0.1]]}}]];*) +(*Style[Row[{ptenergies,Show[ptprodprob,ptprodprobbrem]}],ImageSizeMultipliers->{1, 1,1}]*) + + +(* ::Chapter::Closed:: *) +(*Number of events*) + + +(* ::Section::Closed:: *) +(*Number of events - using the mapping method *) + + +(* ::Subsection::Closed:: *) +(*Initializing all routines*) + + +(* ::Input:: *) +(*Do[{OutGrid\[Theta]final[prod],\[CapitalDelta]\[Theta]vals[prod]}=OutGrid\[Theta]Temp[InGrid\[Theta]\[Epsilon],30,prod,\[Theta]maxBrem[prod]],{prod,ProductionList}]*) +(*{OutGridzfinal,\[CapitalDelta]zvals}=OutGridszTemp[InGridz\[Epsilon],30,zminExp];*) +(*(*Final energy grid. Mass- and production channel-dependent*)*) +(*If[FacilityGivenExperiment!="ESS",*) +(*StepEtemp[Efip_]=Piecewise[{{0.3,Efip<=2.5},{0.5,2.5"C",RuntimeOptions->"Speed",RuntimeAttributes->{Listable},Parallelization->True]/. DownValues@func//ReleaseHold*) +(*];*) +(*(*Generate a dictionary of compiled functions for each variant*)compiledBremCutter=AssociationThread[BremVariantsGivenFacility,createCompiledFunctionBrem/@BremVariantsGivenFacility];*) +(*BremCut[OutGrid\[Theta]final_,OutGridEfinal_,distr_,mLLP_,bremChoice_]:=Block[{},*) +(*angleenergy=Join[10^Tuples[{OutGrid\[Theta]final,OutGridEfinal}],Partition[distr,1],2];*) +(*compiledFunc=compiledBremCutter[bremChoice];*) +(*compiledFunc[angleenergy,mLLP]*) +(*];*) +(*TableIntegrandDiscret[m_,ProdChannel_,\[Epsilon]DecOp_]:=TableIntegrandDiscretTemp[m,ProdChannel,\[Epsilon]DecOp,\[Epsilon]vals,\[Epsilon]azvals,OutGrid\[Theta]final[ProdChannel],OutGridzfinal,OutGridEnergy,InGridm\[Epsilon],InGrid\[Theta]\[Epsilon],InGridE\[Epsilon],InGridz\[Epsilon],\[CapitalDelta]\[Theta]vals[ProdChannel],\[CapitalDelta]zvals,zminExp,GridInFinal,DistrVals,FacilityGivenExperiment,ELLPmax,\[Theta]minExp]*) + + +(* ::Subsection::Closed:: *) +(*Generalized acceptances*) + + +(* ::Subsubsection::Closed:: *) +(*Definitions*) + + +(* ::Input:: *) +(*(*Tabulated acceptance*)*) +(*FactorANUBISceiling=If[SelectedExperiment=="ANUBIS-ceiling",2,1];*) +(*AcceptanceDiscret[m_,ProdChannel_,\[Epsilon]decOp_,decProb_]:=AcceptanceDiscretTemp[m,ProdChannel,\[Epsilon]decOp,decProb,mLLPmin,mmin\[Epsilon],mLLPmax,mmax\[Epsilon],ELLPmax,\[Theta]minExp,TableIntegrandDiscret,BrVis,zmaxExp,zminExp,FactorANUBISceiling,0.]*) +(*Do[mlistAcceptance[prod]=Join[Table[m,{m,1.01Max[mLLPmin[prod],mmin\[Epsilon]],0.95Min[mLLPmax[prod],mmax\[Epsilon]],Min[(0.95Min[mLLPmax[prod],mmax\[Epsilon]]-1.01Max[mLLPmin[prod],mmin\[Epsilon]])/20,2]}],{0.99Min[mLLPmax[prod],mmax\[Epsilon]]}],{prod,ProductionList}];*) + + +(* ::Subsubsection::Closed:: *) +(*Calculating tabulated acceptances*) + + +(* ::Input:: *) +(**) +(*Do[*) +(*\[Epsilon]GeomTabs[prod]=ParallelTable[{m,AcceptanceDiscret[m,prod,"False",0],AcceptanceDiscret[m,prod,"True",0],AcceptanceDiscret[m,prod,"False",1],AcceptanceDiscret[m,prod,"True",1]},{m,mlistAcceptance[prod]}];*) +(*\[Epsilon]GeomTabs[prod]=Join[{Join[{Max[mLLPmin[prod],mmin\[Epsilon]]},Drop[\[Epsilon]GeomTabs[prod][[1]],1]]},\[Epsilon]GeomTabs[prod],{Join[{Min[mLLPmax[prod],mmax\[Epsilon]]},Drop[\[Epsilon]GeomTabs[prod][[-1]],1]]}];*) +(*,{prod,ProductionList}];//AbsoluteTiming*) +(*PlotAcc[ProdChannel_]:=ListLogPlot[Evaluate[{\[Epsilon]GeomTabs[ProdChannel][[All,{1,2}]],\[Epsilon]GeomTabs[ProdChannel][[All,{1,3}]],\[Epsilon]GeomTabs[ProdChannel][[All,{1,4}]],\[Epsilon]GeomTabs[ProdChannel][[All,{1,5}]]}],FrameStyle->Directive[Black, 22],PlotStyle->{{Thickness[0.003],Blue},{Thickness[0.003],Darker@Red},{Thickness[0.003],Darker@Darker@Green},{Thickness[0.003],Black}},GridLines->Automatic,PlotRange->{MinMax[\[Epsilon]GeomTabs[ProdChannel][[All,1]]],{Max[0.9Min[Min[\[Epsilon]GeomTabs[ProdChannel][[All,4]]],Min[\[Epsilon]GeomTabs[ProdChannel][[All,3]]]],10^-5],1.1Max[Max[\[Epsilon]GeomTabs[ProdChannel][[All,2]]],Max[\[Epsilon]GeomTabs[ProdChannel][[All,4]]]]}},Joined->True,Frame->True,ImageSize->Large,FrameLabel->{"\!\(\*SubscriptBox[\(m\), \(LLP\)]\) [GeV]","Acceptance"},PlotLabel-> Style[Row[{"From ",ProdChannel}], 20, Black],PlotLegends->Placed[{Style[#, 18]&/@{"<\!\(\*SubscriptBox[\(\[Epsilon]\), \(LLP\)]\)>","<\!\(\*SubscriptBox[\(\[Epsilon]\), \(LLP\)]\)\!\(\*SubscriptBox[\(\[Epsilon]\), \(decay\)]\)>","c\[Tau]<\!\(\*SubscriptBox[\(\[Epsilon]\), \(LLP\)]\)\!\(\*SubscriptBox[\(P\), \(decay\)]\)>","c\[Tau]<\!\(\*SubscriptBox[\(\[Epsilon]\), \(LLP\)]\)\!\(\*SubscriptBox[\(P\), \(decay\)]\)\!\(\*SubscriptBox[\(\[Epsilon]\), \(decay\)]\)>"}},{0.75,0.2}]]*) +(*Style[Row[Evaluate[Table[PlotAcc[prod],{prod,ProductionList}]]],ImageSizeMultipliers->{1,1,1,1}]*) +(*(*Do[FilenameAcceptance[prod]=ToString@StringForm["Acceptance_ALP-fermion_at_``_From_``.dat",Sequence@@{SelectedExperiment,ExportList[prod]}];*) +(*Export[FileNameJoin[{NotebookDirectory[],"Auxiliary data/ALPs with fermion coupling",SelectedExperiment,FilenameAcceptance[prod]}],\[Epsilon]GeomTabs[prod][[All,{1,2,4,5}]],"Table"]*) +(*,{prod,ProductionList}]*)*) +(*AccAveraged[mLLP_,c\[Tau]_]=NpotGivenExperiment{Sum[If[mLLPmin[prod]1][mLLP]],0],{prod,ProductionListBaseline}],Sum[If[Max[mLLPmin[prod],mmin\[Epsilon]]1][mLLP]],0],{prod,ProductionListBaseline}],Sum[If[Max[mLLPmin[prod],mmin\[Epsilon]]1][mLLP]],0],{prod,ProductionListBaseline}]};*) +(*Export[FileNameJoin[{directory["Auxiliary-experiment"],"AcceptanceAveraged-"<>LLPdirName<>".m"}],AccAveraged[mLLP,c\[Tau]],"MX"];*) + + +(* ::Subsection::Closed:: *) +(*Rough estimates of the upper and lower bounds*) + + +(* ::Input:: *) +(*Do[LowerBoundEstimate[mLLP_,prod]=((NpotGivenExperiment*ProbLLP[mLLP,1,prod]*Interpolation[\[Epsilon]GeomTabs[prod][[All,{1,5}]],InterpolationOrder->1][mLLP])/(2.3ldecayLLP[mLLP,1,ELLP] mLLP/Sqrt[ELLP^2-mLLP^2]))^(-(1/2));*) +(*UpperBoundEstimate[mLLP_,prod]=(Abs[Re[Evaluate[-(ProductLog[-1,-2.3*b/a]/b)/.{a-> NpotGivenExperiment*ProbLLP[mLLP,1,prod]*Interpolation[\[Epsilon]GeomTabs[prod][[All,{1,3}]],InterpolationOrder->1][mLLP],b->zminExp/ldecayLLP[mLLP,1,ELLPmax[0.5,\[Theta]minExp,prod]]}]]]),{prod,ProductionList}]*) +(*ProdTest=ProductionList[[1]]*) +(*LogLogPlot[Evaluate[{0.3LowerBoundEstimate[mLLP,ProdTest],1.8UpperBoundEstimate[mLLP,ProdTest]}],{mLLP,Max[mLLPmin[ProdTest],mmin\[Epsilon]],Min[mLLPmax[ProdTest],mmax\[Epsilon]]},Frame->True,ImageSize->Large]*) + + +(* ::Subsection::Closed:: *) +(*Number of events - fast*) + + +(* ::Input:: *) +(*FactorLowerBound=If[MemberQ[{"ANUBIS-shaft-volume-1","ANUBIS-shaft-volume-2","ANUBIS-shaft-volume-3"},SelectedExperiment]==True,0.1,0.3];*) +(*NeventsDiscret[m_,ProdChannel_,couplinglist_]:=Module[{NevDiscret,NpotTimes\[Chi]val,zshift},*) +(*If[Max[mLLPmin[ProdChannel],mmin\[Epsilon]]"AdaptiveMonteCarlo"]*) +(*NeventsInt[mLLP_,coupling_,ProdChannel_]:=If[mLLPmin[ProdChannel]<=mLLP<=mLLPmax[ProdChannel]&&BrVis[mLLP]!=0,If[0.1LowerBoundEstimate[mLLP,ProdChannel]"AdaptiveMonteCarlo"]*) +(*NeventsDiffInt[mLLP_,coupling_,ProdChannel_,ELLP_]:=If[mLLPmin[ProdChannel]<=mLLP<=mLLPmax[ProdChannel]&&BrVis[mLLP]!=0&&mLLP2,"\!\(\*SubscriptBox[\(\[Theta]\), \(LLP\)]\)"->1,"\!\(\*SubscriptBox[\(z\), \(LLP\)]\)"->3}]*) +(*\[CapitalDelta]xvals["\!\(\*SubscriptBox[\(E\), \(LLP\)]\)"]:=\[CapitalDelta]Evals;*) +(*\[CapitalDelta]xvals["\!\(\*SubscriptBox[\(z\), \(LLP\)]\)"]=\[CapitalDelta]zvals;*) +(*Do[\[CapitalDelta]xvals["\!\(\*SubscriptBox[\(\[Theta]\), \(X\)]\)",prod]=\[CapitalDelta]\[Theta]vals[prod],{prod,ProductionList}];*) +(*LegendX:=Association[{"\!\(\*SubscriptBox[\(E\), \(LLP\)]\)"->"\!\(\*SubscriptBox[\(E\), \(LLP\)]\) [GeV]","\!\(\*SubscriptBox[\(\[Theta]\), \(LLP\)]\)"->"\!\(\*SubscriptBox[\(\[Theta]\), \(LLP\)]\) [rad]","\!\(\*SubscriptBox[\(z\), \(LLP\)]\)"-> "\!\(\*SubscriptBox[\(z\), \(LLP\)]\) [m]"}]*) +(*LegendY:=Association[{"\!\(\*SubscriptBox[\(E\), \(LLP\)]\)"->"\!\(\*SubscriptBox[\(dN\), \(ev\)]\)/\!\(\*SubscriptBox[\(dE\), \(LLP\)]\) [\!\(\*SuperscriptBox[\(GeV\), \(-1\)]\)]","\!\(\*SubscriptBox[\(\[Theta]\), \(LLP\)]\)"->"\!\(\*SubscriptBox[\(dN\), \(ev\)]\)/\!\(\*SubscriptBox[\(d\[Theta]\), \(LLP\)]\) [\!\(\*SuperscriptBox[\(rad\), \(-1\)]\)]","\!\(\*SubscriptBox[\(z\), \(LLP\)]\)"-> "\!\(\*SubscriptBox[\(dN\), \(ev\)]\)/\!\(\*SubscriptBox[\(dz\), \(LLP\)]\) [\!\(\*SuperscriptBox[\(m\), \(-1\)]\)]"}]*) +(*(*Differential number of events*)*) +(*NeventsDifferentialDiscretProd[m_,ProdChannel_,coupling_,Variable_]:=Module[{NpotTimes\[Chi]val},*) +(*ival=iVal[Variable];*) +(*NpotTimes\[Chi]val=NpotGivenExperiment*ProbLLP[m,coupling,ProdChannel];*) +(*tablegrid0=TableIntegrandDiscret[m,ProdChannel,"True"];*) +(*OutGridEfinalTemp=OutGridEnergy[N[m],ProdChannel];*) +(*\[CapitalDelta]Evals=(Rest[10^OutGridEfinalTemp]-Most[10^OutGridEfinalTemp]);*) +(*\[CapitalDelta]xval=\[CapitalDelta]xvals[Variable];*) +(*c\[Tau]Val=c\[Tau]LLP[m,coupling];*) +(*brvis=BrVis[m];*) +(*ilist=DeleteDuplicates[{ival,1,2,3}];*) +(*tablegrid1=SortBy[{#[[ilist[[1]]]],#[[ilist[[2]]]],#[[ilist[[3]]]],#[[4]]}&/@tableGridPrefac[tablegrid0,m,c\[Tau]Val,0.],{#[[1]],#[[2]],#[[3]]}&];*) +(*GridQuantity=tablegrid1[[All,1]]//DeleteDuplicates;*) +(*LengthPerVariable=Length[tablegrid1]/Length[GridQuantity];*) +(*tab1=NdiffCompiled[tablegrid1,GridQuantity,LengthPerVariable,NpotTimes\[Chi]val*brvis];*) +(*Join[tab1[[All,{1}]],Partition[tab1[[All,2]]*\[CapitalDelta]xval^-1,1],2]*) +(*]*) +(*NeventsDifferentialDiscret[m_,coupling_,Variable_]:=Module[{NdiffInt,LegendList,QuantityMinMax,ValueMinMax},*) +(*prodlisttemp={};*) +(*Do[If[Max[mLLPmin[prod],mmin\[Epsilon]]10^-40&][[All,1]]//MinMax;*) +(*NdiffInt[X_,prod]=If[XvalminmaxNdiff[[1]]1][Log10[X]]],0]],{prod,ProductionListBaseline}];*) +(*NdiffInt[X_,"Total"]=Sum[NdiffInt[X,prod],{prod,prodlisttemp}];*) +(*LegendList=Join[{"Total"},prodlisttemp];*) +(*QuantityMinMax=Flatten[Table[MinMax[NdiffData[prod][[All,1]]],{prod,prodlisttemp}],1]//MinMax;*) +(*ValueMinMax=Max[Max[NdiffData[#][[All,2]]]&/@prodlisttemp];*) +(*{Table[NdiffInt[X,prod],{prod,LegendList}],LegendList,QuantityMinMax,ValueMinMax}*) +(*]*) +(*mvaltest=If[FacilityGivenExperiment=="ESS",0.04,0.3];*) +(*couplingvaltest=2*LowerBoundEstimate[mvaltest,"Eta"];*) +(*quantity="\!\(\*SubscriptBox[\(E\), \(LLP\)]\)";*) +(*{NdiffTab[X_],LegendList,QuantityMinMax,ValueMinMax}=NeventsDifferentialDiscret[mvaltest,couplingvaltest,quantity];*) +(*Do[*) +(*prch=LegendList[[i]];*) +(*NdiffInt[X_,prch]=NdiffTab[X][[i]];*) +(*,{i,1,Length[LegendList]}];*) +(*plotdiff=LogLogPlot[Evaluate[Table[NdiffInt[X,prod],{prod,LegendList}]],{X,QuantityMinMax[[1]],QuantityMinMax[[2]]},Frame->True,ImageSize->Large,PlotRange->{All,{10^-5,2ValueMinMax}},PlotStyle->{{Thick,Black,Dashing[0.02]},{Thick,Lighter@Blue},{Thick,Darker@Red},{Thick,Darker@Darker@Green},{Thick,Darker@Cyan},{Thick,Magenta},{Thick,Lighter@Blue,Dashing[0.02]},{Thick,Darker@Red,Dashing[0.02]},{Thick,Darker@Darker@Green,Dashing[0.02]}},PlotLegends->Placed[Style[#,16]&/@(LegendList/.{"Bremsstrahlung-FR-Central"->"Bremsstrahlung"}),{0.82,0.7}],FrameLabel->{LegendX[quantity] ,LegendY[quantity]},FrameStyle->Directive[Black, 18],PlotLabel->Style[Row[{SelectedExperiment,". \!\(\*SubscriptBox[\(m\), \(LLP\)]\) = ",mvaltest," GeV, \!\(\*SuperscriptBox[\(\[Epsilon]\), \(2\)]\) = ",couplingvaltest//N}],18,Black]]*) + + +(* ::Title::Closed:: *) +(*Exporting tabulated number of events*) + + +(* ::Chapter::Closed:: *) +(*Definitions*) + + +(* ::Input:: *) +(*directory["Nevents"]=FileNameJoin[{NotebookDirectory[],"Tabulated Nevents"}];*) +(*directory["Nevents-LLP"]=FileNameJoin[{NotebookDirectory[],"Tabulated Nevents",LLPdirName}];*) +(*directory["Nevents-LLP-experiment"]=FileNameJoin[{NotebookDirectory[],"Tabulated Nevents",LLPdirName,SelectedExperiment}];*) +(*If[!DirectoryQ[directory[#]],CreateDirectory[directory[#]]]&/@{"Nevents","Nevents-LLP","Nevents-LLP-experiment"};*) +(*Print["Filenames with tabulated \!\(\*SubscriptBox[\(N\), \(events\)]\):"]*) +(*Do[FilenameNeventsInt[prod]=ToString@StringForm["Nevents_``_``_at_``_Npot=``.dat",Sequence@@{LLPdirName,prod,SelectedExperiment,NpotGivenExperiment//CForm//ToString}],{prod,ProductionList}]*) +(*FilenameNeventsInt[#]&/@ProductionList*) +(*Do[mRangeExport[prod]=Join[{0.021,0.026,0.031,0.036,0.041,0.046,0.051,0.056,0.061,0.066,0.07,0.08,0.09,0.1,0.11,0.12,0.125,0.13,0.14,0.15,0.17,0.2,0.215,0.25,0.3,0.35,0.4,0.45,0.46,0.47,0.48,0.5,0.51,0.52,0.53,0.54,0.55,0.575,0.6,0.625,0.65,0.675,0.7,0.72,0.73,0.74,0.75,0.76,0.77,0.775,0.777,0.78,0.782,0.785,0.79,0.795,0.8,0.81,0.82,0.84,0.9,0.95,0.97,1,1.005,1.01,1.012,1.015,1.017,1.018,1.02,1.022,1.023,1.024,1.025,1.03,1.05,1.07,1.09,1.1,1.15,1.2,1.25,1.3,1.35,1.4,1.45,1.475,1.5,1.525,1.55,1.575,1.6,1.62,1.65,1.67,1.7,1.75,1.8,1.85,1.9,1.95,2.,2.05,2.1,2.2,2.3,2.4,2.5,2.6,2.7,2.8,2.9,3.,3.05,3.1,3.2},Table[mLLP,{mLLP,3.21,Max[Table[mLLPmax[prod],{prod,ProductionList}]],(Max[Table[mLLPmax[prod],{prod,ProductionList}]]-3)/20}]]//N*) +(*,{prod,ProductionList}];*) +(*couplingsRangeExport=Table[10^x,{x,-18.8,-6,0.03}]//N;*) + + +(* ::Chapter::Closed:: *) +(*Exporting*) + + +(* ::Input:: *) +(*BlockExport[ProdChannel_]:=Module[{mlist},*) +(*mlist=mRangeExport[ProdChannel];*) +(*TabFrom=ParallelTable[Quiet[NeventsDiscret[mlist[[k]],ProdChannel,couplingsRangeExport]],{k,1,Length[mlist],1}];*) +(*Export[FileNameJoin[{directory["Nevents-LLP-experiment"],FilenameNeventsInt[ProdChannel]}],Flatten[TabFrom,1],"Table"]*) +(*]*) +(*Monitor[*) +(*Do[*) +(*prod=ProductionList[[j]];*) +(*BlockExport[prod],{j,1,Length[ProductionList],1}],*) +(*Row[{ProgressIndicator[j,{1,Length[ProductionList]}]," Production mode = ",ProductionList[[j]]," (", j,"/",Length[ProductionList],")"}]]//AbsoluteTiming*) +(*If[icounter>Length[SelectedExperimentList],BlockEvaluation["Sensitivity"]]*) + + +(* ::Title::Closed:: *) +(*Computing sensitivities*) + + +(* ::Chapter::Closed:: *) +(*Basic definitions*) + + +(* ::Input:: *) +(*LLPdirName="DP";*) +(*directory["Sensitivity"]=FileNameJoin[{NotebookDirectory[],"Sensitivity domains"}];*) +(*directory["Sensitivity-LLP"]=FileNameJoin[{directory["Sensitivity"],LLPdirName}];*) +(*If[!DirectoryQ[directory[#]],CreateDirectory[directory[#]]]&/@{"Sensitivity","Sensitivity-LLP"};*) +(*directory["Nevents-LLP"]=FileNameJoin[{NotebookDirectory[],"Tabulated Nevents",LLPdirName}];*) +(*dropdownDialog[list_,phrase_]:=DialogInput[{choice=""},Column[{TextCell[phrase],PopupMenu[Dynamic[choice],list],Button["OK",DialogReturn[choice]]}]]*) +(*infoDialog[phrase_]:=DialogInput[{choice=""},Column[{TextCell[phrase],Button["Proceed",DialogReturn[choice]]}]]*) +(*selectionDialog[list_,phrase_]:=DialogInput[{choice={}},Column[{Row[{phrase}],Pane[TogglerBar[Dynamic[choice],list,Appearance->"Vertical"->{Automatic,5}],ImageSize->{Automatic,Automatic},Scrollbars->{False,True}],Button["OK",DialogReturn[choice]]}]]*) +(*ExperimentDirectoriesListNevents=Select[FileNames["*",directory["Nevents-LLP"],1],DirectoryQ];*) +(*Print["List of available experiments with tabulated \!\(\*SubscriptBox[\(N\), \(events\)]\) for " <>LLPdirName<>":"]*) +(*ExperimentsListNevents=Table[FileNameTake[ExperimentDirectoriesListNevents[[i]],-1],{i,1,Length[ExperimentDirectoriesListNevents],1}]//Sort;*) +(*ExperimentsListNevents//TableForm*) +(*If[Length[ExperimentsListNevents]==0,Print["No experiment is available, generate first the acceptance for the given experiment using module 1"],*) +(*SelectedExperimentList=If[Length[ExperimentsListNevents]!=0,selectionDialog[ExperimentsListNevents,"Select the experiments for which the sensitivity will be computed:"]];*) +(*icounter=1;*) +(*BlockEvaluation[tag_]:=Block[{},*) +(*nb=EvaluationNotebook[];*) +(*NotebookFind[nb,tag,All,CellTags];*) +(*SelectionEvaluate[nb]*) +(*];*) +(*Do[*) +(*BlockEvaluation["Sensitivity-computation"];*) +(*,{icounter,1,Length[SelectedExperimentList],1}]*) +(*]*) + + +(* ::Chapter::Closed:: *) +(*Specifying the experiment and interpolating tabulated number of events*) + + +(* ::Section::Closed:: *) +(*Selecting the experiment*) + + +(* ::Input:: *) +(*Print["Selected experiment:"]*) +(*GivenExperimentForSensitivityComputation=SelectedExperimentList[[icounter++]]*) +(*CondANUBIS=MemberQ[{"ANUBIS-shaft-volume-1","ANUBIS-shaft-volume-2","ANUBIS-shaft-volume-3"},GivenExperimentForSensitivityComputation];*) +(*If[CondANUBIS==True,infoDialog[Row[{"One of the modules of ANUBIS-shaft is chosen. The full sensitivity includes three modules. The importing will be over all modules, so for all ot the the sensitivity has to be computed"}]]]*) +(*If[CondANUBIS==False,GivenExperimentForSensitivityComputationList={GivenExperimentForSensitivityComputation},GivenExperimentForSensitivityComputationList={"ANUBIS-shaft-volume-1","ANUBIS-shaft-volume-2","ANUBIS-shaft-volume-3"}];*) +(*PathsNeventsSelected={};*) +(*Do[PathsNeventsSelected=Join[PathsNeventsSelected,FileNames["*.dat",FileNameJoin[{directory["Nevents-LLP"],exp}]]],{exp,GivenExperimentForSensitivityComputationList}];*) +(*(*Creating the directory for exporting sensitivity curves*)*) +(*ExperimentFolder=If[CondANUBIS==True,"ANUBIS",GivenExperimentForSensitivityComputation];*) +(*directory["Sensitivity-LLP-exp"]=FileNameJoin[{directory["Sensitivity-LLP"],ExperimentFolder}];*) +(*If[!DirectoryQ[directory["Sensitivity-LLP-exp"]],CreateDirectory[directory["Sensitivity-LLP-exp"]]]*) + + +(* ::Section::Closed:: *) +(*Importing data and interpolations*) + + +(* ::Input:: *) +(*(*______________________________________________________*)*) +(*(*Importing and interpolation*)*) +(*(*______________________________________________________*)*) +(*Print["List of production channels:"]*) +(*FilenamesNeventsSelected=Table[Last@FileNameSplit@PathsNeventsSelected[[i]],{i,1,Length[PathsNeventsSelected],1}];*) +(*FilenameParameters[i_]:=StringCases[FilenamesNeventsSelected[[i]],"Nevents_"<>LLPdirName<>"_"~~mother__~~"_at_"~~experiment__~~"_Npot="~~Npot__~~".dat":>{mother,experiment,Npot}][[1]]*) +(*ProductionInfoList=Table[FilenameParameters[i],{i,1,Length[FilenamesNeventsSelected],1}];*) +(*Join[{{"Mother","Experiment","\!\(\*SubscriptBox[\(N\), \(PoT\)]\)"}},ProductionInfoList]//TableForm*) +(*ProductionChannelsList=ProductionInfoList[[All,1]];*) +(*NpotDefault=Interpreter["Number"][ProductionInfoList[[1]][[3]]];*) +(*NeventsTabulated//Clear;*) +(*\[Epsilon]reco[mLLP_]=1;*) +(*If[StringContainsQ[GivenExperimentForSensitivityComputation,"LHCb-downstream"],*) +(*\[Epsilon]reco[mLLP_]=0.4];*) +(*If[StringContainsQ[GivenExperimentForSensitivityComputation,"NuCal"],*) +(*\[Epsilon]reco[mLLP_]=0.7];*) +(*If[StringContainsQ[GivenExperimentForSensitivityComputation,"CHARM"],*) +(*\[Epsilon]reco[mLLP_]=0.6];*) +(*Do[*) +(*Module[{prod},*) +(*prod=ProductionChannelsList[[i]];*) +(*(*The condition if one sums the number of events for the same production mode over several experiments*)*) +(*IfprodExists=MemberQ[Keys[DownValues@NeventsTabulated][[All,1,1]],prod];*) +(*NeventsTabulated[prod]=If[!IfprodExists,Import[PathsNeventsSelected[[i]],"Table"],Join[NeventsTabulated[prod][[All,{1,2}]],NeventsTabulated[prod][[All,{3}]]+Import[PathsNeventsSelected[[i]],"Table"][[All,{3}]]]];*) +(*{mminmax[prod],couplingminmax[prod]}=(NeventsTabulated[prod][[All,#]]//MinMax)&/@{1,2};*) +(*NevMax[prod]=NeventsTabulated[prod][[All,3]]//Max;*) +(*NevInt[mLLP_,\[Epsilon]2_,prod]=\[Epsilon]reco[mLLP]*If[mminmax[prod][[1]]<= mLLP<=mminmax[prod][[2]]&&couplingminmax[prod][[1]]<=\[Epsilon]2<=couplingminmax[prod][[2]],Evaluate[10^(Interpolation[{Log10[#[[1]]],Log10[#[[2]]],Log10[#[[3]]+10^-90]}&/@NeventsTabulated[prod],InterpolationOrder->1][Log10[mLLP],Log10[\[Epsilon]2]])],0];*) +(*]*) +(*,{i,1,Length[ProductionInfoList],1}]*) +(*{mminmaxOverall,couplingminmaxOverall}=MinMax[Table[#[prod],{prod,ProductionChannelsList}]//Flatten]&/@{mminmax,couplingminmax};*) +(*NevMaxOverall=Max[Table[NevMax[prod],{prod,ProductionChannelsList}]];*) + + +(* ::Subsection::Closed:: *) +(*Accounting for various bremsstrahlung descriptions*) + + +(* ::Input:: *) +(*Print["List of various bremsstrahlung channels:"]*) +(*BremChannelsList=Select[ProductionChannelsList,StringContainsQ[#,"Bremsstrahlung"]&]//Sort*) +(*(*Defining the baseline bremsstrahlung setup*)*) +(*BremChannelBaseline="Bremsstrahlung-FR-Central";*) +(*If[BremChannelsList=={},*) +(*ProductionChannelsListUnified=ProductionChannelsList;*) +(*,*) +(*If[MemberQ[BremChannelsList,BremChannelBaseline],*) +(*ProductionChannelsBaseline=Join[Select[ProductionChannelsList,!StringContainsQ[#,"Bremsstrahlung"]&],{BremChannelBaseline}];*) +(*,*) +(*ProductionChannelsBaseline=Join[Select[ProductionChannelsList,!StringContainsQ[#,"Bremsstrahlung"]&],{BremChannelsList[[1]]}]*) +(*];*) +(*ProductionChannelsListUnified=Join[Select[ProductionChannelsList,!StringContainsQ[#,"Bremsstrahlung"]&],{"Bremsstrahlung"}];*) +(*];*) +(*MapThread[(BremNameExportPattern[#1]=#2)&,{("Bremsstrahlung-"<>#)&/@{"FR-Upper","FR-Central","FR-Lower","Baseline","AP-Upper","AP-Central","AP-Lower"},{"FR-Upper","FR-Central","FR-Lower","Baseline","AP-Upper","AP-Central","AP-Lower"}}];*) +(*NevIntOverall[mLLP_,\[Epsilon]2_]=Sum[NevInt[mLLP,\[Epsilon]2,prod],{prod,ProductionChannelsBaseline}];*) +(*pt[mLLP_]:=LogLogPlot[Evaluate[Table[NevInt[mLLP,y,prod],{prod,ProductionChannelsBaseline}]],{y,couplingminmaxOverall[[1]],couplingminmaxOverall[[2]]},PlotLegends->Placed[Style[#,15]&/@ProductionChannelsBaseline,Right],PlotRange->{couplingminmaxOverall,{10^-2,NevMaxOverall}},Frame->True,ImageSize->Large,FrameLabel->{"\!\(\*SuperscriptBox[\(\[Epsilon]\), \(2\)]\)" , "\!\(\*SubscriptBox[\(N\), \(events\)]\)[\!\(\*SubscriptBox[\(m\), \(V\)]\),\!\(\*SuperscriptBox[\(\[Epsilon]\), \(2\)]\)]"},FrameStyle->Directive[Black, 23],PlotStyle->{{Thick,Blue},{Thick,Darker@Red},{Thick,Darker@Darker@Green},{Thick,Black},{Thick,Blue,Dashing[0.02]},{Thick,Darker@Red,Dashing[0.02]},{Thick,Darker@Darker@Green,Dashing[0.02]},{Thick,Black,Dashing[0.02]}},PlotLabel->Style[Row[{ExperimentFolder,". \!\(\*SubscriptBox[\(m\), \(V\)]\) = ",mLLP, " GeV"}],20,Black]]*) +(*pt[0.7]*) + + +(* ::Chapter::Closed:: *) +(*Sensitivity*) + + +(* ::Section::Closed:: *) +(*Events density plot*) + + +(* ::Input:: *) +(*plot=DensityPlot[Evaluate[Log10[NevIntOverall[mLLP,\[Epsilon]2]]],{mLLP,mminmaxOverall[[1]],mminmaxOverall[[2]]},{\[Epsilon]2,couplingminmaxOverall[[1]],couplingminmaxOverall[[2]]},ScalingFunctions->{"Log","Log"},AspectRatio->0.78,PlotRange->{All,All,{Log10[2.3],Log10[NevMaxOverall]}},ImageSize->Large,FrameLabel->{"\!\(\*SubscriptBox[\(m\), \(V\)]\) [GeV]","\!\(\*SuperscriptBox[\(\[Epsilon]\), \(2\)]\)"}, Frame-> True, FrameStyle->Directive[Black, 25],PlotPoints->100,PlotLegends->Placed[BarLegend[{Automatic,{Log10[2.3],Log10[NevMaxOverall]}},LegendMarkerSize->340,LegendLabel->Placed["\!\(\*SubscriptBox[\(Log\), \(10\)]\)[\!\(\*SubscriptBox[\(N\), \(ev\)]\)]",Bottom],LabelStyle->{FontSize->22},Method->{FrameStyle->Black,AxesStyle->None,TicksStyle->Black}],Right],PlotLabel->Style[Row[{ExperimentFolder}],20,Black](*,FrameTicks->{{Automatic,Automatic},{TicksPlotx,None}}*)]*) +(*Export[FileNameJoin[{NotebookDirectory[],"plots/SensCalc/NeventsDensityPlotExample.pdf"}],plot,"AllowRasterization"->False]*) + + +(* ::Section::Closed:: *) +(*Importing constraints*) + + +(* ::Input:: *) +(*ConstraintsDPtemp=Import[FileNameJoin[{NotebookDirectory[],"contours/DP/constraints-DP.mx"}],"MX"];*) +(*ConstraintsTypeDP=ConstraintsDPtemp[[All,1]]*) +(*Do[*) +(*ExcludedRegions["DP",ConstraintsDPtemp[[i]][[1]]]=ConstraintsDPtemp[[i]][[2]];*) +(*,{i,1,Length[ConstraintsDPtemp],1}]*) + + +(* ::Section::Closed:: *) +(*Sensitivity evaluation*) + + +(* ::Subsection::Closed:: *) +(*Sensitivity calculator block*) + + +(* ::Input:: *) +(*SensitivityExtractor[SelectedProduction_,Npot_,NevMin_]:=Module[{RegSens,SensTemp},*) +(*NevTot[mLLP_,\[Epsilon]2_]=Sum[NevInt[mLLP,\[Epsilon]2,prod],{prod,SelectedProduction}];*) +(*RegSens=RegionPlot[Npot/NpotDefault NevTot[10^mLLP,10^\[Epsilon]2]>=NevMin,{mLLP,Log10[mminmaxOverall[[1]]],Log10[mminmaxOverall[[2]]]},{\[Epsilon]2,Log10[couplingminmaxOverall[[1]]],Log10[couplingminmaxOverall[[2]]]},PlotPoints->300];*) +(*SensTemp=Cases[Normal@RegSens,Line[x_]:>x,Infinity];*) +(*Table[{10^#[[1]],10^#[[2]]}&/@SensTemp[[i]],{i,1,Length[SensTemp],1}]*) +(*]*) +(*SensitivityExtractorBrem[SelectedProduction_,i_,Npot_,NevMin_]:=Module[{bremch,selprod},*) +(*bremch=BremChannelsList[[i]];*) +(*selprod=Join[Select[SelectedProduction,#!="Bremsstrahlung"&],{bremch}];*) +(*{i,selprod,BremNameExportPattern[bremch],SensitivityExtractor[selprod,Npot,NevMin]}*) +(*]*) +(*SensitivityBlock[NevMin_,Npot_,SelectedProduction_]:=Block[{},*) +(*If[!MemberQ[SelectedProduction,"Bremsstrahlung"],*) +(*TabSens={{1,SelectedProduction,"None",SensitivityExtractor[SelectedProduction,Npot,NevMin]}};*) +(*,*) +(*TabSens=Table[SensitivityExtractorBrem[SelectedProduction,i,Npot,NevMin],{i,1,Length[BremChannelsList],1}];*) +(*];*) +(*filenameexport=FileNameJoin[{directory["Sensitivity-LLP-exp"],ToString@StringForm["Sensitivity_``_at_``_Nev=``_Npot=``.",Sequence@@{LLPdirName,ExperimentFolder,NevMin//ToString,N[Npot]//CForm//ToString}]}];*) +(*assocData=Map[Association["Index"->#[[1]],"Production modes"->#[[2]],"Bremsstrahlung description"->#[[3]],"Sensitivity domains"->#[[4]]]&,TabSens];*) +(*Export[filenameexport<>"mx",TabSens,"MX"];*) +(*Export[filenameexport<>"json",assocData,"JSON"];*) +(*(*TabSens*)*) +(*Import[filenameexport<>"mx","MX"]*) +(*]*) + + +(* ::Subsection::Closed:: *) +(*Sensitivity setup and plot*) + + +(* ::Input:: *) +(*productionlist=Join[{"All"},ProductionChannelsListUnified];*) +(*DynamicModule[{input1=NpotDefault,input2=2.3,choice={"All"},list,phrase},*) +(*DialogInput[Column[{Style[ExperimentFolder,Bold],TextCell["Enter the number of proton collisions:"],InputField[Dynamic[input1],Expression],TextCell["Enter the value of N_ev,min for which the sensitivity will be computed:"],InputField[Dynamic[input2],Expression],Row[{"Select the production channels to be used for the sensitivity calculation:"}],Pane[TogglerBar[Dynamic[choice],productionlist,Appearance->"Vertical"->{Automatic,1}],ImageSize->{Automatic,Automatic},Scrollbars->{False,True}],Button["Submit",DialogReturn[{NpotVal,NevMinVal,SelectedProduction}={input1,input2,choice}//N],ImageSize->Automatic]}]]];*) +(*If[MemberQ[SelectedProduction,"All"],SelectedProduction=ProductionChannelsListUnified;]*) +(*{{"\!\(\*SubscriptBox[\(N\), \(PoT\)]\) for computation","\!\(\*SubscriptBox[\(N\), \(ev, min\)]\)","Selected production modes"},{NpotVal,NevMinVal,SelectedProduction}}//TableForm*) +(*sens=SensitivityBlock[NevMinVal,NpotVal,SelectedProduction];*) +(*legends=sens[[All,-2]];*) +(*sensregions=sens[[All,-1]];*) +(*ColorsForPlot={{Thick,Blue},{Thick,Darker@Red},{Thick,Darker@Darker@Green},{Thick,Darker@Cyan},{Thick,Magenta},{Thick, Black},{Thick,Lighter@Brown},{Thick,Lighter@Blue},{Thick,Lighter@Red},{Thick,Lighter@Green},{Thick,Blue,Dashing[0.02]},{Thick,Darker@Red,Dashing[0.02]},{Thick,Darker@Darker@Green,Dashing[0.02]},{Thick,Darker@Cyan,Dashing[0.02]},{Thick,Magenta,Dashing[0.02]},{Thick,Black,Dashing[0.02]},{Thick,Lighter@Brown,Dashing[0.02]},{Thick,Lighter@Blue,Dashing[0.02]},{Thick,Lighter@Red,Dashing[0.02]},{Thick,Lighter@Green,Dashing[0.02]}};*) +(*plotstylelist=Flatten[Table[ConstantArray[ColorsForPlot[[i]],If[MatrixQ[sensregions[[i]]],1,Length@sensregions[[i]]]],{i,1,Length[sensregions],1}],1];*) +(*pt1=Show[*) +(*ListLogLogPlot[Cases[sensregions,_?MatrixQ,All],Joined->{True,True,True,True},Frame-> True,FrameLabel->{"\!\(\*SubscriptBox[\(m\), \(V\)]\) [GeV]" , "\!\(\*SuperscriptBox[\(\[Epsilon]\), \(2\)]\)"},FrameStyle->Directive[Black, 23],PlotStyle->plotstylelist,ImageSize->Large,PlotRange->{{1.01mminmaxOverall[[1]],1.1mminmaxOverall[[2]]},{couplingminmaxOverall[[1]],Max[0.99couplingminmaxOverall[[2]]]}},PlotLabel->Style[Row[{"Bremsstrahlung uncertainty"}],18,Black]],LogLogPlot[{1,1,1,1,1,1},{x,1,10},PlotStyle->DeleteDuplicates[plotstylelist],ImageSize->Large,PlotRange->{{1.01mminmaxOverall[[1]],1.1mminmaxOverall[[2]]},{couplingminmaxOverall[[1]],Max[0.2,0.99couplingminmaxOverall[[2]]]}},PlotLabel->Style[Row[{GivenExperimentForSensitivityComputation,", \!\(\*SubscriptBox[\(N\), \(events\)]\) \[GreaterEqual] ",NevMinVal}],18,Black],PlotLegends->Placed[Style[#,15]&/@legends,{0.75,0.75}]]];*) +(*pt2=Show[ListLogLogPlot[Cases[ExcludedRegions[LLPdirName,"FR-Central"],_?MatrixQ,All],Joined->{True,True,True,True},Frame-> True,FrameLabel->{"\!\(\*SubscriptBox[\(m\), \(V\)]\) [GeV]" , "\!\(\*SuperscriptBox[\(\[Epsilon]\), \(2\)]\)"},FrameStyle->Directive[Black, 23],PlotStyle->{{Thick,Gray}},Filling->Table[i->{True,Directive[Gray,Opacity[0.3]]},{i,1,10,1}],ImageSize->Large,PlotRange->{{1.01mminmaxOverall[[1]],1.1mminmaxOverall[[2]]},{0.3Min[Flatten[sensregions]],0.99couplingminmaxOverall[[2]]}},PlotLabel->Style[Row[{GivenExperimentForSensitivityComputation,", \!\(\*SubscriptBox[\(N\), \(events\)]\) \[GreaterEqual] ",NevMinVal}],18,Black]],*) +(*ListLogLogPlot[Cases[sensregions[[2]],_?MatrixQ,All],Joined->{True,True,True,True},PlotStyle->plotstylelist,ImageSize->Large,PlotRange->{{1.01mminmaxOverall[[1]],1.1mminmaxOverall[[2]]},{couplingminmaxOverall[[1]],Max[0.2,0.99couplingminmaxOverall[[2]]]}}],Graphics[{Text[Style["Excluded",24,Black],Scaled[{0.2,0.5}]]}],LogLogPlot[{1,1,1,1,1,1},{x,1,10},PlotStyle->DeleteDuplicates[plotstylelist],ImageSize->Large,PlotRange->{{1.01mminmaxOverall[[1]],1.1mminmaxOverall[[2]]},{couplingminmaxOverall[[1]],Max[0.2,0.99couplingminmaxOverall[[2]]]}},PlotLabel->Style[Row[{GivenExperimentForSensitivityComputation,", \!\(\*SubscriptBox[\(N\), \(events\)]\) \[GreaterEqual] ",NevMinVal}],18,Black],PlotLegends->Placed[Style[#,15]&/@{legends[[2]]},{0.2,0.15}]]];*) +(*Style[Row[{pt2,pt1}]]*) + + +(* ::Input:: *) +(* *) + + +(* ::Input:: *) +(**) + + +(* ::Title::Closed:: *) +(*Deleting generated cells*) + + +(* ::Input:: *) +(*FrontEndTokenExecute["DeleteGeneratedCells"];*) +(*FrontEndTokenExecute["SelectAll"];*) +(*FrontEndTokenExecute["SelectionCloseAllGroups"];*) diff --git a/wls/3. HNL sensitivity.wls b/wls/3. HNL sensitivity.wls new file mode 100755 index 0000000..5c26246 --- /dev/null +++ b/wls/3. HNL sensitivity.wls @@ -0,0 +1,757 @@ +#!/usr/bin/env wolframscript +(* ::Package:: *) + +(* ::Title::Closed:: *) +(*Just launch the code below to run the notebook (shift+enter)*) + + +(* ::Input:: *) +(*ClearAll["Global`*"]*) +(*ParallelEvaluate[ClearAll["Global`*"]];*) +(*BlockEvaluation[tag_]:=Block[{},*) +(*nb=EvaluationNotebook[];*) +(*NotebookFind[nb,tag,All,CellTags];*) +(*SelectionEvaluate[nb]*) +(*]*) +(*CloseKernels[];*) +(*LaunchKernels[];*) +(*dropdownDialog[list_,phrase_]:=DialogInput[{choice=""},Column[{TextCell[phrase],PopupMenu[Dynamic[choice],list],Button["OK",DialogReturn[choice]]}]]*) +(*infoDialog[phrase_]:=DialogInput[{choice=""},Column[{TextCell[phrase],Button["Proceed",DialogReturn[choice]]}]]*) +(*If[(DirectoryQ[FileNameJoin[{NotebookDirectory[],"Auxiliary data"}]]//ToString)=="False",CreateDirectory[FileNameJoin[{NotebookDirectory[],"Auxiliary data"}]]];*) +(*choiceslist={"Tabulated Nevents+sensitivity","Sensitivity only (tabulated Nevents must be produced before)","Acceptance"};*) +(*taglist["Acceptance"]="Acceptance";*) +(*taglist["Tabulated Nevents+sensitivity"]="Number-of-events+sensitivity";*) +(*taglist["Sensitivity only (tabulated Nevents must be produced before)"]="Sensitivity";*) +(*computationchoice=dropdownDialog[choiceslist,"Do you want to compute the tabulated number of events and then sensitivity, or just sensitivity (if the tabulated number of events has been already produced)?"];*) +(*tagselected=taglist[computationchoice]*) +(*BlockEvaluation[tagselected]*) + + +(* ::Title::Closed:: *) +(*Preliminary definitions (launch first)*) + + +(* ::Chapter::Closed:: *) +(*Various directories*) + + +(* ::Input:: *) +(*LLPdirName="HNL";*) +(*(*Set the directory for the search where tabulated acceptances are located*)*) +(*directory["Acceptances"]=FileNameJoin[{NotebookDirectory[],"Acceptances"}];*) +(*(*Set the directory for the search where tabulated angle-energy distributions are located*)*) +(*directory["Distribution"]=FileNameJoin[{NotebookDirectory[],"spectra/New physics particles spectra",LLPdirName}]; *) +(*(*The directory storing production weights of the given LLP*)*) +(*directory["Production weights"]=FileNameJoin[{NotebookDirectory[],"phenomenology",LLPdirName,"Production probabilities"}]; *) +(*(*Directory to which various auxillary datasets will be stored*)*) +(*directory["Auxiliary"]=FileNameJoin[{NotebookDirectory[],"Auxiliary data",LLPdirName}]; *) +(*If[!DirectoryQ[directory["Auxiliary"]],CreateDirectory[directory["Auxiliary"]]];*) +(*(*Directory containing decay widths of the LLPs*)*) +(*directory["Decays"]=FileNameJoin[{NotebookDirectory[],"phenomenology",LLPdirName,"decay widths"}]; *) + + +(* ::Chapter::Closed:: *) +(*Parameters and various functions*) + + +(* ::Input:: *) +(*dropdownDialog[list_,phrase_]:=DialogInput[{choice=""},Column[{TextCell[phrase],PopupMenu[Dynamic[choice],list],Button["OK",DialogReturn[choice]]}]]*) +(*infoDialog[phrase_]:=DialogInput[{choice=""},Column[{TextCell[phrase],Button["Proceed",DialogReturn[choice]]}]]*) +(*(*chbar*)*) +(*chbar= 6.6*10^-25*3*10^8;*) +(*(*Masses of various SM particles*)*) +(*{mSM["e"],mSM["mu"],mSM["tau"]}={0.5*10^-3,0.105,1.77};*) +(*{mSM["W"],mSM["Z"]} = {80.369,91.1876};*) +(*{mSM["e"],mSM["mu"],mSM["PiCharged"]}={0.5*10^-3,0.105,0.139};*) + + +(* ::Chapter::Closed:: *) +(*LLP phenomenology: prodution probabilities, decay widths*) + + +(* ::Section::Closed:: *) +(*Scanning for tabulated distributions*) + + +(* ::Input:: *) +(*(*Define the file pattern*)*) +(*pattern="DoubleDistr_*_*_*.m";*) +(*(*Search for files matching the pattern in the directory and its subdirectories*)*) +(*matchingFiles=FileNames[pattern,{directory["Distribution"]},Infinity];*) +(*(*List of LLPs, production modes, and facilities for which the tabulated distributions have been computed at the previous stage of using SensCalc*)*) +(*ExtractedProductionParameters=Function[filename,parts=StringSplit[FileNameTake[filename],"_"];*) +(*{parts[[2]],parts[[3]],StringDrop[parts[[4]],-2]} ];*) +(*(*Apply the function to each file in the list*)*) +(*DistrCombinations=(ExtractedProductionParameters/@matchingFiles)//Sort;*) +(*HNLsList={"HNL-mixing-e","HNL-mixing-mu","HNL-mixing-tau"};*) +(*(DistrCombinations[[All,1]]//DeleteDuplicates//Sort)==HNLsList*) + + +(* ::Section::Closed:: *) +(*Production weights*) + + +(* ::Input:: *) +(*(*For mesons: \!\( *) +(*\*SubscriptBox[\(\[Sum]\), \(meson\)]\( *) +(*\*SubscriptBox[\(f\), \(q \[Rule] meson\)]*Br\((meson \[Rule] N)\)\ at\ *) +(*\*SuperscriptBox[\(U\), \(2\)]\)\) = 1*)*) +(*(*For X = W/Z: Br(X->N) at U^2 = 1*)*) +(*ProductionWeightsTemp[mN_]=Import[FileNameJoin[{directory["Production weights"],"ProductionWeightsHNL.m"}],"MX"];*) +(*Do[*) +(*Module[{hnl,prod,facility},*) +(*{hnl,prod,facility}=ProductionWeightsTemp[mLLP][[i]][[#]]&/@{1,2,3};*) +(*ProdMotherToLLP[mLLP_,U2_,hnl,prod,facility]=U2*ProductionWeightsTemp[mLLP][[i]][[4]];*) +(*]*) +(*,{i,1,Length[ProductionWeightsTemp[mLLP]],1}]*) +(*WeightsCombinations=ProductionWeightsTemp[mLLP][[All,{1,2,3}]]//Sort;*) +(*WeightsCombinations=Cases[WeightsCombinations,_?(MemberQ[DistrCombinations,#]&)];*) +(*IfCondDistrToWeights=DistrCombinations==WeightsCombinations;*) +(*If[!IfCondDistrToWeights,infoDialog["You have not provided the production probabilities PmotherToLLP to all the generated tabulated distributions! Please do this first to avoid problems"];]*) + + +(* ::Section::Closed:: *) +(*Decay width*) + + +(* ::Input:: *) +(*\[CapitalGamma]table=Import[FileNameJoin[{directory["Decays"],"HNLdecayWidth.dat"}],"Table"];*) +(*{DecayWidth[mLLP_,U2_,HNLsList[[1]]],DecayWidth[mLLP_,U2_,HNLsList[[2]]],DecayWidth[mLLP_,U2_,HNLsList[[3]]]}=U2(10^Interpolation[{#[[1]],Log10[#[[2]]+10^-99]}&/@\[CapitalGamma]table[[All,{1,#}]],InterpolationOrder->1][mLLP])&/@{2,3,4};*) +(*LogLogPlot[Evaluate[DecayWidth[mLLP,1,"HNL-mixing-"<>#]&/@{"e","mu","tau"}],{mLLP,0.1,10},Frame->True,ImageSize->Large]*) +(**) + + +(* ::Chapter::Closed:: *) +(*Loading necessary routines*) + + +(* ::Input:: *) +(*If[Length[inecessary]==0,*) +(*NotebookEvaluate[FileNameJoin[{NotebookDirectory[],"codes/generic.nb"}]];*) +(*NotebookEvaluate[FileNameJoin[{NotebookDirectory[],"codes/for-sensitivities.nb"}]];*) +(*inecessary={1,2,3};*) +(*]*) + + +(* ::Title::Closed:: *) +(*Specifying the experiment and HNL*) + + +(* ::Chapter::Closed:: *) +(*HNL*) + + +(* ::Input:: *) +(*ListHNLtype={"Dirac","Majorana"};*) +(*HNLtype=dropdownDialog[ListHNLtype,"Select the HNL type:"];*) +(*Print["HNL type:"]*) +(*HNLtype*) +(*{MixingPatterne,MixingPattern\[Mu],MixingPattern\[Tau]}=DialogInput[{pattern={1.,0.,0.}},Column[{"Enter the mixing pattern \!\(\*SubscriptBox[SuperscriptBox[\(U\), \(2\)], \(e\)]\):\!\(\*SubscriptBox[SuperscriptBox[\(U\), \(2\)], \(\[Mu]\)]\):\!\(\*SubscriptBox[SuperscriptBox[\(U\), \(2\)], \(\[Tau]\)]\) = \!\(\*SuperscriptBox[\(U\), \(2\)]\)(\!\(\*SubscriptBox[\(x\), \(e\)]\):\!\(\*SubscriptBox[\(x\), \(\[Mu]\)]\):\!\(\*SubscriptBox[\(x\), \(\[Tau]\)]\)) (where \!\(\*SubscriptBox[\(\[CapitalSigma]\), \(i\)]\)\!\(\*SubscriptBox[\(x\), \(i\)]\) = 1) in the form {xe,x\[Mu],x\[Tau]}:",InputField[Dynamic[pattern],Expression],Button["Proceed",DialogReturn[pattern],ImageSize->Automatic]}]]//N;*) +(*Print["Mixing pattern:"]*) +(*MixingPattern=(MixingPatterne+MixingPattern\[Mu]+MixingPattern\[Tau])^-1 {MixingPatterne,MixingPattern\[Mu],MixingPattern\[Tau]}//N*) +(*\[CapitalGamma]LLP[mLLP_,U2_]=If[HNLtype=="Dirac",1/2,1](DecayWidth[mLLP,U2,#]&/@HNLsList) . MixingPattern//Chop*) +(*c\[Tau]LLP[mLLP_,U2_]=chbar/\[CapitalGamma]LLP[mLLP,U2];*) +(*ldecayLLP[mLLP_,U2_,EN_]=Sqrt[EN^2-mLLP^2]/mLLP*c\[Tau]LLP[mLLP,U2];*) + + +(* ::Chapter::Closed:: *) +(*Experiments*) + + +(* ::Input:: *) +(*ExperimentDirectoriesList=Select[FileNames["*",directory["Acceptances"],1],DirectoryQ];*) +(*(*List of the experiments for which any tabulated acceptance has been produced*)*) +(*ExperimentsListTemp=Table[FileNameTake[ExperimentDirectoriesList[[i]],-1],{i,1,Length[ExperimentDirectoriesList],1}];*) +(*IfHNL[exp_]:=Module[{},*) +(*expf=FileNameJoin[{directory["Acceptances"],exp}];*) +(*tabEx=FileExistsQ[FileNameJoin[{expf,"Acceptance_"<>exp<>"_for_"<>#<>".m"}]]&/@HNLsList;*) +(*!MemberQ[tabEx,False]*) +(*]*) +(*ExperimentsList=Select[ExperimentsListTemp,IfHNL[#]&]//Sort*) +(*If[Length[ExperimentsList]==0,Print["No experiment is available, generate first the acceptance for the given experiment using module 1"]]*) +(*Print["Selected experiments:"]*) +(*dropdownDialog[list_,phrase_]:=DialogInput[{choice=""},Column[{TextCell[phrase],PopupMenu[Dynamic[choice],list],Button["OK",DialogReturn[choice]]}]]*) +(*selectionDialog[list_,phrase_]:=DialogInput[{choice={}},Column[{Row[{"Select the experiments for which the number of events will be computed:"}],Pane[TogglerBar[Dynamic[choice],list,Appearance->"Vertical"->{Automatic,5}],ImageSize->{Automatic,Automatic},Scrollbars->{False,True}],Button["OK",DialogReturn[choice]]}]]*) +(*SelectedExperimentList=If[Length[ExperimentsList]!=0,selectionDialog[ExperimentsList,"Select the experiments:"]]*) +(*icounter=1;*) +(**) + + +(* ::Chapter::Closed:: *) +(*Running block for next sections*) + + +(* ::Input:: *) +(*BlockEvaluation[tag_]:=Block[{},*) +(*nb=EvaluationNotebook[];*) +(*NotebookFind[nb,tag,All,CellTags];*) +(*SelectionEvaluate[nb]*) +(*]*) +(*If[tagselected=="Number-of-events+sensitivity",*) +(*Do[*) +(*BlockEvaluation["Number-of-events-computation+sensitivity"];*) +(*,{icounter,1,Length[SelectedExperimentList],1}],*) +(*If[tagselected=="Acceptance",*) +(*Do[*) +(*BlockEvaluation["Acceptance-computation"];*) +(*,{icounter,1,Length[SelectedExperimentList],1}]*) +(*]*) +(*]*) + + +(* ::Title::Closed:: *) +(*Number of events*) + + +(* ::Chapter::Closed:: *) +(*Particular experiment*) + + +(* ::Input:: *) +(*SelectedExperiment=SelectedExperimentList[[icounter++]];*) + + +(* ::Chapter::Closed:: *) +(*Cross-sections, acceptances*) + + +(* ::Section::Closed:: *) +(*Importing data for separate mixings*) + + +(* ::Input:: *) +(*Do[*) +(*ExperimentData[HNLsList[[i]]]=Import[FileNameJoin[{FileNameJoin[{directory["Acceptances"],SelectedExperiment,"Acceptance_"<>SelectedExperiment<>"_for_"<>HNLsList[[i]]<>".m"}]}],"MX"];*) +(*AcceptanceData[HNLsList[[i]]]=ExperimentData[HNLsList[[i]]][[3]];*) +(*BrVisMixing[mLLP_,HNLsList[[i]]]=ExperimentData[HNLsList[[i]]][[5]];*) +(*,{i,1,Length[HNLsList],1}]//AbsoluteTiming*) +(*{AzimuthalAcceptanceInt[\[Theta]LLP_,zLLP_],\[Theta]minExpAll,\[Theta]maxExpAll,\[Theta]minExp,\[Theta]maxExp,zminExp,zmaxExp,zmin\[Theta][\[Theta]LLP_],zmax\[Theta][\[Theta]LLP_]}=Block\[Epsilon]Azimuthal[AcceptanceData[HNLsList[[1]]]];*) +(*brtemp[mLLP_]=BrVisMixing[mLLP,HNLsList[[1]]];*) +(*(*Branching ratio of visible HNL decays averaged over mixings*)*) +(*BrVis[mLLP_]=BrVisMixing[mLLP,HNLsList[[#]]]&/@{1,2,3} . MixingPattern/(MixingPattern//Total)//Chop;*) +(*mlistBr=Join[Table[m,{m,0.02,5.1,0.001}],Table[m,{m,5.12,30,0.01}]];*) +(*LogPlot[Evaluate[{BrVisMixing[mLLP,HNLsList[[1]]],BrVisMixing[mLLP,HNLsList[[2]]],BrVisMixing[mLLP,HNLsList[[3]]],BrVis[mLLP]}],{mLLP,Min[mlistBr],7},FrameStyle->Directive[Black, 22],PlotStyle->{{Thickness[0.003],Blue},{Thickness[0.003],Darker@Red},{Thickness[0.003],Darker@Darker@Green},{Thickness[0.003],Black}},GridLines->Automatic,PlotRange->{{0.02,7},All},Frame->True,ImageSize->Large,FrameLabel->{"\!\(\*SubscriptBox[\(m\), \(N\)]\) [GeV]","\!\(\*SubscriptBox[\(Br\), \(vis\)]\)"},PlotLabel-> Style[Row[{"For ",SelectedExperiment,". \!\(\*SuperscriptBox[SubscriptBox[\(U\), \(e\)], \(2\)]\):\!\(\*SuperscriptBox[SubscriptBox[\(U\), \(\[Mu]\)], \(2\)]\):\!\(\*SuperscriptBox[SubscriptBox[\(U\), \(\[Tau]\)], \(2\)]\) = ",MixingPattern}], 20, Black],PlotLegends->Placed[{Style[#, 18]&/@{"Pure e mixing","Pure \[Mu] mixing","Pure \[Tau] mixing","Averaged"}},{0.75,0.2}]]*) +(*{xxx,yyy,zzz,InGridm\[Epsilon],InGrid\[Theta]\[Epsilon],InGridE\[Epsilon],InGridz\[Epsilon],\[Epsilon]vals,\[Epsilon]azvals,mmin\[Epsilon],mmax\[Epsilon]}=Block\[Epsilon]Decay[AcceptanceData[HNLsList[[1]]],zminExp,brtemp];*) +(*FacilityGivenExperiment=ExperimentData[HNLsList[[1]]][[1]];*) +(*CrossSectionData=ExperimentData[HNLsList[[1]]][[4]]//Transpose;*) +(*NpotGivenExperiment=Select[CrossSectionData,#[[1]]=="Npot"&][[1]][[2]];*) +(*(*Amounts (per PoT) of c or Overscript[c, _], b or Overscript[b, _], and W^+ or W^- at the given experiment (Subscript[P, c or Overscript[c, _]] = Subscript[P, c]+Subscript[P, Overscript[c, _]] = 2*Subscript[P, cOverscript[c, _]], etc.)*)*) +(*{ProbMother["D"],ProbMother["B"],ProbMother["W"]}={Select[CrossSectionData,#[[1]]=="Pc"&][[1]][[2]],Select[CrossSectionData,#[[1]]=="Pb"&][[1]][[2]],Select[CrossSectionData,#[[1]]=="PW"&][[1]][[2]]};*) +(*If[FacilityGivenExperiment=="SPS",*) +(*ProbMother["K"]=0.36];*) +(*If[FacilityGivenExperiment=="ESS",*) +(*ProbMother["PiCharged"]=Select[CrossSectionData,#[[1]]=="PPiCharged"&][[1]][[2]];*) +(*ProbMother["mu"]=Select[CrossSectionData,#[[1]]=="Pmu"&][[1]][[2]];*) +(*];*) +(*(*infoDialog[Row[{"The number of proton collisions is ", NpotGivenExperiment,". You may change it at the stage of computing the sensitivities"}]]*)*) +(*Row[{"Search for ",HNLtype," HNLs with the mixing pattern {\!\(\*SuperscriptBox[SubscriptBox[\(U\), \(e\)], \(2\)]\),\!\(\*SuperscriptBox[SubscriptBox[\(U\), \(\[Mu]\)], \(2\)]\),\!\(\*SuperscriptBox[SubscriptBox[\(U\), \(\[Tau]\)], \(2\)]\)} = \!\(\*SuperscriptBox[\(U\), \(2\)]\)",MixingPattern," at ", SelectedExperiment, " located at ",FacilityGivenExperiment,". \!\(\*SubscriptBox[\(N\), \(collisions\)]\) = ",NpotGivenExperiment}]*) +(*{{"Quantity","\!\(\*SubscriptBox[\(\[Theta]\), \(min\)]\), rad","\!\(\*SubscriptBox[\(\[Theta]\), \(max\)]\), rad","\!\(\*SubscriptBox[\(\[Theta]\), \(min\)]\)(\!\(\*SubscriptBox[\(\[Epsilon]\), \(dec\)]\)), rad","\!\(\*SubscriptBox[\(\[Theta]\), \(max\)]\)(\!\(\*SubscriptBox[\(\[Epsilon]\), \(dec\)]\)), rad","\!\(\*SubscriptBox[\(z\), \(min\)]\), m","\!\(\*SubscriptBox[\(z\), \(max\)]\), m"},{"Description","Min angle covered by experiment","Max angle covered by experiment","Min angle where \!\(\*SubscriptBox[\(\[Epsilon]\), \(decay\)]\)\[NotEqual]0","Max angle where \!\(\*SubscriptBox[\(\[Epsilon]\), \(decay\)]\)\[NotEqual]0","Min long. displacement of the decay volume","Max long. displacement of the decay volume"},{"Value",\[Theta]minExpAll,\[Theta]maxExpAll,\[Theta]minExp,\[Theta]maxExp,zminExp,zmaxExp}}//TableForm*) + + +(* ::Section::Closed:: *) +(*Gluing the data for separate mixings to the given mixing pattern*) + + +(* ::Input:: *) +(*(*Computing weights for decays via different mixing. The weights are Subscript[Br, vis,x]*Subscript[U^2, x]/U^2/Subscript[\[CapitalSigma], x]Subscript[Br, vis,x]*Subscript[U^2, x]/U^2*)*) +(*Weight\[Epsilon]DecayMixing=1/BrVis[#] {BrVisMixing[#,HNLsList[[1]]]*MixingPattern[[1]],BrVisMixing[#,HNLsList[[2]]]*MixingPattern[[2]],BrVisMixing[#,HNLsList[[3]]]*MixingPattern[[3]]}&/@(10^InGridm\[Epsilon]);*) +(*(*The averaged decay acceptance: the weights for the given mass and flavor are contracted with the lists of the decay acceptances for the same mass and flavor, and then there is a summation over flavors*)*) +(*FullAcceptanceData0=Join[AcceptanceData[HNLsList[[1]]][[All,Range[1,5]]],(List/@Flatten[Weight\[Epsilon]DecayMixing[[All,#]]* Partition[AcceptanceData[HNLsList[[#]]][[All,-1]],Length[AcceptanceData[HNLsList[[#]]]]/Length[InGridm\[Epsilon]]]]&/@{1,2,3})//Total,2];//AbsoluteTiming*) +(*{FullAcceptanceData,DecayAcceptanceInt[mLLP_,\[Theta]LLP_,ELLP_,zLLP_],FullAcceptanceInt[mLLP_,\[Theta]LLP_,ELLP_,zLLP_],InGridm\[Epsilon],InGrid\[Theta]\[Epsilon],InGridE\[Epsilon],InGridz\[Epsilon],\[Epsilon]vals,\[Epsilon]azvals,mmin\[Epsilon],mmax\[Epsilon]}=Block\[Epsilon]Decay[FullAcceptanceData0,zminExp,BrVis];*) + + +(* ::Chapter::Closed:: *) +(*Angle-energy distributions for the given experiment*) + + +(* ::Section::Closed:: *) +(*Importing for separate mixings*) + + +(* ::Input:: *) +(*ProductionPatternSelected=Select[DistrCombinations,#[[3]]==FacilityGivenExperiment&];*) +(*Print["Production list:"]*) +(*ProductionList=ProductionPatternSelected[[All,2]]//DeleteDuplicates;*) +(*If[MixingPattern=={0.,0.,1.},ProductionList=Select[ProductionList,#!="K"&]]*) +(*Do[*) +(*Module[{hnl,prod},*) +(*{hnl,prod}=ProductionPatternSelected[[i]][[#]]&/@{1,2};*) +(*(*Importing the data with distribution*)*) +(*DistrDataImportTemp[hnl,prod]=Import[FileNameJoin[{directory["Distribution"],"DoubleDistr_"<>hnl<>"_"<>prod<>"_"<>FacilityGivenExperiment<>".m"}],"MX"];*) +(*ProbLLP[mLLP_,U2_,hnl,prod]=ProbMother[prod]*ProdMotherToLLP[mLLP,U2,hnl,prod,FacilityGivenExperiment];*) +(*]*) +(*,{i,1,Length[ProductionPatternSelected],1}]*) +(*prodsno\[Tau]={"K","PiCharged","mu"};*) +(*Do[*) +(*If[MemberQ[prodsno\[Tau],prod],*) +(*DistrDataImportTemp[HNLsList[[3]],prod]={#[[1]],#[[2]],#[[3]],0.}&/@DistrDataImportTemp[HNLsList[[1]],prod];*) +(*ProbLLP[mLLP_,U2_,HNLsList[[3]],prod]=0.;*) +(*]*) +(*,{prod,ProductionList}]*) + + +(* ::Section::Closed:: *) +(*Gluing*) + + +(* ::Input:: *) +(*Do[ProbLLP[mLLP_,U2_,prod]=Sum[ProbLLP[mLLP,U2,HNLsList[[i]],prod]*MixingPattern[[i]],{i,1,3,1}]//Chop,{prod,ProductionList}];*) +(*(*Code supplementing the data for the distribution up to the given mass with zeros*)*) +(*DataSupplementedBlock[data_,mmax_]:=Block[{},*) +(*mdatamax=Max[data[[All,1]]];*) +(*data\[Theta]Egrid=SortBy[DeleteDuplicatesBy[data,{#[[2]],#[[3]]}&][[All,{2,3}]],{#[[1]],#[[2]]}&]//N;*) +(*Join[data,Flatten[Table[{mLLP,data\[Theta]Egrid[[i]][[1]],data\[Theta]Egrid[[i]][[2]],0},{mLLP,1.001mdatamax,mmax,(mmax-1.001mdatamax)/3},{i,1,Length[data\[Theta]Egrid],1}],{1,2}]]*) +(*]*) +(*DataLogarithmiedComp1=Compile[{{data,_Real,2}},Table[If[data[[i]][[4]]==0,-90.,Log10[data[[i]][[4]]]],{i,1,Length[data],1}],CompilationTarget->"MVM",RuntimeOptions->"Speed"];*) +(*(*The block that glues the distributions according to the mixing pattern*)*) +(*BlockDistrGluing[ProdChannel_]:=Block[{},*) +(*(*Angle-energy distribution data corresponding to the given production channel*)*) +(*DataList=DistrDataImportTemp[#,ProdChannel]&/@HNLsList;*) +(*(*List of the production probabilities per mixing for the given production channel: Subscript[P, prod](m,Subscript[U, i]^2/U^2)*)*) +(*\[Chi]list[mLLP_]=ProbLLP[mLLP,MixingPattern[[#]],HNLsList[[#]],ProdChannel]&/@{1,2,3};*) +(*\[Chi]weights=\[Chi]list[#]&/@(DataList[[1]][[All,1]]//DeleteDuplicates);*) +(*\[Chi]weights={#[[1]]/Max[10^-90.,#[[1]]+#[[2]]+#[[3]]],#[[2]]/Max[10^-90.,#[[1]]+#[[2]]+#[[3]]],#[[3]]/Max[10^-90.,#[[1]]+#[[2]]+#[[3]]]}&/@\[Chi]weights;*) +(*DataListFin=Join[DataList[[1]][[All,{1,2,3}]],(List/@Flatten[\[Chi]weights[[All,#]] Partition[DataList[[#]][[All,-1]],Length[DataList[[#]]]/Length[\[Chi]weights]]]&/@{1,2,3})//Total,2];*) +(*{#[[1]],#[[2]],#[[3]],Max[#[[4]],10^-90.]}&/@DataListFin*) +(*]*) +(*(*Interpolating block*)*) +(*Do[*) +(*DistrDataImport[prod]=BlockDistrGluing[prod];*) +(*DoubleDistrLLPint[mLLP_,\[Theta]LLP_,ELLP_,prod]=10^(Interpolation[distrlogComp[DistrDataImport[prod]],InterpolationOrder->1][Log10[mLLP],Log10[\[Theta]LLP],Log10[ELLP]]);*) +(*maxvalGluing=DistrDataImport[prod][[All,-1]]//Max;*) +(*maxMassGluing=Select[DistrDataImport[prod],#[[-1]]>10^-20. maxvalGluing&][[All,1]]//Max;*) +(*MassListDistr[prod]=DeleteDuplicates[DistrDataImport[prod][[All,1]]];*) +(*{mLLPmin[prod],mLLPmax[prod]}={Min[MassListDistr[prod]],Min[maxMassGluing,Max[MassListDistr[prod]]]};*) +(*,{prod,ProductionList}];//AbsoluteTiming*) +(*directory["Auxiliary-experiment"]=FileNameJoin[{directory["Auxiliary"],SelectedExperiment}];*) +(*If[!DirectoryQ[directory["Auxiliary-experiment"]],CreateDirectory[directory["Auxiliary-experiment"]]]*) +(*Export[FileNameJoin[{directory["Auxiliary-experiment"],ToString@StringForm["Double-Distr-Averaged-HNL_mixing-pattern_``-``-``.m",Sequence@@MixingPattern]}],{Sum[If[mLLPmin[prod]True,ImageSize->Large,PlotLegends->Placed[Style[#,15]&/@ProductionList,Right]];*) +(*ptprodprob=LogLogPlot[Evaluate[Table[ProbLLP[ma,1,prod],{prod,ProductionList}]],{ma,mmin\[Epsilon],mmax\[Epsilon]},Frame->True,ImageSize->Large,PlotLegends->Placed[Style[#,15]&/@ProductionList,Right]];*) +(*Style[Row[{ptprodprob,ptenergies}],ImageSizeMultipliers->{1, 1}]*) + + +(* ::Chapter::Closed:: *) +(*Number of events*) + + +(* ::Section::Closed:: *) +(*Number of events - using the mapping method *) + + +(* ::Subsection::Closed:: *) +(*Initializing all routines*) + + +(* ::Input:: *) +(*Do[{OutGrid\[Theta]final[prod],\[CapitalDelta]\[Theta]vals[prod]}=OutGrid\[Theta]Temp[InGrid\[Theta]\[Epsilon],30,prod,\[Theta]maxBrem],{prod,ProductionList}]*) +(*{OutGridzfinal,\[CapitalDelta]zvals}=OutGridszTemp[InGridz\[Epsilon],30,zminExp];*) +(*(*Final energy grid. Mass- and production channel-dependent*)*) +(*If[FacilityGivenExperiment!="ESS",*) +(*StepEtemp[Efip_]=Piecewise[{{0.3,Efip<=2.5},{0.5,2.5=Log10[m]&];*) +(*OutGridEnergy[m_,"mu"]:=Log10[Select[10^GridInFinal["mu"][[3]],m<#<=ELLPmax[m,\[Theta]LLP,"mu"]&]];*) +(*]*) +(*(*Block that computes the grid Subscript[\[Theta], S],Subscript[E, S],Subscript[z, S], Subscript[\[Epsilon], Full]\[Times]Subscript[f, Subscript[\[Theta], S],Subscript[E, S]]*)*) +(*TableIntegrandDiscret[m_,ProdChannel_,\[Epsilon]DecOp_]:=TableIntegrandDiscretTemp[m,ProdChannel,\[Epsilon]DecOp,\[Epsilon]vals,\[Epsilon]azvals,OutGrid\[Theta]final[ProdChannel],OutGridzfinal,OutGridEnergy,InGridm\[Epsilon],InGrid\[Theta]\[Epsilon],InGridE\[Epsilon],InGridz\[Epsilon],\[CapitalDelta]\[Theta]vals[ProdChannel],\[CapitalDelta]zvals,zminExp,GridInFinal,DistrVals,FacilityGivenExperiment,ELLPmax,\[Theta]minExp]*) + + +(* ::Subsection::Closed:: *) +(*Generalized acceptances*) + + +(* ::Input:: *) +(*(*Tabulated acceptance*)*) +(*FactorANUBISceiling=If[SelectedExperiment=="ANUBIS-ceiling",2,1];*) +(*AcceptanceDiscret[m_,ProdChannel_,\[Epsilon]decOp_,decProb_]:=AcceptanceDiscretTemp[m,ProdChannel,\[Epsilon]decOp,decProb,mLLPmin,mmin\[Epsilon],mLLPmax,mmax\[Epsilon],ELLPmax,\[Theta]minExp,TableIntegrandDiscret,BrVis,zmaxExp,zminExp,FactorANUBISceiling,0.]*) +(*Do[*) +(*If[!(FacilityGivenExperiment=="ESS"&&MemberQ[{"PiCharged","mu"},prod]),*) +(*mLLPlistAcceptance[prod]=Join[Table[m,{m,1.01Max[mLLPmin[prod],mmin\[Epsilon]],0.95Min[mLLPmax[prod],mmax\[Epsilon]],Min[(0.95Min[mLLPmax[prod],mmax\[Epsilon]]-1.01Max[mLLPmin[prod],mmin\[Epsilon]])/20,2]}],{0.99Min[mLLPmax[prod],mmax\[Epsilon]]}],*) +(*mLLPlistAcceptance[prod]=10^GridInFinal[prod][[1]]*) +(*],{prod,ProductionList}];*) +(*Do[*) +(*\[Epsilon]GeomTabs[prod]=ParallelTable[{m,AcceptanceDiscret[m,prod,"False",0],AcceptanceDiscret[m,prod,"True",0],AcceptanceDiscret[m,prod,"False",1],AcceptanceDiscret[m,prod,"True",1]},{m,mLLPlistAcceptance[prod]}];*) +(*If[!(FacilityGivenExperiment=="ESS"&&MemberQ[{"PiCharged","mu"},prod]),*) +(*\[Epsilon]GeomTabs[prod]=SortBy[DeleteDuplicatesBy[Join[{Join[{Max[mLLPmin[prod],mmin\[Epsilon]]},Drop[\[Epsilon]GeomTabs[prod][[1]],1]]},\[Epsilon]GeomTabs[prod],{Join[{Min[mLLPmax[prod],mmax\[Epsilon]]},Drop[\[Epsilon]GeomTabs[prod][[-1]],1]]}],#[[1]]&],#[[1]]&];*) +(*]*) +(*,{prod,ProductionList}];//AbsoluteTiming*) +(*PlotAcc[ProdChannel_]:=ListLogPlot[Evaluate[{\[Epsilon]GeomTabs[ProdChannel][[All,{1,2}]],\[Epsilon]GeomTabs[ProdChannel][[All,{1,3}]],\[Epsilon]GeomTabs[ProdChannel][[All,{1,4}]],\[Epsilon]GeomTabs[ProdChannel][[All,{1,5}]]}],FrameStyle->Directive[Black, 22],PlotStyle->{{Thickness[0.003],Blue},{Thickness[0.003],Darker@Red},{Thickness[0.003],Darker@Darker@Green},{Thickness[0.003],Black}},GridLines->Automatic,PlotRange->{MinMax[\[Epsilon]GeomTabs[ProdChannel][[All,1]]],{Max[0.9Min[Min[\[Epsilon]GeomTabs[ProdChannel][[All,4]]],Min[\[Epsilon]GeomTabs[ProdChannel][[All,3]]]],10^-5],1.1Max[Max[\[Epsilon]GeomTabs[ProdChannel][[All,2]]],Max[\[Epsilon]GeomTabs[ProdChannel][[All,4]]]]}},Joined->True,Frame->True,ImageSize->Large,FrameLabel->{"m [GeV]","Acceptance"},PlotLabel-> Style[Row[{"From ",ProdChannel}], 20, Black],PlotLegends->Placed[{Style[#, 18]&/@{"<\!\(\*SubscriptBox[\(\[Epsilon]\), \(LLP\)]\)>","<\!\(\*SubscriptBox[\(\[Epsilon]\), \(LLP\)]\)\!\(\*SubscriptBox[\(\[Epsilon]\), \(decay\)]\)>","c\[Tau]<\!\(\*SubscriptBox[\(\[Epsilon]\), \(LLP\)]\)\!\(\*SubscriptBox[\(P\), \(decay\)]\)>","c\[Tau]<\!\(\*SubscriptBox[\(\[Epsilon]\), \(LLP\)]\)\!\(\*SubscriptBox[\(P\), \(decay\)]\)\!\(\*SubscriptBox[\(\[Epsilon]\), \(decay\)]\)>"}},{0.75,0.2}]]*) +(*Style[Row[Evaluate[Table[PlotAcc[prod],{prod,ProductionList}]]],ImageSizeMultipliers->{1,1,1,1}]*) +(*(*Do[FilenameAcceptance[prod]=ToString@StringForm["Acceptance_ALP-fermion_at_``_From_``.dat",Sequence@@{SelectedExperiment,ExportList[prod]}];*) +(*Export[FileNameJoin[{NotebookDirectory[],"Auxiliary data/ALPs with fermion coupling",SelectedExperiment,FilenameAcceptance[prod]}],\[Epsilon]GeomTabs[prod][[All,{1,2,4,5}]],"Table"]*) +(*,{prod,ProductionList}]*)*) +(*AccAveraged[mLLP_,c\[Tau]_]=NpotGivenExperiment{Sum[If[mLLPmin[prod]1][mLLP]],0],{prod,ProductionList}],Sum[If[Max[mLLPmin[prod],mmin\[Epsilon]]1][mLLP]],0],{prod,ProductionList}],Sum[If[Max[mLLPmin[prod],mmin\[Epsilon]]1][mLLP]],0],{prod,ProductionList}]};*) +(*Export[FileNameJoin[{directory["Auxiliary-experiment"],"AcceptanceAveraged-"<>LLPdirName<>".m"}],AccAveraged[mLLP,c\[Tau]],"MX"];*) + + +(* ::Subsection::Closed:: *) +(*Rough estimates of the upper and lower bounds*) + + +(* ::Input:: *) +(*Do[LowerBoundEstimate[mLLP_,prod]=((NpotGivenExperiment*ProbLLP[mLLP,1,prod]*Interpolation[\[Epsilon]GeomTabs[prod][[All,{1,5}]],InterpolationOrder->1][mLLP])/(2.3ldecayLLP[mLLP,1,ELLP] mLLP/Sqrt[ELLP^2-mLLP^2]))^(-(1/2));*) +(*UpperBoundEstimate[mLLP_,prod]=(Abs[Re[Evaluate[-(ProductLog[-1,-2.3*b/a]/b)/.{a-> NpotGivenExperiment*ProbLLP[mLLP,1,prod]*Interpolation[\[Epsilon]GeomTabs[prod][[All,{1,3}]],InterpolationOrder->1][mLLP],b->zminExp/ldecayLLP[mLLP,1,ELLPmax[0.5,\[Theta]minExp,prod]]}]]]),{prod,ProductionList}]*) +(*ProdTest=ProductionList[[1]];*) +(*LogLogPlot[Evaluate[{0.3LowerBoundEstimate[mLLP,ProdTest],1.8UpperBoundEstimate[mLLP,ProdTest]}],{mLLP,Max[mLLPmin[ProdTest],mmin\[Epsilon]],Min[mLLPmax[ProdTest],mmax\[Epsilon]]},Frame->True,ImageSize->Large]*) + + +(* ::Subsection::Closed:: *) +(*Number of events - fast*) + + +(* ::Input:: *) +(*FactorLowerBound=If[MemberQ[{"ANUBIS-shaft-volume-1","ANUBIS-shaft-volume-2","ANUBIS-shaft-volume-3"},SelectedExperiment]==True,0.1,0.3];*) +(*NeventsDiscret[m_,ProdChannel_,couplinglist_]:=Module[{NevDiscret,NpotTimes\[Chi]val,zshift},*) +(*If[Max[mLLPmin[ProdChannel],mmin\[Epsilon]]"AdaptiveMonteCarlo"]*) +(*If[FacilityGivenExperiment=="ESS",*) +(*IntegralLLP[mLLP_,U2_,"PiCharged"]:=NIntegrate[Abs[IntegrandLLP[mLLP,U2,\[Theta]LLP,ELLP,zLLP,"PiCharged"]],{\[Theta]LLP,\[Theta]minExp,\[Theta]maxExp},{ELLP,(mSM["PiCharged"]^2-mSM["mu"]^2+mLLP^2)/(2*mSM["PiCharged"])-\[CapitalDelta]Eapprox/2,(mSM["PiCharged"]^2-mSM["mu"]^2+mLLP^2)/(2*mSM["PiCharged"])+\[CapitalDelta]Eapprox/2},{zLLP,zmin\[Theta][\[Theta]LLP],zmax\[Theta][\[Theta]LLP]},Method->"AdaptiveMonteCarlo"]+NIntegrate[Abs[IntegrandLLP[mLLP,U2,\[Theta]LLP,ELLP,zLLP,"PiCharged"]],{\[Theta]LLP,\[Theta]minExp,\[Theta]maxExp},{ELLP,(mSM["PiCharged"]^2-mSM["e"]^2+mLLP^2)/(2*mSM["PiCharged"])-\[CapitalDelta]Eapprox/2,(mSM["PiCharged"]^2-mSM["e"]^2+mLLP^2)/(2*mSM["PiCharged"])+\[CapitalDelta]Eapprox/2},{zLLP,zmin\[Theta][\[Theta]LLP],zmax\[Theta][\[Theta]LLP]},Method->"AdaptiveMonteCarlo"]*) +(*]*) +(*NeventsInt[mLLP_,coupling_,ProdChannel_]:=If[mLLPmin[ProdChannel]<=mLLP<=mLLPmax[ProdChannel]&&BrVis[mLLP]!=0,If[0.1LowerBoundEstimate[mLLP,ProdChannel]2,"\!\(\*SubscriptBox[\(\[Theta]\), \(X\)]\)"->1,"\!\(\*SubscriptBox[\(z\), \(X\)]\)"->3}]*) +(*\[CapitalDelta]xvals["\!\(\*SubscriptBox[\(E\), \(X\)]\)"]:=\[CapitalDelta]Evals;*) +(*\[CapitalDelta]xvals["\!\(\*SubscriptBox[\(z\), \(X\)]\)"]=\[CapitalDelta]zvals;*) +(*Do[\[CapitalDelta]xvals["\!\(\*SubscriptBox[\(\[Theta]\), \(X\)]\)",prod]=\[CapitalDelta]\[Theta]vals[prod],{prod,ProductionList}];*) +(*LegendX:=Association[{"\!\(\*SubscriptBox[\(E\), \(X\)]\)"->"\!\(\*SubscriptBox[\(E\), \(X\)]\) [GeV]","\!\(\*SubscriptBox[\(\[Theta]\), \(X\)]\)"->"\!\(\*SubscriptBox[\(\[Theta]\), \(X\)]\) [rad]","\!\(\*SubscriptBox[\(z\), \(X\)]\)"-> "\!\(\*SubscriptBox[\(z\), \(X\)]\) [m]"}]*) +(*LegendY:=Association[{"\!\(\*SubscriptBox[\(E\), \(X\)]\)"->"\!\(\*SubscriptBox[\(dN\), \(ev\)]\)/\!\(\*SubscriptBox[\(dE\), \(X\)]\) [\!\(\*SuperscriptBox[\(GeV\), \(-1\)]\)]","\!\(\*SubscriptBox[\(\[Theta]\), \(X\)]\)"->"\!\(\*SubscriptBox[\(dN\), \(ev\)]\)/\!\(\*SubscriptBox[\(d\[Theta]\), \(X\)]\) [\!\(\*SuperscriptBox[\(rad\), \(-1\)]\)]","\!\(\*SubscriptBox[\(z\), \(X\)]\)"-> "\!\(\*SubscriptBox[\(dN\), \(ev\)]\)/\!\(\*SubscriptBox[\(dz\), \(X\)]\) [\!\(\*SuperscriptBox[\(m\), \(-1\)]\)]"}]*) +(*(*Differential number of events*)*) +(*NeventsDifferentialDiscretProd[m_,ProdChannel_,coupling_,Variable_]:=Module[{NpotTimes\[Chi]val},*) +(*ival=iVal[Variable];*) +(*NpotTimes\[Chi]val=NpotGivenExperiment*ProbLLP[m,coupling,ProdChannel];*) +(*tablegrid0=TableIntegrandDiscret[m,ProdChannel,"True"];*) +(*OutGridEfinalTemp=OutGridEnergy[N[m],ProdChannel];*) +(*If[!(FacilityGivenExperiment=="ESS"&&ProdChannel=="PiCharged"),*) +(*{OutGridEfinal,\[CapitalDelta]Evals}={1/2 (Rest[OutGridEfinalTemp]+Most[OutGridEfinalTemp]),(Rest[10^OutGridEfinalTemp]-Most[10^OutGridEfinalTemp])};*) +(*,*) +(*\[CapitalDelta]Eapprox=10^-5.;*) +(*\[CapitalDelta]Evals=Table[\[CapitalDelta]Eapprox,Length[OutGridEfinalTemp]];*) +(*OutGridEfinal=OutGridEfinalTemp;*) +(*];*) +(*\[CapitalDelta]xval=\[CapitalDelta]xvals[Variable];*) +(*c\[Tau]Val=c\[Tau]LLP[m,coupling];*) +(*brvis=BrVis[m];*) +(*ilist=DeleteDuplicates[{ival,1,2,3}];*) +(*tablegrid1=SortBy[{#[[ilist[[1]]]],#[[ilist[[2]]]],#[[ilist[[3]]]],#[[4]]}&/@tableGridPrefac[tablegrid0,m,c\[Tau]Val,0.],{#[[1]],#[[2]],#[[3]]}&];*) +(*GridQuantity=tablegrid1[[All,1]]//DeleteDuplicates;*) +(*LengthPerVariable=Length[tablegrid1]/Length[GridQuantity];*) +(*tab1=NdiffCompiled[tablegrid1,GridQuantity,LengthPerVariable,NpotTimes\[Chi]val*brvis];*) +(*Join[tab1[[All,{1}]],Partition[tab1[[All,2]]*\[CapitalDelta]xval^-1,1],2]*) +(*]*) +(*NeventsDifferentialDiscret[m_,coupling_,Variable_]:=Module[{NdiffInt,LegendList,QuantityMinMax,ValueMinMax},*) +(*prodlisttemp={};*) +(*Do[If[Max[mLLPmin[prod],mmin\[Epsilon]]10^-40&][[All,1]]//MinMax;*) +(*NdiffInt[X_,prod]=If[XvalminmaxNdiff[[1]]1][Log10[X]]],0]],{prod,ProductionList}];*) +(*NdiffInt[X_,"Total"]=Sum[NdiffInt[X,prod],{prod,prodlisttemp}];*) +(*LegendList=Join[{"Total"},prodlisttemp];*) +(*QuantityMinMax=Flatten[Table[MinMax[NdiffData[prod][[All,1]]],{prod,prodlisttemp}],1]//MinMax;*) +(*ValueMinMax=Max[Max[NdiffData[#][[All,2]]]&/@prodlisttemp];*) +(*{Table[NdiffInt[X,prod],{prod,LegendList}],LegendList,QuantityMinMax,ValueMinMax}*) +(*]*) +(*mvaltest=If[FacilityGivenExperiment=="ESS",0.04,0.2];*) +(*couplingvaltest=1.4LowerBoundEstimate[mvaltest,If[FacilityGivenExperiment=="ESS","PiCharged","D"]];*) +(*quantity="\!\(\*SubscriptBox[\(E\), \(X\)]\)";*) +(*{NdiffTab[X_],LegendList,QuantityMinMax,ValueMinMax}=NeventsDifferentialDiscret[mvaltest,couplingvaltest,quantity];*) +(*Do[*) +(*prch=LegendList[[i]];*) +(*NdiffInt[X_,prch]=NdiffTab[X][[i]];*) +(*,{i,1,Length[LegendList]}];*) +(*plotdiff=LogLogPlot[Evaluate[Table[NdiffInt[X,prod],{prod,LegendList}]],{X,QuantityMinMax[[1]],QuantityMinMax[[2]]},Frame->True,ImageSize->Large,PlotRange->{All,{10^-5,2ValueMinMax}},PlotStyle->{{Thick,Black},{Thick,Blue},{Thick,Darker@Red},{Thick,Darker@Darker@Green},{Thick,Darker@Cyan},{Thick,Magenta},{Thick,Blue,Dashing[0.02]},{Thick,Darker@Red,Dashing[0.02]},{Thick,Darker@Darker@Green,Dashing[0.02]}},PlotLegends->Placed[Style[#,20]&/@LegendList,Right],FrameLabel->{LegendX[quantity] ,LegendY[quantity]},FrameStyle->Directive[Black, 18],PlotLabel->Style[Row[{SelectedExperiment,". \!\(\*SubscriptBox[\(m\), \(N\)]\) = ",mvaltest," GeV, \!\(\*SuperscriptBox[\(U\), \(2\)]\) = ",couplingvaltest//N}],14,Black]]*) + + +(* ::Title::Closed:: *) +(*Exporting tabulated number of events*) + + +(* ::Chapter::Closed:: *) +(*Definitions*) + + +(* ::Input:: *) +(*directory["Nevents"]=FileNameJoin[{NotebookDirectory[],"Tabulated Nevents"}];*) +(*directory["Nevents-LLP"]=FileNameJoin[{NotebookDirectory[],"Tabulated Nevents",LLPdirName}];*) +(*directory["Nevents-LLP-experiment"]=FileNameJoin[{NotebookDirectory[],"Tabulated Nevents",LLPdirName,SelectedExperiment}];*) +(*If[!DirectoryQ[directory[#]],CreateDirectory[directory[#]]]&/@{"Nevents","Nevents-LLP","Nevents-LLP-experiment"};*) +(*Print["List of filenames with exported tabulated number of events"]*) +(*Do[FilenameNeventsInt[prod]=ToString@StringForm["Nevents_HNL_MixingPattern_``-``-``_type_``_at_``_Npot=``_From_``.dat",Sequence@@{ToString[MixingPattern[[1]]],ToString[MixingPattern[[2]]],ToString[MixingPattern[[3]]],HNLtype,SelectedExperiment,NpotGivenExperiment//CForm//ToString,prod}],{prod,ProductionList}]*) +(*Table[FilenameNeventsInt[prod],{prod,ProductionList}]//TableForm*) +(*mRangeExport["K"]=Table[mx,{mx,0.051,0.495,0.02}];*) +(*mRangeExport["D"]=Join[Table[mx,{mx,0.051,1.951,0.02}],{0.161,0.141,0.131,0.171,0.184,0.188,0.181,0.191,0.201}]//Sort//DeleteDuplicates;*) +(*mRangeExport["B"]=Table[mx,{mx,0.051,6.301,0.02}];*) +(*mRangeExport["W"]=Join[Table[mx,{mx,0.051,3.301,0.02}],Table[mx,{mx,3.35,10,0.05}],Table[mx,{mx,10.1,20.,0.1}]];*) +(*If[FacilityGivenExperiment=="ESS",*) +(*mRangeExport["mu"]=10^GridInFinal["mu"][[1]];*) +(*mRangeExport["PiCharged"]=10^GridInFinal["PiCharged"][[1]];*) +(*]*) +(*couplingsRangeExport=Table[10^x,{x,-13,-3,0.03}];*) + + +(* ::Chapter::Closed:: *) +(*Exporting*) + + +(* ::Input:: *) +(*BlockExport[ProdChannel_]:=Module[{mlist},*) +(*mlist=mRangeExport[ProdChannel];*) +(*TabFrom=ParallelTable[Quiet[NeventsDiscret[mlist[[k]],ProdChannel,couplingsRangeExport]],{k,1,Length[mlist],1}];*) +(*Export[FileNameJoin[{directory["Nevents-LLP-experiment"],FilenameNeventsInt[ProdChannel]}],Flatten[TabFrom,1],"Table"]*) +(*]*) +(*Monitor[*) +(*Do[*) +(*prod=ProductionList[[j]];*) +(*BlockExport[prod],{j,1,Length[ProductionList],1}],*) +(*Row[{ProgressIndicator[j,{1,Length[ProductionList]}]," Production mode = ",ProductionList[[j]]," (", j,"/",Length[ProductionList],")"}]]//AbsoluteTiming*) +(*If[icounter>Length[SelectedExperimentList],BlockEvaluation["Sensitivity"]]*) + + +(* ::Title::Closed:: *) +(*Computing sensitivities*) + + +(* ::Chapter::Closed:: *) +(*Basic definitions*) + + +(* ::Input:: *) +(*LLPdirName="HNL";*) +(*directory["Sensitivity"]=FileNameJoin[{NotebookDirectory[],"Sensitivity domains"}];*) +(*directory["Sensitivity-LLP"]=FileNameJoin[{directory["Sensitivity"],LLPdirName}];*) +(*If[!DirectoryQ[directory[#]],CreateDirectory[directory[#]]]&/@{"Sensitivity","Sensitivity-LLP"};*) +(*directory["Nevents-LLP"]=FileNameJoin[{NotebookDirectory[],"Tabulated Nevents",LLPdirName}];*) +(*dropdownDialog[list_,phrase_]:=DialogInput[{choice=""},Column[{TextCell[phrase],PopupMenu[Dynamic[choice],list],Button["OK",DialogReturn[choice]]}]]*) +(*infoDialog[phrase_]:=DialogInput[{choice=""},Column[{TextCell[phrase],Button["Proceed",DialogReturn[choice]]}]]*) +(*selectionDialog[list_,phrase_]:=DialogInput[{choice={}},Column[{Row[{phrase}],Pane[TogglerBar[Dynamic[choice],list,Appearance->"Vertical"->{Automatic,5}],ImageSize->{Automatic,Automatic},Scrollbars->{False,True}],Button["OK",DialogReturn[choice]]}]]*) +(*ExperimentDirectoriesListNevents=Select[FileNames["*",directory["Nevents-LLP"],1],DirectoryQ];*) +(*Print["List of available experiments with tabulated \!\(\*SubscriptBox[\(N\), \(events\)]\) for " <>LLPdirName<>":"]*) +(*ExperimentsListNevents=Table[FileNameTake[ExperimentDirectoriesListNevents[[i]],-1],{i,1,Length[ExperimentDirectoriesListNevents],1}]//Sort;*) +(*ExperimentsListNevents//TableForm*) +(*If[Length[ExperimentsListNevents]==0,Print["No experiment is available, generate first the acceptance for the given experiment using module 1"],*) +(*SelectedExperimentList=If[Length[ExperimentsListNevents]!=0,selectionDialog[ExperimentsListNevents,"Select the experiments for which the sensitivity will be computed:"]];*) +(*icounter=1;*) +(*BlockEvaluation[tag_]:=Block[{},*) +(*nb=EvaluationNotebook[];*) +(*NotebookFind[nb,tag,All,CellTags];*) +(*SelectionEvaluate[nb]*) +(*];*) +(*Do[*) +(*BlockEvaluation["Sensitivity-computation"];*) +(*,{icounter,1,Length[SelectedExperimentList],1}]*) +(*]*) + + +(* ::Chapter::Closed:: *) +(*Specifying the experiment and the HNL model, importing and interpolations*) + + +(* ::Section::Closed:: *) +(*Specifying the model of HNLs*) + + +(* ::Input:: *) +(*Print["Selected experiment:"]*) +(*GivenExperimentForSensitivityComputation=SelectedExperimentList[[icounter++]]*) +(*CondANUBIS=MemberQ[{"ANUBIS-shaft-volume-1","ANUBIS-shaft-volume-2","ANUBIS-shaft-volume-3"},GivenExperimentForSensitivityComputation];*) +(*If[CondANUBIS==True,infoDialog[Row[{"One of the modules of ANUBIS-shaft is chosen. The full sensitivity includes three modules. The importing will be over all modules, so for all ot the the sensitivity has to be computed"}]]]*) +(*If[CondANUBIS==False,GivenExperimentForSensitivityComputationList={GivenExperimentForSensitivityComputation},GivenExperimentForSensitivityComputationList={"ANUBIS-shaft-volume-1","ANUBIS-shaft-volume-2","ANUBIS-shaft-volume-3"}];*) +(*pathsNeventsAll={};*) +(*Do[pathsNeventsAll=Join[pathsNeventsAll,FileNames["*.dat",FileNameJoin[{directory["Nevents-LLP"],exp}]]],{exp,GivenExperimentForSensitivityComputationList}];*) +(*FilenamesNevents=Table[Last@FileNameSplit@pathsNeventsAll[[i]],{i,1,Length[pathsNeventsAll],1}];*) +(*FilenameParameters[i_]:=StringCases[FilenamesNevents[[i]],"Nevents_HNL_MixingPattern_"~~mixinge__~~"-"~~mixing\[Mu]__~~"-"~~mixing\[Tau]__~~"_type_"~~type__~~"_at_"~~experiment__~~"_Npot="~~Npot__~~"_From_"~~mother__~~".dat":>{mixinge//ToExpression,mixing\[Mu]//ToExpression,mixing\[Tau]//ToExpression,type,experiment,Npot,mother}][[1]]*) +(*FilenameParametersAll=Table[FilenameParameters[i],{i,1,Length[FilenamesNevents],1}]//Sort;*) +(*TableHNLtype=DeleteDuplicates[FilenameParametersAll[[All,{1,2,3,4}]]];*) +(*Join[{{"\!\(\*SuperscriptBox[SubscriptBox[\(U\), \(e\)], \(2\)]\)/\!\(\*SuperscriptBox[\(U\), \(2\)]\)","\!\(\*SuperscriptBox[SubscriptBox[\(U\), \(\[Mu]\)], \(2\)]\)/\!\(\*SuperscriptBox[\(U\), \(2\)]\)","\!\(\*SuperscriptBox[SubscriptBox[\(U\), \(\[Tau]\)], \(2\)]\)/\!\(\*SuperscriptBox[\(U\), \(2\)]\)","HNL type"}},TableHNLtype]//TableForm*) +(*dataSelected=dropdownDialog[TableHNLtype,"Choose available HNL mixing pattern and type (xe,x\[Mu],x\[Tau],Type):"];*) +(*Print["Selected mixing pattern:"]*) +(*SelectedMixingPattern={dataSelected[[1]]//ToExpression,dataSelected[[2]]//ToExpression,dataSelected[[3]]//ToExpression}*) +(*patternsshorten=ToString[NumberForm[#,{Infinity,2}]]&/@SelectedMixingPattern;*) +(*Print["Selected type - Dirac or Majorana:"]*) +(*SelectedHNLtype=dataSelected[[4]]*) +(*(*Creating the directory for exporting sensitivity curves*)*) +(*ExperimentFolder=If[CondANUBIS==True,"ANUBIS",GivenExperimentForSensitivityComputation];*) +(*directory["Sensitivity-LLP-exp"]=FileNameJoin[{directory["Sensitivity-LLP"],ExperimentFolder}];*) +(*If[!DirectoryQ[directory["Sensitivity-LLP-exp"]],CreateDirectory[directory["Sensitivity-LLP-exp"]]]*) +(*(*______________________________________________________*)*) +(*(*Importing and interpolation*)*) +(*(*______________________________________________________*)*) +(*Print["Data to import:"]*) +(*ProductionInfoList=Select[FilenameParametersAll,#[[1]]==dataSelected[[1]]&&#[[2]]==dataSelected[[2]]&&#[[3]]==dataSelected[[3]]&&#[[4]]==dataSelected[[4]]&];*) +(*Join[{{"\!\(\*SuperscriptBox[SubscriptBox[\(U\), \(e\)], \(2\)]\)/\!\(\*SuperscriptBox[\(U\), \(2\)]\)","\!\(\*SuperscriptBox[SubscriptBox[\(U\), \(\[Mu]\)], \(2\)]\)/\!\(\*SuperscriptBox[\(U\), \(2\)]\)","\!\(\*SuperscriptBox[SubscriptBox[\(U\), \(\[Tau]\)], \(2\)]\)/\!\(\*SuperscriptBox[\(U\), \(2\)]\)","HNL type","Experiment","\!\(\*SubscriptBox[\(N\), \(PoT\)]\)","Mother"}},ProductionInfoList]//TableForm*) + + +(* ::Section::Closed:: *) +(*Data importing and interpolation*) + + +(* ::Input:: *) +(*NpotDefault=Interpreter["Number"][ProductionInfoList[[1]][[6]]];*) +(*NeventsTabulated//Clear;*) +(*\[Epsilon]reco[mLLP_]=If[StringContainsQ[GivenExperimentForSensitivityComputation,"LHCb-downstream"]==True,0.4,1];*) +(*pathsNeventsIndex=Table[Position[FilenameParametersAll,ProductionInfoList[[i]]][[1]][[1]],{i,1,Length[ProductionInfoList],1}];*) +(*pathsNevents=pathsNeventsAll[[#]]&/@pathsNeventsIndex;*) +(*ProductionChannelsList=ProductionInfoList[[All,-1]];*) +(*Do[*) +(*Module[{prod},*) +(*prod=ProductionChannelsList[[i]];*) +(*(*The condition if one sums the number of events for the same production mode over several experiments*)*) +(*IfprodExists=MemberQ[Keys[DownValues@NeventsTabulated][[All,1,1]],prod];*) +(*NeventsTabulated[prod]=If[!IfprodExists,Import[pathsNevents[[i]],"Table"],Join[NeventsTabulated[prod][[All,{1,2}]],NeventsTabulated[prod][[All,{3}]]+Import[pathsNevents[[i]],"Table"][[All,{3}]]]];*) +(*{mminmax[prod],couplingminmax[prod]}=(NeventsTabulated[prod][[All,#]]//MinMax)&/@{1,2};*) +(*NevMax[prod]=NeventsTabulated[prod][[All,3]]//Max;*) +(*NevInt[mLLP_,U2_,prod]=\[Epsilon]reco[mLLP]*If[mminmax[prod][[1]]<= mLLP<=mminmax[prod][[2]]&&couplingminmax[prod][[1]]<=U2<=couplingminmax[prod][[2]],Evaluate[10^(Interpolation[{Log10[#[[1]]],Log10[#[[2]]],Log10[#[[3]]+10^-90]}&/@NeventsTabulated[prod],InterpolationOrder->1][Log10[mLLP],Log10[U2]])],0];*) +(*]*) +(*,{i,1,Length[pathsNevents],1}]*) +(*{mminmaxOverall,couplingminmaxOverall}=MinMax[Table[#[prod],{prod,ProductionChannelsList}]//Flatten]&/@{mminmax,couplingminmax};*) +(*NevMaxOverall=Max[Table[NevMax[prod],{prod,ProductionChannelsList}]];*) +(*NevIntOverall[mLLP_,U2_]=Sum[NevInt[mLLP,U2,prod],{prod,ProductionChannelsList}];*) +(*pt[mLLP_]:=LogLogPlot[Evaluate[Join[Table[NevInt[mLLP,y,prod],{prod,ProductionChannelsList}]]],{y,couplingminmaxOverall[[1]],couplingminmaxOverall[[2]]},PlotLegends->Placed[Style[#,15]&/@ProductionChannelsList,Right],PlotRange->{couplingminmaxOverall,{10^-2,NevMaxOverall}},Frame->True,ImageSize->Large,FrameLabel->{"\!\(\*SuperscriptBox[\(U\), \(2\)]\)" , "\!\(\*SubscriptBox[\(N\), \(events\)]\)[\!\(\*SubscriptBox[\(m\), \(N\)]\),\!\(\*SuperscriptBox[\(U\), \(2\)]\)]"},FrameStyle->Directive[Black, 23],PlotStyle->{{Thick,Blue},{Thick,Darker@Red},{Thick,Darker@Darker@Green},{Thick,Black},{Thick,Blue,Dashing[0.02]},{Thick,Darker@Red,Dashing[0.02]},{Thick,Darker@Darker@Green,Dashing[0.02]},{Thick,Black,Dashing[0.02]}},PlotLabel->Style[Row[{GivenExperimentForSensitivityComputation,". \!\(\*SubscriptBox[\(m\), \(N\)]\) = ",mLLP, " GeV"}],20,Black]]*) +(*pt[1.5]*) + + +(* ::Chapter::Closed:: *) +(*Sensitivity*) + + +(* ::Section::Closed:: *) +(*Subscript[N, events] density plot*) + + +(* ::Input:: *) +(*plot=DensityPlot[Evaluate[Log10[NevIntOverall[mLLP,\[Epsilon]2]]],{mLLP,mminmaxOverall[[1]],mminmaxOverall[[2]]},{\[Epsilon]2,couplingminmaxOverall[[1]],couplingminmaxOverall[[2]]},ScalingFunctions->{"Log","Log"},AspectRatio->0.78,PlotRange->{All,All,{Log10[2.3],Log10[NevMaxOverall]}},ImageSize->Large,FrameLabel->{"\!\(\*SubscriptBox[\(m\), \(N\)]\) [GeV]","\!\(\*SuperscriptBox[\(U\), \(2\)]\)"}, Frame-> True, FrameStyle->Directive[Black, 25],PlotPoints->100,PlotLegends->Placed[BarLegend[{Automatic,{Log10[2.3],Log10[NevMaxOverall]}},LegendMarkerSize->340,LegendLabel->Placed["\!\(\*SubscriptBox[\(Log\), \(10\)]\)[\!\(\*SubscriptBox[\(N\), \(ev\)]\)]",Bottom],LabelStyle->{FontSize->22},Method->{FrameStyle->Black,AxesStyle->None,TicksStyle->Black}],Right],PlotLabel->Style[Row[{ExperimentFolder}],20,Black](*,FrameTicks->{{Automatic,Automatic},{TicksPlotx,None}}*)]*) +(*(*Export[FileNameJoin[{NotebookDirectory[],"plots/SensCalc/NeventsDensityPlotExample.pdf"}],plot,"AllowRasterization"->False]*)*) + + +(* ::Section::Closed:: *) +(*Constraints importing*) + + +(* ::Input:: *) +(*importformat["txt"]=importformat["dat"]="Table";*) +(*importformat["m"]=importformat["mx"]="MX";*) +(*importformat["xls"]="XLS";*) +(*dir=FileNameJoin[{NotebookDirectory[],"contours",LLPdirName}];*) +(*If[DirectoryQ[dir],*) +(*filenames=FileNames[LLPdirName<>"-excluded*",dir,Infinity];*) +(*ExcludedRegions[LLPdirName]=Import[#,importformat[FileExtension[#]]]&/@FileNames[LLPdirName<>"-excluded*",dir,Infinity];*) +(*];*) +(*If[!DirectoryQ[dir],*) +(*ExcludedRegions[LLPdirName]={{{10.,10.}}};*) +(*]*) +(*Seesaw=Table[{mN,5*10^-11/mN},{mN,0.01,90,0.1}];*) +(*ExcludedRegionsTemp[LLPdirName]=If[SelectedHNLtype=="Majorana",If[SelectedMixingPattern=={1,0,0},{Seesaw,ExcludedRegions[LLPdirName][[1]],ExcludedRegions[LLPdirName][[4]]},If[SelectedMixingPattern=={0,1,0},{Seesaw,ExcludedRegions[LLPdirName][[2]],ExcludedRegions[LLPdirName][[5]]},If[SelectedMixingPattern=={0,0,1},{Seesaw,ExcludedRegions[LLPdirName][[3]],ExcludedRegions[LLPdirName][[6]]},{Seesaw}]]],{Seesaw}];*) + + +(* ::Section::Closed:: *) +(*Sensitivity*) + + +(* ::Input:: *) +(*SensitivityBlock[Nev_,Npot_,SelectedProduction_]:=Block[{},*) +(*NevTot[mLLP_,U2_]=Sum[NevInt[mLLP,U2,prod],{prod,SelectedProduction}];*) +(*RegSens=RegionPlot[Npot/NpotDefault NevTot[10^mLLP,10^U2]>= Nev,{mLLP,Log10[mminmaxOverall[[1]]],Log10[mminmaxOverall[[2]]]},{U2,Log10[couplingminmaxOverall[[1]]],Log10[couplingminmaxOverall[[2]]]},PlotPoints->200];*) +(*SensTemp=Cases[Normal@RegSens,Line[x_]:>x,Infinity];*) +(*Sens=Table[{10^#[[1]],10^#[[2]]}&/@SensTemp[[i]],{i,1,Length[SensTemp],1}];*) +(*filename=ToString@StringForm["Sensitivity_HNL_Pattern_``-``-``_``_at_``_Nev=``_Npot=``.xls",Sequence@@{patternsshorten[[1]],patternsshorten[[2]],patternsshorten[[3]],SelectedHNLtype,ExperimentFolder,Nev//ToString,Npot//CForm//ToString}];*) +(*Export[FileNameJoin[{directory["Sensitivity-LLP-exp"],filename}],Sens];*) +(*Sens*) +(*]*) +(*productionlist=Join[{"All"},ProductionChannelsList];*) +(*DynamicModule[{input1=NpotDefault,input2=2.3,choice={"All"},list,phrase},*) +(*DialogInput[Column[{Style[ExperimentFolder,Bold],TextCell["Enter the number of proton collisions:"],InputField[Dynamic[input1],Expression],TextCell["Enter the value of N_ev,min for which the sensitivity will be computed:"],InputField[Dynamic[input2],Expression],Row[{"Select the production channels to be used for the sensitivity calculation:"}],Pane[TogglerBar[Dynamic[choice],productionlist,Appearance->"Vertical"->{Automatic,1}],ImageSize->{Automatic,Automatic},Scrollbars->{False,True}],Button["Submit",DialogReturn[{NpotVal,NevMinVal,SelectedProduction}={input1,input2,choice}//N],ImageSize->Automatic]}]]];*) +(*If[MemberQ[SelectedProduction,"All"],SelectedProduction=ProductionChannelsList;]*) +(*{{"\!\(\*SubscriptBox[\(N\), \(PoT\)]\) for computation","\!\(\*SubscriptBox[\(N\), \(ev, min\)]\)","Selected production modes"},{NpotVal,NevMinVal,SelectedProduction}}//TableForm*) +(*sens=SensitivityBlock[NevMinVal,NpotVal,SelectedProduction];*) +(*Show[ListLogLogPlot[Cases[ExcludedRegionsTemp[LLPdirName],_?MatrixQ,All],Joined->{True,True,True,True},Frame-> True,FrameLabel->{"\!\(\*SubscriptBox[\(m\), \(N\)]\) [GeV]" , "\!\(\*SuperscriptBox[\(U\), \(2\)]\)"},FrameStyle->Directive[Black, 23],PlotStyle->{{Thick,Gray}},Filling->{1->{Bottom,Directive[Gray,Opacity[0.3]]},2->{True,Directive[Gray,Opacity[0.3]]},3->{Bottom,Directive[Gray,Opacity[0.1]]},4->{True,Directive[Gray,Opacity[0.3]]}},ImageSize->Large,PlotRange->{{1.01mminmaxOverall[[1]],1.1mminmaxOverall[[2]]},{0.3Min[Flatten[Sens]],0.98couplingminmaxOverall[[2]]}},PlotLabel->Style[Row[{"\!\(\*SubscriptBox[\(N\), \(events\)]\) \[GreaterEqual] ",NevMinVal}],18,Black]],*) +(*ListLogLogPlot[Cases[sens,_?MatrixQ,All],Joined->{True,True,True,True},PlotStyle->Flatten[{ConstantArray[{Thick,Blue},If[MatrixQ[sens],1,Length@sens]]},1],ImageSize->Large,PlotRange->{{1.01mminmaxOverall[[1]],1.1mminmaxOverall[[2]]},{couplingminmaxOverall[[1]],Max[0.2,0.98couplingminmaxOverall[[2]]]}},PlotLabel->Style[Row[{"\!\(\*SubscriptBox[\(N\), \(events\)]\) \[GreaterEqual] ",NevMinVal}],18,Black],PlotLegends->Placed[Style[#,15]&/@{ExperimentFolder},{0.2,0.15}]],Graphics[{Text[Style["Excluded",24,Black],Scaled[{0.7,0.95}]]}]]*) + + +(* ::Title::Closed:: *) +(*Deleting generated cells*) + + +(* ::Input:: *) +(*FrontEndTokenExecute["DeleteGeneratedCells"];*) +(*FrontEndTokenExecute["SelectAll"];*) +(*FrontEndTokenExecute["SelectionCloseAllGroups"];*) diff --git a/wls/3. Scalar sensitivity.wls b/wls/3. Scalar sensitivity.wls new file mode 100755 index 0000000..9162ac2 --- /dev/null +++ b/wls/3. Scalar sensitivity.wls @@ -0,0 +1,900 @@ +#!/usr/bin/env wolframscript +(* ::Package:: *) + +(* ::Title::Closed:: *) +(*Just launch the code below to run the notebook (shift+enter)*) + + +(* ::Input:: *) +(*ClearAll["Global`*"]*) +(*ParallelEvaluate[ClearAll["Global`*"]];*) +(*(*EnsureFreshKernels[]:=Module[{},*) +(*(*Check if the marker variable is defined in any kernel*)If[MemberQ[ParallelEvaluate[$KernelInitializationDone],True],*) +(*(*If yes,close and relaunch kernels*)*) +(*CloseKernels[];*) +(*LaunchKernels[];*) +(*];*) +(*(*Set or reset the marker variable in all kernels*)*) +(*ParallelEvaluate[$KernelInitializationDone=True];]*) +(*EnsureFreshKernels[];*)*) +(*CloseKernels[];*) +(*LaunchKernels[];*) +(*BlockEvaluation[tag_]:=Block[{},*) +(*nb=EvaluationNotebook[];*) +(*NotebookFind[nb,tag,All,CellTags];*) +(*SelectionEvaluate[nb]*) +(*]*) +(*dropdownDialog[list_,phrase_]:=DialogInput[{choice=""},Column[{TextCell[phrase],PopupMenu[Dynamic[choice],list],Button["OK",DialogReturn[choice]]}]]*) +(*infoDialog[phrase_]:=DialogInput[{choice=""},Column[{TextCell[phrase],Button["Proceed",DialogReturn[choice]]}]]*) +(*If[(DirectoryQ[FileNameJoin[{NotebookDirectory[],"Auxiliary data"}]]//ToString)=="False",CreateDirectory[FileNameJoin[{NotebookDirectory[],"Auxiliary data"}]]];*) +(*choiceslist={"Tabulated Nevents+sensitivity","Sensitivity only (tabulated Nevents must be produced before)","Acceptance"};*) +(*taglist["Acceptance"]="Acceptance";*) +(*taglist["Tabulated Nevents+sensitivity"]="Number-of-events+sensitivity";*) +(*taglist["Sensitivity only (tabulated Nevents must be produced before)"]="Sensitivity";*) +(*computationchoice=dropdownDialog[choiceslist,"Do you want to compute the tabulated number of events and then sensitivity, or just sensitivity (if the tabulated number of events has been already produced)?"];*) +(*tagselected=taglist[computationchoice]*) +(*BlockEvaluation[tagselected]*) + + +(* ::Title::Closed:: *) +(*Preliminary definitions*) + + +(* ::Chapter::Closed:: *) +(*Various directories*) + + +(* ::Input:: *) +(*LLPdirName="Scalar";*) +(*(*Set the directory for the search where tabulated acceptances are located*)*) +(*directory["Acceptances"]=FileNameJoin[{NotebookDirectory[],"Acceptances"}];*) +(*(*Set the directory for the search where tabulated angle-energy distributions are located*)*) +(*directory["Distribution"]=FileNameJoin[{NotebookDirectory[],"spectra/New physics particles spectra",LLPdirName}]; *) +(*(*The directory storing production weights of the given LLP*)*) +(*directory["Production weights"]=FileNameJoin[{NotebookDirectory[],"phenomenology",LLPdirName,"Production probabilities"}]; *) +(*(*Directory to which various auxillary datasets will be stored*)*) +(*directory["Auxiliary"]=FileNameJoin[{NotebookDirectory[],"Auxiliary data",LLPdirName}]; *) +(*If[!DirectoryQ[directory["Auxiliary"]],CreateDirectory[directory["Auxiliary"]]];*) +(*(*Directory containing decay widths of the LLPs*)*) +(*directory["Decays"]=FileNameJoin[{NotebookDirectory[],"phenomenology",LLPdirName,"decay widths"}]; *) + + +(* ::Chapter::Closed:: *) +(*Parameters and various functions*) + + +(* ::Input:: *) +(*dropdownDialog[list_,phrase_]:=DialogInput[{choice=""},Column[{TextCell[phrase],PopupMenu[Dynamic[choice],list],Button["OK",DialogReturn[choice]]}]]*) +(*infoDialog[phrase_]:=DialogInput[{choice=""},Column[{TextCell[phrase],Button["Proceed",DialogReturn[choice]]}]]*) +(*selectionDialog[list_,phrase_]:=DialogInput[{choice={}},Column[{Row[{phrase}],Pane[TogglerBar[Dynamic[choice],list,Appearance->"Vertical"->{Automatic,5}],ImageSize->{Automatic,Automatic},Scrollbars->{False,True}],Button["OK",DialogReturn[choice]]}]]*) +(*(*chbar*)*) +(*chbar= 6.6*10^-25*3*10^8;*) +(*(*Masses of various SM particles*)*) +(*{mSM["Bplus"],mSM["Kplus"],mSM["PiPlus"],mSM["h"],mSM["Bs"]}={5.279,0.495,0.139,62.5,5.366};*) +(*(*Fragmentation fractions at the LHC. For the moment, the same fractions are assumed to be at the FCC-hh*)*) +(*fbtob0["LHC"]=fbtobplus["LHC"]=fbtob0["FCC-hh"]=fbtobplus["FCC-hh"]=0.324;*) +(*fbtobs["LHC"]=fbtobs["FCC-hh"]=0.09;*) +(*(*Fragmentation fractions at SPS. From SHiP physics paper*)*) +(*fbtobs["SPS"]=0.11;*) +(*fbtob0["SPS"]=fbtobplus["SPS"]=0.411;*) +(*fstokplus["SPS"]=0.5;*) +(*fstok0l["SPS"]=0.25;*) +(*(*Fraction of K^+/- decaying in-flight at SPS, from https://arxiv.org/pdf/2004.07974.pdf*)*) +(*fractionDecayInFlightKplusKminus=(0.29+0.07);*) +(*(*Fragmentation fractions at FermilabBD. Assumed to be the same as at SPS*)*) +(*fbtobs["FermilabBD"]=0.11;*) +(*fbtob0["FermilabBD"]=fbtobplus["FermilabBD"]=0.411;*) +(*(*Fragmentation fractions at Serpukhov. Assumed to be zero*)*) +(*fbtobs["Serpukhov"]=0.;*) +(*fbtob0["Serpukhov"]=fbtobplus["Serpukhov"]=0.;*) + + +(* ::Chapter::Closed:: *) +(*LLP phenomenology: prodution probabilities, decay widths*) + + +(* ::Section::Closed:: *) +(*Production weights*) + + +(* ::Subsection::Closed:: *) +(*Non-bremsstrahlung*) + + +(* ::Input:: *) +(*PmotherToLLP//Clear;*) +(*FacilitiesList={"SPS","FermilabBD","LHC","FCC-hh","Serpukhov"};*) +(*intProd[filename_,m1_,m2_]:=If[mLLP1][mLLP]],0.];*) +(*BrhtoSS[mLLP_,\[Alpha]_]=2*10^-2*\[Alpha]^2 Sqrt[1-4*mLLP^2/125^2];*) +(*(*Value of \[Alpha] corresponding to the given Br(h\[Rule]SS)=0.01*)*) +(*\[Alpha]valBrhToSS[mS_,BrhToSS_]=\[Alpha]/.Solve[BrhtoSS[mS,\[Alpha]]==BrhToSS,\[Alpha]][[2]];*) +(*Print["Exclusive/inclusive production of dark scalar in decays B->\!\(\*SubscriptBox[\(X\), \(s\)]\)+S:"]*) +(*SelectedBrChoice=dropdownDialog[{"Exclusive","Inclusive"},"Select the description of the scalar's production by decays of B via mixing (see 1904.10447):"]*) +(*Do[*) +(*PmotherToLLP[mLLP_,\[Theta]2_,BrhToSS_,"B-mixing",Facility]=\[Theta]2*(fbtob0[Facility]+fbtobplus[Facility])intProd[If[SelectedBrChoice=="Exclusive","BtoXsStotal.dat","BtoXsSinclusive.dat"],mSM["Bplus"],mSM["PiPlus"]];*) +(*(*Factors of 2 and 1/2 are due to the production of scalars in pairs. \[Alpha] is the quartic coupling defined by Subscript[L, int] = \[Alpha]/(2v)S^2H^+H*)*) +(*PmotherToLLP[mLLP_,\[Theta]2_,BrhToSS_,"B-quartic",Facility]=2*\[Alpha]valBrhToSS[mLLP,BrhToSS]^2*(fbtob0[Facility]+fbtobplus[Facility])*intProd["BplustoXsSStotal.dat",mSM["Bplus"]/2,mSM["PiPlus"]/2];*) +(*PmotherToLLP[mLLP_,\[Theta]2_,BrhToSS_,"Bs-quartic",Facility]=2*\[Alpha]valBrhToSS[mLLP,BrhToSS]^2*fbtobs[Facility]*intProd["BstoSS.dat",mSM["Bs"]/2,0.];*) +(*If[MemberQ[{"LHC","FCC-hh"},Facility],*) +(*PmotherToLLP[mLLP_,\[Theta]2_,BrhToSS_,"h-quartic",Facility]=2*10^-2*\[Alpha]valBrhToSS[mLLP,BrhToSS]^2 Sqrt[1-4*mLLP^2/125^2];*) +(*];*) +(*,{Facility,FacilitiesList}];*) +(*(*Production from K at beam dump experiments with thick target. Assumed to be the same independently of target's material. Also, the fraction of Subscript[(K^0), L] decaying at rest is assumed to be the same as the fraction of charged kaons*)*) +(*PmotherToLLP[mLLP_,\[Theta]2_,BrhToSS_,"K-mixing","SPS"]=\[Theta]2*(fstokplus["SPS"]*intProd["KplustoPiS.dat",mSM["Kplus"],mSM["PiPlus"]]+fstok0l["SPS"]*intProd["K0LtoPiS.dat",mSM["Kplus"],mSM["PiPlus"]]);*) + + +(* ::Subsection::Closed:: *) +(*Bremsstrahlung*) + + +(* ::Input:: *) +(*(*________________*)*) +(*(*Bremsstrahlung*)*) +(*(*________________*)*) +(*BremProd[Facility_]:=Module[{},*) +(*bremprobfiles=FileNames["Pbrem*_"<>Facility<>".m",directory["Production weights"]];*) +(*If[bremprobfiles!={},*) +(*(*Scanning over all available files with the bremsstrahlung probability. They describe different descriptions of the bremsstrahlung*)*) +(*(*Extract the bremsstrahlung description from the filename*)*) +(*bremprobfilenames=Last@FileNameSplit[#]&/@bremprobfiles;*) +(*bremdescription=("Bremsstrahlung-"<>(StringSplit[#,{"Pbrem_"<>LLPdirName<>"_","_"}][[1]])&/@bremprobfilenames);*) +(*Do[*) +(*datbrem[mLLP_,\[Theta]LLP_]=Import[bremprobfiles[[i]],"MX"];*) +(*If[StringContainsQ[bremdescription[[i]],"BB"],*) +(*PmotherToLLP[mLLP_,\[Theta]2_,BrhToSS_,bremdescription[[i]],Facility]=datbrem[mLLP,\[Theta]LLP][[1]]*\[Theta]2;*) +(*ELLPmin[bremdescription[[i]],Facility]=Evaluate[datbrem[mLLP,\[Theta]LLP][[2]]];*) +(*\[Theta]maxBrem[bremdescription[[i]],Facility]=Evaluate[datbrem[mLLP,\[Theta]LLP][[3]]];*) +(*ELLPmax[mLLP_,\[Theta]LLP_,bremdescription[[i]],Facility]=Evaluate[datbrem[mLLP,\[Theta]LLP][[4]]];*) +(*,*) +(*Do[*) +(*Module[{bremname},*) +(*bremname=bremdescription[[i]]<>"-"<>datbrem[mLLP,\[Theta]LLP][[j]][[1]]<>"-mixing";*) +(*PmotherToLLP[mLLP_,\[Theta]2_,BrhToSS_,bremname,Facility]=datbrem[mLLP,\[Theta]LLP][[j]][[2]]*\[Theta]2;*) +(*ELLPmin[bremname,Facility]=Evaluate[datbrem[mLLP,\[Theta]LLP][[j]][[3]]];*) +(*\[Theta]maxBrem[bremname,Facility]=Evaluate[datbrem[mLLP,\[Theta]LLP][[j]][[4]]];*) +(*ELLPmax[mLLP_,\[Theta]LLP_,bremname,Facility]=Evaluate[datbrem[mLLP,\[Theta]LLP][[j]][[5]]];*) +(*]*) +(*,{j,1,Length[datbrem[mLLP,\[Theta]LLP]],1}]*) +(*]*) +(*,{i,1,Length[bremdescription],1}]*) +(*]*) +(*]*) +(*Do[*) +(*BremProd[Facility],{Facility,{"FCC-hh","Serpukhov","SPS","FermilabBD","LHC"}}];*) +(*(*Scaling of the lower bound: Subscript[(\[Theta]^2), lower bound] ~ ((\!\( *) +(*\*SubscriptBox[\(N\), \(ev\)]*) +(*\*SubscriptBox[\(|\), \(\[Theta]\ = \ 1\)]\))^(-\[Beta]/2))*)*) +(*WeightsCombinations=Keys[DownValues@PmotherToLLP][[All,1,#]]&/@{4,5}//Transpose//Sort;*) +(*LowerBoundScaling["B-mixing"]=LowerBoundScaling["K-mixing"]=1;*) +(*Do[*) +(*prodLowerBoundScaling[prod]=If[StringContainsQ[prod,"mixing"],1,If[StringContainsQ[prod,"quartic"],2]];*) +(*,{prod,WeightsCombinations[[All,1]]//DeleteDuplicates}]*) + + +(* ::Section::Closed:: *) +(*Scanning for tabulated distributions*) + + +(* ::Input:: *) +(*(*Define the file pattern*)*) +(*pattern="DoubleDistr_*_*_*.m";*) +(*(*Search for files matching the pattern in the directory and its subdirectories*)*) +(*matchingFiles=FileNames[pattern,{directory["Distribution"]},Infinity];*) +(*(*List of LLPs, production modes, and facilities for which the tabulated distributions have been computed at the previous stage of using SensCalc*)*) +(*ExtractedProductionParameters=Function[filename,parts=StringSplit[FileNameTake[filename],"_"];*) +(*{parts[[2]],parts[[3]],StringDrop[parts[[4]],-2]} ];*) +(*(*combinations selected LLP, production channel, facility for which the tabulated distributions are present*)*) +(*Print["List of available distributions:"]*) +(*DistrCombinations=(ExtractedProductionParameters/@matchingFiles)//Sort*) +(**) +(*If[MemberQ[DistrCombinations[[All,2]],"Bremsstrahlung-FR-mixing"]||MemberQ[DistrCombinations[[All,2]],"Bremsstrahlung-AP-mixing"],*) +(*FacilitiesFR=Select[DistrCombinations,StringContainsQ[#[[2]],{"FR"}]&][[All,3]];*) +(*FacilitiesAP=Select[DistrCombinations,StringContainsQ[#[[2]],{"AP"}]&][[All,3]];*) +(*DistrCombinationsToCheck=Select[DistrCombinations,!StringContainsQ[#[[2]],{"FR","AP"}]&];*) +(*DistrCombinationsToCheck=Join[DistrCombinationsToCheck,Flatten[Table[{LLPdirName,brem,fac},{fac,FacilitiesFR},{brem,Select[WeightsCombinations,#[[2]]==fac&&StringContainsQ[#[[1]],"FR"]&][[All,1]]}],1],Flatten[Table[{LLPdirName,brem,fac},{fac,FacilitiesAP},{brem,Select[WeightsCombinations,#[[2]]==fac&&StringContainsQ[#[[1]],"AP"]&][[All,1]]}],1]]//Sort;*) +(*,*) +(*DistrCombinationsToCheck=DistrCombinations*) +(*]*) +(*DistrCombinationsToCheck;*) +(*Print["If there are production weights to all available distributions:"]*) +(*IfCondDistrToWeights=True;*) +(*Do[*) +(*IfCondDistrToWeights=Select[WeightsCombinations,#[[1]]==DistrCombinationsToCheck[[i]][[2]]&&#[[2]]==DistrCombinationsToCheck[[i]][[3]]&]!={};*) +(*If[IfCondDistrToWeights==False,Break[]];*) +(*,{i,1,Length[DistrCombinationsToCheck],1}]*) +(*IfCondDistrToWeights*) +(*If[!IfCondDistrToWeights,infoDialog["You have not provided the production probabilities PmotherToLLP to all the generated tabulated distributions! Please do this first to avoid problems"];]*) + + +(* ::Section::Closed:: *) +(*LLP lifetime*) + + +(* ::Input:: *) +(*(*Decay length of the scalar - following Winkler*)*) +(*c\[Tau]LLP[mLLP_,\[Theta]2_]=1/\[Theta]2 Interpolation[Select[Import[FileNameJoin[{directory["Decays"],"ctaus.dat"}],"Table"],#[[1]]!=2.&],InterpolationOrder->1][mLLP];*) +(*ldecayLLP[mLLP_,\[Theta]2_,ELLP_]=c\[Tau]LLP[mLLP,\[Theta]2]*Sqrt[ELLP^2-mLLP^2]/mLLP;*) + + +(* ::Chapter::Closed:: *) +(*Loading necessary routines*) + + +(* ::Input:: *) +(*If[Length[inecessary]==0,*) +(*NotebookEvaluate[FileNameJoin[{NotebookDirectory[],"codes/generic.nb"}]];*) +(*NotebookEvaluate[FileNameJoin[{NotebookDirectory[],"codes/for-sensitivities.nb"}]];*) +(*inecessary={1,2,3};*) +(*]*) + + +(* ::Title::Closed:: *) +(*Specifying the experiment*) + + +(* ::Input:: *) +(*SetDirectory[NotebookDirectory[]];*) +(*(*Parent directory*)*) +(*NotebookDirectory[]//ParentDirectory;*) +(*ExperimentDirectoriesList=Select[FileNames["*",directory["Acceptances"],1],DirectoryQ];*) +(*(*List of available experiments (for which the geometry has been implemented)*)*) +(*ExperimentsListTemp=Table[FileNameTake[ExperimentDirectoriesList[[i]],-1],{i,1,Length[ExperimentDirectoriesList],1}];*) +(*ExperimentsListTemp2=Join[Partition[ExperimentsListTemp,1],Table[{TrueQ@FileExistsQ@FileNameJoin[{directory["Acceptances"],ExperimentsListTemp[[i]],ToString@StringForm["Acceptance_``_for_``.m",ExperimentsListTemp[[i]],LLPdirName]}]},{i,1,Length[ExperimentsListTemp]}],2];*) +(*Print["List of available experiments:"]*) +(*ExperimentsList=Select[ExperimentsListTemp2,#[[2]]==True&][[All,1]]//Sort*) +(*If[Length[ExperimentsList]==0,Print["No experiment is available, generate first the acceptance for the given experiment using module 1"]]*) +(*Print["Selected experiments:"]*) +(*dropdownDialog[list_,phrase_]:=DialogInput[{choice=""},Column[{TextCell[phrase],PopupMenu[Dynamic[choice],list],Button["OK",DialogReturn[choice]]}]]*) +(*SelectedExperimentList=If[Length[ExperimentsList]!=0,selectionDialog[ExperimentsList,"Select the experiments:"]]*) +(*icounter=1;*) + + +(* ::Chapter::Closed:: *) +(*Running block for next sections*) + + +(* ::Input:: *) +(*BlockEvaluation[tag_]:=Block[{},*) +(*nb=EvaluationNotebook[];*) +(*NotebookFind[nb,tag,All,CellTags];*) +(*SelectionEvaluate[nb]*) +(*]*) +(*If[tagselected=="Number-of-events+sensitivity",*) +(*Do[*) +(*BlockEvaluation["Number-of-events-computation+sensitivity"];*) +(*,{icounter,1,Length[SelectedExperimentList],1}],*) +(*If[tagselected=="Acceptance",*) +(*Do[*) +(*BlockEvaluation["Acceptance-computation"];*) +(*,{icounter,1,Length[SelectedExperimentList],1}]*) +(*]*) +(*]*) + + +(* ::Title::Closed:: *) +(*Number of events*) + + +(* ::Chapter::Closed:: *) +(*Particular experiment*) + + +(* ::Input:: *) +(*SelectedExperiment=SelectedExperimentList[[icounter++]];*) +(*Print[Row[{"Experiment ",icounter-1,"/",Length[SelectedExperimentList]}]]*) + + +(* ::Chapter::Closed:: *) +(*Cross-sections, acceptances*) + + +(* ::Section::Closed:: *) +(*Cross-sections, acceptances*) + + +(* ::Input:: *) +(*dataAcceptances=Import[FileNameJoin[{FileNameJoin[{directory["Acceptances"],SelectedExperiment,ToString@StringForm["Acceptance_``_for_``.m",Sequence@@{SelectedExperiment,LLPdirName}]}]}],"MX"];//AbsoluteTiming*) +(*{FacilityGivenExperiment,FullAcceptanceData0,BrVis[mLLP_]}=dataAcceptances[[#]]&/@{1,3,5};*) +(*LogLogPlot[Evaluate[BrVis[mLLP]],{mLLP,0.02,10},Frame->True,ImageSize->Large,FrameStyle->Directive[Black, 22],PlotStyle->{{Thickness[0.003],Blue},{Thickness[0.003],Darker@Red},{Thickness[0.003],Darker@Darker@Green},{Thickness[0.003],Black}},GridLines->Automatic,PlotRange->{{0.1,10},{0.01,1.2}},Frame->True,ImageSize->Large,FrameLabel->{"m [GeV]","\!\(\*SubscriptBox[\(Br\), \(vis\)]\)"},PlotLabel-> Style[Row[{"For ",SelectedExperiment}], 20, Black]]*) +(*(*___________________________*)*) +(*(*Interpolation of the tabulated azimuthal acceptance, extracting Subscript[\[Theta], min/max], etc.*)*) +(*(*___________________________*)*) +(*{AzimuthalAcceptanceInt[\[Theta]LLP_,zLLP_],\[Theta]minExpAll,\[Theta]maxExpAll,\[Theta]minExp,\[Theta]maxExp,zminExp,zmaxExp,zmin\[Theta][\[Theta]LLP_],zmax\[Theta][\[Theta]LLP_]}=Block\[Epsilon]Azimuthal[FullAcceptanceData0];*) +(*(*Logarithmized data with full acceptance, and also decay acceptance and full acceptance interpolations*)*) +(*{FullAcceptanceData,DecayAcceptanceInt[mLLP_,\[Theta]LLP_,ELLP_,zLLP_],FullAcceptanceInt[mLLP_,\[Theta]LLP_,ELLP_,zLLP_],InGridm\[Epsilon],InGrid\[Theta]\[Epsilon],InGridE\[Epsilon],InGridz\[Epsilon],\[Epsilon]vals,\[Epsilon]azvals,mmin\[Epsilon],mmax\[Epsilon]}=Block\[Epsilon]Decay[FullAcceptanceData0,zminExp,BrVis];*) +(*CrossSectionData=dataAcceptances[[4]]//Transpose;*) +(*NpotGivenExperiment=Select[CrossSectionData,#[[1]]=="Npot"&][[1]][[2]]//N;*) +(*(*infoDialog[Row[{"The number of proton collisions is ", NpotGivenExperiment,". You may change it at the stage of computing the sensitivities"}]]*)*) +(*(*Total number of b Overscript[b, _] and h*)*) +(*ProbMother["B-mixing"]=ProbMother["B-quartic"]=ProbMother["Bs-quartic"]=Select[CrossSectionData,#[[1]]=="Pb"&][[1]][[2]];*) +(*ProbMother["h-quartic"]=Select[CrossSectionData,#[[1]]=="Ph"&][[1]][[2]];*) +(*ProbMother["K-mixing"]=If[FacilityGivenExperiment=="SPS",fractionDecayInFlightKplusKminus,0.];*) +(*ProbMother["Bremsstrahlung-AP-mixing"]=ProbMother["Bremsstrahlung-FR-mixing"]=ProbMother["Bremsstrahlung-BB-mixing"]=1.;*) +(*{{"\!\(\*SubscriptBox[\(\[Chi]\), \(b\\\ or\\\ \*OverscriptBox[\(b\), \(_\)]\)]\)","\!\(\*SubscriptBox[\(\[Chi]\), \(h\)]\)"},{ProbMother["B-mixing"],ProbMother["h-quartic"]}}//TableForm*) +(*Row[{"Search for "<>LLPdirName<>" at ", SelectedExperiment, " located at ",FacilityGivenExperiment,". \!\(\*SubscriptBox[\(N\), \(collisions\)]\) = ",NpotGivenExperiment}]*) +(*{{"Quantity","\!\(\*SubscriptBox[\(\[Theta]\), \(min\)]\), rad","\!\(\*SubscriptBox[\(\[Theta]\), \(max\)]\), rad","\!\(\*SubscriptBox[\(\[Theta]\), \(min\)]\)(\!\(\*SubscriptBox[\(\[Epsilon]\), \(dec\)]\)), rad","\!\(\*SubscriptBox[\(\[Theta]\), \(max\)]\)(\!\(\*SubscriptBox[\(\[Epsilon]\), \(dec\)]\)), rad","\!\(\*SubscriptBox[\(z\), \(min\)]\), m","\!\(\*SubscriptBox[\(z\), \(max\)]\), m"},{"Description","Min angle covered by experiment","Max angle covered by experiment","Min angle where \!\(\*SubscriptBox[\(\[Epsilon]\), \(decay\)]\)\[NotEqual]0","Max angle where \!\(\*SubscriptBox[\(\[Epsilon]\), \(decay\)]\)\[NotEqual]0","Min long. displacement of the decay volume","Max long. displacement of the decay volume"},{"Value",\[Theta]minExpAll,\[Theta]maxExpAll,\[Theta]minExp,\[Theta]maxExp,zminExp,zmaxExp}}//TableForm*) + + +(* ::Input:: *) +(*Export[FileNameJoin[{NotebookDirectory[],"temp1/FACET/acc-Pre-FACET.mx"}],FullAcceptanceInt[mLLP,\[Theta]LLP,ELLP,zLLP],"MX"]*) + + +(* ::Chapter::Closed:: *) +(*LLP angle-energy distributions for the given experiment*) + + +(* ::Section::Closed:: *) +(*Importing and definitions*) + + +(* ::Subsection::Closed:: *) +(*Specifying production channels*) + + +(* ::Input:: *) +(*(*List of production channels for the selected facility*)*) +(*ProductionPatternSelectedDistr=Select[DistrCombinations,#[[3]]==FacilityGivenExperiment&];*) +(*ProductionPatternSelected=Select[DistrCombinationsToCheck,#[[3]]==FacilityGivenExperiment&];*) +(*ProductionListTemp=ProductionPatternSelected[[All,2]]//DeleteDuplicates;*) +(*(*Selecting only those bremsstrahlung channels for which the distribution is non-zero*)*) +(*BremVariantsGivenFacility=Select[WeightsCombinations[[All,{1,2}]],#[[2]]==FacilityGivenExperiment&&StringContainsQ[#[[1]],"Bremsstrahlung"]&][[All,1]];*) +(*Do[*) +(*ProbMother[channel]=1;*) +(*,{channel,Join[{"DrellYan"},BremVariantsGivenFacility,{"Mixing","Mixing-Old"}]}]*) +(*Print["Production list:"]*) +(*(*Deciding if the bremsstrahlung contributes to the production by comparing Subscript[\[Theta], max,brem] with Subscript[\[Theta], min,experiment]*)*) +(*Do[*) +(*ELLPmax[mLLP_,\[Theta]LLP_,ch]=ELLPmax[mLLP,\[Theta]LLP,ch,FacilityGivenExperiment];*) +(*ELLPmin[ch]=ELLPmin[ch,FacilityGivenExperiment];*) +(*\[Theta]maxBrem[ch]=\[Theta]maxBrem[ch,FacilityGivenExperiment]*) +(*,{ch,BremVariantsGivenFacility}]*) +(*ProdListBrem=Select[ProductionListTemp,StringContainsQ[#,"Bremsstrahlung"]&];*) +(*(*ProdListBremSelected=Select[ProdListBrem,\[Theta]maxBrem[#]>\[Theta]minExp&];*)*) +(*ProdListBremSelected=ProdListBrem;*) +(*ProductionList=Join[ProdListBremSelected,Select[ProductionListTemp,!StringContainsQ[#,"Bremsstrahlung"]&]]*) +(*(*Production list with only baseline bremsstrahlung description*)*) +(*BremSelected="Bremsstrahlung-AP-Central-mixing";*) +(*ProductionListBaseline=Select[ProductionList,!StringContainsQ[#,"Bremsstrahlung"]||#==BremSelected&];*) +(*Do[*) +(*If[!MemberQ[ProductionList,_String?(StringContainsQ[#,pattern]&)],*) +(*ProductionPatternSelectedDistr=Select[ProductionPatternSelectedDistr,!StringContainsQ[#[[2]],pattern]&]*) +(*];*) +(*,{pattern,{"AP","Fouroghi-Ritz","BB"}}]*) +(*BremVariantsGivenFacility=Select[ProductionList,StringContainsQ[#,"Bremsstrahlung"]&]*) + + +(* ::Subsection::Closed:: *) +(*Importing distributions*) + + +(* ::Input:: *) +(*Do[*) +(*Module[{prod,prodbrem},*) +(*prod=ProductionPatternSelectedDistr[[i]][[2]];*) +(*dirimp=If[StringContainsQ[prod,{"DrellYan","Mixing"}],FileNameJoin[{directory["Distribution"],"Pregenerated"}],directory["Distribution"]];*) +(*(*Importing the data with distribution*)*) +(*If[!StringContainsQ[prod,{"AP","FR"}],*) +(*DistrDataImport[prod]=Abs[Import[FileNameJoin[{dirimp,"DoubleDistr_"<>LLPdirName<>"_"<>prod<>"_"<>FacilityGivenExperiment<>".m"}],"MX"]];*) +(*If[prod=="DrellYan",*) +(*DistrDataImport[prod]=Select[DistrDataImport[prod],MinMaxMassesDrellYan[FacilityGivenExperiment][[1]]<=#[[1]]<=MinMaxMassesDrellYan[FacilityGivenExperiment][[2]]&];*) +(*];*) +(*,*) +(*(*If the selected channel is Bremsstrahlung under the description of AP or FR, then there are variants for the description parametrizing the theoretical uncertainty*)*) +(*DistrDataImportTemp[prod]=Import[FileNameJoin[{dirimp,"DoubleDistr_"<>LLPdirName<>"_"<>prod<>"_"<>FacilityGivenExperiment<>".m"}],"MX"];*) +(*Do[*) +(*prodbrem=StringReplace[prod,"-mixing"->""]<>"-"<>DistrDataImportTemp[prod][[j]][[1]]<>"-mixing";*) +(*DistrDataImport[prodbrem]=DistrDataImportTemp[prod][[j]][[2]];*) +(*mlistDistr[prodbrem]=DeleteDuplicates[DistrDataImport[prodbrem][[All,1]]];*) +(*{mLLPmin[prodbrem],mLLPmax[prodbrem]}=MinMax[mlistDistr[prodbrem]];*) +(*,{j,1,Length[DistrDataImportTemp[prod]],1}];*) +(*];*) +(*]*) +(*,{i,1,Length[ProductionPatternSelectedDistr],1}]*) +(*Do[*) +(*Module[{},*) +(*mlistDistr[prod]=DeleteDuplicates[DistrDataImport[prod][[All,1]]];*) +(*{mLLPmin[prod],mLLPmax[prod]}=MinMax[mlistDistr[prod]];*) +(*DoubleDistrLLPint[mLLP_,\[Theta]LLP_,ELLP_,prod]=10^(Interpolation[distrlogComp[DistrDataImport[prod]],InterpolationOrder->1][Log10[mLLP],Log10[\[Theta]LLP],Log10[ELLP]]);*) +(*If[StringContainsQ[prod,"Bremsstrahlung"],*) +(*DoubleDistrLLPint[mLLP_,\[Theta]LLP_,ELLP_,prod]=If[ELLP<=ELLPmax[mLLP,\[Theta]LLP,prod],Evaluate[DoubleDistrLLPint[mLLP,\[Theta]LLP,ELLP,prod]],0.]];*) +(*(*Probability to produce LLP*)*) +(*ProbLLP[mLLP_,\[Theta]2_,BrhToSS_,prod]=ProbMother[prod]*PmotherToLLP[mLLP,\[Theta]2,BrhToSS,prod,FacilityGivenExperiment]/.{Atarget->AtargetVal,Yield\[Rho]0->ProbMother["Rho0"]};*) +(*]*) +(*,{prod,ProductionList}]*) +(*Do[{GridInFinal[prod],DistrVals[prod]}=BlockGridsValsDistr[prod,DistrDataImport],{prod,ProductionList}];//AbsoluteTiming*) +(*(*____________________________*)*) +(*(*Finding Subscript[E, max](Subscript[m, LLP],Subscript[\[Theta], LLP]) for the angular range at the given experiment*)*) +(*(*____________________________*)*) +(*Do[ELLPmax[mfip_,\[Theta]fip_,prod]=EmaxBlock[prod,8,DistrDataImport,FacilityGivenExperiment],{prod,Select[ProductionList,!StringContainsQ[#,"Bremsstrahlung"]&]}]//AbsoluteTiming*) + + +(* ::Subsection::Closed:: *) +(*Exporting averaged distribution*) + + +(* ::Input:: *) +(*directory["Auxiliary-experiment"]=FileNameJoin[{directory["Auxiliary"],SelectedExperiment}];*) +(*If[!DirectoryQ[directory["Auxiliary-experiment"]],CreateDirectory[directory["Auxiliary-experiment"]]];*) +(*Export[FileNameJoin[{directory["Auxiliary-experiment"],"Double-Distr-Averaged-"<>LLPdirName<>".m"}],{Sum[If[mLLPmin[prod]True,ImageSize->Large,PlotLegends->Placed[Style[#,15]&/@ProductionListBaseline,Right]];*) +(*ptprodprob=LogLogPlot[Evaluate[Table[ProbLLP[ma,10^-10,0.01,prod],{prod,ProductionListBaseline}]],{ma,mmin\[Epsilon],mmax\[Epsilon]},Frame->True,ImageSize->Large,PlotLegends->Placed[Style[#,16]&/@ProductionListBaseline,{0.34,0.28}], FrameStyle->Directive[Black, 25],PlotRange->{{0.02,3},{10^-20,10^-13}},PlotStyle->{{Thick,Blue},{Thick,Darker@Red},{Thick,Darker@Darker@Green},{Thick,Darker@Cyan},{Thick,Magenta},{Thick,Brown}},AspectRatio->0.66,ImageSize->Large,FrameLabel->{"\!\(\*SubscriptBox[\(m\), \(LLP\)]\) [GeV]","\!\(\*SubscriptBox[\(P\), \(prod\)]\)/\!\(\*SuperscriptBox[\(\[Theta]\), \(2\)]\)"},PlotLabel->Style[Row[{"Production probabilities of ",LLPdirName," at ",SelectedExperiment}],18,Black]];*) +(*ptprodprobbrem=LogLogPlot[Evaluate[Table[ProbLLP[ma,1,0,prod],{prod,BremVariantsGivenFacility}]],{ma,mmin\[Epsilon],mmax\[Epsilon]},Frame->True,ImageSize->Large,PlotLegends->Placed[Style[#,16]&/@BremVariantsGivenFacility,Right], FrameStyle->Directive[Black, 25],PlotRange->{{0.02,2},{10^-12,0.001}},PlotStyle->{{Thick,Blue},{Thick,Darker@Red},{Thick,Darker@Darker@Green},{Thick,Darker@Cyan},{Thick,Magenta},{Thick,Brown}},AspectRatio->0.66,ImageSize->Large,FrameLabel->{"\!\(\*SubscriptBox[\(m\), \(LLP\)]\) [GeV]","\!\(\*SubscriptBox[\(P\), \(prod\)]\)/\!\(\*SuperscriptBox[\(\[Theta]\), \(2\)]\)"},PlotLabel->Style[Row[{"Production probabilities of ",LLPdirName," at ",SelectedExperiment}],18,Black]];*) +(*Style[Row[{ptprodprob,ptenergies,ptprodprobbrem}],ImageSizeMultipliers->{1, 1,1}]*) + + +(* ::Chapter::Closed:: *) +(*Number of events*) + + +(* ::Section::Closed:: *) +(*Number of events *) + + +(* ::Subsection::Closed:: *) +(*Initializing all routines*) + + +(* ::Input:: *) +(*Do[{OutGrid\[Theta]final[prod],\[CapitalDelta]\[Theta]vals[prod]}=OutGrid\[Theta]Temp[InGrid\[Theta]\[Epsilon],30,prod,\[Theta]maxBrem[prod]],{prod,ProductionList}]*) +(*{OutGridzfinal,\[CapitalDelta]zvals}=OutGridszTemp[InGridz\[Epsilon],30,zminExp];*) +(*(*Final energy grid. Mass- and production channel-dependent*)*) +(*If[FacilityGivenExperiment!="ESS",*) +(*StepEtemp[Efip_]=Piecewise[{{0.3,Efip<=2.5},{0.5,2.5"C",RuntimeOptions->"Speed",RuntimeAttributes->{Listable},Parallelization->True]/. DownValues@func//ReleaseHold*) +(*];*) +(*(*Generate a dictionary of compiled functions for each variant*)compiledBremCutter=AssociationThread[BremVariantsGivenFacility,createCompiledFunctionBrem/@BremVariantsGivenFacility];*) +(*BremCut[OutGrid\[Theta]final_,OutGridEfinal_,distr_,mLLP_,bremChoice_]:=Block[{},*) +(*angleenergy=Join[10^Tuples[{OutGrid\[Theta]final,OutGridEfinal}],Partition[distr,1],2];*) +(*compiledFunc=compiledBremCutter[bremChoice];*) +(*compiledFunc[angleenergy,mLLP]*) +(*];*) +(*TableIntegrandDiscret[m_,ProdChannel_,\[Epsilon]DecOp_]:=TableIntegrandDiscretTemp[m,ProdChannel,\[Epsilon]DecOp,\[Epsilon]vals,\[Epsilon]azvals,OutGrid\[Theta]final[ProdChannel],OutGridzfinal,OutGridEnergy,InGridm\[Epsilon],InGrid\[Theta]\[Epsilon],InGridE\[Epsilon],InGridz\[Epsilon],\[CapitalDelta]\[Theta]vals[ProdChannel],\[CapitalDelta]zvals,zminExp,GridInFinal,DistrVals,FacilityGivenExperiment,ELLPmax,\[Theta]minExp]*) + + +(* ::Subsection::Closed:: *) +(*Generalized acceptances*) + + +(* ::Input:: *) +(*(*Tabulated acceptance*)*) +(*FactorANUBISceiling=If[SelectedExperiment=="ANUBIS-ceiling",2,1];*) +(*AcceptanceDiscret[m_,ProdChannel_,\[Epsilon]decOp_,decProb_]:=AcceptanceDiscretTemp[m,ProdChannel,\[Epsilon]decOp,decProb,mLLPmin,mmin\[Epsilon],mLLPmax,mmax\[Epsilon],ELLPmax,\[Theta]minExp,TableIntegrandDiscret,BrVis,zmaxExp,zminExp,FactorANUBISceiling,0.]*) +(*Do[mlistAcceptance[prod]=Select[Join[{1.01Max[mLLPmin[prod],mmin\[Epsilon]]},10^InGridm\[Epsilon],{Min[mLLPmax[prod],mmax\[Epsilon]]}],mLLPmin[prod]<=#<=mLLPmax[prod]&]//Sort//DeleteDuplicates;*) +(*,{prod,ProductionList}];*) +(*Do[*) +(*\[Epsilon]GeomTabs[prod]=ParallelTable[{m,AcceptanceDiscret[m,prod,"False",0],AcceptanceDiscret[m,prod,"True",0],AcceptanceDiscret[m,prod,"False",1],AcceptanceDiscret[m,prod,"True",1]},{m,mlistAcceptance[prod]}];*) +(*,{prod,ProductionList}];//AbsoluteTiming*) +(*PlotAcc[ProdChannel_]:=ListLogPlot[Evaluate[{\[Epsilon]GeomTabs[ProdChannel][[All,{1,2}]],\[Epsilon]GeomTabs[ProdChannel][[All,{1,3}]],\[Epsilon]GeomTabs[ProdChannel][[All,{1,4}]],\[Epsilon]GeomTabs[ProdChannel][[All,{1,5}]]}],FrameStyle->Directive[Black, 22],PlotStyle->{{Thickness[0.003],Blue},{Thickness[0.003],Darker@Red},{Thickness[0.003],Darker@Darker@Green},{Thickness[0.003],Black}},GridLines->Automatic,PlotRange->{MinMax[\[Epsilon]GeomTabs[ProdChannel][[All,1]]],{Max[0.9Min[Min[\[Epsilon]GeomTabs[ProdChannel][[All,4]]],Min[\[Epsilon]GeomTabs[ProdChannel][[All,3]]]],10^-5],1.1Max[Max[\[Epsilon]GeomTabs[ProdChannel][[All,2]]],Max[\[Epsilon]GeomTabs[ProdChannel][[All,4]]]]}},Joined->True,Frame->True,ImageSize->Large,FrameLabel->{"m [GeV]","Acceptance"},PlotLabel-> Style[Row[{"From ",ProdChannel}], 20, Black],PlotLegends->Placed[{Style[#, 18]&/@{"<\!\(\*SubscriptBox[\(\[Epsilon]\), \(LLP\)]\)>","<\!\(\*SubscriptBox[\(\[Epsilon]\), \(LLP\)]\)\!\(\*SubscriptBox[\(\[Epsilon]\), \(decay\)]\)>","c\[Tau]<\!\(\*SubscriptBox[\(\[Epsilon]\), \(LLP\)]\)\!\(\*SubscriptBox[\(P\), \(decay\)]\)>","c\[Tau]<\!\(\*SubscriptBox[\(\[Epsilon]\), \(LLP\)]\)\!\(\*SubscriptBox[\(P\), \(decay\)]\)\!\(\*SubscriptBox[\(\[Epsilon]\), \(decay\)]\)>"}},{0.75,0.2}]]*) +(*Style[Row[Evaluate[Table[PlotAcc[prod],{prod,ProductionList}]]],ImageSizeMultipliers->{1,1,1,1}]*) +(*(*Do[FilenameAcceptance[prod]=ToString@StringForm["Acceptance_ALP-fermion_at_``_From_``.dat",Sequence@@{SelectedExperiment,ExportList[prod]}];*) +(*Export[FileNameJoin[{NotebookDirectory[],"Auxiliary data/ALPs with fermion coupling",SelectedExperiment,FilenameAcceptance[prod]}],\[Epsilon]GeomTabs[prod][[All,{1,2,4,5}]],"Table"]*) +(*,{prod,ProductionList}]*)*) +(*AccAveraged[mLLP_,\[Theta]2_,BrhToSS_]=NpotGivenExperiment{Sum[If[mLLPmin[prod]1][mLLP]],0],{prod,ProductionListBaseline}],Sum[If[Max[mLLPmin[prod],mmin\[Epsilon]]1][mLLP]],0],{prod,ProductionListBaseline}],Sum[If[Max[mLLPmin[prod],mmin\[Epsilon]]1][mLLP]],0],{prod,ProductionListBaseline}]};*) +(*Export[FileNameJoin[{directory["Auxiliary-experiment"],"AcceptanceAveraged-"<>LLPdirName<>".m"}],AccAveraged[mLLP,\[Theta]2,BrhToSS],"MX"];*) + + +(* ::Subsection::Closed:: *) +(*Rough estimates of the upper and lower bounds*) + + +(* ::Input:: *) +(**) +(*BrhToSSreference=0.15;*) +(*Do[*) +(*factorLowerBound=If[StringContainsQ[prod,"mixing"],1/2,1];*) +(*LowerBoundEstimate[mLLP_,prod]=((NpotGivenExperiment*ProbLLP[mLLP,1,BrhToSSreference,prod]*Interpolation[\[Epsilon]GeomTabs[prod][[All,{1,5}]],InterpolationOrder->1][mLLP])/(2.3ldecayLLP[mLLP,1,ELLP] mLLP/Sqrt[ELLP^2-mLLP^2]))^-factorLowerBound;*) +(*UpperBoundEstimate[mLLP_,prod]=(Abs[Re[Evaluate[-(ProductLog[-1,-2.3*b/a]/b)/.{a-> NpotGivenExperiment*ProbLLP[mLLP,1,BrhToSSreference,prod]*Interpolation[\[Epsilon]GeomTabs[prod][[All,{1,3}]],InterpolationOrder->1][mLLP],b->zminExp/ldecayLLP[mLLP,1,ELLPmax[0.5,\[Theta]minExp,prod]]}]]]),{prod,ProductionList}]*) +(*ProdTest=ProductionList[[1]]*) +(*LogLogPlot[Evaluate[{0.3LowerBoundEstimate[mLLP,ProdTest],1.8UpperBoundEstimate[mLLP,ProdTest]}],{mLLP,Max[mLLPmin[ProdTest],mmin\[Epsilon]],Min[mLLPmax[ProdTest],mmax\[Epsilon]]},Frame->True,ImageSize->Large]*) + + +(* ::Subsection::Closed:: *) +(*Number of events - fast*) + + +(* ::Input:: *) +(*FactorLowerBound=If[MemberQ[{"ANUBIS-shaft-volume-1","ANUBIS-shaft-volume-2","ANUBIS-shaft-volume-3"},SelectedExperiment]==True,0.1,0.3];*) +(*NeventsDiscret[m_,ProdChannel_,BrhToSS_,\[Theta]2list_]:=Module[{NevDiscret(*,NpotTimes\[Chi]val*)},*) +(*If[Max[mmin\[Epsilon],mLLPmin[ProdChannel]]"AdaptiveMonteCarlo"]*) +(*(*IntegralLLP[mLLP_,finv_,ProdChannel_]:=NIntegrate[Abs[IntegrandLLP[mLLP,finv,Exp[\[Theta]LLP],Exp[ELLP],Exp[zLLP],ProdChannel]]Exp[\[Theta]LLP+ELLP+zLLP],{\[Theta]LLP,Log[\[Theta]minExp],Log[\[Theta]maxExp]},{ELLP,Log[mLLP],Log[ELLPmax[mLLP,Exp[\[Theta]LLP],ProdChannel]]},{zLLP,Log[zmin\[Theta][Exp[\[Theta]LLP]]],Log[zmax\[Theta][Exp[\[Theta]LLP]]]},Method\[Rule]"AdaptiveMonteCarlo"]*)*) +(*NeventsInt[mLLP_,\[Theta]2_,BrhToSS_,ProdChannel_]:=FactorANUBISceiling*If[mLLPmin[ProdChannel]<=mLLP<=mLLPmax[ProdChannel]&&BrVis[mLLP]!=0,If[FactorLowerBound*LowerBoundEstimate[mLLP,ProdChannel]<\[Theta]2<2UpperBoundEstimate[mLLP,ProdChannel],NpotGivenExperiment*ProbLLP[mLLP,\[Theta]2,BrhToSS,ProdChannel]*IntegralLLP[mLLP,\[Theta]2,ProdChannel],0.],0.]*) +(*IntegralLLPE[mLLP_,\[Theta]2_,ProdChannel_,ELLP_]:=NIntegrate[Abs[IntegrandLLP[mLLP,\[Theta]2,\[Theta]LLP,ELLP,zLLP,ProdChannel]],{\[Theta]LLP,\[Theta]minExp,\[Theta]maxExp},{zLLP,zmin\[Theta][\[Theta]LLP],zmax\[Theta][\[Theta]LLP]},Method->"AdaptiveMonteCarlo"]*) +(*NeventsDiffIntE[mLLP_,\[Theta]2_,BrhToSS_,ProdChannel_,ELLP_]:=If[mLLPmin[ProdChannel]<=mLLP<=mLLPmax[ProdChannel]&&BrVis[mLLP]!=0&&mLLP"AdaptiveMonteCarlo"]*) +(*NeventsDiffIntz[mLLP_,\[Theta]2_,BrhToSS_,ProdChannel_,zLLP_]:=If[mLLPmin[ProdChannel]<=mLLP<=mLLPmax[ProdChannel]&&BrVis[mLLP]!=0&&zminExp<=zLLP<=zmaxExp,If[0.1LowerBoundEstimate[mLLP,ProdChannel]<\[Theta]2<2UpperBoundEstimate[mLLP,ProdChannel],NpotGivenExperiment*ProbLLP[mLLP,\[Theta]2,BrhToSS,ProdChannel]*IntegralLLPz[mLLP,\[Theta]2,ProdChannel,zLLP],0.],0.]*) + + +(* ::Section::Closed:: *) +(*Tests*) + + +(* ::Subsection::Closed:: *) +(*Total number of events*) + + +(* ::Input:: *) +(*(*This is a comparison between the slow and fast integration methods. For the selected mass and production channel, the numbers of events obtained using the methods should agree within 10%*)*) +(*(*If the agreement is worse, there may be a few reasons*)*) +(*(*1) The grid for the fast method is not dense enough. Try to increase the grid density (OutGrid\[Theta]final, OutGridEfinal, OutGridzfinal) to see whether the agreement improves. Sometimes, even a slightly denser grid for e.g. z may lead to a significant improvement in the agrement*)*) +(*(*2) The Monte-Carlo integrator for the slow method fails to evaluate properly; this may happen if the range of the integration over energies is too large compared to the domain where most of the events actually are (off-axis experiments such as MATHUSLA and ANUBIS). Another symptom is that for the given mass and coupling the integral "jumps", i.e., returns values with large error*)*) +(*(*A separate discussion should be made for the couplings belong to the domain c\[Tau] \[Gamma] << Subscript[z, experiment]. The discrepancy may be significant, and the reason is insufficient grid density for the fast integration method. However, due to the exponential suppression of the number of events, this may be compensated by a tiny shift in the coupling, so the discrepancy should be considered as appropriate.*)*) +(*mtest=If[MemberQ[{"LHC","FCC-hh"},FacilityGivenExperiment]==True,5,0.5];*) +(*ProdTest=If[MemberQ[{"LHC","FCC-hh"},FacilityGivenExperiment]==True,"h-quartic","B-mixing"];*) +(*couplinglist=(*{10^-12,3*10^-12,5*10^-12,10^-11,5*10^-11,10^-10,5*10^-10,10^-9,5*10^-9,10^-8,2*10^-8,4*10^-8,10^-7,5*10^-7,6*10^-7,7*10^-7,8*10^-7,9*10^-7,10^-6,2*10^-6}//N*)Table[10^x,{x,-17.,-3.,0.3}];*) +(*dat1=NeventsDiscret[mtest,ProdTest,BrhToSSreference,couplinglist];//AbsoluteTiming*) +(*dat2=ParallelTable[{couplinglist[[i]],c\[Tau]LLP[mtest,couplinglist[[i]]],Quiet[NeventsInt[mtest,couplinglist[[i]],BrhToSSreference,ProdTest]]},{i,1,Length[couplinglist],1}];//AbsoluteTiming*) +(*Join[{{"\!\(\*FractionBox[SubscriptBox[\(m\), \(LLP\)], \(GeV\)]\)","coupling","\!\(\*FractionBox[\(c\[Tau]\), SubscriptBox[\(z\), \(min\)]]\)","\!\(\*SubscriptBox[\(N\), \(events, fast\)]\)","\!\(\*SubscriptBox[\(N\), \(events, slow\)]\)"}},Join[dat1[[All,{1,2}]],{#[[2]]/zminExp}&/@dat2,dat1[[All,{3}]],dat2[[All,{3}]],2]]//TableForm*) + + +(* ::Subsection::Closed:: *) +(*Differential number of events*) + + +(* ::Input:: *) +(*(*Variable = "Subscript[E, X]","Subscript[z, X]","Subscript[\[Theta], X]". The number belongs to the column in the tabulated data*)*) +(*iVal:=Association[{"\!\(\*SubscriptBox[\(E\), \(X\)]\)" ->2,"\!\(\*SubscriptBox[\(\[Theta]\), \(X\)]\)"->1,"\!\(\*SubscriptBox[\(z\), \(X\)]\)"->3}]*) +(*Do[*) +(*\[CapitalDelta]xvals["\!\(\*SubscriptBox[\(E\), \(X\)]\)",prod]:=\[CapitalDelta]Evals;*) +(*\[CapitalDelta]xvals["\!\(\*SubscriptBox[\(z\), \(X\)]\)",prod]=\[CapitalDelta]zvals;*) +(*\[CapitalDelta]xvals["\!\(\*SubscriptBox[\(\[Theta]\), \(X\)]\)",prod]=\[CapitalDelta]\[Theta]vals[prod]*) +(*,{prod,ProductionList}];*) +(*LegendX:=Association[{"\!\(\*SubscriptBox[\(E\), \(X\)]\)"->"\!\(\*SubscriptBox[\(E\), \(X\)]\) [GeV]","\!\(\*SubscriptBox[\(\[Theta]\), \(X\)]\)"->"\!\(\*SubscriptBox[\(\[Theta]\), \(X\)]\) [rad]","\!\(\*SubscriptBox[\(z\), \(X\)]\)"-> "\!\(\*SubscriptBox[\(z\), \(X\)]\) [m]"}]*) +(*LegendY:=Association[{"\!\(\*SubscriptBox[\(E\), \(X\)]\)"->"\!\(\*SubscriptBox[\(dN\), \(ev\)]\)/\!\(\*SubscriptBox[\(dE\), \(X\)]\) [\!\(\*SuperscriptBox[\(GeV\), \(-1\)]\)]","\!\(\*SubscriptBox[\(\[Theta]\), \(X\)]\)"->"\!\(\*SubscriptBox[\(dN\), \(ev\)]\)/\!\(\*SubscriptBox[\(d\[Theta]\), \(X\)]\) [\!\(\*SuperscriptBox[\(rad\), \(-1\)]\)]","\!\(\*SubscriptBox[\(z\), \(X\)]\)"-> "\!\(\*SubscriptBox[\(dN\), \(ev\)]\)/\!\(\*SubscriptBox[\(dz\), \(X\)]\) [\!\(\*SuperscriptBox[\(m\), \(-1\)]\)]"}]*) +(*(*Differential number of events*)*) +(*NeventsDifferentialDiscretProd[m_,ProdChannel_,coupling_,BrhToSS_,Variable_]:=Module[{NpotTimes\[Chi]val},*) +(*ival=iVal[Variable];*) +(*NpotTimes\[Chi]val=NpotGivenExperiment*ProbLLP[m,coupling,BrhToSS,ProdChannel];*) +(*tablegrid0=TableIntegrandDiscret[m,ProdChannel,"True"];*) +(*OutGridEfinalTemp=OutGridEnergy[N[m],ProdChannel];*) +(*\[CapitalDelta]Evals=(Rest[10^OutGridEfinalTemp]-Most[10^OutGridEfinalTemp]);*) +(*\[CapitalDelta]xval=\[CapitalDelta]xvals[Variable,ProdChannel];*) +(*c\[Tau]Val=c\[Tau]LLP[m,coupling];*) +(*brvis=BrVis[m];*) +(*ilist=DeleteDuplicates[{ival,1,2,3}];*) +(*tablegrid1=SortBy[{#[[ilist[[1]]]],#[[ilist[[2]]]],#[[ilist[[3]]]],#[[4]]}&/@tableGridPrefac[tablegrid0,m,c\[Tau]Val,0.],{#[[1]],#[[2]],#[[3]]}&];*) +(*GridQuantity=tablegrid1[[All,1]]//DeleteDuplicates;*) +(*LengthPerVariable=Length[tablegrid1]/Length[GridQuantity];*) +(*tab1=NdiffCompiled[tablegrid1,GridQuantity,LengthPerVariable,NpotTimes\[Chi]val*brvis];*) +(*Join[tab1[[All,{1}]],Partition[tab1[[All,2]]*\[CapitalDelta]xval^-1,1],2]*) +(*]*) +(*NeventsDifferentialDiscret[m_,coupling_,BrhToSS_,Variable_]:=Module[{NdiffInt,LegendList,QuantityMinMax,ValueMinMax},*) +(*prodlisttemp={};*) +(*Do[If[Max[mLLPmin[prod],mmin\[Epsilon]]10^-40&][[All,1]]//MinMax;*) +(*NdiffInt[X_,prod]=If[XvalminmaxNdiff[[1]]1][Log10[X]]],0]],{prod,ProductionListBaseline}];*) +(*NdiffInt[X_,"Total"]=Sum[NdiffInt[X,prod],{prod,prodlisttemp}];*) +(*LegendList=Join[{"Total"},prodlisttemp];*) +(*QuantityMinMax=Flatten[Table[MinMax[NdiffData[prod][[All,1]]],{prod,prodlisttemp}],1]//MinMax;*) +(*ValueMinMax=Max[Max[NdiffData[#][[All,2]]]&/@prodlisttemp];*) +(*{Table[NdiffInt[X,prod],{prod,LegendList}],LegendList,QuantityMinMax,ValueMinMax}*) +(*]*) +(*mvaltest=If[FacilityGivenExperiment=="ESS",0.04,3];*) +(*couplingvaltest=1.4LowerBoundEstimate[mvaltest,"B-mixing"];*) +(*BrhToSStest=0.0;*) +(*quantity="\!\(\*SubscriptBox[\(\[Theta]\), \(X\)]\)";*) +(*{NdiffTab[X_],LegendList,QuantityMinMax,ValueMinMax}=NeventsDifferentialDiscret[mvaltest,couplingvaltest,BrhToSStest,quantity];*) +(*Do[*) +(*prch=LegendList[[i]];*) +(*NdiffInt[X_,prch]=NdiffTab[X][[i]];*) +(*,{i,1,Length[LegendList]}];*) +(*plotdiff=LogLogPlot[Evaluate[Table[NdiffInt[X,prod],{prod,LegendList}]],{X,QuantityMinMax[[1]],QuantityMinMax[[2]]},Frame->True,ImageSize->Large,PlotRange->{All,{10^-5,2ValueMinMax}},PlotStyle->{{Thick,Black},{Thick,Blue},{Thick,Darker@Red},{Thick,Darker@Darker@Green},{Thick,Darker@Cyan},{Thick,Magenta},{Thick,Blue,Dashing[0.02]},{Thick,Darker@Red,Dashing[0.02]},{Thick,Darker@Darker@Green,Dashing[0.02]}},PlotLegends->Placed[Style[#,20]&/@LegendList,Right],FrameLabel->{LegendX[quantity] ,LegendY[quantity]},FrameStyle->Directive[Black, 18],PlotLabel->Style[Row[{SelectedExperiment,". \!\(\*SubscriptBox[\(m\), \(S\)]\) = ",mvaltest," GeV, \!\(\*SuperscriptBox[\(\[Theta]\), \(2\)]\) = ",couplingvaltest//N,", \!\(\*SubscriptBox[\(Br\), \(h -> SS\)]\) = ",BrhToSStest}],14,Black]]*) + + +(* ::Title::Closed:: *) +(*Exporting tabulated number of events*) + + +(* ::Chapter::Closed:: *) +(*Definitions*) + + +(* ::Input:: *) +(*directory["Nevents"]=FileNameJoin[{NotebookDirectory[],"Tabulated Nevents"}];*) +(*directory["Nevents-LLP"]=FileNameJoin[{NotebookDirectory[],"Tabulated Nevents",LLPdirName}];*) +(*directory["Nevents-LLP-experiment"]=FileNameJoin[{NotebookDirectory[],"Tabulated Nevents",LLPdirName,SelectedExperiment}];*) +(*If[!DirectoryQ[directory[#]],CreateDirectory[directory[#]]]&/@{"Nevents","Nevents-LLP","Nevents-LLP-experiment"};*) +(*Print["Filenames with tabulated \!\(\*SubscriptBox[\(N\), \(events\)]\):"]*) +(*Do[FilenameNeventsInt[prod]=ToString@StringForm["Nevents_``_``_at_``_Npot=``.dat",Sequence@@{LLPdirName,prod,SelectedExperiment,NpotGivenExperiment//CForm//ToString}],{prod,ProductionList}]*) +(*FilenameNeventsInt[#]&/@ProductionList*) +(*Do[mRangeExport[brem]={0.021,0.031,0.041,0.051,0.06,0.07,0.08,0.09,0.1,0.13,0.15,0.2,0.205,0.21,0.212,0.214,0.216,0.218,0.22,0.225,0.23,0.24,0.25,0.26,0.27,0.275,0.28,0.285,0.289,0.3,0.32,0.35,0.4,0.45,0.5,0.6,0.7,0.8,0.85,0.9,0.95,0.99,1.,1.01,1.02,1.025,1.03,1.05,1.1,1.2,1.3,1.4,1.5,1.6,1.7,1.8,1.9,1.99,2.1,2.2,2.3,2.4,2.5};*) +(*,{brem,BremVariantsGivenFacility}];*) +(*mRangeExport["K-mixing"]={0.021,0.051,0.1,0.13,0.15,0.2,0.205,0.21,0.212,0.214,0.216,0.218,0.22,0.23,0.24,0.25,0.26,0.27,0.275,0.28,0.285,0.289,0.3,0.32,0.35,0.995(mSM["Kplus"]-mSM["PiPlus"])};*) +(*mRangeExport["B-quartic"]={0.021,0.051,0.1,0.13,0.15,0.2,0.205,0.21,0.212,0.214,0.216,0.218,0.22,0.23,0.24,0.25,0.26,0.27,0.275,0.28,0.285,0.289,0.3,0.32,0.35,0.4,0.45,0.5,0.55,0.6,0.65,0.7,0.8,0.85,0.9,0.95,0.99,1.02,1.05,1.1,1.2,1.3,1.4,1.5,1.6,1.7,1.8,1.9,1.99,2.05,2.1,2.2,2.3,2.4,2.5,2.55};*) +(*mRangeExport["B-mixing"]={0.021,0.051,0.1,0.13,0.15,0.17,0.2,0.205,0.21,0.212,0.214,0.216,0.218,0.22,0.23,0.24,0.25,0.26,0.27,0.275,0.28,0.285,0.289,0.3,0.32,0.35,0.4,0.45,0.5,0.55,0.6,0.65,0.7,0.8,0.85,0.9,0.95,0.99,1.02,1.05,1.1,1.2,1.3,1.4,1.5,1.6,1.7,1.8,1.9,1.99,2.1,2.3,2.4,2.5,2.6,2.7,2.8,2.9,3,3.1,3.2,3.3,3.5,3.6,3.7,3.8,3.9,4,4.1,4.2,4.3,4.4,4.5,4.6,4.65,4.7,4.75,4.77,4.8,4.83,4.85,4.87,4.9,4.93,4.95,4.97,5,5.03,5.05,5.07,5.1};*) +(*mRangeExport["Bs-quartic"]={0.021,0.051,0.1,0.13,0.15,0.17,0.2,0.205,0.21,0.212,0.214,0.216,0.218,0.22,0.23,0.25,0.26,0.275,0.28,0.285,0.289,0.3,0.32,0.35,0.5,0.55,0.6,0.65,0.7,0.8,0.85,0.9,0.95,0.99,1.02,1.05,1.1,1.2,1.3,1.4,1.5,1.6,1.7,1.8,1.9,1.99,2.05,2.1,2.2,2.3,2.4,2.5,2.55,2.6,2.65};*) +(*mRangeExport["h-quartic"]={0.021,0.051,0.1,0.13,0.15,0.17,0.2,0.205,0.21,0.212,0.214,0.216,0.218,0.22,0.23,0.24,0.25,0.26,0.27,0.275,0.28,0.285,0.289,0.3,0.32,0.35,0.4,0.45,0.5,0.55,0.6,0.65,0.7,0.8,0.85,0.9,0.95,0.99,1.02,1.05,1.1,1.2,1.3,1.4,1.5,1.6,1.7,1.8,1.9,1.99,2.1,2.3,2.4,2.5,2.6,2.7,2.8,2.9,3,3.2,3.3,3.4,3.5,3.6,3.7,3.8,3.9,4,4.1,4.2,4.3,4.4,4.5,4.6,4.7,4.8,4.9,5,5.1,7.,10.,10.6,12.,15.,20.,30.,40.,45.,50.,55.,60.,61.,62.,62.49};*) +(*couplingsRangeExport=Table[10^x,{x,-20,-3,0.02}]//N;*) + + +(* ::Chapter::Closed:: *) +(*Exporting*) + + +(* ::Input:: *) +(*BlockExport[ProdChannel_]:=Block[{},*) +(*mlist=mRangeExport[ProdChannel];*) +(*TabFrom=ParallelTable[Quiet[NeventsDiscret[mlist[[k]],ProdChannel,BrhToSSreference,couplingsRangeExport]],{k,1,Length[mlist],1}];*) +(*Export[FileNameJoin[{directory["Nevents-LLP-experiment"],FilenameNeventsInt[ProdChannel]}],Flatten[TabFrom,1],"Table"]*) +(*]*) +(*Monitor[*) +(*Do[*) +(*prod=ProductionList[[j]];*) +(*BlockExport[prod],{j,1,Length[ProductionList],1}],*) +(*Row[{ProgressIndicator[j,{1,Length[ProductionList]}]," Production mode = ",ProductionList[[j]]," (", j,"/",Length[ProductionList],")"}]]//AbsoluteTiming*) +(*If[icounter>Length[SelectedExperimentList],BlockEvaluation["Sensitivity"]]*) + + +(* ::Title::Closed:: *) +(*Computing sensitivities*) + + +(* ::Chapter::Closed:: *) +(*Basic definitions*) + + +(* ::Input:: *) +(*BrhToSSreference=0.15;*) +(*LLPdirName="Scalar";*) +(*directory["Sensitivity"]=FileNameJoin[{NotebookDirectory[],"Sensitivity domains"}];*) +(*directory["Sensitivity-LLP"]=FileNameJoin[{directory["Sensitivity"],LLPdirName}];*) +(*If[!DirectoryQ[directory[#]],CreateDirectory[directory[#]]]&/@{"Sensitivity","Sensitivity-LLP"};*) +(*directory["Nevents-LLP"]=FileNameJoin[{NotebookDirectory[],"Tabulated Nevents",LLPdirName}];*) +(*dropdownDialog[list_,phrase_]:=DialogInput[{choice=""},Column[{TextCell[phrase],PopupMenu[Dynamic[choice],list],Button["OK",DialogReturn[choice]]}]]*) +(*infoDialog[phrase_]:=DialogInput[{choice=""},Column[{TextCell[phrase],Button["Proceed",DialogReturn[choice]]}]]*) +(*selectionDialog[list_,phrase_]:=DialogInput[{choice={}},Column[{Row[{phrase}],Pane[TogglerBar[Dynamic[choice],list,Appearance->"Vertical"->{Automatic,5}],ImageSize->{Automatic,Automatic},Scrollbars->{False,True}],Button["OK",DialogReturn[choice]]}]]*) +(*ExperimentDirectoriesListNevents=Select[FileNames["*",directory["Nevents-LLP"],1],DirectoryQ];*) +(*Print["List of available experiments with tabulated \!\(\*SubscriptBox[\(N\), \(events\)]\) for " <>LLPdirName<>":"]*) +(*ExperimentsListNevents=Table[FileNameTake[ExperimentDirectoriesListNevents[[i]],-1],{i,1,Length[ExperimentDirectoriesListNevents],1}]//Sort;*) +(*ExperimentsListNevents//TableForm*) +(*If[Length[ExperimentsListNevents]==0,Print["No experiment is available, generate first the acceptance for the given experiment using module 1"],*) +(*SelectedExperimentList=If[Length[ExperimentsListNevents]!=0,selectionDialog[ExperimentsListNevents,"Select the experiments for which the sensitivity will be computed:"]];*) +(*icounter=1;*) +(*BlockEvaluation[tag_]:=Block[{},*) +(*nb=EvaluationNotebook[];*) +(*NotebookFind[nb,tag,All,CellTags];*) +(*SelectionEvaluate[nb]*) +(*];*) +(*Do[*) +(*BlockEvaluation["Sensitivity-computation"];*) +(*,{icounter,1,Length[SelectedExperimentList],1}]*) +(*]*) + + +(* ::Input:: *) +(**) + + +(* ::Chapter::Closed:: *) +(*Importing data and interpolations*) + + +(* ::Section::Closed:: *) +(*Selecting experiment*) + + +(* ::Input:: *) +(*Print["Selected experiment:"]*) +(*GivenExperimentForSensitivityComputation=SelectedExperimentList[[icounter++]]*) +(*CondANUBIS=MemberQ[{"ANUBIS-shaft-volume-1","ANUBIS-shaft-volume-2","ANUBIS-shaft-volume-3"},GivenExperimentForSensitivityComputation];*) +(*If[CondANUBIS==True,infoDialog[Row[{"One of the modules of ANUBIS-shaft is chosen. The full sensitivity includes three modules. The importing will be over all modules, so for all ot the the sensitivity has to be computed"}]]]*) +(*If[CondANUBIS==False,GivenExperimentForSensitivityComputationList={GivenExperimentForSensitivityComputation},GivenExperimentForSensitivityComputationList={"ANUBIS-shaft-volume-1","ANUBIS-shaft-volume-2","ANUBIS-shaft-volume-3"}];*) +(*PathsNeventsSelected={};*) +(*Do[PathsNeventsSelected=Join[PathsNeventsSelected,FileNames["*.dat",FileNameJoin[{directory["Nevents-LLP"],exp}]]],{exp,GivenExperimentForSensitivityComputationList}];*) +(*(*Filenames=Table[{StringReplace[Last@FileNameSplit@files[[i]],{"e+0"\[RuleDelayed]"*^","e-0"\[RuleDelayed]"*^-"}]},{i,1,Length[files],1}];*)*) +(*(*Creating the directory for exporting sensitivity curves*)*) +(*ExperimentFolder=If[CondANUBIS==True,"ANUBIS",GivenExperimentForSensitivityComputation];*) +(*directory["Sensitivity-LLP-exp"]=FileNameJoin[{directory["Sensitivity-LLP"],ExperimentFolder}];*) +(*If[!DirectoryQ[directory["Sensitivity-LLP-exp"]],CreateDirectory[directory["Sensitivity-LLP-exp"]]]*) +(**) + + +(* ::Section::Closed:: *) +(*Importing and interpolations*) + + +(* ::Input:: *) +(*Print["List of production channels:"]*) +(*FilenamesNevents=Table[Last@FileNameSplit@PathsNeventsSelected[[i]],{i,1,Length[PathsNeventsSelected],1}];*) +(*FilenameParameters[i_]:=StringCases[FilenamesNevents[[i]],"Nevents_Scalar_"~~mother__~~"_at_"~~experiment__~~"_Npot="~~Npot__~~".dat":>{mother,experiment,Npot}][[1]]*) +(*(*______________________________________________________*)*) +(*(*Importing and interpolation*)*) +(*(*______________________________________________________*)*) +(*ProductionInfoList=Table[FilenameParameters[i],{i,1,Length[FilenamesNevents],1}];*) +(*Join[{{"Mother","Experiment","\!\(\*SubscriptBox[\(N\), \(PoT\)]\)"}},ProductionInfoList]//TableForm*) +(*ProductionChannelsList=ProductionInfoList[[All,1]];*) +(*NpotDefault=Interpreter["Number"][ProductionInfoList[[1]][[3]]];*) +(*NeventsTabulated//Clear;*) +(*\[Epsilon]reco[mLLP_]=If[StringContainsQ[GivenExperimentForSensitivityComputation,"LHCb-downstream"]==True,0.4,If[StringContainsQ[GivenExperimentForSensitivityComputation,"CHARM-lepton"]==True,If[mLLP<0.105*2,0.51,0.85],1]];*) +(*Do[*) +(*Module[{prod},*) +(*prod=ProductionChannelsList[[i]];*) +(*(*The condition if one sums the number of events for the same production mode over several experiments*)*) +(*IfprodExists=MemberQ[Keys[DownValues@NeventsTabulated][[All,1,1]],prod];*) +(*NeventsTabulated[prod]=If[!IfprodExists,Import[PathsNeventsSelected[[i]],"Table"],Join[NeventsTabulated[prod][[All,{1,2}]],NeventsTabulated[prod][[All,{3}]]+Import[PathsNeventsSelected[[i]],"Table"][[All,{3}]]]];*) +(*{mminmax[prod],couplingminmax[prod]}=(NeventsTabulated[prod][[All,#]]//MinMax)&/@{1,2};*) +(*NevMax[prod]=NeventsTabulated[prod][[All,3]]//Max;*) +(*NevInt[mLLP_,\[Theta]2_,BrhToSS_,prod]=If[StringContainsQ[prod,"quartic"],BrhToSS/BrhToSSreference,1]*\[Epsilon]reco[mLLP]*If[mminmax[prod][[1]]<= mLLP<=mminmax[prod][[2]]&&couplingminmax[prod][[1]]<=\[Theta]2<=couplingminmax[prod][[2]],Evaluate[10^(Interpolation[{Log10[#[[1]]],Log10[#[[2]]],Log10[#[[3]]+10^-90]}&/@NeventsTabulated[prod],InterpolationOrder->1][Log10[mLLP],Log10[\[Theta]2]])],0];*) +(*]*) +(*,{i,1,Length[ProductionInfoList],1}]*) +(*{mminmaxOverall,couplingminmaxOverall}=MinMax[Table[#[prod],{prod,ProductionChannelsList}]//Flatten]&/@{mminmax,couplingminmax};*) +(*NevMaxOverall=Max[NeventsTabulated[#][[All,3]]&/@ProductionChannelsList]*) + + +(* ::Subsection::Closed:: *) +(*Accounting for various bremsstrahlung descriptions*) + + +(* ::Input:: *) +(*Print["List of various bremsstrahlung channels:"]*) +(*BremChannelsList=Select[ProductionChannelsList,StringContainsQ[#,"Bremsstrahlung"]&]//Sort*) +(*(*Defining the baseline bremsstrahlung setup*)*) +(*BremChannelBaseline="Bremsstrahlung-AP-Central-mixing";*) +(*If[BremChannelsList=={},*) +(*ProductionChannelsListUnified=ProductionChannelsBaseline=ProductionChannelsList;*) +(*,*) +(*If[MemberQ[BremChannelsList,BremChannelBaseline],*) +(*ProductionChannelsBaseline=Join[Select[ProductionChannelsList,!StringContainsQ[#,"Bremsstrahlung"]&],{BremChannelBaseline}];*) +(*,*) +(*ProductionChannelsBaseline=Join[Select[ProductionChannelsList,!StringContainsQ[#,"Bremsstrahlung"]&],{BremChannelsList[[1]]}]*) +(*];*) +(*ProductionChannelsListUnified=Join[Select[ProductionChannelsList,!StringContainsQ[#,"Bremsstrahlung"]&],{"Bremsstrahlung"}];*) +(*];*) +(*MapThread[(BremNameExportPattern[#1]=#2)&,{("Bremsstrahlung-"<>#<>"-mixing")&/@{"FR-Upper","FR-Central","FR-Lower","BB","AP-Upper","AP-Central","AP-Lower"},{"FR-Upper-mixing","FR-Central-mixing","FR-Lower-mixing","BB-mixing","AP-Upper-mixing","AP-Central-mixing","AP-Lower-mixing"}}];*) +(*NevIntOverall[mLLP_,\[Theta]2_,BrhToSS_]=Sum[NevInt[mLLP,\[Theta]2,BrhToSS,prod],{prod,ProductionChannelsBaseline}];*) +(*pt[mLLP_,BrhToSS_]:=LogLogPlot[Evaluate[Table[NevInt[mLLP,y,BrhToSS,prod],{prod,ProductionChannelsBaseline}]],{y,couplingminmaxOverall[[1]],couplingminmaxOverall[[2]]},PlotLegends->Placed[Style[#,15]&/@ProductionChannelsBaseline,Right],PlotRange->{couplingminmaxOverall,{10^-2,NevMaxOverall}},Frame->True,ImageSize->Large,FrameLabel->{"\!\(\*SuperscriptBox[\(\[Theta]\), \(2\)]\)" , "\!\(\*SubscriptBox[\(N\), \(events\)]\)[\!\(\*SubscriptBox[\(m\), \(S\)]\),\!\(\*SuperscriptBox[\(\[Theta]\), \(2\)]\),\!\(\*SubscriptBox[\(Br\), \(h -> SS\)]\)]"},FrameStyle->Directive[Black, 23],PlotStyle->{{Thick,Blue},{Thick,Darker@Red},{Thick,Darker@Darker@Green},{Thick,Black},{Thick,Blue,Dashing[0.02]},{Thick,Darker@Red,Dashing[0.02]},{Thick,Darker@Darker@Green,Dashing[0.02]},{Thick,Black,Dashing[0.02]}},PlotLabel->Style[Row[{ExperimentFolder,". \!\(\*SubscriptBox[\(m\), \(S\)]\) = ",mLLP, " GeV, \!\(\*SubscriptBox[\(Br\), \(h -> SS\)]\) = ",BrhToSS}],20,Black]]*) +(*pt[0.7,0.01]*) + + +(* ::Chapter::Closed:: *) +(*Sensitivity computation*) + + +(* ::Section::Closed:: *) +(*Density plot for number of events*) + + +(* ::Input:: *) +(*BrhToSSval=0.01;*) +(*(*If the plot is not as smooth as it is desired, increase the value of PlotPoints option*)*) +(*plot=DensityPlot[Evaluate[Log10[NevIntOverall[mLLP,\[Theta]2,BrhToSSval]]],{mLLP,mminmaxOverall[[1]],mminmaxOverall[[2]]},{\[Theta]2,couplingminmaxOverall[[1]],couplingminmaxOverall[[2]]},ScalingFunctions->{"Log","Log"},AspectRatio->0.78,PlotRange->{All,All,{Log10[2.3],Log10[NevMaxOverall]}},ImageSize->Large,FrameLabel->{"\!\(\*SubscriptBox[\(m\), \(S\)]\) [GeV]","\!\(\*SuperscriptBox[\(\[Theta]\), \(2\)]\)"}, Frame-> True, FrameStyle->Directive[Black, 25],PlotPoints->100,PlotLegends->Placed[BarLegend[{Automatic,{Log10[2.3],Log10[NevMaxOverall]}},LegendMarkerSize->340,LegendLabel->Placed["\!\(\*SubscriptBox[\(Log\), \(10\)]\)[\!\(\*SubscriptBox[\(N\), \(ev\)]\)]",Bottom],LabelStyle->{FontSize->22},Method->{FrameStyle->Black,AxesStyle->None,TicksStyle->Black}],Right],PlotLabel->Style[Row[{ExperimentFolder,", Br(h\[Rule]SS) = ",BrhToSSval}],20,Black](*,FrameTicks->{{Automatic,Automatic},{TicksPlotx,None}}*)]*) +(*(*Exporting. "AllowRasterization"->False option reduces the size of the output. Without this option, the file may be very large, depending on the value of PlotPoints*)*) +(*(*Export[FileNameJoin[{NotebookDirectory[],"NeventsDensityPlotExample.pdf"}],plot,"AllowRasterization"->False]*)*) + + +(* ::Section::Closed:: *) +(*Importing excluded region*) + + +(* ::Input:: *) +(*importformat["txt"]=importformat["dat"]="Table";*) +(*importformat["m"]=importformat["mx"]="MX";*) +(*importformat["xls"]="XLS";*) +(*dir=FileNameJoin[{NotebookDirectory[],"contours",LLPdirName}];*) +(*If[DirectoryQ[dir],*) +(*filenames=FileNames[LLPdirName<>"-excluded*",dir,Infinity];*) +(*ExcludedRegions[LLPdirName]=Import[#,importformat[FileExtension[#]]]&/@FileNames[LLPdirName<>"-excluded*",dir,Infinity];*) +(*];*) +(*If[!DirectoryQ[dir],*) +(*ExcludedRegions[LLPdirName]={{{10.,10.}}};*) +(*]*) + + +(* ::Section::Closed:: *) +(*Sensitivity*) + + +(* ::Subsection::Closed:: *) +(*Sensitivity calculator block*) + + +(* ::Input:: *) +(*SensitivityExtractor[SelectedProduction_,Npot_,BrhToSSval_,NevMin_]:=Module[{RegSens,SensTemp},*) +(*NevTot[mLLP_,\[Theta]2_]=Sum[NevInt[mLLP,\[Theta]2,BrhToSSval,prod],{prod,SelectedProduction}];*) +(*RegSens=RegionPlot[Npot/NpotDefault NevTot[10^mLLP,10^\[Epsilon]2]>=NevMin,{mLLP,Log10[mminmaxOverall[[1]]],Log10[mminmaxOverall[[2]]]},{\[Epsilon]2,Log10[couplingminmaxOverall[[1]]],Log10[couplingminmaxOverall[[2]]]},PlotPoints->300];*) +(*SensTemp=Cases[Normal@RegSens,Line[x_]:>x,Infinity];*) +(*Table[{10^#[[1]],10^#[[2]]}&/@SensTemp[[i]],{i,1,Length[SensTemp],1}]*) +(*]*) +(*SensitivityExtractorBrem[SelectedProduction_,i_,Npot_,BrhToSSval_,NevMin_]:=Module[{bremch,selprod},*) +(*bremch=BremChannelsList[[i]];*) +(*selprod=Join[Select[SelectedProduction,#!="Bremsstrahlung"&],{bremch}];*) +(*{i,selprod,BremNameExportPattern[bremch],SensitivityExtractor[selprod,Npot,BrhToSSval,NevMin]}*) +(*]*) +(*SensitivityBlock[NevMin_,BrhToSSval_,Npot_,SelectedProduction_]:=Block[{},*) +(*If[!MemberQ[SelectedProduction,"Bremsstrahlung"],*) +(*TabSens={{1,SelectedProduction,"None",SensitivityExtractor[SelectedProduction,Npot,BrhToSSval,NevMin]}};*) +(*,*) +(*TabSens=Table[SensitivityExtractorBrem[SelectedProduction,i,Npot,BrhToSSval,NevMin],{i,1,Length[BremChannelsList],1}];*) +(*];*) +(*filenameexport=FileNameJoin[{directory["Sensitivity-LLP-exp"],ToString@StringForm["Sensitivity_``_at_``_BrhToSS=``_Nev=``_Npot=``.",Sequence@@{LLPdirName,ExperimentFolder,BrhToSSval//ToString,NevMin//ToString,N[Npot]//CForm//ToString}]}];*) +(*assocData=Map[Association["Index"->#[[1]],"Production modes"->#[[2]],"Bremsstrahlung description"->#[[3]],"Sensitivity domains"->#[[4]]]&,TabSens];*) +(*Export[filenameexport<>"mx",TabSens,"MX"];*) +(*Export[filenameexport<>"json",assocData,"JSON"];*) +(*(*TabSens*)*) +(*Import[filenameexport<>"mx","MX"]*) +(*]*) + + +(* ::Subsection::Closed:: *) +(*Sensitivity setup and plot*) + + +(* ::Input:: *) +(*productionlist=Join[{"All"},ProductionChannelsListUnified];*) +(*DynamicModule[{input0=0.,input1=NpotDefault,input2=2.3,choice={"All"},list,phrase},*) +(*DialogInput[Column[{Style[ExperimentFolder,Bold],TextCell["Enter Br(h->SS):"],InputField[Dynamic[input0],Expression],TextCell["Enter the number of proton collisions:"],InputField[Dynamic[input1],Expression],TextCell["Enter the value of N_ev,min for which the sensitivity will be computed:"],InputField[Dynamic[input2],Expression],Row[{"Select the production channels to be used for the sensitivity calculation:"}],Pane[TogglerBar[Dynamic[choice],productionlist,Appearance->"Vertical"->{Automatic,1}],ImageSize->{Automatic,Automatic},Scrollbars->{False,True}],Button["Submit",DialogReturn[{BrhToSSval,NpotVal,NevMinVal,SelectedProduction}={input0,input1,input2,choice}//N],ImageSize->Automatic]}]]];*) +(*If[MemberQ[SelectedProduction,"All"],SelectedProduction=ProductionChannelsListUnified;]*) +(*{{"Br(h->SS)","\!\(\*SubscriptBox[\(N\), \(PoT\)]\) for computation","\!\(\*SubscriptBox[\(N\), \(ev, min\)]\)","Selected production modes"},{BrhToSSval,NpotVal,NevMinVal,SelectedProduction}}//TableForm*) +(*sens=SensitivityBlock[NevMinVal,BrhToSSval,NpotVal,SelectedProduction];*) +(*legends=sens[[All,-2]];*) +(*sensregions=sens[[All,-1]];*) +(*ColorsForPlot={{Thick,Blue},{Thick,Darker@Red},{Thick,Darker@Darker@Green},{Thick,Darker@Cyan},{Thick,Magenta},{Thick, Black},{Thick,Lighter@Brown},{Thick,Lighter@Blue},{Thick,Lighter@Red},{Thick,Lighter@Green},{Thick,Blue,Dashing[0.02]},{Thick,Darker@Red,Dashing[0.02]},{Thick,Darker@Darker@Green,Dashing[0.02]},{Thick,Darker@Cyan,Dashing[0.02]},{Thick,Magenta,Dashing[0.02]},{Thick,Black,Dashing[0.02]},{Thick,Lighter@Brown,Dashing[0.02]},{Thick,Lighter@Blue,Dashing[0.02]},{Thick,Lighter@Red,Dashing[0.02]},{Thick,Lighter@Green,Dashing[0.02]}};*) +(*plotstylelist=Flatten[Table[ConstantArray[ColorsForPlot[[i]],If[MatrixQ[sensregions[[i]]],1,Length@sensregions[[i]]]],{i,1,Length[sensregions],1}],1];*) +(*Show[ListLogLogPlot[Cases[ExcludedRegions[LLPdirName],_?MatrixQ,All],Joined->{True,True,True,True},Frame-> True,FrameLabel->{"\!\(\*SubscriptBox[\(m\), \(S\)]\) [GeV]" , "\!\(\*SuperscriptBox[\(\[Theta]\), \(2\)]\)"},FrameStyle->Directive[Black, 23],PlotStyle->{{Thick,Gray}},Filling->{1->{True,Directive[Gray,Opacity[0.3]]},2->{True,Directive[Gray,Opacity[0.3]]},3->{True,Directive[Gray,Opacity[0.3]]},4->{True,Directive[Gray,Opacity[0.3]]}},ImageSize->Large,PlotRange->{{1.01mminmaxOverall[[1]],1.1mminmaxOverall[[2]]},{0.3Min[Flatten[sensregions]],0.99couplingminmaxOverall[[2]]}},PlotLabel->Style[Row[{GivenExperimentForSensitivityComputation,", \!\(\*SubscriptBox[\(N\), \(events\)]\) \[GreaterEqual] ",NevMinVal,", \!\(\*SubscriptBox[\(Br\), \(h -> SS\)]\) = ",BrhToSSval}],18,Black]],*) +(*ListLogLogPlot[Cases[sensregions,_?MatrixQ,All],Joined->{True,True,True,True},PlotStyle->plotstylelist,ImageSize->Large,PlotRange->{{1.01mminmaxOverall[[1]],1.1mminmaxOverall[[2]]},{couplingminmaxOverall[[1]],Max[0.2,0.99couplingminmaxOverall[[2]]]}}],LogLogPlot[{1,1,1,1,1,1},{x,1,10},PlotStyle->DeleteDuplicates[plotstylelist],ImageSize->Large,PlotRange->{{1.01mminmaxOverall[[1]],1.1mminmaxOverall[[2]]},{couplingminmaxOverall[[1]],Max[0.2,0.99couplingminmaxOverall[[2]]]}},PlotLegends->Placed[Style[#,15]&/@legends,{0.2,0.15}]],Graphics[{Text[Style["Excluded",24,Black],Scaled[{0.7,0.95}]]}]]*) +(*(*Show[ListLogLogPlot[Cases[ExcludedRegions[LLPdirName],_?MatrixQ,All],Joined\[Rule]{True,True,True,True},Frame\[Rule] True,FrameLabel\[Rule]{"Subscript[m, S] [GeV]" , "\[Theta]^2"},FrameStyle\[Rule]Directive[Black, 23],PlotStyle\[Rule]{{Thick,Gray}},Filling\[Rule]{1\[Rule]{True,Directive[Gray,Opacity[0.3]]},2\[Rule]{True,Directive[Gray,Opacity[0.3]]},3\[Rule]{True,Directive[Gray,Opacity[0.3]]},4\[Rule]{True,Directive[Gray,Opacity[0.3]]}},ImageSize\[Rule]Large,PlotRange\[Rule]{{1.01mminmaxOverall[[1]],1.1mminmaxOverall[[2]]},{0.3*Min[Flatten[Sens]],couplingminmaxOverall[[2]]}},PlotLabel\[Rule]Style[Row[{"Subscript[N, events] \[GreaterEqual] ",NevMinVal}],18,Black]],*) +(*ListLogLogPlot[Cases[sens,_?MatrixQ,All],Joined\[Rule]{True,True,True,True},PlotStyle\[Rule]Flatten[{ConstantArray[{Thick,Blue},If[MatrixQ[sens],1,Length@sens]]},1],ImageSize\[Rule]Large,PlotRange\[Rule]{{1.01mminmaxOverall[[1]],1.1mminmaxOverall[[2]]},{0.3*Min[Flatten[Sens]],0.99couplingminmaxOverall[[2]]}},PlotLabel\[Rule]Style[Row[{"Subscript[N, events] \[GreaterEqual] ",NevMinVal}],18,Black],PlotLegends\[Rule]Placed[Style[#,15]&/@{ExperimentFolder},{0.2,0.15}]],Graphics[{Text[Style["Excluded",24,Black],Scaled[{0.7,0.95}]]}]]*)*) + + +(* ::Title::Closed:: *) +(*Deleting generated cells*) + + +(* ::Input:: *) +(*FrontEndTokenExecute["DeleteGeneratedCells"];*) +(*FrontEndTokenExecute["SelectAll"];*) +(*FrontEndTokenExecute["SelectionCloseAllGroups"];*) diff --git a/wls/4. Plots.wls b/wls/4. Plots.wls new file mode 100755 index 0000000..293b899 --- /dev/null +++ b/wls/4. Plots.wls @@ -0,0 +1,550 @@ +#!/usr/bin/env wolframscript +(* ::Package:: *) + +(* ::Chapter::Closed:: *) +(*Definitions (launch first)*) + + +(* ::Input:: *) +(*dropdownDialog[list_,phrase_]:=DialogInput[{choice=""},Column[{TextCell[phrase],PopupMenu[Dynamic[choice],list],Button["OK",DialogReturn[choice]]}]]*) +(*selectionDialog[list_,phrase_]:=DialogInput[{choice={}},Column[{Row[{"Select the experiments for which the number of events will be computed. The meaning is ",phrase}],Pane[TogglerBar[Dynamic[choice],list,Appearance->"Vertical"->{Automatic,3}],ImageSize->{Automatic,Automatic},Scrollbars->{False,True}],Button["OK",DialogReturn[choice]]}]]*) +(*selectionDialog2[list_,phrase_]:=DialogInput[{choice=Null},Column[{Row[{phrase}],Pane[RadioButtonBar[Dynamic[choice],list,Appearance->"Vertical"],ImageSize->{Automatic,Automatic},Scrollbars->{False,True}],Button["OK",DialogReturn[choice]]}]]*) +(*If[(DirectoryQ[FileNameJoin[{NotebookDirectory[],"plots"}]]//ToString)=="False",CreateDirectory[FileNameJoin[{NotebookDirectory[],"plots"}]]]*) +(*(*List of implemented LLPs*)*) +(*LLPlist={"HNL","Scalar","DP","ALP-photon","ALP-fermion","ALP-gluon","B-L","B-3Le-Lmu+Ltau","B-Le-3Lmu+Ltau","B-3Lmu"};*) + + +(* ::Section::Closed:: *) +(*Constraints/sensitivities*) + + +(* ::Input:: *) +(*importformat["txt"]=importformat["dat"]="Table";*) +(*importformat["m"]=importformat["mx"]="MX";*) +(*importformat["xls"]="XLS";*) +(*Do[*) +(*dir=FileNameJoin[{NotebookDirectory[],"contours",LLP}];*) +(*If[DirectoryQ[dir],*) +(*filenames=FileNames[LLP<>"-excluded*",dir,Infinity];*) +(*ExcludedRegions[LLP]=Import[#,importformat[FileExtension[#]]]&/@FileNames[LLP<>"-excluded*",dir,Infinity];*) +(*];*) +(*If[!DirectoryQ[dir],*) +(*ExcludedRegions[LLP]={{{10.,10.}}};*) +(*]*) +(*,{LLP,Select[LLPlist,#!="DP"&]}]*) + + +(* ::Subsection::Closed:: *) +(*DP*) + + +(* ::Input:: *) +(*ConstraintsDPtemp=Import[FileNameJoin[{NotebookDirectory[],"contours/DP/constraints-DP.mx"}],"MX"];*) +(*ConstraintsTypeDP=ConstraintsDPtemp[[All,1]]*) +(*Do[*) +(*ExcludedRegions["DP",ConstraintsDPtemp[[i]][[1]]]=ConstraintsDPtemp[[i]][[2]];*) +(*,{i,1,Length[ConstraintsDPtemp],1}]*) + + +(* ::Chapter::Closed:: *) +(*HNL*) + + +(* ::Section::Closed:: *) +(*Importing sensitivities from other papers*) + + +(* ::Input:: *) +(*(*Importing contours with past experiments and some sensitivities*)*) +(*Seesaw=Table[{mN,5*10^-11/mN},{mN,0.01,90,0.1}];*) + + +(* ::Section::Closed:: *) +(*List of available sensitivities*) + + +(* ::Input:: *) +(*LLPdirName="HNL";*) +(*filenamesSensitivityTemp=FileNames["*.xls",FileNameJoin[{NotebookDirectory[],"Sensitivity domains",LLPdirName}],2]//Sort;*) +(*filenamesSensitivity=Table[Last@FileNameSplit@filenamesSensitivityTemp[[i]],{i,1,Length[filenamesSensitivityTemp],1}];*) +(*ParametersSensitivityTemp[i_]:=StringCases[filenamesSensitivity[[i]],"Sensitivity_"<>LLPdirName<>"_Pattern_"~~ue__~~"-"~~um__~~"-"~~ut__~~"_"~~type__~~"_at_"~~experiment__~~"_Nev="~~Nev__~~"_Npot="~~Npot__~~".xls":>{ue,um,ut,type,experiment,Nev,Npot}][[1]]*) +(*ParametersSensitivity=Table[ParametersSensitivityTemp[i],{i,1,Length[filenamesSensitivity],1}];*) +(*Print["List of available sensitivities:"]*) +(*rowexpl={{"\!\(\*FractionBox[SubscriptBox[SuperscriptBox[\(U\), \(2\)], \(e\)], SuperscriptBox[\(U\), \(2\)]]\)","\!\(\*FractionBox[SubscriptBox[SuperscriptBox[\(U\), \(2\)], \(\[Mu]\)], SuperscriptBox[\(U\), \(2\)]]\)","\!\(\*FractionBox[SubscriptBox[SuperscriptBox[\(U\), \(2\)], \(\[Tau]\)], SuperscriptBox[\(U\), \(2\)]]\)","Nature","Experiment","\!\(\*SubscriptBox[\(N\), \(ev, min\)]\)","\!\(\*SubscriptBox[\(N\), \(PoT\)]\)"}};*) +(*Join[rowexpl,ParametersSensitivity]//TableForm*) +(*Print["Selected sensitivities:"]*) +(*listSensitivities=selectionDialog[ParametersSensitivity,"{\!\(\*SubscriptBox[\(x\), \(e\)]\), \!\(\*SubscriptBox[\(x\), \(\[Mu]\)]\), \!\(\*SubscriptBox[\(x\), \(\[Tau]\)]\), Nature, Experiment, \!\(\*SubscriptBox[\(N\), \(ev, min\)]\), \!\(\*SubscriptBox[\(N\), \(PoT\)]\)}"];*) +(*Join[rowexpl,listSensitivities]//TableForm*) +(*SensitivitiesForPlot=Table[Import[FileNameJoin[{NotebookDirectory[],"Sensitivity domains",LLPdirName,listSensitivities[[i]][[5]],ToString@StringForm["Sensitivity_"<>LLPdirName<>"_Pattern_``-``-``_``_at_``_Nev=``_Npot=``.xls",Sequence@@listSensitivities[[i]]]}]],{i,1,Length[listSensitivities],1}];*) +(*dirplots=FileNameJoin[{NotebookDirectory[],"plots",LLPdirName}];*) +(*If[!DirectoryQ[dirplots],CreateDirectory[dirplots]]*) +(*{mminmaxoverall,couplingminmaxoverall}=MinMax[Join[##,1]&@@Table[MinMax[Flatten[SensitivitiesForPlot[[i]],1][[All,#]]],{i,1,Length[SensitivitiesForPlot]}]]&/@{1,2};*) +(*(*If the selected pattern coincides with pure e, mu, or tau mixings, the plot will also include the excluded region*)*) +(*pattern=listSensitivities[[All,{1,2,3}]][[1]]//ToExpression;*) +(*nature=listSensitivities[[All,4]][[1]];*) +(*ExcludedRegionsTemp[LLPdirName]=If[nature=="Majorana",If[pattern=={1,0,0},{Seesaw,ExcludedRegions[LLPdirName][[1]],ExcludedRegions[LLPdirName][[4]]},If[pattern=={0,1,0},{Seesaw,ExcludedRegions[LLPdirName][[2]],ExcludedRegions[LLPdirName][[5]]},If[pattern=={0,0,1},{Seesaw,ExcludedRegions[LLPdirName][[3]],ExcludedRegions[LLPdirName][[6]]},{Seesaw}]]],{Seesaw}];*) + + +(* ::Section::Closed:: *) +(*Plot*) + + +(* ::Input:: *) +(*LegendsForPlot=Table[Row[{listSensitivities[[i]][[5]],", \!\(\*SubscriptBox[\(N\), \(ev\)]\) \[GreaterEqual] ", listSensitivities[[i]][[6]]}],{i,1,Length[listSensitivities],1}];*) +(*ColorsForPlot={{Thick,Blue},{Thick,Darker@Red},{Thick,Darker@Darker@Green},{Thick,Darker@Cyan},{Thick,Magenta},{Thick, Black},{Thick,Blue,Dashing[0.02]},{Thick,Darker@Red,Dashing[0.02]},{Thick,Darker@Darker@Green,Dashing[0.02]},{Thick,Darker@Cyan,Dashing[0.02]},{Thick,Magenta,Dashing[0.02]},{Thick,Black,Dashing[0.02]}};*) +(*plotstylelist=Flatten[Table[ConstantArray[ColorsForPlot[[i]],If[MatrixQ[SensitivitiesForPlot[[i]]],1,Length@SensitivitiesForPlot[[i]]]],{i,1,Length[SensitivitiesForPlot],1}],1];*) +(*PlotSensitivityHNL=Show[ListLogLogPlot[Evaluate[ExcludedRegionsTemp[LLPdirName]],Joined->True,PlotStyle->{{Thick,Gray,Dashing[0.05]},{Thick,Gray},{Thick,Lighter@Gray}},Frame-> True,FrameLabel->{"\!\(\*SubscriptBox[\(m\), \(N\)]\) [GeV]" , "\!\(\*SuperscriptBox[\(U\), \(2\)]\)"},FrameStyle->Directive[Black, 23],ImageSize->Large,PlotRange->{{1.01mminmaxoverall[[1]],1.1mminmaxoverall[[2]]},{0.05*couplingminmaxoverall[[1]],0.97couplingminmaxoverall[[2]]}},PlotLabel->Style[Row[{"HNLs. ", nature, " nature, pattern =", pattern}],16,Black],Filling->{1->{Bottom,Directive[Gray,Opacity[0.2]]},2->{True,Directive[Gray,Opacity[0.3]]},2->{Bottom,Directive[Lighter@Gray,Opacity[0.2]]}}],ListLogLogPlot[Cases[SensitivitiesForPlot,_?MatrixQ,All],Joined->True,PlotStyle->plotstylelist],Plot[{1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},{x,0,1},PlotStyle->DeleteDuplicates[plotstylelist],PlotLegends->Placed[Style[#,15]&/@LegendsForPlot,(*{0.24,0.14}*)Right]],Graphics[{Text[Style["Excluded",24,Black],Scaled[{0.5,0.9}]]}]]*) +(*Export[FileNameJoin[{dirplots,"Sensitivity_"<>LLPdirName<>".pdf"}],PlotSensitivityHNL]*) + + +(* ::Chapter::Closed:: *) +(*Scalar*) + + +(* ::Section:: *) +(*Importing constraints/sensitivities from other papers*) + + +(* ::Section::Closed:: *) +(*List of available sensitivities*) + + +(* ::Input:: *) +(*LLPdirName="Scalar";*) +(*SensitivityFolder=FileNameJoin[{NotebookDirectory[],"Sensitivity domains",LLPdirName}];*) +(*filenamesSensitivityTemp=FileNames["*.mx",SensitivityFolder,2];*) +(*filenamesSensitivity=Table[Last@FileNameSplit@filenamesSensitivityTemp[[i]],{i,1,Length[filenamesSensitivityTemp],1}];*) +(*ParametersSensitivityTemp[i_]:=StringCases[filenamesSensitivity[[i]],"Sensitivity_"<>LLPdirName<>"_at_"~~experiment__~~"_BrhToSS="~~BrhToSS__~~"_Nev="~~Nev__~~"_Npot="~~Npot__~~".mx":>{experiment,BrhToSS//ToExpression,Nev//ToExpression,Npot}][[1]]*) +(*ParametersSensitivity=Table[ParametersSensitivityTemp[i],{i,1,Length[filenamesSensitivity],1}];*) +(*Print["List of available sensitivities:"]*) +(*rowexpl={{"Experiment","Br(h->SS)","\!\(\*SubscriptBox[\(N\), \(ev, min\)]\)","\!\(\*SubscriptBox[\(N\), \(PoT\)]\)"}};*) +(*Join[rowexpl,ParametersSensitivity]//TableForm*) +(*Print["Selected sensitivities:"]*) +(*listSensitivities=selectionDialog[ParametersSensitivity,"{Experiment, \!\(\*SubscriptBox[\(Br\), \(h -> SS\)]\), \!\(\*SubscriptBox[\(N\), \(ev, min\)]\), \!\(\*SubscriptBox[\(N\), \(PoT\)]\)}"];*) +(*Join[rowexpl,listSensitivities]//TableForm*) +(*SensitivitiesForPlotTemp=Table[Import[FileNameJoin[{NotebookDirectory[],"Sensitivity domains",LLPdirName,listSensitivities[[i]][[1]],ToString@StringForm["Sensitivity_"<>LLPdirName<>"_at_``_BrhToSS=``_Nev=``_Npot=``.mx",Sequence@@listSensitivities[[i]]]}]],{i,1,Length[listSensitivities],1}];*) +(*bremBaseline=selectionDialog2[SensitivitiesForPlotTemp[[1]][[All,3]],"Select the baseline bremsstrahlung choice:"];*) +(*SensitivitiesForPlotBaselineTemp=Table[Select[SensitivitiesForPlotTemp[[i]],#[[3]]==bremBaseline&],{i,1,Length[SensitivitiesForPlotTemp]}];*) +(*SensitivitiesForPlotBaseline=SensitivitiesForPlotBaselineTemp[[All,1,-1]];*) +(*dirplots=FileNameJoin[{NotebookDirectory[],"plots",LLPdirName}];*) +(*If[!DirectoryQ[dirplots],CreateDirectory[dirplots]]*) +(*{mminmaxoverall,couplingminmaxoverall}=MinMax[Join[##,1]&@@Table[MinMax[Flatten[SensitivitiesForPlotBaseline[[i]],1][[All,#]]],{i,1,Length[SensitivitiesForPlotBaseline]}]]&/@{1,2};*) +(*(*Importing constraints*)*) +(*PlotRangeDomain={{0.025,5.3},{10^-13.,10^-4}};*) +(*PlotConstraintsTemp[phrase_]:=Show[ListLogLogPlot[Evaluate[ExcludedRegions[LLPdirName]],Joined->True,PlotStyle->{{Thick,Gray},{Thick,Gray},{Thick,Gray},{Thick,Lighter@Gray},{Thick,Gray}},Frame-> True,FrameLabel->{"\!\(\*SubscriptBox[\(m\), \(S\)]\) [GeV]" , "\!\(\*SuperscriptBox[\(\[Theta]\), \(2\)]\)"},FrameStyle->Directive[Black, 23],ImageSize->Large,PlotRange->PlotRangeDomain,PlotLabel->Style[Row[{phrase}],18,Black],Filling->{1->{True,Directive[Gray,Opacity[0.3]]},2->{True,Directive[Gray,Opacity[0.3]]},3->{True,Directive[Gray,Opacity[0.3]]},4->{True,Directive[Gray,Opacity[0.1]]}}],Graphics[{Text[Style["Excluded",24,Black],Scaled[{0.25,0.95}]]}]]*) +(*PlotConstraintsTemp["Dark scalar"]*) + + +(* ::Section::Closed:: *) +(*Plots - baseline*) + + +(* ::Input:: *) +(*LegendsForPlot=Table[Row[{listSensitivities[[i]][[1]],", \!\(\*SubscriptBox[\(N\), \(ev\)]\) \[GreaterEqual] ", listSensitivities[[i]][[3]]}],{i,1,Length[listSensitivities],1}];*) +(*ColorsForPlot={{Thick,Blue},{Thick,Darker@Red},{Thick,Darker@Darker@Green},{Thick,Darker@Cyan},{Thick,Magenta},{Thick, Black},{Thick,Blue,Dashing[0.02]},{Thick,Darker@Red,Dashing[0.02]},{Thick,Darker@Darker@Green,Dashing[0.02]},{Thick,Darker@Cyan,Dashing[0.02]},{Thick,Magenta,Dashing[0.02]},{Thick,Black,Dashing[0.02]}};*) +(*plotstylelist=Flatten[Table[ConstantArray[ColorsForPlot[[i]],If[MatrixQ[SensitivitiesForPlotBaseline[[i]]],1,Length@SensitivitiesForPlotBaseline[[i]]]],{i,1,Length[SensitivitiesForPlotBaseline],1}],1];*) +(*PlotSensitivityScalar=Show[PlotConstraintsTemp["Dark scalar"],ListLogLogPlot[Cases[SensitivitiesForPlotBaseline,_?MatrixQ,All],Joined->True,PlotStyle->plotstylelist],Plot[{1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},{x,0,1},PlotStyle->DeleteDuplicates[plotstylelist],PlotLegends->Placed[Style[#,15]&/@LegendsForPlot,{0.3,0.14}(*Right*)]]]*) +(*Export[FileNameJoin[{dirplots,"Sensitivity_"<>LLPdirName<>".pdf"}],PlotSensitivityScalar]*) + + +(* ::Section::Closed:: *) +(*Plot - bremsstrahlung uncertainties (for dedicated experiments)*) + + +(* ::Input:: *) +(*counterval=1;*) +(*sensitivityExperiment//Clear;*) +(*Print["Selected experiment:"]*) +(*GivenExperiment=listSensitivities[[counterval]][[1]]*) +(*sensData=SensitivitiesForPlotTemp[[counterval]];*) +(*Print["Available bremsstrahlung descriptions:"]*) +(*bremVariants=sensData[[All,3]]*) +(*Do[*) +(*sensitivityExperiment[sensData[[i]][[3]]]=sensData[[i]][[-1]]*) +(*,{i,1,Length[sensData],1}]*) +(*sensitivitiesGivenExperiment=sensitivityExperiment[#]&/@bremVariants;*) +(*BremDescriptionUncertainty="AP";*) +(*ColorsBrem["Baseline"]={Thick,Darker@Red};*) +(*{lower,central,upper}=(BremDescriptionUncertainty<>"-"<>#<>"-mixing")&/@{"Lower","Central","Upper"};*) +(*ColorsBrem[central]={Thick,Blue};*) +(*ColorsBrem[lower]={Thick,Blue,Dashing[0.01]};*) +(*ColorsBrem[upper]={Thick,Blue,Dashing[0.01]};*) +(*(*Do[*) +(*PlotSens[bremvariant]=ListLogLogPlot[Cases[sensitivityExperiment[bremvariant],_?MatrixQ,All],Joined->True,PlotStyle->ColorsBrem[bremvariant]]*) +(*,{bremvariant,bremVariants}*) +(*]*)*) +(*PlotUncertainty[sensitivityExperiment_]:=Block[{},*) +(*Do[LenRegions[u]=Length[sensitivityExperiment[u]],{u,{upper,lower}}];*) +(*SensitivitiesToPlot=Join[Table[sensitivityExperiment[upper][[i]],{i,1,LenRegions[upper]}],Table[sensitivityExperiment[lower][[i]],{i,1,LenRegions[lower]}]];*) +(*FillingDirective=Join[Table[i->{True,Directive[Blue,Opacity[0.1]]},{i,1,LenRegions[upper],1}],Table[i+LenRegions[upper]->{True,Directive[White]},{i,1,LenRegions[lower],1}]];*) +(*ColorsDirective=Join[Table[ColorsBrem[upper],LenRegions[upper]],Table[ColorsBrem[lower],LenRegions[lower]]];*) +(*plot1=ListLogLogPlot[Evaluate[SensitivitiesToPlot],Joined->True,Filling->FillingDirective,PlotStyle->ColorsDirective,Frame->True,PlotRange->PlotRangeDomain,FrameStyle->Directive[Black, 23],ImageSize->Large,FrameLabel->{"\!\(\*SubscriptBox[\(m\), \(S\)]\) [GeV]" , "\!\(\*SuperscriptBox[\(\[Theta]\), \(2\)]\)"},PlotLabel->Style[Row[{GivenExperiment}],18,Black]];*) +(*plot2=PlotConstraintsTemp[GivenExperiment];*) +(*Show[plot1,plot2]*) +(*]*) +(*plotstylelist=Flatten[Table[ConstantArray[ColorsBrem[bremVariants[[i]]],If[MatrixQ[sensitivitiesGivenExperiment[[i]]],1,Length@sensitivitiesGivenExperiment[[i]]]],{i,1,Length[sensitivitiesGivenExperiment],1}],1];*) +(*(*For filling the uncertainty band*)*) +(*PlotSensitivityDP=Show[PlotUncertainty[sensitivityExperiment],ListLogLogPlot[Cases[sensitivitiesGivenExperiment,_?MatrixQ,All],Joined->True,PlotStyle->plotstylelist](*,plotUncertainty*)(*,Plot[{1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},{x,0,1},PlotStyle->DeleteDuplicates[plotstylelist],PlotLegends\[Rule]Placed[Style[#,15]&/@LegendsForPlot,(*{0.24,0.14}*)Right]]*)]*) +(**) + + +(* ::Chapter::Closed:: *) +(*DP*) + + +(* ::Section::Closed:: *) +(*Importing constraints/sensitivities*) + + +(* ::Input:: *) +(*{otherconstraint["NA62-dump-lepton"],otherconstraint["NuCal"],otherconstraint["CHARM-lepton"]}=Import[FileNameJoin[{NotebookDirectory[],"contours/DP/Particular constraints/",#}],"Table"]&/@{"DP_NA62-dump-with-brem-collaboration.txt","DP_NuCal_Tsai.txt","DP_CHARM_Tsai.txt"};*) +(*{legendotherconstraint["NA62-dump-lepton"],legendotherconstraint["NuCal"],legendotherconstraint["CHARM-lepton"]}={"2303.08666","1908.07525","1908.07525"};*) + + +(* ::Section::Closed:: *) +(*List of available sensitivities*) + + +(* ::Input:: *) +(*LLPdirName="DP";*) +(*filenamesSensitivityTemp=FileNames["*.mx",FileNameJoin[{NotebookDirectory[],"Sensitivity domains",LLPdirName}],2];*) +(*filenamesSensitivity=Table[Last@FileNameSplit@filenamesSensitivityTemp[[i]],{i,1,Length[filenamesSensitivityTemp],1}];*) +(*ParametersSensitivityTemp[i_]:=StringCases[filenamesSensitivity[[i]],"Sensitivity_"<>LLPdirName<>"_at_"~~experiment__~~"_Nev="~~Nev__~~"_Npot="~~Npot__~~".mx":>{experiment,Nev//ToExpression,Npot}][[1]]*) +(*ParametersSensitivity=Table[ParametersSensitivityTemp[i],{i,1,Length[filenamesSensitivity],1}];*) +(*Print["List of available sensitivities:"]*) +(*rowexpl={{"Experiment","\!\(\*SubscriptBox[\(N\), \(ev, min\)]\)","\!\(\*SubscriptBox[\(N\), \(PoT\)]\)"}};*) +(*Join[rowexpl,ParametersSensitivity]//TableForm*) +(*Print["Selected sensitivities:"]*) +(*listSensitivities=selectionDialog[ParametersSensitivity,"{Experiment, \!\(\*SubscriptBox[\(N\), \(ev, min\)]\), \!\(\*SubscriptBox[\(N\), \(PoT\)]\)}"];*) +(*Join[rowexpl,listSensitivities]//TableForm*) +(*SensitivitiesForPlotTemp=Table[Import[FileNameJoin[{NotebookDirectory[],"Sensitivity domains",LLPdirName,listSensitivities[[i]][[1]],ToString@StringForm["Sensitivity_"<>LLPdirName<>"_at_``_Nev=``_Npot=``.mx",Sequence@@listSensitivities[[i]]]}]],{i,1,Length[listSensitivities],1}];*) +(*bremBaseline=selectionDialog2[SensitivitiesForPlotTemp[[1]][[All,3]],"Select the baseline bremsstrahlung choice:"];*) +(*SensitivitiesForPlotBaselineTemp=Table[Select[SensitivitiesForPlotTemp[[i]],#[[3]]==bremBaseline&],{i,1,Length[SensitivitiesForPlotTemp]}];*) +(*SensitivitiesForPlotBaseline=SensitivitiesForPlotBaselineTemp[[All,1,-1]];*) +(*dirplots=FileNameJoin[{NotebookDirectory[],"plots",LLPdirName}];*) +(*If[!DirectoryQ[dirplots],CreateDirectory[dirplots]]*) +(*{mminmaxoverall,couplingminmaxoverall}=MinMax[Join[##,1]&@@Table[MinMax[Flatten[SensitivitiesForPlotBaseline[[i]],1][[All,#]]],{i,1,Length[SensitivitiesForPlotBaseline]}]]&/@{1,2};*) +(*(*Importing constraints*)*) +(*PlotRangeDomain={{0.025,5.02},{10^-19.,10^-4}};*) +(*PlotConstraintsTemp[phrase_,brem_, beamDumpPhrase_]:=Show[ListLogLogPlot[Evaluate[ExcludedRegions[LLPdirName,brem]],Joined->True,PlotStyle->{{Thick,Gray},{Thick,Gray},{Thick,Gray},{Thick,Gray},{Thick,Gray}},Frame-> True,FrameLabel->{"\!\(\*SubscriptBox[\(m\), \(V\)]\) [GeV]" , "\!\(\*SuperscriptBox[\(\[Epsilon]\), \(2\)]\)"},FrameStyle->Directive[Black, 23],ImageSize->Large,PlotRange->PlotRangeDomain,PlotLabel->Style[Row[{phrase}],18,Black],Filling->{1->{True,Directive[Gray,Opacity[0.1]]},2->{True,Directive[Gray,Opacity[0.3]]},3->{True,Directive[Gray,Opacity[0.3]]},4->{True,Directive[Gray,Opacity[0.3]]}}],Graphics[{Text[Style["SN1987A",24,Black],Scaled[{0.14,0.1}]],Text[Style[beamDumpPhrase,24,Black],Scaled[{0.18,0.5}]],Text[Style["Prompt signatures",24,Black],Scaled[{0.25,0.95}]]}]]*) +(*PlotConstraintsTemp["Dark photon",bremBaseline];*) +(**) + + +(* ::Section::Closed:: *) +(*Plot - basic*) + + +(* ::Input:: *) +(*LegendsForPlot=Table[Row[{listSensitivities[[i]][[1]],", \!\(\*SubscriptBox[\(N\), \(ev\)]\) \[GreaterEqual] ",listSensitivities[[i]][[2]]}],{i,1,Length[listSensitivities],1}];*) +(*ColorsForPlot={{Thick,Blue},{Thick,Darker@Red},{Thick,Darker@Darker@Green},{Thick,Darker@Cyan},{Thick,Magenta},{Thick, Black},{Thick,Blue,Dashing[0.02]},{Thick,Darker@Red,Dashing[0.02]},{Thick,Darker@Darker@Green,Dashing[0.02]},{Thick,Darker@Cyan,Dashing[0.02]},{Thick,Magenta,Dashing[0.02]},{Thick,Black,Dashing[0.02]}};*) +(*plotstylelist=Flatten[Table[ConstantArray[ColorsForPlot[[i]],If[MatrixQ[SensitivitiesForPlotBaseline[[i]]],1,Length@SensitivitiesForPlotBaseline[[i]]]],{i,1,Length[SensitivitiesForPlotBaseline],1}],1];*) +(*PlotSensitivityDP=Show[PlotConstraintsTemp["Dark photon",bremBaseline,"Beam dump"],ListLogLogPlot[Cases[SensitivitiesForPlotBaseline,_?MatrixQ,All],Joined->True,PlotStyle->plotstylelist],Plot[{1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},{x,0,1},PlotStyle->DeleteDuplicates[plotstylelist],PlotLegends->Placed[Style[#,15]&/@LegendsForPlot,(*{0.24,0.14}*)Right]]]*) +(*Export[FileNameJoin[{dirplots,"Sensitivity_"<>LLPdirName<>".pdf"}],PlotSensitivityDP]*) + + +(* ::Section::Closed:: *) +(*Plot - bremsstrahlung uncertainties (for dedicated experiments)*) + + +(* ::Input:: *) +(*counterval=8;*) +(*sensitivityExperiment//Clear;*) +(*Print["Selected experiment:"]*) +(*GivenExperiment=listSensitivities[[counterval]][[1]]*) +(*sensData=SensitivitiesForPlotTemp[[counterval]];*) +(*Print["Available bremsstrahlung descriptions:"]*) +(*bremVariants=sensData[[All,3]]*) +(*Do[*) +(*sensitivityExperiment[sensData[[i]][[3]]]=sensData[[i]][[-1]]*) +(*,{i,1,Length[sensData],1}]*) +(*sensitivitiesGivenExperiment=sensitivityExperiment[#]&/@bremVariants;*) +(*BremDescriptionUncertainty="FR";*) +(*ColorsBrem["Baseline"]={Thick,Darker@Red};*) +(*{lower,central,upper}=(BremDescriptionUncertainty<>"-"<>#)&/@{"Lower","Central","Upper"};*) +(*ColorsBrem[central]={Thick,Blue};*) +(*ColorsBrem[lower]={Thick,Blue,Opacity[0.1]};*) +(*ColorsBrem[upper]={Thick,Blue,Opacity[0.1]};*) +(*(*Do[*) +(*PlotSens[bremvariant]=ListLogLogPlot[Cases[sensitivityExperiment[bremvariant],_?MatrixQ,All],Joined->True,PlotStyle->ColorsBrem[bremvariant]]*) +(*,{bremvariant,bremVariants}*) +(*]*)*) +(*PlotUncertainty[sensitivityExperiment_]:=Block[{},*) +(*Do[LenRegions[u]=Length[sensitivityExperiment[u]],{u,{upper,lower}}];*) +(*SensitivitiesToPlot=Join[Table[sensitivityExperiment[upper][[i]],{i,1,LenRegions[upper]}],Table[sensitivityExperiment[lower][[i]],{i,1,LenRegions[lower]}]];*) +(*FillingDirective=Join[Table[i->{True,Directive[Blue,Opacity[0.1]]},{i,1,LenRegions[upper],1}],Table[i+LenRegions[upper]->{True,Directive[White]},{i,1,LenRegions[lower],1}]];*) +(*ColorsDirective=Join[Table[ColorsBrem[upper],LenRegions[upper]],Table[ColorsBrem[lower],LenRegions[lower]]];*) +(*plot1=ListLogLogPlot[Evaluate[SensitivitiesToPlot],Joined->True,Filling->FillingDirective,PlotStyle->ColorsDirective,Frame->True,PlotRange->PlotRangeDomain,FrameStyle->Directive[Black, 23],ImageSize->Large,FrameLabel->{"\!\(\*SubscriptBox[\(m\), \(V\)]\) [GeV]" , "\!\(\*SuperscriptBox[\(\[Epsilon]\), \(2\)]\)"},PlotLabel->Style[Row[{GivenExperiment}],18,Black]];*) +(*plot2=PlotConstraintsTemp[GivenExperiment,"No brem","e beam dumps"];*) +(*Show[plot1,plot2]*) +(*]*) +(*plotstylelist=Flatten[Table[ConstantArray[ColorsBrem[bremVariants[[i]]],If[MatrixQ[sensitivitiesGivenExperiment[[i]]],1,Length@sensitivitiesGivenExperiment[[i]]]],{i,1,Length[sensitivitiesGivenExperiment],1}],1];*) +(*(*For filling the uncertainty band*)*) +(*If[Length[otherconstraint[GivenExperiment][[1]]]>0,*) +(*PlotSensitivityDP=Show[PlotUncertainty[sensitivityExperiment],ListLogLogPlot[otherconstraint[GivenExperiment],Joined->True,PlotStyle->{{Darker@Green,Dashing[0.01]}},PlotLegends->Placed[Style[#,15]&/@{legendotherconstraint[GivenExperiment]},{0.83,0.1}]],ListLogLogPlot[Cases[sensitivitiesGivenExperiment,_?MatrixQ,All],Joined->True,PlotStyle->plotstylelist]],PlotSensitivityDP=Show[PlotUncertainty[sensitivityExperiment],ListLogLogPlot[Cases[sensitivitiesGivenExperiment,_?MatrixQ,All],Joined->True,PlotStyle->plotstylelist]]*) +(*]*) +(*Export[FileNameJoin[{NotebookDirectory[],"plots/DP/Uncertainties/Brem_"<>GivenExperiment<>".pdf"}],PlotSensitivityDP]*) +(**) + + +(* ::Section::Closed:: *) +(*Plot - bremsstrahlung uncertainties (overall; include NuCal and NA62-dump-lepton constraints!!)*) + + +(* ::Input:: *) +(*experimentsPast={"BEBC","NuCal","CHARM-lepton"};*) +(*experimentsNA62lepton={"NA62-dump-lepton"};*) +(*experimentsFuture={"SHiP-ECN3","FACET","FASER2-FPF","NA62-dump","DarkQuest-phase-1","LHCb-Downstream"};*) +(*senslisttemp=Table[{listSensitivities[[i]][[1]],SensitivitiesForPlotTemp[[i]]},{i,1,Length[listSensitivities],1}];*) +(*senslistPastAll=Select[senslisttemp,MemberQ[experimentsPast,#[[1]]]&];*) +(*{senslistPast["Lower"],senslistPast["Upper"]}=Table[Select[Flatten[senslistPastAll[[All,2]],1],#[[3]]==list&][[All,4]],{list,{"FR-Lower","FR-Upper"}}];*) +(*senslistNA62leptonAll=Select[senslisttemp,MemberQ[experimentsNA62lepton,#[[1]]]&];*) +(*{senslistNA62lepton["Lower"],senslistNA62lepton["Upper"]}=Table[Select[Flatten[senslistNA62leptonAll[[All,2]],1],#[[3]]==list&][[All,4]],{list,{"FR-Lower","FR-Upper"}}];*) +(*senslistFutureAll=Select[senslisttemp,MemberQ[experimentsFuture,#[[1]]]&];*) +(*{senslistFuture["Lower"],senslistFuture["Upper"]}=Table[Select[Flatten[senslistFutureAll[[All,2]],1],#[[3]]==list&][[All,4]],{list,{"FR-Lower","FR-Upper"}}];*) +(*ColorsForPlot={{Thick,Blue},{Thick,Darker@Red},{Thick,Darker@Darker@Green},{Thick,Darker@Cyan},{Thick,Magenta},{Thick, Black},{Thick,Blue,Dashing[0.02]},{Thick,Darker@Red,Dashing[0.02]},{Thick,Darker@Darker@Green,Dashing[0.02]},{Thick,Darker@Cyan,Dashing[0.02]},{Thick,Magenta,Dashing[0.02]},{Thick,Black,Dashing[0.02]}};*) +(*{plotstylelistFuture["Lower"],plotstylelistFuture["Upper"]}=Table[Flatten[Table[ConstantArray[ColorsForPlot[[i]],If[MatrixQ[list[[i]]],1,Length@list[[i]]]],{i,1,Length[list],1}],1],{list,{senslistFuture["Lower"],senslistFuture["Upper"]}}];*) +(*PlotConstraintsTemp1[phrase_]:=Show[ListLogLogPlot[Evaluate[ExcludedRegions[LLPdirName]],Joined->True,PlotStyle->{{Thick,Gray},{Thick,Gray},{Thick,Gray},{Thick,Lighter@Gray},{Thick,Gray}},Frame-> True,FrameLabel->{"\!\(\*SubscriptBox[\(m\), \(V\)]\) [GeV]" , "\!\(\*SuperscriptBox[\(\[Epsilon]\), \(2\)]\)"},FrameStyle->Directive[Black, 23],ImageSize->Large,PlotRange->PlotRangeDomain,PlotLabel->Style[Row[{phrase}],18,Black],Filling->{1->{True,Directive[Gray,Opacity[0.3]]},2->{True,Directive[Gray,Opacity[0.3]]},3->{True,Directive[Gray,Opacity[0.3]]},4->{True,Directive[Gray,Opacity[0.1]]}}],Graphics[{Text[Style["Excluded",24,Black],Scaled[{0.25,0.95}]]}]]*) +(*plotOverall["Lower"]=Show[PlotConstraintsTemp["Lower bound of bremsstrahlung","FR-Lower", "Beam dump"],ListLogLogPlot[Cases[senslistNA62lepton["Lower"],_?MatrixQ,All],Joined->True,PlotStyle->{{Thick,Black,Dashing[0.02]}},Filling->Table[{i->{True,Directive[Lighter@Gray,Opacity[0.1]]}},{i,1,20,1}]],ListLogLogPlot[Cases[senslistFuture["Lower"],_?MatrixQ,All],Joined->True,PlotStyle->plotstylelistFuture["Lower"]],Plot[{1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},{x,0,1},PlotStyle->DeleteDuplicates[plotstylelistFuture["Lower"]],PlotLegends->Placed[Style[#,15]&/@senslistFutureAll[[All,1]],{0.81,0.67}(*Right*)]]];*) +(*plotOverall["Upper"]=Show[PlotConstraintsTemp["Upper bound of bremsstrahlung","FR-Upper", "Beam dump"],ListLogLogPlot[Cases[senslistNA62lepton["Upper"],_?MatrixQ,All],Joined->True,PlotStyle->{{Thick,Black,Dashing[0.02]}},Filling->Table[{i->{True,Directive[Lighter@Gray,Opacity[0.1]]}},{i,1,20,1}]],ListLogLogPlot[Cases[senslistFuture["Upper"],_?MatrixQ,All],Joined->True,PlotStyle->plotstylelistFuture["Upper"]],Plot[{1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},{x,0,1},PlotStyle->DeleteDuplicates[plotstylelistFuture["Upper"]],PlotLegends->Placed[Style[#,15]&/@senslistFutureAll[[All,1]],{0.81,0.67}(*Right*)]]];*) +(*Style[Row[plotOverall[#]&/@{"Lower","Upper"}]]*) +(*Export[FileNameJoin[{NotebookDirectory[],"plots/DP/Uncertainties/Summary-Brem-"<>#<>".pdf"}],plotOverall[#]]&/@{"Lower","Upper"};*) + + +(* ::Chapter::Closed:: *) +(*ALP-photon*) + + +(* ::Section:: *) +(*Importing constraints/sensitivities*) + + +(* ::Section::Closed:: *) +(*List of available sensitivities*) + + +(* ::Input:: *) +(*LLPdirName="ALP-photon";*) +(*filenamesSensitivityTemp=FileNames["*.xls",FileNameJoin[{NotebookDirectory[],"Sensitivity domains",LLPdirName}],2];*) +(*filenamesSensitivity=Table[Last@FileNameSplit@filenamesSensitivityTemp[[i]],{i,1,Length[filenamesSensitivityTemp],1}];*) +(*ParametersSensitivityTemp[i_]:=StringCases[filenamesSensitivity[[i]],"Sensitivity_"<>LLPdirName<>"_at_"~~experiment__~~"_Nev="~~Nev__~~"_Npot="~~Npot__~~".xls":>{experiment,Nev//ToExpression,Npot}][[1]]*) +(*ParametersSensitivity=Table[ParametersSensitivityTemp[i],{i,1,Length[filenamesSensitivity],1}];*) +(*Print["List of available sensitivities:"]*) +(*rowexpl={{"Experiment","\!\(\*SubscriptBox[\(N\), \(ev, min\)]\)","\!\(\*SubscriptBox[\(N\), \(PoT\)]\)"}};*) +(*Join[rowexpl,ParametersSensitivity]//TableForm*) +(*listSensitivities=selectionDialog[ParametersSensitivity,"{Experiment, \!\(\*SubscriptBox[\(N\), \(ev, min\)]\), \!\(\*SubscriptBox[\(N\), \(PoT\)]\)}"];*) +(*Print["Selected sensitivities:"]*) +(*Join[rowexpl,listSensitivities]//TableForm*) +(*SensitivitiesForPlot=Table[Import[FileNameJoin[{NotebookDirectory[],"Sensitivity domains",LLPdirName,listSensitivities[[i]][[1]],ToString@StringForm["Sensitivity_"<>LLPdirName<>"_at_``_Nev=``_Npot=``.xls",Sequence@@listSensitivities[[i]]]}]],{i,1,Length[listSensitivities],1}];*) +(*dirplots=FileNameJoin[{NotebookDirectory[],"plots",LLPdirName}];*) +(*If[!DirectoryQ[dirplots],CreateDirectory[dirplots]]*) +(**) + + +(* ::Section::Closed:: *) +(*Plot*) + + +(* ::Input:: *) +(*{mminmaxoverall,couplingminmaxoverall}=MinMax[Join[##,1]&@@Table[MinMax[Flatten[SensitivitiesForPlot[[i]],1][[All,#]]],{i,1,Length[SensitivitiesForPlot]}]]&/@{1,2};*) +(*LegendsForPlot=Table[Row[{listSensitivities[[i]][[1]],", \!\(\*SubscriptBox[\(N\), \(ev\)]\) \[GreaterEqual] ", listSensitivities[[i]][[2]]}],{i,1,Length[listSensitivities],1}];*) +(*ColorsForPlot={{Thick,Blue},{Thick,Darker@Red},{Thick,Darker@Darker@Green},{Thick,Darker@Cyan},{Thick,Magenta},{Thick, Black},{Thick,Blue,Dashing[0.02]},{Thick,Darker@Red,Dashing[0.02]},{Thick,Darker@Darker@Green,Dashing[0.02]},{Thick,Darker@Cyan,Dashing[0.02]},{Thick,Magenta,Dashing[0.02]},{Thick,Black,Dashing[0.02]}};*) +(*plotstylelist=Flatten[Table[ConstantArray[ColorsForPlot[[i]],If[MatrixQ[SensitivitiesForPlot[[i]]],1,Length@SensitivitiesForPlot[[i]]]],{i,1,Length[SensitivitiesForPlot],1}],1];*) +(*PlotSensitivityALPphoton=Show[ListLogLogPlot[Evaluate[ExcludedRegions[LLPdirName]],Joined->True,PlotStyle->{{Thick,Gray}},Frame-> True,FrameLabel->{"\!\(\*SubscriptBox[\(m\), \(a\)]\) [GeV]" , "\!\(\*SubscriptBox[\(g\), \(a\)]\) [\!\(\*SuperscriptBox[\(GeV\), \(-1\)]\)]"},FrameStyle->Directive[Black, 23],ImageSize->Large,PlotRange->{{1.01mminmaxoverall[[1]],1.1mminmaxoverall[[2]]},{0.05*couplingminmaxoverall[[1]],0.99couplingminmaxoverall[[2]]}},PlotLabel->Style[Row[{"ALPs coupled to photons"}],18,Black],Filling->{1->{True,Directive[Gray,Opacity[0.3]]}}],ListLogLogPlot[Cases[SensitivitiesForPlot,_?MatrixQ,All],Joined->True,PlotStyle->plotstylelist],Plot[{1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},{x,0,1},PlotStyle->DeleteDuplicates[plotstylelist],PlotLegends->Placed[Style[#,15]&/@LegendsForPlot,(*{0.24,0.14}*)Right]],Graphics[{Text[Style["Excluded",24,Black],Scaled[{0.2,0.5}]]}]]*) +(*Export[FileNameJoin[{dirplots,"Sensitivity_"<>LLPdirName<>".pdf"}],PlotSensitivityALPphoton]*) +(**) + + +(* ::Chapter::Closed:: *) +(*ALP-fermion*) + + +(* ::Section:: *) +(*Importing constraints/sensitivities from other papers*) + + +(* ::Section::Closed:: *) +(*List of available sensitivities*) + + +(* ::Input:: *) +(*LLPdirName="ALP-fermion";*) +(*filenamesSensitivityTemp=FileNames["*.xls",FileNameJoin[{NotebookDirectory[],"Sensitivity domains",LLPdirName}],2];*) +(*filenamesSensitivity=Table[Last@FileNameSplit@filenamesSensitivityTemp[[i]],{i,1,Length[filenamesSensitivityTemp],1}];*) +(*ParametersSensitivityTemp[i_]:=StringCases[filenamesSensitivity[[i]],"Sensitivity_"<>LLPdirName<>"_at_"~~experiment__~~"_Nev="~~Nev__~~"_Npot="~~Npot__~~".xls":>{experiment,Nev//ToExpression,Npot}][[1]]*) +(*ParametersSensitivity=Table[ParametersSensitivityTemp[i],{i,1,Length[filenamesSensitivity],1}];*) +(*Print["List of available sensitivities:"]*) +(*rowexpl={{"Experiment","\!\(\*SubscriptBox[\(N\), \(ev, min\)]\)","\!\(\*SubscriptBox[\(N\), \(Pot\)]\)"}};*) +(*Join[rowexpl,ParametersSensitivity]//TableForm*) +(*listSensitivities=selectionDialog[ParametersSensitivity,"{Experiment, \!\(\*SubscriptBox[\(N\), \(ev, min\)]\), \!\(\*SubscriptBox[\(N\), \(PoT\)]\)}"];*) +(*Print["Selected sensitivities:"]*) +(*Join[rowexpl,listSensitivities]//TableForm*) +(*SensitivitiesForPlot=Table[Import[FileNameJoin[{NotebookDirectory[],"Sensitivity domains",LLPdirName,listSensitivities[[i]][[1]],ToString@StringForm["Sensitivity_"<>LLPdirName<>"_at_``_Nev=``_Npot=``.xls",Sequence@@listSensitivities[[i]]]}]],{i,1,Length[listSensitivities],1}];*) +(*dirplots=FileNameJoin[{NotebookDirectory[],"plots",LLPdirName}];*) +(*If[!DirectoryQ[dirplots],CreateDirectory[dirplots]]*) +(*{mminmaxoverall,couplingminmaxoverall}=MinMax[Join[##,1]&@@Table[MinMax[Flatten[SensitivitiesForPlot[[i]],1][[All,#]]],{i,1,Length[SensitivitiesForPlot]}]]&/@{1,2};*) +(**) + + +(* ::Section::Closed:: *) +(*Plot*) + + +(* ::Input:: *) +(*LegendsForPlot=Table[Row[{listSensitivities[[i]][[1]],", \!\(\*SubscriptBox[\(N\), \(ev\)]\) \[GreaterEqual] ",listSensitivities[[i]][[2]]}],{i,1,Length[listSensitivities],1}];*) +(*ColorsForPlot={{Thick,Blue},{Thick,Darker@Red},{Thick,Darker@Darker@Green},{Thick,Darker@Cyan},{Thick,Magenta},{Thick, Black},{Thick,Blue,Dashing[0.02]},{Thick,Darker@Red,Dashing[0.02]},{Thick,Darker@Darker@Green,Dashing[0.02]},{Thick,Darker@Cyan,Dashing[0.02]},{Thick,Magenta,Dashing[0.02]},{Thick,Black,Dashing[0.02]}};*) +(*plotstylelist=Flatten[Table[ConstantArray[ColorsForPlot[[i]],If[MatrixQ[SensitivitiesForPlot[[i]]],1,Length@SensitivitiesForPlot[[i]]]],{i,1,Length[SensitivitiesForPlot],1}],1];*) +(*PlotSensitivityALPfermion=Show[ListLogLogPlot[Evaluate[Cases[ExcludedRegions[LLPdirName],_?MatrixQ,All]],Joined->True,PlotStyle->{{Thick,Gray}},Frame-> True,FrameLabel->{"\!\(\*SubscriptBox[\(m\), \(a\)]\) [GeV]" , "\!\(\*SubscriptBox[\(g\), \(Y\)]\) = 2\!\(\*SubscriptBox[\(v\), \(h\)]\)/\!\(\*SubscriptBox[\(f\), \(a\)]\)"},FrameStyle->Directive[Black, 23],ImageSize->Large,PlotRange->{{1.01mminmaxoverall[[1]],1.1mminmaxoverall[[2]]},{0.05*couplingminmaxoverall[[1]],0.99couplingminmaxoverall[[2]]}},PlotLabel->Style[Row[{"ALPs coupled to fermions"}],18,Black],Filling->Table[i->{True,Directive[Gray,Opacity[0.3]]},{i,1,20,1}]],ListLogLogPlot[Cases[SensitivitiesForPlot,_?MatrixQ,All],Joined->True,PlotStyle->plotstylelist],Plot[{1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},{x,0,1},PlotStyle->DeleteDuplicates[plotstylelist],PlotLegends->Placed[Style[#,15]&/@LegendsForPlot,(*{0.24,0.14}*)Right]],Graphics[{Text[Style["Excluded",24,Black],Scaled[{0.75,0.94}]]}]]*) +(*Export[FileNameJoin[{dirplots,"Sensitivity_"<>LLPdirName<>".pdf"}],PlotSensitivityALPfermion]*) + + +(* ::Chapter::Closed:: *) +(*ALP-gluon*) + + +(* ::Section:: *) +(*Importing constraints and sensitivities from other studies*) + + +(* ::Section::Closed:: *) +(*List of available sensitivities*) + + +(* ::Input:: *) +(*LLPdirName="ALP-gluon";*) +(*filenamesSensitivityTemp=FileNames["*.xls",FileNameJoin[{NotebookDirectory[],"Sensitivity domains",LLPdirName}],2];*) +(*filenamesSensitivity=Table[Last@FileNameSplit@filenamesSensitivityTemp[[i]],{i,1,Length[filenamesSensitivityTemp],1}];*) +(*ParametersSensitivityTemp[i_]:=StringCases[filenamesSensitivity[[i]],"Sensitivity_"<>LLPdirName<>"_at_"~~experiment__~~"_Nev="~~Nev__~~"_Npot="~~Npot__~~".xls":>{experiment,Nev//ToExpression,Npot}][[1]]*) +(*ParametersSensitivity=Table[ParametersSensitivityTemp[i],{i,1,Length[filenamesSensitivity],1}];*) +(*Print["List of available sensitivities:"]*) +(*rowexpl={{"Experiment","\!\(\*SubscriptBox[\(N\), \(ev, min\)]\)","\!\(\*SubscriptBox[\(N\), \(PoT\)]\)"}};*) +(*Join[rowexpl,ParametersSensitivity]//TableForm*) +(*Print["Selected sensitivities:"]*) +(*listSensitivities=selectionDialog[ParametersSensitivity,"{Experiment, \!\(\*SubscriptBox[\(N\), \(ev, min\)]\), \!\(\*SubscriptBox[\(N\), \(PoT\)]\)}"];*) +(*SensitivitiesForPlot=Table[Import[FileNameJoin[{NotebookDirectory[],"Sensitivity domains",LLPdirName,listSensitivities[[i]][[1]],ToString@StringForm["Sensitivity_"<>LLPdirName<>"_at_``_Nev=``_Npot=``.xls",Sequence@@listSensitivities[[i]]]}]],{i,1,Length[listSensitivities],1}];*) +(*dirplots=FileNameJoin[{NotebookDirectory[],"plots",LLPdirName}];*) +(*If[!DirectoryQ[dirplots],CreateDirectory[dirplots]]*) +(*Join[rowexpl,listSensitivities]//TableForm*) +(**) + + +(* ::Section::Closed:: *) +(*Plot*) + + +(* ::Input:: *) +(*{mminmaxoverall,couplingminmaxoverall}=MinMax[Join[##,1]&@@Table[MinMax[Flatten[SensitivitiesForPlot[[i]],1][[All,#]]],{i,1,Length[SensitivitiesForPlot]}]]&/@{1,2};*) +(*LegendsForPlot=Table[Row[{listSensitivities[[i]][[1]],", \!\(\*SubscriptBox[\(N\), \(ev\)]\) \[GreaterEqual] ", listSensitivities[[i]][[2]]}],{i,1,Length[listSensitivities],1}];*) +(*ColorsForPlot={{Thick,Blue},{Thick,Darker@Red},{Thick,Darker@Darker@Green},{Thick,Darker@Cyan},{Thick,Magenta},{Thick, Black},{Thick,Blue,Dashing[0.02]},{Thick,Darker@Red,Dashing[0.02]},{Thick,Darker@Darker@Green,Dashing[0.02]},{Thick,Darker@Cyan,Dashing[0.02]},{Thick,Magenta,Dashing[0.02]},{Thick,Black,Dashing[0.02]}};*) +(*plotstylelist=Flatten[Table[ConstantArray[ColorsForPlot[[i]],If[MatrixQ[SensitivitiesForPlot[[i]]],1,Length@SensitivitiesForPlot[[i]]]],{i,1,Length[SensitivitiesForPlot],1}],1];*) +(*PlotSensitivityALPgluon=Show[ListLogLogPlot[Evaluate[ExcludedRegions[LLPdirName][[1]]],Joined->True,PlotStyle->{{Thick,Gray}},Frame-> True,FrameLabel->{"\!\(\*SubscriptBox[\(m\), \(a\)]\) [GeV]" , "\!\(\*SubscriptBox[\(f\), \(G\)]\) [\!\(\*SuperscriptBox[\(GeV\), \(-1\)]\)]"},FrameStyle->Directive[Black, 23],ImageSize->Large,PlotRange->{{Max[1.01mminmaxoverall[[1]]],1.1mminmaxoverall[[2]]},{0.05*couplingminmaxoverall[[1]],0.99couplingminmaxoverall[[2]]}},PlotLabel->Style[Row[{"ALPs coupled to gluons"}],18,Black],Filling->{1->{True,Directive[Gray,Opacity[0.3]]},2->{True,Directive[Gray,Opacity[0.3]]},3->{True,Directive[Gray,Opacity[0.3]]},4->{True,Directive[Gray,Opacity[0.3]]}}],ListLogLogPlot[Cases[SensitivitiesForPlot,_?MatrixQ,All],Joined->True,PlotStyle->plotstylelist],Plot[{1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},{x,0,1},PlotStyle->DeleteDuplicates[plotstylelist],PlotLegends->Placed[Style[#,15]&/@LegendsForPlot,(*{0.24,0.14}*)Right]],Graphics[{Text[Style["Excluded",24,Black],Scaled[{0.15,0.7}]]}]]*) +(*Export[FileNameJoin[{dirplots,"Sensitivity_"<>LLPdirName<>".pdf"}],PlotSensitivityALPgluon]*) + + +(* ::Input:: *) +(*3*ArcSin[0.02/0.3]*) + + +(* ::Chapter::Closed:: *) +(*B mediators*) + + +(* ::Section::Closed:: *) +(*List of available sensitivities*) + + +(* ::Input:: *) +(*LLPdirName=dropdownDialog[{"B-L","B-3Lmu","B-3Le-Lmu+Ltau","B-Le-3Lmu+Ltau"},"Select the type of the mediator:"]*) +(*filenamesSensitivityTemp=FileNames["*.mx",FileNameJoin[{NotebookDirectory[],"Sensitivity domains",LLPdirName}],2];*) +(*filenamesSensitivity=Table[Last@FileNameSplit@filenamesSensitivityTemp[[i]],{i,1,Length[filenamesSensitivityTemp],1}];*) +(*ParametersSensitivityTemp[i_]:=StringCases[filenamesSensitivity[[i]],"Sensitivity_"<>LLPdirName<>"_at_"~~experiment__~~"_Nev="~~Nev__~~"_Npot="~~Npot__~~".mx":>{experiment,Nev//ToExpression,Npot}][[1]]*) +(*ParametersSensitivity=Table[ParametersSensitivityTemp[i],{i,1,Length[filenamesSensitivity],1}];*) +(*Print["List of available sensitivities:"]*) +(*rowexpl={{"Experiment","\!\(\*SubscriptBox[\(N\), \(ev, min\)]\)","\!\(\*SubscriptBox[\(N\), \(PoT\)]\)"}};*) +(*Join[rowexpl,ParametersSensitivity]//TableForm*) +(*Print["Selected sensitivities:"]*) +(*listSensitivities=selectionDialog[ParametersSensitivity,"{Experiment, \!\(\*SubscriptBox[\(N\), \(ev, min\)]\), \!\(\*SubscriptBox[\(N\), \(PoT\)]\)}"];*) +(*Join[rowexpl,listSensitivities]//TableForm*) +(*SensitivitiesForPlotTemp=Table[Import[FileNameJoin[{NotebookDirectory[],"Sensitivity domains",LLPdirName,listSensitivities[[i]][[1]],ToString@StringForm["Sensitivity_"<>LLPdirName<>"_at_``_Nev=``_Npot=``.mx",Sequence@@listSensitivities[[i]]]}]],{i,1,Length[listSensitivities],1}];*) +(*bremBaseline=selectionDialog2[SensitivitiesForPlotTemp[[1]][[All,3]],"Select the baseline bremsstrahlung choice:"];*) +(*SensitivitiesForPlotBaselineTemp=Table[Select[SensitivitiesForPlotTemp[[i]],#[[3]]==bremBaseline&],{i,1,Length[SensitivitiesForPlotTemp]}];*) +(*SensitivitiesForPlotBaseline=SensitivitiesForPlotBaselineTemp[[All,1,-1]];*) +(*dirplots=FileNameJoin[{NotebookDirectory[],"plots",LLPdirName}];*) +(*If[!DirectoryQ[dirplots],CreateDirectory[dirplots]]*) +(*{mminmaxoverall,couplingminmaxoverall}=MinMax[Join[##,1]&@@Table[MinMax[Flatten[SensitivitiesForPlotBaseline[[i]],1][[All,#]]],{i,1,Length[SensitivitiesForPlotBaseline]}]]&/@{1,2};*) +(*(*Importing constraints*)*) +(*PlotRangeDomain={{0.025,5.02},{10^-21.,10^-6}};*) +(*If[LLPdirName=="B-L",*) +(*PlotConstraintsTemp[phrase_]:=Show[ListLogLogPlot[Evaluate[ExcludedRegions[LLPdirName]],Joined->True,PlotStyle->{{Thick,Gray},{Thick,Gray},{Thick,Gray},{Thick,Lighter@Gray},{Thick,Gray}},Frame-> True,FrameLabel->{"\!\(\*SubscriptBox[\(m\), \(V\)]\) [GeV]" , "\!\(\*SubscriptBox[\(\[Alpha]\), \(B\)]\)"},FrameStyle->Directive[Black, 23],ImageSize->Large,PlotRange->PlotRangeDomain,PlotLabel->Style[Row[{phrase}],18,Black],Filling->{1->{True,Directive[Gray,Opacity[0.3]]},2->{True,Directive[Gray,Opacity[0.3]]},3->{True,Directive[Gray,Opacity[0.3]]},4->{True,Directive[Gray,Opacity[0.1]]}}],Graphics[{Text[Style["Excluded",24,Black],Scaled[{0.25,0.95}]]}]]*) +(*,*) +(*PlotConstraintsTemp[phrase_]:=Show[ListLogLogPlot[Table[{x,10^5},{x,0.01,100,1}],Joined->True,PlotStyle->{{Thick,Gray},{Thick,Gray},{Thick,Gray},{Thick,Lighter@Gray},{Thick,Gray}},Frame-> True,FrameLabel->{"\!\(\*SubscriptBox[\(m\), \(V\)]\) [GeV]" , "\!\(\*SubscriptBox[\(\[Alpha]\), \(B\)]\)"},FrameStyle->Directive[Black, 23],ImageSize->Large,PlotRange->PlotRangeDomain,PlotLabel->Style[Row[{phrase}],18,Black],Filling->{1->{True,Directive[Gray,Opacity[0.3]]},2->{True,Directive[Gray,Opacity[0.3]]},3->{True,Directive[Gray,Opacity[0.3]]},4->{True,Directive[Gray,Opacity[0.1]]}}],Graphics[{Text[Style["Excluded",24,Black],Scaled[{0.25,0.95}]]}]]*) +(*]*) +(*PlotConstraintsTemp[LLPdirName];*) +(**) + + +(* ::Section::Closed:: *) +(*Plot - baseline*) + + +(* ::Input:: *) +(*LegendsForPlot=Table[Row[{listSensitivities[[i]][[1]],", \!\(\*SubscriptBox[\(N\), \(ev\)]\) \[GreaterEqual] ",listSensitivities[[i]][[2]]}],{i,1,Length[listSensitivities],1}];*) +(*ColorsForPlot={{Thick,Blue},{Thick,Darker@Red},{Thick,Darker@Darker@Green},{Thick,Darker@Cyan},{Thick,Magenta},{Thick, Black},{Thick,Blue,Dashing[0.02]},{Thick,Darker@Red,Dashing[0.02]},{Thick,Darker@Darker@Green,Dashing[0.02]},{Thick,Darker@Cyan,Dashing[0.02]},{Thick,Magenta,Dashing[0.02]},{Thick,Black,Dashing[0.02]}};*) +(*plotstylelist=Flatten[Table[ConstantArray[ColorsForPlot[[i]],If[MatrixQ[SensitivitiesForPlotBaseline[[i]]],1,Length@SensitivitiesForPlotBaseline[[i]]]],{i,1,Length[SensitivitiesForPlotBaseline],1}],1];*) +(*PlotSensitivityDP=Show[PlotConstraintsTemp[LLPdirName],ListLogLogPlot[Cases[SensitivitiesForPlotBaseline,_?MatrixQ,All],Joined->True,PlotStyle->plotstylelist],Plot[{1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},{x,0,1},PlotStyle->DeleteDuplicates[plotstylelist],PlotLegends->Placed[Style[#,15]&/@LegendsForPlot,(*{0.24,0.14}*)Right]]]*) +(*Export[FileNameJoin[{dirplots,"Sensitivity_"<>LLPdirName<>".pdf"}],PlotSensitivityDP]*) + + +(* ::Section::Closed:: *) +(*Plot - bremsstrahlung uncertainties (for dedicated experiments)*) + + +(* ::Input:: *) +(*counterval=1;*) +(*sensitivityExperiment//Clear;*) +(*Print["Selected experiment:"]*) +(*GivenExperiment=listSensitivities[[counterval]][[1]]*) +(*sensData=SensitivitiesForPlotTemp[[counterval]];*) +(*Print["Available bremsstrahlung descriptions:"]*) +(*bremVariants=sensData[[All,3]]*) +(*Do[*) +(*sensitivityExperiment[sensData[[i]][[3]]]=sensData[[i]][[-1]]*) +(*,{i,1,Length[sensData],1}]*) +(*sensitivitiesGivenExperiment=sensitivityExperiment[#]&/@bremVariants;*) +(*BremDescriptionUncertainty="AP";*) +(*ColorsBrem["Baseline"]={Thick,Darker@Red};*) +(*{lower,central,upper}=(BremDescriptionUncertainty<>"-"<>#)&/@{"Lower","Central","Upper"};*) +(*ColorsBrem[central]={Thick,Blue};*) +(*ColorsBrem[lower]={Thick,Blue,Dashing[0.01]};*) +(*ColorsBrem[upper]={Thick,Blue,Dashing[0.01]};*) +(*(*Do[*) +(*PlotSens[bremvariant]=ListLogLogPlot[Cases[sensitivityExperiment[bremvariant],_?MatrixQ,All],Joined->True,PlotStyle->ColorsBrem[bremvariant]]*) +(*,{bremvariant,bremVariants}*) +(*]*)*) +(*PlotUncertainty[sensitivityExperiment_]:=Block[{},*) +(*Do[LenRegions[u]=Length[sensitivityExperiment[u]],{u,{upper,lower}}];*) +(*SensitivitiesToPlot=Join[Table[sensitivityExperiment[upper][[i]],{i,1,LenRegions[upper]}],Table[sensitivityExperiment[lower][[i]],{i,1,LenRegions[lower]}]];*) +(*FillingDirective=Join[Table[i->{True,Directive[Blue,Opacity[0.1]]},{i,1,LenRegions[upper],1}],Table[i+LenRegions[upper]->{True,Directive[White]},{i,1,LenRegions[lower],1}]];*) +(*ColorsDirective=Join[Table[ColorsBrem[upper],LenRegions[upper]],Table[ColorsBrem[lower],LenRegions[lower]]];*) +(*plot1=ListLogLogPlot[Evaluate[SensitivitiesToPlot],Joined->True,Filling->FillingDirective,PlotStyle->ColorsDirective,Frame->True,PlotRange->PlotRangeDomain,FrameStyle->Directive[Black, 23],ImageSize->Large,FrameLabel->{"\!\(\*SubscriptBox[\(m\), \(V\)]\) [GeV]" , "\!\(\*SubscriptBox[\(\[Alpha]\), \(B\)]\)"},PlotLabel->Style[Row[{GivenExperiment}],18,Black]];*) +(*If[LLPdirName=="B-L",*) +(*plot2=PlotConstraintsTemp[GivenExperiment];*) +(*pt3=Show[plot1,plot2]*) +(*,*) +(*plot1*) +(*]*) +(*]*) +(*plotstylelist=Flatten[Table[ConstantArray[ColorsBrem[bremVariants[[i]]],If[MatrixQ[sensitivitiesGivenExperiment[[i]]],1,Length@sensitivitiesGivenExperiment[[i]]]],{i,1,Length[sensitivitiesGivenExperiment],1}],1];*) +(*(*For filling the uncertainty band*)*) +(*PlotSensitivityDP=Show[PlotUncertainty[sensitivityExperiment],ListLogLogPlot[Cases[sensitivitiesGivenExperiment,_?MatrixQ,All],Joined->True,PlotStyle->plotstylelist](*,plotUncertainty*)(*,Plot[{1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},{x,0,1},PlotStyle->DeleteDuplicates[plotstylelist],PlotLegends\[Rule]Placed[Style[#,15]&/@LegendsForPlot,(*{0.24,0.14}*)Right]]*)]*) +(**) + + +(* ::Title::Closed:: *) +(*Deleting generated cells*) + + +(* ::Input:: *) +(*FrontEndTokenExecute["DeleteGeneratedCells"];*) +(*FrontEndTokenExecute["SelectAll"];*) +(*FrontEndTokenExecute["SelectionCloseAllGroups"];*)