예제 #1
0
    def _construct_paths(self):
        """Determine directory paths and create the ones that are needed."""

        mpsTemplates = os.path.join("src", "Alignment",
                                    "MillePedeAlignmentAlgorithm", "templates")
        if checked_out_MPS()[0]:
            mpsTemplates = os.path.join(os.environ["CMSSW_BASE"], mpsTemplates)
        else:
            mpsTemplates = os.path.join(os.environ["CMSSW_RELEASE_BASE"],
                                        mpsTemplates)
        self._mille_script = os.path.join(mpsTemplates,
                                          "mps_runMille_template.sh")
        self._pede_script = os.path.join(mpsTemplates,
                                         "mps_runPede_rfcp_template.sh")

        # get working directory name
        currentDir = os.getcwd()
        match = re.search(re.compile('mpproduction\/mp(.+?)$', re.M | re.I),
                          currentDir)
        if match:
            self._mps_dir_name = 'mp' + match.group(1)
        else:
            print(
                "Current location does not seem to be a MillePede campaign directory:",
                end=' ')
            print(currentDir)
            sys.exit(1)
예제 #2
0
    def _construct_paths(self):
        """Determine directory paths and create the ones that are needed."""

        mpsTemplates = os.path.join("src", "Alignment",
                                    "MillePedeAlignmentAlgorithm", "templates")
        if checked_out_MPS()[0]:
            mpsTemplates = os.path.join(os.environ["CMSSW_BASE"], mpsTemplates)
        else:
            mpsTemplates = os.path.join(os.environ["CMSSW_RELEASE_BASE"], mpsTemplates)
        self._mille_script = os.path.join(mpsTemplates, "mps_runMille_template.sh")
        self._pede_script  = os.path.join(mpsTemplates, "mps_runPede_rfcp_template.sh")

        # get working directory name
        currentDir = os.getcwd()
        match = re.search(re.compile('mpproduction\/mp(.+?)$', re.M|re.I),currentDir)
        if match:
            self._mps_dir_name = 'mp'+match.group(1)
        else:
            print "Current location does not seem to be a MillePede campaign directory:",
            print currentDir
            sys.exit(1)
예제 #3
0
# parse argument
args = parser.parse_args()
aligmentConfig = args.alignmentConfig

# parse config file
config = ConfigParser.ConfigParser()
config.optionxform = str  # default would give lowercase options -> not wanted
config.read(aligmentConfig)

#------------------------------------------------------------------------------
# construct directories

# set variables that are not too specific (millescript, pedescript, etc.)
mpsTemplates = os.path.join("src", "Alignment", "MillePedeAlignmentAlgorithm",
                            "templates")
if checked_out_MPS()[0]:
    mpsTemplates = os.path.join(os.environ["CMSSW_BASE"], mpsTemplates)
else:
    mpsTemplates = os.path.join(os.environ["CMSSW_RELEASE_BASE"], mpsTemplates)
milleScript = os.path.join(mpsTemplates, "mps_runMille_template.sh")
pedeScript = os.path.join(mpsTemplates, "mps_runPede_rfcp_template.sh")

# get working directory name
currentDir = os.getcwd()
mpsdirname = ''
match = re.search(re.compile('mpproduction\/mp(.+?)$', re.M | re.I),
                  currentDir)
if match:
    mpsdirname = 'mp' + match.group(1)
else:
    print "Current location does not seem to be a MillePede campaign directory:",
