CMS 3D CMS Logo

List of all members | Public Member Functions | Public Attributes
cmsHarvester.CMSHarvester Class Reference

CMSHarvester class. More...

Inheritance diagram for cmsHarvester.CMSHarvester:

Public Member Functions

def __init__ (self, cmd_line_opts=None)
 
def cleanup (self)
 
def config_file_header (self)
 
def db_account_name_cms_cond_dqm_summary (self)
 
def db_account_name_cms_cond_globaltag (self)
 
def format_conditions_string (self, globaltag)
 
def ident_string (self)
 
def option_handler_book_keeping_file (self, option, opt_str, value, parser)
 
def option_handler_debug (self, option, opt_str, value, parser)
 
def option_handler_force (self, option, opt_str, value, parser)
 
def option_handler_frontier_connection (self, option, opt_str, value, parser)
 
def option_handler_globaltag (self, option, opt_str, value, parser)
 
def option_handler_harvesting_mode (self, option, opt_str, value, parser)
 
def option_handler_harvesting_type (self, option, opt_str, value, parser)
 
def option_handler_input_Jsonfile (self, option, opt_str, value, parser)
 
def option_handler_input_Jsonrunfile (self, option, opt_str, value, parser)
 
def option_handler_input_spec (self, option, opt_str, value, parser)
 
def option_handler_input_todofile (self, option, opt_str, value, parser)
 
def option_handler_no_ref_hists (self, option, opt_str, value, parser)
 
def option_handler_quiet (self, option, opt_str, value, parser)
 
def option_handler_ref_hist_mapping_file (self, option, opt_str, value, parser)
 
def set_output_level (self, output_level)
 
def time_stamp (self)
 

Public Attributes

 all_sites_found
 
 book_keeping_file_name
 
 book_keeping_file_name_default
 
 book_keeping_information
 
 caf_access
 
 castor_base_dir
 
 castor_base_dir_default
 
 castor_prefix
 
 cmd_line_opts
 
 crab_submission
 
 datasets_to_ignore
 
 datasets_to_use
 
 force_running
 
 frontier_connection_name
 
 frontier_connection_overridden
 
 globaltag
 
 globaltag_check_cache
 
 harvesting_info
 
 harvesting_mode
 
 harvesting_mode_default
 
 harvesting_modes
 
 harvesting_type
 
 harvesting_types
 
 input_method
 
 input_name
 
 Jsonfilename
 
 Jsonlumi
 
 Jsonrunfilename
 
 log_level
 
 logger
 
 no_matching_site_found_str
 
 non_t1access
 
 nr_max_sites
 
 preferred_site
 
 ref_hist_mappings
 
 ref_hist_mappings_file_name
 
 ref_hist_mappings_file_name_default
 
 runs_to_ignore
 
 runs_to_use
 
 saveByLumiSection
 
 sites_and_versions_cache
 
 todofile
 
 use_ref_hists
 
 version
 

Detailed Description

CMSHarvester class.

Class to perform CMS harvesting.

