Пример #1
0
 def __init__ ( self, *args, **kwargs ):
     super(ExtrapolationTest, self).__init__(*args, **kwargs)
     data = [ [ [[ 150.*GeV, 50.*GeV], [ 150.*GeV, 50.*GeV] ], 3.*fb ],
          [ [[ 200.*GeV,100.*GeV], [ 200.*GeV,100.*GeV] ],  5.*fb ],
          [ [[ 300.*GeV,200.*GeV], [ 300.*GeV,200.*GeV] ], 15.*fb ],
          [ [[ 400.*GeV,300.*GeV], [ 400.*GeV,300.*GeV] ], 17.*fb ] ]
     self.txnameData = TxNameData( data, "upperLimits",
             sys._getframe().f_code.co_name, .05 )
Пример #2
0
class ExtrapolationTest(unittest.TestCase):
    def __init__ ( self, *args, **kwargs ):
        super(ExtrapolationTest, self).__init__(*args, **kwargs)
        data = [ [ [[ 150.*GeV, 50.*GeV], [ 150.*GeV, 50.*GeV] ], 3.*fb ],
             [ [[ 200.*GeV,100.*GeV], [ 200.*GeV,100.*GeV] ],  5.*fb ],
             [ [[ 300.*GeV,200.*GeV], [ 300.*GeV,200.*GeV] ], 15.*fb ],
             [ [[ 400.*GeV,300.*GeV], [ 400.*GeV,300.*GeV] ], 17.*fb ] ]
        self.txnameData = TxNameData( data, "upperLimits",
                sys._getframe().f_code.co_name, .05 )

    def tryWith ( self, masses ):
        return self.txnameData.getValueFor( masses )

    def testWithDirectData(self):
        result=self.tryWith ([[ 275.*GeV,175.*GeV], [ 275.*GeV,175.*GeV] ])

        self.assertAlmostEqual( result.asNumber(pb),0.0125 )
        eps = 1 * keV
        result=self.tryWith([[ 275.*GeV,175.*GeV + eps],
                             [ 275.*GeV + eps ,175.*GeV] ])
        
        self.assertAlmostEqual( result.asNumber(pb),0.0125 )

        result=self.tryWith([[ 275.*GeV,185.*GeV], [ 275.*GeV,165.*GeV] ])
        self.assertTrue ( result == None )

    def show ( self ):
        #txnameObj.nonZeroEps = 1e+4
        #txnameObj.simplexTolerance = 1e-2
        for eps in numpy.arange ( 2, 9, .3 ):
            e = (10**eps) * eV
            masses = [[ 275.*GeV + e, 175.*GeV ], [ 275.*GeV,175.*GeV - e ]]
            print ( "%s: %s" % ( pprint ( e ), self.tryWith ( masses ) ))
Пример #3
0
 def testEfficiencyMaps(self):
     data = [ [ [[ 150.*GeV, 50.*GeV], [ 150.*GeV, 50.*GeV] ],  .03 ], 
          [ [[ 200.*GeV,100.*GeV], [ 200.*GeV,100.*GeV] ], .05 ], 
          [ [[ 300.*GeV,100.*GeV], [ 300.*GeV,100.*GeV] ], .10 ], 
          [ [[ 300.*GeV,150.*GeV], [ 300.*GeV,150.*GeV] ], .13 ], 
          [ [[ 300.*GeV,200.*GeV], [ 300.*GeV,200.*GeV] ], .15 ], 
          [ [[ 300.*GeV,250.*GeV], [ 300.*GeV,250.*GeV] ], .20 ], 
          [ [[ 400.*GeV,100.*GeV], [ 400.*GeV,100.*GeV] ], .08 ], 
          [ [[ 400.*GeV,150.*GeV], [ 400.*GeV,150.*GeV] ], .10 ], 
          [ [[ 400.*GeV,200.*GeV], [ 400.*GeV,200.*GeV] ], .12 ], 
          [ [[ 400.*GeV,250.*GeV], [ 400.*GeV,250.*GeV] ], .15 ], 
          [ [[ 400.*GeV,300.*GeV], [ 400.*GeV,300.*GeV] ], .17 ], 
          [ [[ 400.*GeV,350.*GeV], [ 400.*GeV,350.*GeV] ], .19 ], ]
     txnameData=TxNameData ( data, "efficiencyMap" ,
             sys._getframe().f_code.co_name )
     result=txnameData.getValueFor([[ 300.*GeV,125.*GeV], [ 300.*GeV,125.*GeV] ])
     self.assertAlmostEqual( result,0.115 ) 
