
import numpy as np

'''
Define variables used in compareUltimate
Python doesn't understand external parameters, 
so workaround is to make a function for them, because f*it
'''

import os

#Set whether Kshort decays in VELO
def KshortChannel():
    path = os.getcwd()
    #print path
    return "dgerick" in path

def UseLowQ2Range1():
    return False 
def UseLowQ2Range2():
    return  False 
def firstMCweight ():
    return "nLongTracks" 

def UseDTF(): 
    return True


def yearArray(): #Assign run to year
  return np.array([
    [2011,2012, 2015, 2016, 2017, 2018],
    [1, 1, 2, 2, 2, 2]
  ])     

def yearListFull():
  return yearArray()[0][:]

def yearListRun(Run):  
  if (Run ==12): return yearListFull()
  else:
    mask = yearArray()[1][:]==Run
    return yearArray()[0][mask]

def yearList(Run, MC,Reference,PHSP): #Too lazy to do Kshort option  
  if (PHSP or not MC): return yearListRun(Run)
  else:
    if (Reference):
      mask = yearListRun(Run)[:]<2017
    else: 
      mask = yearListRun(Run)[:]!=2015
  return yearListRun(Run)[mask]  

def yearRunArrayFull(Run):  
  if (Run ==12): return yearArray()
  else:
    mask = yearArray()[1][:]==Run
    return yearArray()[:,mask]

def yearRunArray(year, Run, MC,Reference,PHSP):
  if (Run == 0):
    mask =  yearRunArrayFull(12)[0][:]==year
    return yearRunArrayFull(12)[:,mask] 
  else:  
    if (PHSP or not MC): return yearRunArrayFull(Run)
    else:
      if (Reference):
        mask = yearRunArrayFull(Run)[0][:]<2017
      else: 
        mask = yearRunArrayFull(Run)[0][:]!=2015 
    return yearRunArrayFull(Run)[:,mask]     




def polarityList():
  return ["down","up","both"]


#Define a dictionary with nBins, Max and Min for each variable plot
def dictVarPlotLimitsInt():
    return {
                 "nSPDHits": [61,-0.5,600.5],
                 "nTracks": [60,-0.5,399.5],
                 "nLongTracks": [50,-0.5,139.5],
                 "nTTracks": [50,-0.5,139.5],
                 "nBackTracks": [50,-0.5,199.5],
                 "nMuonTracks": [50,-0.5,199.5],
                 "nVeloTracks": [50,-0.5,249.5],
                 "nDownstreamTracks": [50,-0.5,49.5],
                 "totCandidates": [10,-0.5,9.5],
                 "nCandidate": [10,-0.5,9.5],
                 "nUpstreamTracks": [50,-0.5,29.5]
    }


def dictPDGmass():
  return{
            "B_plus":5279.29,
             "K_star_plus":891.66,
             "K_plus":493.68,
             "K_short":497.61,
             "pi_plus":139.57,
             "pi_zero":134.98,
             "gamma":0,
             "J_psi":3096.90,
             "mu":105.66,
    }

def dictParticleIDs():
  return{
             "B_plus":521,
             "K_star_plus":323,
             "K_plus":321,
             "K_short":310,
             "pi_plus":211,
             "pi_zero_resolved":111,
             "gamma":22,
             "mu_minus":13,
             "J_psi":443
    } 

