38 def getAnalysisSelections(self):
39 """This function allows to get all analysis selections from DQ libraries
40
41 Returns:
42 allAnalysisCuts, allMCSignals, allSels, allMixing: All analysis selections with order
43 """
44
45 allAnalysisCuts = []
46 allPairCuts = []
47 nAddedallAnalysisCutsList = []
48 nAddedPairCutsList = []
49 selsWithOneColon = []
50 allSels = []
51 oneColon = ":"
52 doubleColon = "::"
53 allMCSignals = []
54 allMixing = []
55
56 headers = {
57 "User-Agent":
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"
59 }
60
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"
64
65
66
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.")
69
70
71 context = ssl._create_unverified_context()
72
73
74
75 requestCutsLibrary = Request(URL_CUTS_LIBRARY, headers = headers)
76 requestMCSignalsLibrary = Request(URL_MCSIGNALS_LIBRARY, headers = headers)
77 requestMixingLibrary = Request(URL_MIXING_LIBRARY, headers = headers)
78
79
80 htmlCutsLibrary = urlopen(requestCutsLibrary, context = context).read()
81 htmlMCSignalsLibrary = urlopen(requestMCSignalsLibrary, context = context).read()
82 htmlMixingLibrary = urlopen(requestMixingLibrary, context = context).read()
83
84
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)
91
92
93 with open("tempMCSignalsLibrary.h") as f:
94 for line in 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
99
100 with open("tempMixingLibrary.h") as f:
101 for line in 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
106
107 with open("tempCutsLibrary.h") as f:
108 for line in 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]
113 if getPairCuts:
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]
119
120
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
126
127
128 for i in nAddedPairCutsList:
129 Style1 = [x + i for x in nameSpacedallAnalysisCuts]
130 selsWithOneColon = selsWithOneColon + Style1
131
132
133
134
135 allSels = selsWithOneColon + nAddedallAnalysisCutsList
136
137
138 return allAnalysisCuts, allMCSignals, allSels, allMixing