Exemple #1
0
def main(argv = None):
    """Main routine of the script.

    Arguments:
    - `argv`: arguments passed to the main routine
    """

    if argv == None:
        argv = sys.argv[1:]

    parser = argparse.ArgumentParser(
        description="Prepare input db file for MillePede workflow.")
    parser.add_argument("-g", "--global-tag", dest="global_tag", required=True,
                        metavar="TAG",
                        help="global tag to extract the alignment payloads")
    parser.add_argument("-r", "--run-number", dest="run_number", required=True,
                        metavar="INTEGER", type=int,
                        help="run number to select IOV")
    parser.add_argument("-o", "--output-db", dest="output_db",
                        default="alignment_input.db", metavar="PATH",
                        help="name of the output file (default: '%(default)s')")
    args = parser.parse_args(argv)

    inputs = mps_tools.get_tags(args.global_tag,
                                ["TrackerAlignmentRcd",
                                 "TrackerSurfaceDeformationRcd",
                                 "TrackerAlignmentErrorExtendedRcd"])
    for inp in inputs.itervalues():
        inp["iovs"] = mps_tools.get_iovs(inp["connect"], inp["tag"])
    mps_tools.create_single_iov_db(inputs, args.run_number, args.output_db)
def main(argv = None):
    """Main routine of the script.

    Arguments:
    - `argv`: arguments passed to the main routine
    """

    if argv == None:
        argv = sys.argv[1:]

    parser = argparse.ArgumentParser(
        description="Prepare input db file for MillePede workflow.")
    parser.add_argument("-g", "--global-tag", dest="global_tag", required=True,
                        metavar="TAG",
                        help="global tag to extract the alignment payloads")
    parser.add_argument("-r", "--run-number", dest="run_number", required=True,
                        metavar="INTEGER", type=int,
                        help="run number to select IOV")
    parser.add_argument("-o", "--output-db", dest="output_db",
                        default="alignment_input.db", metavar="PATH",
                        help="name of the output file (default: '%(default)s')")
    args = parser.parse_args(argv)

    mps_tools.create_single_iov_db(args.global_tag,
                                   args.run_number,
                                   args.output_db)
Exemple #3
0
def create_input_db(cms_process, run_number):
    """
    Create sqlite file with single-IOV tags and use it to override the GT. If
    the GT is already customized by the user, the customization has higher
    priority. Returns a snippet to be appended to the configuration file

    Arguments:
    - `cms_process`: cms.Process object
    - `run_number`: run from which to extract the alignment payloads
    """

    run_number = int(run_number)
    if not run_number > 0:
        print "'FirstRunForStartGeometry' must be positive, but is", run_number
        sys.exit(1)

    input_db_name = os.path.abspath("alignment_input.db")
    tags = mps_tools.create_single_iov_db(
        check_iov_definition(cms_process, run_number), run_number,
        input_db_name)

    result = ""
    for record, tag in tags.iteritems():
        if result == "":
            result += ("\nimport "
                       "Alignment.MillePedeAlignmentAlgorithm.alignmentsetup."
                       "SetCondition as tagwriter\n")
        result += ("\ntagwriter.setCondition(process,\n"
                   "       connect = \"" + tag["connect"] + "\",\n"
                   "       record = \"" + record + "\",\n"
                   "       tag = \"" + tag["tag"] + "\")\n")

    return result
Exemple #4
0
def create_input_db(cms_process, run_number):
    """
    Create sqlite file with single-IOV tags and use it to override the GT. If
    the GT is already customized by the user, the customization has higher
    priority. Returns a snippet to be appended to the configuration file

    Arguments:
    - `cms_process`: cms.Process object
    - `run_number`: run from which to extract the alignment payloads
    """

    run_number = int(run_number)
    if not run_number > 0:
        print "'FirstRunForStartGeometry' must be positive, but is", run_number
        sys.exit(1)

    input_db_name = os.path.abspath("alignment_input.db")
    tags = mps_tools.create_single_iov_db(
        check_iov_definition(cms_process, run_number),
        run_number, input_db_name)

    result = ""
    for record,tag in tags.iteritems():
        if result == "":
            result += ("\nimport "
                       "Alignment.MillePedeAlignmentAlgorithm.alignmentsetup."
                       "SetCondition as tagwriter\n")
        result += ("\ntagwriter.setCondition(process,\n"
                   "       connect = \""+tag["connect"]+"\",\n"
                   "       record = \""+record+"\",\n"
                   "       tag = \""+tag["tag"]+"\")\n")

    return result
