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.

232 lines
19 KiB

  1. from compareUltimateSelection 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. if '__main__' == __name__:
  8. print ""
  9. parser = ShowArgumentsParser(
  10. formatter_class=argparse.RawDescriptionHelpFormatter,
  11. prog=os.path.basename(sys.argv[0]),
  12. description=("""Do the comparison for:
  13. For a full list of arguments, do: 'python {0} -h'
  14. """).format(os.path.basename(sys.argv[0]))
  15. )
  16. ## add the arguments
  17. parser.add_argument("-v", "--verbose", action="store_true",help="increase output verbosity")
  18. parser.add_argument("-DataMC", "--DataMC", action="store_true",help="DataMC")
  19. parser.add_argument("-MCMC", "--MCMC", action="store_true",help="MCMC")
  20. parser.add_argument("-TwoVars", "--TwoVars", action="store_true",help="TwoVars")
  21. parser.add_argument("-DataData", "--DataData", action="store_true",help="DataData")
  22. parser.add_argument("-muIP", "--muIP", action="store_true",help="muIP")
  23. parser.add_argument("-basic", "--basic", action="store_true",help="Set all parameters for comparison")
  24. parser.add_argument("-all", "--all", action="store_true",help="Run over all variables")
  25. parser.add_argument("-AllKshort", "--AllKshort", action="store_true",help="AllKshort")
  26. parser.add_argument("-AllKplus", "--AllKplus", action="store_true",help="AllKplus")
  27. parser.add_argument('-particle', metavar='<particle>', default = -1, type = int,
  28. help="Sets which particle plots should be produced, default: all")
  29. #add parameters
  30. parser.add_argument('-variable', metavar='<variable>', default = "", type = str, help="Sets the variable to be compared")
  31. parser.add_argument('-variable2', metavar='<variable2>', default = "", type = str, help="Sets the second variable to be compared")
  32. parser.add_argument('-cut', metavar='<cut>', default = "", type = str, help="Sets the cut for the variable")
  33. parser.add_argument('-cut2', metavar='<cut2>', default = "", type = str, help="Sets the cut for the second variable")
  34. parser.add_argument('-year', metavar='<year>', default = "2011", type = str, help="Sets the year")
  35. parser.add_argument('-year2', metavar='<year2>', default = "2012", type = str, help="Sets the second year")
  36. parser.add_argument('-polarity', metavar='<polarity>', default = "both", type = str, help="Sets the mode to be split by polarity, default merge Up and Down, options up, down")
  37. parser.add_argument('-polarity2', metavar='<polarity2>', default = "both", type = str, help="Sets the mode to be split by polarity2, default merge Up and Down, options up, down")
  38. #TODO add helps
  39. parser.add_argument("-Data", "--Data", action="store_true", default = False,help="Data")
  40. parser.add_argument("-Data2", "--Data2", action="store_true",default = False,help="Data2")
  41. parser.add_argument("-MC", "--MC", action="store_true",default = False,help="MC")
  42. parser.add_argument("-MC2", "--MC2", action="store_true",default = False,help="MC2")
  43. parser.add_argument("-TM", "--TM", action="store_true",default = False,help="TM")
  44. parser.add_argument("-TM2", "--TM2", action="store_true",default = False,help="TM2")
  45. parser.add_argument("-RefChan", "--RefChan", action="store_true",default = False,help="ReferenceChannel")
  46. parser.add_argument("-RefChan2", "--RefChan2", action="store_true",default = False,help="ReferenceChannel2")
  47. parser.add_argument("-PHSP", "--PHSP", action="store_true",default = False,help="PHSP")
  48. parser.add_argument("-PHSP2", "--PHSP2", action="store_true",default = False,help="PHSP2")
  49. parser.add_argument("-Presel", "--Presel", action="store_true",default = False,help="Preselected")
  50. parser.add_argument("-Presel2", "--Presel2", action="store_true",default = False,help="Preselected2")
  51. parser.add_argument("-BDTed", "--BDTed", action="store_true",default = False,help="BDTed")
  52. parser.add_argument("-BDTed2", "--BDTed2", action="store_true",default = False,help="BDTed2")
  53. parser.add_argument("-sWeighted", "--sWeighted", action="store_true",default = False,help="sWeighted")
  54. parser.add_argument("-sWeighted2", "--sWeighted2", action="store_true",default = False,help="sWeighted2")
  55. parser.add_argument("-bWeighted", "--bWeighted", action="store_true",default = False,help="bWeighted")
  56. parser.add_argument("-bWeighted2", "--bWeighted2", action="store_true",default = False,help="bWeighted2")
  57. parser.add_argument("-b2Dweighted", "--b2Dweighted", action="store_true",default = False,help="b2Dweighted")
  58. parser.add_argument("-b2Dweighted2", "--b2Dweighted2", action="store_true",default = False,help="b2Dweighted2")
  59. parser.add_argument("-KshortDecaysInVelo", "--KshortDecaysInVelo", action="store_true",default = False,help="KshortDecaysInVelo")
  60. parser.add_argument("-KshortDecaysInVelo2", "--KshortDecaysInVelo2", action="store_true",default = False,help="KshortDecaysInVelo2")
  61. opts = parser.parse_args()
  62. if (opts.verbose): print "[DEBUG]\t",opts
  63. #get year/s
  64. year_list = []
  65. if (opts.year == "All"):
  66. year_list = yearList()
  67. else: year_list = re.split(",",opts.year)
  68. year_list2 = []
  69. if (opts.year == "All"):
  70. year_list2 = yearList()
  71. else: year_list2 = re.split(",",opts.year)
  72. for year in year_list:
  73. if (opts.basic):
  74. for year2 in year_list2:
  75. if (opts.all):
  76. for var in ListOfAllVars():
  77. compareUltimate( variable1 = var, variable2 = var,
  78. year1 = int(year), year2 = int(year2), cut1 = opts.cut, cut2 = opts.cut2,
  79. magnet1 = opts.polarity, MC1 = opts.MC, TM1 = opts.TM, ReferenceChannel1 = opts.RefChan, PHSP1 = opts.PHSP, Preselected1 = opts.Presel, BDTed1 = opts.BDTed,
  80. magnet2 = opts.polarity2, MC2 = opts.MC2, TM2 = opts.TM2, ReferenceChannel2 = opts.RefChan2, PHSP2 = opts.PHSP2, Preselected2 = opts.Presel2, BDTed2 = opts.BDTed2,
  81. sWeighted1 = opts.sWeighted, bWeighted1=opts.bWeighted, b2Dweighted1=opts.b2Dweighted, weightBranch1 = firstMCweight(),
  82. sWeighted2 = opts.sWeighted2, bWeighted2=opts.bWeighted2, b2Dweighted2=opts.b2Dweighted2, weightBranch2 = firstMCweight(),
  83. bPrint = False, KshortDecaysInVelo1 = opts.KshortDecaysInVelo, KshortDecaysInVelo2 = opts.KshortDecaysInVelo2, verbose = opts.verbose)
  84. else:
  85. compareUltimate( variable1 = opts.variable, variable2 = opts.variable2,
  86. year1 = int(year), year2 = int(year2), cut1 = opts.cut, cut2 = opts.cut2,
  87. magnet1 = opts.polarity, MC1 = opts.MC, TM1 = opts.TM, ReferenceChannel1 = opts.RefChan, PHSP1 = opts.PHSP, Preselected1 = opts.Presel, BDTed1 = opts.BDTed,
  88. magnet2 = opts.polarity2, MC2 = opts.MC2, TM2 = opts.TM2, ReferenceChannel2 = opts.RefChan2, PHSP2 = opts.PHSP2, Preselected2 = opts.Presel2, BDTed2 = opts.BDTed2,
  89. sWeighted1 = opts.sWeighted, bWeighted1=opts.bWeighted, b2Dweighted1=opts.b2Dweighted, weightBranch1 = firstMCweight(),
  90. sWeighted2 = opts.sWeighted2, bWeighted2=opts.bWeighted2, b2Dweighted2=opts.b2Dweighted2, weightBranch2 = firstMCweight(),
  91. bPrint = False, KshortDecaysInVelo1 = opts.KshortDecaysInVelo, KshortDecaysInVelo2 = opts.KshortDecaysInVelo2, verbose = opts.verbose)
  92. if (opts.muIP):
  93. if (opts.Data):
  94. compareUltimateBchargeAllSamplesTwoVars("log(mu_plus_IPCHI2_OWNPV)", "log(mu_minus_IPCHI2_OWNPV)",
  95. year = int(year), magnet = opts.polarity, MC =False, ReferenceChannel=False, PHSP= False, Preselected=True, BDTed=False,
  96. sWeighted=opts.sWeighted, bWeighted=False, b2Dweighted=False, KshortDecaysInVelo=False, verbose =opts.verbose)
  97. compareUltimateBchargeAllSamplesTwoVars("log(mu_minus_IPCHI2_OWNPV)", "log(mu_plus_IPCHI2_OWNPV)",
  98. year = int(year), magnet = opts.polarity, MC =False, ReferenceChannel=False, PHSP= False, Preselected=True, BDTed=False,
  99. sWeighted=opts.sWeighted, bWeighted=False, b2Dweighted=False, KshortDecaysInVelo=False, verbose =opts.verbose)
  100. compareUltimateBchargeAllSamplesTwoVars("log(mu_plus_IPCHI2_OWNPV)", "log(mu_plus_IPCHI2_OWNPV)",
  101. year = int(year), magnet = opts.polarity, MC =False, ReferenceChannel=False, PHSP= False, Preselected=True, BDTed=False,
  102. sWeighted=opts.sWeighted, bWeighted=False, b2Dweighted=False, KshortDecaysInVelo=False, verbose =opts.verbose)
  103. compareUltimateBchargeAllSamplesTwoVars("log(mu_minus_IPCHI2_OWNPV)", "log(mu_minus_IPCHI2_OWNPV)",
  104. year = int(year), magnet = opts.polarity, MC =False, ReferenceChannel=False, PHSP= False, Preselected=True, BDTed=False,
  105. sWeighted=opts.sWeighted, bWeighted=False, b2Dweighted=False, KshortDecaysInVelo=False, verbose =opts.verbose)
  106. compareUltimateTwoVarsData("log(mu_minus_IPCHI2_OWNPV)", "log(mu_minus_IPCHI2_OWNPV)", year= int(year), magnet = opts.polarity,
  107. cut1 = "Polarity=65535", cut2 = "Polarity=1", Preselected= True, BDTed = False, sWeighted = opts.sWeighted, KshortDecaysInVelo = False, verbose = opts.verbose)
  108. compareUltimateTwoVarsData("log(mu_plus_IPCHI2_OWNPV)", "log(mu_plus_IPCHI2_OWNPV)", year= int(year), magnet = opts.polarity,
  109. cut1 = "Polarity=65535", cut2 = "Polarity=1", Preselected= True, BDTed = False, sWeighted = opts.sWeighted, KshortDecaysInVelo = False, verbose = opts.verbose)
  110. if (opts.MC):
  111. compareUltimateBchargeAllSamplesTwoVars("log(mu_plus_IPCHI2_OWNPV)", "log(mu_minus_IPCHI2_OWNPV)",
  112. year = int(year), magnet = opts.polarity, MC =True, ReferenceChannel=opts.RefChan, PHSP= opts.PHSP, Preselected=opts.Presel, BDTed=False,
  113. sWeighted=False, bWeighted=opts.bWeighted, b2Dweighted=opts.b2Dweighted, KshortDecaysInVelo=False, verbose =opts.verbose)
  114. compareUltimateBchargeAllSamplesTwoVars("log(mu_plus_IPCHI2_OWNPV)", "log(mu_plus_IPCHI2_OWNPV)",
  115. year = int(year), magnet = opts.polarity, MC =True, ReferenceChannel=opts.RefChan, PHSP= opts.PHSP, Preselected=opts.Presel, BDTed=False,
  116. sWeighted=False, bWeighted=opts.bWeighted, b2Dweighted=opts.b2Dweighted, KshortDecaysInVelo=False, verbose =opts.verbose)
  117. compareUltimateBchargeAllSamplesTwoVars("log(mu_minus_IPCHI2_OWNPV)", "log(mu_minus_IPCHI2_OWNPV)",
  118. year = int(year), magnet = opts.polarity, MC =True, ReferenceChannel=opts.RefChan, PHSP= opts.PHSP, Preselected=opts.Presel, BDTed=False,
  119. sWeighted=False, bWeighted=opts.bWeighted, b2Dweighted=opts.b2Dweighted, KshortDecaysInVelo=False, verbose =opts.verbose)
  120. compareUltimateTwoVarsMC("log(mu_minus_IPCHI2_OWNPV)", "log(mu_minus_IPCHI2_OWNPV)",year= int(year), magnet = opts.polarity,
  121. cut1 = "Polarity=65535", cut2 = "Polarity=1", TM=opts.TM, ReferenceChannel = opts.RefChan, PHSP = opts.PHSP,
  122. Preselected= opts.Presel, BDTed = opts.BDTed, bWeighted = opts.bWeighted, b2Dweighted = opts.b2Dweighted,
  123. KshortDecaysInVelo = opts.KshortDecaysInVelo, verbose = opts.verbose)
  124. compareUltimateTwoVarsMC("log(mu_plus_IPCHI2_OWNPV)", "log(mu_plus_IPCHI2_OWNPV)",year= int(year), magnet = opts.polarity,
  125. cut1 = "Polarity=65535", cut2 = "Polarity=1", TM=opts.TM, ReferenceChannel = opts.RefChan, PHSP = opts.PHSP,
  126. Preselected= opts.Presel, BDTed = opts.BDTed, bWeighted = opts.bWeighted, b2Dweighted = opts.b2Dweighted,
  127. KshortDecaysInVelo = opts.KshortDecaysInVelo, verbose = opts.verbose)
  128. if (opts.DataMC):
  129. compareUltimateDataMC(variable = "log(mu_plus_IPCHI2_OWNPV)", year =int(year), cut="", magnet=opts.polarity,
  130. TM = opts.TM, ReferenceChannel = opts.RefChan, PHSP = opts.PHSP,
  131. sWeighted = opts.sWeighted, bWeighted = opts.bWeighted, b2Dweighted = opts.b2Dweighted,
  132. KshortDecaysInVelo = opts.KshortDecaysInVelo, verbose = opts.verbose)
  133. compareUltimateDataMC(variable = "log(mu_minus_IPCHI2_OWNPV)", year =int(year), cut="", magnet=opts.polarity,
  134. TM = opts.TM, ReferenceChannel = opts.RefChan, PHSP = opts.PHSP,
  135. sWeighted = opts.sWeighted, bWeighted = opts.bWeighted, b2Dweighted = opts.b2Dweighted,
  136. KshortDecaysInVelo = opts.KshortDecaysInVelo, verbose = opts.verbose)
  137. compareUltimateDataMC(variable = "log(mu_plus_IPCHI2_OWNPV)", year =int(year), cut="B_plus_ID = 521", magnet=opts.polarity,
  138. TM = opts.TM, ReferenceChannel = opts.RefChan, PHSP = opts.PHSP,
  139. sWeighted = opts.sWeighted, bWeighted = opts.bWeighted, b2Dweighted = opts.b2Dweighted,
  140. KshortDecaysInVelo = opts.KshortDecaysInVelo, verbose = opts.verbose)
  141. compareUltimateDataMC(variable = "log(mu_minus_IPCHI2_OWNPV)", year =int(year), cut="B_plus_ID = 521", magnet=opts.polarity,
  142. TM = opts.TM, ReferenceChannel = opts.RefChan, PHSP = opts.PHSP,
  143. sWeighted = opts.sWeighted, bWeighted = opts.bWeighted, b2Dweighted = opts.b2Dweighted,
  144. KshortDecaysInVelo = opts.KshortDecaysInVelo, verbose = opts.verbose)
  145. compareUltimateDataMC(variable = "log(mu_plus_IPCHI2_OWNPV)", year =int(year), cut="B_plus_ID = -521", magnet=opts.polarity,
  146. TM = opts.TM, ReferenceChannel = opts.RefChan, PHSP = opts.PHSP,
  147. sWeighted = opts.sWeighted, bWeighted = opts.bWeighted, b2Dweighted = opts.b2Dweighted,
  148. KshortDecaysInVelo = opts.KshortDecaysInVelo, verbose = opts.verbose)
  149. compareUltimateDataMC(variable = "log(mu_minus_IPCHI2_OWNPV)", year =int(year), cut="B_plus_ID = -521", magnet=opts.polarity,
  150. TM = opts.TM, ReferenceChannel = opts.RefChan, PHSP = opts.PHSP,
  151. sWeighted = opts.sWeighted, bWeighted = opts.bWeighted, b2Dweighted = opts.b2Dweighted,
  152. KshortDecaysInVelo = opts.KshortDecaysInVelo, verbose = opts.verbose)
  153. compareUltimateDataMC(variable = "log(mu_plus_IPCHI2_OWNPV)", year =int(year), cut="B_plus_ID = 521", magnet=opts.polarity,
  154. TM = opts.TM, ReferenceChannel = opts.RefChan, PHSP = opts.PHSP,
  155. sWeighted = opts.sWeighted, bWeighted = opts.bWeighted, b2Dweighted = opts.b2Dweighted,
  156. KshortDecaysInVelo = opts.KshortDecaysInVelo, verbose = opts.verbose)
  157. compareUltimateDataMC(variable = "log(mu_minus_IPCHI2_OWNPV)", year =int(year), cut="B_plus_ID = -521", magnet=opts.polarity,
  158. TM = opts.TM, ReferenceChannel = opts.RefChan, PHSP = opts.PHSP,
  159. sWeighted = opts.sWeighted, bWeighted = opts.bWeighted, b2Dweighted = opts.b2Dweighted,
  160. KshortDecaysInVelo = opts.KshortDecaysInVelo, verbose = opts.verbose)
  161. compareUltimateDataMC(variable = "log(mu_plus_IPCHI2_OWNPV)", year =int(year), cut="B_plus_ID = -521", magnet=opts.polarity,
  162. TM = opts.TM, ReferenceChannel = opts.RefChan, PHSP = opts.PHSP,
  163. sWeighted = opts.sWeighted, bWeighted = opts.bWeighted, b2Dweighted = opts.b2Dweighted,
  164. KshortDecaysInVelo = opts.KshortDecaysInVelo, verbose = opts.verbose)
  165. compareUltimateDataMC(variable = "log(mu_minus_IPCHI2_OWNPV)", year =int(year), cut="B_plus_ID = +521", magnet=opts.polarity,
  166. TM = opts.TM, ReferenceChannel = opts.RefChan, PHSP = opts.PHSP,
  167. sWeighted = opts.sWeighted, bWeighted = opts.bWeighted, b2Dweighted = opts.b2Dweighted,
  168. KshortDecaysInVelo = opts.KshortDecaysInVelo, verbose = opts.verbose)
  169. else:
  170. if (opts.DataMC):
  171. if (opts.all):
  172. for var in ListOfAllVars():
  173. compareUltimateDataMC(variable = var, year =int(year), cut=opts.cut, magnet=opts.polarity,
  174. TM = opts.TM, ReferenceChannel = opts.RefChan, PHSP = opts.PHSP,
  175. sWeighted = opts.sWeighted, bWeighted = opts.bWeighted, b2Dweighted = opts.b2Dweighted,
  176. KshortDecaysInVelo = opts.KshortDecaysInVelo, verbose = opts.verbose)
  177. else:
  178. compareUltimateDataMC(variable = opts.variable, year =int(year), cut=opts.cut, magnet=opts.polarity,
  179. TM = opts.TM, ReferenceChannel = opts.RefChan, PHSP = opts.PHSP,
  180. sWeighted = opts.sWeighted, bWeighted = opts.bWeighted, b2Dweighted = opts.b2Dweighted,
  181. KshortDecaysInVelo = opts.KshortDecaysInVelo, verbose = opts.verbose)
  182. if (opts.MCMC):
  183. for year2 in year_list2:
  184. compareUltimateMCMC(variable = opts.variable, year1 = int(year) , year2 = int(year2) , cut1 = opts.cut, cut2 = opts.cut2, magnet1 = opts.polarity, magnet2 = opts.polarity2,
  185. TM = opts.TM, ReferenceChannel = opts.RefChan, PHSP = opts.PHSP, KshortDecaysInVelo = opts.KshortDecaysInVelo, verbose = opts.verbose)
  186. if (opts.DataData):
  187. for year2 in year_list2:
  188. compareUltimateDataData(variable = opts.variable, year1 = int(year) , year2 = int(year2), cut1 = opts.cut, cut2 = opts.cut2, magnet1 = opts.polarity, magnet2 = opts.polarity2,
  189. sWeighted1 = opts.sWeighted, sWeighted2 = opts.sWeighted2,
  190. KshortDecaysInVelo1 = opts.KshortDecaysInVelo, KshortDecaysInVelo2 = opts.KshortDecaysInVelo2, verbose = opts.verbose)
  191. if (opts.TwoVars):
  192. if (opts.Data):
  193. compareUltimateTwoVarsData(variable1 = opts.variable, variable2 = opts.variable2,
  194. year =int(year) , cut1 = opts.cut, cut2 = opts.cut2, magnet = opts.polarity, Preselected=opts.Presel, BDTed = opts.BDTed,
  195. sWeighted = opts.sWeighted, KshortDecaysInVelo = opts.KshortDecaysInVelo, verbose = opts.verbose)
  196. if (opts.MC):
  197. compareUltimateTwoVarsMC(variable1 = opts.variable, variable2 = opts.variable2,
  198. year =int(year) , cut1 = opts.cut, cut2 = opts.cut2, magnet = opts.polarity,
  199. TM = opts.TM, ReferenceChannel = opts.RefChan, PHSP = opts.PHSP, Preselected=opts.Presel, BDTed = opts.BDTed,
  200. bWeighted1 = opts.bWeighted, b2Dweighted1 = opts.b2Dweighted, bWeighted2 = opts.bWeighted2, b2Dweighted2 = opts.b2Dweighted2,
  201. KshortDecaysInVelo2 = opts.KshortDecaysInVelo, verbose = opts.verbose)