def dictVarPlotLimitsKshort (KshortDecaysInVelo = True):
    return {
                 "log(1-B_plus_DIRA_OWNPV)":      {"Min": -20.0,  "Max": -9.0},
                 "log(B_plus_OWNPV_CHI2)":        {"Min": 1.0,    "Max": 4.5},
                 "log(B_plus_IPCHI2_OWNPV)":      {"Min": -2.5,   "Max": 3.0},
                 "B_plus_ENDVERTEX_CHI2":         {"Min": 0.,     "Max": 40.},
                 "B_plus_FD_OWNPV":               {"Min": 0.,     "Max": 120.0},
                 "B_plus_PT_DTF":                 {"Min": 0.,     "Max": 40e3},
                 "B_plus_PT":                     {"Min": 0.,     "Max": 40e3},
                 "B_plus_DOCA1":                  {"Min": -0.1,   "Max": 25.1},
                 "B_plus_IP_OWNPV":               {"Min": 0.0,    "Max": 0.12},
                 "B_plus_NEW_ConePTasym":         {"Min": -1.001, "Max": 1.001},
                 "B_plus_NEW_ConePT":             {"Min": 0.,     "Max": 40e3},
                 "B_plus_NEW_ConePasym":          {"Min": -1.001, "Max": 1.001},
                 "B_plus_NEW_ConeP":              {"Min": 0.,     "Max": 60e3},
                 "B_plus_ETA_DTF":                {"Min": 2.,     "Max": 5.0},
                 "B_plus_ETA":                    {"Min": 2.,     "Max": 5.0},
                 "log(K_star_plus_IPCHI2_OWNPV)": {"Min": -5.0,   "Max": 10.0},
                 "K_star_plus_PT_DTF":            {"Min": 0.,     "Max": 20e3},
                 "K_star_plus_PT":                {"Min": 0.,     "Max": 20e3},
                 "K_star_plus_ETA_DTF":           {"Min": 2.,     "Max": 5.0},
                 "K_star_plus_ETA":               {"Min": 2.,     "Max": 5.0},
                 "K_short_PT_DTF":                {"Min": 0.,     "Max": 10e3},
                 "K_short_PT":                    {"Min": 0.,     "Max": 10e3},
                 "K_short_FD_OWNPV":              {"Min": 0.,     "Max": 700.0 if KshortDecaysInVelo else 2500.0},
                 "K_short_ETA":                   {"Min": 2.,     "Max": 5.0},
                 "K_star_plus_M":                 {"Min": 792.,   "Max": 992.},
                 "log(K_short_IPCHI2_OWNPV)":     {"Min": 0.0  if KshortDecaysInVelo else -5.0,
                                                   "Max": 10.0 if KshortDecaysInVelo else  5.0},
                 "Ks_pi_minus_PT_DTF":            {"Min": 0.,     "Max": 5e3},
                 "Ks_pi_minus_PT":                {"Min": 0.,     "Max": 5e3},
                 "Ks_pi_minus_PX_DTF":            {"Min": -2.5e3, "Max": 2.5e3},
                 "Ks_pi_minus_PX":                {"Min": -2.5e3, "Max": 2.5e3},
                 "Ks_pi_minus_PY_DTF":            {"Min": -2.5e3, "Max": 2.5e3},
                 "Ks_pi_minus_PY":                {"Min": -2.5e3, "Max": 2.5e3},
                 "Ks_pi_minus_PZ_DTF":            {"Min": 2e3,    "Max": 25e3},
                 "Ks_pi_minus_PZ":                {"Min": 2e3,    "Max": 25e3},
                 "Ks_pi_minus_PE_DTF":            {"Min": 2e3,    "Max": 25e3},
                 "Ks_pi_minus_PE":                {"Min": 2e3,    "Max": 25e3},
                 "Ks_pi_minus_P_DTF":             {"Min": 2e3,    "Max": 25e3},
                 "Ks_pi_minus_P":                 {"Min": 2e3,    "Max": 25e3},
                 "Ks_pi_minus_ETA_DTF":           {"Min": 2.,     "Max": 5.0},
                 "Ks_pi_minus_ETA":               {"Min": 2.,     "Max": 5.0},

                 "Ks_pi_plus_PT_DTF":             {"Min": 0.,     "Max": 5e3},
                 "Ks_pi_plus_PT":                 {"Min": 0.,     "Max": 5e3},
                 "Ks_pi_plus_PX_DTF":             {"Min": -2.5e3, "Max": 2.5e3},
                 "Ks_pi_plus_PX":                 {"Min": -2.5e3, "Max": 2.5e3},
                 "Ks_pi_plus_PY_DTF":             {"Min": -2.5e3, "Max": 2.5e3},
                 "Ks_pi_plus_PY":                 {"Min": -2.5e3, "Max": 2.5e3},
                 "Ks_pi_plus_PZ_DTF":             {"Min": 2e3,    "Max": 25e3},
                 "Ks_pi_plus_PZ":                 {"Min": 2e3,    "Max": 25e3},
                 "Ks_pi_plus_PE_DTF":             {"Min": 2e3,    "Max": 25e3},
                 "Ks_pi_plus_PE":                 {"Min": 2e3,    "Max": 25e3},
                 "Ks_pi_plus_P_DTF":              {"Min": 2e3,    "Max": 25e3},
                 "Ks_pi_plus_P":                  {"Min": 2e3,    "Max": 25e3},
                 "Ks_pi_plus_ETA_DTF":            {"Min": 2.,     "Max": 5.0},
                 "Ks_pi_plus_ETA":                {"Min": 2.,     "Max": 5.0},

                 "pi_plus_PT_DTF":                {"Min": 0.,     "Max": 12e3},
                 "pi_plus_PT":                    {"Min": 0.,     "Max": 12e3},
                 "pi_plus_PX_DTF":                {"Min": -2.5e3, "Max": 2.5e3},
                 "pi_plus_PX":                    {"Min": -2.5e3, "Max": 2.5e3},
                 "pi_plus_PY_DTF":                {"Min": -2.5e3, "Max": 2.5e3},
                 "pi_plus_PY":                    {"Min": -2.5e3, "Max": 2.5e3},
                 "pi_plus_PZ_DTF":                {"Min": 0.,     "Max": 30e3},
                 "pi_plus_PZ":                    {"Min": 0.,     "Max": 30e3},
                 "pi_plus_PE_DTF":                {"Min": 0.,     "Max": 30e3},
                 "pi_plus_PE":                    {"Min": 0.,     "Max": 30e3},
                 "pi_plus_P_DTF":                 {"Min": 0.,     "Max": 30e3},
                 "pi_plus_P":                     {"Min": 0.,     "Max": 30e3},
                 "pi_plus_ETA_DTF":               {"Min": 2.,     "Max": 5.0},
                 "pi_plus_ETA":                   {"Min": 2.,     "Max": 5.0},
                 "log(pi_plus_IPCHI2_OWNPV)":     {"Min": 1.0,    "Max": 10.0},

                 "mu_plus_PX_DTF":                {"Min": -6e3,   "Max": 6e3},
                 "mu_plus_PX":                    {"Min": -6e3,   "Max": 6e3},
                 "mu_plus_PY_DTF":                {"Min": -6e3,   "Max": 6e3},
                 "mu_plus_PY":                    {"Min": -6e3,   "Max": 6e3},
                 "mu_plus_PZ_DTF":                {"Min": 3e3,    "Max": 30e3},
                 "mu_plus_PZ":                    {"Min": 3e3,    "Max": 30e3},
                 "mu_plus_PT_DTF":                {"Min": 0.,     "Max": 10e3},
                 "mu_plus_PT":                    {"Min": 0.,     "Max": 10e3},
                 "mu_plus_PE_DTF":                {"Min": 3e3,    "Max": 30e3},
                 "mu_plus_PE":                    {"Min": 3e3,    "Max": 30e3},
                 "mu_plus_P_DTF":                 {"Min": 3e3,    "Max": 30e3},
                 "mu_plus_P":                     {"Min": 3e3,    "Max": 30e3},
                 "mu_plus_ETA_DTF":               {"Min": 2.,     "Max": 5.0},
                 "mu_plus_ETA":                   {"Min": 2.,     "Max": 5.0},
                 "log(mu_plus_IPCHI2_OWNPV)":     {"Min": 2.0,    "Max": 12.0},

                 "mu_minus_PX_DTF":               {"Min": -6e3,   "Max": 6e3},
                 "mu_minus_PX":                   {"Min": -6e3,   "Max": 6e3},
                 "mu_minus_PY_DTF":               {"Min": -6e3,   "Max": 6e3},
                 "mu_minus_PY":                   {"Min": -6e3,   "Max": 6e3},
                 "mu_minus_PZ_DTF":               {"Min": 3e3,    "Max": 30e3},
                 "mu_minus_PZ":                   {"Min": 3e3,    "Max": 30e3},
                 "mu_minus_PT_DTF":               {"Min": 0.,     "Max": 10e3},
                 "mu_minus_PT":                   {"Min": 0.,     "Max": 10e3},
                 "mu_minus_PE_DTF":               {"Min": 3e3,    "Max": 30e3},
                 "mu_minus_PE":                   {"Min": 3e3,    "Max": 30e3},
                 "mu_minus_P_DTF":                {"Min": 3e3,    "Max": 30e3},
                 "mu_minus_P":                    {"Min": 3e3,    "Max": 30e3},
                 "mu_minus_ETA_DTF":              {"Min": 2.,     "Max": 5.0},
                 "mu_minus_ETA":                  {"Min": 2.,     "Max": 5.0},
                 "log(mu_minus_IPCHI2_OWNPV)":    {"Min": 2.0,    "Max": 12.0},

                 "nCandidate":                    {"Min": 0,      "Max": 10},
                 "totCandidates":                 {"Min": 0,      "Max": 10},
                 "nTracks":                       {"Min": 0.,     "Max": 600.},
                 "nLongTracks":                   {"Min": 0.,     "Max": 200.},
                 "nVeloTracks":                   {"Min": 0.,     "Max": 200.},
                 "nTTracks":                      {"Min": 0.,     "Max": 200.},
                 "nUpstreamTracks":               {"Min": 0.,     "Max": 200.}


                }

