Esempio n. 1
0
def setup(process, binary_files, tree_files, run_start_geometry):
    """Pede-specific setup.

    Arguments:
    - `process`: cms.Process object
    - `binary_files`: list of binary files to be read by pede
    - `tree_files`: list of ROOT files created in the mille step
    - `run_start_geometry`: run ID to pick the start geometry
    """

    # write alignments, APEs, and surface deformations to DB by default
    # --------------------------------------------------------------------------
    process.AlignmentProducer.saveToDB = True
    process.AlignmentProducer.saveApeToDB = True
    process.AlignmentProducer.saveDeformationsToDB = True

    # setup database output module
    # --------------------------------------------------------------------------
    from CondCore.CondDB.CondDB_cfi import CondDB
    process.PoolDBOutputService = cms.Service(
        "PoolDBOutputService",
        CondDB.clone(connect="sqlite_file:alignments_MP.db"),
        timetype=cms.untracked.string("runnumber"),
        toPut=cms.VPSet(
            cms.PSet(record=cms.string("TrackerAlignmentRcd"),
                     tag=cms.string("Alignments")),
            cms.PSet(record=cms.string("TrackerAlignmentErrorExtendedRcd"),
                     tag=cms.string("AlignmentErrorsExtended")),
            cms.PSet(record=cms.string("TrackerSurfaceDeformationRcd"),
                     tag=cms.string("Deformations")),
            cms.PSet(record=cms.string("SiStripLorentzAngleRcd_peak"),
                     tag=cms.string("SiStripLorentzAngle_peak")),
            cms.PSet(record=cms.string("SiStripLorentzAngleRcd_deco"),
                     tag=cms.string("SiStripLorentzAngle_deco")),
            cms.PSet(record=cms.string("SiPixelLorentzAngleRcd"),
                     tag=cms.string("SiPixelLorentzAngle")),
            cms.PSet(record=cms.string("SiStripBackPlaneCorrectionRcd"),
                     tag=cms.string("SiStripBackPlaneCorrection"))))

    # Reconfigure parts of the algorithm configuration
    # --------------------------------------------------------------------------
    process.AlignmentProducer.algoConfig.mergeBinaryFiles = binary_files
    process.AlignmentProducer.algoConfig.mergeTreeFiles = tree_files

    # Configure the empty source to include all needed runs
    # --------------------------------------------------------------------------
    iovs = mps_tools.make_unique_runranges(process.AlignmentProducer)
    number_of_events = iovs[-1] - iovs[0] + 1

    process.maxEvents = cms.untracked.PSet(
        input=cms.untracked.int32(number_of_events))
    process.source = cms.Source(
        "EmptySource",
        firstRun=cms.untracked.uint32(run_start_geometry),
        numberEventsInRun=cms.untracked.uint32(1))

    # Define the executed path
    # --------------------------------------------------------------------------
    process.p = cms.Path(process.AlignmentProducer)