Пример #4
0
 def testWithDirectData(self):
     data = [ [ [[ 150.*GeV, 50.*GeV], [ 150.*GeV, 50.*GeV] ],  3.*fb ], 
          [ [[ 200.*GeV,100.*GeV], [ 200.*GeV,100.*GeV] ],  5.*fb ], 
          [ [[ 300.*GeV,100.*GeV], [ 300.*GeV,100.*GeV] ], 10.*fb ], 
          [ [[ 300.*GeV,150.*GeV], [ 300.*GeV,150.*GeV] ], 13.*fb ], 
          [ [[ 300.*GeV,200.*GeV], [ 300.*GeV,200.*GeV] ], 15.*fb ], 
          [ [[ 300.*GeV,250.*GeV], [ 300.*GeV,250.*GeV] ], 20.*fb ], 
          [ [[ 400.*GeV,100.*GeV], [ 400.*GeV,100.*GeV] ],  8.*fb ], 
          [ [[ 400.*GeV,150.*GeV], [ 400.*GeV,150.*GeV] ], 10.*fb ], 
          [ [[ 400.*GeV,200.*GeV], [ 400.*GeV,200.*GeV] ], 12.*fb ], 
          [ [[ 400.*GeV,250.*GeV], [ 400.*GeV,250.*GeV] ], 15.*fb ], 
          [ [[ 400.*GeV,300.*GeV], [ 400.*GeV,300.*GeV] ], 17.*fb ], 
          [ [[ 400.*GeV,350.*GeV], [ 400.*GeV,350.*GeV] ], 19.*fb ], ]
     txnameData=TxNameData ( data, "upperLimits",
             sys._getframe().f_code.co_name )
     result=txnameData.getValueFor([[ 300.*GeV,125.*GeV], [ 300.*GeV,125.*GeV] ])
     self.assertAlmostEqual( result.asNumber(pb),0.0115 ) 
Пример #5
0
 def testWithDirectData(self):
     data = [
         [[[150. * GeV, 50. * GeV], [150. * GeV, 50. * GeV]], 3. * fb],
         [[[200. * GeV, 100. * GeV], [200. * GeV, 100. * GeV]], 5. * fb],
         [[[300. * GeV, 100. * GeV], [300. * GeV, 100. * GeV]], 10. * fb],
         [[[300. * GeV, 150. * GeV], [300. * GeV, 150. * GeV]], 13. * fb],
         [[[300. * GeV, 200. * GeV], [300. * GeV, 200. * GeV]], 15. * fb],
         [[[300. * GeV, 250. * GeV], [300. * GeV, 250. * GeV]], 20. * fb],
         [[[400. * GeV, 100. * GeV], [400. * GeV, 100. * GeV]], 8. * fb],
         [[[400. * GeV, 150. * GeV], [400. * GeV, 150. * GeV]], 10. * fb],
         [[[400. * GeV, 200. * GeV], [400. * GeV, 200. * GeV]], 12. * fb],
         [[[400. * GeV, 250. * GeV], [400. * GeV, 250. * GeV]], 15. * fb],
         [[[400. * GeV, 300. * GeV], [400. * GeV, 300. * GeV]], 17. * fb],
         [[[400. * GeV, 350. * GeV], [400. * GeV, 350. * GeV]], 19. * fb],
     ]
     txnameData = TxNameData(data, "upperLimits",
                             sys._getframe().f_code.co_name)
     result = txnameData.getValueFor([[300. * GeV, 125. * GeV],
                                      [300. * GeV, 125. * GeV]])
     self.assertAlmostEqual(result.asNumber(pb), 0.0115)
