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