21from urllib.request
import Request, urlopen
28 Class for Downloading DQ Libraries Github
and It gets analysis selections
29 like analysis cuts, MC signals
and event mixing variables
39 """This function allows to get all analysis selections from DQ libraries
42 allAnalysisCuts, allMCSignals, allSels, allMixing: All analysis selections with order
47 nAddedallAnalysisCutsList = []
48 nAddedPairCutsList = []
58 "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/35.0.1916.47 Safari/537.36"
61 URL_CUTS_LIBRARY =
"https://github.com/AliceO2Group/O2Physics/blob/master/PWGDQ/Core/CutsLibrary.h?raw=true"
62 URL_MCSIGNALS_LIBRARY =
"https://github.com/AliceO2Group/O2Physics/blob/master/PWGDQ/Core/MCSignalLibrary.h?raw=true"
63 URL_MIXING_LIBRARY =
"https://github.com/AliceO2Group/O2Physics/blob/master/PWGDQ/Core/MixingLibrary.h?raw=true"
67 if not (os.path.isfile(
"tempCutsLibrary.h")
or os.path.isfile(
"tempMCSignalsLibrary.h")
or os.path.isfile(
"tempMixingLibrary.h")):
68 print(
"[INFO] Some Libs are Missing. They will download.")
71 context = ssl._create_unverified_context()
75 requestCutsLibrary = Request(URL_CUTS_LIBRARY, headers = headers)
76 requestMCSignalsLibrary = Request(URL_MCSIGNALS_LIBRARY, headers = headers)
77 requestMixingLibrary = Request(URL_MIXING_LIBRARY, headers = headers)
80 htmlCutsLibrary = urlopen(requestCutsLibrary, context = context).read()
81 htmlMCSignalsLibrary = urlopen(requestMCSignalsLibrary, context = context).read()
82 htmlMixingLibrary = urlopen(requestMixingLibrary, context = context).read()
85 with open(
"tempCutsLibrary.h",
"wb")
as f:
86 f.write(htmlCutsLibrary)
87 with open(
"tempMCSignalsLibrary.h",
"wb")
as f:
88 f.write(htmlMCSignalsLibrary)
89 with open(
"tempMixingLibrary.h",
"wb")
as f:
90 f.write(htmlMixingLibrary)
93 with open(
"tempMCSignalsLibrary.h")
as f:
95 stringIfSearch = [x
for x
in f
if "if" in x]
96 for i
in stringIfSearch:
97 getSignals = re.findall(
'"([^"]*)"', i)
98 allMCSignals = allMCSignals + getSignals
100 with open(
"tempMixingLibrary.h")
as f:
102 stringIfSearch = [x
for x
in f
if "if" in x]
103 for i
in stringIfSearch:
104 getMixing = re.findall(
'"([^"]*)"', i)
105 allMixing = allMixing + getMixing
107 with open(
"tempCutsLibrary.h")
as f:
109 stringIfSearch = [x
for x
in f
if "if" in x]
110 for i
in stringIfSearch:
111 getCuts = re.findall(
'"([^"]*)"', i)
112 getPairCuts = [y
for y
in getCuts
if "pair" in y]
114 allPairCuts = (allPairCuts + getPairCuts)
115 namespacedPairCuts = [x + oneColon
for x
in allPairCuts]
116 allAnalysisCuts = (allAnalysisCuts + getCuts)
117 nameSpacedallAnalysisCuts = [x + oneColon
for x
in allAnalysisCuts]
118 nameSpacedallAnalysisCutsTwoDots = [x + doubleColon
for x
in allAnalysisCuts]
121 for k
in range(1, 10):
122 nAddedallAnalysisCuts = [x + str(k)
for x
in nameSpacedallAnalysisCutsTwoDots]
123 nAddedallAnalysisCutsList = nAddedallAnalysisCutsList + nAddedallAnalysisCuts
124 nAddedPairCuts = [x + str(k)
for x
in namespacedPairCuts]
125 nAddedPairCutsList = nAddedPairCutsList + nAddedPairCuts
128 for i
in nAddedPairCutsList:
129 Style1 = [x + i
for x
in nameSpacedallAnalysisCuts]
130 selsWithOneColon = selsWithOneColon + Style1
135 allSels = selsWithOneColon + nAddedallAnalysisCutsList
138 return allAnalysisCuts, allMCSignals, allSels, allMixing
def getAnalysisSelections(self)