CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Functions
tools Namespace Reference

Functions

def addCrabInputFile
 
def copyFilesFromCastor
 
def copyFilesLocal
 
def create_single_iov_db
 
def dqmWorkflowName
 
def getDatasetStr
 
def haddInCastor
 
def haddLocal
 
def listFilesInCastor
 
def listFilesLocal
 
def loadCmsProcess
 
def loadCmsProcessFile
 
def loadCrabCfg
 
def loadCrabDefault
 
def parseInput
 
def prependPaths
 
def replaceTemplate
 
def run_checked
 
def setGridEnv
 
def writeCfg
 
def writeCfgPkl
 

Function Documentation

def tools.addCrabInputFile (   crabCfg,
  inputFile 
)
def tools.copyFilesFromCastor (   castor_dir,
  output_dir,
  type = 'root' 
)

Definition at line 55 of file tools.py.

def tools.copyFilesLocal (   dir,
  output_dir,
  type = 'root' 
)

Definition at line 68 of file tools.py.

def tools.create_single_iov_db (   global_tag,
  run_number,
  output_db 
)
Create an sqlite file with single-IOV tags for alignment payloads.

Arguments:
- `global_tag`: global tag from which to extract the payloads
- `run_number`: run for which the IOVs are selected
- `output_db`: name of the output sqlite file

Definition at line 7 of file tools.py.

References shell.connect(), join(), and run_checked().

7 
8 def create_single_iov_db(global_tag, run_number, output_db):
9  """Create an sqlite file with single-IOV tags for alignment payloads.
10 
11  Arguments:
12  - `global_tag`: global tag from which to extract the payloads
13  - `run_number`: run for which the IOVs are selected
14  - `output_db`: name of the output sqlite file
15  """
16 
17  con = shell.connect()
18  tags = con.global_tag_map(global_tag_name = global_tag,
19  record = ["TrackerAlignmentRcd",
20  "TrackerSurfaceDeformationRcd",
21  "TrackerAlignmentErrorExtendedRcd"])
22  con.close_session()
23 
24  tags = {item["record"]: {"name": item["tag_name"]}
25  for item in tags.as_dicts()}
26 
27  for record,tag in tags.iteritems():
28  iovs = con.tag(name = tag["name"]).iovs().as_dicts()
29  run_is_covered = False
30  for iov in reversed(iovs):
31  if iov["since"] <= run_number:
32  tag["since"] = str(iov["since"])
33  run_is_covered = True
34  break
35  if not run_is_covered:
36  msg = ("Run number {0:d} is not covered in '{1:s}' ({2:s}) from"
37  " '{3:s}'.".format(run_number, tag["name"], record,
38  global_tag))
39  print msg
40  print "Aborting..."
41  sys.exit(1)
42 
43  result = {}
44  if os.path.exists(output_db): os.remove(output_db)
45  for record,tag in tags.iteritems():
46  result[record] = {"connect": "sqlite_file:"+output_db,
47  "tag": "_".join([tag["name"], tag["since"]])}
48  cmd = ("conddb_import",
49  "-f", "frontier://PromptProd/cms_conditions",
50  "-c", result[record]["connect"],
51  "-i", tag["name"],
52  "-t", result[record]["tag"],
53  "-b", str(run_number),
54  "-e", str(run_number))
55  run_checked(cmd)
56  run_checked(["sqlite3", output_db, "update iov set since=1"])
57 
58  return result
59 
def connect
Definition: shell.py:10
def run_checked
Definition: tools.py:60
def create_single_iov_db
Definition: tools.py:7
static std::string join(char **cmd)
Definition: RemoteFile.cc:18
def tools.dqmWorkflowName (   datasetpath,
  type,
  rev = 1 
)

Definition at line 23 of file tools.py.

Referenced by DTDqm.DTDqm.initProcess().

def tools.getDatasetStr (   datasetpath)

Definition at line 15 of file tools.py.

Referenced by DTDQMMerge.DTDQMMerge.initProcess().

def tools.haddInCastor (   castor_dir,
  result_file,
  type = 'root',
  prefix = 'rfio:',
  suffix = None 
)

Definition at line 81 of file tools.py.

def tools.haddLocal (   dir,
  result_file,
  type = 'root' 
)

