227{
229
231 VP1SGAccessHelper sg_access(
theclass->systemBase());
233 return false;
234
235 typename T::const_iterator element, lastElement(container->end());
236
238
239 if ( container->size()==0 && container->begin()!=lastElement ) {
240 theclass->message(
"ERROR: container '"+
storegate_key+
"' has size()==0, but different begin() and end() iterators!");
241 return false;
242 }
243
245
246 bool fallback(false);
247 SG::ConstIterator<typename T::base_value_type> firstElementD, lastElementD;
248 if ( container->size()!=0 && container->begin()==lastElement ) {
249
250 theclass->messageDebug(
"Retrieved empty container. This might be misleading. Now going to attempt to load prds via iterators instead.");
251 if (VP1SGContentsHelper(
theclass->systemBase()).getKeys<T>().count()!=1) {
252 theclass->messageDebug(
"But seems that there is not exactly one collection of type "+QString(
typeid(T).
name())
253 +", so we won't attempt that anyway!! Thus we assume there there are simply no prd's.");
254 } else {
255 if(sg_access.retrieve(firstElementD, lastElementD,true)) {
256 if (firstElementD==lastElementD) {
257 theclass->messageDebug(
"No prd's found when accessed by iterators either. It seems that there really are just no prds in this collection.");
258 } else {
259 fallback = true;
260 }
261 } else {
262 theclass->messageDebug(
"Failed retrieval by iterators. We take that as a sign that there really are just no prds in this collection ");
263 }
264 }
265 }
266
267 theclass->messageVerbose(
"Loop over actual prd's and create handles");
268
269
270 int ignoredUnsafeHandle_NoPRD(0);
271 int ignoredUnsafeHandle_NoDetElem(0);
272 int ignoredUnsafeHandle_NotSane(0);
273 typename T::base_value_type::const_iterator prd, prdLast;
274 int iprds(0);
275 if (!fallback) {
276
277
278
279
280
281
282
283 for ( element = container->begin(); element!=lastElement ; ++element) {
284 prd = (*element)->begin(), prdLast = (*element)->end();
285 for ( ; prd!=prdLast ; ++prd) {
286 ++iprds;
287 if (!*prd) {
288 ++ignoredUnsafeHandle_NoPRD;
289 continue;
290 }
291 PRDHandleBase * handle =
theclass->addPRD(*prd);
292 if (handle) {
293 if (!handle->
isSane()) ignoredUnsafeHandle_NotSane++;
295 ++ignoredUnsafeHandle_NoDetElem;
296 delete handle;
297 } else {
299 theclass->common()->registerPRD2Handle(*prd,handle);
300 }
301 }
302 }
303 if (!(iprds%100))
304 theclass->systemBase()->updateGUI();
305 }
306
307 } else {
308
309 for (; firstElementD!=lastElementD; ++firstElementD ) {
310 prd = firstElementD->begin(), prdLast = firstElementD->end();
311 for ( ; prd!=prdLast ; ++prd) {
312 ++iprds;
313 if (!*prd) {
314 ++ignoredUnsafeHandle_NoPRD;
315 continue;
316 }
317 PRDHandleBase * handle =
theclass->addPRD(*prd);
318 if (handle) {
319 if (!handle->
isSane()) ignoredUnsafeHandle_NotSane++;
320
322 ++ignoredUnsafeHandle_NoDetElem;
323 delete handle;
324 } else {
326 theclass->common()->registerPRD2Handle(*prd,handle);
327 }
328 }
329 if (!(iprds%100))
330 theclass->systemBase()->updateGUI();
331 }
332 }
333 }
334 theclass->systemBase()->updateGUI();
336
337 if (ignoredUnsafeHandle_NoPRD)
338 theclass->message(
"WARNING - ignoring "+
str(ignoredUnsafeHandle_NoPRD)+
" null prd pointer(s).");
339 if (ignoredUnsafeHandle_NoDetElem)
340 theclass->message(
"WARNING - ignoring "+
str(ignoredUnsafeHandle_NoDetElem)+
" prd pointer(s) with null detector elements.");
341 if (ignoredUnsafeHandle_NotSane)
342 theclass->message(
"WARNING - found "+
str(ignoredUnsafeHandle_NotSane)+
" prd pointer(s) which fail sanity checks (i.e. contain NaNs).");
343
344
345 theclass->messageVerbose(
"postLoadInitialisation");
347
348 theclass->systemBase()->updateGUI();
349
350
351 theclass->recheckCutStatusOfAllNotVisibleHandles();
352
353 theclass->message(
"Found "+QString::number(iprds)+
" ("+QString::number(
theclass->nShownHandles())+
" shown) PRDs in container '"+
storegate_key+
"'");
354
355 return true;
356
357}
PRDCollHandleBase * theclass
std::vector< PRDHandleBase * > prdhandles
virtual const Trk::PrepRawData * getPRD() const =0
virtual bool isSane() const
Returns false if the PRD is not safe to draw.
virtual const TrkDetElementBase * detectorElement() const =0
return the detector element corresponding to this PRD The pointer will be zero if the det el is not d...