예제 #4
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="Setup a new alignment campaign in the MPproduction area.")
    parser.add_argument("-d",
                        "--description",
                        dest="description",
                        required=True,
                        help="comment to describe the purpose of the campaign")
    parser.add_argument("-t",
                        "--data-type",
                        dest="type",
                        required=True,
                        metavar="TYPE",
                        choices=["MC", "data"],
                        help="type of the input data (choices: %(choices)s)")
    parser.add_argument("-c",
                        "--copy",
                        dest="copy",
                        metavar="CAMPAIGN",
                        help="input campaign (optional)")
    args = parser.parse_args(argv)

    if os.path.basename(os.path.normpath(os.getcwd())) != "MPproduction":
        print ">>> Cannot create a campaign outside of the 'MPproduction' area."
        print ">>> Please change to the 'MPproduction' directory first."
        sys.exit(1)

    if len(args.description.strip()) == 0:
        print ">>> Please provide a non-empty description of the campaign"
        sys.exit(1)

    MPS_dir = os.path.join("src", "Alignment", "MillePedeAlignmentAlgorithm")
    args.checked_out = checked_out_MPS()
    if args.checked_out[0]:
        MPS_dir = os.path.join(os.environ["CMSSW_BASE"], MPS_dir)
    else:
        MPS_dir = os.path.join(os.environ["CMSSW_RELEASE_BASE"], MPS_dir)
    args.MPS_dir = MPS_dir

    mp_regex = re.compile(r"mp([0-9]+).*")
    all_campaign_numbers = sorted(
        map(lambda x: get_first_match(mp_regex, x), os.listdir(".")))
    next_number = (0 if len(all_campaign_numbers) == 0 else
                   sorted(all_campaign_numbers)[-1] + 1)

    while True:
        try:
            number_of_digits = len(str(next_number))
            number_of_digits = 4 if number_of_digits <= 4 else number_of_digits
            next_campaign = "mp{{0:0{0}d}}".format(number_of_digits)
            next_campaign = next_campaign.format(next_number)
            os.makedirs(next_campaign)
            print ">>> Created new campaign:", next_campaign

            campaign_list = "MP_ali_list.txt"
            with open(campaign_list, "a") as f:
                campaign_info = add_campaign(f, next_campaign, args)
            backup_dir = ".MP_ali_list"
            try:
                os.makedirs(backup_dir)
            except OSError as e:
                if e.args == (17, 'File exists'):
                    pass
                else:
                    raise
            with open(os.path.join(backup_dir, campaign_list), "a") as f:
                fcntl.flock(f, fcntl.LOCK_EX)
                f.write(campaign_info)
                fcntl.flock(f, fcntl.LOCK_UN)
            print "    - updated campaign list '" + campaign_list + "'"

            if args.copy is None:
                copy_default_templates(args, next_campaign)
            else:
                copied_files = []
                for ext in ("py", "ini", "txt"):
                    for config_file in glob.glob(args.copy + "/*." + ext):
                        copied_files.append(os.path.basename(config_file))
                        shutil.copy(config_file, next_campaign)
                if len(copied_files) == 0:
                    print "    - no configuration files for '" + args.copy + "'"
                    copy_default_templates(args, next_campaign)
                else:
                    print "    - copied configuration files from",
                    print "'" + args.copy + "':", ", ".join(copied_files)

        except OSError as e:
            if e.args == (17, 'File exists'):
                next_number += 1  # someone created a campaign ~at the same time
                continue
            else:
                raise
        break