Esempio n. 2
0
def check_iov_definition(cms_process, first_run):
    """
    Check consistency of input alignment payloads and IOV definition.
    Returns a dictionary with the information needed to override possibly
    problematic input taken from the global tag.

    Arguments:
    - `cms_process`: cms.Process object containing the CMSSW configuration
    - `first_run`: first run for start geometry
    """

    print "Checking consistency of IOV definition..."
    iovs = mps_tools.make_unique_runranges(cms_process.AlignmentProducer)

    inputs = {
        "TrackerAlignmentRcd": None,
        "TrackerSurfaceDeformationRcd": None,
        "TrackerAlignmentErrorExtendedRcd": None,
    }

    for condition in cms_process.GlobalTag.toGet.value():
        if condition.record.value() in inputs:
            inputs[condition.record.value()] = {
                "tag":
                condition.tag.value(),
                "connect": ("pro" if not condition.hasParameter("connect") else
                            condition.connect.value())
            }

    inputs_from_gt = [record for record in inputs if inputs[record] is None]
    inputs.update(
        mps_tools.get_tags(cms_process.GlobalTag.globaltag.value(),
                           inputs_from_gt))

    if first_run != iovs[0]:  # simple consistency check
        if iovs[0] == 1 and len(iovs) == 1:
            print "Single IOV output detected in configuration and",
            print "'FirstRunForStartGeometry' is not 1."
            print "Creating single IOV output from input conditions in run",
            print str(first_run) + "."
            for inp in inputs:
                inputs[inp]["problematic"] = True
        else:
            print "Value of 'FirstRunForStartGeometry' has to match first",
            print "defined output IOV:",
            print first_run, "!=", iovs[0]
            sys.exit(1)

    for inp in inputs.itervalues():
        inp["iovs"] = mps_tools.get_iovs(inp["connect"], inp["tag"])

    # check consistency of input with output
    problematic_gt_inputs = {}
    input_indices = {
        key: len(value["iovs"]) - 1
        for key, value in inputs.iteritems()
    }
    for iov in reversed(iovs):
        for inp in inputs:
            if inputs[inp].pop("problematic", False):
                problematic_gt_inputs[inp] = inputs[inp]
            if inp in problematic_gt_inputs: continue
            if input_indices[inp] < 0:
                print "First output IOV boundary at run", iov,
                print "is before the first input IOV boundary at",
                print inputs[inp]["iovs"][0], "for '" + inp + "'."
                print "Please check your run range selection."
                sys.exit(1)
            input_iov = inputs[inp]["iovs"][input_indices[inp]]
            if iov < input_iov:
                if inp in inputs_from_gt:
                    problematic_gt_inputs[inp] = inputs[inp]
                    print "Found problematic input taken from global tag."
                    print "Input IOV boundary at run", input_iov,
                    print "for '" + inp + "' is within output IOV starting with",
                    print "run", str(iov) + "."
                    print "Deriving an alignment with coarse IOV granularity",
                    print "starting from finer granularity leads to wrong",
                    print "results."
                    print "A single IOV input using the IOV of",
                    print "'FirstRunForStartGeometry' (" + str(
                        first_run) + ") is",
                    print "automatically created and used."
                    continue
                print "Found input IOV boundary at run", input_iov,
                print "for '" + inp + "' which is within output IOV starting with",
                print "run", str(iov) + "."
                print "Deriving an alignment with coarse IOV granularity",
                print "starting from finer granularity leads to wrong results."
                print "Please check your run range selection."
                sys.exit(1)
            elif iov == input_iov:
                input_indices[inp] -= 1

    # check consistency of 'TrackerAlignmentRcd' with other inputs
    input_indices = {
        key: len(value["iovs"]) - 1
        for key, value in inputs.iteritems()
        if (key != "TrackerAlignmentRcd") and (
            inp not in problematic_gt_inputs)
    }
    for iov in reversed(inputs["TrackerAlignmentRcd"]["iovs"]):
        for inp in input_indices:
            input_iov = inputs[inp]["iovs"][input_indices[inp]]
            if iov < input_iov:
                print "Found input IOV boundary at run", input_iov,
                print "for '" + inp + "' which is within 'TrackerAlignmentRcd'",
                print "IOV starting with run", str(iov) + "."
                print "Deriving an alignment with inconsistent IOV boundaries",
                print "leads to wrong results."
                print "Please check your input IOVs."
                sys.exit(1)
            elif iov == input_iov:
                input_indices[inp] -= 1

    print "IOV consistency check successful."
    print "-" * 60

    return problematic_gt_inputs
Esempio n. 3
0
def check_iov_definition(cms_process, first_run):
    """
    Check consistency of input alignment payloads and IOV definition.
    Returns a dictionary with the information needed to override possibly
    problematic input taken from the global tag.

    Arguments:
    - `cms_process`: cms.Process object containing the CMSSW configuration
    - `first_run`: first run for start geometry
    """

    print "Checking consistency of IOV definition..."
    iovs = mps_tools.make_unique_runranges(cms_process.AlignmentProducer)

    inputs = {
        "TrackerAlignmentRcd": None,
        "TrackerSurfaceDeformationRcd": None,
        "TrackerAlignmentErrorExtendedRcd": None,
    }

    for condition in cms_process.GlobalTag.toGet.value():
        if condition.record.value() in inputs:
            inputs[condition.record.value()] = {
                "tag": condition.tag.value(),
                "connect": ("pro"
                            if not condition.hasParameter("connect")
                            else condition.connect.value())
            }

    inputs_from_gt = [record for record in inputs if inputs[record] is None]
    inputs.update(mps_tools.get_tags(cms_process.GlobalTag.globaltag.value(),
                                     inputs_from_gt))


    if first_run != iovs[0]:     # simple consistency check
        if iovs[0] == 1 and len(iovs) == 1:
            print "Single IOV output detected in configuration and",
            print "'FirstRunForStartGeometry' is not 1."
            print "Creating single IOV output from input conditions in run",
            print str(first_run)+"."
            for inp in inputs: inputs[inp]["problematic"] = True
        else:
            print "Value of 'FirstRunForStartGeometry' has to match first",
            print "defined output IOV:",
            print first_run, "!=", iovs[0]
            sys.exit(1)


    for inp in inputs.itervalues():
        inp["iovs"] = mps_tools.get_iovs(inp["connect"], inp["tag"])

    # check consistency of input with output
    problematic_gt_inputs = {}
    input_indices = {key: len(value["iovs"]) -1
                     for key,value in inputs.iteritems()}
    for iov in reversed(iovs):
        for inp in inputs:
            if inputs[inp].pop("problematic", False):
                problematic_gt_inputs[inp] = inputs[inp]
            if inp in problematic_gt_inputs: continue
            if input_indices[inp] < 0:
                print "First output IOV boundary at run", iov,
                print "is before the first input IOV boundary at",
                print inputs[inp]["iovs"][0], "for '"+inp+"'."
                print "Please check your run range selection."
                sys.exit(1)
            input_iov = inputs[inp]["iovs"][input_indices[inp]]
            if iov < input_iov:
                if inp in inputs_from_gt:
                    problematic_gt_inputs[inp] = inputs[inp]
                    print "Found problematic input taken from global tag."
                    print "Input IOV boundary at run",input_iov,
                    print "for '"+inp+"' is within output IOV starting with",
                    print "run", str(iov)+"."
                    print "Deriving an alignment with coarse IOV granularity",
                    print "starting from finer granularity leads to wrong",
                    print "results."
                    print "A single IOV input using the IOV of",
                    print "'FirstRunForStartGeometry' ("+str(first_run)+") is",
                    print "automatically created and used."
                    continue
                print "Found input IOV boundary at run",input_iov,
                print "for '"+inp+"' which is within output IOV starting with",
                print "run", str(iov)+"."
                print "Deriving an alignment with coarse IOV granularity",
                print "starting from finer granularity leads to wrong results."
                print "Please check your run range selection."
                sys.exit(1)
            elif iov == input_iov:
                input_indices[inp] -= 1

    # check consistency of 'TrackerAlignmentRcd' with other inputs
    input_indices = {key: len(value["iovs"]) -1
                     for key,value in inputs.iteritems()
                     if (key != "TrackerAlignmentRcd")
                     and (inp not in problematic_gt_inputs)}
    for iov in reversed(inputs["TrackerAlignmentRcd"]["iovs"]):
        for inp in input_indices:
            input_iov = inputs[inp]["iovs"][input_indices[inp]]
            if iov < input_iov:
                print "Found input IOV boundary at run",input_iov,
                print "for '"+inp+"' which is within 'TrackerAlignmentRcd'",
                print "IOV starting with run", str(iov)+"."
                print "Deriving an alignment with inconsistent IOV boundaries",
                print "leads to wrong results."
                print "Please check your input IOVs."
                sys.exit(1)
            elif iov == input_iov:
                input_indices[inp] -= 1

    print "IOV consistency check successful."
    print "-"*60

    return problematic_gt_inputs
