-
Notifications
You must be signed in to change notification settings - Fork 4
/
align_txt_file.py
168 lines (160 loc) · 12.6 KB
/
align_txt_file.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
old = open("cutFile_silvio.txt")
nlines = []
max_length = [-1]*30
for line in old.readlines():
nline = line.replace("\t"," ")
tmp = ''
while tmp != nline:
tmp = nline
nline = nline.replace(" "," ")
if (len(nline)>4 and nline[0]!='#' and nline[1]!='#'and nline[0:4]!='JSON') or (len(nline)>4 and nline[0:13]=='#VariableName'):
words = nline.split(" ")
for i in range(len(words)):
max_length[i] = max(max_length[i],len(words[i]))
nlines.append(nline)
new = open("cutFile_silvio_mod.txt",'w')
for nline in nlines:
if (len(nline)>4 and nline[0]!='#' and nline[1]!='#'and nline[0:4]!='JSON') or (len(nline)>4 and nline[0:13]=='#VariableName'):
words = nline.split(" ")
nnline = ''
for i in range(len(words)-1):
nnline += words[i] + " "*(max_length[i]+1-len(words[i]))
nnline = nnline+'\n'
else:
nnline = nline
new.write(nnline)
#Example
"""
JSON /afs/cern.ch/cms/CAF/CMSCOMM/COMM_DQM/certification/Collisions16/13TeV/Cert_271036-284044_13TeV_PromptReco_Collisions16_JSON_NoL1T.txt
#
############################# Example of file with list of cuts
#
#
#------------------------ Preliminary cut variables and values (cut level -1) here -----------------------------
# This first list of variable names and values are used to pass configurable values to the user code associated
# to a variable name.
# The user can retrieve the values associated to a variable name via a provided function call
# [e.g. getPreCutValue1("jetFidRegion") and similarly for value2, value3 and value4 ]
# The idea is that the user can use these values to define the list of objects (electrons, jets, etc.) used in
# analysis. No cut is automatically evaluated on these variables and the cut level must be equal to -1.
# Variable names must be unique.
#
#VariableName value1 value2 value3 value4 level
#------------ ------------ ------------- ------------ ------------- -----
produceSkim 0 - - - -1
produceReducedSkim 1 - - - -1
jetFidRegion 2.5 - - - -1
tightJetID 1 - - - -1
pt0Cut 60 - - - -1
pt1Cut 30 - - - -1
ptCut 30 - - - -1
DeltaR 1.1 - - - -1
DetaJJforTrig 1.3 - - - -1
hadFraction 0.95 - - - -1
emFraction 0.95 - - - -1
# turn on/off on-the-fly JECs (value1 0: off, 1: on)
useJECs 1 - - - -1
# turn on/off the removal of JEC
noJECs 0 - - - -1
# turn on/off shift JECs (value1 0: off, 1: on, value2: sign of the shifting. The value is taken from a txt file with JEC uncertainties)
shiftJECs 0 -1 - - -1
# turn on/off FastJet clustering of wide jets (0: off, 1: on)
useFastJet 0 - - - -1
# clustering algorithm used for wide jets (CambridgeAachen, Kt, AntiKt)
jetAlgo AntiKt - - - -1
#
#
#--------------------------------- Cuts (level 0,1,2,3 ... n) below --------------------------------------------
# The cut variable names, cut boundaries and histogram binnings are provided here by the user.
# In the event loop of the analysisClass_template.C, the user have to fill each variable with its value using
# a provided function call [ e.g. fillVariableWithValue("nEleFinal", number_of_electrons) ]
# The variable names in the user code has to match the names provided here.
# Variable names must be unique.
# The cut will be declared "passed" if
# ( minValue1 < VariableName <= maxValue1 )
# in case only the first range (minValue1, maxValue1) is provided,
# otherwise the cut will be declared "passed" if
# ( minValue1 < VariableName <= maxValue1 ) OR ( minValue2 < VariableName <= maxValue2 )
# in case even the second range (minValue2, maxValue2) is provided.
# The level of the cut (0,1,2 ... n) is provided by the user and can be used in the code to easily determine if
# groups of same-level cuts have passed or failed.
#
#VariableName minValue1(<) maxValue1(>=) minValue2(<) maxValue2(>=) level histoNbinsMinMax OptionalFlag
#------------ ------------ ------------- ------------ ------------- ----- ---------------- ------------
PassJSON -1 1 - - 0 2 -0.5 1.5 SAVE
nVtx -inf +inf - - 1 -2 0 50 SAVE
nJet 1 +inf - - 1 31 -0.5 30.5 SAVE
pTWJ_j1 50 +inf - - 1 500 0 5000 SAVE
pTWJ_j1_noCorr 50 +inf - - 1 500 0 5000 SAVE
etaWJ_j1 -2.5 2.5 - - 1 50 -2.5 2.5 SAVE
pTWJ_j2 20 +inf - - 1 500 0 5000 SAVE
pTWJ_j2_noCorr 20 +inf - - 1 500 0 5000 SAVE
etaWJ_j2 -2.5 2.5 - - 1 50 -2.5 2.5 SAVE
deltaETAjj -inf +inf - - 1 100 0. 3. SAVE
#mjj 300 +inf - - 1 10000 0 10000 SAVE
#mjj_noCorr 300 +inf - - 1 10000 0 10000 SAVE
mjj -inf +inf - - 1 10000 0 10000 SAVE
mjj_noCorr -inf +inf - - 1 10000 0 10000 SAVE
mjj_shiftJEC -inf +inf - - 1 10000 0 10000 SAVE
# no cut on these variables, just want to save histograms and variables
passHLT_CaloJet40_CaloScouting_PFScouting -inf +inf - - 1 2 0 2. SAVE
passHLT_L1HTT_CaloScouting_PFScouting -inf +inf - - 1 2 0 2. SAVE
passHLT_CaloScoutingHT250 -inf +inf - - 1 2 0 2. SAVE
passHLT_PFScoutingHT450 -inf +inf - - 1 2 0 2. SAVE
passHLT_PFHT900 -inf +inf - - 1 2 0 2. SAVE
passHLT_PFHT800 -inf +inf - - 1 2 0 2. SAVE
passHLT_PFHT650MJJ950 -inf +inf - - 1 2 0 2. SAVE
passHLT_PFHT650MJJ900 -inf +inf - - 1 2 0 2. SAVE
passHLT_PFJET500 -inf +inf - - 1 2 0 2. SAVE
passHLT_PFJET450 -inf +inf - - 1 2 0 2. SAVE
passHLT_Mu45Eta2p1 -inf +inf - - 1 2 0 2. SAVE
passHLT_AK8PFHT700TriMass50 -inf +inf - - 1 2 0 2. SAVE
passHLT_AK8PFJet360TrimMass50 -inf +inf - - 1 2 0 2. SAVE
passHLT_CaloJet500NoJetID -inf +inf - - 1 2 0 2. SAVE
passL1T_HTT200 -inf +inf - - 1 2 0 2. SAVE
passL1T_HTT240 -inf +inf - - 1 2 0 2. SAVE
passL1T_HTT270 -inf +inf - - 1 2 0 2. SAVE
passL1T_HTT280 -inf +inf - - 1 2 0 2. SAVE
passL1T_HTT300 -inf +inf - - 1 2 0 2. SAVE
passL1T_HTT320 -inf +inf - - 1 2 0 2. SAVE
passL1T_ZeroBias -inf +inf - - 1 2 0 2. SAVE
isData -inf +inf - - 1 2 0 2. SAVE
run -inf +inf - - 1 50 0 100000 SAVE
event -inf +inf - - 1 50 0 100000 SAVE
lumi -inf +inf - - 1 50 0 10000 SAVE
htAK4 -inf +inf - - 1 500 0 10000 SAVE
mhtAK4 -inf +inf - - 1 500 0 10000 SAVE
mhtAK4Sig -inf +inf - - 1 100 0 2 SAVE
met -inf +inf - - 1 500 0 5000 SAVE
deltaPHIjj -inf +inf - - 1 200 -3.15 3.15 SAVE
deltaPHIjjAK4 -inf +inf - - 1 200 -3.15 3.15 SAVE
deltaETAjjAK4 -inf +inf - - 1 100 0. 3. SAVE
Nak4 -inf +inf - - 1 100 0 100 SAVE
pTAK4_j1 -inf +inf - - 1 500 0 5000 SAVE
etaAK4_j1 -inf +inf - - 1 50 -2.5 2.5 SAVE
phiAK4_j1 -inf +inf - - 1 200 -3.15 3.15 SAVE
massWJ_j1 -inf +inf - - 1 200 0 1000 SAVE
phiWJ_j1 -inf +inf - - 1 200 -3.15 3.15 SAVE
jetJecAK4_j1 -inf +inf - - 1 90 0 3 SAVE
jetJecUncAK4_j1 -inf +inf - - 1 90 0 3 SAVE
jetCSVAK4_j1 -inf +inf - - 1 100 0 2 SAVE
pTAK4_j2 -inf +inf - - 1 500 0 5000 SAVE
etaAK4_j2 -inf +inf - - 1 50 -2.5 2.5 SAVE
phiAK4_j2 -inf +inf - - 1 200 -3.15 3.15 SAVE
massWJ_j2 -inf +inf - - 1 200 0 1000 SAVE
phiWJ_j2 -inf +inf - - 1 200 -3.15 3.15 SAVE
jetJecAK4_j2 -inf +inf - - 1 90 0 3 SAVE
jetJecUncAK4_j2 -inf +inf - - 1 90 0 3 SAVE
jetCSVAK4_j2 -inf +inf - - 1 100 0 2 SAVE
CosThetaStarWJ -inf +inf - - 1 200 -1 1 SAVE
CosThetaStarAK4 -inf +inf - - 1 200 -1 1 SAVE
Dijet_MassAK4 -inf +inf - - 1 1000 0 10000 SAVE
IdTight_j1 0.5 1.5 - - 1 2 0 2. SAVE
IdTight_j2 0.5 1.5 - - 1 2 0 2. SAVE
HadEnFrac_j1 -inf +inf - - 1 100 0 1 SAVE
EmEnFrac_j1 -inf +inf - - 1 100 0 1 SAVE
HadEnFrac_j2 -inf +inf - - 1 100 0 1 SAVE
EmEnFrac_j2 -inf +inf - - 1 100 0 1 SAVE
corr1_WJ1 -inf +inf - - 1 100 0 1 SAVE
corr2_WJ2 -inf +inf - - 1 100 0 1 SAVE
"""