CMS 3D CMS Logo

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