Angular analysis of B+->K*+(K+pi0)mumu
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

174 lines
19 KiB

  1. from compareUltimateSource import *
  2. '''
  3. Tool for comparing two variables from two datasets.
  4. Yes, writting it in Python3 would be smarter,
  5. but default is Python2 on all servers so far
  6. '''
  7. def compareUltimateAllPolarities(variable1, variable2,
  8. year1, year2, cut1, cut2 ,
  9. MC1, TM1, ReferenceChannel1, PHSP1, Preselected1, BDTed1,
  10. MC2, TM2, ReferenceChannel2, PHSP2, Preselected2, BDTed2,
  11. sWeighted1, bWeighted1, b2Dweighted1,
  12. sWeighted2, bWeighted2, b2Dweighted2,
  13. bPrint, KshortDecaysInVelo1, KshortDecaysInVelo2, verbose):
  14. for magnet in polarityList():
  15. compareUltimate(variable1 = variable1, variable2 = variable2,
  16. year1 = year1, year2 = year2, cut1 = cut1, cut2 = cut2,
  17. magnet1 = magnet, MC1 = MC1, TM1 = TM1, ReferenceChannel1 = ReferenceChannel1, PHSP1 = PHSP1, Preselected1 = Preselected1, BDTed1 = BDTed1,
  18. magnet2 = magnet, MC2 = MC2, TM2 = TM2, ReferenceChannel2 = ReferenceChannel2, PHSP2 = PHSP2, Preselected2 = Preselected2, BDTed2 = BDTed2,
  19. sWeighted1 = sWeighted1, bWeighted1 = bWeighted1, b2Dweighted1 = b2Dweighted1, weightBranch1 = firstMCweight(),
  20. sWeighted2 = sWeighted2, bWeighted2 = bWeighted2, b2Dweighted2 = b2Dweighted2, weightBranch2 = firstMCweight(),
  21. bPrint = bPrint, KshortDecaysInVelo1 = KshortDecaysInVelo1, KshortDecaysInVelo2 = KshortDecaysInVelo2, verbose = verbose)
  22. def compareUltimateAllPolAndYears( variable1, variable2,
  23. cut1, cut2 ,
  24. MC1, TM1, ReferenceChannel1, PHSP1, Preselected1, BDTed1,
  25. MC2, TM2, ReferenceChannel2, PHSP2, Preselected2, BDTed2,
  26. sWeighted1, bWeighted1, b2Dweighted1,
  27. sWeighted2, bWeighted2, b2Dweighted2,
  28. bPrint, KshortDecaysInVelo1, KshortDecaysInVelo2, verbose):
  29. for year in polarityList():
  30. compareUltimateAllPolarities(variable1 = variable1, variable2 = variable2,
  31. year1 = year, year2 = year, cut1 = cut1, cut2 = cut2,
  32. magnet1 = magnet, MC1 = MC1, TM1 = TM1, ReferenceChannel1 = ReferenceChannel1, PHSP1 = PHSP1, Preselected1 = Preselected1, BDTed1 = BDTed1,
  33. magnet2 = magnet, MC2 = MC2, TM2 = TM2, ReferenceChannel2 = ReferenceChannel2, PHSP2 = PHSP2, Preselected2 = Preselected2, BDTed2 = BDTed2,
  34. sWeighted1 = sWeighted1, bWeighted1 = bWeighted1, b2Dweighted1 = b2Dweighted1, weightBranch1 = firstMCweight(),
  35. sWeighted2 = sWeighted2, bWeighted2 = bWeighted2, b2Dweighted2 = b2Dweighted2, weightBranch2 = firstMCweight(),
  36. bPrint = bPrint, KshortDecaysInVelo1 = KshortDecaysInVelo1, KshortDecaysInVelo2 = KshortDecaysInVelo2, verbose = verbose)
  37. #Two samples, same variable
  38. def compareUltimateDataMC(variable, year, cut, magnet,
  39. TM = True, ReferenceChannel = False, PHSP = False,
  40. sWeighted = True, bWeighted = False, b2Dweighted = True, KshortDecaysInVelo = False, verbose = False):
  41. return compareUltimate(variable1 = variable, variable2 = variable,
  42. year1 = year, year2 = year, cut1 = cut, cut2 = cut,
  43. magnet1 = magnet, MC1 = False, TM1 = False, ReferenceChannel1 = False, PHSP1 = False, Preselected1 = True, BDTed1 = False,
  44. magnet2 = magnet, MC2 = True, TM2 = TM, ReferenceChannel2 = ReferenceChannel, PHSP2 = PHSP, Preselected2 = True, BDTed2 = False,
  45. sWeighted1 = sWeighted, bWeighted1 = False , b2Dweighted1 = False, weightBranch1 = firstMCweight(),
  46. sWeighted2 = False, bWeighted2 = bWeighted, b2Dweighted2 = b2Dweighted, weightBranch2 = firstMCweight(),
  47. bPrint = False, KshortDecaysInVelo1 = KshortDecaysInVelo, KshortDecaysInVelo2 = KshortDecaysInVelo, verbose = verbose)
  48. #Two MC versions, same variable
  49. def compareUltimateMCMC(variable, year1, year2, cut1, cut2, magnet1, magnet2,
  50. TM = True, ReferenceChannel = False, PHSP = False,
  51. bWeighted1 = False, b2Dweighted1 = False, bWeighted2 = False, b2Dweighted2 = False, KshortDecaysInVelo = False, verbose = False):
  52. return compareUltimate(variable1 = variable, variable2 = variable,
  53. year1 = year1, year2 = year2, cut1 = cut1, cut2 = cut2,
  54. magnet1 = magnet1, MC1 = True, TM1 = TM, ReferenceChannel1 = ReferenceChannel, PHSP1 = PHSP, Preselected1 = True, BDTed1 = False,
  55. magnet2 = magnet2, MC2 = True, TM2 = TM, ReferenceChannel2 = ReferenceChannel, PHSP2 = PHSP, Preselected2 = True, BDTed2 = False,
  56. sWeighted1 = False, bWeighted1 = bWeighted1, b2Dweighted1 = b2Dweighted1, weightBranch1 = firstMCweight(),
  57. sWeighted2 = False, bWeighted2 = bWeighted2, b2Dweighted2 = b2Dweighted2, weightBranch2 = firstMCweight(),
  58. bPrint = False, KshortDecaysInVelo1 = KshortDecaysInVelo, KshortDecaysInVelo2 = KshortDecaysInVelo, verbose = verbose)
  59. #Two data versions, same variable
  60. def compareUltimateDataData(variable, year1, year2, cut1, cut2, magnet1, magnet2, sWeighted1, sWeighted2, KshortDecaysInVelo1, KshortDecaysInVelo2, verbose):
  61. return compareUltimate(variable1 = variable, variable2 = variable,
  62. year1 = year1, year2 = year2, cut1 = cut1, cut2 = cut2,
  63. magnet1 = magnet1, MC1 = False, TM1 = False, ReferenceChannel1 = False, PHSP1 = False, Preselected1 = True, BDTed1 = False,
  64. magnet2 = magnet2, MC2 = True, TM2 = False, ReferenceChannel2 = False, PHSP2 = False, Preselected2 = True, BDTed2 = False,
  65. sWeighted1 = sWeighted1, bWeighted1 = False, b2Dweighted1 = False, weightBranch1 = firstMCweight(),
  66. sWeighted2 = sWeighted2, bWeighted2 = False, b2Dweighted2 = False, weightBranch2 = firstMCweight(),
  67. bPrint = False, KshortDecaysInVelo1 = KshortDecaysInVelo, KshortDecaysInVelo2 = KshortDecaysInVelo, verbose = verbose)
  68. #Two variables, same data sample, different cuts
  69. def compareUltimateTwoVars(variable1, variable2, year, cut1, cut2, magnet, MC, TM, ReferenceChannel, PHSP, Preselected, BDTed, sWeighted, bWeighted, b2Dweighted, KshortDecaysInVelo, verbose = False):
  70. return compareUltimate(variable1 = variable1, variable2 = variable2,
  71. year1 = year, year2 = year, cut1 = cut1, cut2 = cut2,
  72. magnet1 = magnet, MC1 = MC, TM1 = TM, ReferenceChannel1 = ReferenceChannel, PHSP1 = PHSP, Preselected1 = Preselected, BDTed1 = BDTed,
  73. magnet2 = magnet, MC2 = MC, TM2 = TM, ReferenceChannel2 = ReferenceChannel, PHSP2 = PHSP, Preselected2 = Preselected, BDTed2 = BDTed,
  74. sWeighted1 = sWeighted, bWeighted1 = bWeighted, b2Dweighted1 = b2Dweighted, weightBranch1 = firstMCweight(),
  75. sWeighted2 = sWeighted, bWeighted2 = bWeighted, b2Dweighted2 = b2Dweighted, weightBranch2 = firstMCweight(),
  76. bPrint = False, KshortDecaysInVelo1 = KshortDecaysInVelo, KshortDecaysInVelo2 = KshortDecaysInVelo, verbose = verbose)
  77. #Two variables, data sample, different cuts
  78. def compareUltimateTwoVarsData(variable1, variable2, year, cut1, cut2, magnet, Preselected, BDTed, sWeighted, KshortDecaysInVelo, verbose):
  79. return compareUltimateTwoVars(variable1=variable1, variable2=variable2, year=year, cut1=cut1,cut2=cut2, magnet=magnet, MC=False, TM=False, ReferenceChannel=False, PHSP=False, Preselected=Preselected, BDTed = BDTed, sWeighted=sWeighted, bWeighted=False, b2Dweighted=False, KshortDecaysInVelo=KshortDecaysInVelo, verbose = verbose)
  80. #Two variables, MC sample, different cuts
  81. def compareUltimateTwoVarsMC(variable1, variable2, year, cut1, cut2, magnet, TM, ReferenceChannel, PHSP, Preselected, BDTed, bWeighted, b2Dweighted, KshortDecaysInVelo, verbose):
  82. return compareUltimateTwoVars(variable1=variable1, variable2=variable2, year=year, cut1=cut1,cut2=cut2, magnet=magnet, MC=True, TM=TM, ReferenceChannel=ReferenceChannel, PHSP=PHSP, Preselected=Preselected, BDTed= BDTed, sWeighted=False, bWeighted=bWeighted, b2Dweighted=b2Dweighted, KshortDecaysInVelo=KshortDecaysInVelo, verbose = verbose)
  83. #One variable, same data sample, different cuts
  84. def compareUltimateTwoCuts(variable, year, magnet, cut1, cut2, MC, TM, ReferenceChannel, PHSP, Preselected, BDTed, sWeighted, bWeighted, b2Dweighted, KshortDecaysInVelo, verbose):
  85. return compareUltimate(variable1 = variable, variable2 = variable,
  86. year1 = year, year2 = year, cut1 = cut1, cut2 = cut2,
  87. magnet1 = magnet, MC1 = MC, TM1 = TM, ReferenceChannel1 = ReferenceChannel, PHSP1 = PHSP, Preselected1 = Preselected, BDTed1 = BDTed,
  88. magnet2 = magnet, MC2 = MC, TM2 = TM, ReferenceChannel2 = ReferenceChannel, PHSP2 = PHSP, Preselected2 = Preselected, BDTed2 = BDTed,
  89. sWeighted1 = sWeighted, bWeighted1 = bWeighted, b2Dweighted1 = b2Dweighted, weightBranch1 = firstMCweight(),
  90. sWeighted2 = sWeighted, bWeighted2 = bWeighted, b2Dweighted2 = b2Dweighted, weightBranch2 = firstMCweight(),
  91. bPrint = False, KshortDecaysInVelo1 = KshortDecaysInVelo, KshortDecaysInVelo2 = KshortDecaysInVelo, verbose = verbose)
  92. #One variable, data sample, different cuts
  93. def compareUltimateTwoCutsData(variable, year, magnet, cut1, cut2, Preselected, BDTed, sWeighted, KshortDecaysInVelo, verbose):
  94. return compareUltimateTwoCuts(variable=variable, year= year, magnet= magnet, cut1 = cut1, cut2 = cut2,MC=False, TM=False, ReferenceChannel = False, PHSP = False, Preselected= Preselected, BDTed = BDTed, sWeighted = sWeighted, bWeighted = False, b2Dweighted = False, KshortDecaysInVelo = KshortDecaysInVelo, verbose = verbose)
  95. #One variable, MC sample, different cuts
  96. def compareUltimateTwoCutsMC(variable, year, magnet, cut1, cut2, TM, ReferenceChannel, PHSP, Preselected, BDTed, bWeighted, b2Dweighted, KshortDecaysInVelo, verbose):
  97. return compareUltimateTwoCuts(variable=variable, year= year, magnet= magnet, cut1 = cut1, cut2 = cut2,MC=True, TM=TM, ReferenceChannel = ReferenceChannel, PHSP = False, Preselected= Preselected, BDTed = BDTed, sWeighted = False, bWeighted = bWeighted, b2Dweighted = b2Dweighted, KshortDecaysInVelo = KshortDecaysInVelo, verbose = verbose)
  98. def compareUltimateBchargeAllSamples(variable, year, magnet, MC, ReferenceChannel, PHSP, Preselected, BDTed, sWeighted, bWeighted, b2Dweighted, KshortDecaysInVelo, verbose):
  99. if (not MC):
  100. compareUltimateTwoCutsData(variable=variable, year= year, magnet= magnet, cut1 = "B_plus_ID = 521", cut2 = "B_plus_ID = -521", Preselected= Preselected, BDTed = BDTed, sWeighted = sWeighted, KshortDecaysInVelo = KshortDecaysInVelo, verbose = verbose)
  101. else:
  102. compareUltimateTwoCutsMC(variable=variable, year= year, magnet= magnet, cut1 = "B_plus_ID = 521", cut2 = "B_plus_ID = -521", TM=False, ReferenceChannel = ReferenceChannel, PHSP = PHSP, Preselected= Preselected, BDTed = BDTed, sWeighted = False, bWeighted = bWeighted, b2Dweighted = b2Dweighted, KshortDecaysInVelo = KshortDecaysInVelo, verbose = verbose)
  103. compareUltimateTwoCutsMC(variable=variable, year= year, magnet= magnet, cut1 = "B_plus_ID = 521", cut2 = "B_plus_ID = 521", TM=False, ReferenceChannel = ReferenceChannel, PHSP = PHSP, Preselected= Preselected, BDTed = BDTed, sWeighted = False, bWeighted = bWeighted, b2Dweighted = b2Dweighted, KshortDecaysInVelo = KshortDecaysInVelo, verbose = verbose)
  104. compareUltimateTwoCutsMC(variable=variable, year= year, magnet= magnet, cut1 = "B_plus_ID = -521", cut2 = "B_plus_ID = -521", TM=False, ReferenceChannel = ReferenceChannel, PHSP = PHSP, Preselected= Preselected, BDTed = BDTed, sWeighted = False, bWeighted = bWeighted, b2Dweighted = b2Dweighted, KshortDecaysInVelo = KshortDecaysInVelo, verbose = verbose)
  105. compareUltimateTwoCutsMC(variable=variable, year= year, magnet= magnet, cut1 = "B_plus_TRUEID = 521", cut2 = "B_plus_TRUEID = -521", TM=True, ReferenceChannel = ReferenceChannel, PHSP = PHSP, Preselected= Preselected, BDTed = BDTed, sWeighted = False, bWeighted = bWeighted, b2Dweighted = b2Dweighted, KshortDecaysInVelo = KshortDecaysInVelo, verbose = verbose)
  106. compareUltimateTwoCutsMC(variable=variable, year= year, magnet= magnet, cut1 = "B_plus_TRUEID = 521", cut2 = "B_plus_TRUEID = -521", TM=True, ReferenceChannel = ReferenceChannel, PHSP = PHSP, Preselected= Preselected, BDTed = BDTed, sWeighted = False, bWeighted = bWeighted, b2Dweighted = b2Dweighted, KshortDecaysInVelo = KshortDecaysInVelo, verbose = verbose)
  107. def compareUltimateBchargeAllSamplesTwoVars(variable1, variable2, year, magnet, MC, ReferenceChannel, PHSP, Preselected, BDTed, sWeighted, bWeighted, b2Dweighted, KshortDecaysInVelo, verbose):
  108. if (not MC):
  109. compareUltimateTwoVarsData(variable1=variable1, variable2=variable2, year= year, magnet= magnet, cut1 = "B_plus_ID = 521", cut2 = "B_plus_ID = -521", Preselected= Preselected, BDTed = BDTed, sWeighted = sWeighted, KshortDecaysInVelo = KshortDecaysInVelo, verbose = verbose)
  110. else:
  111. compareUltimateTwoVarsMC(variable1=variable1, variable2=variable2,year= year, magnet= magnet, cut1 = "B_plus_ID = 521", cut2 = "B_plus_ID = -521", TM=False, ReferenceChannel = ReferenceChannel, PHSP = PHSP, Preselected= Preselected, BDTed = BDTed, bWeighted = bWeighted, b2Dweighted = b2Dweighted, KshortDecaysInVelo = KshortDecaysInVelo, verbose = verbose)
  112. compareUltimateTwoVarsMC(variable1=variable1, variable2=variable2,year= year, magnet= magnet, cut1 = "B_plus_ID = -521", cut2 = "B_plus_ID = 521", TM=False, ReferenceChannel = ReferenceChannel, PHSP = PHSP, Preselected= Preselected, BDTed = BDTed, bWeighted = bWeighted, b2Dweighted = b2Dweighted, KshortDecaysInVelo = KshortDecaysInVelo, verbose = verbose)
  113. compareUltimateTwoVarsMC(variable1=variable1, variable2=variable2,year= year, magnet= magnet, cut1 = "B_plus_ID = 521", cut2 = "B_plus_ID = 521", TM=False, ReferenceChannel = ReferenceChannel, PHSP = PHSP, Preselected= Preselected, BDTed = BDTed, bWeighted = bWeighted, b2Dweighted = b2Dweighted, KshortDecaysInVelo = KshortDecaysInVelo, verbose = verbose)
  114. compareUltimateTwoVarsMC(variable1=variable1, variable2=variable2,year= year, magnet= magnet, cut1 = "B_plus_ID = -521", cut2 = "B_plus_ID = -521", TM=False, ReferenceChannel = ReferenceChannel, PHSP = PHSP, Preselected= Preselected, BDTed = BDTed, bWeighted = bWeighted, b2Dweighted = b2Dweighted, KshortDecaysInVelo = KshortDecaysInVelo, verbose = verbose)
  115. compareUltimateTwoVarsMC(variable1=variable1, variable2=variable2,year= year, magnet= magnet, cut1 = "B_plus_TRUEID = 521", cut2 = "B_plus_TRUEID = -521", TM=True, ReferenceChannel = ReferenceChannel, PHSP = PHSP, Preselected= Preselected, BDTed = BDTed, bWeighted = bWeighted, b2Dweighted = b2Dweighted, KshortDecaysInVelo = KshortDecaysInVelo, verbose = verbose)
  116. compareUltimateTwoVarsMC(variable1=variable1, variable2=variable2,year= year, magnet= magnet, cut1 = "B_plus_TRUEID = 521", cut2 = "B_plus_TRUEID = -521", TM=True, ReferenceChannel = ReferenceChannel, PHSP = PHSP, Preselected= Preselected, BDTed = BDTed, bWeighted = bWeighted, b2Dweighted = b2Dweighted, KshortDecaysInVelo = KshortDecaysInVelo, verbose = verbose)
  117. def compareUltimateBchargeAllPolarities(variable, year,MC, ReferenceChannel, PHSP, Preselected, BDTed, sWeighted, bWeighted, b2Dweighted, KshortDecaysInVelo, verbose):
  118. for pol in polarityList():
  119. compareUltimateBchargeAllSamples(variable=variable, year=year, magnet = pol,MC = MC, ReferenceChannel= ReferenceChannel, PHSP=PHSP, Preselected = Preselected, BDTed= BDTed, sWeighted=sWeighted, bWeighted=bWeighted, b2Dweighted=b2Dweighted, KshortDecaysInVelo=KshortDecaysInVelo, verbose=verbose)
  120. def compareUltimateBchargeAllYears(variable,MC, ReferenceChannel, PHSP, Preselected, BDTed, sWeighted, bWeighted, b2Dweighted, KshortDecaysInVelo, verbose):
  121. for year in yearList():
  122. compareUltimateBchargeAllPolarities(variable = variable, year = year, MC = MC,ReferenceChannel = ReferenceChannel, PHSP = PHSP, Preselected= Preselected, BDTed = BDTed, sWeighted = sWeighted, bWeighted= bWeighted, b2Dweighted = b2Dweighted,KshortDecaysInVelo =KshortDecaysInVelo, verbose= verbose)
  123. def compareUltimateMuonIPCHI2All(verbose): #TODO possibly change parameters such as preselected
  124. compareUltimateBchargeAllYears(variable = "log(mu_plus_IPCHI2_OWNPV)", MC = False, ReferenceChannel = False, PHSP = False, Preselected= True, BDTed = False, sWeighted = False, bWeighted= False, b2Dweighted = False,KshortDecaysInVelo =False, verbose= verbose)
  125. compareUltimateBchargeAllYears(variable = "log(mu_minus_IPCHI2_OWNPV)", MC = True, ReferenceChannel = False, PHSP = False, Preselected= True, BDTed = False, sWeighted = False, bWeighted= False, b2Dweighted = False,KshortDecaysInVelo =False, verbose= verbose)
  126. compareUltimateBchargeAllYears(variable = "log(mu_minus_IPCHI2_OWNPV)", MC = True, ReferenceChannel = True, PHSP = False, Preselected= True, BDTed = False, sWeighted = False, bWeighted= False, b2Dweighted = False,KshortDecaysInVelo =False, verbose= verbose)
  127. compareUltimateBchargeAllYears(variable = "log(mu_minus_IPCHI2_OWNPV)", MC = True, ReferenceChannel = False, PHSP = True, Preselected= True, BDTed = False, sWeighted = False, bWeighted= False, b2Dweighted = False,KshortDecaysInVelo =False, verbose= verbose)
  128. def compareUltimateBDTcut(variable, year, magnet, sWeighted, KshortDecaysInVelo, verbose):
  129. return compareUltimateTwoCuts(variable = variable, year =year, magnet =magnet, cut1 ="MLPresponse < 0.1", cut2 = "MLPresponse > 0.9", MC=False, TM=False, ReferenceChannel=False, PHSP=False, Preselected=True, BDTed=True, sWeighted = sWeighted, bWeighted=False, b2Dweighted=False, KshortDecaysInVelo=KshortDecaysInVelo, verbose=verbose)
  130. def compareUltimateAllKplusDataMC(year = 2011, magnet = "both", cut = "", ReferenceChannel = False, PHSP = False, bWeighted = False, b2Dweighted = True, whichParticle = 1, verbose = False):
  131. for var in ListOfKplusVars(whichParticle=whichParticle):
  132. compareUltimateDataMC(var, year, cut, magnet,
  133. TM = True, ReferenceChannel = ReferenceChannel, PHSP = PHSP,
  134. sWeighted = True, bWeighted = bWeighted, b2Dweighted = b2Dweighted, KshortDecaysInVelo = False, verbose = verbose)
  135. return 0 #TODO
  136. def compareUltimateAllKplusBDTcut(year = 2011, magnet = "both", whichParticle = 1, verbose = False):
  137. for var in ListOfKplusVars(whichParticle=whichParticle):
  138. compareUltimateBDTcut(var, year, year, magnet, magnet, KshortDecaysInVelo =False)
  139. return 0 #TODO