144def checkDirectory(directory, the_type, requireTree, depth):
145
146 from PyUtils import PoolFile
147 nentries = None
148 hasMetadata = False
149
150 msg.debug('Checking directory %s ...', directory.GetName())
151
152 listOfKeys=directory.GetListOfKeys()
153
154 msg.debug('Checking %s keys ... ', listOfKeys.GetEntries())
155
156 for key in listOfKeys:
157
158 msg.debug('Looking at key %s ...', key.GetName())
159 msg.debug('Key is of class %s.', key.GetClassName())
160
161 the_object=directory.Get(key.GetName())
162 if not the_object:
163 msg.warning("Can't get object of key %s.", key.GetName())
164 return 1
165
166 if requireTree and not isinstance(the_object, TTree):
167 msg.warning("Object of key %s is not of class TTree!", key.GetName())
168 return 1
169
170 if isinstance(the_object,TTree):
171
172 msg.debug('Checking tree %s ...', the_object.GetName())
173
174 if depth == 0:
175 if PoolFile.PoolOpts.TTreeNames.EventData == the_object.GetName():
176 nentries = the_object.GetEntries()
177 msg.debug(f' contains {nentries} events')
178 elif PoolFile.PoolOpts.TTreeNames.MetaData == the_object.GetName():
179 hasMetadata = True
180 msg.debug(' contains MetaData')
181
182 if the_type=='event':
183 if checkTreeEventWise(the_object)==1:
184 return 1
185 elif the_type=='basket':
186 if checkTreeBasketWise(the_object)==1:
187 return 1
188
189 msg.debug('Tree %s looks ok.', the_object.GetName())
190
191 if isRNTuple(the_object):
192
193 msg.debug('Checking ntuple of key %s ...', key.GetName())
194
195 try:
196 reader=RNTupleReader.Open(the_object)
197 except Exception as err:
198 msg.warning('Could not open ntuple %s: %s', the_object, err)
199 return 1
200
201 if depth == 0:
202 if PoolFile.PoolOpts.RNTupleNames.EventData == reader.GetDescriptor().GetName():
203 nentries = reader.GetNEntries()
204 msg.debug(f' contains {nentries} events')
205 elif PoolFile.PoolOpts.RNTupleNames.MetaData == reader.GetDescriptor().GetName():
206 hasMetadata = True
207 msg.debug(' contains MetaData')
208
209 if the_type=='event':
210 if checkNTupleEventWise(the_object)==1:
211 return 1
212 elif the_type=='basket':
213 if checkNTupleFieldWise(the_object)==1:
214 return 1
215
216 msg.debug('NTuple of key %s looks ok.', key.GetName())
217
218 if isinstance(the_object, TDirectory):
219 if checkDirectory(the_object, the_type, requireTree, depth + 1)==1:
220 return 1
221
222
223 if depth == 0 and hasMetadata and checkNEvents(directory.GetName(), nentries)==1:
224 return 1
225 else:
226 msg.debug('Directory %s looks ok.', directory.GetName())
227 return 0
228
229