Exemple #5
0
    def _create_input_db(self):
        """
        Create sqlite file with single-IOV tags and use it to override the
        GT. If the GT is already customized by the user, the customization has
        higher priority. Creates a snippet to be appended to the configuration
        file.
        """

        run_number = int(self._first_run)
        if not run_number > 0:
            print("'FirstRunForStartGeometry' must be positive, but is", run_number)
            sys.exit(1)

        input_db_name = os.path.abspath("alignment_input.db")
        tags = mps_tools.create_single_iov_db(self._check_iov_definition(),
                                              run_number, input_db_name)

        self._override_gt = ""
        for record,tag in six.iteritems(tags):
            if self._override_gt == "":
                self._override_gt \
                    += ("\nimport "
                        "Alignment.MillePedeAlignmentAlgorithm.alignmentsetup."
                        "SetCondition as tagwriter\n")
            self._override_gt += ("\ntagwriter.setCondition(process,\n"
                                  "       connect = \""+tag["connect"]+"\",\n"
                                  "       record = \""+record+"\",\n"
                                  "       tag = \""+tag["tag"]+"\")\n")
Exemple #6
0
    def _create_input_db(self):
        """
        Create sqlite file with single-IOV tags and use it to override the
        GT. If the GT is already customized by the user, the customization has
        higher priority. Creates a snippet to be appended to the configuration
        file.
        """

        run_number = int(self._first_run)
        if not run_number > 0:
            print "'FirstRunForStartGeometry' must be positive, but is", run_number
            sys.exit(1)

        input_db_name = os.path.abspath("alignment_input.db")
        tags = mps_tools.create_single_iov_db(self._check_iov_definition(),
                                              run_number, input_db_name)

        self._override_gt = ""
        for record,tag in tags.iteritems():
            if self._override_gt == "":
                self._override_gt \
                    += ("\nimport "
                        "Alignment.MillePedeAlignmentAlgorithm.alignmentsetup."
                        "SetCondition as tagwriter\n")
            self._override_gt += ("\ntagwriter.setCondition(process,\n"
                                  "       connect = \""+tag["connect"]+"\",\n"
                                  "       record = \""+record+"\",\n"
                                  "       tag = \""+tag["tag"]+"\")\n")
Exemple #7
0
def create_input_db(cfg, run_number):
    """
    Create sqlite file with single-IOV tags and use it to override the GT. If
    the GT is already customized by the user, the customization has higher
    priority. Returns a snippet to be appended to the configuration file

    Arguments:
    - `cfg`: path to python configuration
    - `run_number`: run from which to extract the alignment payloads
    """

    sys.path.append(os.path.dirname(cfg))
    cache_stdout = sys.stdout
    sys.stdout = open(os.devnull, "w")  # suppress unwanted output
    __configuration = \
        importlib.import_module(os.path.splitext(os.path.basename(cfg))[0])
    sys.stdout = cache_stdout

    run_number = int(run_number)
    if not run_number > 0:
        print "'FirstRunForStartGeometry' must be positive, but is", run_number
        sys.exit(1)

    global_tag = __configuration.process.GlobalTag.globaltag.value()
    input_db_name = os.path.abspath("alignment_input.db")
    tags = mps_tools.create_single_iov_db(global_tag, run_number,
                                          input_db_name)

    for condition in __configuration.process.GlobalTag.toGet.value():
        if condition.record.value() in tags: del tags[condition.record.value()]

    result = ""
    for record, tag in tags.iteritems():
        if result == "":
            result += ("\nimport "
                       "Alignment.MillePedeAlignmentAlgorithm.alignmentsetup."
                       "SetCondition as tagwriter\n")
        result += ("\ntagwriter.setCondition(process,\n"
                   "       connect = \"" + tag["connect"] + "\",\n"
                   "       record = \"" + record + "\",\n"
                   "       tag = \"" + tag["tag"] + "\")\n")

    os.remove(cfg + "c")
    return result
Exemple #8
0
def create_input_db(cfg, run_number):
    """
    Create sqlite file with single-IOV tags and use it to override the GT. If
    the GT is already customized by the user, the customization has higher
    priority. Returns a snippet to be appended to the configuration file

    Arguments:
    - `cfg`: path to python configuration
    - `run_number`: run from which to extract the alignment payloads
    """

    sys.path.append(os.path.dirname(cfg))
    cache_stdout = sys.stdout
    sys.stdout = open(os.devnull, "w") # suppress unwanted output
    __configuration = \
        importlib.import_module(os.path.splitext(os.path.basename(cfg))[0])
    sys.stdout = cache_stdout

    run_number = int(run_number)
    if not run_number > 0:
        print "'FirstRunForStartGeometry' must be positive, but is", run_number
        sys.exit(1)

    global_tag = __configuration.process.GlobalTag.globaltag.value()
    input_db_name = os.path.abspath("alignment_input.db")
    tags = mps_tools.create_single_iov_db(global_tag, run_number, input_db_name)

    for condition in __configuration.process.GlobalTag.toGet.value():
        if condition.record.value() in tags: del tags[condition.record.value()]

    result = ""
    for record,tag in tags.iteritems():
        if result == "":
            result += ("\nimport "
                       "Alignment.MillePedeAlignmentAlgorithm.alignmentsetup."
                       "SetCondition as tagwriter\n")
        result += ("\ntagwriter.setCondition(process,\n"
                   "       connect = \""+tag["connect"]+"\",\n"
                   "       record = \""+record+"\",\n"
                   "       tag = \""+tag["tag"]+"\")\n")

    os.remove(cfg+"c")
    return result