예제 #1
0
    def setInputFiles(self, files):

        # reset the storage manager and process
        if self._data_manager is not None:
            del self._data_manager
            self._data_manager = None

        if files == None:
            return

        _file_list = ROOTvector(ROOTstring)()

        for file in files:
            # First, check that the file exists:
            try:
                if not os.path.exists(file):
                    print(
                        "\033[91m ERROR: requested file does not exist. \033[0m"
                    )
                    continue
            except (Exception, e):
                print(e)
                return
            # Next, verify it is a root file:
            if not file.endswith(".root"):
                print("\033[91m ERROR: must supply a root file. \033[0m")
                continue

            # Finally, ping the file to see what is available to draw
            self.pingFile(file)
            if len(self._keyTable['all']) > 0:
                self._hasFile = True
                _file_list.push_back(file)

        # Have to figure out number of events available
        for _f in _file_list:
            _f = str(_f)
            _rf = TFile(_f)
            _tree = _rf.Get("Events")
            self._n_entries += _tree.GetEntries()
            _rf.Close()

        # Create an instance of the data manager:
        if _file_list.size() > 0:
            self._data_manager = gallery.Event(_file_list)

        # Open the manager
        self._lastProcessed = -1

        self.goToEvent(0)

        self.fileChanged.emit()
예제 #2
0
import ROOT
from ROOT import gallery
from ROOT import evd

a = evd.DrawWire()
a.initialize()
a.setYDimension(9600, 0)
a.setYDimension(9600, 1)
a.setYDimension(9600, 2)

files = ROOT.vector(ROOT.string)()
files.push_back(
    "/data/uboone/pulser_data/10V-pulses/TestRun-2017_2_21_14_10_54-0010153-00000_20170222T014119_mucs_20170222T021127_merged.root"
)
b = gallery.Event(files)

a.analyze(b)

c = a.getArrayByPlane(0)

print(type(c))
print(c.shape)

print(b)
예제 #3
0
class evd_manager_base(manager, QtCore.QObject):
    fileChanged = QtCore.pyqtSignal()
    eventChanged = QtCore.pyqtSignal()
    """docstring for lariat_manager"""
    def __init__(self, geom, file=None):
        super(evd_manager_base, self).__init__(geom, file)
        manager.__init__(self, geom, file)
        QtCore.QObject.__init__(self)
        # For the larlite manager, need both the ana_processor and
        # the storage manager
        self._processer = processer()
        # self._mgr = fmwk.storage_manager()
        self._data_manager = None

        self._keyTable = dict()
        self._drawnClasses = dict()

        if file != None:
            self.setInputFiles(file)

        self._n_entries = 0

        # Toggle whether or not to draw wires:
        self._drawWires = False
        # self._drawParams = False
        # self._drawTruth = False

        self._wireDrawer = None
        # self._truthDrawer = None

    def pingFile(self, file):
        """
        this function opens the file and
        determines what is available to draw
        """
        # This function opens the file to see
        # what data products are available

        # Open the file
        f = TFile(file)
        # Use the larlite_id_tree to find out how many entries are in the file:
        e = f.Get("Events")

        # prepare a dictionary of data products
        lookUpTable = dict()
        lookUpTable.update({"all": dict()})

        product_list = []
        # Loop over the keys (list of trees)
        for key in e.GetListOfBranches():

            if key.GetTypeName() == 'art::EventAuxiliary':
                continue

            if "NuMu" in key.GetName() and "Assns" in key.GetTypeName():
                if "PFParticle" in key.GetTypeName():
                    continue
            elif "Assns" in key.GetTypeName():
                continue

            prod = product(key.GetName(), key.GetTypeName())

            # if "NuMu" in key.GetName():
            #     print "NuMu stage is " + str(prod.stage())
            #     print "NuMu name is " +  str(prod.fullName())
            #     print "NuMu type name is " + str(prod.typeName())
            _product = prod._typeName

            # Add the product to the "all" list and
            # also to it's stage list:

            # gets three items in thisKeyList, which is a list
            # [dataProduct, producer, 'tree'] (don't care about 'tree')
            # check if the data product is in the dict:
            if _product in lookUpTable['all']:
                # extend the list:
                lookUpTable['all'][_product] += (prod, )
            else:
                lookUpTable['all'].update({_product: (prod, )})

            if not (prod.stage() in lookUpTable):
                lookUpTable.update({prod.stage(): dict()})
            if _product in lookUpTable[prod.stage()]:
                # extend the list:
                lookUpTable[prod.stage()][_product] += (prod, )
            else:
                lookUpTable[prod.stage()].update({_product: (prod, )})

        self._keyTable.update(lookUpTable)
        return

    def setInputFile(self, file):
        f = [
            file,
        ]
        self.setInputFiles(f)

    def setInputFiles(self, files):

        # reset the storage manager and process
        if self._data_manager is not None:
            self._data_manager = None
        # self._process.reset()

        if files == None:
            return

        _file_list = ROOT.vector(ROOT.string)()

        for file in files:
            # First, check that the file exists:
            try:
                if not os.path.exists(file):
                    print "ERROR: requested file does not exist."
                    continue
            except Exception, e:
                print e
                return
            # Next, verify it is a root file:
            if not file.endswith(".root"):
                print "ERROR: must supply a root file."
                continue

            # Finally, ping the file to see what is available to draw
            self.pingFile(file)
            if len(self._keyTable['all']) > 0:
                self._hasFile = True
                _file_list.push_back(file)

        # Have to figure out number of events available
        for _f in _file_list:
            _rf = ROOT.TFile(_f)
            _tree = _rf.Get("Events")
            self._n_entries += _tree.GetEntries()

        # Create an instance of the data manager:
        if _file_list.size() > 0:
            self._data_manager = gallery.Event(_file_list)

        # Open the manager
        self._lastProcessed = -1
        self.goToEvent(0)
        self.fileChanged.emit()
예제 #4
0
                           ";L_{MC} [cm];N. Entries / 10 cm", 20, 0, 200)
h_mc_shower_energy = TH1F("h_mc_shower_energy",
                          ";E_{MC} [GeV];N. Entries / 0.05 GeV", 20, 0, 2)

# Efficiency histograms
h_correct = TH1F("h_correct", ";#nu_{e} energy [GeV];Efficiency", 15, 0, 3)
h_total = TH1F("h_total", ";#nu_{e} energy [GeV];Efficiency", 15, 0, 3)
h_correct_more_showers = TH1F("h_correct_more_showers",
                              ";#nu_{e} energy [GeV];Efficiency", 15, 0, 3)
h_correct_shower_only = TH1F("h_correct_shower", ";#nu_{e} [GeV];Efficiency",
                             15, 0, 3)
h_correct_more_showers_only = TH1F("h_correct_more_showers_only",
                                   ";#nu_{e} [GeV];Efficiency", 15, 0, 3)

print "Creating event object ..."
ev = gallery.Event(filenames)

# Capture the functions that will get ValidHandles. This avoids some
# inefficiency in constructing the function objects many times.
get_showers = ev.getValidHandle(vector(recob.Shower))
get_mcparticles = ev.getValidHandle(vector(simb.MCParticle))
get_mcshowers = ev.getValidHandle(vector(sim.MCShower))
get_tracks = ev.getValidHandle(vector(recob.Track))
get_mctruth = ev.getValidHandle(vector(simb.MCTruth))

print "Entering event loop..."
n = 0
max_e = 0
while (not ev.atEnd()):

    n += 1