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