Definition at line 98 of file tools.py.

def tools.listFilesInCastor (   castor_dir,
  type = 'root',
  prefix = 'rfio:' 
)

Definition at line 30 of file tools.py.

Referenced by DTDqm.runDQM(), and DTDQMMerge.runDQM().

def tools.listFilesLocal (   dir,
  type = 'root' 
)

Definition at line 42 of file tools.py.

def tools.loadCmsProcess (   psetPath)

Definition at line 144 of file tools.py.

Referenced by DTValidSummary.DTValidSummary.initProcess(), DTDqm.DTDqm.initProcess(), DTDQMMerge.DTDQMMerge.initProcess(), DTAnalysisResiduals.DTAnalysisResiduals.initProcess(), DTTTrigProd.DTTTrigProd.initProcess(), DTVDriftMeanTimerCalibration.DTVDriftMeanTimerCalibration.initProcess(), DTDQMHarvesting.DTDQMHarvesting.initProcess(), DTVDriftSegmentCalibration.DTVDriftSegmentCalibration.initProcess(), DTNoiseCalibration.DTNoiseCalibration.initProcess(), DTResidualCalibration.DTResidualCalibration.initProcess(), DTDQMValidation.DTDQMValidation.initProcess(), and DTTTrigValid.DTTTrigValid.initProcess().

def tools.loadCmsProcessFile (   psetName)

Definition at line 140 of file tools.py.

def tools.loadCrabCfg (   cfgName = None)

Definition at line 178 of file tools.py.

Referenced by DTNoiseCalibration.DTNoiseCalibration.initCrab(), DTTTrigProd.DTTTrigProd.initCrab(), DTDQMValidation.DTDQMValidation.initCrab(), DTResidualCalibration.DTResidualCalibration.initCrab(), DTAnalysisResiduals.DTAnalysisResiduals.initCrab(), DTTTrigValid.DTTTrigValid.initCrab(), DTVDriftSegmentCalibration.DTVDriftSegmentCalibration.initCrab(), and DTVDriftMeanTimerCalibration.DTVDriftMeanTimerCalibration.initCrab().

def tools.loadCrabDefault (   crabCfg,
  config 
)

Definition at line 195 of file tools.py.

Referenced by DTNoiseCalibration.DTNoiseCalibration.initCrab(), DTTTrigProd.DTTTrigProd.initCrab(), DTDQMValidation.DTDQMValidation.initCrab(), DTResidualCalibration.DTResidualCalibration.initCrab(), DTAnalysisResiduals.DTAnalysisResiduals.initCrab(), DTTTrigValid.DTTTrigValid.initCrab(), DTVDriftSegmentCalibration.DTVDriftSegmentCalibration.initCrab(), and DTVDriftMeanTimerCalibration.DTVDriftMeanTimerCalibration.initCrab().

def tools.parseInput (   inputFields,
  requiredFields = () 
)

Definition at line 122 of file tools.py.

def tools.prependPaths (   process,
  seqname 
)

Definition at line 154 of file tools.py.

def tools.replaceTemplate (   template,
  opts 
)

Definition at line 5 of file tools.py.

def tools.run_checked (   cmd)
Run `cmd` and exit in case of failures.

Arguments:
- `cmd`: list containing the strings of the command

Definition at line 60 of file tools.py.

References join().

Referenced by create_single_iov_db().

60 
61 def run_checked(cmd):
62  """Run `cmd` and exit in case of failures.
63 
64  Arguments:
65  - `cmd`: list containing the strings of the command
66  """
67 
68  try:
69  with open(os.devnull, "w") as devnull:
70  subprocess.check_call(cmd, stdout = devnull)
71  except subprocess.CalledProcessError as e:
72  print "Problem in running the following command:"
73  print " ".join(e.cmd)
74  sys.exit(1)
def run_checked
Definition: tools.py:60
static std::string join(char **cmd)
Definition: RemoteFile.cc:18
def tools.setGridEnv (   cmssw_dir)

Definition at line 110 of file tools.py.

def tools.writeCfg (   process,
  dir,
  psetName 
)

Definition at line 158 of file tools.py.

def tools.writeCfgPkl (   process,
  dir,
  psetName 
)

Definition at line 162 of file tools.py.