CMS 3D CMS Logo

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