More documentation `obviously' to follow.

Definition at line 295 of file cmsHarvester.py.

Constructor & Destructor Documentation

◆ __init__()

def cmsHarvester.CMSHarvester.__init__ (   self,
  cmd_line_opts = None 
)

Definition at line 304 of file cmsHarvester.py.

304  def __init__(self, cmd_line_opts=None):
305  "Initialize class and process command line options."
306 
307  self.version = __version__
308 
309  # These are the harvesting types allowed. See the head of this
310  # file for more information.
311  self.harvesting_types = [
312  "RelVal",
313  "RelValFS",
314  "MC",
315  "DQMOffline",
316  ]
317 
318  # These are the possible harvesting modes:
319  # - Single-step: harvesting takes place on-site in a single
320  # step. For each samples only a single ROOT file containing
321  # the harvesting results is returned.
322  # - Single-step-allow-partial: special hack to allow
323  # harvesting of partial statistics using single-step
324  # harvesting on spread-out samples.
325  # - Two-step: harvesting takes place in two steps. The first
326  # step returns a series of monitoring elenent summaries for
327  # each sample. The second step then merges these summaries
328  # locally and does the real harvesting. This second step
329  # produces the ROOT file containing the harvesting results.
330  self.harvesting_modes = [
331  "single-step",
332  "single-step-allow-partial",
333  "two-step"
334  ]
335 
336  # It is possible to specify a GlobalTag that will override any
337  # choices (regarding GlobalTags) made by the cmsHarvester.
338  # BUG BUG BUG
339  # For the moment, until I figure out a way to obtain the
340  # GlobalTag with which a given data (!) dataset was created,
341  # it is necessary to specify a GlobalTag for harvesting of
342  # data.
343  # BUG BUG BUG end
344  self.globaltag = None
345 
346  # It's also possible to switch off the use of reference
347  # histograms altogether.
348  self.use_ref_hists = True
349 
350  # The database name and account are hard-coded. They are not
351  # likely to change before the end-of-life of this tool. But of
352  # course there is a way to override this from the command
353  # line. One can even override the Frontier connection used for
354  # the GlobalTag and for the reference histograms
355  # independently. Please only use this for testing purposes.
356  self.frontier_connection_name = {}
357  self.frontier_connection_name["globaltag"] = "frontier://" \
358  "FrontierProd/"
359  self.frontier_connection_name["refhists"] = "frontier://" \
360  "FrontierProd/"
361  self.frontier_connection_overridden = {}
362  for key in self.frontier_connection_name.keys():
363  self.frontier_connection_overridden[key] = False
364 
365  # This contains information specific to each of the harvesting
366  # types. Used to create the harvesting configuration. It is
367  # filled by setup_harvesting_info().
368  self.harvesting_info = None
369 
370 
371 
372  # These are default `unused' values that will be filled in
373  # depending on the command line options.
374 
375  # The type of harvesting we're doing. See
376  # self.harvesting_types for allowed types.
377  self.harvesting_type = None
378 
379  # The harvesting mode, popularly known as single-step
380  # vs. two-step. The thing to remember at this point is that
381  # single-step is only possible for samples located completely
382  # at a single site (i.e. SE).
383  self.harvesting_mode = None
384  # BUG BUG BUG
385  # Default temporarily set to two-step until we can get staged
386  # jobs working with CRAB.
387  self.harvesting_mode_default = "single-step"
388  # BUG BUG BUG end
389 
390  # The input method: are we reading a dataset name (or regexp)
391  # directly from the command line or are we reading a file
392  # containing a list of dataset specifications. Actually we
393  # keep one of each for both datasets and runs.
394  self.input_method = {}
395  self.input_method["datasets"] = {}
396  self.input_method["datasets"]["use"] = None
397  self.input_method["datasets"]["ignore"] = None
398  self.input_method["runs"] = {}
399  self.input_method["runs"]["use"] = None
400  self.input_method["runs"]["ignore"] = None
401  self.input_method["runs"]["ignore"] = None
402  # The name of whatever input we're using.
403  self.input_name = {}
404  self.input_name["datasets"] = {}
405  self.input_name["datasets"]["use"] = None
406  self.input_name["datasets"]["ignore"] = None
407  self.input_name["runs"] = {}
408  self.input_name["runs"]["use"] = None
409  self.input_name["runs"]["ignore"] = None
410 
411  self.Jsonlumi = False
412  self.Jsonfilename = "YourJSON.txt"
413  self.Jsonrunfilename = "YourJSON.txt"
414  self.todofile = "YourToDofile.txt"
415 
416  # If this is true, we're running in `force mode'. In this case
417  # the sanity checks are performed but failure will not halt
418  # everything.
419  self.force_running = None
420 
421  # The base path of the output dir in CASTOR.
422  self.castor_base_dir = None
423  self.castor_base_dir_default = "/castor/cern.ch/" \
424  "cms/store/temp/" \
425  "dqm/offline/harvesting_output/"
426 
427  # The name of the file to be used for book keeping: which
428  # datasets, runs, etc. we have already processed.
429  self.book_keeping_file_name = None
430  self.book_keeping_file_name_default = "harvesting_accounting.txt"
431 
432  # The dataset name to reference histogram name mapping is read
433  # from a text file. The name of this file is kept in the
434  # following variable.
435  self.ref_hist_mappings_file_name = None
436  # And this is the default value.
437  self.ref_hist_mappings_file_name_default = "harvesting_ref_hist_mappings.txt"
438 
439  # Hmmm, hard-coded prefix of the CERN CASTOR area. This is the
440  # only supported CASTOR area.
441  # NOTE: Make sure this one starts with a `/'.
442  self.castor_prefix = "/castor/cern.ch"
443 
444  # Normally the central harvesting should be done using the
445  # `t1access' grid role. To be able to run without T1 access
446  # the --no-t1access flag can be used. This variable keeps
447  # track of that special mode.
448  self.non_t1access = False
449  self.caf_access = False
450  self.saveByLumiSection = False
451  self.crab_submission = False
452  self.nr_max_sites = 1
453 
454  self.preferred_site = "no preference"
455 
456  # This will become the list of datasets and runs to consider
457  self.datasets_to_use = {}
458  # and this will become the list of datasets and runs to skip.
459  self.datasets_to_ignore = {}
460  # This, in turn, will hold all book keeping information.
461  self.book_keeping_information = {}
462  # And this is where the dataset name to reference histogram
463  # name mapping is stored.
464  self.ref_hist_mappings = {}
465 
466  # We're now also allowing run selection. This means we also
467  # have to keep list of runs requested and vetoed by the user.
468  self.runs_to_use = {}
469  self.runs_to_ignore = {}
470 
471  # Cache for CMSSW version availability at different sites.
472  self.sites_and_versions_cache = {}
473 
474  # Cache for checked GlobalTags.
475  self.globaltag_check_cache = []
476 
477  # Global flag to see if there were any jobs for which we could
478  # not find a matching site.
479  self.all_sites_found = True
480 
481  # Helper string centrally defined.
482  self.no_matching_site_found_str = "no_matching_site_found"
483 
484  # Store command line options for later use.
485  if cmd_line_opts is None:
486  cmd_line_opts = sys.argv[1:]
487  self.cmd_line_opts = cmd_line_opts
488 
489  # Set up the logger.
490  log_handler = logging.StreamHandler()
491  # This is the default log formatter, the debug option switches
492  # on some more information.
493  log_formatter = logging.Formatter("%(message)s")
494  log_handler.setFormatter(log_formatter)
495  logger = logging.getLogger()
496  logger.name = "main"
497  logger.addHandler(log_handler)
498  self.logger = logger
499  # The default output mode is quite verbose.
500  self.set_output_level("NORMAL")
501 
502  #logger.debug("Initialized successfully")
503 
504  # End of __init__.
505 
def __init__(self, dataset, job_number, job_id, job_name, isDA, isMC, applyBOWS, applyEXTRACOND, extraconditions, runboundary, lumilist, intlumi, maxevents, gt, allFromGT, alignmentDB, alignmentTAG, apeDB, apeTAG, bowDB, bowTAG, vertextype, tracktype, refittertype, ttrhtype, applyruncontrol, ptcut, CMSSW_dir, the_dir)