def dictVarPlotLimitsKplus ():
    return {

                #Bplus
                 "log(1-B_plus_DIRA_OWNPV)": {"Min": -20.0},
                 "log(B_plus_OWNPV_CHI2)": {"Min": -1.0},
                 "B_plus_FD_OWNPV": {"Min": -1.0,"Max": 60.0},
                 "B_plus_ETA_DTF": {"Max": 5.0},
                 "B_plus_ETA": {"Max": 5.0},
                 "B_plus_PHI": {"Min":-3.15, "Max": 3.15},
                 "B_plus_PT_DTF": {"Max":30e3},
                 "B_plus_PT": {"Max": 30e3},
                 "B_plus_DOCA1": {"Min": -0.1, "Max": 19.9},
                 "log(B_plus_IPCHI2_OWNPV)": {"Min": -0.5, "Max": 3.0},
                 "B_plus_IP_OWNPV": {"Min": -0.01, "Max": 0.1},
                 "B_pls_NEW_ConePTasym": {"Min": -0.6, "Max": 1.001},
                 "B_plus_NEW_ConePT": {"Min": -0.6, "Max": 30e3},
                 "B_plus_NEW_ConeP": {"Min": -1.5, "Max": 300e3},
                 "B_plus_ConeDeltaETA": {"Min": -1.5, "Max": 6.0}, #TODO: change to NEW after new preselection
                 "B_plus_NEW_ConeDeltaETA": {"Min": -1.5,"Max": 6.0}, #TODO: change to NEW after new preselection                 
                 "B_plus_FDCHI2_OWNPV": {"Min": 100.0, "Max": 1e3},

                #K*
                 "K_star_plus_PT_DTF": {"Min": 1000.0,"Max": 10e3},
                 "K_star_plus_PT": {"Min": 1000.0,"Max": 10e3},
                 "K_star_plus_PHI": {"Min":-3.15, "Max": 3.15},
                 "K_star_plus_IP_OWNPV": {"Max": 10.0},
                 "K_star_plus_IPCHI2_OWNPV": {"Min": -10.0, "Max": 10.0},
                 "K_star_plus_FD_OWNPV": {"Max": 500.0},
                 "K_star_plus_FDCHI2_OWNPV": {"Min": 0.0, "Max": 60e3},
                 "K_star_plus_DIRA_OWNPV": {"Min": -12.5, "Max": 2.5},
                 "K_star_plus_ETA_DTF": {"Max": 5.0 },
                 "K_star_plus_ETA": {"Max": 5.0},

                 #K+
                 "K_plus_IPCHI2_OWNPV": {"Min": 1.0, "Max": 11.0},
                 "K_plus_IP_OWNPV": {"Max": 2.0},
                 "K_plus_MINIPCHI2": {"Min": -0.5, "Max": 2e3},
                 "K_plus_MINIP": {"Max": 2.0},
                 "K_plus_OWNPV_CHI2": {"Min": 0.5},
                 "K_plus_PT_DTF": {"Max": 9e3},
                 "K_plus_PT": {"Max": 9e3},
                 "K_star_PHI": {"Min":-3.15, "Max": 3.15},
                 "K_plus_ETA_DTF": {"Max": 5.0 },
                 "K_plus_ETA": {"Max": 5.0},

                 #pi0
                 "pi_zero_resolved_PT_DTF": {"Max": 4.2e3},
                 "pi_zero_resolved_PT": {"Max": 4.2e3},
                 "pi_zero_resolved_PHI": {"Min":-3.15, "Max": 3.15},
                 "pi_zero_resolved_ETA_DTF": {"Max": 5.0 },
                 "pi_zero_resolved_ETA": {"Max": 5.0},

                 #gammas
                 "gamma1_PT_DTF": {"Max": 8.0 },
                 "gamma1_PT": {"Max": 8.0},
                 "gamma1_PHI": {"Min":-3.15, "Max": 3.15},
                 "gamma2_PT_DTF": {"Max": 8.0 },
                 "gamma2_PT": {"Max": 8.0},
                 "gamma2_PHI": {"Min":-3.15, "Max": 3.15},

                 #Jpsi
                 "J_psi_DOCA1": {"Max": 0.2},
                 "J_psi_FD_OWNPV": {"Max": 35.0}  ,
                 "J_psi_FDCHI2_OWNPV": {"Max": 15e3},
                 "J_psi_IP_OWNPV": {"Max": 1.0},
                 "J_psi_DIRA_OWNPV": {"Min": -16.0, "Max": -4.0},
                 "J_psi_OWNPV_CHI2": {"Min": 0.9},
         
                 #mu+
                 "mu_plus_PT_DTF": {"Max": 10e3},
                 "mu_plus_PT": {"Max": 10e3},
                 "mu_plus_PHI": {"Min":-3.15, "Max": 3.15},
                 "mu_plus_OWNPV_CHI2": {"Min": 0.5},
                 "mu_plus_IP_OWNPV": {"Max": 4.0},

                 #mu-
                 "mu_minus_PT_DTF": {"Max": 10e3},
                 "mu_minus_PT": {"Max": 10e3},
                 "mu_minus_PHI": {"Min":-3.15, "Max": 3.15},
                 "mu_minus_OWNPV_CHI2": {"Min": 0.5},
                 "mu_minus_IP_OWNPV": {"Max": 4.0}
}