Пример #6
0
 def testOutsideConvexHull2(self):
     data = [
         [[[150. * GeV, 50. * GeV], [150. * GeV, 50. * GeV]], .03],
         [[[200. * GeV, 100. * GeV], [200. * GeV, 100. * GeV]], .05],
         [[[300. * GeV, 100. * GeV], [300. * GeV, 100. * GeV]], .10],
         [[[300. * GeV, 150. * GeV], [300. * GeV, 150. * GeV]], .13],
         [[[300. * GeV, 200. * GeV], [300. * GeV, 200. * GeV]], .15],
         [[[300. * GeV, 250. * GeV], [300. * GeV, 250. * GeV]], .20],
         [[[400. * GeV, 100. * GeV], [400. * GeV, 100. * GeV]], .08],
         [[[400. * GeV, 150. * GeV], [400. * GeV, 150. * GeV]], .10],
         [[[400. * GeV, 200. * GeV], [400. * GeV, 200. * GeV]], .12],
         [[[400. * GeV, 250. * GeV], [400. * GeV, 250. * GeV]], .15],
         [[[400. * GeV, 300. * GeV], [400. * GeV, 300. * GeV]], .17],
         [[[400. * GeV, 350. * GeV], [400. * GeV, 350. * GeV]], .19],
     ]
     txnameData = TxNameData(data, "efficiencyMap",
                             sys._getframe().f_code.co_name)
     result = txnameData.getValueFor([[300. * GeV, 125. * GeV],
                                      [300. * GeV, 100. * GeV]])
     self.assertEqual(result, None)
Пример #7
0
    def testWithDirectData(self):
        data = [[[[1.5640E+02*GeV],[1.5640E+02*GeV]],3.1127E-03*pb],
                [[[1.9728E+02*GeV],[1.9728E+02*GeV]],1.6769E-03*pb],
                [[[2.4632E+02*GeV],[2.4632E+02*GeV]],9.2590E-04*pb],
                [[[3.0899E+02*GeV],[3.0899E+02*GeV]],8.4880E-04*pb],
                [[[4.9155E+02*GeV],[4.9155E+02*GeV]],6.3010E-04*pb],
                [[[5.5967E+02*GeV],[5.5967E+02*GeV]],5.9950E-04*pb],
                [[[6.5504E+02*GeV],[6.5504E+02*GeV]],5.6320E-04*pb],
                [[[7.4496E+02*GeV],[7.4496E+02*GeV]],5.2260E-04*pb],
                [[[8.6757E+02*GeV],[8.6757E+02*GeV]],5.1580E-04*pb],
                [[[1.0283E+03*GeV],[1.0283E+03*GeV]],5.0900E-04*pb],
                [[[1.2191E+03*GeV],[1.2191E+03*GeV]],4.8380E-04*pb],
                [[[1.4098E+03*GeV],[1.4098E+03*GeV]],5.1410E-04*pb],
                [[[1.6005E+03*GeV],[1.6005E+03*GeV]],5.8110E-04*pb]]
        
        txnameData=TxNameData ( data, "upperLimits",
                sys._getframe().f_code.co_name )

        self.assertEqual(txnameData.dimensionality,1)

        #Tranformation to "PCA frame"        
        dataShift = (data[0][0][0][0]+data[-1][0][0][0])/2.
        dataShift = dataShift.asNumber(GeV)
        
        #Check inside the grid:
        result=txnameData.getValueFor([[ 1100.*GeV]]*2)
        self.assertAlmostEqual( result.asNumber(pb),0.00049953) 
        #Check outside the grid:
        result=txnameData.getValueFor([[ 2000.*GeV]]*2)
        self.assertEqual( result,None)
        
        #Check class methods:
        isimplex = txnameData.tri.find_simplex(np.array([350.-dataShift]))
        self.assertEqual(isimplex,3)
        simplex = txnameData.tri.simplices[isimplex]
        self.assertEqual(min(simplex),3)
        self.assertEqual(max(simplex),4)
