예제 #1
0
    def __init__(self, cfg_ana, cfg_comp, looperName):
        super(PileUpAnalyzer, self).__init__(cfg_ana, cfg_comp, looperName)

        self.doHists = True
        self.currentFile = None

        if (hasattr(self.cfg_ana,
                    'makeHists')) and (not self.cfg_ana.makeHists):
            self.doHists = False

        self.allVertices = self.cfg_ana.allVertices if (hasattr(
            self.cfg_ana, 'allVertices')) else "_AUTO_"

        self.autoPU = getattr(self.cfg_ana, 'autoPU', False)

        if self.cfg_comp.isMC and self.doHists:
            self.rawmcpileup = VertexHistograms('/'.join(
                [self.dirName, 'rawMCPU.root']))
        self.enable = True
        ## if component is embed return (has no trigger obj)
        if self.cfg_comp.isEmbed:
            self.cfg_comp.puFileMC = None
            self.cfg_comp.puFileData = None

        self.setupInputs()
예제 #2
0
    def __init__(self, cfg_ana, cfg_comp, looperName):
        super(VertexAnalyzer, self).__init__(cfg_ana, cfg_comp, looperName)

        self.doHists=True
        if (hasattr(self.cfg_ana,'makeHists')) and (not self.cfg_ana.makeHists):
            self.doHists=False
        if self.doHists:    
            self.pileup = VertexHistograms('/'.join([self.dirName,
                                                     'pileup.root']))
        
        self.allVertices = self.cfg_ana.allVertices if (hasattr(self.cfg_ana,'allVertices')) else "_AUTO_"
예제 #3
0
    def __init__(self, cfg_ana, cfg_comp, looperName):
        super(PileUpAnalyzer, self).__init__(cfg_ana, cfg_comp, looperName)

        self.doHists=True

        if (hasattr(self.cfg_ana,'makeHists')) and (not self.cfg_ana.makeHists):
            self.doHists=False

        self.allVertices = self.cfg_ana.allVertices if (hasattr(self.cfg_ana,'allVertices')) else "_AUTO_"

        if self.cfg_comp.isMC and self.doHists:
            self.rawmcpileup = VertexHistograms('/'.join([self.dirName,
                                                          'rawMCPU.root']))
        self.enable = True
        ## if component is embed return (has no trigger obj)
        if self.cfg_comp.isEmbed :
          self.cfg_comp.puFileMC   = None
          self.cfg_comp.puFileData = None
          
        if self.cfg_comp.isMC or self.cfg_comp.isEmbed:
            if not hasattr(self.cfg_comp,"puFileMC") or (self.cfg_comp.puFileMC is None and self.cfg_comp.puFileData is None):
                self.enable = False
            else:
                assert( os.path.isfile(os.path.expandvars(self.cfg_comp.puFileMC)) )
                assert( os.path.isfile(os.path.expandvars(self.cfg_comp.puFileData)) )

                self.mcfile = TFile( self.cfg_comp.puFileMC )
                self.mchist = self.mcfile.Get('pileup')
                self.mchist.Scale( 1 / self.mchist.Integral() )

                self.datafile = TFile( self.cfg_comp.puFileData )
                self.datahist = self.datafile.Get('pileup')
                self.datahist.Scale( 1 / self.datahist.Integral() )

                #PU uncertainties variations
                self.datahistPlus=None
                self.datahistMinus=None
                if hasattr(self.cfg_comp,"puFileDataPlus") :
                    self.datafilePlus = TFile( self.cfg_comp.puFileDataPlus )
                    self.datahistPlus = self.datafilePlus.Get('pileup')
                    self.datahistPlus.Scale( 1. / self.datahistPlus.Integral() )
                if hasattr(self.cfg_comp,"puFileDataMinus") :
                    self.datafileMinus = TFile( self.cfg_comp.puFileDataMinus )
                    self.datahistMinus = self.datafileMinus.Get('pileup')
                    self.datahistMinus.Scale( 1. / self.datahistMinus.Integral() )

                # import pdb; pdb.set_trace()
                if self.mchist.GetNbinsX() != self.datahist.GetNbinsX():
                    raise ValueError('data and mc histograms must have the same number of bins')
                if self.mchist.GetXaxis().GetXmin() != self.datahist.GetXaxis().GetXmin():
                    raise ValueError('data and mc histograms must have the same xmin')
                if self.mchist.GetXaxis().GetXmax() != self.datahist.GetXaxis().GetXmax():
                    raise ValueError('data and mc histograms must have the same xmax')