CMS 3D CMS Logo

hgcalPerformanceValidation.py
Go to the documentation of this file.
1 #! /usr/bin/env python3
2 
3 #------------------------------------------------------------------------------------------
4 # Description: This script is used to produce the results of the regurarly announced RelVal campaings.
5 # Essentially, this is a wrapper around the basic HGCal Validation script:
6 # Validation/HGCalValidation/scripts/makeHGCalValidationPlots.py
7 # Documentation: Full documentation on this script and details on how to run it are in the section
8 # "Campaign Validation" in the HGCal DPG website:
9 # http://hgcal.web.cern.ch/hgcal/Validation/RelVals/
10 # Information on the CMSSW HGCalValidation package and relevant objects can be
11 # found in the "Validation" section.
12 #------------------------------------------------------------------------------------------
13 
14 import sys
15 import os
16 import commands
17 import optparse
18 import pandas as pd
19 
20 from collections import OrderedDict
21 
22 from Validation.RecoTrack.plotting.validation import Sample, Validation
23 from Validation.HGCalValidation.html import _sampleName,_pageNameMap,_summary,_summobj,_MatBudSections,_geoPageNameMap,_individualmaterials,_matPageNameMap,_individualmatplots,_individualMatPlotsDesc,_hideShowFun,_allmaterialsplots,_allmaterialsPlotsDesc, _fromvertexplots, _fromVertexPlotsDesc
24 
25 #------------------------------------------------------------------------------------------
26 #Parsing input options
28 
29  usage = ('usage: %prog [options]\n'
30  + '%prog -h for help')
31  parser = optparse.OptionParser(usage)
32 
33  parser.add_option('', '--Obj', dest='OBJ', type='string', default=None, help='Object to run. Options are: Geometry, SimHits, Digis, RecHits, Calibrations, CaloParticles, hgcalLayerClusters')
34  parser.add_option('', '--html-validation-name', dest='HTMLVALNAME', type='string', default='', help='Could be either be hgcalLayerClusters or hgcalMultiClusters')
35  parser.add_option('-d', '--download', action='store_true', dest='DOWNLOAD', default=False, help='Download DQM files from RelVals')
36  parser.add_option('-g', '--gather', dest='GATHER', type='string', default=None, help='Objects to gather: hitValidation, hitCalibration, hgcalLayerClusters, hgcalMultiClusters, ticlMultiClustersFromTrackstersEM, ticlMultiClustersFromTrackstersHAD')
37  parser.add_option('-w', '--wwwarea', dest='WWWAREA', type='string', default='/eos/project/h/hgcaldpg/www', help='Objects to gather: hitValidation, hitCalibration, hgcalLayerClusters, hgcalMultiClusters, ticlMultiClustersFromTrackstersEM, ticlMultiClustersFromTrackstersHAD')
38  parser.add_option('-y', '--dry-run', action='store_true', dest='DRYRUN', default=False, help='perform a dry run (nothing is lauched).')
39  parser.add_option('-i', '--inputeosarea', dest='INPUT', type='string', default='/eos/cms/store/group/dpg_hgcal/comm_hgcal/apsallid/RelVals', help='Eos area where we will place all DQM files of the new and reference release campaign')
40  parser.add_option('', '--geometry', action='store_true', dest='GEOMETRY', default=False, help='Geometry validation section')
41  parser.add_option('', '--copyhtml', action='store_true', dest='COPYHTML', default=False, help='If used the main index.html file will be copied to the www area. Useful in case of experimenting to avoid surprises.')
42 
43  # store options and arguments as global variables
44  global opt, args
45  (opt, args) = parser.parse_args()
46 
48 
49 #------------------------------------------------------------------------------------------
50 #Some helpful functions
51 #Processing the external os commands
52 def processCmd(cmd, quite = 0):
53  print(cmd)
54  status, output = commands.getstatusoutput(cmd)
55  if (status !=0 and not quite):
56  print('Error in processing command:\n ['+cmd+']')
57  print('Output:\n ['+output+'] \n')
58  return output
59 
60 #PUtype
61 def putype(t):
62  if "_pmx" in NewRelease:
63  if "_pmx" in RefRelease:
64  return {"default": "pmx"+t}
65  return {"default": t, NewRelease: "pmx"+t}
66  return t
67 
68 #------------------------------------------------------------------------------------------
69 #Input section: Each time a new RelVal campaign is announced the following variables should
70 # be updated:
71 # NewRelease: The new release being validated.
72 # RefRelease: The reference release we want to test the new one against.
73 # thereleases: All releases validated for which we have validation results
74 # including the NewRelease.
75 # NotNormalRelease , NotNormalRefRelease: If one of the releases to be validated has
76 # used the DIGI on 11_0_0 put "raw". Otherwise put "normal".
77 # phase2samples_noPU: These are the noPU phase 2 RelVal samples that are regurarly
78 # produced.
79 # phase2samples_PU: These are the PU phase 2 RelVal samples that are regurarly
80 # produced.
81 # RefRepository, NewRepository: The path where the DQM files of the campaign
82 # will be placed.
83 #------------------------------------------------------------------------------------------
84 #thereleases = { "CMSSW 11_1_X" : ["CMSSW_11_1_0_pre4_GEANT4","CMSSW_11_1_0_pre3","CMSSW_11_1_0_pre2"] }
85 thereleases = OrderedDict()
86 thereleases = { "CMSSW 11_3_X" : [
87  "CMSSW_11_3_0_pre3_G4VECGEOM_vs_CMSSW_11_3_0_pre3",
88  "CMSSW_11_3_0_pre3_D76_vs_CMSSW_11_3_0_pre3",
89  "CMSSW_11_3_0_pre3_vs_CMSSW_11_3_0_pre2",
90  "CMSSW_11_3_0_pre2_vs_CMSSW_11_3_0_pre1",
91  "CMSSW_11_3_0_pre1_vs_CMSSW_11_2_0_pre10",
92  ],
93  "CMSSW 11_2_X" : [
94  "CMSSW_11_2_0_vs_CMSSW_11_2_0_pre10",
95  "CMSSW_11_2_0_pre10_vs_CMSSW_11_2_0_pre9",
96  "CMSSW_11_2_0_pre9_vs_CMSSW_11_2_0_pre8",
97  "CMSSW_11_2_0_pre8_vs_CMSSW_11_2_0_pre7",
98  "CMSSW_11_2_0_pre7_vs_CMSSW_11_2_0_pre6",
99  "CMSSW_11_2_0_pre6_ROOT622_vs_CMSSW_11_2_0_pre6",
100  "CMSSW_11_2_0_pre6_vs_CMSSW_11_2_0_pre5",
101  "CMSSW_11_2_0_pre5_GEANT106_vs_CMSSW_11_2_0_pre5",
102  "CMSSW_11_2_0_pre5_vs_CMSSW_11_2_0_pre3",
103  "CMSSW_11_2_0_pre3_vs_CMSSW_11_2_0_pre1",
104  "CMSSW_11_2_0_pre1_vs_CMSSW_11_1_0_pre8"
105  ],
106  "CMSSW 11_1_X" : [
107  "CMSSW_11_1_0_pre8_raw1100_vs_CMSSW_11_1_0_pre8",
108  "CMSSW_11_1_0_pre8_raw1100_vs_CMSSW_11_1_0_pre7_raw1100",
109  "CMSSW_11_1_0_pre8_vs_CMSSW_11_1_0_pre7",
110  "CMSSW_11_1_0_pre7_raw1100_vs_CMSSW_11_1_0_pre7",
111  "CMSSW_11_1_0_pre7_raw1100_vs_CMSSW_11_1_0_pre6_raw1100",
112  "CMSSW_11_1_0_pre7_vs_CMSSW_11_1_0_pre6",
113  "CMSSW_11_1_0_pre6_raw1100_vs_CMSSW_11_1_0_pre6",
114  "CMSSW_11_1_0_pre6_raw1100_vs_CMSSW_11_1_0_pre5_raw1100",
115  "CMSSW_11_1_0_pre6_vs_CMSSW_11_1_0_pre5",
116  "CMSSW_11_1_0_pre5_vs_CMSSW_11_1_0_pre4",
117  "CMSSW_11_1_0_pre5_raw1100_vs_CMSSW_11_1_0_pre5",
118  "CMSSW_11_1_0_pre5_raw1100_vs_CMSSW_11_1_0_pre4_raw1100",
119  "CMSSW_11_1_0_pre4_raw1100_vs_CMSSW_11_1_0_pre4",
120  "CMSSW_11_1_0_pre4_raw1100_vs_CMSSW_11_1_0_pre3_raw1100",
121  "CMSSW_11_1_0_pre4_GEANT4","CMSSW_11_1_0_pre4"
122  ]
123 }
124 
125 geometryTests = OrderedDict()
126 geometryTests = { "Material budget" : [
127  #"Extended2026D49_vs_Extended2026D71",
128  "Extended2026D49_vs_Extended2026D76"
129  ]
130 }
131 
132 GeoScenario = "Extended2026D49_vs_Extended2026D76"
133 
134 RefRelease='CMSSW_11_3_0_pre3'
135 
136 NewRelease='CMSSW_11_3_0_pre3_G4VECGEOM'
137 
138 NotNormalRelease = "normal"
139 NotNormalRefRelease = "normal"
140 
141 if ( os.path.isdir('%s/%s' %(opt.WWWAREA, NewRelease))) :
142  print("The campaign you are trying to validate has already an existing validation folder in the official www area.")
143  print("Make sure you are not overwriting anything and try again.")
144  exit()
145 
146 if "raw" in NotNormalRelease:
147  # appendglobaltag = "_2026D49noPU_raw1100_rsb"
148  # appendglobaltag = "_2026D49noPU_raw1100"
149  # appendglobaltag = "_2026D49noPU_gcc900"
150  appendglobaltag = "_2026D76noPU"
151 else:
152  appendglobaltag = "_2026D49noPU"
153 
154 #Until the final list of RelVals settles down the following sample list is under constant review
155 '''
156 phase2samples_noPU_oldnaming = [
157 # Sample("RelValCloseByParticleGun_CE_H_Fine_300um", dqmVersion="0002", scenario="2026D49", appendGlobalTag=appendglobaltag ),
158  Sample("RelValCloseByParticleGun_CE_H_Fine_300um", scenario="2026D49", appendGlobalTag=appendglobaltag ),
159  Sample("RelValCloseByParticleGun_CE_H_Fine_200um", scenario="2026D49", appendGlobalTag=appendglobaltag ),
160  Sample("RelValCloseByParticleGun_CE_H_Fine_120um", scenario="2026D49", appendGlobalTag=appendglobaltag ),
161  Sample("RelValCloseByParticleGun_CE_H_Coarse_Scint", scenario="2026D49", appendGlobalTag=appendglobaltag ),
162  Sample("RelValCloseByParticleGun_CE_H_Coarse_300um", scenario="2026D49", appendGlobalTag=appendglobaltag ),
163  Sample("RelValCloseByParticleGun_CE_E_Front_300um", scenario="2026D49", appendGlobalTag=appendglobaltag ),
164  Sample("RelValCloseByParticleGun_CE_E_Front_200um", scenario="2026D49", appendGlobalTag=appendglobaltag ),
165  Sample("RelValCloseByParticleGun_CE_E_Front_120um", scenario="2026D49", appendGlobalTag=appendglobaltag ),
166  #Sample("RelValCloseByParticleGun_CE_E_Front_120um", scenario="2026D49", appendGlobalTag=appendglobaltag , version="v2"),
167  Sample("RelValTTbar", midfix="14TeV", scenario="2026D49", appendGlobalTag=appendglobaltag ),
168  Sample("RelValZMM", midfix="14", scenario="2026D49", appendGlobalTag=appendglobaltag ),
169  Sample("RelValSingleGammaFlatPt8To150", scenario="2026D49", appendGlobalTag=appendglobaltag ),
170  Sample("RelValSingleMuPt10", scenario="2026D49", appendGlobalTag=appendglobaltag ),
171  Sample("RelValSingleMuPt100", scenario="2026D49", appendGlobalTag=appendglobaltag ),
172  Sample("RelValSingleMuPt1000", scenario="2026D49", appendGlobalTag=appendglobaltag ),
173  Sample("RelValSingleMuFlatPt2To100", scenario="2026D49", appendGlobalTag=appendglobaltag ),
174  Sample("RelValSingleMuFlatPt0p7To10", scenario="2026D49", appendGlobalTag=appendglobaltag ),
175  Sample("RelValSingleEFlatPt2To100", scenario="2026D49", appendGlobalTag=appendglobaltag ),
176  Sample("RelValSingleTauFlatPt2To150", scenario="2026D49", appendGlobalTag=appendglobaltag ),
177  Sample("RelValSinglePiFlatPt0p7To10", scenario="2026D49", appendGlobalTag=appendglobaltag ),
178  Sample("RelValQCD_Pt20toInfMuEnrichPt15", midfix="14TeV", scenario="2026D49", appendGlobalTag=appendglobaltag ),
179  Sample("RelValQCD_Pt15To7000_Flat", midfix="14TeV", scenario="2026D49", appendGlobalTag=appendglobaltag ),
180  Sample("RelValZTT", midfix="14TeV", scenario="2026D49", appendGlobalTag=appendglobaltag ),
181  Sample("RelValZMM", midfix="14", scenario="2026D49", appendGlobalTag=appendglobaltag ),
182  Sample("RelValZEE", midfix="14", scenario="2026D49", appendGlobalTag=appendglobaltag ),
183  Sample("RelValB0ToKstarMuMu", midfix="14TeV", scenario="2026D49", appendGlobalTag=appendglobaltag ),
184  Sample("RelValBsToEleEle", midfix="14TeV", scenario="2026D49", appendGlobalTag=appendglobaltag ),
185  Sample("RelValBsToMuMu", midfix="14TeV", scenario="2026D49", appendGlobalTag=appendglobaltag ),
186  Sample("RelValBsToJpsiGamma", midfix="14TeV", scenario="2026D49", appendGlobalTag=appendglobaltag ),
187  Sample("RelValBsToJpsiPhi_mumuKK", midfix="14TeV", scenario="2026D49", appendGlobalTag=appendglobaltag ),
188  Sample("RelValBsToPhiPhi_KKKK", midfix="14TeV", scenario="2026D49", appendGlobalTag=appendglobaltag ),
189  Sample("RelValDisplacedMuPt30To100", scenario="2026D49", appendGlobalTag=appendglobaltag ),
190  Sample("RelValDisplacedMuPt2To10", scenario="2026D49", appendGlobalTag=appendglobaltag ),
191  Sample("RelValDisplacedMuPt10To30", scenario="2026D49", appendGlobalTag=appendglobaltag ),
192  Sample("RelValTauToMuMuMu", midfix="14TeV", scenario="2026D49", appendGlobalTag=appendglobaltag ),
193  #Sample("RelValMinBias", midfix="14TeV", scenario="2026D49", appendGlobalTag=appendglobaltag ),
194  Sample("RelValH125GGgluonfusion", midfix="14", scenario="2026D49", appendGlobalTag=appendglobaltag ),
195  Sample("RelValNuGun", scenario="2026D49", appendGlobalTag=appendglobaltag )
196  ]
197 '''
198 
199 #Main workflow RelVals
200 phase2samples_noPU = [
201 
202  #------------------------------
203  #version v2 campaign
204  #Sample("RelValZpTT_1500", midfix="14", scenario="2026D49", appendGlobalTag=appendglobaltag, version="v2" ),
205 
218 
219  #------------------------------
220  #NORMAL version v1 campaign
221  Sample("RelValZpTT_1500", midfix="14", scenario="2026D49", appendGlobalTag=appendglobaltag ),
222  #Sample("RelValZpTT_1500", midfix="14TeV", scenario="2026D49", appendGlobalTag=appendglobaltag ),
223  Sample("RelValZTT", midfix="14TeV", scenario="2026D49", appendGlobalTag=appendglobaltag ),
224  Sample("RelValZMM", midfix="14", scenario="2026D49", appendGlobalTag=appendglobaltag ),
225  Sample("RelValZEE", midfix="14", scenario="2026D49", appendGlobalTag=appendglobaltag ),
226  #Sample("RelValTenTau_15_500_Eta3p1", scenario="2026D49", appendGlobalTag=appendglobaltag ),
227  Sample("RelValTenTau_15_500", scenario="2026D49", appendGlobalTag=appendglobaltag ),
228  Sample("RelValTTbar", midfix="14TeV", scenario="2026D49", appendGlobalTag=appendglobaltag ),
229  Sample("RelValQCD_Pt15To7000_Flat", midfix="14", scenario="2026D49", appendGlobalTag=appendglobaltag ),
230  #Sample("RelValQCD_Pt15To7000_Flat", midfix="14TeV", scenario="2026D49", appendGlobalTag=appendglobaltag ),
231  Sample("RelValNuGun", scenario="2026D49", appendGlobalTag=appendglobaltag ),
232  #Sample("RelValMinBias", midfix="14", scenario="2026D49", appendGlobalTag=appendglobaltag ),
233  Sample("RelValMinBias", midfix="14TeV", scenario="2026D49", appendGlobalTag=appendglobaltag ),
234  Sample("RelValH125GGgluonfusion", midfix="14", scenario="2026D49", appendGlobalTag=appendglobaltag )
235  #------------------------------
236 
237 
238 ]
239 
240 
241 #More workflows
242 phase2samples_noPU_extend = [
243 
244  #Sample("RelValSingleMuPt10", scenario="2026D49", appendGlobalTag=appendglobaltag, version="v2"),
245  #Sample("RelValSingleMuPt100", scenario="2026D49", appendGlobalTag=appendglobaltag, version="v2" ),
246  #Sample("RelValSingleMuPt1000", scenario="2026D49", appendGlobalTag=appendglobaltag, version="v2" )
247 
248 
249 
250  Sample("RelValSingleMuPt10", scenario="2026D49", appendGlobalTag=appendglobaltag ),
251  Sample("RelValSingleMuPt100", scenario="2026D49", appendGlobalTag=appendglobaltag ),
252  Sample("RelValSingleMuPt1000", scenario="2026D49", appendGlobalTag=appendglobaltag )
253 
254 ]
255 
256 #These workflows were added in CMSSW_11_1_0_pre6 but there were missing from CMSSW_11_1_0_pre5.
257 #So, I am only download them to be reary for pre7. Then, I comment them out
258 #For the moment I cannot find these in pre7.
259 phase2samples_noPU_extend_more = [
260 
261  #------------------------------
262  #version v2 campaign
263  Sample("RelValCloseByPGun_CE_H_Fine_300um", scenario="2026D49", appendGlobalTag=appendglobaltag, version="v2" ),
264  Sample("RelValCloseByPGun_CE_H_Fine_200um", scenario="2026D49", appendGlobalTag=appendglobaltag, version="v2" ),
265  Sample("RelValCloseByPGun_CE_H_Fine_120um", scenario="2026D49", appendGlobalTag=appendglobaltag, version="v2" ),
266  Sample("RelValCloseByPGun_CE_H_Coarse_Scint", scenario="2026D49", appendGlobalTag=appendglobaltag, version="v2" ),
267  Sample("RelValCloseByPGun_CE_H_Coarse_300um", scenario="2026D49", appendGlobalTag=appendglobaltag, version="v2" ),
268  Sample("RelValCloseByPGun_CE_E_Front_300um", scenario="2026D49", appendGlobalTag=appendglobaltag, version="v2" ),
269  Sample("RelValCloseByPGun_CE_E_Front_200um", scenario="2026D49", appendGlobalTag=appendglobaltag, version="v2" ),
270  Sample("RelValCloseByPGun_CE_E_Front_120um", scenario="2026D49", appendGlobalTag=appendglobaltag, version="v2" ),
271  Sample("RelValSingleGammaFlatPt8To150", scenario="2026D49", appendGlobalTag=appendglobaltag, version="v2" ),
272  Sample("RelValSingleEFlatPt2To100", scenario="2026D49", appendGlobalTag=appendglobaltag, version="v2" ),
273  Sample("RelValSinglePiFlatPt0p7To10", scenario="2026D49", appendGlobalTag=appendglobaltag, version="v2" )
274 
275 
276 
277  #------------------------------
278  #NORMAL version v1 campaign
279  #Sample("RelValCloseByPGun_CE_H_Fine_300um", scenario="2026D49", appendGlobalTag=appendglobaltag ),
280  #Sample("RelValCloseByPGun_CE_H_Fine_200um", scenario="2026D49", appendGlobalTag=appendglobaltag ),
281  #Sample("RelValCloseByPGun_CE_H_Fine_120um", scenario="2026D49", appendGlobalTag=appendglobaltag ),
282  #Sample("RelValCloseByPGun_CE_H_Coarse_Scint", scenario="2026D49", appendGlobalTag=appendglobaltag ),
283  #Sample("RelValCloseByPGun_CE_H_Coarse_300um", scenario="2026D49", appendGlobalTag=appendglobaltag ),
284  #Sample("RelValCloseByPGun_CE_E_Front_300um", scenario="2026D49", appendGlobalTag=appendglobaltag ),
285  #Sample("RelValCloseByPGun_CE_E_Front_200um", scenario="2026D49", appendGlobalTag=appendglobaltag ),
286  #Sample("RelValCloseByPGun_CE_E_Front_120um", scenario="2026D49", appendGlobalTag=appendglobaltag ),
287  #Sample("RelValSingleGammaFlatPt8To150", scenario="2026D49", appendGlobalTag=appendglobaltag ),
288  #Sample("RelValSingleEFlatPt2To100", scenario="2026D49", appendGlobalTag=appendglobaltag ),
289  #Sample("RelValSinglePiFlatPt0p7To10", scenario="2026D49", appendGlobalTag=appendglobaltag )
290  #------------------------------
291 
292  #Sample("RelValCloseByPGun_CE_H_Fine_300um", scenario="2026D49", appendGlobalTag=appendglobaltag + "_HGCal" ),
293  #Sample("RelValCloseByPGun_CE_H_Fine_200um", scenario="2026D49", appendGlobalTag=appendglobaltag + "_HGCal" ),
294  #Sample("RelValCloseByPGun_CE_H_Fine_120um", scenario="2026D49", appendGlobalTag=appendglobaltag + "_HGCal" ),
295  #Sample("RelValCloseByPGun_CE_H_Coarse_Scint", scenario="2026D49", appendGlobalTag=appendglobaltag + "_HGCal" ),
296  #Sample("RelValCloseByPGun_CE_H_Coarse_300um", scenario="2026D49", appendGlobalTag=appendglobaltag + "_HGCal" ),
297  #Sample("RelValCloseByPGun_CE_E_Front_300um", scenario="2026D49", appendGlobalTag=appendglobaltag + "_HGCal" ),
298  #Sample("RelValCloseByPGun_CE_E_Front_200um", scenario="2026D49", appendGlobalTag=appendglobaltag + "_HGCal" ),
299  #Sample("RelValCloseByPGun_CE_E_Front_120um", scenario="2026D49", appendGlobalTag=appendglobaltag + "_HGCal" ),
300  #Sample("RelValSingleGammaFlatPt8To150", scenario="2026D49", appendGlobalTag=appendglobaltag + "_HGCal" ),
301  #Sample("RelValSingleEFlatPt2To100", scenario="2026D49", appendGlobalTag=appendglobaltag + "_HGCal" ),
302  #Sample("RelValSinglePiFlatPt0p7To10", scenario="2026D49", appendGlobalTag=appendglobaltag + "_HGCal" )
303 
304 
305  #Sample("RelValQCD_Pt20toInfMuEnrichPt15", midfix="14", scenario="2026D49", appendGlobalTag=appendglobaltag ),
306  #Sample("RelValDisplacedMuPt30To100", scenario="2026D49", appendGlobalTag=appendglobaltag ),
307  #Sample("RelValDisplacedMuPt2To10", scenario="2026D49", appendGlobalTag=appendglobaltag ),
308  #Sample("RelValDisplacedMuPt10To30", scenario="2026D49", appendGlobalTag=appendglobaltag ),
309  #Sample("RelValB0ToKstarMuMu", midfix="14TeV", scenario="2026D49", appendGlobalTag=appendglobaltag ),
310  #Sample("RelValBsToEleEle", midfix="14TeV", scenario="2026D49", appendGlobalTag=appendglobaltag ),
311  #Sample("RelValBsToMuMu", midfix="14TeV", scenario="2026D49", appendGlobalTag=appendglobaltag ),
312  #Sample("RelValBsToJpsiGamma", midfix="14TeV", scenario="2026D49", appendGlobalTag=appendglobaltag ),
313  #Sample("RelValBsToJpsiPhi_mumuKK", midfix="14TeV", scenario="2026D49", appendGlobalTag=appendglobaltag ),
314  #Sample("RelValBsToPhiPhi_KKKK", midfix="14TeV", scenario="2026D49", appendGlobalTag=appendglobaltag ),
315  #Sample("RelValTauToMuMuMu", midfix="14TeV", scenario="2026D49", appendGlobalTag=appendglobaltag ),
316  #Sample("RelValSingleTauFlatPt2To150", scenario="2026D49", appendGlobalTag=appendglobaltag ),
317  #Sample("RelValSingleMuFlatPt0p7To10", scenario="2026D49", appendGlobalTag=appendglobaltag )
318 
319 ]
320 
321 phase2samples_noPU.extend(phase2samples_noPU_extend)
322 phase2samples_noPU.extend(phase2samples_noPU_extend_more)
323 #phase2samples_noPU.extend(phase2samples_noPU_oldnaming)
324 
325 #phase2samples_noPU = [
326 # Sample("RelValCloseByPGun_CE_E_Front_300um", scenario="2026D49", appendGlobalTag=appendglobaltag ),
327 # Sample("RelValCloseByPGun_CE_E_Front_200um", scenario="2026D49", appendGlobalTag=appendglobaltag )
328 #]
329 
330 #For the PU samples
331 phase2samples_PU = [
332  Sample("RelValTTbar", midfix="14TeV", scenario="2026D49", putype=putype("25ns"), punum=200, appendGlobalTag="_2026D49PU200", version="v2"),
333 ]
334 
335 # Reference and new repository
336 RefRepository = '%s' %(opt.INPUT)
337 NewRepository = '%s' %(opt.INPUT)
338 
339 #------------------------------------------------------------------------------------------
340 #Download section: The basic HGCal validation object is created and the DQM files of the
341 # DQM files of the RelVals are downloaded.
342 #------------------------------------------------------------------------------------------
343 
344 #Create basic object for the HGCal validation plots
345 val = Validation(
346  fullsimSamples = phase2samples_noPU,
347  fastsimSamples = [],
348  refRelease=RefRelease, refRepository=RefRepository,
349  newRelease=NewRelease, newRepository=NewRepository
350 )
351 
352 #------------------------------------------------------------------------------------------
353 #Download the DQM files of the RelVals.
354 if(opt.DOWNLOAD):
355  val.download()
356 
357  #Keep them in eos, save afs space.
358  if (not os.path.isdir(RefRepository+'/'+NewRelease)) :
359  processCmd('mkdir -p '+RefRepository+'/'+NewRelease)
360 
361  for infi in phase2samples_noPU:
362  if "_HGCal" in infi.filename(NewRelease):
363  processCmd('mv ' + infi.filename(NewRelease) + ' ' + infi.filename(NewRelease).replace("_HGCal",""))
364  processCmd('mv ' + infi.filename(NewRelease).replace("_HGCal","") + ' ' + RefRepository+'/'+NewRelease)
365  else:
366  #processCmd('mv ' + infi.filename(NewRelease) + ' ' + infi.filename(NewRelease).replace("2026D49noPU-v2","2026D49noPU-v1"))
367  #processCmd('mv ' + infi.filename(NewRelease).replace("2026D49noPU-v2","2026D49noPU-v1") + ' ' + RefRepository+'/'+NewRelease)
368  processCmd('mv ' + infi.filename(NewRelease) + ' ' + RefRepository+'/'+NewRelease)
369 
370 #------------------------------------------------------------------------------------------
371 #Objects processing section: The objects defined in --Obj are analyzed here.
372 #------------------------------------------------------------------------------------------
373 
374 #This is the hgcalLayerClusters, ticlMultiClustersFromTrackstersEM, ticlMultiClustersFromTrackstersHAD, and hitCalibration part
375 if (opt.OBJ == 'hgcalLayerClusters' or opt.OBJ == 'hitCalibration' or opt.OBJ == 'ticlMultiClustersFromTrackstersEM' or opt.OBJ == 'ticlMultiClustersFromTrackstersHAD' or opt.OBJ == 'allTiclMultiClusters'):
376  fragments = []
377  #Now that we have them in eos lets produce plots
378  #Let's loop through RelVals
379  for infi in phase2samples_noPU:
380  samplename = infi.filename(NewRelease).replace("DQM_V0001_R000000001__","").replace("__DQMIO.root","")
381  #samplename = infi.filename(NewRelease).replace("DQM_V0001_R000000001__","").split("__CMSSW_10_6_0_pre4",1)[0]
382  #samplename = samplename + infi.pileup()
383  if infi.pileup() == "PU":
384  samplename = samplename + str(infi.pileupNumber())
385 
386  #print( infi.name() )
387  print(_sampleName[infi.name()])
388  print("="*40)
389  print(samplename)
390  print("="*40)
391 
392  inputpathRef = ""
393  if RefRelease != None: inputpathRef = RefRepository +'/' + RefRelease +'/'
394  inputpathNew = NewRepository +'/' + NewRelease+ '/'
395 
396  if RefRelease == None:
397  cmd = 'python Validation/HGCalValidation/scripts/makeHGCalValidationPlots.py ' + inputpathNew + infi.filename(NewRelease) + ' --outputDir HGCValid_%s_Plots --no-ratio --png --separate --html-sample "%s" ' %(opt.HTMLVALNAME, _sampleName[infi.name()] ) + ' --html-validation-name %s --subdirprefix ' %(opt.HTMLVALNAME) + ' plots_%s' % (samplename)+ ' --collection %s' %(opt.HTMLVALNAME)
398  elif "raw" in NotNormalRelease and "normal" in NotNormalRefRelease:
399  cmd = 'python Validation/HGCalValidation/scripts/makeHGCalValidationPlots.py ' + inputpathRef + infi.filename(RefRelease).replace("mcRun4_realistic_v3_2026D76noPU-v1","mcRun4_realistic_v3_2026D49noPU-v1") + ' ' + inputpathNew + infi.filename(NewRelease) + ' --outputDir HGCValid_%s_Plots --no-ratio --png --separate --html-sample "%s" ' %(opt.HTMLVALNAME, _sampleName[infi.name()] ) + ' --html-validation-name %s --subdirprefix ' %(opt.HTMLVALNAME) + ' plots_%s' % (samplename) + ' --collection %s' %(opt.HTMLVALNAME)
400  #cmd = 'python Validation/HGCalValidation/scripts/makeHGCalValidationPlots.py ' + inputpathRef + infi.filename(RefRelease).replace("mcRun4_realistic_v3_2026D49noPU_raw1100_rsb-v1","mcRun4_realistic_v3_2026D49noPU-v1") + ' ' + inputpathNew + infi.filename(NewRelease) + ' --outputDir HGCValid_%s_Plots --no-ratio --png --separate --html-sample "%s" ' %(opt.HTMLVALNAME, _sampleName[infi.name()] ) + ' --html-validation-name %s --subdirprefix ' %(opt.HTMLVALNAME) + ' plots_%s' % (samplename) + ' --collection %s' %(opt.HTMLVALNAME)
401  elif "raw" in NotNormalRelease and "raw" in NotNormalRefRelease:
402  #cmd = 'python Validation/HGCalValidation/scripts/makeHGCalValidationPlots.py ' + inputpathRef + infi.filename(RefRelease) + ' ' + inputpathNew + infi.filename(NewRelease) + ' --outputDir HGCValid_%s_Plots --no-ratio --png --separate --html-sample "%s" ' %(opt.HTMLVALNAME, _sampleName[infi.name()] ) + ' --html-validation-name %s --subdirprefix ' %(opt.HTMLVALNAME) + ' plots_%s' % (samplename) + ' --collection %s' %(opt.HTMLVALNAME)
403  cmd = 'python Validation/HGCalValidation/scripts/makeHGCalValidationPlots.py ' + inputpathRef + infi.filename(RefRelease).replace("_raw1100","_raw1100_rsb") + ' ' + inputpathNew + infi.filename(NewRelease) + ' --outputDir HGCValid_%s_Plots --no-ratio --png --separate --html-sample "%s" ' %(opt.HTMLVALNAME, _sampleName[infi.name()] ) + ' --html-validation-name %s --subdirprefix ' %(opt.HTMLVALNAME) + ' plots_%s' % (samplename) + ' --collection %s' %(opt.HTMLVALNAME)
404  elif "normal" in NotNormalRelease and "normal" in NotNormalRefRelease:
405  #cmd = 'python Validation/HGCalValidation/scripts/makeHGCalValidationPlots.py ' + inputpathRef + infi.filename(RefRelease) + ' ' + inputpathNew + infi.filename(NewRelease) + ' --outputDir HGCValid_%s_Plots --no-ratio --png --separate --html-sample "%s" ' %(opt.HTMLVALNAME, _sampleName[infi.name()] ) + ' --html-validation-name %s --subdirprefix ' %(opt.HTMLVALNAME) + ' plots_%s' % (samplename) + ' --collection %s' %(opt.HTMLVALNAME)
406  cmd = 'python Validation/HGCalValidation/scripts/makeHGCalValidationPlots.py ' + inputpathRef + infi.filename(RefRelease).replace("2026D49noPU-v2","2026D49noPU-v1") + ' ' + inputpathNew + infi.filename(NewRelease) + ' --outputDir HGCValid_%s_Plots --no-ratio --png --separate --html-sample "%s" ' %(opt.HTMLVALNAME, _sampleName[infi.name()] ) + ' --html-validation-name %s --subdirprefix ' %(opt.HTMLVALNAME) + ' plots_%s' % (samplename) + ' --collection %s' %(opt.HTMLVALNAME)
407  else:
408  #print inputpathRef, infi.filename(RefRelease).replace("D49","D41")
409  #YOU SHOULD INSPECT EACH TIME THIS COMMAND AND THE REPLACE
410  #cmd = 'python Validation/HGCalValidation/scripts/makeHGCalValidationPlots.py ' + inputpathRef + infi.filename(RefRelease).replace("D49","D41").replace("200-v2","200-v1") + ' ' + inputpathNew + infi.filename(NewRelease) + ' --outputDir HGCValid_%s_Plots --no-ratio --png --separate --html-sample "%s" ' %(opt.HTMLVALNAME, _sampleName[infi.name()] ) + ' --html-validation-name %s --subdirprefix ' %(opt.HTMLVALNAME) + ' plots_%s' % (samplename) + ' --collection %s' %(opt.HTMLVALNAME) .replace("v2__", "v1__")
411  cmd = 'python Validation/HGCalValidation/scripts/makeHGCalValidationPlots.py ' + inputpathRef + infi.filename(RefRelease).replace("mcRun4_realistic_v2-v1", "mcRun4_realistic_v2_2026D49noPU-v1") + ' ' + inputpathNew + infi.filename(NewRelease) + ' --outputDir HGCValid_%s_Plots --no-ratio --png --separate --html-sample "%s" ' %(opt.HTMLVALNAME, _sampleName[infi.name()] ) + ' --html-validation-name %s --subdirprefix ' %(opt.HTMLVALNAME) + ' plots_%s' % (samplename) + ' --collection %s' %(opt.HTMLVALNAME)
412  print(cmd)
413 
414  if(opt.DRYRUN):
415  print('Dry-run: ['+cmd+']')
416  else:
417  output = processCmd(cmd)
418  if opt.OBJ == 'hgcalLayerClusters':
419  processCmd('mv HGCValid_%s_Plots/plots_%s_Layer\ Clusters.html HGCValid_%s_Plots/index.html'%(opt.HTMLVALNAME,samplename,opt.HTMLVALNAME))
420  processCmd('awk \'NR>=6&&NR<=589\' HGCValid_%s_Plots/index.html > HGCValid_%s_Plots/index_%s.html '% (opt.HTMLVALNAME,opt.HTMLVALNAME, samplename))
421  processCmd('echo " <br/>" >> HGCValid_%s_Plots/index_%s.html '%(opt.HTMLVALNAME, samplename) )
422  processCmd('echo " <hr>" >> HGCValid_%s_Plots/index_%s.html '%(opt.HTMLVALNAME, samplename) )
423 
424  if opt.OBJ == 'hitCalibration':
425  #processCmd('indexname=`ls HGCValid_%s_Plots/plots_*.html`; mv ${indexname} HGCValid_%s_Plots/index.html;'%(opt.HTMLVALNAME,opt.HTMLVALNAME))
426  processCmd('mv HGCValid_%s_Plots/plots_%s_Calibrated\ RecHits.html HGCValid_%s_Plots/index.html'%(opt.HTMLVALNAME,samplename,opt.HTMLVALNAME))
427  processCmd('sed -i \'s/Calibrated\ RecHits//g\' HGCValid_%s_Plots/index.html'%(opt.HTMLVALNAME) )
428  processCmd('awk \'NR>=6&&NR<=27\' HGCValid_%s_Plots/index.html > HGCValid_%s_Plots/index_%s.html '% (opt.HTMLVALNAME,opt.HTMLVALNAME, samplename))
429  processCmd('echo " <br/>" >> HGCValid_%s_Plots/index_%s.html '%(opt.HTMLVALNAME, samplename) )
430  processCmd('echo " <hr>" >> HGCValid_%s_Plots/index_%s.html '%(opt.HTMLVALNAME, samplename) )
431 
432  if opt.OBJ == 'ticlMultiClustersFromTrackstersEM' or opt.OBJ == 'ticlMultiClustersFromTrackstersHAD' or opt.OBJ == 'allTiclMultiClusters':
433  processCmd('mv HGCValid_%s_Plots/plots_%s_MultiClusters.html HGCValid_%s_Plots/index.html'%(opt.HTMLVALNAME,samplename,opt.HTMLVALNAME))
434  processCmd('awk \'NR>=6&&NR<=141\' HGCValid_%s_Plots/index.html > HGCValid_%s_Plots/index_%s.html '% (opt.HTMLVALNAME,opt.HTMLVALNAME, samplename))
435  processCmd('echo " <br/>" >> HGCValid_%s_Plots/index_%s.html '%(opt.HTMLVALNAME, samplename) )
436  processCmd('echo " <hr>" >> HGCValid_%s_Plots/index_%s.html '%(opt.HTMLVALNAME, samplename) )
437 
438 
439  fragments.append( 'HGCValid_%s_Plots/index_%s.html'% (opt.HTMLVALNAME, samplename) )
440 
441 
442  #Let's also create the final index xml file.
443  processCmd('mv HGCValid_%s_Plots/index.html HGCValid_%s_Plots/test.html' %(opt.HTMLVALNAME,opt.HTMLVALNAME) )
444  index_file = open('HGCValid_%s_Plots/index.html'%(opt.HTMLVALNAME),'w')
445  #Write preamble
446  index_file.write('<html>\n')
447  index_file.write(' <head>\n')
448  index_file.write(' <title>HGCal validation %s </title>\n' %(opt.HTMLVALNAME) )
449  index_file.write(' </head>\n')
450  index_file.write(' <body>\n')
451 
452  for frag in fragments:
453  with open(frag,'r') as f:
454  lines = f.read().splitlines()
455  for line in lines:
456  print(line)
457  index_file.write(line + '\n')
458  #processCmd( 'cat ' + frag + ' >> HGCalValidationPlots/index.html ' )
459  #index_file.write(frag)
460 
461 
462  #Writing postamble"
463  index_file.write(' </body>\n')
464  index_file.write('</html>\n')
465  index_file.close()
466 
467 #------------------------------------------------------------------------------------------
468 #This is the SimHits part
469 if (opt.OBJ == 'SimHits'):
470  #This is where we will save the final output pngs:
471  if (not os.path.isdir("hgcalSimHitStudy")) :
472  processCmd('mkdir -p hgcalSimHitStudy')
473  #Prepare for www
474  processCmd('cp %s/../public/index.php hgcalSimHitStudy/.'%(opt.WWWAREA) )
475 
476  #The input to this is for the moment 100 GeV muon from runnin cmsRun runHGCalSimHitStudy_cfg.py
477  #Input: hgcSimHits.root
478  cmd = 'root.exe -b -q Validation/HGCalValidation/macros/validationplots.C\(\\"hgcSimHit.root' + '\\",\\"'+ opt.OBJ + '\\"\)'
479  if(opt.DRYRUN):
480  print('Dry-run: ['+cmd+']')
481  else:
482  output = processCmd(cmd)
483 
484 #------------------------------------------------------------------------------------------
485 if (opt.OBJ == 'hitValidation'):
486  fragments = []
487  #Now that we have them in eos lets produce plots
488  #Let's loop through RelVals
489  for infi in phase2samples_noPU:
490  samplename = infi.filename(NewRelease).replace("DQM_V0001_R000000001__","").replace("__DQMIO.root","")
491  #samplename = infi.filename(NewRelease).replace("DQM_V0001_R000000001__","").split("__CMSSW_10_6_0_pre4",1)[0]
492  #samplename = samplename + infi.pileup()
493  if infi.pileup() == "PU":
494  samplename = samplename + str(infi.pileupNumber())
495 
496  print("="*40)
497  print(samplename)
498  print("="*40)
499 
500  inputpathRef = ""
501  if RefRelease != None: inputpathRef = RefRepository +'/' + RefRelease +'/'
502  inputpathNew = NewRepository +'/' + NewRelease+ '/'
503 
504  if RefRelease == None:
505  cmd = 'python Validation/HGCalValidation/scripts/makeHGCalValidationPlots.py ' + inputpathNew + infi.filename(NewRelease) + ' --outputDir HGCValid_%s_Plots --no-ratio --png --separate --html-sample "%s" ' %(opt.HTMLVALNAME, _sampleName[infi.name()] ) + ' --html-validation-name %s --subdirprefix ' %(opt.HTMLVALNAME) + ' plots_%s' % (samplename)+ ' --collection %s' %(opt.HTMLVALNAME)
506  elif "raw" in NotNormalRelease and "normal" in NotNormalRefRelease:
507  cmd = 'python Validation/HGCalValidation/scripts/makeHGCalValidationPlots.py ' + inputpathRef + infi.filename(RefRelease).replace("mcRun4_realistic_v3_2026D76noPU-v1","mcRun4_realistic_v3_2026D49noPU-v1") + ' ' + inputpathNew + infi.filename(NewRelease) + ' --outputDir HGCValid_%s_Plots --no-ratio --png --separate --html-sample "%s" ' %(opt.HTMLVALNAME, _sampleName[infi.name()] ) + ' --html-validation-name %s --subdirprefix ' %(opt.HTMLVALNAME) + ' plots_%s' % (samplename) + ' --collection %s' %(opt.HTMLVALNAME)
508  #cmd = 'python Validation/HGCalValidation/scripts/makeHGCalValidationPlots.py ' + inputpathRef + infi.filename(RefRelease).replace("mcRun4_realistic_v3_2026D49noPU_raw1100_rsb-v1","mcRun4_realistic_v3_2026D49noPU-v1") + ' ' + inputpathNew + infi.filename(NewRelease) + ' --outputDir HGCValid_%s_Plots --no-ratio --png --separate --html-sample "%s" ' %(opt.HTMLVALNAME, _sampleName[infi.name()] ) + ' --html-validation-name %s --subdirprefix ' %(opt.HTMLVALNAME) + ' plots_%s' % (samplename) + ' --collection %s' %(opt.HTMLVALNAME)
509  elif "raw" in NotNormalRelease and "raw" in NotNormalRefRelease:
510  #cmd = 'python Validation/HGCalValidation/scripts/makeHGCalValidationPlots.py ' + inputpathRef + infi.filename(RefRelease) + ' ' + inputpathNew + infi.filename(NewRelease) + ' --outputDir HGCValid_%s_Plots --no-ratio --png --separate --html-sample "%s" ' %(opt.HTMLVALNAME, _sampleName[infi.name()] ) + ' --html-validation-name %s --subdirprefix ' %(opt.HTMLVALNAME) + ' plots_%s' % (samplename) + ' --collection %s' %(opt.HTMLVALNAME)
511  cmd = 'python Validation/HGCalValidation/scripts/makeHGCalValidationPlots.py ' + inputpathRef + infi.filename(RefRelease).replace("_raw1100","_raw1100_rsb") + ' ' + inputpathNew + infi.filename(NewRelease) + ' --outputDir HGCValid_%s_Plots --no-ratio --png --separate --html-sample "%s" ' %(opt.HTMLVALNAME, _sampleName[infi.name()] ) + ' --html-validation-name %s --subdirprefix ' %(opt.HTMLVALNAME) + ' plots_%s' % (samplename) + ' --collection %s' %(opt.HTMLVALNAME)
512  elif "normal" in NotNormalRelease and "normal" in NotNormalRefRelease:
513  #cmd = 'python Validation/HGCalValidation/scripts/makeHGCalValidationPlots.py ' + inputpathRef + infi.filename(RefRelease) + ' ' + inputpathNew + infi.filename(NewRelease) + ' --outputDir HGCValid_%s_Plots --no-ratio --png --separate --html-sample "%s" ' %(opt.HTMLVALNAME, _sampleName[infi.name()] ) + ' --html-validation-name %s --subdirprefix ' %(opt.HTMLVALNAME) + ' plots_%s' % (samplename) + ' --collection %s' %(opt.HTMLVALNAME)
514  cmd = 'python Validation/HGCalValidation/scripts/makeHGCalValidationPlots.py ' + inputpathRef + infi.filename(RefRelease).replace("2026D49noPU-v2","2026D49noPU-v1") + ' ' + inputpathNew + infi.filename(NewRelease) + ' --outputDir HGCValid_%s_Plots --no-ratio --png --separate --html-sample "%s" ' %(opt.HTMLVALNAME, _sampleName[infi.name()] ) + ' --html-validation-name %s --subdirprefix ' %(opt.HTMLVALNAME) + ' plots_%s' % (samplename) + ' --collection %s' %(opt.HTMLVALNAME)
515  else:
516  #cmd = 'python Validation/HGCalValidation/scripts/makeHGCalValidationPlots.py ' + inputpathRef + infi.filename(RefRelease).replace("D49","D41").replace("200-v2","200-v1") + ' ' + inputpathNew + infi.filename(NewRelease) + ' --outputDir HGCValid_%s_Plots --no-ratio --png --separate --html-sample "%s" ' %(opt.HTMLVALNAME, _sampleName[infi.name()] ) + ' --html-validation-name %s --subdirprefix ' %(opt.HTMLVALNAME) + ' plots_%s' % (samplename) + ' --collection %s' %(opt.HTMLVALNAME)
517  cmd = 'python Validation/HGCalValidation/scripts/makeHGCalValidationPlots.py ' + inputpathRef + infi.filename(RefRelease).replace("mcRun4_realistic_v2-v1", "mcRun4_realistic_v2_2026D49noPU-v1") + ' ' + inputpathNew + infi.filename(NewRelease) + ' --outputDir HGCValid_%s_Plots --no-ratio --png --separate --html-sample "%s" ' %(opt.HTMLVALNAME, _sampleName[infi.name()] ) + ' --html-validation-name %s --subdirprefix ' %(opt.HTMLVALNAME) + ' plots_%s' % (samplename) + ' --collection %s' %(opt.HTMLVALNAME)
518  #cmd = 'python Validation/HGCalValidation/scripts/makeHGCalValidationPlots.py ' + inputpathRef + infi.filename(RefRelease) + ' ' + inputpathNew + infi.filename(NewRelease) + ' --outputDir HGCValid_%s_Plots --no-ratio --png --separate --html-sample "%s" ' %(opt.HTMLVALNAME, _sampleName[infi.name()] ) + ' --html-validation-name %s --subdirprefix ' %(opt.HTMLVALNAME) + ' plots_%s' % (samplename) + ' --collection %s' %(opt.HTMLVALNAME)
519 
520 
521  if(opt.DRYRUN):
522  print('Dry-run: ['+cmd+']')
523  else:
524  output = processCmd(cmd)
525  processCmd('mv HGCValid_%s_Plots/plots_%s_Hits.html HGCValid_%s_Plots/index.html'%(opt.HTMLVALNAME,samplename,opt.HTMLVALNAME))
526  processCmd('awk \'NR>=6&&NR<=184\' HGCValid_%s_Plots/index.html > HGCValid_%s_Plots/index_%s.html '% (opt.HTMLVALNAME,opt.HTMLVALNAME, samplename))
527  processCmd('echo " <br/>" >> HGCValid_%s_Plots/index_%s.html '%(opt.HTMLVALNAME, samplename) )
528  processCmd('echo " <hr>" >> HGCValid_%s_Plots/index_%s.html '%(opt.HTMLVALNAME, samplename) )
529 
530  fragments.append( 'HGCValid_%s_Plots/index_%s.html'% (opt.HTMLVALNAME, samplename) )
531 
532 
533  #Let's also create the final index xml file.
534  processCmd('mv HGCValid_%s_Plots/index.html HGCValid_%s_Plots/test.html' %(opt.HTMLVALNAME,opt.HTMLVALNAME) )
535  index_file = open('HGCValid_%s_Plots/index.html'%(opt.HTMLVALNAME),'w')
536  #Write preamble
537  index_file.write('<html>\n')
538  index_file.write(' <head>\n')
539  index_file.write(' <title>HGCal validation %s </title>\n' %(opt.HTMLVALNAME) )
540  index_file.write(' </head>\n')
541  index_file.write(' <body>\n')
542 
543  for frag in fragments:
544  with open(frag,'r') as f:
545  lines = f.read().splitlines()
546  for line in lines:
547  print(line)
548  index_file.write(line + '\n')
549  #processCmd( 'cat ' + frag + ' >> HGCalValidationPlots/index.html ' )
550  #index_file.write(frag)
551 
552 
553  #Writing postamble"
554  index_file.write(' </body>\n')
555  index_file.write('</html>\n')
556  index_file.close()
557 
558 #-------------------------------------------------------------------------------------------
559 #This is the Digis part
560 if (opt.OBJ == 'Digis'):
561  #This is where we will save the final output pngs:
562  if (not os.path.isdir("hgcalDigiStudy")) :
563  processCmd('mkdir -p hgcalDigiStudy')
564  processCmd('mkdir -p hgcalDigiStudyEE')
565  processCmd('mkdir -p hgcalDigiStudyHEF')
566  processCmd('mkdir -p hgcalDigiStudyHEB')
567  #Prepare for www
568  processCmd('cp %s/../public/index.php hgcalDigiStudy/.'%(opt.WWWAREA) )
569  processCmd('cp %s/../public/index.php hgcalDigiStudyEE/.'%(opt.WWWAREA) )
570  processCmd('cp %s/../public/index.php hgcalDigiStudyHEF/.'%(opt.WWWAREA) )
571  processCmd('cp %s/../public/index.php hgcalDigiStudyHEB/.'%(opt.WWWAREA) )
572  #The input here is from running cmsRun runHGCalDigiStudy_cfg.py, to which
573  #we usually give ttbar noPU as input
574  #Input: hgcDigi.root
575  cmd = 'root.exe -b -q Validation/HGCalValidation/macros/validationplots.C\(\\"hgcDigi.root' + '\\",\\"'+ opt.OBJ + '\\"\)'
576  if(opt.DRYRUN):
577  print('Dry-run: ['+cmd+']')
578  else:
579  output = processCmd(cmd)
580  #mv the output under the main directory
581  processCmd('mv hgcalDigiStudyEE hgcalDigiStudy/.')
582  processCmd('mv hgcalDigiStudyHEF hgcalDigiStudy/.')
583  processCmd('mv hgcalDigiStudyHEB hgcalDigiStudy/.')
584 
585 #-------------------------------------------------------------------------------------------
586 #This is the RecHits part
587 if (opt.OBJ == 'RecHits'):
588  #This is where we will save the final output pngs:
589  if (not os.path.isdir("hgcalRecHitStudy")) :
590  processCmd('mkdir -p hgcalRecHitStudy')
591  processCmd('mkdir -p hgcalRecHitStudyEE')
592  processCmd('mkdir -p hgcalRecHitStudyHEF')
593  processCmd('mkdir -p hgcalRecHitStudyHEB')
594  #Prepare for www
595  processCmd('cp %s/../public/index.php hgcalRecHitStudy/.'%(opt.WWWAREA) )
596  processCmd('cp %s/../public/index.php hgcalRecHitStudyEE/.'%(opt.WWWAREA) )
597  processCmd('cp %s/../public/index.php hgcalRecHitStudyHEF/.'%(opt.WWWAREA) )
598  processCmd('cp %s/../public/index.php hgcalRecHitStudyHEB/.'%(opt.WWWAREA) )
599  #The input here is from running cmsRun runHGCalRecHitStudy_cfg.py, to which
600  #we usually give ttbar noPU as input
601  #Input: hgcRecHit.root
602  cmd = 'root.exe -b -q Validation/HGCalValidation/macros/validationplots.C\(\\"hgcRecHit.root' + '\\",\\"'+ opt.OBJ + '\\"\)'
603  if(opt.DRYRUN):
604  print('Dry-run: ['+cmd+']')
605  else:
606  output = processCmd(cmd)
607  #mv the output under the main directory
608  processCmd('mv hgcalRecHitStudyEE hgcalRecHitStudy/.')
609  processCmd('mv hgcalRecHitStudyHEF hgcalRecHitStudy/.')
610  processCmd('mv hgcalRecHitStudyHEB hgcalRecHitStudy/.')
611 
612 #-------------------------------------------------------------------------------------------
613 
614 if (opt.OBJ == 'CaloParticles'):
615  particletypes = ["-11","-13","-211","-321","11","111","13","211","22","321"]
616  #This is where we will save the final output pngs:
617  if (not os.path.isdir("CaloParticles")) :
618  processCmd('mkdir -p CaloParticles')
619  #Prepare for www
620  processCmd('cp %s/../public/index.php CaloParticles/.'%(opt.WWWAREA) )
621 
622  #Let's loop through RelVals
623  for infi in phase2samples_noPU:
624  #samplename = infi.filename(NewRelease).replace("DQM_V0001_R000000001__","").replace("__DQMIO.root","")
625  samplename = infi.filename(NewRelease).replace("DQM_V0001_R000000001__","").split("__"+NewRelease,1)[0]
626  samplename = samplename + infi.pileup()
627  if infi.pileup() == "PU":
628  samplename = samplename + str(infi.pileupNumber())
629 
630  print("="*40)
631  print(samplename)
632  print("="*40)
633  if (not os.path.isdir(samplename)) :
634  processCmd('mkdir -p ' + samplename )
635  processCmd('cp %s/RelVals/index.php '%(opt.WWWAREA) + samplename + '/.')
636  for part in particletypes:
637  processCmd('mkdir -p ' + samplename + '/' +part )
638  #Prepare for www
639  processCmd('cp %s/RelVals/index.php '%(opt.WWWAREA) + samplename + '/' +part + '/.')
640 
641  inputpathRef = ""
642  if RefRelease != None: inputpathRef = RefRepository +'/' + RefRelease +'/'
643  inputpathNew = NewRepository +'/' + NewRelease+ '/'
644  cmd = 'root.exe -b -q Validation/HGCalValidation/macros/validationplots.C\(\\"'+ inputpathNew + infi.filename(NewRelease) + '\\",\\"'+ opt.OBJ + '\\",\\"'+ samplename + '\\"\\)'
645  if(opt.DRYRUN):
646  print('Dry-run: ['+cmd+']')
647  else:
648  output = processCmd(cmd)
649  processCmd('mv ' +samplename+ ' CaloParticles/.' )
650 
651 #------------------------------------------------------------------------------------------
652 #Summary section: After processing all the objects the results are gathered, webpages are
653 # created and a summary page is added.
654 #-------------------------------------------------------------------------------------------
655 #Here we will gather all results.
656 if (opt.GATHER != None) :
657 
658  #First we need the top folder to contain all validation releases.
659  index_file = open('index.html','w')
660  #Write preamble
661  index_file.write('<html>\n')
662  index_file.write(' <head>\n')
663  index_file.write(' <title>HGCAL validation results </title>\n' )
664  index_file.write(' </head>\n')
665  index_file.write(' <body>\n')
666  index_file.write(' <h1>\n')
667  index_file.write(' HGCAL Validation Results \n' )
668  index_file.write(' </h1>\n')
669  index_file.write(' <hr/>\n' )
670  index_file.write(' <h2>\n')
671  index_file.write(' Release Validation Campaigns \n' )
672  index_file.write(' </h2>\n')
673  index_file.write(' <ul>\n' )
674 
675  for trel in thereleases.keys():
676  index_file.write(' <li>\n' )
677  index_file.write(' %s\n' %(trel) )
678  for rel in thereleases[trel]:
679  index_file.write(' <ul>\n' )
680  index_file.write(' <li><a href="%s/index.html">%s</a></li>\n' %(rel, rel ) )
681  index_file.write(' </ul>\n' )
682  index_file.write(' </li>\n' )
683  index_file.write(' <br>\n' )
684  index_file.write(' <br>\n' )
685  index_file.write(' <br>\n' )
686 
687  index_file.write(' </ul>\n' )
688  index_file.write(' <hr/>\n' )
689 
690  #New section : Geometry Validation
691  #Regardless of the release validation, the top html menu should contain the geometry section.
692  #we put this in the "gather" step.
693  index_file.write(' <h2>\n')
694  index_file.write(' Geometry Validation \n' )
695  index_file.write(' </h2>\n')
696  index_file.write(' <ul>\n' )
697 
698  for tgeo in geometryTests.keys():
699  index_file.write(' <li>\n' )
700  index_file.write(' %s\n' %(tgeo) )
701  for geo in geometryTests[tgeo]:
702  #We need the directory for the geometry related results
703  if (not os.path.isdir(geo)):
704  processCmd('mkdir -p %s/%s' %(opt.WWWAREA,geo) )
705  processCmd('mkdir -p %s' %(geo) )
706  for mats in _individualmaterials:
707  processCmd('mkdir -p %s/%s/indimat/%s' %(opt.WWWAREA,geo,mats) )
708  processCmd('mkdir -p %s/indimat/%s' %(geo,mats) )
709 
710  index_file.write(' <ul>\n' )
711  index_file.write(' <li><a href="%s/index.html">%s</a></li>\n' %(geo, geo ) )
712  index_file.write(' </ul>\n' )
713  index_file.write(' </li>\n' )
714  index_file.write(' <br>\n' )
715  index_file.write(' <br>\n' )
716  index_file.write(' <br>\n' )
717 
718  #Writing postamble"
719  index_file.write(' </body>\n')
720  index_file.write('</html>\n')
721  index_file.close()
722 
723  #This is the main html file for the validation webpage. In order to avoid
724  #surprises when experimenting, in order to copy it automatically to the
725  #www area you should have activated the relevant flag:
726  if (opt.COPYHTML) : processCmd('cp index.html %s/.' %(opt.WWWAREA) )
727 
728  #Let's make also the summary folder
729  if (not os.path.isdir("HGCValid_summary_Plots")):
730  processCmd('mkdir -p HGCValid_summary_Plots')
731 
732  #To avoid the nans transpose later
733  df = pd.DataFrame.from_dict(_summary, orient = 'index').transpose()
734  #Make a specific order in columns
735  df = df[_summobj]
736 
737  index_file = open('HGCValid_summary_Plots/index.html','w')
738  #Write preamble
739  index_file.write('<html>\n')
740  index_file.write(' <body>\n')
741 
742  #Let's loop through RelVals
743  for infi in phase2samples_noPU:
744  samplename = infi.filename(NewRelease).replace("DQM_V0001_R000000001__","").replace("__DQMIO.root","")
745  index_file.write( '<h2> %s </h2> \n' %(_sampleName[infi.name()]) )
746  #table here with summary objects
747  index_file.write('<table> \n')
748  index_file.write(' <tr>\n')
749  #This is the row with the headers. So, the objects for us.
750  for obj in _summobj:
751  index_file.write(' <th>%s</th>\n' %(_pageNameMap[obj]) )
752  index_file.write(' </tr>\n')
753 
754  for i, row in df.iterrows():
755  index_file.write(' <tr>\n')
756  for j, column in row.iteritems():
757  print(column)
758  index_file.write(' <td>\n')
759  index_file.write(' <ul>\n')
760 
761 # if df[obj][ind] == None:
762  if column == None:
763  index_file.write(' </ul>\n')
764  index_file.write(' </td>\n')
765  continue
766  #index_file.write(' \n')
767  else:
768  #print(df[obj][ind])
769  print(j)
770  #index_file.write(' <li><a href="plots_%s_%s">%s</a></li> \n' %(samplename, df[obj][ind], df[obj][ind].partition("/")[2] ))
771  if "Ticl" in j:
772  index_file.write(' <li><a href="../HGCValid_%s_Plots/plots_%s_%s">%s</a></li> \n' %(j, samplename, column, column.replace("ticlMultiClustersFromTracksters","") ))
773  else:
774  index_file.write(' <li><a href="../HGCValid_%s_Plots/plots_%s_%s">%s</a></li> \n' %(j, samplename, column, column.partition("/")[2] ))
775 
776  index_file.write(' </ul>\n')
777  index_file.write(' </td>\n')
778 
779  index_file.write(' </tr>\n')
780 
781  index_file.write(' </table>\n')
782  index_file.write(' <br/>\n' )
783  index_file.write(' <br/>\n' )
784  index_file.write(' <br/>\n' )
785 
786  #Writing postamble"
787  index_file.write(' </body>\n')
788  index_file.write('</html>\n')
789  index_file.close()
790 
791  objects = opt.GATHER.split(",")
792 
793  localoutputdir = ""
794  if "raw" in NotNormalRelease and "raw" in NotNormalRefRelease:
795  localoutputdir = NewRelease + "_raw1100" + "_vs_" + RefRelease + "_raw1100"
796  elif "raw" in NotNormalRelease and "normal" in NotNormalRefRelease:
797  #localoutputdir = NewRelease + "_raw1100" + "_vs_" + RefRelease
798  localoutputdir = NewRelease + "_D76" + "_vs_" + RefRelease
799  elif "normal" in NotNormalRelease and "normal" in NotNormalRefRelease:
800  localoutputdir = NewRelease + "_vs_" + RefRelease
801  else:
802  localoutputdir = NewRelease
803 
804  #make the structure to hold the objects
805  for obj in objects:
806  #This is where we will save the final output per campaing:
807  if (not os.path.isdir('%s/standalone' %(localoutputdir))) :
808  processCmd('mkdir -p %s/standalone' %(localoutputdir))
809  if (obj!="standalone"): processCmd('mv HGCValid_%s_Plots %s'%(obj, localoutputdir) )
810  else :
811  processCmd('mv hgcalSimHitStudy %s/standalone/.'%(localoutputdir) )
812  processCmd('mv hgcalDigiStudy %s/standalone/.'%(localoutputdir) )
813  processCmd('mv hgcalRecHitStudy %s/standalone/.'%(localoutputdir) )
814  processCmd('cp %s/../public/index.php %s/standalone/.'%(opt.WWWAREA, localoutputdir) )
815 
816  '''
817  #Let's also copy to the summary folder what we need.
818  for infi in phase2samples_noPU:
819  samplename = infi.filename(NewRelease).replace("DQM_V0001_R000000001__","").replace("__DQMIO.root","")
820  for obj in _summobj:
821  #print obj
822  #if obj == "hitValidation" : samplename = samplename + infi.pileup()
823  #else : samplename = infi.filename(NewRelease).replace("DQM_V0001_R000000001__","").replace("__DQMIO.root","")
824  for ind in df.index:
825  if df[obj][ind] == None: continue
826  else: processCmd('cp -r %s/HGCValid_%s_Plots/plots_%s_%s %s/HGCValid_summary_Plots ' %(NewRelease, obj, samplename, df[obj][ind].partition("/")[0], NewRelease ) )
827  '''
828 
829  #html file of the relval campaign we are validating
830  index_file = open('%s/index.html'%(localoutputdir),'w')
831  #Write preamble
832  index_file.write('<html>\n')
833  index_file.write(' <head>\n')
834  index_file.write(' <title> <h2> HGCal validation results for %s </h2> </title>\n' %(localoutputdir) )
835  index_file.write(' </head>\n')
836  index_file.write(' <body>\n')
837  index_file.write(' <h2> HGCal validation results for %s </h2> \n' %(localoutputdir) )
838 
839  for obj in objects:
840  print(obj)
841  if (obj!="standalone"):
842  index_file.write(' <br/>\n' )
843  index_file.write(' <ul>\n' )
844  index_file.write(' <li><a href="HGCValid_%s_Plots/index.html">%s</a></li>\n' %(obj, _pageNameMap[obj] ) )
845  index_file.write(' </ul>\n' )
846  index_file.write(' <br/>\n' )
847  else :
848  index_file.write(' <br/>\n' )
849  index_file.write(' <ul>\n' )
850  index_file.write(' <li><a href="%s/index.php">%s</a></li>\n' %(obj, _pageNameMap[obj] ) )
851  index_file.write(' </ul>\n' )
852  index_file.write(' <br/>\n' )
853 
854 
855  #Writing postamble
856  index_file.write(' </body>\n')
857  index_file.write('</html>\n')
858  index_file.close()
859 
860  #We choose to zip in uncompressed form all the files for two reasons:
861  #1. Copying to eos so many files is really slow. It is faster to
862  # create one uncompressed file, copy that and unzip there.
863  #2. Inevitably, we will have to do some cleanup of the older campaigns,
864  # since we will reach the number of files limit quite easily.
865  # It will be easier to have already save the zip file and just delete
866  # the directory content, leaving inside only the zip file.
867 
868  # This will take some time.
869 # processCmd('zip -0 -r %s.zip %s' %(localoutputdir,localoutputdir) )
870 # processCmd('cp %s.zip %s/.' %(localoutputdir,opt.WWWAREA) )
871 # processCmd('cd %s' %(opt.WWWAREA) )
872 # processCmd('unzip -q %s.zip' %(localoutputdir) )
873 # processCmd('mv %s.zip %s/.' %(localoutputdir,localoutputdir) )
874 # processCmd('cd -')
875 
876 
877 #------------------------------------------------------------------------------------------
878 #Geometry section: Here we gather results from geometry related validation packages.
879 #-------------------------------------------------------------------------------------------
880 #Keep in mind that the gne
881 if (opt.GEOMETRY) :
882  #html file of the geometry scenario we are estimating the material budget
883  index_file = open('%s/index.html'%(GeoScenario),'w')
884  #Write preamble
885  index_file.write('<html>\n')
886  index_file.write(' <head>\n')
887  index_file.write(' <title> <h2> HGCAL material budget results for %s </h2> </title>\n' %(GeoScenario) )
888  index_file.write(' </head>\n')
889  index_file.write(' <body>\n')
890  index_file.write(' <h2> HGCAL material budget results for %s </h2> \n' %(GeoScenario) )
891 
892  for obj in _MatBudSections:
893  print(obj)
894  #We need the directory for the geometry related results
895  if (not os.path.isdir('%s/%s/%s' %(opt.WWWAREA,GeoScenario,obj))):
896  processCmd('mkdir -p %s/%s/%s' %(opt.WWWAREA,GeoScenario,obj) )
897  index_file.write(' <br/>\n' )
898  index_file.write(' <ul>\n' )
899  index_file.write(' <li><a href="%s/index.html">%s</a></li>\n' %(obj, _geoPageNameMap[obj] ) )
900  index_file.write(' </ul>\n' )
901  index_file.write(' <br/>\n' )
902 
903  #Writing postamble
904  index_file.write(' </body>\n')
905  index_file.write('</html>\n')
906  index_file.close()
907 
908  #Copy the material budget menu file in the current geometry scenario
909  processCmd('cp %s/index.html %s/%s/.' %(GeoScenario, opt.WWWAREA,GeoScenario) )
910 
911  #html file for the menu of the individual materials
912  index_file = open('%s/indimat/index.html'%(GeoScenario),'w')
913  #Write preamble
914  index_file.write('<html>\n')
915  index_file.write(' <head>\n')
916  index_file.write(' <title> <h2> HGCAL material budget results for individual materials for %s </h2> </title>\n' %(GeoScenario) )
917  index_file.write(' </head>\n')
918  index_file.write(' <body>\n')
919  index_file.write(' <h2> HGCAL material budget results for individual materials for %s </h2> \n' %(GeoScenario) )
920  for mats in _individualmaterials:
921  print(mats)
922  #index_file.write(' <br/>\n' )
923  index_file.write(' <ul>\n' )
924  index_file.write(' <li><a href="%s/index.html">%s</a></li>\n' %(mats, _matPageNameMap[mats] ) )
925  index_file.write(' </ul>\n' )
926  #index_file.write(' <br/>\n' )
927 
928  #Writing postamble
929  index_file.write(' </body>\n')
930  index_file.write('</html>\n')
931  index_file.close()
932 
933  #Copy the menu html file for the individual materials
934  processCmd('cp %s/indimat/index.html %s/%s/indimat/.' %(GeoScenario, opt.WWWAREA,GeoScenario) )
935 
936  #html file for all HGCal stack plots materials
937  index_file = open('%s/allhgcal/index.html'%(GeoScenario),'w')
938  #Write preamble
939  index_file.write('<html>\n')
940  index_file.write(' <head>\n')
941 
942  index_file.write(' <style>img.Reference{margin: 20px auto 20px auto; border: 10px solid green; border-radius: 10px;}img.New{margin: 20px auto 20px auto; border: 10px solid red; border-radius: 10px;} </style> \n')
943 
944  index_file.write(_hideShowFun["thestyle"])
945 
946  index_file.write(' <title> <h2> HGCAL material budget results for all materials for %s </h2> </title>\n' %(GeoScenario) )
947  index_file.write(' </head>\n')
948  index_file.write(' <body>\n')
949 
950  index_file.write(' <h2> HGCAL material budget results for : <span style="color:red;font-size:120%%" >All Materials </span></h2> \n' )
951 
952  index_file.write('<p> %s plots have a green border followed by the %s plots which features a red border. </p>\n' % (GeoScenario.split("_")[0], GeoScenario.split("_")[2]) )
953 
954  index_file.write('<h2> Geometry: <span style="color:green;" > %s</span>_vs_<span style="color:red;" >%s </span> </h2>\n' % (GeoScenario.split("_")[0], GeoScenario.split("_")[2]) )
955 
956  index_file.write('<hr/>\n')
957 
958  index_file.write(_hideShowFun["divTabs"])
959 
960  for region in ["_AllHGCAL", "_ZminusZoom", "_ZplusZoom"]:
961 
962  index_file.write('<div id="%s" class="tabcontent"> \n' %(region))
963  pngnamestring = ""
964  if region == "_AllHGCAL": pngnamestring = ""
965  else: pngnamestring = region
966 
967  for allmatplot in _allmaterialsplots:
968  if region == "_AllHGCAL":
969  index_file.write('<p> %s <a href="../%s/%s%s.pdf" class="TMLlink">Click to enlarge %s plot</a></p>\n' %(_allmaterialsPlotsDesc[allmatplot], GeoScenario.split("_")[2],allmatplot,pngnamestring,GeoScenario.split("_")[2]))
970  index_file.write('<img class="Reference" src="../%s/%s%s.png" width="375"/> \n' %(GeoScenario.split("_")[0],allmatplot,pngnamestring) )
971  index_file.write('<img class="New" src="../%s/%s%s.png" width="375"/> \n' %(GeoScenario.split("_")[2],allmatplot,pngnamestring))
972  index_file.write('<hr/>\n')
973  elif region != "_AllHGCAL" and "HGCal_l_vs_z_vs_R" in allmatplot:
974  index_file.write('<p> %s <a href="../%s/%s/%s%s.pdf" class="TMLlink">Click to enlarge %s plot</a></p>\n' %(_allmaterialsPlotsDesc[allmatplot], GeoScenario.split("_")[2],region.replace("_Zminus","ZMinus").replace("_Zplus","ZPlus"),allmatplot,pngnamestring,GeoScenario.split("_")[2]))
975  index_file.write('<img class="Reference" src="../%s/%s/%s%s.png" width="375"/> \n' %(GeoScenario.split("_")[0],region.replace("_Zminus","ZMinus").replace("_Zplus","ZPlus"),allmatplot,pngnamestring) )
976  index_file.write('<img class="New" src="../%s/%s/%s%s.png" width="375"/> \n' %(GeoScenario.split("_")[2],region.replace("_Zminus","ZMinus").replace("_Zplus","ZPlus"),allmatplot,pngnamestring))
977  index_file.write('<hr/>\n')
978 
979 
980  index_file.write('</div>\n')
981 
982  index_file.write(_hideShowFun["buttonandFunction"])
983  index_file.write(' </body>\n')
984  index_file.write('</html>\n')
985  index_file.close()
986 
987  #Copy all materials budget file
988  processCmd('cp %s/allhgcal/index.html %s/%s/allhgcal/.' %(GeoScenario, opt.WWWAREA,GeoScenario) )
989 
990  #html file of the individual materials for the material budget analysis
991  for mats in _individualmaterials:
992  index_file = open('%s/indimat/%s/index.html'%(GeoScenario,mats),'w')
993  #Write preamble
994  index_file.write('<html>\n')
995  index_file.write(' <head>\n')
996 
997  index_file.write(' <style>img.Reference{margin: 20px auto 20px auto; border: 10px solid green; border-radius: 10px;}img.New{margin: 20px auto 20px auto; border: 10px solid red; border-radius: 10px;} </style> \n')
998 
999  index_file.write(_hideShowFun["thestyle"])
1000 
1001  index_file.write(' <title> <h2> HGCAL material budget results for individual materials for %s </h2> </title>\n' %(GeoScenario) )
1002  index_file.write(' </head>\n')
1003  index_file.write(' <body>\n')
1004  index_file.write(' <h2> HGCAL material budget results for : <span style="color:red;font-size:120%%" >%s </span></h2> \n' %(_matPageNameMap[mats]) )
1005 
1006  index_file.write('<p> %s plots have a green border followed by the %s plots which features a red border. </p>\n' % (GeoScenario.split("_")[0], GeoScenario.split("_")[2]) )
1007 
1008  index_file.write('<h2> Geometry: <span style="color:green;" > %s</span>_vs_<span style="color:red;" >%s </span> </h2>\n' % (GeoScenario.split("_")[0], GeoScenario.split("_")[2]) )
1009 
1010  index_file.write('<hr/>\n')
1011 
1012  #--------------------------------------------------------------
1013  #This one below is a solution using a table with 3 columns:
1014  #Two for the plots and the third for the text.
1015 
1016  #index_file.write('<table style=\'font-size:120%%\' border="1" cellspacing="1" cellpadding="0">\n')
1017  #index_file.write('<tbody>\n')
1018 
1019  #for indiplots in _individualmatplots:
1020  # index_file.write('<tr>\n')
1021  # index_file.write('<td> <img class="Reference" src="../../%s/%s/%s%s.png" width="375"/> </td>\n' %(GeoScenario.split("_")[0],mats,indiplots,mats) )
1022  # index_file.write('<td> <img class="New" src="../../%s/%s/%s%s.png" width="375"/> </td>\n' %(GeoScenario.split("_")[2],mats,indiplots,mats))
1023  # index_file.write('<td> %s <a href="../../%s/%s/%s%s.pdf" class="TMLlink">Click to enlarge %s plot</a></td>\n' %(_individualMatPlotsDesc[indiplots].replace("THEMAT",_matPageNameMap[mats]), GeoScenario.split("_")[2],mats,indiplots,mats,GeoScenario.split("_")[2]))
1024  # index_file.write('</tr>\n')
1025 
1026  #Writing postamble
1027  #index_file.write('</tbody>\n')
1028  #index_file.write('</table>\n')
1029  #--------------------------------------------------------------
1030  index_file.write(_hideShowFun["divTabs"])
1031 
1032  #Individual material here for: All HGCAL, Zminus, Zplus
1033  for region in ["_AllHGCAL", "_ZminusZoom", "_ZplusZoom"]:
1034  #The hide/show button
1035  #index_file.write(_hideShowFun["buttonandFunction%s"%(region)])
1036 
1037  index_file.write('<div id="%s" class="tabcontent"> \n' %(region))
1038  pngnamestring = ""
1039  if region == "_AllHGCAL": pngnamestring = ""
1040  else: pngnamestring = region
1041  for indiplots in _individualmatplots:
1042  if region == "_AllHGCAL":
1043  index_file.write('<p> %s <a href="../../%s/%s/%s%s%s.pdf" class="TMLlink">Click to enlarge %s plot</a></p>\n' %(_individualMatPlotsDesc[indiplots].replace("THEMAT",_matPageNameMap[mats]), GeoScenario.split("_")[2],mats,indiplots,mats,pngnamestring,GeoScenario.split("_")[2]))
1044  index_file.write('<img class="Reference" src="../../%s/%s/%s%s%s.png" width="375"/> \n' %(GeoScenario.split("_")[0],mats,indiplots,mats,pngnamestring) )
1045  index_file.write('<img class="New" src="../../%s/%s/%s%s%s.png" width="375"/> \n' %(GeoScenario.split("_")[2],mats,indiplots,mats,pngnamestring))
1046  index_file.write('<hr/>\n')
1047  else:
1048  index_file.write('<p> %s <a href="../../%s/%s/%s/%s%s%s.pdf" class="TMLlink">Click to enlarge %s plot</a></p>\n' %(_individualMatPlotsDesc[indiplots].replace("THEMAT",_matPageNameMap[mats]), GeoScenario.split("_")[2],mats,region.replace("_Zminus","ZMinus").replace("_Zplus","ZPlus"),indiplots,mats,pngnamestring,GeoScenario.split("_")[2]))
1049  index_file.write('<img class="Reference" src="../../%s/%s/%s/%s%s%s.png" width="375"/> \n' %(GeoScenario.split("_")[0],mats,region.replace("_Zminus","ZMinus").replace("_Zplus","ZPlus"),indiplots,mats,pngnamestring) )
1050  index_file.write('<img class="New" src="../../%s/%s/%s/%s%s%s.png" width="375"/> \n' %(GeoScenario.split("_")[2],mats,region.replace("_Zminus","ZMinus").replace("_Zplus","ZPlus"),indiplots,mats,pngnamestring))
1051  index_file.write('<hr/>\n')
1052 
1053 
1054  index_file.write('</div>\n')
1055 
1056  index_file.write(_hideShowFun["buttonandFunction"])
1057  index_file.write(' </body>\n')
1058  index_file.write('</html>\n')
1059  index_file.close()
1060 
1061  #Copy the individual materials budget file
1062  processCmd('cp %s/indimat/%s/index.html %s/%s/indimat/%s/.' %(GeoScenario, mats, opt.WWWAREA,GeoScenario,mats) )
1063 
1064  #html file for from vertex up to muon stations
1065  index_file = open('%s/fromvertex/index.html'%(GeoScenario),'w')
1066  #Write preamble
1067  index_file.write('<html>\n')
1068  index_file.write(' <head>\n')
1069 
1070  index_file.write(' <style>img.Reference{margin: 20px auto 20px auto; border: 10px solid green; border-radius: 10px;}img.New{margin: 20px auto 20px auto; border: 10px solid red; border-radius: 10px;} </style> \n')
1071 
1072  index_file.write(_hideShowFun["thestyle"])
1073 
1074  index_file.write(' <title> <h2> HGCAL material budget results from vertex up to in front of muon stations for %s </h2> </title>\n' %(GeoScenario) )
1075  index_file.write(' </head>\n')
1076  index_file.write(' <body>\n')
1077 
1078  index_file.write(' <h2> HGCAL material budget results from vertex up to in front of muon stations: <span style="color:red;font-size:120%%" >All detectors </span></h2> \n' )
1079 
1080  index_file.write('<p> %s plots have a green border followed by the %s plots which features a red border. </p>\n' % (GeoScenario.split("_")[0], GeoScenario.split("_")[2]) )
1081 
1082  index_file.write('<h2> Geometry: <span style="color:green;" > %s</span>_vs_<span style="color:red;" >%s </span> </h2>\n' % (GeoScenario.split("_")[0], GeoScenario.split("_")[2]) )
1083 
1084  index_file.write('<hr/>\n')
1085 
1086  #index_file.write(_hideShowFun["divTabs"])
1087 
1088  for vertexplots in _fromvertexplots:
1089  index_file.write('<p> %s </p>\n' %(_fromVertexPlotsDesc[vertexplots]))
1090  index_file.write('<img class="Reference" src="%s/Figures/MaterialBdg_FromVertexToBackOf%s.png" width="375"/> \n' %(GeoScenario.split("_")[0],vertexplots) )
1091  index_file.write('<img class="New" src="%s/Figures/MaterialBdg_FromVertexToBackOf%s.png" width="375"/> \n' %(GeoScenario.split("_")[2],vertexplots) )
1092  index_file.write('<hr/>\n')
1093 
1094  #index_file.write(_hideShowFun["buttonandFunction"])
1095  index_file.write(' </body>\n')
1096  index_file.write('</html>\n')
1097  index_file.close()
1098 
1099  #Copy all materials budget file
1100  processCmd('cp %s/fromvertex/index.html %s/%s/fromvertex/.' %(GeoScenario, opt.WWWAREA,GeoScenario) )
1101 
geometryDiff.transpose
def transpose(a)
Definition: geometryDiff.py:39
hgcalPerformanceValidation.parseOptions
def parseOptions()
Definition: hgcalPerformanceValidation.py:27
if
if(0==first)
Definition: CAHitNtupletGeneratorKernelsImpl.h:58
submitPVValidationJobs.split
def split(sequence, size)
Definition: submitPVValidationJobs.py:352
str
#define str(s)
Definition: TestProcessor.cc:53
hgcalPerformanceValidation.processCmd
def processCmd(cmd, quite=0)
Definition: hgcalPerformanceValidation.py:52
hgcalPerformanceValidation.putype
putype
Definition: hgcalPerformanceValidation.py:332
print
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)
Definition: Utilities.cc:46
beamvalidation.exit
def exit(msg="")
Definition: beamvalidation.py:52
python.rootplot.root2matplotlib.replace
def replace(string, replacements)
Definition: root2matplotlib.py:444