예제 #5
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="Setup a new alignment campaign in the MPproduction area.")
    parser.add_argument("-d", "--description", dest="description", required=True,
                        help="comment to describe the purpose of the campaign")
    parser.add_argument("-t", "--data-type", dest="type", required=True,
                        metavar="TYPE", choices=["MC", "data"],
                        help="type of the input data (choices: %(choices)s)")
    parser.add_argument("-c", "--copy", dest="copy", metavar="CAMPAIGN",
                        help="input campaign (optional)")
    args = parser.parse_args(argv)


    if os.path.basename(os.path.normpath(os.getcwd())) != "MPproduction":
        print ">>> Cannot create a campaign outside of the 'MPproduction' area."
        print ">>> Please change to the 'MPproduction' directory first."
        sys.exit(1)

    if len(args.description.strip()) == 0:
        print ">>> Please provide a non-empty description of the campaign"
        sys.exit(1)

    MPS_dir = os.path.join("src", "Alignment", "MillePedeAlignmentAlgorithm")
    args.checked_out = checked_out_MPS()
    if args.checked_out[0]:
        MPS_dir = os.path.join(os.environ["CMSSW_BASE"], MPS_dir)
    else:
        MPS_dir = os.path.join(os.environ["CMSSW_RELEASE_BASE"], MPS_dir)
    args.MPS_dir = MPS_dir

    mp_regex = re.compile(r"mp([0-9]+).*")
    all_campaign_numbers = sorted(map(lambda x: get_first_match(mp_regex, x),
                                      os.listdir(".")))
    next_number = (0
                   if len(all_campaign_numbers) == 0
                   else sorted(all_campaign_numbers)[-1] + 1)

    while True:
        try:
            number_of_digits = len(str(next_number))
            number_of_digits = 4 if number_of_digits <= 4 else number_of_digits
            next_campaign = "mp{{0:0{0}d}}".format(number_of_digits)
            next_campaign = next_campaign.format(next_number)
            os.makedirs(next_campaign)
            print ">>> Created new campaign:", next_campaign

            campaign_list = "MP_ali_list.txt"
            with open(campaign_list, "a") as f:
                campaign_info = add_campaign(f, next_campaign, args)
            backup_dir = ".MP_ali_list"
            try:
                os.makedirs(backup_dir)
            except OSError as e:
                if e.args == (17, 'File exists'):
                    pass
                else:
                    raise
            with open(os.path.join(backup_dir, campaign_list), "a") as f:
                fcntl.flock(f, fcntl.LOCK_EX)
                f.write(campaign_info)
                fcntl.flock(f, fcntl.LOCK_UN)
            print "    - updated campaign list '"+campaign_list+"'"

            if args.copy is None:
                copy_default_templates(args, next_campaign)
            else:
                copied_files = []
                for ext in ("py", "ini", "txt"):
                    for config_file in glob.glob(args.copy+"/*."+ext):
                        copied_files.append(os.path.basename(config_file))
                        shutil.copy(config_file, next_campaign)
                if len(copied_files) == 0:
                    print "    - no configuration files for '"+args.copy+"'"
                    copy_default_templates(args, next_campaign)
                else:
                    print "    - copied configuration files from",
                    print "'"+args.copy+"':", ", ".join(copied_files)

        except OSError as e:
            if e.args == (17, 'File exists'):
                next_number += 1 # someone created a campaign ~at the same time
                continue
            else:
                raise
        break
예제 #6
0
args = parser.parse_args()
aligmentConfig = args.alignmentConfig

# parse config file
config = ConfigParser.ConfigParser()
config.optionxform = str    # default would give lowercase options -> not wanted
config.read(aligmentConfig)



#------------------------------------------------------------------------------
# construct directories

# set variables that are not too specific (millescript, pedescript, etc.)
mpsTemplates = os.path.join("src", "Alignment", "MillePedeAlignmentAlgorithm", "templates")
if checked_out_MPS()[0]:
    mpsTemplates = os.path.join(os.environ["CMSSW_BASE"], mpsTemplates)
else:
    mpsTemplates = os.path.join(os.environ["CMSSW_RELEASE_BASE"], mpsTemplates)
milleScript = os.path.join(mpsTemplates, "mps_runMille_template.sh")
pedeScript  = os.path.join(mpsTemplates, "mps_runPede_rfcp_template.sh")

# get working directory name
currentDir = os.getcwd()
mpsdirname = ''
match = re.search(re.compile('mpproduction\/mp(.+?)$', re.M|re.I),currentDir)
if match:
    mpsdirname = 'mp'+match.group(1)
else:
    print "Current location does not seem to be a MillePede campaign directory:",
    print currentDir
