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