Пример #8
0
    def testClusterer(self):
        """ test the mass clusterer """
        from smodels.theory import lheReader, lheDecomposer, crossSection
        from smodels.theory import clusterTools
        from smodels.experiment.txnameObj import TxName, TxNameData
        from smodels.experiment.infoObj import Info
        from smodels.tools.physicsUnits import GeV, pb, fb
        import copy

        data = [[[[674.99 * GeV, 199.999 * GeV], [674.99 * GeV,
                                                  199.999 * GeV]], .03 * fb],
                [[[725.0001 * GeV, 200. * GeV], [725.0001 * GeV, 200. * GeV]],
                 .06 * fb],
                [[[750. * GeV, 250. * GeV], [750. * GeV, 250. * GeV]],
                 .03 * fb]]
        info = Info(
            os.path.join("./database/8TeV/ATLAS/ATLAS-SUSY-2013-05/data/",
                         "dataInfo.txt"))
        globalInfo = Info(
            os.path.join("./database/8TeV/ATLAS/ATLAS-SUSY-2013-05/",
                         "globalInfo.txt"))
        txnameData = TxNameData(data, "efficiencyMap", Id=1)
        txname = TxName(
            "./database/8TeV/ATLAS/ATLAS-SUSY-2013-05/data/T2bb.txt",
            globalInfo, info)
        txname.txnameData = txnameData

        filename = "./testFiles/lhe/simplyGluino.lhe"
        reader = lheReader.LheReader(filename)
        event = reader.next()
        reader.close()
        event_xsec = event.metainfo["totalxsec"]
        self.assertTrue(abs(event_xsec - 0.262 * pb) < .1 * pb)
        xsecs = crossSection.getXsecFromLHEFile(filename)
        element = lheDecomposer.elementFromEvent(event, xsecs)
        element.txname = None
        e0 = copy.deepcopy(element)  ## has a gluino with mass of 675 GeV

        ## make a second element with a slightly different gluino mass
        e1 = copy.deepcopy(element)
        e1.branches[0].masses[0] = 725 * GeV
        e1.branches[1].masses[0] = 725 * GeV
        e0.txname = txname
        e1.txname = txname

        # lets now cluster the two different gluino masses.
        newel = clusterTools.groupAll([e0, e1])
        newmasses = newel.getAvgMass()
        self.assertTrue(
            newmasses ==
            None)  ## in the case of efficiency maps the avg mass is none
        ## since it makes no sense

        txname.txnameData.dataTag = 'upperLimits'
        newel = clusterTools.clusterElements([e0, e1], 5.)
        ## this example gives an avg cluster mass of 700 gev
        self.assertTrue(newel[0].getAvgMass()[0][0] == 700. * GeV)

        newel = clusterTools.clusterElements([e0, e1], .5)
        #in this example the distance is not in maxdist, so we dont cluster
        self.assertTrue(len(newel) == 2)