def ListOfKplusVars(whichParticle = -1): #TODO this can be so much improved
    #-1 add all vars,
    # 0: Global
    # anything else: MC numbering scheme
       
    list_tmp = []

    if (whichParticle == 1 or whichParticle == -1):
      list_tmp.extend([
            # "MLPresponse",    #TODO
             "B_plus_ThetaL",  
             "B_plus_ThetaK",  
             "B_plus_Phi"     
        ])
    if (whichParticle == 0 or whichParticle == -1): 
      list_tmp.extend([  
        "nTracks",
        "nLongTracks",
        "nVeloTracks",       
        "nTTracks",          
        "nUpstreamTracks",         
        "nDownstreamTracks",
        "nCandidate",
        "totCandidates",
        "Q2", #TODO
        "nSPDHits"   
        ])

      #B+
    if (whichParticle == 521 or whichParticle == -1):
      list_tmp.extend([      
       #"log(1-B_plus_DIRA_OWNPV)",
       #"log(B_plus_OWNPV_CHI2)",
       #"B_plus_FD_OWNPV",
       #"B_plus_FDCHI2_OWNPV",
       #"B_plus_IP_OWNPV",
       #"log(B_plus_IPCHI2_OWNPV)",
       #"B_plus_DOCA1", #TODO
       #"B_plus_NEW_ConePTasym", #TODO
       #"B_plus_NEW_ConePT",
       #"B_plus_NEW_ConeP",
       #"B_plus_NEW_ConeDeltaETA",
       #"B_plus_CONEDELTAPHI", #TODO
       "B_plus_M", 
       "B_plus_PHI",
       #"B_plus_ETA" #TODO
      ])
       
      # K*
    if (whichParticle == 323 or whichParticle == -1):
      list_tmp.extend([            
       "log(1-K_star_plus_DIRA_OWNPV)",
       "log(K_star_plus_OWNPV_CHI2)",
       "K_star_plus_FD_OWNPV",
       "K_star_plus_FDCHI2_OWNPV",
       "K_star_plus_IP_OWNPV",
       "log(K_star_plus_IPCHI2_OWNPV)",
       "K_star_plus_PT",
       "K_star_plus_PHI",
       "K_star_plus_ETA" #TODO
      ])
      # mu
    if (whichParticle == 13 or whichParticle == -1):
      list_tmp.extend([            
       "log(1-mu_plus_DIRA_OWNPV)", #TODO
       "log(mu_plus_OWNPV_CHI2)",   
       "mu_plus_FD_OWNPV", #TODO
       "mu_plus_FDCHI2_OWNPV",#TODO
       "mu_plus_IP_OWNPV",  
       "log(mu_plus_IPCHI2_OWNPV)",
       "mu_plus_PT", 
       "mu_plus_PHI", 
       "mu_plus_ETA", #TODO
       "log(1-mu_minus_DIRA_OWNPV)",      
       "log(mu_minus_OWNPV_CHI2)",     
       "mu_minus_FD_OWNPV",#TODO
       "mu_minus_FDCHI2_OWNPV",#TODO
       "mu_minus_IP_OWNPV",
       "log(mu_minus_IPCHI2_OWNPV)",
       "mu_minus_PT", 
       "mu_minus_PHI", 
       "mu_minus_ETA" #TODO
      ])

      #Jpsi
    if (whichParticle == 443 or whichParticle == -1):
      list_tmp.extend([   
       "log(1-J_psi_DIRA_OWNPV)", #TODO
       "log(J_psi_OWNPV_CHI2)",
       "J_psi_FD_OWNPV",  
       "J_psi_FDCHI2_OWNPV",
       "J_psi_IP_OWNPV",
       "log(J_psi_IPCHI2_OWNPV)",
       "J_psi_PT",
       "J_psi_PHI",
       "J_psi_ETA" #TODO
       ])
    


      #K+
    if (whichParticle == 321 or whichParticle == -1):
      list_tmp.extend([       
       "K_plus_TRACK_CHI2NDOF",
       "log(1-K_plus_DIRA_OWNPV)", #TODO
       "log(K_plus_OWNPV_CHI2)",
       "K_plus_FD_OWNPV", #TODO
       "K_plus_FDCHI2_OWNPV",#TODO
       "K_plus_IP_OWNPV", 
       "log(K_plus_IPCHI2_OWNPV)", 
       "K_plus_MINIP", 
       "K_plus_MINIPCHI2",
       "K_plus_PT", 
       "K_plus_PHI",
       "K_plus_ETA"
       ])

      # pi0
    if (whichParticle == 111 or whichParticle == -1):
      list_tmp.extend([           
       "pi_zero_resolved_CL",
       "pi_zero_resolved_PT",
       "pi_zero_resolved_PHI",
       "pi_zero_resolved_ETA"
       ])


      #gamma
    if (whichParticle == 22 or whichParticle == 111 or whichParticle == -1):
      list_tmp.extend([           
    "log(gamma1_PT)",
    "gamma1_PHI", 
    "gamma1_ETA", #TODO
    "gamma2_CL",
    "gamma1_CL",
    "log(gamma2_PT)",
    "gamma2_PHI",
    "gamma2_ETA", #TODO
    "open_angle"
      ])

    return list_tmp


