예제 #1
0
파일: process.py 프로젝트: swang373/ZnnHbb
    def _cut_samples(self, task_queue, done_queue):
    
        for sample, sample_cut in iter(task_queue.get, None):

            inpath = SAMPLE_DIR + sample
            outpath = self.tmpdir + sample

            with root_open(inpath, 'r') as infile, root_open(outpath, 'w') as outfile:

                intree = infile.Get('tree')
                outtree = intree.CopyTree(sample_cut & self.process_cut)
                outtree.Write()
            
                for key in infile.GetListOfKeys():
                    if key.GetName() == 'tree':
                        continue
                    obj = key.ReadObj()
                    obj.Write()

                done_queue.put(outfile.GetName())
예제 #2
0
파일: sample.py 프로젝트: swang373/ZnnHbb
    def _copy_files(self, task_queue, done_queue):
 
        for fname in iter(task_queue.get, None):
        
            inpath = 'root://eoscms.cern.ch/' + self.path + fname
            outpath = self.tmpdir + fname

            with root_open(inpath, 'r') as infile, root_open(outpath, 'w') as outfile:

                intree = infile.Get('tree')
                outtree = intree.CopyTree(self.cuts)
                outtree.Write()

                for key in infile.GetListOfKeys():
                    if key.GetName() == 'tree':
                        continue
                    obj = key.ReadObj()
                    obj.Write()

                n_out, n_in = outtree.GetEntriesFast(), intree.GetEntriesFast()

            done_queue.put((n_out, n_in, fname))
예제 #3
0
파일: sample.py 프로젝트: swang373/ZnnHbb
    def _write_sample_lumi(self):
       
        with root_open(self.outputfile, 'r+') as infile: 

            tree = infile.Get('tree')

            sample_lumi_address = np.array([-999], np.float32)
            sample_lumi_branch = tree.Branch('sample_lumi', sample_lumi_address, 'sample_lumi/F')
        
            n_pos = infile.Get('CountPosWeight').GetBinContent(1)
            n_neg = infile.Get('CountNegWeight').GetBinContent(1)

            sample_lumi_address[0] = (n_pos - n_neg) / self.xsec
            self.logger.info('Sample Luminosity: %s pb-1', sample_lumi_address[0])

            for i in xrange(0, tree.GetEntriesFast()):
                tree.GetEntry(i)
                sample_lumi_branch.Fill()

            tree.Write()