Member Function Documentation

◆ cleanup()

def cmsHarvester.CMSHarvester.cleanup (   self)

Definition at line 508 of file cmsHarvester.py.

Referenced by esMonitoring.FDJsonServer.handle_close().

508  def cleanup(self):
509  "Clean up after ourselves."
510 
511  # NOTE: This is the safe replacement of __del__.
512 
513  #self.logger.debug("All done -> shutting down")
514  logging.shutdown()
515 
516  # End of cleanup.
517 

◆ config_file_header()

def cmsHarvester.CMSHarvester.config_file_header (   self)

Definition at line 602 of file cmsHarvester.py.

References cmsHarvester.CMSHarvester.ident_string(), join(), and cmsHarvester.CMSHarvester.time_stamp().

602  def config_file_header(self):
603  "Create a nice header to be used to mark the generated files."
604 
605  tmp = []
606 
607  time_stamp = self.time_stamp()
608  ident_str = self.ident_string()
609  tmp.append("# %s" % time_stamp)
610  tmp.append("# WARNING: This file was created automatically!")
611  tmp.append("")
612  tmp.append("# Created by %s" % ident_str)
613 
614  header = "\n".join(tmp)
615 
616  # End of config_file_header.
617  return header
618 
static std::string join(char **cmd)
Definition: RemoteFile.cc:19

◆ db_account_name_cms_cond_dqm_summary()

def cmsHarvester.CMSHarvester.db_account_name_cms_cond_dqm_summary (   self)
See db_account_name_cms_cond_globaltag.

Definition at line 587 of file cmsHarvester.py.

587  def db_account_name_cms_cond_dqm_summary(self):
588  """See db_account_name_cms_cond_globaltag."""
589 
590  account_name = None
591  version = self.cmssw_version[6:11]
592  if version < "3_4_0":
593  account_name = "CMS_COND_31X_DQM_SUMMARY"
594  else:
595  account_name = "CMS_COND_34X"
596 
597  # End of db_account_name_cms_cond_dqm_summary.
598  return account_name
599 

◆ db_account_name_cms_cond_globaltag()

def cmsHarvester.CMSHarvester.db_account_name_cms_cond_globaltag (   self)
Return the database account name used to store the GlobalTag.

The name of the database account depends (albeit weakly) on
the CMSSW release version.

Definition at line 570 of file cmsHarvester.py.

570  def db_account_name_cms_cond_globaltag(self):
571  """Return the database account name used to store the GlobalTag.
572 
573  The name of the database account depends (albeit weakly) on
574  the CMSSW release version.
575 
576  """
577 
578  # This never changed, unlike the cms_cond_31X_DQM_SUMMARY ->
579  # cms_cond_34X_DQM transition.
580  account_name = "CMS_COND_31X_GLOBALTAG"
581 
582  # End of db_account_name_cms_cond_globaltag.
583  return account_name
584 

◆ format_conditions_string()