def ListOfKshortVars():
  return [
    "log(1-B_plus_DIRA_OWNPV)",
    "log(B_plus_OWNPV_CHI2)",    
    "log(B_plus_IPCHI2_OWNPV)",  
    "B_plus_ENDVERTEX_CHI2",
    "B_plus_FD_OWNPV",      
    "B_plus_IP_OWNPV",      
    "B_plus_PT", 
    "B_plus_DOCA1",         
    "B_plus_NEW_ConePTasym",
    "B_plus_PT",

    "K_star_plus_PT",   
    "log(K_star_plus_IPCHI2_OWNPV)",         
    "K_star_plus_PT",
    #"K_star_plus_M",

    "log(K_short_IPCHI2_OWNPV)",     
    "K_short_FD_OWNPV",         
    "K_short_PT",
    "K_short_ETA",

    "Ks_pi_minus_PX",
    "Ks_pi_minus_PY",
    "Ks_pi_minus_PZ",
    "Ks_pi_minus_PT",
    "Ks_pi_minus_PE",
    "Ks_pi_minus_P",
    "Ks_pi_minus_ETA",

    "Ks_pi_plus_PX",
    "Ks_pi_plus_PY",
    "Ks_pi_plus_PZ",
    "Ks_pi_plus_PT",
    "Ks_pi_plus_PE",
    "Ks_pi_plus_P",
    "Ks_pi_plus_ETA",

    "pi_plus_PX",
    "pi_plus_PY",
    "pi_plus_PZ",
    "pi_plus_PT",
    "pi_plus_PE",
    "pi_plus_P",
    "pi_plus_ETA",
    "log(pi_plus_IPCHI2_OWNPV)",     

    "mu_plus_PX",
    "mu_plus_PY",
    "mu_plus_PZ",
    "mu_plus_PT",
    "mu_plus_PE",
    "mu_plus_P",
    "mu_plus_ETA",
    "log(mu_plus_IPCHI2_OWNPV)", 

    "mu_minus_PX",
    "mu_minus_PY",
    "mu_minus_PZ",
    "mu_minus_PT",
    "mu_minus_PE",
    "mu_minus_P",
    "mu_minus_ETA",
    "log(mu_minus_IPCHI2_OWNPV)",

    "nCandidate",
    "totCandidates",   
    "nTracks",              
    "nLongTracks",          
    "nVeloTracks",          
    "nTTracks",             
    "nUpstreamTracks"

  ]

def ListOfAllVars():
  if (KshortChannel()): return ListOfKshortVars()
  else: return ListOfKplusVars(whichParticle = -1)