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