10 MassFit.cpp
Renata Kopecná edited this page 2022-02-07 17:12:23 +01:00

Table of Contents

Classes

TMefficiencyClass

  • Public members:

    Name Description
    string sVariable LaTeX name of the parameter
    std::vector<string>sBranchName vector of branches needed to get this variable
    Int_t Bins Number of bins in the var
    Float_t Range[2] Range of the var, [low_edge,high_edge]
    std::vector<std::array<double,2>> vVarRange Range of the variables directly from the branch
    std::vector<double> binEdges vector containing the bin borders
    std::vector<double> binEdgesEquidistant vector containing the bin borders assuming equidistant binning
    bool isEquidistant is the binning equidistant?
    Float_t Step Bin width; more of a helper, equal to Range\[1\] - Range\[0\] / Bins
    string cut string in a TFormula format handlight the branches (eg."TMath::Abs(pi_zero_resolved_ETA_DTF-K_plus_ETA_DTF)"
  • Functions:

Functions and their parameters:

TMefficiencyClass::TMefficiencyClass()

Constructor of the TMefficiencyClass. Based on the varName input parameter, it initializes all the class variables.

  • Parameters
    • string varName

void TMefficiencyClass::fillBinEdges()

Takes the TM efficiency class nad based on the number of bins and the overall bin range fills binEdgesEquidistant

void TMefficiencyClass::isEq()

Checks whether the varName parameter contains string "_equal" if yes, sets isEquidistant to true and remove the "_equal" from the varName.

  • Parameters
    • string &varName

bool TMefficiencyClass::check_vector_size()

Checks whether the size of the binEdges (or binEdgesEqudistant if isEquidistant is true) array is equal to nBins+1.

  • Parameters
    • bool isEqui
  • Return
    • True if everything is okay, False if the bin-edge array size is not equal to nBins+1.

bool useExtraVarBool()

This functions checks whether the used extra variable is listed in the binning scheme defined in the TMefficiencyClass.

  • Parameters
    • string extraVar
  • Return

string GetsWeightPlots()

Retrieves and returns the path of the sWeight plots.

  • Parameters
    • string year
    • bool UseOnlyJpsiEvents
    • bool UseOnlyMuMuEvents
    • bool KshortDecaysInVelo
    • bool GetShapeFromMC
    • string SignalType
    • string BkgType
    • bool ConstrainParameters
  • Return
    • sWeight plot path

double massFit()

Performs the fit. Loads the already compiled source files (see B mass model), performs basic sanity checks. If the parameters need to be taken from MC/MVAed data, perform the MC/MVA data fit (unless loopFit is true, than it performs the fit only when running the code for the first time!). The fit shape is defined by SigType and BkgType, creates all the RooVars and RooPDFs needed for the fit. Performs the fit and calculates the signal and background yields together with their errors. Saves these values, together with the effective sigma, in a separate file and calculates significance from this. Then, the fit is plotted, including the pulls, and saved. Furthermore, when sWeight is set to true, it calculates and saves the sWeights in the data tuple and creates control plots.

  • Parameters
    • string year (which year?)
    • string magnet (which polarity?)
    • int Run (which Run? If 0, do year, if 1 or 2, do run)
    • bool MC (use MC?)
    • bool Preselected (fit preselected sample?)
    • bool TM (fit truth-matched MC?)
    • bool PHSP (fit PHSP MC?)
    • bool UseOnlyJpsiEvents (fit only events in Jpsi Q2?)
    • bool UseOnlyMuMuEvents (fit only events in rare Q2?)
    • bool GetShapeFromMC (Fix/constrain parameters to the MC/MVA data shape?)
    • string SigType
      • LeftCB, RightCB, DoubleCB, OneCB, SingleGaussian, DoubleGaussian, NoSig
    • string BkgType
      • SingleExponential, DoubleExponential, ExpGaus, NoBackground, OneCB
    • bool ConstrainParameters (Constrain parameters to the MC/MVA data fit?)
    • bool KshortDecaysInVelo (Long-Long or Down-Down?)
    • bool UseLowQ2Range (Only use events with Q2<Jpsi)
    • Double_t TMVAcut (What TMVA cut should be applied?)
    • int randomSubset (use a random half of the sample?)
    • bool fixedMassRegion (calculate yield in a fixed window or based on sigma?)
    • bool yieldOverFullRange (calculate the yield over the full range?)
    • bool sWeight (calculate and save sWeights?)
    • bool loopFit (prevents the MC/MVA data fit to be performed every time the fit is run)
    • bool IsEfficiency (are you fitting to get an efficiency? (required for proper path handling))
    • string sExtraVar (are you fiting in a bin of some other variable, such as cos(thetak)? what variable?)
    • int nExtraBin (what fit of this variable are you fitting in?)
    • bool removeMultiple (remove multiple candidates)
    • bool weighted (use weighted data)
    • bool weightedFromPi0 (use weights from pi0s)
    • string whichWeight (what branch to use for the pi0 weights?)
    • bool nonTM (fit MC not passing the truth matching?)
    • string customTMbranch (define the truth-matching branch)
    • bool gammaTM (truth-match gammas?)
    • bool InclusiveSample (fit the B->XMuMu MC sample)
  • Return
    • Signal yield is everything went well, 0 if something failed.

int quickFit()

Calls massFit(year,"both", 0,
MC, true, MC, false,
UseOnlyJpsiEvents, UseOnlyMuMuEvents,
GetShapeFromMC,SigType,BkgType,ConstrainParameters,
KshortDecaysInVelo,false,
-1.0, 0,
false, false,
sWeight,
false, false,
"",-1,
false,
false, false, "",
false, "", false,
false)
.

  • Parameters
    • string year
    • bool MC
    • bool sWeight
    • bool UseOnlyJpsiEvents
    • bool UseOnlyMuMuEvents
    • bool KshortDecaysInVelo
    • bool GetShapeFromMC
    • string SigType
    • string BkgType
    • bool ConstrainParameters
  • Return
    • Signal yield is everything went well, 0 if something failed.

int quickTest()

Calls massFit. For the details the fastest is to see the code.

  • Parameters
    • bool gammaTM = false
    • string customTMbranch = "TMed"
  • Return

int testOneCbBackground()

Sets verbosity to 1. Calls massFit. For the details the fastest is to see the code.

  • Parameters
    • bool MC = false
    • string SigType = "OneCB"
    • string BkgType = "SingleExponentialOneCB"
    • string customTMbranch = ""
    • bool gammaTM = false
  • Return
    • Signal yield is everything went well, 0 if something failed.

int efficiencyFit()

Calls massFit with predefined options optimized for an efficiency fit. For the details the fastest is to see the code.

  • Parameters
    • string year = "2011"
    • string magnet = "down"
    • int Run = 0
    • bool Preselected = true
    • bool TM = true
    • bool PHSP = false
    • bool UseOnlyJpsiEvents = false
    • bool UseOnlyMuMuEvents = false
    • bool GetShapeFromMC = false
    • string SigType = "OneCB"
    • string BkgType = "SingleExponential"
    • bool ConstrainParameters = false
    • bool KshortDecaysInVelo = Kst2Kspiplus
    • Double_t TMVAcut = -1.0
    • bool fixedMassRegion = !Kst2Kspiplus
    • bool UseLowQ2Range =false
    • string sExtraVar = ""
    • int nExtraBin = -1
    • bool removeMultiple = false
    • bool weighted = false
    • bool weightedFromPi0 = false
    • string whichWeight = ""
    • string customTMbranch = ""
    • bool gammaTM = false
  • Return
    • Signal yield is everything went well, 0 if something failed.

int basicYieldFit()

Calls massFit. For the details the fastest is to see the code.

  • Parameters
    • string year
    • int Run
    • bool MC
    • bool PHSP
    • bool UseOnlyJpsiEvents
    • bool UseOnlyMuMuEvents
    • bool GetShapeFromMC
    • string SigType
    • string BkgType
    • bool ConstrainParameters
    • bool KshortDecaysInVelo
    • bool UseLowQ2Range
    • Double_t TMVAcut
    • bool fixedMassRegion
    • bool loopFit
    • bool removeMultiple
  • Return
    • Signal yield is everything went well, 0 if something failed.

int basicYieldFitAllYears()

Calls massFit. For the details the fastest is to see the code.

  • Parameters
    • bool MC = true
    • bool PHSP = false
    • bool UseOnlyJpsiEvents = false
    • bool UseOnlyMuMuEvents = false
    • bool GetShapeFromMC = false
    • string SigType = "OneCB"
    • string BkgType = "SingleExponential"
    • bool ConstrainParameters = false
    • bool KshortDecaysInVelo = Kst2Kspiplus
    • bool UseLowQ2Range =false
    • Double_t TMVAcut = -1.
    • bool fixedMassRegion = !Kst2Kspiplus
    • bool loopFit = false
    • bool removeMultiple = false

int basicFitAllYearsAndRegions()

Calls massFit. For the details the fastest is to see the code.

  • Parameters
    • bool MC = true
    • bool PHSP = false
    • bool GetShapeFromMC = false
    • string SigType = "OneCB"
    • string BkgType = "SingleExponential"
    • bool ConstrainParameters = false
    • bool KshortDecaysInVelo = Kst2Kspiplus
    • bool UseLowQ2Range =false
    • Double_t TMVAcut = -1.0
    • bool removeMultiple = false
  • Return
    • Signal yield is everything went well, 0 if something failed.

int getYieldBasicOptionsMC()

Calls massFit. For the details the fastest is to see the code.

  • Parameters
    • bool TM
    • string year
    • int Run
    • bool ReferenceChannel
    • bool PHSP
    • bool removeMultiple
  • Return

int getYieldBasicOptionsMCAllYears()

Calls massFit. For the details the fastest is to see the code.

  • Parameters
    • bool TM
    • bool ReferenceChannel
    • bool PHSP
    • bool removeMultiple
  • Return
    • Signal yield is everything went well, 0 if something failed.

int getYieldAllYearsBasicOptions()

Calls massFit. For the details the fastest is to see the code.

  • Parameters
    • bool TM
    • bool removeMultiple
  • Return
    • Signal yield is everything went well, 0 if something failed.

int basicYieldFitAllRuns()

Calls massFit. For the details the fastest is to see the code.

  • Parameters
    • bool MC = true
    • bool PHSP = false
    • bool UseOnlyJpsiEvents = false
    • bool UseOnlyMuMuEvents = false
    • bool GetShapeFromMC = false
    • string SigType = "OneCB"
    • string BkgType = "SingleExponential"
    • bool ConstrainParameters = false
    • bool KshortDecaysInVelo = Kst2Kspiplus
    • bool UseLowQ2Range =false
    • Double_t TMVAcut = -1.0
    • bool fixedMassRegion = !Kst2Kspiplus
    • bool loopFit = false
    • bool removeMultiple = false
  • Return
    • Signal yield is everything went well, 0 if something failed.

int massFitTestAll()

Calls massFit. For the details the fastest is to see the code.

  • Parameters
    • bool GetShapeFromMC = true
    • bool ConstrainParameters = false
    • int Run = 1
  • Return
    • Signal yield is everything went well, 0 if something failed.

int massFitTestQ2All()

Calls massFit. For the details the fastest is to see the code.

  • Parameters
    • int Run
    • bool PHSP
    • bool UseOnlyMuMuEvents
    • bool UseOnlyJpsiEvents
  • Return
    • Signal yield is everything went well, 0 if something failed.

int PrintFitResults()

Prints out the fitted parameter values and their uncertainty.

  • Parameters
    • RooFitResult* fitRes
  • Return
    • Signal yield is everything went well, 0 if something failed.

int fitJpsi()

Calls massFit. For the details the fastest is to see the code.

  • Parameters
    • string year
    • int Run
    • bool MC
    • double TMVAcut
    • bool RemoveMultiple
  • Return