Exemple #1
0
    def cardsurl(self):
        commit = self.genproductionscommitfordecay
        JHUGencard = os.path.join(
            "https://raw.githubusercontent.com/cms-sw/genproductions/", commit,
            self.decaycard.split("genproductions/")[-1])
        result = JHUGencard
        moreresult = super(JHUGenDecayMCSample, self).cardsurl
        if moreresult: result += "\n# " + moreresult

        with contextlib.closing(urlopen(JHUGencard)) as f:
            JHUGengitcard = f.read()

        try:
            with open(self.JHUGencardlocationintarball) as f:
                JHUGencard = f.read()
        except IOError:
            raise ValueError(
                "no {0.JHUGencardlocationintarball} in the tarball\n{0}".
                format(self))

        if JHUGencard != JHUGengitcard:
            raise ValueError("JHUGencard != JHUGengitcard\n{}\n{}\n{}".format(
                self, JHUGencard, JHUGengitcard))

        return result
 def olddatasetname(self):
     p = self.productionmode
     if p == "VBF": p = "VBFH"
     with contextlib.closing(
             urlopen(
                 "https://raw.githubusercontent.com/CJLST/ZZAnalysis/miniAOD_80X/AnalysisStep/test/prod/samples_2016_MC.csv"
             )) as f:
         reader = csv.DictReader(f)
         for row in reader:
             if row["identifier"] == "{}{}".format(p, self.mass):
                 dataset = row["dataset"]
                 result = re.sub(r"^/([^/]*)/[^/]*/[^/]*$", r"\1", dataset)
                 assert result != dataset and "/" not in result, result
                 if self.decaymode == "4l":
                     return result
     raise ValueError("Nothing for {}".format(self))
 def updated2016datasetnamespreadsheet(cls):
     with contextlib.closing(
             urlopen(
                 "https://raw.githubusercontent.com/CJLST/ZZAnalysis/4432347314253d2955a9aed708765e17ab719502/AnalysisStep/test/prod/samples_2016_MC.csv"
             )) as f:
         return f.read()
 def olddatasetnamespreadsheet(cls):
     with contextlib.closing(
             urlopen(
                 "https://raw.githubusercontent.com/CJLST/ZZAnalysis/f7d5b5fecf322a8cffa435cfbe3f05fb1ae6aba2/AnalysisStep/test/prod/samples_2016_MC.csv"
             )) as f:
         return list(f)
    def cardsurl(self):
        commit = self.genproductionscommit
        productioncardurl = os.path.join(
            "https://raw.githubusercontent.com/cms-sw/genproductions/", commit,
            self.productioncard.split("genproductions/")[-1])
        mdatascript = os.path.join(
            "https://raw.githubusercontent.com/cms-sw/genproductions/", commit,
            "bin/MCFM/ACmdataConfig.py")
        with cdtemp():
            with contextlib.closing(urlopen(productioncardurl)) as f:
                productiongitcard = f.read()


#    for root, dirs, files in os.walk("."):
#      for ifile in files:
#        try:
#          os.stat(ifile)
#        except Exception as e:
#          if e.args == 'No such file or directory':   continue
#          print ifile
#          print e.message, e.args
#          raise ValueError("There is a broken symlink in the tarball\n{}".format(self))
        try:
            with open("readInput.DAT") as f:
                productioncard = f.read()
        except IOError:
            raise ValueError(
                "no readInput.DAT in the tarball\n{}".format(self))
        try:
            with open("src/User/mdata.f") as f:
                mdatacard = f.read()
        except IOError:
            raise ValueError(
                "no src/User/mdata.f in the tarball\n{}".format(self))

        if differentproductioncards(
                productioncard,
                productiongitcard) and not 'BKG' in self.identifiers:
            with cd(here):
                with open("productioncard", "w") as f:
                    f.write(productioncard)
                with open("productiongitcard", "w") as f:
                    f.write(productiongitcard)
            raise ValueError(
                "productioncard != productiongitcard\n{}\nSee ./productioncard and ./productiongitcard"
                .format(self))

        with contextlib.closing(
                urlopen(
                    os.path.join(
                        "https://raw.githubusercontent.com/cms-sw/genproductions/"
                        + commit + "/bin/MCFM/run_mcfm_AC.py"))) as f:
            infunction = False
            for line in f:
                if re.match(r"^\s*def .*", line): infunction = False
                if re.match(r"^\s*def downloadmcfm.*", line): infunction = True
                if not infunction: continue
                match = re.search(r"git checkout ([\w.]*)", line)
                if match: mcfmcommit = match.group(1)
        with cdtemp():
            wget("http://spin.pha.jhu.edu/Generator/JHUGenerator." +
                 self.JHUGenversion + ".tar.gz")
            subprocess.check_output([
                "tar", "xvzf", "JHUGenerator." + self.JHUGenversion + ".tar.gz"
            ])
            mkdir_p("src/User")
            shutil.move("MCFM-JHUGen/src/User/mdata.f", "src/User/")
            wget(mdatascript)
            subprocess.check_call([
                "python",
                os.path.basename(mdatascript), "--coupling", self.coupling,
                "--mcfmdir", ".", "--bsisigbkg", self.signalbkgbsi
            ])
            with open("src/User/mdata.f") as f:
                mdatagitcard = f.read()

        if mdatacard != mdatagitcard and not 'BKG' in self.identifiers:
            with cd(here):
                with open("mdatacard", "w") as f:
                    f.write(mdatacard)
                with open("mdatagitcard", "w") as f:
                    f.write(mdatagitcard)
            raise ValueError(
                "mdatacard != mdatagitcard\n{}\nSee ./mdatacard and ./mdatagitcard"
                .format(self))

        result = (productioncardurl + "\n" + "# " + mdatascript + "\n" +
                  "#    --coupling " + self.coupling + " --bsisigbkg " +
                  self.signalbkgbsi)

        moreresult = super(MCFMMCSample, self).cardsurl
        if moreresult: result += "\n# " + moreresult

        return result
 def csvfile2016(cls):
     with contextlib.closing(
             urlopen(
                 "https://raw.githubusercontent.com/CJLST/ZZAnalysis/f7d5b5fecf322a8cffa435cfbe3f05fb1ae6aba2/AnalysisStep/test/prod/samples_2016_MC_anomalous.csv"
             )) as f:
         return list(f)