13 from pluginCondDBPyInterface
import *
14 from CondCore.Utilities
import iovInspector
as inspect
25 import simplejson
as json
27 print "Please use lxplus or set an environment (for example crab) with json lib available"
31 print "### command line:"
32 copyargs = sys.argv[:]
33 for i
in range(len(copyargs)):
36 if copyargs[i].
find(
" ") != -1:
37 copyargs[i] =
"\"%s\"" % copyargs[i]
38 commandline =
" ".
join(copyargs)
41 infotofile = [
"### %s\n" % commandline]
46 usage=
'%prog [options]\n\n'+\
47 'Creates a Python configuration file with filenames for runs in specified run range, with certain min B field and data quality requirements.'
49 parser=optparse.OptionParser(usage)
51 parser.add_option(
"-d",
"--alcaDataset",
52 help=
"[REQUIRED] Name of the input AlCa dataset to get filenames from.",
59 parser.add_option(
"-m",
"--isMC",
60 help=
"Whether sample is MC (true) or real data (false).",
65 parser.add_option(
"-s",
"--startRun",
66 help=
"First run number in range.",
71 parser.add_option(
"-e",
"--endRun",
72 help=
"Last run number in range.",
77 parser.add_option(
"-b",
"--minB",
78 help=
"Lower limit on minimal B field for a run.",
84 parser.add_option(
"--maxB",
85 help=
"Upper limit on B field for a run.",
90 parser.add_option(
"-r",
"--runRegistry",
91 help=
"If present, use RunRegistry API for B field and data quality quiery",
96 parser.add_option(
"-j",
"--json",
97 help=
"If present with JSON file as argument, use JSON file for the good runs and ignore B field and --runRegistry options. "+\
98 "The latest JSON file is available at /afs/cern.ch/cms/CAF/CMSCOMM/COMM_DQM/certification/Collisions10/7TeV/StreamExpress/",
103 parser.add_option(
"-t",
"--dbTag",
104 help=
"Runinfo DB tag to use.",
106 default=
"runinfo_31X_hlt",
109 parser.add_option(
"--printTags",
110 help=
"If present, the only thing script will do is printing list of tags in the DB",
115 parser.add_option(
"--dbName",
116 help=
"RunInfo DB name to use. The default one is "+\
117 "'oracle://cms_orcoff_prod/CMS_COND_31X_RUN_INFO'",
119 default=
"oracle://cms_orcoff_prod/CMS_COND_31X_RUN_INFO",
122 parser.add_option(
"--dqDataset",
123 help=
"Dataset name to query for good data quality runs. "+\
124 "If this option is not used, dqDataset=alcaDataset is automatically set. "+\
125 "If alcaDataset does not have DQ information use /Cosmics/Commissioning08-v1/RAW for CRAFT08 "+\
126 "and use /Cosmics/CRAFT09-v1/RAW for CRAFT08",
133 parser.add_option(
"-c",
"--dqCriteria",
134 help=
"Set of DQ criteria to use with -dq flag of dbs.\n"+\
135 "An example of a really strict condition:\n"
136 "'DT_Shift_Offline=GOOD&CSC_Shift_Offline=GOOD&SiStrip_Shift_Offline=GOOD&Pixel_Shift_Offline=GOOD'"
137 "NOTE: if --runRegistry is used, DQ criteria sintax should be as Advanced query syntax for RR. E.g.:"
138 "\"{cmpDt}='GOOD' and {cmpCsc}='GOOD' and {cmpStrip}='GOOD' and {cmpPix}='GOOD'\"",
146 parser.add_option(
"-o",
"--outputFile",
147 help=
"Name for output file (please include the .py suffix)",
149 default=
"filelist.py",
152 parser.add_option(
"-v",
"--verbose",
153 help=
"Degree of debug info verbosity",
158 options,args=parser.parse_args()
166 if options.alcaDataset==
'' and not options.printTags:
167 print "--alcaDataset /your/dataset/name is required!"
170 if options.dqDataset==
'':
171 options.dqDataset = options.alcaDataset
173 if not (options.isMC==
'true' or options.isMC==
'false'):
174 print "--isMC option can have only 'true' or 'false' arguments"
179 minI = options.minB*18160/3.8
180 maxI = options.maxB*18160/3.8
184 if options.runRegistry: rr =
' --runRegistry'
187 if options.json!=
'': jj =
' --json '+options.json
189 allOptions =
'### ' + copyargs[0] +
' --alcaDataset ' + options.alcaDataset +
' --isMC ' + options.isMC + \
190 ' --startRun ' + str(options.startRun) +
' --endRun '+ str(options.endRun) + \
191 ' --minB ' + str(options.minB) +
' --maxB ' + str(options.maxB) + rr + jj +\
192 ' --dbTag ' + options.dbTag +
' --dqDataset ' + options.dqDataset +
' --dqCriteria "' + options.dqCriteria +
'"'\
193 ' --outputFile ' + options.outputFile
195 print "### all options, including default:"
209 sys.setdlopenflags(DLFCN.RTLD_GLOBAL+DLFCN.RTLD_LAZY)
213 rdbms = RDBMS(
"/afs/cern.ch/cms/DB/conddb")
215 db = rdbms.getDB(options.dbName)
218 if options.printTags:
219 print "\nOverview of all tags in "+options.dbName+
" :\n"
237 iov = inspect.Iov(db,tag)
242 print "######## summries ########"
243 for x
in iov.summaries():
244 print x[0], x[1], x[2] ,x[3]
249 print "###(start_current,stop_current,avg_current,max_current,min_current,run_interval_micros) vs runnumber###"
250 print iov.trend(what)
253 print "######## trends ########"
254 for x
in iov.trendinrange(what,options.startRun-1,options.endRun+1):
255 if v>0
or x[0]==67647L
or x[0]==66893L
or x[0]==67264L:
256 print x[0],x[1] ,x[2], x[2][4], x[2][3]
258 if x[2][4] >= minI
and x[2][3] <= maxI:
259 runs_b_on.append(int(x[0]))
261 except Exception, er :
264 print "### runs with good B field ###"
277 dbs_quiery =
"find run where dataset="+options.dqDataset+
" and dq="+options.dqCriteria
278 print 'dbs search --noheader --query="'+dbs_quiery+
'" | sort'
280 os.system(
'python $DBSCMD_HOME/dbsCommandLine.py -c search --noheader --query="'+dbs_quiery+
'" | sort > /tmp/runs_full_of_pink_bunnies')
284 ff = open(
'/tmp/runs_full_of_pink_bunnies',
"r")
286 while line
and line!=
'':
287 runs_good_dq.append(int(line))
291 os.system(
'rm /tmp/runs_full_of_pink_bunnies')
293 print "### runs with good quality ###"
305 server = xmlrpclib.ServerProxy(
'http://pccmsdqm04.cern.ch/runregistry/xmlrpc')
307 rr_quiery =
"{runNumber}>="+str(options.startRun)+
" and {runNumber}<="+str(options.endRun)+\
308 " and {bfield}>="+str(options.minB)+
" and {bfield}<="+str(options.maxB)
309 if options.dqCriteria !=
"": rr_quiery +=
" and "+options.dqCriteria
311 rrstr = server.RunDatasetTable.export(
'GLOBAL',
'chart_runs_cum_evs_vs_bfield', rr_quiery)
312 rrstr = rrstr.replace(
"bfield",
"'bfield'")
313 rrstr = rrstr.replace(
"events",
"'events'")
317 for rr
in rrdata[
'events']: runs_good.append(rr[0])
327 jsonfile=
file(options.json,
'r')
328 jsondict = json.load(jsonfile)
331 for run
in jsondict.keys(): runs_good.append(int(run))
347 if options.isMC==
'false' and not options.runRegistry
and options.json==
'':
350 infotofile.append(
"### runs with good B field ###\n")
351 infotofile.append(
"### %s\n" % str(runs_b_on))
359 if options.isMC==
'false' and not options.runRegistry
and options.json==
'':
362 infotofile.append(
"### runs with good quality ###\n")
363 infotofile.append(
"### %s\n" % str(runs_good_dq))
366 runs_good = [val
for val
in runs_b_on
if val
in runs_good_dq]
368 print "### runs with good B field and quality ###"
371 infotofile.append(
"### runs with good B field and quality ###\n")
372 infotofile.append(
"### %s\n" % str(runs_good))
377 if options.isMC==
'false' and options.runRegistry
and options.json==
'':
379 print "### runs with good B field and quality ###"
388 if options.isMC==
'false' and options.json!=
'':
390 print "### good runs from JSON file ###"
396 dbs_quiery =
"find run, file.numevents, file where dataset="+options.alcaDataset+
" and run>="+str(options.startRun)+
" and run<="+str(options.endRun)+
" and file.numevents>0"
399 os.system(
'python $DBSCMD_HOME/dbsCommandLine.py -c search --noheader --query="'+dbs_quiery+
'" | sort > /tmp/runs_and_files_full_of_pink_bunnies')
403 list_of_numevents = []
406 ff = open(
'/tmp/runs_and_files_full_of_pink_bunnies',
'r')
408 (run, numevents, fname) = line.split(
' ')
409 if options.isMC==
'false' and (int(run)
not in runs_good):
411 fname = fname.rstrip(
'\n')
412 list_of_files.append(fname)
413 list_of_runs.append(int(run))
414 list_of_numevents.append(numevents)
415 total_numevents += int(numevents)
419 uniq_list_of_runs =
list(set(list_of_runs))
420 uniq_list_of_runs.sort()
422 print "### list of runs with good B field and quality in the dataset: ###"
423 print uniq_list_of_runs
424 infotofile.append(
"### list of runs with good B field and quality in the dataset: ###\n")
425 infotofile.append(
"### %s\n" % str(uniq_list_of_runs))
429 files_events =
zip(list_of_files, list_of_numevents)
430 unique_files_events =
list(set(files_events))
431 list_of_files, list_of_numevents =
map(list,
zip(*unique_files_events))
432 total_numevents = sum(
map(int, list_of_numevents) )
434 print "### total number of events in those "+str(len(uniq_list_of_runs))+
" runs = "+str(total_numevents)
436 infotofile.append(
"### total number of events in those "+str(len(uniq_list_of_runs))+
" runs = "+str(total_numevents))
442 size = len(list_of_files)
447 ff = open(options.outputFile,
'w')
448 ff.write(
"".
join(infotofile))
449 ff.write(
"\nfileNames = [\n")
451 for i
in range(0,size):
455 ff.write(
" '"+ list_of_files[i] +
"'"+comma+
" # "+ list_of_numevents[i] +
"\n")
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
def getRunRegistryGoodRuns
obtaining list of good B and quality runs from Run Registry https://twiki.cern.ch/twiki/bin/view/CMS/...
static std::string join(char **cmd)
def getGoodBRuns
functions definitions
def getGoodQRuns
obtaining list of good quality runs
def getJSONGoodRuns
obtain a list of good runs from JSON file
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