Esempio n. 4
0
def setup(process, binary_files, tree_files, run_start_geometry):
    """Pede-specific setup.

    Arguments:
    - `process`: cms.Process object
    - `binary_files`: list of binary files to be read by pede
    - `tree_files`: list of ROOT files created in the mille step
    - `run_start_geometry`: run ID to pick the start geometry
    """

    # write alignments, APEs, and surface deformations to DB by default
    # --------------------------------------------------------------------------
    process.AlignmentProducer.saveToDB = True
    process.AlignmentProducer.saveApeToDB = True
    process.AlignmentProducer.saveDeformationsToDB = True

    # setup database output module
    # --------------------------------------------------------------------------
    from CondCore.CondDB.CondDB_cfi import CondDB
    process.PoolDBOutputService = cms.Service("PoolDBOutputService",
        CondDB.clone(connect = "sqlite_file:alignments_MP.db"),
        timetype = cms.untracked.string("runnumber"),
        toPut = cms.VPSet(
            cms.PSet(
                record = cms.string("TrackerAlignmentRcd"),
                tag = cms.string("Alignments")),
            cms.PSet(
                record = cms.string("TrackerAlignmentErrorExtendedRcd"),
                tag = cms.string("AlignmentErrorsExtended")),
            cms.PSet(
                record = cms.string("TrackerSurfaceDeformationRcd"),
                tag = cms.string("Deformations")),
            cms.PSet(
                record = cms.string("SiStripLorentzAngleRcd_peak"),
                tag = cms.string("SiStripLorentzAngle_peak")),
            cms.PSet(
                record = cms.string("SiStripLorentzAngleRcd_deco"),
                tag = cms.string("SiStripLorentzAngle_deco")),
            cms.PSet(
                record = cms.string("SiPixelLorentzAngleRcd"),
                tag = cms.string("SiPixelLorentzAngle")),
            cms.PSet(
                record = cms.string("SiStripBackPlaneCorrectionRcd"),
                tag = cms.string("SiStripBackPlaneCorrection"))
        )
    )


    # Reconfigure parts of the algorithm configuration
    # --------------------------------------------------------------------------
    process.AlignmentProducer.algoConfig.mergeBinaryFiles = binary_files
    process.AlignmentProducer.algoConfig.mergeTreeFiles   = tree_files


    # align calibrations to general settings
    # --------------------------------------------------------------------------
    for calib in process.AlignmentProducer.calibrations:
        calib.saveToDB       = process.AlignmentProducer.saveToDB
        calib.treeFile       = process.AlignmentProducer.algoConfig.treeFile
        calib.mergeTreeFiles = process.AlignmentProducer.algoConfig.mergeTreeFiles


    # Configure the empty source to include all needed runs
    # --------------------------------------------------------------------------
    iovs = mps_tools.make_unique_runranges(process.AlignmentProducer)
    number_of_events = iovs[-1] - iovs[0] + 1

    process.maxEvents = cms.untracked.PSet(
        input = cms.untracked.int32(number_of_events))
    process.source = cms.Source(
        "EmptySource",
        firstRun = cms.untracked.uint32(run_start_geometry),
        numberEventsInRun = cms.untracked.uint32(1))

    # Define the executed path
    # --------------------------------------------------------------------------
    process.p = cms.Path(process.AlignmentProducer)