Пример #9
0
    def testSimpleCluster(self):
        """ test the mass clusterer """

        data = [[[[674.99 * GeV, 199.999 * GeV], [674.99 * GeV,
                                                  199.999 * GeV]], .03 * fb],
                [[[725.0001 * GeV, 200. * GeV], [725.0001 * GeV, 200. * GeV]],
                 .06 * fb],
                [[[750. * GeV, 250. * GeV], [750. * GeV, 250. * GeV]],
                 .03 * fb]]
        info = Info(
            "./database/8TeV/ATLAS/ATLAS-SUSY-2013-05/data/dataInfo.txt")
        globalInfo = Info(
            "./database/8TeV/ATLAS/ATLAS-SUSY-2013-05/globalInfo.txt")
        txnameData = TxNameData(data, "upperLimit", Id=1)
        txname = TxName(
            "./database/8TeV/ATLAS/ATLAS-SUSY-2013-05/data/T2bb.txt",
            globalInfo, info, finalStates)
        txname.txnameData = txnameData
        dataset = DataSet(info=globalInfo, createInfo=False)
        dataset.dataInfo = info
        dataset.txnameList = [txname]

        u = SMparticles.u
        gluino = mssm.gluino.copy()
        gluino.__setattr__("mass", 675. * GeV)
        gluino.__setattr__('totalwidth', float('inf') * GeV)
        n1 = mssm.n1.copy()
        n1.__setattr__("mass", 200. * GeV)
        n1.__setattr__('totalwidth', 0. * GeV)

        w1 = XSectionList()
        w1.xSections.append(XSection())
        w1.xSections[0].info = XSectionInfo()
        w1.xSections[0].info.sqrts = 8. * TeV
        w1.xSections[0].info.label = '8 TeV'
        w1.xSections[0].info.order = 0
        w1.xSections[0].value = 10. * fb

        b1 = Branch()
        b1.evenParticles = [[u, u]]
        b1.oddParticles = [gluino, n1]
        b2 = b1.copy()
        el1 = Element()
        el1.branches = [b1, b2]
        el1.weight = w1
        el1.txname = txname
        el1.eff = 1.  #(Used in clustering)

        ## make a second element with a slightly different gluino mass
        el2 = el1.copy()
        el2.motherElements = [el2]  #Enforce el2 and el1 not to be related
        el2.txname = txname
        el2.branches[0].oddParticles = [
            ptc.copy() for ptc in el1.branches[0].oddParticles
        ]
        el2.branches[1].oddParticles = [
            ptc.copy() for ptc in el1.branches[1].oddParticles
        ]
        el2.branches[0].oddParticles[0].__setattr__("mass", 725. * GeV)
        el2.branches[1].oddParticles[0].__setattr__("mass", 725. * GeV)
        el2.eff = 1.  #(Used in clustering)

        #Cluster for upper limits (all elements close in upper limit should be clustered together)
        maxDist = 5.  #Cluster all elements
        newel = clusterTools.clusterElements([el1, el2], maxDist, dataset)[0]
        newmasses = newel.averageElement().mass
        self.assertEqual(newmasses, [[700. * GeV, 200. * GeV]] * 2)

        maxDist = 0.5  #Elements differ and should not be clustered
        newel = clusterTools.clusterElements([el1, el2], maxDist, dataset)
        #in this example the distance is not in maxdist, so we dont cluster
        self.assertTrue(len(newel) == 2)

        info = Info(
            "./database/8TeV/CMS/CMS-SUS-13-012-eff/6NJet8_1000HT1250_200MHT300/dataInfo.txt"
        )
        globalInfo = Info(
            "./database/8TeV/CMS/CMS-SUS-13-012-eff/globalInfo.txt")
        txnameData = TxNameData(data, "efficiencyMap", Id=1)
        txname = TxName(
            "./database/8TeV/CMS/CMS-SUS-13-012-eff/6NJet8_1000HT1250_200MHT300/T2.txt",
            globalInfo, info, finalStates)
        txname.txnameData = txnameData
        dataset = DataSet(info=globalInfo, createInfo=False)
        dataset.dataInfo = info
        dataset.txnameList = [txname]

        #Cluster for efficiency maps (all elements should be clustered together independent of maxDist)
        maxDist = 0.001
        newel = clusterTools.clusterElements([el1, el2], maxDist, dataset)[0]
        newmasses = newel.averageElement().mass
        self.assertEqual(newmasses, [[700. * GeV, 200. * GeV]] * 2)
