CMS 3D CMS Logo

HDQMDatabaseProducer.py
Go to the documentation of this file.
1 from __future__ import print_function
2 import os
3 import sys
4 
5 if len(sys.argv) != 2:
6  print("Error: please, specify the configuration file")
7  sys.exit()
8 else:
9  configFile = sys.argv[1]
10 
11 if os.path.isfile(configFile):
12  print("Using configuration file:", configFile)
13 else:
14  print("Error: configuration file", configFile, "not found")
15  sys.exit()
16 
17 # Read the parameters
18 import HDQMDatabaseProducerConfiguration
20 # print SourceDir
21 
22 import DiscoverDQMFiles
23 discoverDQMFiles = DiscoverDQMFiles.DiscoverDQMFiles()
24 
25 import PopulateDB
26 populateDB = PopulateDB.PopulateDB()
27 
28 import ProducePlots
29 producePlots = ProducePlots.ProducePlots()
30 
31 
32 # If needed, discover all the RecoTypes and use them
33 if len(config.RecoTypes) == 0:
34  fullList = discoverDQMFiles.filesList(config.SourceDir)
35  keys = {}
36  for file in fullList:
37  # print file.split("__")[2]
38  keys[file.split("__")[2]] = 1
39  print("Found the following reco types:", keys.keys())
40  config.RecoTypes = keys.keys()
41 
42 # Save the list of recoTypes to file for the WebInterface
43 recoTypesFile = open('recoTypesFile.txt', 'w')
44 
45 # import sys
46 # sys.exit()
47 
48 for recoType in config.RecoTypes:
49  # Create the list of DQM root files
50  fullList = discoverDQMFiles.filesList(config.SourceDir, recoType)
51  for subDetAndTag in config.SubDetsAndTags:
52  FullTagName = config.TagName+"_"+subDetAndTag.SubDet+"_"+subDetAndTag.Tag
53  # Take the list of already processed runs
54  import DiscoverProcessedRuns
55  discoverProcessedRuns = DiscoverProcessedRuns.DiscoverProcessedRuns()
56 
57  discoverProcessedRuns.Database = config.Database
58  discoverProcessedRuns.AuthenticationPath = config.AuthenticationPath
59  discoverProcessedRuns.CMSSW_Version = config.CMSSW_Version
60  discoverProcessedRuns.TagName = FullTagName
61 
62  processedRuns = discoverProcessedRuns.runsList()
63 
64  # Filter out the files of already processed runs
65  filteredList = list(fullList)
66  for run in processedRuns:
67  for file in fullList:
68  if( file.find(run) != -1 ):
69  # It should not give an exception unless a file is removed twice...
70  try:
71  filteredList.remove(file)
72  except Exception:
73  print("Error, trying to remove file:", file, "twice!")
74  pass
75 
76  # Sort with run number and remove the last RunsToSkip runs
77  filteredList = sorted(filteredList, key=lambda run: run.split("R0")[1].split("__")[0])
78  runsToSkip = int(config.RunsToSkip)
79  if( runsToSkip > 0 ):
80  for lastRun in range(runsToSkip):
81  filteredList.pop()
82 
83  # Store the information in the database
84  tempDir = config.BaseDir+"/"+subDetAndTag.SubDet+"_"+config.RunType+"/"
85  if not os.path.isdir(tempDir):
86  os.mkdir(tempDir)
87 
88  for file in filteredList:
89  runNumber = int(file.split("R0")[1].split("__")[0])
90 
91  populateDB.RunNumber = str(runNumber)
92  populateDB.AuthenticationPath = config.AuthenticationPath
93  populateDB.Database = config.Database
94  populateDB.TagName = FullTagName
95  populateDB.FileName = file
96  populateDB.TemplatesDir = config.TemplatesDir
97  populateDB.DetName = subDetAndTag.SubDet
98  populateDB.Dir = config.BaseDir+"/"+subDetAndTag.SubDet+"_"+config.RunType+"/"
99  populateDB.CMSSW_Version = config.CMSSW_Version
100 
101  populateDB.run()
102 
103  # Produce the plots if needed
104  if len(filteredList) == 0:
105  print("Creating plots")
106 
107  producePlots.Dir = config.BaseDir+"/"
108  producePlots.TagName = FullTagName
109  producePlots.DetName = subDetAndTag.SubDet
110  producePlots.StorageDir = config.StorageDir
111  producePlots.BaseDir = config.BaseDir
112  producePlots.FirstRun = str(config.FirstRun)
113  producePlots.CMSSW_Version = config.CMSSW_Version
114  producePlots.Database = config.Database
115  producePlots.Password = PASSWORD
116  producePlots.RunType = config.RunType
117  producePlots.Group = config.Group
118  producePlots.QualityFlag = subDetAndTag.QualityFlag
119 
120  producePlots.makePlots()
121 
122  # All done, save the recoType to file
123  recoTypesFile.write(recoType+"\n")
124 
125 recoTypesFile.close()
S & print(S &os, JobReport::InputFile const &f)
Definition: JobReport.cc:65
#define str(s)
double split
Definition: MVATrainer.cc:139
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger list("!*","!HLTx*"if it matches 2 triggers or more) will accept the event if all the matching triggers are FAIL.It will reject the event if any of the triggers are PASS or EXCEPTION(this matches the behavior of"!*"before the partial wildcard feature was incorporated).Triggers which are in the READY state are completely ignored.(READY should never be returned since the trigger paths have been run