Update 'Utils3.py'
parent
a537d86b97
commit
c7edd75253
100
Utils3.py.md
100
Utils3.py.md
@ -14,19 +14,19 @@ A list of trree branches that are saved as integers
|
||||
|
||||
## Functions
|
||||
|
||||
### def expressionList()
|
||||
### expressionList()
|
||||
* **Return**
|
||||
* A list of used expressions, used for pasring any input formula
|
||||
|
||||
|
||||
### def isInt()
|
||||
### isInt()
|
||||
* **Parameters**
|
||||
* variable=""
|
||||
* **Return**
|
||||
* True is the variable is stored as an integer, false otherwise
|
||||
|
||||
|
||||
### def treeName()
|
||||
### treeName()
|
||||
|
||||
|
||||
* **Parameters**
|
||||
@ -34,7 +34,7 @@ A list of trree branches that are saved as integers
|
||||
* **Return**
|
||||
* The correct tree name for given sample.
|
||||
|
||||
### def getOptionsDictionary(y)
|
||||
### getOptionsDictionary(y)
|
||||
* **Parameters**
|
||||
* year
|
||||
* Run
|
||||
@ -55,14 +55,14 @@ A list of trree branches that are saved as integers
|
||||
* A dicitonary with all possible saved options in
|
||||
|
||||
|
||||
### def checkYearSample()
|
||||
### checkYearSample()
|
||||
|
||||
* **Parameters**
|
||||
* optionsDict
|
||||
* **Return**
|
||||
* Checks whether the selected data sample defined by optionsDict makes sense. If yes, returns True, otherwise False
|
||||
|
||||
### def checkYearSample()
|
||||
### checkYearSample()
|
||||
|
||||
* **Parameters**
|
||||
* year,MC,ReferenceChannel,PHSP,KshortChannel
|
||||
@ -70,7 +70,7 @@ A list of trree branches that are saved as integers
|
||||
* Checks whether the selected data sample defined by the options makes sense. If yes, returns True, otherwise False
|
||||
|
||||
|
||||
### def getTreePath()
|
||||
### getTreePath()
|
||||
* **Parameters**
|
||||
* optionsDict, verbose
|
||||
* **Return**
|
||||
@ -78,46 +78,26 @@ A list of trree branches that are saved as integers
|
||||
|
||||
|
||||
|
||||
### def addToTChain()
|
||||
|
||||
### addToTChain()
|
||||
Adds TTrees to TChain from file selected by optionsDict
|
||||
* **Parameters**
|
||||
* tree, optionsDict, verbose
|
||||
* **Return**
|
||||
|
||||
|
||||
|
||||
filePath, filePath2 = getTreePath(optionsDict=optionsDict, verbose=verbose)
|
||||
|
||||
#Get first file name
|
||||
if(optionsDict['BDTed'] or optionsDict['sWeighted'] or optionsDict['bWeighted'] or optionsDict['b2Dweighted']):
|
||||
print ("[INFO]\tOpening", filePath)
|
||||
tree.Add(filePath)
|
||||
else:
|
||||
if (optionsDict['magnet']=="both"):
|
||||
print ("[INFO]\tOpening", filePath)
|
||||
tree.Add(filePath)
|
||||
print ("[INFO]\tOpening", filePath2)
|
||||
tree.Add(filePath2)
|
||||
else:
|
||||
print ("[INFO]\tOpening", filePath)
|
||||
tree.Add(filePath)
|
||||
|
||||
|
||||
### def addTMathTags()
|
||||
### addTMathTags()
|
||||
|
||||
* **Parameters**
|
||||
* varName
|
||||
* **Return**
|
||||
*
|
||||
for expr in expressionList():
|
||||
varName = varName.replace(expr,"TMath::"+expr)
|
||||
return varName
|
||||
* the varName ewith added "TMath::" so ROOT can function
|
||||
|
||||
### def list_of_DTF_vars ()
|
||||
### list_of_DTF_vars ()
|
||||
|
||||
* **Return**
|
||||
* A list of variables that can have a DTF suffix
|
||||
|
||||
### def replace_variables_to_DTF()
|
||||
### replace_variables_to_DTF()
|
||||
Pretty much appends \"_DTF\" to everything
|
||||
* **Parameters**
|
||||
* variable = ""
|
||||
@ -125,104 +105,84 @@ Pretty much appends \"_DTF\" to everything
|
||||
* the updated name of the variable (with \"_DTF\" appended)
|
||||
|
||||
|
||||
|
||||
### def getListOfUsedVariables(
|
||||
### getListOfUsedVariables(
|
||||
Parses the desired cut on the given variable to be readable by python
|
||||
* **Parameters**
|
||||
* variable, cut
|
||||
* **Return**
|
||||
* List of branches that need to be loaded
|
||||
*
|
||||
### def evaluateCut()
|
||||
### evaluateCut()
|
||||
* **Parameters**
|
||||
* cut,variablesDict
|
||||
* **Return**
|
||||
* parses and evaluates the cut using eval()
|
||||
|
||||
### def makeVariablePythonFriendly()
|
||||
### makeVariablePythonFriendly()
|
||||
Removes ROOT tags and lowers all the letters
|
||||
* **Parameters**
|
||||
* variable
|
||||
* **Return**
|
||||
* variable parsed to be readable by python
|
||||
|
||||
### def evaluateVariable()
|
||||
### evaluateVariable()
|
||||
* **Parameters**
|
||||
* variable,variablesDict
|
||||
* **Return**
|
||||
*
|
||||
tmp = variable
|
||||
for varName,varValue in variablesDict.items():
|
||||
tmp = tmp.replace(str(varName),str(varValue[0]))
|
||||
tmp = makeVariablePythonFriendly(tmp)
|
||||
return numexpr.evaluate(tmp).item()
|
||||
* Evaluates the expression using the information from the branches
|
||||
|
||||
### def evaluateWeight() #TODO
|
||||
### evaluateWeight()
|
||||
* **Parameters**
|
||||
* variablesDict,optionsDict
|
||||
* **Return**
|
||||
* weight for the given optionsDict
|
||||
* weight branch name for the given optionsDict
|
||||
|
||||
|
||||
### def datasetTag()
|
||||
### datasetTag()
|
||||
* **Parameters**
|
||||
* optionsDict
|
||||
* **Return**
|
||||
* Tag (name) for the desired dataset
|
||||
|
||||
### def weightTag()
|
||||
### weightTag()
|
||||
* **Parameters**
|
||||
* optionsDict
|
||||
* **Return**
|
||||
* weight tag for the given optionsDict
|
||||
*
|
||||
### def KshortDecaysInVeloTag()
|
||||
### KshortDecaysInVeloTag()
|
||||
* **Parameters**
|
||||
* KshortDecaysInVelo=False
|
||||
* **Return**
|
||||
* Empty string if K+pi0, otherwise '\_LL' if KshortDecaysInVelo else '\_DD'
|
||||
|
||||
### def variableTag()
|
||||
### variableTag()
|
||||
* **Parameters**
|
||||
* variable=""
|
||||
* **Return**
|
||||
* parsed and cleanedup variable name for saving the file. It is not perfext but works somewhat
|
||||
|
||||
|
||||
### def histName()
|
||||
### histName()
|
||||
* **Parameters**
|
||||
* variable, optionsDict
|
||||
* **Return**
|
||||
*
|
||||
name = variableTag(variable)
|
||||
name = name.replace("TMath::","") #remove functions
|
||||
for expr in (expressionList()): #For whatever reason I have to but the brackets there
|
||||
name = name.replace(expr.lower(),expr) #Add capitals to functions
|
||||
|
||||
name = "Hist_" + str(optionsDict['year']) + "_" + datasetTag(optionsDict)
|
||||
name = name + KshortDecaysInVeloTag(optionsDict) + weightTag(optionsDict)
|
||||
return name
|
||||
* Name of the histogram to be saved
|
||||
|
||||
|
||||
### def stopWatch()
|
||||
|
||||
Prints the time passed between `value` and now.
|
||||
* **Parameters**
|
||||
* value
|
||||
|
||||
|
||||
### def getTreeWithPairingBranch()
|
||||
### getTreeWithPairingBranch()
|
||||
Adds the branch with the corresponding pairing function to the tree. Pairing function is a unique number calculated from the event and run numbers. This is calculated using the [Cantor pairing function](https://en.wikipedia.org/wiki/Pairing_function#Cantor_pairing_function)
|
||||
* **Parameters**
|
||||
* treeFile,tree,run,test
|
||||
* **Return**
|
||||
* The new tree file and the new tree
|
||||
|
||||
### def checkMCyear()
|
||||
### checkMCyear()
|
||||
* **Parameters**
|
||||
* year, ReferenceChannel, PHSP
|
||||
* **Return**
|
||||
|
||||
|
||||
if ((not KshortChannel) and (not ReferenceChannel) and (not PHSP) and year == 2015): return 2016
|
||||
else: return year
|
||||
* either the year or year 2016 if the 2015 sample is not available
|
Loading…
Reference in New Issue
Block a user