def readFromRootFile(self, filename, TupleMeanStd, weighter): # this function defines how to convert the root ntuple to the training format # options are not yet described here import ROOT fileTimeOut(filename, 120) #give eos a minute to recover rfile = ROOT.TFile(filename) tree = rfile.Get(self.treename) self.nsamples = tree.GetEntries() # user code, example works with the example 2D images in root format generated by make_example_data from DeepJetCore.preprocessing import readListArray feature_array, n_rechits_cut = readListArray( filename, self.treename, self.feat_branch, self.nsamples, list_size=self.max_rechits, n_feat_per_element=self.n_features, zeropad=True, list_size_cut=True) energy_only = feature_array[:, :, 0:1] #keep dimension fraction_array, _ = readListArray( filename, self.treename, self.truth_branch, self.nsamples, list_size=self.max_rechits, n_feat_per_element=self. n_simcluster, #nsimcluster, right now just one, but zero-padded here zeropad=True, list_size_cut=True) print('TrainData_hitlistX: ', filename, ';convert from root: fraction of hits cut ', 100. * float(n_rechits_cut) / float(self.nsamples), '%') #needs the energy, too to determine weights fraction_array = numpy.concatenate([fraction_array, energy_only], axis=-1) #in case something was removed here if n_rechits_cut > 0: feature_array = feature_array[0:self.nsamples - n_rechits_cut] fraction_array = fraction_array[0:self.nsamples - n_rechits_cut] self.nsamples = len(feature_array) self.x = [feature_array] self.y = [ fraction_array ] # we need the features also in the truth part for weighting self.w = [] # no event weights
def readFromRootFile(self,filename,TupleMeanStd, weighter): # this function defines how to convert the root ntuple to the training format # options are not yet described here import ROOT fileTimeOut(filename,120) #give eos a minute to recover rfile = ROOT.TFile(filename) tree = rfile.Get(self.treename) self.nsamples=tree.GetEntries() max_rechits = 40000 # user code, example works with the example 2D images in root format generated by make_example_data from DeepJetCore.preprocessing import readListArray feature_array = readListArray(filename, self.treename, "rechit_features", self.nsamples, list_size=max_rechits, n_feat_per_element=7, zeropad=True) energy_only = feature_array[:,:,0:1]#keep dimension fraction_array = readListArray(filename, self.treename, "simcluster_fractions", self.nsamples, list_size=max_rechits, n_feat_per_element=7,#nsimcluster, right now just one, but zero-padded here zeropad=True) #needs the energy, too to determine weights fraction_array = numpy.concatenate([fraction_array,energy_only],axis=-1) #in case something was removed here self.nsamples=len(feature_array) self.x=[feature_array] self.y=[fraction_array] # we need the features also in the truth part for weighting self.w=[] # no event weights
if plotRechits: add_to_out = "rh_" if 'root' == infile[-4:]: rfile = ROOT.TFile(infile) tree = rfile.Get("Delphes") nentries = tree.GetEntries() if plotRechits: print('reading features') features, _ = readListArray(filename=infile, treename="Delphes", branchname="rechit_features", nevents=nentries, list_size=3500, n_feat_per_element=10, zeropad=True, list_size_cut=True) print('reading truth') truth, _ = readListArray(filename=infile, treename="Delphes", branchname="rechit_simcluster_fractions", nevents=nentries, list_size=3500, n_feat_per_element=20, zeropad=True, list_size_cut=True)