def cmsHarvester.CMSHarvester.format_conditions_string (   self,
  globaltag 
)
Create the conditions string needed for `cmsDriver'.

Just glueing the FrontierConditions bit in front of it really.

Definition at line 545 of file cmsHarvester.py.

References spr.find().

545  def format_conditions_string(self, globaltag):
546  """Create the conditions string needed for `cmsDriver'.
547 
548  Just glueing the FrontierConditions bit in front of it really.
549 
550  """
551 
552  # Not very robust but okay. The idea is that if the user
553  # specified (since this cannot happen with GlobalTags coming
554  # from DBS) something containing `conditions', they probably
555  # know what they're doing and we should not muck things up. In
556  # all other cases we just assume we only received the
557  # GlobalTag part and we built the usual conditions string from
558  # that .
559  if globaltag.lower().find("conditions") > -1:
560  conditions_string = globaltag
561  else:
562  conditions_string = "FrontierConditions_GlobalTag,%s" % \
563  globaltag
564 
565  # End of format_conditions_string.
566  return conditions_string
567 
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19

◆ ident_string()

def cmsHarvester.CMSHarvester.ident_string (   self)

Definition at line 533 of file cmsHarvester.py.

Referenced by cmsHarvester.CMSHarvester.config_file_header().

533  def ident_string(self):
534  "Spit out an identification string for cmsHarvester.py."
535 
536  ident_str = "`cmsHarvester.py " \
537  "version %s': cmsHarvester.py %s" % \
538  (__version__,
539  reduce(lambda x, y: x+' '+y, sys.argv[1:]))
540 
541  return ident_str
542 

◆ option_handler_book_keeping_file()

def cmsHarvester.CMSHarvester.option_handler_book_keeping_file (   self,
  option,
  opt_str,
  value,
  parser 
)
Store the name of the file to be used for book keeping.

The only check done here is that only a single book keeping
file is specified.

Definition at line 962 of file cmsHarvester.py.

References cmsHarvester.CMSHarvester.book_keeping_file_name, info(), crabFunctions.CrabController.logger, o2olib.O2OJobMgr.logger, conddb_version_mgr.conddb_tool.logger, o2olib.O2ORunMgr.logger, and cmsHarvester.CMSHarvester.logger.

962  def option_handler_book_keeping_file(self, option, opt_str, value, parser):
963  """Store the name of the file to be used for book keeping.
964 
965  The only check done here is that only a single book keeping
966  file is specified.
967 
968  """
969 
970  file_name = value
971 
972  if not self.book_keeping_file_name is None:
973  msg = "Only one book keeping file should be specified"
974  self.logger.fatal(msg)
975  raise Usage(msg)
976  self.book_keeping_file_name = file_name
977 
978  self.logger.info("Book keeping file to be used: `%s'" % \
979  self.book_keeping_file_name)
980 
981  # End of option_handler_book_keeping_file.
982 
static const TGPicture * info(bool iBackgroundIsBlack)

◆ option_handler_debug()

def cmsHarvester.CMSHarvester.option_handler_debug (   self,
  option,
  opt_str,
  value,
  parser 
)
Switch to debug mode.

This both increases the amount of output generated, as well as
changes the format used (more detailed information is given).

Definition at line 660 of file cmsHarvester.py.

References crabFunctions.CrabController.logger, o2olib.O2OJobMgr.logger, conddb_version_mgr.conddb_tool.logger, o2olib.O2ORunMgr.logger, cmsHarvester.CMSHarvester.logger, and cmsHarvester.CMSHarvester.set_output_level().

660  def option_handler_debug(self, option, opt_str, value, parser):
661  """Switch to debug mode.
662 
663  This both increases the amount of output generated, as well as
664  changes the format used (more detailed information is given).
665 
666  """
667 
668  # Switch to a more informative log formatter for debugging.
669  log_formatter_debug = logging.Formatter("[%(levelname)s] " \
670  # NOTE: funcName was
671  # only implemented
672  # starting with python
673  # 2.5.
674  #"%(funcName)s() " \
675  #"@%(filename)s:%(lineno)d " \
676  "%(message)s")
677  # Hmmm, not very nice. This assumes there's only a single
678  # handler associated with the current logger.
679  log_handler = self.logger.handlers[0]
680  log_handler.setFormatter(log_formatter_debug)
681  self.set_output_level("DEBUG")
682 
683  # End of option_handler_debug.
684 

◆ option_handler_force()

def cmsHarvester.CMSHarvester.option_handler_force (   self,
  option,
  opt_str,
  value,
  parser 
)
Switch on `force mode' in which case we don't brake for nobody.

In so-called `force mode' all sanity checks are performed but
we don't halt on failure. Of course this requires some care
from the user.

Definition at line 696 of file cmsHarvester.py.

References debug, cmsHarvester.CMSHarvester.force_running, crabFunctions.CrabController.logger, o2olib.O2OJobMgr.logger, conddb_version_mgr.conddb_tool.logger, o2olib.O2ORunMgr.logger, and cmsHarvester.CMSHarvester.logger.

696  def option_handler_force(self, option, opt_str, value, parser):
697  """Switch on `force mode' in which case we don't brake for nobody.
698 
699  In so-called `force mode' all sanity checks are performed but
700  we don't halt on failure. Of course this requires some care
701  from the user.
702 
703  """
704 
705  self.logger.debug("Switching on `force mode'.")
706  self.force_running = True
707 
708  # End of option_handler_force.
709 
#define debug
Definition: HDRShower.cc:19

◆ option_handler_frontier_connection()

def cmsHarvester.CMSHarvester.option_handler_frontier_connection (   self,
  option,
  opt_str,
  value,
  parser 
)
Override the default Frontier connection string.

Please only use this for testing (e.g. when a test payload has
been inserted into cms_orc_off instead of cms_orc_on).

This method gets called for three different command line
options:
- --frontier-connection,
- --frontier-connection-for-globaltag,
- --frontier-connection-for-refhists.
Appropriate care has to be taken to make sure things are only
specified once.

Definition at line 824 of file cmsHarvester.py.

References cmsHarvester.CMSHarvester.frontier_connection_name, cmsHarvester.CMSHarvester.frontier_connection_overridden, relativeConstraints.keys, crabFunctions.CrabController.logger, o2olib.O2OJobMgr.logger, conddb_version_mgr.conddb_tool.logger, o2olib.O2ORunMgr.logger, cmsHarvester.CMSHarvester.logger, and MessageLogger_cfi.warning.

Referenced by cmsHarvester.CMSHarvester.option_handler_no_ref_hists().

824  value, parser):
825  """Override the default Frontier connection string.
826 
827  Please only use this for testing (e.g. when a test payload has
828  been inserted into cms_orc_off instead of cms_orc_on).
829 
830  This method gets called for three different command line
831  options:
832  - --frontier-connection,
833  - --frontier-connection-for-globaltag,
834  - --frontier-connection-for-refhists.
835  Appropriate care has to be taken to make sure things are only
836  specified once.
837 
838  """
839 
840  # Figure out with which command line option we've been called.
841  frontier_type = opt_str.split("-")[-1]
842  if frontier_type == "connection":
843  # Main option: change all connection strings.
844  frontier_types = self.frontier_connection_name.keys()
845  else:
846  frontier_types = [frontier_type]
847 
848  # Make sure that each Frontier connection is specified only
849  # once. (Okay, in a bit of a dodgy way...)
850  for connection_name in frontier_types:
851  if self.frontier_connection_overridden[connection_name] == True:
852  msg = "Please specify either:\n" \
853  " `--frontier-connection' to change the " \
854  "Frontier connection used for everything, or\n" \
855  "either one or both of\n" \
856  " `--frontier-connection-for-globaltag' to " \
857  "change the Frontier connection used for the " \
858  "GlobalTag and\n" \
859  " `--frontier-connection-for-refhists' to change " \
860  "the Frontier connection used for the " \
861  "reference histograms."
862  self.logger.fatal(msg)
863  raise Usage(msg)
864 
865  frontier_prefix = "frontier://"
866  if not value.startswith(frontier_prefix):
867  msg = "Expecting Frontier connections to start with " \
868  "`%s'. You specified `%s'." % \
869  (frontier_prefix, value)
870  self.logger.fatal(msg)
871  raise Usage(msg)
872  # We also kind of expect this to be either FrontierPrep or
873  # FrontierProd (but this is just a warning).
874  if value.find("FrontierProd") < 0 and \
875  value.find("FrontierProd") < 0:
876  msg = "Expecting Frontier connections to contain either " \
877  "`FrontierProd' or `FrontierPrep'. You specified " \
878  "`%s'. Are you sure?" % \
879  value
880  self.logger.warning(msg)
881 
882  if not value.endswith("/"):
883  value += "/"
884 
885  for connection_name in frontier_types:
886  self.frontier_connection_name[connection_name] = value
887  self.frontier_connection_overridden[connection_name] = True
888 
889  frontier_type_str = "unknown"
890  if connection_name == "globaltag":
891  frontier_type_str = "the GlobalTag"
892  elif connection_name == "refhists":
893  frontier_type_str = "the reference histograms"
894 
895  self.logger.warning("Overriding default Frontier " \
896  "connection for %s " \
897  "with `%s'" % \
898  (frontier_type_str,
899  self.frontier_connection_name[connection_name]))
900 
901  # End of option_handler_frontier_connection
902 

◆ option_handler_globaltag()

def cmsHarvester.CMSHarvester.option_handler_globaltag (   self,
  option,
  opt_str,
  value,
  parser 
)
Set the GlobalTag to be used, overriding our own choices.

By default the cmsHarvester will use the GlobalTag with which
a given dataset was created also for the harvesting. The
--globaltag option is the way to override this behaviour.

Definition at line 789 of file cmsHarvester.py.

References alignment.Alignment.globaltag, cmsHarvester.CMSHarvester.globaltag, info(), crabFunctions.CrabController.logger, o2olib.O2OJobMgr.logger, conddb_version_mgr.conddb_tool.logger, o2olib.O2ORunMgr.logger, and cmsHarvester.CMSHarvester.logger.

789  def option_handler_globaltag(self, option, opt_str, value, parser):
790  """Set the GlobalTag to be used, overriding our own choices.
791 
792  By default the cmsHarvester will use the GlobalTag with which
793  a given dataset was created also for the harvesting. The
794  --globaltag option is the way to override this behaviour.
795 
796  """
797 
798  # Make sure that this flag only occurred once.
799  if not self.globaltag is None:
800  msg = "Only one GlobalTag should be specified"
801  self.logger.fatal(msg)
802  raise Usage(msg)
803  self.globaltag = value
804 
805  self.logger.info("GlobalTag to be used: `%s'" % \
806  self.globaltag)
807 
808  # End of option_handler_globaltag.
809 
static const TGPicture * info(bool iBackgroundIsBlack)

◆ option_handler_harvesting_mode()

def cmsHarvester.CMSHarvester.option_handler_harvesting_mode (   self,
  option,
  opt_str,
  value,
  parser 
)
Set the harvesting mode to be used.

Single-step harvesting can be used for samples that are
located completely at a single site (= SE). Otherwise use
two-step mode.

Definition at line 756 of file cmsHarvester.py.

References cmsHarvester.CMSHarvester.harvesting_mode, cmsHarvester.CMSHarvester.harvesting_modes, info(), join(), crabFunctions.CrabController.logger, o2olib.O2OJobMgr.logger, conddb_version_mgr.conddb_tool.logger, o2olib.O2ORunMgr.logger, and cmsHarvester.CMSHarvester.logger.

756  def option_handler_harvesting_mode(self, option, opt_str, value, parser):
757  """Set the harvesting mode to be used.
758 
759  Single-step harvesting can be used for samples that are
760  located completely at a single site (= SE). Otherwise use
761  two-step mode.
762 
763  """
764 
765  # Check for valid mode.
766  harvesting_mode = value.lower()
767  if not harvesting_mode in self.harvesting_modes:
768  msg = "Unknown harvesting mode `%s'" % harvesting_mode
769  self.logger.fatal(msg)
770  self.logger.fatal(" possible modes are: %s" % \
771  ", ".join(self.harvesting_modes))
772  raise Usage(msg)
773 
774  # Check if we've been given only a single mode, otherwise
775  # complain.
776  if not self.harvesting_mode is None:
777  msg = "Only one harvesting mode should be specified"
778  self.logger.fatal(msg)
779  raise Usage(msg)
780  self.harvesting_mode = harvesting_mode
781 
782  self.logger.info("Harvesting mode to be used: `%s'" % \
783  self.harvesting_mode)
784 
785  # End of option_handler_harvesting_mode.
786 
static const TGPicture * info(bool iBackgroundIsBlack)
static std::string join(char **cmd)
Definition: RemoteFile.cc:19

◆ option_handler_harvesting_type()

def cmsHarvester.CMSHarvester.option_handler_harvesting_type (   self,
  option,
  opt_str,
  value,
  parser 
)
Set the harvesting type to be used.

This checks that no harvesting type is already set, and sets
the harvesting type to be used to the one specified. If a
harvesting type is already set an exception is thrown. The
same happens when an unknown type is specified.

Definition at line 712 of file cmsHarvester.py.

References cmsHarvester.CMSHarvester.harvesting_type, cmsHarvester.CMSHarvester.harvesting_types, info(), join(), crabFunctions.CrabController.logger, o2olib.O2OJobMgr.logger, conddb_version_mgr.conddb_tool.logger, o2olib.O2ORunMgr.logger, and cmsHarvester.CMSHarvester.logger.

712  def option_handler_harvesting_type(self, option, opt_str, value, parser):
713  """Set the harvesting type to be used.
714 
715  This checks that no harvesting type is already set, and sets
716  the harvesting type to be used to the one specified. If a
717  harvesting type is already set an exception is thrown. The
718  same happens when an unknown type is specified.
719 
720  """
721 
722  # Check for (in)valid harvesting types.
723  # NOTE: The matching is done in a bit of a complicated
724  # way. This allows the specification of the type to be
725  # case-insensitive while still ending up with the properly
726  # `cased' version afterwards.
727  value = value.lower()
728  harvesting_types_lowered = [i.lower() for i in self.harvesting_types]
729  try:
730  type_index = harvesting_types_lowered.index(value)
731  # If this works, we now have the index to the `properly
732  # cased' version of the harvesting type.
733  except ValueError:
734  self.logger.fatal("Unknown harvesting type `%s'" % \
735  value)
736  self.logger.fatal(" possible types are: %s" %
737  ", ".join(self.harvesting_types))
738  raise Usage("Unknown harvesting type `%s'" % \
739  value)
740 
741  # Check if multiple (by definition conflicting) harvesting
742  # types are being specified.
743  if not self.harvesting_type is None:
744  msg = "Only one harvesting type should be specified"
745  self.logger.fatal(msg)
746  raise Usage(msg)
747  self.harvesting_type = self.harvesting_types[type_index]
748 
749  self.logger.info("Harvesting type to be used: `%s'" % \
750  self.harvesting_type)
751 
752  # End of option_handler_harvesting_type.
753 
static const TGPicture * info(bool iBackgroundIsBlack)
static std::string join(char **cmd)
Definition: RemoteFile.cc:19

◆ option_handler_input_Jsonfile()

def cmsHarvester.CMSHarvester.option_handler_input_Jsonfile (   self,
  option,
  opt_str,
  value,
  parser 
)

Definition at line 912 of file cmsHarvester.py.

References cmsHarvester.CMSHarvester.Jsonfilename.

912  def option_handler_input_Jsonfile(self, option, opt_str, value, parser):
913 
914  self.Jsonfilename = value
915  # End of option_handler_input_Jsonfile.
916 

◆ option_handler_input_Jsonrunfile()

def cmsHarvester.CMSHarvester.option_handler_input_Jsonrunfile (   self,
  option,
  opt_str,
  value,
  parser 
)

Definition at line 919 of file cmsHarvester.py.

References cmsHarvester.CMSHarvester.Jsonrunfilename.

919  def option_handler_input_Jsonrunfile(self, option, opt_str, value, parser):
920 
921  self.Jsonrunfilename = value
922  # End of option_handler_input_Jsonrunfile.
923 

◆ option_handler_input_spec()

def cmsHarvester.CMSHarvester.option_handler_input_spec (   self,
  option,
  opt_str,
  value,
  parser 
)
TODO TODO TODO
Document this...

Definition at line 926 of file cmsHarvester.py.

References debug, spr.find(), cmsHarvester.CMSHarvester.input_method, cmsHarvester.CMSHarvester.input_name, crabFunctions.CrabController.logger, o2olib.O2OJobMgr.logger, conddb_version_mgr.conddb_tool.logger, o2olib.O2ORunMgr.logger, cmsHarvester.CMSHarvester.logger, and python.rootplot.root2matplotlib.replace().

926  def option_handler_input_spec(self, option, opt_str, value, parser):
927  """TODO TODO TODO
928  Document this...
929 
930  """
931 
932  # Figure out if we were called for the `use these' or the
933  # `ignore these' case.
934  if opt_str.lower().find("ignore") > -1:
935  spec_type = "ignore"
936  else:
937  spec_type = "use"
938 
939  # Similar: are we being called for datasets or for runs?
940  if opt_str.lower().find("dataset") > -1:
941  select_type = "datasets"
942  else:
943  select_type = "runs"
944 
945  if not self.input_method[select_type][spec_type] is None:
946  msg = "Please only specify one input method " \
947  "(for the `%s' case)" % opt_str
948  self.logger.fatal(msg)
949  raise Usage(msg)
950 
951  input_method = opt_str.replace("-", "").replace("ignore", "")
952  self.input_method[select_type][spec_type] = input_method
953  self.input_name[select_type][spec_type] = value
954 
955  self.logger.debug("Input method for the `%s' case: %s" % \
956  (spec_type, input_method))
957 
958  # End of option_handler_input_spec
959 
def replace(string, replacements)
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
#define debug
Definition: HDRShower.cc:19

◆ option_handler_input_todofile()

def cmsHarvester.CMSHarvester.option_handler_input_todofile (   self,
  option,
  opt_str,
  value,
  parser 
)

Definition at line 905 of file cmsHarvester.py.

References cmsHarvester.CMSHarvester.todofile.

905  def option_handler_input_todofile(self, option, opt_str, value, parser):
906 
907  self.todofile = value
908  # End of option_handler_input_todofile.
909 

◆ option_handler_no_ref_hists()

def cmsHarvester.CMSHarvester.option_handler_no_ref_hists (   self,
  option,
  opt_str,
  value,
  parser 
)

Definition at line 812 of file cmsHarvester.py.

References crabFunctions.CrabController.logger, o2olib.O2OJobMgr.logger, conddb_version_mgr.conddb_tool.logger, o2olib.O2ORunMgr.logger, cmsHarvester.CMSHarvester.logger, cmsHarvester.CMSHarvester.option_handler_frontier_connection(), cmsHarvester.CMSHarvester.use_ref_hists, and MessageLogger_cfi.warning.

812  def option_handler_no_ref_hists(self, option, opt_str, value, parser):
813  "Switch use of all reference histograms off."
814 
815  self.use_ref_hists = False
816 
817  self.logger.warning("Switching off all use of reference histograms")
818 
819  # End of option_handler_no_ref_hists.
820 
821 
822 

◆ option_handler_quiet()

def cmsHarvester.CMSHarvester.option_handler_quiet (   self,
  option,
  opt_str,
  value,
  parser 
)

Definition at line 687 of file cmsHarvester.py.

References cmsHarvester.CMSHarvester.set_output_level().

687  def option_handler_quiet(self, option, opt_str, value, parser):
688  "Switch to quiet mode: less verbose."
689 
690  self.set_output_level("QUIET")
691 
692  # End of option_handler_quiet.
693 

◆ option_handler_ref_hist_mapping_file()

def cmsHarvester.CMSHarvester.option_handler_ref_hist_mapping_file (   self,
  option,
  opt_str,
  value,
  parser 
)
Store the name of the file for the ref. histogram mapping.

Definition at line 985 of file cmsHarvester.py.

References info(), crabFunctions.CrabController.logger, o2olib.O2OJobMgr.logger, conddb_version_mgr.conddb_tool.logger, o2olib.O2ORunMgr.logger, cmsHarvester.CMSHarvester.logger, and cmsHarvester.CMSHarvester.ref_hist_mappings_file_name.

985  def option_handler_ref_hist_mapping_file(self, option, opt_str, value, parser):
986  """Store the name of the file for the ref. histogram mapping.
987 
988  """
989 
990  file_name = value
991 
992  if not self.ref_hist_mappings_file_name is None:
993  msg = "Only one reference histogram mapping file " \
994  "should be specified"
995  self.logger.fatal(msg)
996  raise Usage(msg)
997  self.ref_hist_mappings_file_name = file_name
998 
999  self.logger.info("Reference histogram mapping file " \
1000  "to be used: `%s'" % \
1001  self.ref_hist_mappings_file_name)
1002 
1003  # End of option_handler_ref_hist_mapping_file.
1004 
static const TGPicture * info(bool iBackgroundIsBlack)

◆ set_output_level()

def cmsHarvester.CMSHarvester.set_output_level (   self,
  output_level 
)
Adjust the level of output generated.

Choices are:
  - normal  : default level of output
  - quiet   : less output than the default
  - verbose : some additional information
  - debug   : lots more information, may be overwhelming

NOTE: The debug option is a bit special in the sense that it
      also modifies the output format.

Definition at line 621 of file cmsHarvester.py.

Referenced by cmsHarvester.CMSHarvester.option_handler_debug(), and cmsHarvester.CMSHarvester.option_handler_quiet().

621  def set_output_level(self, output_level):
622  """Adjust the level of output generated.
623 
624  Choices are:
625  - normal : default level of output
626  - quiet : less output than the default
627  - verbose : some additional information
628  - debug : lots more information, may be overwhelming
629 
630  NOTE: The debug option is a bit special in the sense that it
631  also modifies the output format.
632 
633  """
634 
635  # NOTE: These levels are hooked up to the ones used in the
636  # logging module.
637  output_levels = {
638  "NORMAL" : logging.INFO,
639  "QUIET" : logging.WARNING,
640  "VERBOSE" : logging.INFO,
641  "DEBUG" : logging.DEBUG
642  }
643 
644  output_level = output_level.upper()
645 
646  try:
647  # Update the logger.
648  self.log_level = output_levels[output_level]
649  self.logger.setLevel(self.log_level)
650  except KeyError:
651  # Show a complaint
652  self.logger.fatal("Unknown output level `%s'" % ouput_level)
653  # and re-raise an exception.
654  raise Exception
655 
656  # End of set_output_level.
657 

◆ time_stamp()

def cmsHarvester.CMSHarvester.time_stamp (   self)

Definition at line 520 of file cmsHarvester.py.

Referenced by cmsHarvester.CMSHarvester.config_file_header().

520  def time_stamp(self):
521  "Create a timestamp to use in the created config files."
522 
523  time_now = datetime.datetime.utcnow()
524  # We don't care about the microseconds.
525  time_now = time_now.replace(microsecond = 0)
526  time_stamp = "%sUTC" % datetime.datetime.isoformat(time_now)
527 
528  # End of time_stamp.
529  return time_stamp
530 

Member Data Documentation

◆ all_sites_found

cmsHarvester.CMSHarvester.all_sites_found

Definition at line 479 of file cmsHarvester.py.

◆ book_keeping_file_name

cmsHarvester.CMSHarvester.book_keeping_file_name

◆ book_keeping_file_name_default

cmsHarvester.CMSHarvester.book_keeping_file_name_default

Definition at line 430 of file cmsHarvester.py.

◆ book_keeping_information

cmsHarvester.CMSHarvester.book_keeping_information

Definition at line 461 of file cmsHarvester.py.

◆ caf_access

cmsHarvester.CMSHarvester.caf_access

Definition at line 449 of file cmsHarvester.py.

◆ castor_base_dir

cmsHarvester.CMSHarvester.castor_base_dir

Definition at line 422 of file cmsHarvester.py.

◆ castor_base_dir_default

cmsHarvester.CMSHarvester.castor_base_dir_default

Definition at line 423 of file cmsHarvester.py.

◆ castor_prefix

cmsHarvester.CMSHarvester.castor_prefix

Definition at line 442 of file cmsHarvester.py.

◆ cmd_line_opts

cmsHarvester.CMSHarvester.cmd_line_opts

Definition at line 487 of file cmsHarvester.py.

◆ crab_submission

cmsHarvester.CMSHarvester.crab_submission

Definition at line 451 of file cmsHarvester.py.

◆ datasets_to_ignore

cmsHarvester.CMSHarvester.datasets_to_ignore

Definition at line 459 of file cmsHarvester.py.

◆ datasets_to_use

cmsHarvester.CMSHarvester.datasets_to_use

Definition at line 457 of file cmsHarvester.py.

◆ force_running

cmsHarvester.CMSHarvester.force_running

Definition at line 419 of file cmsHarvester.py.

Referenced by cmsHarvester.CMSHarvester.option_handler_force().

◆ frontier_connection_name

cmsHarvester.CMSHarvester.frontier_connection_name

◆ frontier_connection_overridden

cmsHarvester.CMSHarvester.frontier_connection_overridden

◆ globaltag

cmsHarvester.CMSHarvester.globaltag

Definition at line 344 of file cmsHarvester.py.

Referenced by cmsHarvester.CMSHarvester.option_handler_globaltag().

◆ globaltag_check_cache

cmsHarvester.CMSHarvester.globaltag_check_cache

Definition at line 475 of file cmsHarvester.py.

◆ harvesting_info

cmsHarvester.CMSHarvester.harvesting_info

Definition at line 368 of file cmsHarvester.py.

◆ harvesting_mode

cmsHarvester.CMSHarvester.harvesting_mode

◆ harvesting_mode_default

cmsHarvester.CMSHarvester.harvesting_mode_default

Definition at line 387 of file cmsHarvester.py.

◆ harvesting_modes

cmsHarvester.CMSHarvester.harvesting_modes

◆ harvesting_type

cmsHarvester.CMSHarvester.harvesting_type

◆ harvesting_types

cmsHarvester.CMSHarvester.harvesting_types

◆ input_method

cmsHarvester.CMSHarvester.input_method

◆ input_name

cmsHarvester.CMSHarvester.input_name

◆ Jsonfilename

cmsHarvester.CMSHarvester.Jsonfilename

◆ Jsonlumi

cmsHarvester.CMSHarvester.Jsonlumi

Definition at line 411 of file cmsHarvester.py.

◆ Jsonrunfilename

cmsHarvester.CMSHarvester.Jsonrunfilename

◆ log_level

cmsHarvester.CMSHarvester.log_level

Definition at line 648 of file cmsHarvester.py.

◆ logger

cmsHarvester.CMSHarvester.logger

◆ no_matching_site_found_str

cmsHarvester.CMSHarvester.no_matching_site_found_str

Definition at line 482 of file cmsHarvester.py.

◆ non_t1access

cmsHarvester.CMSHarvester.non_t1access

Definition at line 448 of file cmsHarvester.py.

◆ nr_max_sites

cmsHarvester.CMSHarvester.nr_max_sites

Definition at line 452 of file cmsHarvester.py.

◆ preferred_site

cmsHarvester.CMSHarvester.preferred_site

Definition at line 454 of file cmsHarvester.py.

◆ ref_hist_mappings

cmsHarvester.CMSHarvester.ref_hist_mappings

Definition at line 464 of file cmsHarvester.py.

◆ ref_hist_mappings_file_name

cmsHarvester.CMSHarvester.ref_hist_mappings_file_name

◆ ref_hist_mappings_file_name_default

cmsHarvester.CMSHarvester.ref_hist_mappings_file_name_default

Definition at line 437 of file cmsHarvester.py.

◆ runs_to_ignore

cmsHarvester.CMSHarvester.runs_to_ignore

Definition at line 469 of file cmsHarvester.py.

◆ runs_to_use

cmsHarvester.CMSHarvester.runs_to_use

Definition at line 468 of file cmsHarvester.py.

◆ saveByLumiSection

cmsHarvester.CMSHarvester.saveByLumiSection

Definition at line 450 of file cmsHarvester.py.

◆ sites_and_versions_cache

cmsHarvester.CMSHarvester.sites_and_versions_cache

Definition at line 472 of file cmsHarvester.py.

◆ todofile

cmsHarvester.CMSHarvester.todofile

◆ use_ref_hists

cmsHarvester.CMSHarvester.use_ref_hists

◆ version

cmsHarvester.CMSHarvester.version