Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:32:36

0001 #! /usr/bin/env python3
0002 
0003 #------------------------------------------------------------------------------------------
0004 # Description: This script is used to produce the results of the regurarly announced RelVal campaings.
0005 #              Essentially, this is a wrapper around the basic HGCal Validation script:
0006 #              Validation/HGCalValidation/scripts/makeHGCalValidationPlots.py
0007 # Documentation: Full documentation on this script and details on how to run it are in the section 
0008 #                "Campaign Validation" in the HGCal DPG website:
0009 #                http://hgcal.web.cern.ch/hgcal/Validation/RelVals/
0010 #                Information on the CMSSW HGCalValidation package and relevant objects can be 
0011 #                found in the "Validation" section.  
0012 #------------------------------------------------------------------------------------------
0013 
0014 import sys
0015 import os
0016 import subprocess
0017 import optparse
0018 import pandas as pd
0019 
0020 from collections import OrderedDict
0021 
0022 from Validation.RecoTrack.plotting.validation import Sample, Validation
0023 from Validation.HGCalValidation.hgcalHtml import _sampleName,_pageNameMap,_summary,_summobj,_MatBudSections,_geoPageNameMap,_individualmaterials,_matPageNameMap,_individualmatplots,_individualMatPlotsDesc,_hideShowFun,_allmaterialsplots,_allmaterialsPlotsDesc, _fromvertexplots, _fromVertexPlotsDesc
0024 
0025 from Validation.HGCalValidation.PostProcessorHGCAL_cfi import tracksterLabels as trackstersIters
0026 
0027 #------------------------------------------------------------------------------------------
0028 #Parsing input options
0029 def parseOptions():
0030 
0031     usage = ('usage: %prog [options]\n'
0032              + '%prog -h for help')
0033     parser = optparse.OptionParser(usage)
0034 
0035     parser.add_option('', '--Obj', dest='OBJ',  type='string', default=None, help='Object to run. Options are: Geometry, SimHits, Digis, RecHits, Calibrations, CaloParticles, hgcalLayerClusters')
0036     parser.add_option('', '--html-validation-name', dest='HTMLVALNAME', type='string', default='', help='Could be either be hgcalLayerClusters or hgcalMultiClusters')
0037     parser.add_option('-d', '--download', action='store_true', dest='DOWNLOAD', default=False, help='Download DQM files from RelVals')
0038     parser.add_option('-g', '--gather', dest='GATHER',  type='string', default=None, help='Objects to gather: hitValidation, hitCalibration, hgcalLayerClusters, hgcalMultiClusters, ticlMultiClustersFromTrackstersEM, ticlMultiClustersFromTrackstersHAD')
0039     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')
0040     parser.add_option('-y', '--dry-run', action='store_true', dest='DRYRUN', default=False, help='perform a dry run (nothing is lauched).')
0041     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')
0042     parser.add_option('', '--geometry', action='store_true', dest='GEOMETRY', default=False, help='Geometry validation section')
0043     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.')
0044 
0045     # store options and arguments as global variables
0046     global opt, args
0047     (opt, args) = parser.parse_args()
0048 
0049 parseOptions()
0050 
0051 #------------------------------------------------------------------------------------------
0052 #Some helpful functions
0053 #Processing the external os subprocess
0054 def processCmd(cmd, quite = 0):
0055     print(cmd)
0056     status, output = subprocess.getstatusoutput(cmd)
0057     if (status !=0 and not quite):
0058         print('Error in processing command:\n   ['+cmd+']')
0059         print('Output:\n   ['+output+'] \n')
0060     return output
0061 
0062 #PUtype
0063 def putype(t):
0064     if "_pmx" in NewRelease:
0065         if "_pmx" in RefRelease:
0066             return {"default": "pmx"+t}
0067         return {"default": t, NewRelease: "pmx"+t}
0068     return t
0069 
0070 #------------------------------------------------------------------------------------------
0071 #Input section: Each time a new RelVal campaign is announced the following variables should 
0072 #               be updated:
0073 #               NewRelease: The new release being validated.
0074 #               RefRelease: The reference release we want to test the new one against.
0075 #               thereleases: All releases validated for which we have validation results 
0076 #                            including the NewRelease.
0077 #               NotNormalRelease , NotNormalRefRelease: If one of the releases to be validated has
0078 #                            used the DIGI on 11_0_0 put "raw". Otherwise put "normal". 
0079 #               phase2samples_noPU: These are the noPU phase 2 RelVal samples that are regurarly 
0080 #                                   produced.   
0081 #               phase2samples_PU: These are the PU phase 2 RelVal samples that are regurarly 
0082 #                                 produced.  
0083 #               RefRepository, NewRepository: The path where the DQM files of the campaign 
0084 #                                             will be placed.
0085 #------------------------------------------------------------------------------------------
0086 #thereleases = { "CMSSW 11_1_X" : ["CMSSW_11_1_0_pre4_GEANT4","CMSSW_11_1_0_pre3","CMSSW_11_1_0_pre2"] }
0087 thereleases = OrderedDict()
0088 thereleases = { "CMSSW 12_4_X" : [
0089     "CMSSW_12_4_0_pre3_DD4HEP_vs_CMSSW_12_4_0_pre3_DDD",
0090     "CMSSW_12_4_0_pre3_vs_CMSSW_12_4_0_pre2",
0091     "CMSSW_12_4_0_pre2_vs_CMSSW_12_3_0_pre6"
0092                 ],
0093                 "CMSSW 12_3_X" : [
0094     "CMSSW_12_3_1_vs_CMSSW_12_3_0_pre6",
0095     "CMSSW_12_3_0_pre6_vs_CMSSW_12_3_0_pre5",
0096     "CMSSW_12_3_0_pre5_D88_vs_CMSSW_12_3_0_pre5_D77",
0097     "CMSSW_12_3_0_pre5_D77_vs_CMSSW_12_3_0_pre3_D77",
0098     "CMSSW_12_3_0_pre4_vs_CMSSW_12_3_0_pre3",
0099     "CMSSW_12_3_0_pre3_vs_CMSSW_12_3_0_pre2"
0100                 ],
0101                 "CMSSW 12_2_X" : [
0102     "CMSSW_12_2_0_vs_CMSSW_12_2_0_pre3",
0103     "CMSSW_12_2_0_pre3_D88_vs_CMSSW_12_2_0_pre3_D77",
0104     "CMSSW_12_2_0_pre3_vs_CMSSW_12_2_0_pre2",
0105     "CMSSW_12_2_0_pre2_vs_CMSSW_12_1_0_pre5"
0106                  ],
0107                 "CMSSW 12_1_X" : [
0108     "CMSSW_12_1_0_pre5_vs_CMSSW_12_1_0_pre4",
0109     "CMSSW_12_1_0_pre5_D77_vs_CMSSW_12_1_0_pre4_D76",
0110     "CMSSW_12_1_0_pre4_ROOT624_vs_CMSSW_12_1_0_pre4",
0111     "CMSSW_12_1_0_pre4_vs_CMSSW_12_1_0_pre3",
0112     "CMSSW_12_1_0_pre3_vs_CMSSW_12_1_0_pre2",
0113     "CMSSW_12_1_0_pre2_vs_CMSSW_12_0_0_pre6",
0114     "CMSSW_12_1_0_pre2_D77_vs_CMSSW_12_1_0_pre2_D76"
0115                  ],
0116                 "CMSSW 12_0_X" : [
0117     "CMSSW_12_0_1_vs_CMSSW_12_0_0_pre4",
0118     "CMSSW_12_0_0_pre6_vs_CMSSW_12_0_0_pre4",
0119     "CMSSW_12_0_0_pre4_vs_CMSSW_12_0_0_pre3",
0120     "CMSSW_12_0_0_pre3_vs_CMSSW_12_0_0_pre2",
0121     "CMSSW_12_0_0_pre2_vs_CMSSW_12_0_0_pre1",
0122     "CMSSW_12_0_0_pre1_vs_CMSSW_11_3_0_pre6"
0123                  ],
0124                 "CMSSW 11_3_X" : [
0125     "CMSSW_11_3_0_vs_CMSSW_11_3_0_pre6",
0126     "CMSSW_11_3_0_pre6_vs_CMSSW_11_3_0_pre5",
0127     "CMSSW_11_3_0_pre5_vs_CMSSW_11_3_0_pre4",
0128     "CMSSW_11_3_0_pre4_vs_CMSSW_11_3_0_pre3",
0129     "CMSSW_11_3_0_pre3_G4VECGEOM_vs_CMSSW_11_3_0_pre3",
0130     "CMSSW_11_3_0_pre3_D76_vs_CMSSW_11_3_0_pre3",
0131     "CMSSW_11_3_0_pre3_vs_CMSSW_11_3_0_pre2",
0132     "CMSSW_11_3_0_pre2_vs_CMSSW_11_3_0_pre1",
0133     "CMSSW_11_3_0_pre1_vs_CMSSW_11_2_0_pre10",
0134                 ],
0135                 "CMSSW 11_2_X" : [
0136     "CMSSW_11_2_0_vs_CMSSW_11_2_0_pre10",
0137     "CMSSW_11_2_0_pre10_vs_CMSSW_11_2_0_pre9",
0138     "CMSSW_11_2_0_pre9_vs_CMSSW_11_2_0_pre8",
0139     "CMSSW_11_2_0_pre8_vs_CMSSW_11_2_0_pre7",
0140     "CMSSW_11_2_0_pre7_vs_CMSSW_11_2_0_pre6",
0141     "CMSSW_11_2_0_pre6_ROOT622_vs_CMSSW_11_2_0_pre6",
0142     "CMSSW_11_2_0_pre6_vs_CMSSW_11_2_0_pre5",
0143     "CMSSW_11_2_0_pre5_GEANT106_vs_CMSSW_11_2_0_pre5",
0144     "CMSSW_11_2_0_pre5_vs_CMSSW_11_2_0_pre3",
0145     "CMSSW_11_2_0_pre3_vs_CMSSW_11_2_0_pre1",
0146     "CMSSW_11_2_0_pre1_vs_CMSSW_11_1_0_pre8"
0147                 ],
0148                 "CMSSW 11_1_X" : [
0149     "CMSSW_11_1_0_pre8_raw1100_vs_CMSSW_11_1_0_pre8",
0150     "CMSSW_11_1_0_pre8_raw1100_vs_CMSSW_11_1_0_pre7_raw1100",
0151     "CMSSW_11_1_0_pre8_vs_CMSSW_11_1_0_pre7",
0152     "CMSSW_11_1_0_pre7_raw1100_vs_CMSSW_11_1_0_pre7",
0153     "CMSSW_11_1_0_pre7_raw1100_vs_CMSSW_11_1_0_pre6_raw1100",
0154     "CMSSW_11_1_0_pre7_vs_CMSSW_11_1_0_pre6",
0155     "CMSSW_11_1_0_pre6_raw1100_vs_CMSSW_11_1_0_pre6",
0156     "CMSSW_11_1_0_pre6_raw1100_vs_CMSSW_11_1_0_pre5_raw1100",
0157     "CMSSW_11_1_0_pre6_vs_CMSSW_11_1_0_pre5",
0158     "CMSSW_11_1_0_pre5_vs_CMSSW_11_1_0_pre4",
0159     "CMSSW_11_1_0_pre5_raw1100_vs_CMSSW_11_1_0_pre5",
0160     "CMSSW_11_1_0_pre5_raw1100_vs_CMSSW_11_1_0_pre4_raw1100",
0161     "CMSSW_11_1_0_pre4_raw1100_vs_CMSSW_11_1_0_pre4",
0162     "CMSSW_11_1_0_pre4_raw1100_vs_CMSSW_11_1_0_pre3_raw1100",
0163     "CMSSW_11_1_0_pre4_GEANT4","CMSSW_11_1_0_pre4"
0164                ] 
0165 }
0166 
0167 geometryTests = OrderedDict()
0168 geometryTests = { "Material budget" : [
0169                 #"Extended2026D49_vs_Extended2026D71",
0170                 "Extended2026D49_vs_Extended2026D76",
0171                 "Extended2026D76_vs_Extended2026D83",
0172                 "Extended2026D83_vs_Extended2026D86",
0173                 "Extended2026D77_vs_Extended2026D88"
0174                 ]
0175 }
0176 
0177 GeoScenario = "Extended2026D77_vs_Extended2026D88"
0178 
0179 RefRelease='CMSSW_12_3_0_pre6'
0180 
0181 NewRelease='CMSSW_12_3_1'
0182 
0183 NotNormalRelease = "normal"
0184 NotNormalRefRelease = "normal"
0185 #NotNormalRefRelease = "raw"
0186 
0187 if ( os.path.isdir('%s/%s' %(opt.WWWAREA, NewRelease))) : 
0188     print("The campaign you are trying to validate has already an existing validation folder in the official www area.")
0189     print("Make sure you are not overwriting anything and try again.")
0190     exit()
0191 
0192 if "raw" in NotNormalRelease: 
0193     #   appendglobaltag = "_2026D49noPU_raw1100_rsb"
0194     #   appendglobaltag = "_2026D49noPU_raw1100"
0195     #   appendglobaltag = "_2026D49noPU_gcc900"
0196     #appendglobaltag = "_2026D77noPU"
0197     appendglobaltag = "_2026D88noPU"
0198     #appendglobaltag = "_2026D88noPU_DDD"
0199     #appendglobaltag = "_2026D88noPU_DD4HEP"
0200 else: 
0201     #   appendglobaltag = "_2026D49noPU"
0202     #appendglobaltag = "_2026D76noPU"
0203     #appendglobaltag = "_2026D77noPU"
0204     appendglobaltag = "_2026D88noPU"
0205     #appendglobaltag = "_2026D88noPU_DDD"
0206     #appendglobaltag = "_2026D88noPU_DD4HEP"
0207 
0208 #Until the final list of RelVals settles down the following sample list is under constant review
0209 '''
0210 phase2samples_noPU_oldnaming = [
0211 #    Sample("RelValCloseByParticleGun_CE_H_Fine_300um", dqmVersion="0002", scenario="2026D49", appendGlobalTag=appendglobaltag ),
0212     Sample("RelValCloseByParticleGun_CE_H_Fine_300um", scenario="2026D49", appendGlobalTag=appendglobaltag ),
0213     Sample("RelValCloseByParticleGun_CE_H_Fine_200um", scenario="2026D49", appendGlobalTag=appendglobaltag ),
0214     Sample("RelValCloseByParticleGun_CE_H_Fine_120um", scenario="2026D49", appendGlobalTag=appendglobaltag ),
0215     Sample("RelValCloseByParticleGun_CE_H_Coarse_Scint", scenario="2026D49", appendGlobalTag=appendglobaltag ),
0216     Sample("RelValCloseByParticleGun_CE_H_Coarse_300um", scenario="2026D49", appendGlobalTag=appendglobaltag ),
0217     Sample("RelValCloseByParticleGun_CE_E_Front_300um", scenario="2026D49", appendGlobalTag=appendglobaltag ),
0218     Sample("RelValCloseByParticleGun_CE_E_Front_200um", scenario="2026D49", appendGlobalTag=appendglobaltag ),
0219     Sample("RelValCloseByParticleGun_CE_E_Front_120um", scenario="2026D49", appendGlobalTag=appendglobaltag ),
0220     #Sample("RelValCloseByParticleGun_CE_E_Front_120um", scenario="2026D49", appendGlobalTag=appendglobaltag , version="v2"),
0221     Sample("RelValTTbar", midfix="14TeV", scenario="2026D49", appendGlobalTag=appendglobaltag ),
0222     Sample("RelValZMM", midfix="14", scenario="2026D49", appendGlobalTag=appendglobaltag ),
0223     Sample("RelValSingleGammaFlatPt8To150", scenario="2026D49", appendGlobalTag=appendglobaltag ),
0224     Sample("RelValSingleMuPt10", scenario="2026D49", appendGlobalTag=appendglobaltag ),
0225     Sample("RelValSingleMuPt100", scenario="2026D49", appendGlobalTag=appendglobaltag ),
0226     Sample("RelValSingleMuPt1000", scenario="2026D49", appendGlobalTag=appendglobaltag ),
0227     Sample("RelValSingleMuFlatPt2To100", scenario="2026D49", appendGlobalTag=appendglobaltag ),
0228     Sample("RelValSingleMuFlatPt0p7To10", scenario="2026D49", appendGlobalTag=appendglobaltag ),
0229     Sample("RelValSingleEFlatPt2To100", scenario="2026D49", appendGlobalTag=appendglobaltag ),
0230     Sample("RelValSingleTauFlatPt2To150", scenario="2026D49", appendGlobalTag=appendglobaltag ),
0231     Sample("RelValSinglePiFlatPt0p7To10", scenario="2026D49", appendGlobalTag=appendglobaltag ),
0232     Sample("RelValQCD_Pt20toInfMuEnrichPt15", midfix="14TeV", scenario="2026D49", appendGlobalTag=appendglobaltag ),
0233     Sample("RelValQCD_Pt15To7000_Flat", midfix="14TeV", scenario="2026D49", appendGlobalTag=appendglobaltag ),
0234     Sample("RelValZTT", midfix="14TeV", scenario="2026D49", appendGlobalTag=appendglobaltag ),
0235     Sample("RelValZMM", midfix="14", scenario="2026D49", appendGlobalTag=appendglobaltag ),
0236     Sample("RelValZEE", midfix="14", scenario="2026D49", appendGlobalTag=appendglobaltag ),
0237     Sample("RelValB0ToKstarMuMu", midfix="14TeV", scenario="2026D49", appendGlobalTag=appendglobaltag ),
0238     Sample("RelValBsToEleEle", midfix="14TeV", scenario="2026D49", appendGlobalTag=appendglobaltag ),
0239     Sample("RelValBsToMuMu", midfix="14TeV", scenario="2026D49", appendGlobalTag=appendglobaltag ),
0240     Sample("RelValBsToJpsiGamma", midfix="14TeV", scenario="2026D49", appendGlobalTag=appendglobaltag ),
0241     Sample("RelValBsToJpsiPhi_mumuKK", midfix="14TeV", scenario="2026D49", appendGlobalTag=appendglobaltag ),
0242     Sample("RelValBsToPhiPhi_KKKK", midfix="14TeV", scenario="2026D49", appendGlobalTag=appendglobaltag ),
0243     Sample("RelValDisplacedMuPt30To100", scenario="2026D49", appendGlobalTag=appendglobaltag ),
0244     Sample("RelValDisplacedMuPt2To10", scenario="2026D49", appendGlobalTag=appendglobaltag ),
0245     Sample("RelValDisplacedMuPt10To30", scenario="2026D49", appendGlobalTag=appendglobaltag ),
0246     Sample("RelValTauToMuMuMu", midfix="14TeV", scenario="2026D49", appendGlobalTag=appendglobaltag ),
0247     #Sample("RelValMinBias", midfix="14TeV", scenario="2026D49", appendGlobalTag=appendglobaltag ),
0248     Sample("RelValH125GGgluonfusion", midfix="14", scenario="2026D49", appendGlobalTag=appendglobaltag ),
0249     Sample("RelValNuGun", scenario="2026D49", appendGlobalTag=appendglobaltag )
0250     ]
0251 '''
0252 
0253 #Main workflow RelVals
0254 phase2samples_noPU = [
0255 
0256     #------------------------------
0257     #version v2 campaign
0258     #Sample("RelValZpTT_1500", midfix="14", scenario="2026D49", appendGlobalTag=appendglobaltag, version="v2" ),
0259     #Sample("RelValZpTT_1500", midfix="14TeV", scenario="2026D49", appendGlobalTag=appendglobaltag, version="v2" ),
0260     #Sample("RelValZTT", midfix="14TeV", scenario="2026D49", appendGlobalTag=appendglobaltag, version="v2" ),
0261     #Sample("RelValZMM", midfix="14", scenario="2026D49", appendGlobalTag=appendglobaltag, version="v2" ),
0262     #Sample("RelValZEE", midfix="14", scenario="2026D49", appendGlobalTag=appendglobaltag, version="v2" ),
0263     #Sample("RelValTenTau_15_500_Eta3p1", scenario="2026D49", appendGlobalTag=appendglobaltag, version="v2"  ),
0264     #Sample("RelValTenTau_15_500", scenario="2026D49", appendGlobalTag=appendglobaltag, version="v2"  ),
0265     #Sample("RelValTTbar", midfix="14TeV", scenario="2026D49", appendGlobalTag=appendglobaltag, version="v2" ),
0266     #Sample("RelValQCD_Pt15To7000_Flat", midfix="14", scenario="2026D49", appendGlobalTag=appendglobaltag, version="v2" ),
0267     #Sample("RelValQCD_Pt15To7000_Flat", midfix="14TeV", scenario="2026D49", appendGlobalTag=appendglobaltag, version="v2" ),
0268     #Sample("RelValNuGun", scenario="2026D49", appendGlobalTag=appendglobaltag, version="v2" ),
0269     #Sample("RelValMinBias", midfix="14", scenario="2026D49", appendGlobalTag=appendglobaltag, version="v2" ),
0270     #Sample("RelValMinBias", midfix="14TeV", scenario="2026D49", appendGlobalTag=appendglobaltag, version="v2" ),
0271     #Sample("RelValH125GGgluonfusion", midfix="14", scenario="2026D49", appendGlobalTag=appendglobaltag, version="v2" )
0272 
0273     #------------------------------
0274     #NORMAL version v1 campaign
0275     Sample("RelValZpTT_1500", midfix="14", scenario="2026D49", appendGlobalTag=appendglobaltag ),
0276     #Sample("RelValZpTT_1500", midfix="14TeV", scenario="2026D49", appendGlobalTag=appendglobaltag ),
0277     Sample("RelValZTT", midfix="14TeV", scenario="2026D49", appendGlobalTag=appendglobaltag ),
0278     Sample("RelValZMM", midfix="14", scenario="2026D49", appendGlobalTag=appendglobaltag ),
0279     #Sample("RelValZMM", midfix="14", scenario="2026D49", dqmVersion="0002", appendGlobalTag=appendglobaltag ),
0280     Sample("RelValZEE", midfix="14", scenario="2026D49", appendGlobalTag=appendglobaltag ),
0281     Sample("RelValTenTau_15_500_Eta3p1", scenario="2026D49", appendGlobalTag=appendglobaltag  ),
0282     #Sample("RelValTenTau_15_500", scenario="2026D49", appendGlobalTag=appendglobaltag  ),
0283     Sample("RelValTTbar", midfix="14TeV", scenario="2026D49", appendGlobalTag=appendglobaltag ),
0284     Sample("RelValQCD_Pt15To7000_Flat", midfix="14", scenario="2026D49", appendGlobalTag=appendglobaltag ),
0285     #Sample("RelValQCD_Pt15To7000_Flat", midfix="14TeV", scenario="2026D49", appendGlobalTag=appendglobaltag ),
0286     Sample("RelValNuGun", scenario="2026D49", appendGlobalTag=appendglobaltag ),
0287     #Sample("RelValMinBias", midfix="14", scenario="2026D49", appendGlobalTag=appendglobaltag ),
0288     Sample("RelValMinBias", midfix="14TeV", scenario="2026D49", appendGlobalTag=appendglobaltag ),
0289     Sample("RelValH125GGgluonfusion", midfix="14", scenario="2026D49", appendGlobalTag=appendglobaltag )
0290     #------------------------------
0291 
0292 
0293 ]
0294 
0295 
0296 #More workflows 
0297 phase2samples_noPU_extend = [
0298 
0299     #Sample("RelValSingleMuPt10", scenario="2026D49", appendGlobalTag=appendglobaltag, version="v2"),
0300     #Sample("RelValSingleMuPt100", scenario="2026D49", appendGlobalTag=appendglobaltag, version="v2" ),
0301     #Sample("RelValSingleMuPt1000", scenario="2026D49", appendGlobalTag=appendglobaltag, version="v2" )
0302 
0303     Sample("RelValSingleMuPt10", scenario="2026D49", appendGlobalTag=appendglobaltag ),
0304     Sample("RelValSingleMuPt100", scenario="2026D49", appendGlobalTag=appendglobaltag ),
0305     Sample("RelValSingleMuPt1000", scenario="2026D49", appendGlobalTag=appendglobaltag )
0306 
0307 ]
0308 
0309 #These workflows were added in CMSSW_11_1_0_pre6 but there were missing from CMSSW_11_1_0_pre5.
0310 #So, I am only download them to be reary for pre7. Then, I comment them out
0311 #For the moment I cannot find these in pre7.
0312 phase2samples_noPU_extend_more = [
0313 
0314     #------------------------------
0315     #version v3 campaign
0316     #Sample("RelValCloseByPGun_CE_H_Fine_300um", scenario="2026D49", appendGlobalTag=appendglobaltag, version="v3" ),
0317     #Sample("RelValCloseByPGun_CE_H_Fine_200um", scenario="2026D49", appendGlobalTag=appendglobaltag, version="v3" ),
0318     #Sample("RelValCloseByPGun_CE_H_Fine_120um", scenario="2026D49", appendGlobalTag=appendglobaltag, version="v3" ),
0319     #Sample("RelValCloseByPGun_CE_H_Coarse_Scint", scenario="2026D49", appendGlobalTag=appendglobaltag, version="v3" ),
0320     #Sample("RelValCloseByPGun_CE_H_Coarse_300um", scenario="2026D49", appendGlobalTag=appendglobaltag, version="v3" ),
0321     #Sample("RelValCloseByPGun_CE_E_Front_300um", scenario="2026D49", appendGlobalTag=appendglobaltag, version="v3" ),
0322     #Sample("RelValCloseByPGun_CE_E_Front_200um", scenario="2026D49", appendGlobalTag=appendglobaltag, version="v3" ),
0323     #Sample("RelValCloseByPGun_CE_E_Front_120um", scenario="2026D49", appendGlobalTag=appendglobaltag, version="v3" ),
0324     #Sample("RelValSingleGammaFlatPt8To150", scenario="2026D49", appendGlobalTag=appendglobaltag, version="v3" ),
0325     #Sample("RelValSingleEFlatPt2To100", scenario="2026D49", appendGlobalTag=appendglobaltag, version="v3" ),
0326     #Sample("RelValSinglePiFlatPt0p7To10", scenario="2026D49", appendGlobalTag=appendglobaltag, version="v3" )
0327 
0328     #------------------------------
0329     #version v2 campaign
0330     #Sample("RelValCloseByPGun_CE_H_Fine_300um", scenario="2026D49", appendGlobalTag=appendglobaltag, version="v2" ),
0331     #Sample("RelValCloseByPGun_CE_H_Fine_200um", scenario="2026D49", appendGlobalTag=appendglobaltag, version="v2" ),
0332     #Sample("RelValCloseByPGun_CE_H_Fine_120um", scenario="2026D49", appendGlobalTag=appendglobaltag, version="v2" ),
0333     #Sample("RelValCloseByPGun_CE_H_Coarse_Scint", scenario="2026D49", appendGlobalTag=appendglobaltag, version="v2" ),
0334     #Sample("RelValCloseByPGun_CE_H_Coarse_300um", scenario="2026D49", appendGlobalTag=appendglobaltag, version="v2" ),
0335     #Sample("RelValCloseByPGun_CE_E_Front_300um", scenario="2026D49", appendGlobalTag=appendglobaltag, version="v2" ),
0336     #Sample("RelValCloseByPGun_CE_E_Front_200um", scenario="2026D49", appendGlobalTag=appendglobaltag, version="v2" ),
0337     #Sample("RelValCloseByPGun_CE_E_Front_120um", scenario="2026D49", appendGlobalTag=appendglobaltag, version="v2" ),
0338     #Sample("RelValSingleGammaFlatPt8To150", scenario="2026D49", appendGlobalTag=appendglobaltag, version="v2" ),
0339     #Sample("RelValSingleEFlatPt2To100", scenario="2026D49", appendGlobalTag=appendglobaltag, version="v2" ),
0340     #Sample("RelValSinglePiFlatPt0p7To10", scenario="2026D49", appendGlobalTag=appendglobaltag, version="v2" )
0341 
0342 
0343 
0344     #------------------------------
0345     #NORMAL version v1 campaign
0346     Sample("RelValCloseByPGun_CE_H_Fine_300um", scenario="2026D49", appendGlobalTag=appendglobaltag ),
0347     Sample("RelValCloseByPGun_CE_H_Fine_200um", scenario="2026D49", appendGlobalTag=appendglobaltag ),
0348     Sample("RelValCloseByPGun_CE_H_Fine_120um", scenario="2026D49", appendGlobalTag=appendglobaltag ),
0349     Sample("RelValCloseByPGun_CE_H_Coarse_Scint", scenario="2026D49", appendGlobalTag=appendglobaltag ),
0350     Sample("RelValCloseByPGun_CE_H_Coarse_300um", scenario="2026D49", appendGlobalTag=appendglobaltag ),
0351     Sample("RelValCloseByPGun_CE_E_Front_300um", scenario="2026D49", appendGlobalTag=appendglobaltag ),
0352     Sample("RelValCloseByPGun_CE_E_Front_200um", scenario="2026D49", appendGlobalTag=appendglobaltag ),
0353     Sample("RelValCloseByPGun_CE_E_Front_120um", scenario="2026D49", appendGlobalTag=appendglobaltag ),
0354     Sample("RelValSingleGammaFlatPt8To150", scenario="2026D49", appendGlobalTag=appendglobaltag ),
0355     Sample("RelValSingleEFlatPt2To100", scenario="2026D49", appendGlobalTag=appendglobaltag ),
0356     Sample("RelValSinglePiFlatPt0p7To10", scenario="2026D49", appendGlobalTag=appendglobaltag )
0357     #------------------------------
0358 
0359     #Sample("RelValCloseByPGun_CE_H_Fine_300um", scenario="2026D49", appendGlobalTag=appendglobaltag + "_HGCal" ),
0360     #Sample("RelValCloseByPGun_CE_H_Fine_200um", scenario="2026D49", appendGlobalTag=appendglobaltag + "_HGCal" ),
0361     #Sample("RelValCloseByPGun_CE_H_Fine_120um", scenario="2026D49", appendGlobalTag=appendglobaltag + "_HGCal" ),
0362     #Sample("RelValCloseByPGun_CE_H_Coarse_Scint", scenario="2026D49", appendGlobalTag=appendglobaltag + "_HGCal" ),
0363     #Sample("RelValCloseByPGun_CE_H_Coarse_300um", scenario="2026D49", appendGlobalTag=appendglobaltag + "_HGCal" ),
0364     #Sample("RelValCloseByPGun_CE_E_Front_300um", scenario="2026D49", appendGlobalTag=appendglobaltag + "_HGCal" ),
0365     #Sample("RelValCloseByPGun_CE_E_Front_200um", scenario="2026D49", appendGlobalTag=appendglobaltag + "_HGCal" ),
0366     #Sample("RelValCloseByPGun_CE_E_Front_120um", scenario="2026D49", appendGlobalTag=appendglobaltag + "_HGCal" ),
0367     #Sample("RelValSingleGammaFlatPt8To150", scenario="2026D49", appendGlobalTag=appendglobaltag + "_HGCal" ),
0368     #Sample("RelValSingleEFlatPt2To100", scenario="2026D49", appendGlobalTag=appendglobaltag + "_HGCal" ),
0369     #Sample("RelValSinglePiFlatPt0p7To10", scenario="2026D49", appendGlobalTag=appendglobaltag + "_HGCal" )
0370 
0371 
0372     #Sample("RelValQCD_Pt20toInfMuEnrichPt15", midfix="14", scenario="2026D49", appendGlobalTag=appendglobaltag ),
0373     #Sample("RelValDisplacedMuPt30To100", scenario="2026D49", appendGlobalTag=appendglobaltag ),
0374     #Sample("RelValDisplacedMuPt2To10", scenario="2026D49", appendGlobalTag=appendglobaltag ),
0375     #Sample("RelValDisplacedMuPt10To30", scenario="2026D49", appendGlobalTag=appendglobaltag ),
0376     #Sample("RelValB0ToKstarMuMu", midfix="14TeV", scenario="2026D49", appendGlobalTag=appendglobaltag ),
0377     #Sample("RelValBsToEleEle", midfix="14TeV", scenario="2026D49", appendGlobalTag=appendglobaltag ),
0378     #Sample("RelValBsToMuMu", midfix="14TeV", scenario="2026D49", appendGlobalTag=appendglobaltag ),
0379     #Sample("RelValBsToJpsiGamma", midfix="14TeV", scenario="2026D49", appendGlobalTag=appendglobaltag ),
0380     #Sample("RelValBsToJpsiPhi_mumuKK", midfix="14TeV", scenario="2026D49", appendGlobalTag=appendglobaltag ),
0381     #Sample("RelValBsToPhiPhi_KKKK", midfix="14TeV", scenario="2026D49", appendGlobalTag=appendglobaltag ),
0382     #Sample("RelValTauToMuMuMu", midfix="14TeV", scenario="2026D49", appendGlobalTag=appendglobaltag ),
0383     #Sample("RelValSingleTauFlatPt2To150", scenario="2026D49", appendGlobalTag=appendglobaltag ),
0384     #Sample("RelValSingleMuFlatPt0p7To10", scenario="2026D49", appendGlobalTag=appendglobaltag )
0385 
0386 ]
0387 
0388 phase2samples_noPU.extend(phase2samples_noPU_extend)
0389 phase2samples_noPU.extend(phase2samples_noPU_extend_more)
0390 #phase2samples_noPU = phase2samples_noPU_extend_more
0391 #phase2samples_noPU.extend(phase2samples_noPU_oldnaming)
0392 
0393 #phase2samples_noPU = [
0394 #    Sample("RelValCloseByPGun_CE_E_Front_300um", scenario="2026D49", appendGlobalTag=appendglobaltag ),
0395 #    Sample("RelValCloseByPGun_CE_E_Front_200um", scenario="2026D49", appendGlobalTag=appendglobaltag )
0396 #]
0397 
0398 #For the PU samples 
0399 phase2samples_PU = [
0400     Sample("RelValTTbar", midfix="14TeV", scenario="2026D49", putype=putype("25ns"), punum=200, appendGlobalTag="_2026D49PU200", version="v2"),
0401 ]
0402 
0403 # Reference and new repository
0404 RefRepository = '%s' %(opt.INPUT)
0405 NewRepository = '%s' %(opt.INPUT)
0406 
0407 #------------------------------------------------------------------------------------------
0408 #Download section: The basic HGCal validation object is created and the DQM files of the 
0409 #                  DQM files of the RelVals are downloaded. 
0410 #------------------------------------------------------------------------------------------
0411 
0412 #Create basic object for the HGCal validation plots
0413 val = Validation(
0414     fullsimSamples = phase2samples_noPU,
0415     fastsimSamples = [],
0416     refRelease=RefRelease, refRepository=RefRepository,
0417     newRelease=NewRelease, newRepository=NewRepository
0418 )
0419 
0420 #------------------------------------------------------------------------------------------
0421 #Download the DQM files of the RelVals. 
0422 if(opt.DOWNLOAD): 
0423     val.download()
0424 
0425     #Keep them in eos, save afs space. 
0426     if (not os.path.isdir(RefRepository+'/'+NewRelease)) :
0427         processCmd('mkdir -p '+RefRepository+'/'+NewRelease)
0428 
0429     for infi in phase2samples_noPU:
0430         if "_HGCal" in infi.filename(NewRelease): 
0431             processCmd('mv ' + infi.filename(NewRelease) + ' ' + infi.filename(NewRelease).replace("_HGCal",""))
0432             processCmd('mv ' + infi.filename(NewRelease).replace("_HGCal","") + ' ' + RefRepository+'/'+NewRelease)
0433         else: 
0434             #processCmd('mv ' + infi.filename(NewRelease) + ' ' + infi.filename(NewRelease).replace("2026D49noPU-v2","2026D49noPU-v1"))
0435             #processCmd('mv ' + infi.filename(NewRelease).replace("2026D49noPU-v2","2026D49noPU-v1")  + ' ' + RefRepository+'/'+NewRelease)
0436             processCmd('mv ' + infi.filename(NewRelease)  + ' ' + RefRepository+'/'+NewRelease)
0437 
0438 #------------------------------------------------------------------------------------------
0439 #Objects processing section: The objects defined in --Obj are analyzed here. 
0440 #------------------------------------------------------------------------------------------
0441 if (opt.OBJ == 'layerClusters' or opt.OBJ == 'hitCalibration' or opt.OBJ == 'hitValidation' or opt.OBJ == 'tracksters' or opt.OBJ == 'simulation'):
0442     fragments = []
0443     #In the case of simulation we want to split the plots in specific folder
0444     if opt.OBJ == 'simulation': processCmd('mkdir HGCValid_SimClusters_Plots HGCValid_CaloParticles_Plots')
0445     #Let's loop through RelVals
0446     for infi in phase2samples_noPU:
0447         samplename = infi.filename(NewRelease).replace("DQM_V0001_R000000001__","").replace("__DQMIO.root","")
0448         #samplename = infi.filename(NewRelease).replace("DQM_V0001_R000000001__","").split("__CMSSW_10_6_0_pre4",1)[0]
0449         #samplename = samplename + infi.pileup()
0450         if infi.pileup() == "PU":
0451             samplename = samplename + str(infi.pileupNumber())
0452 
0453         #print( infi.name()  )
0454         print(_sampleName[infi.name()])
0455         print("="*40)
0456         print(samplename)
0457         print("="*40)
0458 
0459         #In the case of tracksters. We want to split the results.
0460         if opt.OBJ == 'tracksters':
0461            for tracksterCollection in trackstersIters:
0462                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) )
0463 
0464         inputpathRef = ""
0465         if RefRelease != None: inputpathRef = RefRepository +'/' + RefRelease +'/'
0466         inputpathNew = NewRepository +'/' + NewRelease+ '/'
0467 
0468         if RefRelease == None:
0469             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)
0470         elif "raw" in NotNormalRelease and "normal" in NotNormalRefRelease:
0471             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)
0472             #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)
0473         elif "normal" in NotNormalRelease and "raw" in NotNormalRefRelease:
0474             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)
0475             #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)
0476         elif "raw" in NotNormalRelease and "raw" in NotNormalRefRelease:
0477             #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)
0478             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)
0479         elif "normal" in NotNormalRelease and "normal" in NotNormalRefRelease:
0480             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)
0481             #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)
0482         else: 
0483             #print inputpathRef, infi.filename(RefRelease).replace("D49","D41")
0484             #YOU SHOULD INSPECT EACH TIME THIS COMMAND AND THE REPLACE
0485             #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__")
0486             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) 
0487             print(cmd)
0488 
0489         if(opt.DRYRUN):
0490             print('Dry-run: ['+cmd+']')
0491         else:
0492             output = processCmd(cmd)
0493             if opt.OBJ == 'layerClusters':
0494                 processCmd('mv HGCValid_%s_Plots/plots_%s_Layer\ Clusters.html HGCValid_%s_Plots/index.html'%(opt.HTMLVALNAME,samplename,opt.HTMLVALNAME))
0495                 processCmd('awk \'NR>=6&&NR<=396\' HGCValid_%s_Plots/index.html > HGCValid_%s_Plots/index_%s.html '% (opt.HTMLVALNAME,opt.HTMLVALNAME, samplename))
0496                 processCmd('echo "  <br/>" >> HGCValid_%s_Plots/index_%s.html '%(opt.HTMLVALNAME, samplename) )
0497                 processCmd('echo "  <hr>" >> HGCValid_%s_Plots/index_%s.html '%(opt.HTMLVALNAME, samplename) )
0498 
0499             if opt.OBJ == 'hitCalibration':
0500                 #processCmd('indexname=`ls HGCValid_%s_Plots/plots_*.html`; mv ${indexname} HGCValid_%s_Plots/index.html;'%(opt.HTMLVALNAME,opt.HTMLVALNAME))
0501                 processCmd('mv HGCValid_%s_Plots/plots_%s_Calibrated\ RecHits.html HGCValid_%s_Plots/index.html'%(opt.HTMLVALNAME,samplename,opt.HTMLVALNAME))
0502                 processCmd('sed -i \'s/Calibrated\ RecHits//g\' HGCValid_%s_Plots/index.html'%(opt.HTMLVALNAME) )
0503                 processCmd('awk \'NR>=6&&NR<=27\' HGCValid_%s_Plots/index.html > HGCValid_%s_Plots/index_%s.html '% (opt.HTMLVALNAME,opt.HTMLVALNAME, samplename))
0504                 processCmd('echo "  <br/>" >> HGCValid_%s_Plots/index_%s.html '%(opt.HTMLVALNAME, samplename) )
0505                 processCmd('echo "  <hr>" >> HGCValid_%s_Plots/index_%s.html '%(opt.HTMLVALNAME, samplename) )
0506 
0507             if opt.OBJ == 'hitValidation':
0508                 processCmd('mv HGCValid_%s_Plots/plots_%s_Hits.html HGCValid_%s_Plots/index.html'%(opt.HTMLVALNAME,samplename,opt.HTMLVALNAME))
0509                 processCmd('awk \'NR>=6&&NR<=184\' HGCValid_%s_Plots/index.html > HGCValid_%s_Plots/index_%s.html '% (opt.HTMLVALNAME,opt.HTMLVALNAME, samplename))
0510                 processCmd('echo "  <br/>" >> HGCValid_%s_Plots/index_%s.html '%(opt.HTMLVALNAME, samplename) )  
0511                 processCmd('echo "  <hr>" >> HGCValid_%s_Plots/index_%s.html '%(opt.HTMLVALNAME, samplename) )
0512                 
0513             if opt.OBJ == 'tracksters':
0514                 processCmd('mv HGCValid_%s_Plots/plots_%s_Tracksters.html HGCValid_Tracksters_Plots/index.html'%(opt.HTMLVALNAME,samplename))
0515                 processCmd('mv HGCValid_%s_Plots/plots_%s_Test-TICL.html HGCValid_Test-TICL_Plots/index.html'%(opt.HTMLVALNAME,samplename))
0516                 processCmd('mv HGCValid_%s_Plots/plots_%s_TICL-patternRecognition.html HGCValid_TICL-patternRecognition_Plots/index.html'%(opt.HTMLVALNAME,samplename))
0517                 processCmd('awk \'NR>=6&&NR<=135\' HGCValid_Tracksters_Plots/index.html > HGCValid_Tracksters_Plots/index_%s.html ' %(samplename))
0518                 processCmd('awk \'NR>=6&&NR<=117\' HGCValid_Test-TICL_Plots/index.html > HGCValid_Test-TICL_Plots/index_%s.html '% (samplename))
0519                 processCmd('awk \'NR>=6&&NR<=117\' HGCValid_TICL-patternRecognition_Plots/index.html > HGCValid_TICL-patternRecognition_Plots/index_%s.html '% (samplename))
0520                 processCmd('echo "  <br/>" >> HGCValid_Tracksters_Plots/index_%s.html '%(samplename) )
0521                 processCmd('echo "  <br/>" >> HGCValid_Test-TICL_Plots/index_%s.html '%(samplename) )
0522                 processCmd('echo "  <br/>" >> HGCValid_TICL-patternRecognition_Plots/index_%s.html '%(samplename) )
0523                 processCmd('echo "  <hr>" >> HGCValid_Tracksters_Plots/index_%s.html '%(samplename) )
0524                 processCmd('echo "  <hr>" >> HGCValid_Test-TICL_Plots/index_%s.html '%(samplename) )
0525                 processCmd('echo "  <hr>" >> HGCValid_TICL-patternRecognition_Plots/index_%s.html '%(samplename) )
0526                 #Now move the plots also to the relevant folders
0527                 for tracksterCollection in trackstersIters:
0528                     #Linking
0529                     processCmd('mv HGCValid_%s_Plots/plots_%s_%s/*_Link HGCValid_Test-TICL_Plots/plots_%s_%s/.'%(opt.HTMLVALNAME,samplename,tracksterCollection,samplename,tracksterCollection))
0530                     processCmd('mv HGCValid_%s_Plots/plots_%s_%s/*CaloParticle*Trackster* HGCValid_Test-TICL_Plots/plots_%s_%s/.'%(opt.HTMLVALNAME,samplename,tracksterCollection,samplename,tracksterCollection))
0531                     processCmd('mv HGCValid_%s_Plots/plots_%s_%s/*Trackster*CaloParticle* HGCValid_Test-TICL_Plots/plots_%s_%s/.'%(opt.HTMLVALNAME,samplename,tracksterCollection,samplename,tracksterCollection))
0532                     #Pattern recognition
0533                     processCmd('mv HGCValid_%s_Plots/plots_%s_%s/*_PR HGCValid_TICL-patternRecognition_Plots/plots_%s_%s/.'%(opt.HTMLVALNAME,samplename,tracksterCollection,samplename,tracksterCollection))
0534                     processCmd('mv HGCValid_%s_Plots/plots_%s_%s/*SimTrackster*Trackster* HGCValid_TICL-patternRecognition_Plots/plots_%s_%s/.'%(opt.HTMLVALNAME,samplename,tracksterCollection,samplename,tracksterCollection))
0535                     processCmd('mv HGCValid_%s_Plots/plots_%s_%s/*Trackster*SimTrackster* HGCValid_TICL-patternRecognition_Plots/plots_%s_%s/.'%(opt.HTMLVALNAME,samplename,tracksterCollection,samplename,tracksterCollection))
0536                     #Tracksters
0537                     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']:
0538                         processCmd('mv HGCValid_%s_Plots/plots_%s_%s/%s HGCValid_Tracksters_Plots/plots_%s_%s/.'%(opt.HTMLVALNAME,samplename,tracksterCollection,gr,samplename,tracksterCollection))
0539 
0540 
0541             if  opt.OBJ == 'simulation':              
0542 
0543                 processCmd('mv HGCValid_%s_Plots/plots_%s_SimClusters.html HGCValid_SimClusters_Plots/index.html'%(opt.HTMLVALNAME,samplename))
0544                 processCmd('mv HGCValid_%s_Plots/plots_%s_CaloParticles.html HGCValid_CaloParticles_Plots/index.html'%(opt.HTMLVALNAME,samplename))
0545                 processCmd('awk \'NR>=6&&NR<=157\' HGCValid_SimClusters_Plots/index.html > HGCValid_SimClusters_Plots/index_%s.html '% (samplename))
0546                 processCmd('awk \'NR>=6&&NR<=331\' HGCValid_CaloParticles_Plots/index.html > HGCValid_CaloParticles_Plots/index_%s.html '% (samplename))
0547                 processCmd('echo "  <br/>" >> HGCValid_SimClusters_Plots/index_%s.html '%(samplename) )
0548                 processCmd('echo "  <br/>" >> HGCValid_CaloParticles_Plots/index_%s.html '%(samplename) )
0549                 processCmd('echo "  <hr>" >> HGCValid_SimClusters_Plots/index_%s.html '%(samplename) )
0550                 processCmd('echo "  <hr>" >> HGCValid_CaloParticles_Plots/index_%s.html '%(samplename) )
0551                 #Now move the plots also to the relevant folders
0552                 processCmd('mv HGCValid_%s_Plots/plots_%s_ClusterLevel HGCValid_SimClusters_Plots/.'%(opt.HTMLVALNAME,samplename))
0553                 processCmd('mv HGCValid_%s_Plots/plots_%s_ticlSimTracksters HGCValid_SimClusters_Plots/.'%(opt.HTMLVALNAME,samplename))
0554                 processCmd('mv HGCValid_%s_Plots/plots_%s_CaloParticles_* HGCValid_CaloParticles_Plots/.'%(opt.HTMLVALNAME,samplename))
0555 
0556 
0557         if opt.OBJ == 'simulation': 
0558             fragments.append( 'HGCValid_SimClusters_Plots/index_%s.html'% (samplename) )
0559             fragments.append( 'HGCValid_CaloParticles_Plots/index_%s.html'% (samplename) )
0560         elif opt.OBJ == 'tracksters':
0561             fragments.append( 'HGCValid_Tracksters_Plots/index_%s.html'% (samplename) )
0562             fragments.append( 'HGCValid_Test-TICL_Plots/index_%s.html'% (samplename) )
0563             fragments.append( 'HGCValid_TICL-patternRecognition_Plots/index_%s.html'% (samplename) )
0564         else:
0565             fragments.append( 'HGCValid_%s_Plots/index_%s.html'% (opt.HTMLVALNAME, samplename) )
0566 
0567 
0568     #Let's also create the final index xml file(s). 
0569     indexfiles = []
0570     if opt.OBJ == 'simulation': 
0571         indexfiles = ["SimClusters","CaloParticles"]
0572     elif opt.OBJ == 'tracksters':
0573         indexfiles = ["Tracksters","Test-TICL","TICL-patternRecognition"]
0574     else: 
0575         indexfiles = [opt.HTMLVALNAME]
0576 
0577     for ind in indexfiles:        
0578         processCmd('mv HGCValid_%s_Plots/index.html HGCValid_%s_Plots/test.html' %(ind,ind) )
0579         index_file = open('HGCValid_%s_Plots/index.html'%(ind),'w')            
0580         #Write preamble
0581         index_file.write('<html>\n')
0582         index_file.write(' <head>\n')
0583         index_file.write('  <title>HGCAL validation %s </title>\n' %(ind) )
0584         index_file.write(' </head>\n')
0585         index_file.write(' <body>\n')
0586 
0587         for frag in fragments:   
0588             if ind not in frag: continue
0589             with open(frag,'r') as f:
0590                 lines = f.read().splitlines()
0591                 for line in lines:
0592                     print(line)
0593                     index_file.write(line + '\n')
0594                     #processCmd( 'cat ' + frag + ' >> HGCalValidationPlots/index.html '   )
0595                     #index_file.write(frag)
0596 
0597         #Writing postamble"
0598         index_file.write(' </body>\n')
0599         index_file.write('</html>\n')
0600         index_file.close()
0601 
0602 #------------------------------------------------------------------------------------------
0603 #This is the SimHits part
0604 if (opt.OBJ == 'SimHits'):
0605     #This is where we will save the final output pngs: 
0606     if (not os.path.isdir("hgcalSimHitStudy")) :
0607         processCmd('mkdir -p hgcalSimHitStudy')
0608     #Prepare for www
0609     processCmd('cp %s/../public/index.php hgcalSimHitStudy/.'%(opt.WWWAREA) )
0610 
0611     #The input to this is for the moment 100 GeV muon from runnin cmsRun runHGCalSimHitStudy_cfg.py 
0612     #Input: hgcSimHits.root
0613     cmd = 'root.exe -b -q Validation/HGCalValidation/macros/validationplots.C\(\\"hgcSimHit.root' +  '\\",\\"'+ opt.OBJ + '\\"\)'
0614     if(opt.DRYRUN):
0615         print('Dry-run: ['+cmd+']')
0616     else:
0617         output = processCmd(cmd)
0618 
0619 #------------------------------------------------------------------------------------------
0620 '''
0621 if (opt.OBJ == 'hitValidation'):
0622     fragments = []
0623     #Now  that we have them in eos lets produce plots
0624     #Let's loop through RelVals
0625     for infi in phase2samples_noPU:
0626         samplename = infi.filename(NewRelease).replace("DQM_V0001_R000000001__","").replace("__DQMIO.root","")
0627         #samplename = infi.filename(NewRelease).replace("DQM_V0001_R000000001__","").split("__CMSSW_10_6_0_pre4",1)[0]
0628         #samplename = samplename + infi.pileup()
0629         if infi.pileup() == "PU":
0630             samplename = samplename + str(infi.pileupNumber())
0631 
0632         print("="*40)
0633         print(samplename)
0634         print("="*40)
0635 
0636         inputpathRef = ""
0637         if RefRelease != None: inputpathRef = RefRepository +'/' + RefRelease +'/'
0638         inputpathNew = NewRepository +'/' + NewRelease+ '/'
0639 
0640         if RefRelease == None:
0641             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)
0642         elif "raw" in NotNormalRelease and "normal" in NotNormalRefRelease:
0643             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)
0644             #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)
0645         elif "raw" in NotNormalRelease and "raw" in NotNormalRefRelease:
0646             #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)
0647             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)
0648         elif "normal" in NotNormalRelease and "normal" in NotNormalRefRelease:
0649             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)
0650             #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)
0651         else: 
0652             #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) 
0653             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)
0654             #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)
0655 
0656 
0657         if(opt.DRYRUN):
0658             print('Dry-run: ['+cmd+']')
0659         else:
0660             output = processCmd(cmd)
0661             processCmd('mv HGCValid_%s_Plots/plots_%s_Hits.html HGCValid_%s_Plots/index.html'%(opt.HTMLVALNAME,samplename,opt.HTMLVALNAME))
0662             processCmd('awk \'NR>=6&&NR<=184\' HGCValid_%s_Plots/index.html > HGCValid_%s_Plots/index_%s.html '% (opt.HTMLVALNAME,opt.HTMLVALNAME, samplename))
0663             processCmd('echo "  <br/>" >> HGCValid_%s_Plots/index_%s.html '%(opt.HTMLVALNAME, samplename) )  
0664             processCmd('echo "  <hr>" >> HGCValid_%s_Plots/index_%s.html '%(opt.HTMLVALNAME, samplename) )
0665 
0666         fragments.append( 'HGCValid_%s_Plots/index_%s.html'% (opt.HTMLVALNAME, samplename) )
0667 
0668 
0669     #Let's also create the final index xml file. 
0670     processCmd('mv HGCValid_%s_Plots/index.html HGCValid_%s_Plots/test.html' %(opt.HTMLVALNAME,opt.HTMLVALNAME) )
0671     index_file = open('HGCValid_%s_Plots/index.html'%(opt.HTMLVALNAME),'w')            
0672     #Write preamble
0673     index_file.write('<html>\n')
0674     index_file.write(' <head>\n')
0675     index_file.write('  <title>HGCal validation %s </title>\n' %(opt.HTMLVALNAME) )
0676     index_file.write(' </head>\n')
0677     index_file.write(' <body>\n')
0678 
0679     for frag in fragments:   
0680         with open(frag,'r') as f:
0681             lines = f.read().splitlines()
0682             for line in lines:
0683                 print(line)
0684                 index_file.write(line + '\n')
0685                 #processCmd( 'cat ' + frag + ' >> HGCalValidationPlots/index.html '   )
0686                 #index_file.write(frag)
0687 
0688 
0689     #Writing postamble"
0690     index_file.write(' </body>\n')
0691     index_file.write('</html>\n')
0692     index_file.close()
0693 '''
0694 
0695 #-------------------------------------------------------------------------------------------
0696 #This is the Digis part
0697 if (opt.OBJ == 'Digis'):
0698     #This is where we will save the final output pngs: 
0699     if (not os.path.isdir("hgcalDigiStudy")) :
0700         processCmd('mkdir -p hgcalDigiStudy')
0701         processCmd('mkdir -p hgcalDigiStudyEE')
0702         processCmd('mkdir -p hgcalDigiStudyHEF')
0703         processCmd('mkdir -p hgcalDigiStudyHEB')
0704     #Prepare for www
0705     processCmd('cp %s/../public/index.php hgcalDigiStudy/.'%(opt.WWWAREA) )
0706     processCmd('cp %s/../public/index.php hgcalDigiStudyEE/.'%(opt.WWWAREA) )
0707     processCmd('cp %s/../public/index.php hgcalDigiStudyHEF/.'%(opt.WWWAREA) )
0708     processCmd('cp %s/../public/index.php hgcalDigiStudyHEB/.'%(opt.WWWAREA) )
0709     #The input here is from running cmsRun runHGCalDigiStudy_cfg.py, to which 
0710     #we usually give ttbar noPU as input 
0711     #Input: hgcDigi.root
0712     cmd = 'root.exe -b -q Validation/HGCalValidation/macros/validationplots.C\(\\"hgcDigi.root' +  '\\",\\"'+ opt.OBJ + '\\"\)'
0713     if(opt.DRYRUN):
0714         print('Dry-run: ['+cmd+']')
0715     else:
0716         output = processCmd(cmd)
0717         #mv the output under the main directory
0718         processCmd('mv hgcalDigiStudyEE hgcalDigiStudy/.')
0719         processCmd('mv hgcalDigiStudyHEF hgcalDigiStudy/.')
0720         processCmd('mv hgcalDigiStudyHEB hgcalDigiStudy/.')
0721 
0722 #-------------------------------------------------------------------------------------------
0723 #This is the RecHits part
0724 if (opt.OBJ == 'RecHits'):
0725     #This is where we will save the final output pngs: 
0726     if (not os.path.isdir("hgcalRecHitStudy")) :
0727         processCmd('mkdir -p hgcalRecHitStudy')
0728         processCmd('mkdir -p hgcalRecHitStudyEE')
0729         processCmd('mkdir -p hgcalRecHitStudyHEF')
0730         processCmd('mkdir -p hgcalRecHitStudyHEB')
0731     #Prepare for www
0732     processCmd('cp %s/../public/index.php hgcalRecHitStudy/.'%(opt.WWWAREA) )
0733     processCmd('cp %s/../public/index.php hgcalRecHitStudyEE/.'%(opt.WWWAREA) )
0734     processCmd('cp %s/../public/index.php hgcalRecHitStudyHEF/.'%(opt.WWWAREA) )
0735     processCmd('cp %s/../public/index.php hgcalRecHitStudyHEB/.'%(opt.WWWAREA) )
0736     #The input here is from running cmsRun runHGCalRecHitStudy_cfg.py, to which 
0737     #we usually give ttbar noPU as input 
0738     #Input: hgcRecHit.root
0739     cmd = 'root.exe -b -q Validation/HGCalValidation/macros/validationplots.C\(\\"hgcRecHit.root' +  '\\",\\"'+ opt.OBJ + '\\"\)'
0740     if(opt.DRYRUN):
0741         print('Dry-run: ['+cmd+']')
0742     else:
0743         output = processCmd(cmd)
0744         #mv the output under the main directory
0745         processCmd('mv hgcalRecHitStudyEE hgcalRecHitStudy/.')
0746         processCmd('mv hgcalRecHitStudyHEF hgcalRecHitStudy/.')
0747         processCmd('mv hgcalRecHitStudyHEB hgcalRecHitStudy/.')
0748 
0749 #-------------------------------------------------------------------------------------------
0750 ## TODO #This is the CaloParticles part
0751 if (opt.OBJ == 'CaloParticles'):
0752     particletypes = ["-11","-13","-211","-321","11","111","13","211","22","321"]
0753     #This is where we will save the final output pngs: 
0754     if (not os.path.isdir("CaloParticles")) :
0755         processCmd('mkdir -p CaloParticles')
0756     #Prepare for www
0757     processCmd('cp %s/../public/index.php CaloParticles/.'%(opt.WWWAREA) )
0758 
0759     #Let's loop through RelVals
0760     for infi in phase2samples_noPU:
0761         #samplename = infi.filename(NewRelease).replace("DQM_V0001_R000000001__","").replace("__DQMIO.root","")
0762         samplename = infi.filename(NewRelease).replace("DQM_V0001_R000000001__","").split("__"+NewRelease,1)[0]
0763         samplename = samplename + infi.pileup()
0764         if infi.pileup() == "PU":
0765             samplename = samplename + str(infi.pileupNumber())
0766 
0767         print("="*40)
0768         print(samplename)
0769         print("="*40)
0770         if (not os.path.isdir(samplename)) :
0771             processCmd('mkdir -p ' + samplename )
0772             processCmd('cp %s/RelVals/index.php '%(opt.WWWAREA) + samplename + '/.')
0773             for part in particletypes: 
0774                 processCmd('mkdir -p ' + samplename + '/' +part )
0775                 #Prepare for www
0776                 processCmd('cp %s/RelVals/index.php '%(opt.WWWAREA) + samplename + '/' +part + '/.')
0777 
0778         inputpathRef = ""
0779         if RefRelease != None: inputpathRef = RefRepository +'/' + RefRelease +'/'
0780         inputpathNew = NewRepository +'/' + NewRelease+ '/'
0781         cmd = 'root.exe -b -q Validation/HGCalValidation/macros/validationplots.C\(\\"'+ inputpathNew + infi.filename(NewRelease) +  '\\",\\"'+ opt.OBJ + '\\",\\"'+ samplename + '\\"\\)'
0782         if(opt.DRYRUN):
0783             print('Dry-run: ['+cmd+']')
0784         else:
0785             output = processCmd(cmd)
0786             processCmd('mv ' +samplename+ ' CaloParticles/.' )
0787 
0788 #------------------------------------------------------------------------------------------
0789 #Summary section: After processing all the objects the results are gathered, webpages are 
0790 #                 created and a summary page is added. 
0791 #-------------------------------------------------------------------------------------------
0792 #Here we will gather all results. 
0793 if (opt.GATHER != None) :
0794 
0795     #First we need the top folder to contain all validation releases. 
0796     index_file = open('index.html','w')            
0797     #Write preamble
0798     index_file.write('<html>\n')
0799     index_file.write(' <head>\n')
0800     index_file.write('  <title>HGCAL validation results </title>\n'  )
0801     index_file.write(' </head>\n')
0802     index_file.write(' <body>\n')
0803     index_file.write(' <h1>\n')
0804     index_file.write(' HGCAL Validation Results \n'  )
0805     index_file.write(' </h1>\n')
0806     index_file.write(' <hr/>\n' )
0807     index_file.write(' <h2>\n')
0808     index_file.write(' Release Validation Campaigns \n'  )
0809     index_file.write(' </h2>\n')
0810     index_file.write('  <ul>\n' )
0811 
0812     for trel in thereleases.keys():
0813         index_file.write('   <li>\n' )
0814         index_file.write('   %s\n' %(trel) )
0815         for rel in thereleases[trel]: 
0816             index_file.write('  <ul>\n' )
0817             index_file.write('   <li><a href="%s/index.html">%s</a></li>\n' %(rel, rel ) )
0818             index_file.write('  </ul>\n' )
0819         index_file.write('   </li>\n' )
0820         index_file.write('  <br>\n' )
0821         index_file.write('  <br>\n' )
0822         index_file.write('  <br>\n' )
0823 
0824     index_file.write('  </ul>\n' )
0825     index_file.write(' <hr/>\n' )
0826 
0827     #New section : Geometry Validation
0828     #Regardless of the release validation, the top html menu should contain the geometry section.
0829     #we put this in the "gather" step.
0830     index_file.write(' <h2>\n')
0831     index_file.write(' Geometry Validation \n'  )
0832     index_file.write(' </h2>\n')
0833     index_file.write('  <ul>\n' )
0834 
0835     for tgeo in geometryTests.keys():
0836         index_file.write('   <li>\n' )
0837         index_file.write('   %s\n' %(tgeo) )
0838         for geo in geometryTests[tgeo]:
0839             #We need the directory for the geometry related results 
0840             if (not os.path.isdir(geo)):
0841                 processCmd('mkdir -p %s/%s' %(opt.WWWAREA,geo) )
0842                 processCmd('mkdir -p %s' %(geo) )
0843                 for mats in _individualmaterials:
0844                     processCmd('mkdir -p %s/%s/indimat/%s' %(opt.WWWAREA,geo,mats) )
0845                     processCmd('mkdir -p %s/indimat/%s' %(geo,mats) )
0846 
0847             index_file.write('  <ul>\n' )
0848             index_file.write('   <li><a href="%s/index.html">%s</a></li>\n' %(geo, geo ) )
0849             index_file.write('  </ul>\n' )
0850         index_file.write('   </li>\n' )
0851         index_file.write('  <br>\n' )
0852         index_file.write('  <br>\n' )
0853         index_file.write('  <br>\n' )
0854 
0855     #Writing postamble"
0856     index_file.write(' </body>\n')
0857     index_file.write('</html>\n')
0858     index_file.close()
0859 
0860     #This is the main html file for the validation webpage. In order to avoid 
0861     #surprises when experimenting, in order to copy it automatically to the 
0862     #www area you should have activated the relevant flag:  
0863     if (opt.COPYHTML) : processCmd('cp index.html %s/.' %(opt.WWWAREA) )
0864 
0865     #Let's make also the summary folder
0866     if (not os.path.isdir("HGCValid_summary_Plots")):  
0867         processCmd('mkdir -p HGCValid_summary_Plots')   
0868 
0869     #To avoid the nans transpose later                          
0870     df = pd.DataFrame.from_dict(_summary, orient = 'index').transpose()
0871     #Make a specific order in columns
0872     df = df[_summobj]
0873 
0874     index_file = open('HGCValid_summary_Plots/index.html','w')
0875     #Write preamble
0876     index_file.write('<html>\n')
0877     index_file.write(' <body>\n')
0878 
0879     #Let's loop through RelVals
0880     for infi in phase2samples_noPU:
0881         samplename = infi.filename(NewRelease).replace("DQM_V0001_R000000001__","").replace("__DQMIO.root","")
0882         index_file.write( '<h2> %s </h2> \n' %(_sampleName[infi.name()]) )
0883         #table here with summary objects
0884         index_file.write('<table> \n')
0885         index_file.write('  <tr>\n')
0886         #This is the row with the headers. So, the objects for us.
0887         for obj in _summobj:
0888             index_file.write('    <th>%s</th>\n' %(_pageNameMap[obj]) )
0889         index_file.write('  </tr>\n')
0890 
0891         for i, row in df.iterrows():
0892             index_file.write('  <tr>\n')
0893             for j, column in row.iteritems():
0894                 print(column)  
0895                 index_file.write('    <td>\n')
0896                 index_file.write('    <ul>\n')
0897 
0898 #                if df[obj][ind] == None: 
0899                 if column == None:  
0900                     index_file.write('    </ul>\n')
0901                     index_file.write('    </td>\n')
0902                     continue
0903                     #index_file.write(' \n')
0904                 else:
0905                     #print(df[obj][ind])          
0906                     print(j)
0907                     #index_file.write(' <li><a href="plots_%s_%s">%s</a></li>   \n' %(samplename, df[obj][ind], df[obj][ind].partition("/")[2] ))
0908                     if "Tracksters" in j or "Test-TICL" in j or "TICL-patternRecognition" in j:
0909                         index_file.write(' <li><a href="../HGCValid_%s_Plots/plots_%s_%s">%s</a></li>   \n' %(j, samplename, column, column.replace("ticlTracksters","") ))
0910                     else:
0911                         index_file.write(' <li><a href="../HGCValid_%s_Plots/plots_%s_%s">%s</a></li>   \n' %(j, samplename, column, column.partition("/")[2] ))
0912 
0913                 index_file.write('    </ul>\n')                        
0914                 index_file.write('    </td>\n')
0915 
0916             index_file.write('  </tr>\n')
0917 
0918         index_file.write(' </table>\n')
0919         index_file.write('  <br/>\n' )
0920         index_file.write('  <br/>\n' )
0921         index_file.write('  <br/>\n' )
0922 
0923         #Writing postamble"
0924     index_file.write(' </body>\n')
0925     index_file.write('</html>\n')
0926     index_file.close()
0927 
0928     objects = opt.GATHER.split(",")
0929 
0930     localoutputdir = ""
0931     if "raw" in NotNormalRelease and "raw" in NotNormalRefRelease: 
0932         localoutputdir = NewRelease + "_raw1100" + "_vs_" + RefRelease + "_raw1100"
0933     elif "raw" in NotNormalRelease and "normal" in NotNormalRefRelease: 
0934         #localoutputdir = NewRelease + "_raw1100" + "_vs_" + RefRelease
0935         localoutputdir = NewRelease + "_D76" + "_vs_" + RefRelease
0936     elif "normal" in NotNormalRelease and "normal" in NotNormalRefRelease: 
0937         localoutputdir = NewRelease + "_vs_" + RefRelease
0938     else: 
0939         localoutputdir = NewRelease
0940 
0941     #make the structure to hold the objects
0942     for obj in objects:
0943         #This is where we will save the final output per campaing: 
0944         if (not os.path.isdir('%s/standalone' %(localoutputdir))) :
0945             processCmd('mkdir -p %s/standalone' %(localoutputdir))
0946         if (obj!="standalone"): processCmd('mv HGCValid_%s_Plots %s'%(obj, localoutputdir) )
0947         else : 
0948             processCmd('mv hgcalSimHitStudy %s/standalone/.'%(localoutputdir) )
0949             processCmd('mv hgcalDigiStudy %s/standalone/.'%(localoutputdir) )
0950             processCmd('mv hgcalRecHitStudy %s/standalone/.'%(localoutputdir) )
0951             processCmd('cp %s/../public/index.php %s/standalone/.'%(opt.WWWAREA, localoutputdir) )
0952 
0953     '''
0954     #Let's also copy to the summary folder what we need. 
0955     for infi in phase2samples_noPU:
0956         samplename = infi.filename(NewRelease).replace("DQM_V0001_R000000001__","").replace("__DQMIO.root","")
0957         for obj in _summobj:
0958             #print obj 
0959             #if obj == "hitValidation" : samplename = samplename + infi.pileup()
0960             #else : samplename = infi.filename(NewRelease).replace("DQM_V0001_R000000001__","").replace("__DQMIO.root","")
0961             for ind in df.index:
0962                 if df[obj][ind] == None: continue
0963                 else: processCmd('cp -r %s/HGCValid_%s_Plots/plots_%s_%s %s/HGCValid_summary_Plots ' %(NewRelease, obj, samplename, df[obj][ind].partition("/")[0], NewRelease ) )
0964     '''
0965 
0966     #html file of the relval campaign we are validating
0967     index_file = open('%s/index.html'%(localoutputdir),'w')            
0968     #Write preamble
0969     index_file.write('<html>\n')
0970     index_file.write(' <head>\n')
0971     index_file.write('  <title> <h2> HGCAL validation results for %s </h2> </title>\n' %(localoutputdir) )
0972     index_file.write(' </head>\n')
0973     index_file.write(' <body>\n')
0974     index_file.write(' <h2> HGCAL validation results for %s </h2> \n' %(localoutputdir) )
0975 
0976     for obj in objects:
0977         print(obj)
0978         if (obj!="standalone"):
0979             index_file.write('  <br/>\n' )
0980             index_file.write('  <ul>\n' )
0981             index_file.write('   <li><a href="HGCValid_%s_Plots/index.html">%s</a></li>\n' %(obj, _pageNameMap[obj] ) )
0982             index_file.write('  </ul>\n' )
0983             index_file.write('  <br/>\n' )
0984         else : 
0985             index_file.write('  <br/>\n' )
0986             index_file.write('  <ul>\n' )
0987             index_file.write('   <li><a href="%s/index.php">%s</a></li>\n' %(obj, _pageNameMap[obj] ) )
0988             index_file.write('  </ul>\n' )
0989             index_file.write('  <br/>\n' )
0990 
0991 
0992     #Writing postamble
0993     index_file.write(' </body>\n')
0994     index_file.write('</html>\n')
0995     index_file.close()
0996 
0997     #We choose to zip in uncompressed form all the files for two reasons:
0998     #1. Copying to eos so many files is really slow. It is faster to
0999     #   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