Пример #10
0
    def testClustererLifeTimes(self):
        """ test the clustering with distinct lifetimes"""

        data = [[[[674.99 * GeV, 199.999 * GeV], [674.99 * GeV,
                                                  199.999 * GeV]], .03 * fb],
                [[[725.0001 * GeV, 200. * GeV], [725.0001 * GeV, 200. * GeV]],
                 .06 * fb],
                [[[750. * GeV, 250. * GeV], [750. * GeV, 250. * GeV]],
                 .03 * fb]]
        info = Info(
            "./database/8TeV/ATLAS/ATLAS-SUSY-2013-05/data/dataInfo.txt")
        globalInfo = Info(
            "./database/8TeV/ATLAS/ATLAS-SUSY-2013-05/globalInfo.txt")
        txnameData = TxNameData(data, "upperLimit", Id=1)
        txname = TxName(
            "./database/8TeV/ATLAS/ATLAS-SUSY-2013-05/data/T2bb.txt",
            globalInfo, info, finalStates)
        txname.txnameData = txnameData
        dataset = DataSet(info=globalInfo, createInfo=False)
        dataset.dataInfo = info
        dataset.txnameList = [txname]

        u = SMparticles.u
        gluino = mssm.gluino.copy()
        gluino.__setattr__("mass", 675. * GeV)
        gluino.__setattr__('totalwidth', 1e-15 * GeV)
        n1 = mssm.n1.copy()
        n1.__setattr__("mass", 200. * GeV)
        n1.__setattr__('totalwidth', 0. * GeV)

        w1 = XSectionList()
        w1.xSections.append(XSection())
        w1.xSections[0].info = XSectionInfo()
        w1.xSections[0].info.sqrts = 8. * TeV
        w1.xSections[0].info.label = '8 TeV'
        w1.xSections[0].info.order = 0
        w1.xSections[0].value = 10. * fb

        b1 = Branch()
        b1.evenParticles = [ParticleList([u, u])]
        b1.oddParticles = [gluino, n1]
        b2 = b1.copy()
        el1 = Element()
        el1.branches = [b1, b2]
        el1.weight = w1
        el1.txname = txname
        el1.eff = 1.  #(Used in clustering)

        ## make a second element with a slightly different gluino width
        el2 = el1.copy()
        el2.motherElements = [el2]  #Enforce el2 and el1 not to be related
        el2.txname = txname
        el2.branches[0].oddParticles = [
            ptc.copy() for ptc in el1.branches[0].oddParticles
        ]
        el2.branches[1].oddParticles = [
            ptc.copy() for ptc in el1.branches[1].oddParticles
        ]
        el2.eff = 1.  #(Used in clustering)

        el2.branches[0].oddParticles[0].__setattr__("mass", 675. * GeV)
        el2.branches[1].oddParticles[0].__setattr__("mass", 675. * GeV)
        el2.branches[0].oddParticles[0].__setattr__("totalwidth",
                                                    0.9e-15 * GeV)
        el2.branches[1].oddParticles[0].__setattr__("totalwidth",
                                                    0.9e-15 * GeV)

        newel = clusterTools.clusterElements([el1, el2], 5., dataset)
        ## this example gives an avg cluster mass of 700 gev
        self.assertEqual(newel[0].averageElement().mass[0][0], 675. * GeV)
        self.assertAlmostEqual(
            newel[0].averageElement().totalwidth[0][0].asNumber(GeV) * 1e15,
            0.95)

        newel = clusterTools.clusterElements([el1, el2], .5, dataset)
        #in this example the distance is in maxdist, so we cluster
        self.assertTrue(len(newel) == 1)

        newel = clusterTools.clusterElements([el1, el2], .1, dataset)
        #in this example the distance is not in maxdist, so we dont cluster
        self.assertTrue(len(newel) == 2)