예제 #7
0
    def __init__(self):
        # get path to modules, defaut ini and templates
        self.mpspath = os.path.join(
            os.environ["CMSSW_BASE"]
            if checked_out_MPS()[0] else os.environ["CMSSW_RELEASE_BASE"],
            "src", "Alignment", "MillePedeAlignmentAlgorithm")

        # General
        # jobmX dir
        self.jobNumber = -1
        # MillePedeUser_X time
        self.jobTime = -1
        # ./jobData/jobmX path
        self.jobDataPath = ""
        # base outputpath
        self.outputPath = ""
        # latex file name
        self.latexfile = ""
        # identification in every plot (e.g. mp1885)
        self.message = ""
        # limits for warning dict with keys xyz, rot, dist
        # arguments must be given in this order
        self.limit = {}
        # statboxsize
        self.statboxsize = -1
        # global tag
        self.globalTag = None
        # first run to pick for the geometry in self.globalTag
        self.firstRun = None

        # what should be created
        self.showmonitor = False
        self.showadditional = False
        self.showdump = False
        self.showtime = False
        self.showhighlevel = False
        self.showmodule = False
        self.showsubmodule = False
        self.showtex = False
        self.showbeamer = False
        self.showhtml = False

        # MODULEPLOTS
        # number of bins after shrinking
        self.numberofbins = -1
        # definition of sharp peak; max_outlier / StdDev > X
        self.defpeak = -1
        # new histogram width in units of StdDev
        self.widthstddev = -1
        # every parameter (e.g. xyz) with same range
        self.samerange = False
        # rangemode "stddev" = multiple of StdDev, "all" = show all, "given" =
        # use given ranges
        self.rangemode = -1
        # ranges
        self.rangexyzM = []
        self.rangerotM = []
        self.rangedistM = []

        # HIGHLEVELPLOTS
        # given ranges
        self.rangexyzHL = []
        self.rangerotHL = []
        # every parameter (e.g. xyz) with same range
        self.samerangeHL = False
        # rangemode "all" = show all, "given" = use given ranges
        self.rangemodeHL = -1

        # Time dependent
        self.firsttree = -1

        # list with the plots for the output
        self.outputList = []
예제 #8
0
파일: iniparser.py 프로젝트: ANSH0712/cmssw
    def __init__(self):
        # get path to modules, defaut ini and templates
        self.mpspath = os.path.join(os.environ["CMSSW_BASE"]
                                    if checked_out_MPS()[0]
                                    else os.environ["CMSSW_RELEASE_BASE"], "src",
                                    "Alignment", "MillePedeAlignmentAlgorithm")

        # General
        # jobmX dir
        self.jobNumber = -1
        # MillePedeUser_X time
        self.jobTime = -1
        # ./jobData/jobmX path
        self.jobDataPath = ""
        # base outputpath
        self.outputPath = ""
        # latex file name
        self.latexfile = ""
        # identification in every plot (e.g. mp1885)
        self.message = ""
        # limits for warning dict with keys xyz, rot, dist
        # arguments must be given in this order
        self.limit = {}
        # statboxsize
        self.statboxsize = -1
        # global tag
        self.globalTag = None
        # first run to pick for the geometry in self.globalTag
        self.firstRun = None

        # what should be created
        self.showmonitor    = False
        self.showadditional = False
        self.showdump       = False
        self.showtime       = False
        self.showhighlevel  = False
        self.showmodule     = False
        self.showsubmodule  = False
        self.showtex        = False
        self.showbeamer     = False
        self.showhtml       = False

        # MODULEPLOTS
        # number of bins after shrinking
        self.numberofbins = -1
        # definition of sharp peak; max_outlier / StdDev > X
        self.defpeak = -1
        # new histogram width in units of StdDev
        self.widthstddev = -1
        # every parameter (e.g. xyz) with same range
        self.samerange = False
        # rangemode "stddev" = multiple of StdDev, "all" = show all, "given" =
        # use given ranges
        self.rangemode = -1
        # ranges
        self.rangexyzM = []
        self.rangerotM = []
        self.rangedistM = []

        # HIGHLEVELPLOTS
        # given ranges
        self.rangexyzHL = []
        self.rangerotHL = []
        # every parameter (e.g. xyz) with same range
        self.samerangeHL = False
        # rangemode "all" = show all, "given" = use given ranges
        self.rangemodeHL = -1

        # Time dependent
        self.firsttree = -1

        # list with the plots for the output
        self.outputList = []