# for a given TDirectory (remember that a TFile is also a TDirectory) get all non-directory objects
# redturns a tuple ('rootFolderPath', TObject) and is a generator
baseString+=TDir.GetName()+"/"
forTObjectingenerateTDirContents(TDir):
#import pdb; pdb.set_trace() # import the debugger and instruct it to stop here
ifnewOwnershipisnotNone:ROOT.SetOwnership(TObject,newOwnership)# do this to prevent an std::bad_alloc error, setting it to to 'True' gives permission to delete it, https://root.cern.ch/root/htmldoc/guides/users-guide/ObjectOwnership.html
elifisinstance(TDir.Get(TKey.GetName()),ROOT.TH1)andnotisinstance(TDir.Get(TKey.GetName()),ROOT.TH2):#check that the TKey indeed refers to a TH1
TH1List.append(TKey.GetName())
ifTDirConstraintinTDir.GetName()and"VR1"inTKey.GetName():TH1List.append(TKey.GetName())# add the histogram to our list if it is in a TDir that contains the string <TDirConstraint>
ROOT.SetOwnership(baseHist,False)# if we pass badBaseHist the histogram is relevant, so we change the ownership here to False in the attempt to prevent deletion
# discern DSID and plotTitle to use them when sorting into a tree structure
DSID=idDSID(path)
plotTitle=idPlotTitle(path,DSID=DSID)
# build my tree structure here to house the relevant histograms, pre-sorted for plotting
canvasList.sort(key=lambdax:x.GetTitle())# i.e. we are sorting the list by the output of a function, where the function provides takes implicitly elements of the list, and in our case calls the .GetTitle() method of that element of the list and outputs it
postProcessedDataFileName=os.path.basename(args.input[0])# split off the file name from the path+fileName string if necessary
ifisinstance(args.input,list):postProcessedDataFileName=os.path.basename(args.input[0])# split off the file name from the path+fileName string if necessary
else:postProcessedDataFileName=os.path.basename(args.input)# split off the file name from the path+fileName string if necessary