]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/BASE/util/AliHLTESDMCEventPublisherComponent.cxx
avoid warning for the default HLT simulation
[u/mrichter/AliRoot.git] / HLT / BASE / util / AliHLTESDMCEventPublisherComponent.cxx
1 // $Id: AliHLTESDMCEventPublisherComponent.cxx 25452 2008-04-25 21:46:04Z richterm $
2
3 /**************************************************************************
4  * This file is property of and copyright by the ALICE HLT Project        * 
5  * ALICE Experiment at CERN, All rights reserved.                         *
6  *                                                                        *
7  * Primary Authors: Jochen Thaeder <thaeder@kip.uni-heidelberg.de>        *
8  *                  for The ALICE HLT Project.                            *
9  *                                                                        *
10  * Permission to use, copy, modify and distribute this software and its   *
11  * documentation strictly for non-commercial purposes is hereby granted   *
12  * without fee, provided that the above copyright notice appears in all   *
13  * copies and that both the copyright notice and this permission notice   *
14  * appear in the supporting documentation. The authors make no claims     *
15  * about the suitability of this software for any purpose. It is          *
16  * provided "as is" without express or implied warranty.                  *
17  **************************************************************************/
18
19 /** @file   AliHLTESDMCEventPublisherComponent.cxx
20     @author Jochen Thaeder
21     @date   
22     @brief  Component for publishing ESD and MC events.
23     @note   The class is used in Offline (AliRoot) context
24 */
25
26 #include "AliHLTESDMCEventPublisherComponent.h"
27
28 #include "TList.h"
29 #include "TTree.h"
30 #include "TKey.h"
31 #include "TFile.h"
32
33 /** ROOT macro for the implementation of ROOT specific class methods */
34 ClassImp(AliHLTESDMCEventPublisherComponent)
35
36 /*
37  * ---------------------------------------------------------------------------------
38  *                            Constructor / Destructor
39  * ---------------------------------------------------------------------------------
40  */
41
42 // #################################################################################
43 AliHLTESDMCEventPublisherComponent::AliHLTESDMCEventPublisherComponent()
44   :
45   AliHLTFilePublisher(),
46   fpCurrentFolder(NULL),
47   fpCurrentFileList(NULL),
48   fCurrentEvent(0),
49   fNEventsInFolder(0),
50   fFolderList(),
51   fSpecification(0),
52   fPublishESD(kFALSE),
53   fPublishHLTESD(kFALSE),
54   fPublishMC(kFALSE),
55   fFastMC(kFALSE),
56   fpTreeESD(NULL),
57   fpTreeHLTESD(NULL),
58   fpTreeE(NULL),
59   fpTreeK(NULL),
60   fpTreeTR(NULL),
61   fpESD(NULL),
62   fpHLTESD(NULL),
63   fpMC(NULL),
64   fpHLTMC(NULL) {
65   // see header file for class documentation
66   // or
67   // refer to README to build package
68   // or
69   // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
70
71   // Set file to ROOT-File
72   SetIsRawFile( kFALSE );
73
74   fFolderList.SetOwner();
75 }
76
77 // #################################################################################
78 AliHLTESDMCEventPublisherComponent::~AliHLTESDMCEventPublisherComponent() {
79   // see header file for class documentation
80
81   // file list and file name list are owner of their objects and
82   // delete all the objects
83 }
84
85 /*
86  * ---------------------------------------------------------------------------------
87  * Public functions to implement AliHLTComponent's interface.
88  * These functions are required for the registration process
89  * ---------------------------------------------------------------------------------
90  */
91
92 // #################################################################################
93 const char* AliHLTESDMCEventPublisherComponent::GetComponentID() {
94   // see header file for class documentation
95   return "ESDMCEventPublisher";
96 }
97
98 // #################################################################################
99 AliHLTComponent* AliHLTESDMCEventPublisherComponent::Spawn() {
100   // see header file for class documentation
101   return new AliHLTESDMCEventPublisherComponent;
102 }
103
104 /*
105  * ---------------------------------------------------------------------------------
106  * Protected functions to implement AliHLTComponent's interface.
107  * These functions provide initialization as well as the actual processing
108  * capabilities of the component. 
109  * ---------------------------------------------------------------------------------
110  */
111
112 // #################################################################################
113 Int_t AliHLTESDMCEventPublisherComponent::DoInit(int argc, const char** argv) {
114   // see header file for class documentation
115
116   Int_t iResult = 0;
117   Int_t bMissingParam=0;
118   
119   TString argument="";
120
121   fSpecification = kAliHLTVoidDataSpec;
122
123   // -- Loop over all arguments
124   for ( Int_t iter = 0; iter<argc && iResult>=0; iter++) {
125     argument=argv[iter];
126     if (argument.IsNull()) continue;
127     
128     // -- Check for which type to publish
129     //    Can be one, all or some of : ESD, HLTESD and MC
130     if ( !argument.CompareTo("-entrytype") ) {
131       if ((bMissingParam=(++iter>=argc))) break;
132       
133       TString parameter(argv[iter]);
134       parameter.Remove(TString::kLeading, ' ');
135       
136       if ( !parameter.CompareTo("ESD") )
137         fPublishESD = kTRUE;
138       else if ( !parameter.CompareTo("HLTESD") )
139         fPublishHLTESD = kTRUE;
140       else if ( !parameter.CompareTo("MC") )
141         fPublishMC = kTRUE;
142       else if ( !parameter.CompareTo("MCFAST") ) {
143         fPublishMC = kTRUE;
144         fFastMC = kTRUE;
145       }
146       else {
147         HLTError("Wrong parameter %s for argument %s.", parameter.Data(), argument.Data());
148         iResult=-EINVAL;
149       }
150     } 
151     
152     // -- Data path to reconstructed data
153     else if ( ! argument.CompareTo("-datapath") ) {
154       if ((bMissingParam=(++iter>=argc))) break;
155       
156       TString parameter(argv[iter]);
157       parameter.Remove(TString::kLeading, ' ');
158       
159       fFolderList.Add( new TObjString(parameter) );
160     }
161
162     // -- Data Specification 
163     //    -- see header file !!!
164     else if ( ! argument.CompareTo("-dataspec") ) {
165       if ((bMissingParam=(++iter>=argc))) break;
166       
167       TString parameter(argv[iter]);
168       parameter.Remove(TString::kLeading, ' ');
169             
170       if ( parameter.IsDigit() )
171         fSpecification = (AliHLTUInt32_t) parameter.Atoi();
172       else if ( parameter.BeginsWith("0x") && parameter.Replace(0,2,"",0).IsHex() )
173         sscanf(parameter.Data(),"%x", &fSpecification);
174       else {
175         HLTError("Wrong parameter for argument %s, number expected", argument.Data());
176         iResult=-EINVAL;
177       }
178     }
179
180     // -- Argument not known
181     else {
182       HLTError("Unknown argument %s.", argument.Data());
183       iResult = -EINVAL;
184     }
185     
186   } // for ( Int iter = 0; iter<argc && iResult>=0; iter++) {
187   
188   // -- Check if parameter is missing
189   if ( bMissingParam ) {
190     HLTError("Missing parameter for argument %s.", argument.Data());
191      iResult=-EINVAL;
192   }
193   
194   //  -- Check if at least on entrytype was specified
195   if ( fPublishESD||fPublishHLTESD||fPublishMC ) 
196     AddDataTypesToOutputlist();
197   else {
198     HLTError("At least one -entrytype argument needs to be specified.");
199     iResult=-EINVAL;
200   }
201   
202   // -- Check if at least one datapath was specified
203   if ( !fFolderList.GetEntries() ) {
204     HLTError("At least one -datapath argument needs to be specified.");
205     iResult=-EINVAL;
206   }
207   
208   // -- Add files according to entry type to event
209   if ( iResult >= 0 ) {
210     iResult = InsertFiles();
211   }
212
213   // -- Calculate event size
214   if ( fPublishESD )
215     fMaxSize += sizeof(AliESDEvent);
216   if ( fPublishHLTESD )
217     fMaxSize += sizeof(AliESDEvent);
218   if ( fPublishMC )
219     fMaxSize += sizeof(AliMCEvent) + 15000;
220   
221   if ( fEvents.GetSize() == 0) {
222     HLTError("No Files have been added.");
223     iResult=-EINVAL;
224   }
225
226   if ( iResult < 0 ) {
227     fEvents.Clear();
228   }
229   
230   return iResult;
231 }
232
233 // #################################################################################
234 Int_t AliHLTESDMCEventPublisherComponent::DoDeinit() {
235   // see header file for class documentation
236
237   Int_t iResult = 0;
238
239   if ( fpESD ) 
240     delete fpESD;
241   fpESD = NULL;
242
243   if ( fpHLTESD ) 
244     delete fpHLTESD;
245   fpHLTESD = NULL;
246
247   if ( fpMC ) 
248     delete fpMC;
249   fpMC = NULL;
250
251   if ( fpHLTMC ) 
252     delete fpHLTMC;
253   fpHLTMC = NULL;
254
255
256   CloseCurrentFileList();
257   
258   AliHLTFilePublisher::DoDeinit();
259
260   return iResult;
261 }
262
263 // #################################################################################
264 void AliHLTESDMCEventPublisherComponent::AddDataTypesToOutputlist() {
265   // see header file for class documentation
266
267   // add all different data types to the list
268   if ( fPublishESD  )
269     fOutputDataTypes.push_back(kAliHLTDataTypeESDObject|kAliHLTDataOriginOffline);
270   else if ( fPublishHLTESD )
271     fOutputDataTypes.push_back(kAliHLTDataTypeESDObject|kAliHLTDataOriginHLT);
272   else if( fPublishMC )
273     fOutputDataTypes.push_back(kAliHLTDataTypeMCObject);
274 }
275
276 // #################################################################################
277 Int_t AliHLTESDMCEventPublisherComponent::InsertFiles(){
278   // see header file for class documentation
279
280   Int_t iResult=0;
281
282   EventFiles* pCurrentFolder = NULL;
283
284   TObjString *objPath = 0;
285   TIter next(&fFolderList);
286
287   // Loop over all folders
288   while ( ( objPath = (TObjString*) next() ) && iResult>=0 ) {
289
290     TString pathAliESDs = objPath->GetString();      
291     pathAliESDs.Append("/AliESDs.root");
292
293     TString pathKinematics = objPath->GetString();      
294     pathKinematics.Append("/Kinematics.root");
295
296     TString pathgalice = objPath->GetString();      
297     pathgalice.Append("/galice.root");
298
299     TString pathTrackRefs = objPath->GetString();      
300     pathTrackRefs.Append("/TrackRefs.root");
301
302
303     // Add ESD file for this folder
304     if ( fPublishESD || fPublishHLTESD ) {
305       FileDesc* pDesc=new FileDesc( pathAliESDs.Data(), kAliHLTDataTypeESDObject, kAliHLTVoidDataSpec, kFALSE);
306       if ( pDesc ) 
307         iResult = InsertFile( pCurrentFolder, pDesc );
308       else 
309         iResult = -ENOMEM;
310     }
311
312     // Add MC files for this folder
313     if ( fPublishMC ) {
314       FileDesc* pDescKinematics=new FileDesc( pathKinematics.Data(), kAliHLTDataTypeMCObject, kAliHLTVoidDataSpec, kFALSE);
315       if ( pDescKinematics )  
316         iResult = InsertFile( pCurrentFolder, pDescKinematics );
317       else 
318         iResult = -ENOMEM;
319
320       FileDesc* pDescgalice=new FileDesc( pathgalice.Data(), kAliHLTDataTypeMCObject, kAliHLTVoidDataSpec, kFALSE);
321       if ( pDescgalice )  
322         iResult = InsertFile( pCurrentFolder, pDescgalice );
323       else 
324         iResult = -ENOMEM;
325
326       if ( ! fFastMC ) {
327         FileDesc* pDescTrackRefs=new FileDesc( pathTrackRefs.Data(), kAliHLTDataTypeMCObject, kAliHLTVoidDataSpec, kFALSE);
328         if ( pDescTrackRefs )  
329           iResult = InsertFile( pCurrentFolder, pDescTrackRefs );
330         else 
331           iResult = -ENOMEM;
332       }
333     }
334     
335     // -- Add all files belonging to one eventfolder
336     InsertEvent( pCurrentFolder );
337     
338   } // while ( ( path = (TObjString*)next() ) ) {
339   
340   return iResult;
341 }
342
343 // #################################################################################
344 Int_t AliHLTESDMCEventPublisherComponent::GetEvent( const AliHLTComponentEventData& /*evtData*/,
345                                                 AliHLTComponentTriggerData& /*trigData*/,
346                                                 AliHLTUInt8_t* /*outputPtr*/, 
347                                                 AliHLTUInt32_t& size,
348                                                 vector<AliHLTComponentBlockData>& /*outputBlocks*/ ) {
349   // see header file for class documentation
350
351   if ( !IsDataEvent() ) return 0;
352
353   Int_t iResult=0;
354   size=0;
355
356   // -- Initialize folder list and 
357   //    re-initialize after reaching the end in the event before
358   //    
359   if ( !fpCurrentFolder ) {
360     fpCurrentFolder = GetEventList()->FirstLink();
361
362     // -- Set file list of this folder and open the files
363     if ( fpCurrentFolder ) {
364       iResult = OpenCurrentFileList();
365     }
366     else {
367       HLTError("Folder link can not be retrieved from folder list.");
368       iResult=-ENOENT;
369     }
370   }
371   
372   // -- if file list was properly created
373   if ( iResult >= 0 && fpCurrentFileList ) {
374     
375     // -- Publish ESDs
376     if ( fPublishESD  && fpTreeESD ) {
377       fpTreeESD->GetEntry(fCurrentEvent);
378       PushBack( fpESD, kAliHLTDataTypeESDObject|kAliHLTDataOriginOffline , fSpecification  ); 
379     }
380
381     // -- Publish HLTESDs
382     if ( fPublishHLTESD && fpTreeHLTESD ) {
383       fpTreeHLTESD->GetEntry(fCurrentEvent);
384       PushBack( fpHLTESD, kAliHLTDataTypeESDObject|kAliHLTDataOriginHLT , fSpecification ); 
385     }
386
387     // -- Publish MC
388     if ( fPublishMC ) {
389
390       TObjLink *flnk = fpCurrentFileList->FirstLink();
391       
392       // -- Loop over files in the current list
393       while (flnk && iResult>=0) {
394         
395         FileDesc* pFileDesc = dynamic_cast<FileDesc*>( flnk->GetObject() );
396         TFile* pFile = *pFileDesc;
397
398         TString filename = pFile->GetName();
399         filename.Remove(0,filename.Last('/')+1);
400         
401         TString foldername( Form("Event%d", fCurrentEvent) );
402
403         // -- Open Kinematics
404         if ( !filename.CompareTo("Kinematics.root") ){
405
406           if ( fNEventsInFolder != (UInt_t)(pFile->GetListOfKeys()->GetEntries()) ) {
407             HLTError("Not all files contain the same number of events : %u and %d", 
408                      fNEventsInFolder, pFile->GetListOfKeys()->GetEntries() );
409             iResult=-EFAULT;
410           }
411           
412           // -- Get Tree K
413           else {
414             TDirectoryFile *dirK = dynamic_cast<TDirectoryFile*> (pFile->Get(foldername));
415             if ( dirK )
416               fpTreeK = dynamic_cast<TTree*> (dirK->Get("TreeK"));
417             else {
418               HLTError("Directory %s could not be found.",  foldername.Data() );
419               iResult=-EFAULT;
420             }
421           }
422         } // if ( !filename.CompareTo("Kinematics.root") ){
423
424         // -- Open TrackReferences
425         else if ( !fFastMC && !filename.CompareTo("TrackRefs.root") ) {
426           
427           if ( fNEventsInFolder != (UInt_t)(pFile->GetListOfKeys()->GetEntries()) ) {
428             HLTError("Not all files contain the same number of events : %u and %d", 
429                      fNEventsInFolder, pFile->GetListOfKeys()->GetEntries() );
430             iResult=-EFAULT;
431           }
432           
433           // -- Get Tree TR
434           else {
435             TDirectoryFile *dirTR = dynamic_cast<TDirectoryFile*> (pFile->Get(foldername));
436             if ( dirTR )
437               fpTreeTR = dynamic_cast<TTree*> (dirTR->Get("TreeTR"));
438             else {
439               HLTError("Directory %s could not be found.",  foldername.Data() );
440               iResult=-EFAULT;
441             }
442           }
443         } // else if ( !filename.CompareTo("TrackRefs.root") ){
444         
445         flnk = flnk->Next();
446         
447       } // while (flnk && iResult>=0) {
448       
449       if ( fpMC ) delete fpMC;
450       fpMC = new AliMCEvent();
451       
452       if ( fpTreeE && fpTreeK && fpTreeTR ) {
453         fpMC->ConnectTreeE(fpTreeE);
454         fpTreeE->GetEntry(fCurrentEvent);
455
456         fpMC->ConnectTreeK(fpTreeK);
457         fpMC->ConnectTreeTR(fpTreeTR);  
458       }
459       else if( fpTreeE && fpTreeK && fFastMC ) {
460         fpMC->ConnectTreeE(fpTreeE);
461         fpTreeE->GetEntry(fCurrentEvent);
462
463         fpMC->ConnectTreeK(fpTreeK);
464       }
465       else {
466         HLTError("Not all trees needed for MC Event have been created.");
467         iResult=-EFAULT;
468       }
469
470       // -- Fill AliHLTMCEvent 
471       if ( iResult>=0 && fpMC ) {
472         PushBack( fpMC, kAliHLTDataTypeMCObject|kAliHLTDataOriginOffline , fSpecification ); 
473
474         fpHLTMC = new AliHLTMCEvent(fpMC);
475         
476         if ( fpHLTMC )
477           PushBack( fpHLTMC, kAliHLTDataTypeMCObject|kAliHLTDataOriginHLT , fSpecification ); 
478       }
479
480     } // if ( fPublishMC ) {
481     
482     // -- Next Event in Folder, 
483     //    if last event was already reached:
484     //    -> Reser and close files
485     if ( ++fCurrentEvent >= fNEventsInFolder )
486       iResult = CloseCurrentFileList();
487     
488   } // if ( iResult >= 0 && fCurrentFileList ) {
489
490   // -- Next Folder 
491   //   (fpCurrentEvent will be NULL*pFileDesc if end of events in file is reached)
492   if ( iResult >= 0 && fpCurrentFolder && !fCurrentEvent ) {
493     fpCurrentFolder=fpCurrentFolder->Next();
494
495     // -- if next Folder present : Set current file list of next folder
496     //    else : end of folder list reached, reset fpCurrentFileList
497     if ( fpCurrentFolder )
498       iResult = OpenCurrentFileList();
499
500   }
501
502   return iResult;
503 }
504
505 // #################################################################################
506 Int_t AliHLTESDMCEventPublisherComponent::OpenCurrentFileList() {
507   // see header file for class documentation
508
509   Int_t iResult = 0;
510   Int_t nEntries = -1;
511
512   // -- Get Current Folder
513   EventFiles* pCurrentFolderDesc = dynamic_cast<EventFiles*>( fpCurrentFolder->GetObject() );
514
515   // -- Get List of files in current folder  
516   if ( pCurrentFolderDesc )
517     fpCurrentFileList = *pCurrentFolderDesc; // type conversion operator defined
518   else {
519     HLTError("Folder descriptor can not be retrieved from folder list link");
520     iResult=-EFAULT;
521   }
522   
523   if ( fpCurrentFileList && iResult >= 0 ) {
524   
525     TObjLink *flnk = fpCurrentFileList->FirstLink();
526   
527     // -- Loop over all files in folder
528     // ----------------------------------
529     while ( flnk && iResult>=0 ) {
530       FileDesc* pFileDesc = dynamic_cast<FileDesc*>( flnk->GetObject() );
531       TFile* pFile = NULL;
532     
533       // If file is not opened yet, open it ... which it should not
534       if ( pFileDesc && ( pFile = *pFileDesc ) == NULL )
535         pFileDesc->OpenFile();
536       else {
537         HLTError("File already open, this should not happen.");
538         iResult=-EFAULT;
539       }
540       
541       if ( (pFile = *pFileDesc ) == NULL ) {
542         HLTError("Opening file failed." );
543         iResult=-EFAULT;
544       }
545
546       // -- Open trees
547       // ---------------
548       TString filename = pFile->GetName();
549       filename.Remove(0,filename.Last('/')+1);
550       
551       // -- Open ESD tree
552       if ( !filename.CompareTo("AliESDs.root") && fPublishESD ) {
553         fpTreeESD = dynamic_cast<TTree*>(pFile->Get("esdTree") );
554
555         if ( fpTreeESD ) {
556           if ( nEntries == -1 ) 
557             nEntries = (Int_t)(fpTreeESD->GetEntriesFast());
558           else if ( nEntries != (Int_t)(fpTreeESD->GetEntriesFast()) ) {
559             HLTError("Not all files contain the same number of events : %d and %ld", 
560                      nEntries, fpTreeESD->GetEntriesFast());
561             iResult=-EFAULT;
562           }
563         
564           // Setup AliESDEvent
565           if ( fpESD ) delete fpESD;
566           fpESD = new AliESDEvent();        
567           fpESD->ReadFromTree(fpTreeESD); 
568
569         } // if ( fpTreeESD ) {
570         else {
571           HLTError("Getting ESD tree failed for file %s.", pFile->GetName() );
572           iResult=-EFAULT;
573         }
574       } // if ( !filename.CompareTo("AliESDs.root") && fPublishESD ){
575
576
577       // -- Open HLTESD tree
578       if ( !filename.CompareTo("AliESDs.root") && fPublishHLTESD ) {
579         fpTreeHLTESD = dynamic_cast<TTree*>(pFile->Get("HLTesdTree") );
580
581         if ( fpTreeHLTESD ) {
582           if ( nEntries == -1 ) 
583             nEntries = (Int_t)(fpTreeHLTESD->GetEntriesFast());
584           else if ( nEntries != (Int_t)(fpTreeHLTESD->GetEntriesFast()) ) {
585             HLTError("Not all files contain the same number of events : %d and %ld", 
586                      nEntries, fpTreeHLTESD->GetEntriesFast());
587             iResult=-EFAULT;
588           }
589
590           // Setup AliESDEvent
591           if ( fpHLTESD ) delete fpHLTESD;
592           fpHLTESD = new AliESDEvent();     
593           fpHLTESD->ReadFromTree(fpTreeHLTESD); 
594
595         } // if ( fpTreeHLTESD ) {
596         else {
597           HLTError("Getting HLTESD tree failed for file %s.", pFile->GetName() );
598           iResult=-EFAULT;
599         }
600
601       } // if ( !filename.CompareTo("AliESDs.root") && fPublishHLTESD ){
602
603       // -- Open galice tree : TreeE
604       else if ( !filename.CompareTo("galice.root") && fPublishMC ) {
605         fpTreeE = dynamic_cast<TTree*>(pFile->Get("TE") );
606
607         if ( fpTreeE ) {
608           if ( nEntries == -1 ) 
609             nEntries = (Int_t)(fpTreeE->GetEntriesFast());
610           else if ( nEntries != (Int_t)(fpTreeE->GetEntriesFast()) ) {
611             HLTError("Not all files contain the same number of events : %d and %ld", 
612                      nEntries, fpTreeE->GetEntriesFast());
613             iResult=-EFAULT;
614           }
615         } // if ( fpTreeE ) {
616         else {
617           HLTError("Getting TreeE failed for file %s.", pFile->GetName() );
618           iResult=-EFAULT;
619         }
620       } // if ( !filename.CompareTo("galice.root") && fPublishMC ){
621
622       flnk = flnk->Next();
623       
624     } // while ( flnk && iResult>=0 ) {
625
626   } // if ( fpCurrentFileList && iResult >= 0 ) {
627   else {
628     HLTError("Current file list could not get created.");
629     iResult=-EFAULT;
630   }
631   
632   if ( iResult >= 0 )
633     fNEventsInFolder = (UInt_t)(nEntries);
634
635   return iResult;  
636 }
637
638 // #################################################################################
639 Int_t AliHLTESDMCEventPublisherComponent::CloseCurrentFileList() {
640   // see header file for class documentation
641
642   Int_t iResult = 0;
643
644   // -- Reset 
645   fCurrentEvent = 0;
646   fNEventsInFolder = 0;
647
648   // if not set, no files are open ...
649   if ( fpCurrentFileList ) {
650     
651     TObjLink *flnk = fpCurrentFileList->FirstLink();
652   
653     // -- Loop over all files in folder
654     while ( flnk && iResult>=0 ) {
655       FileDesc* pFileDesc = dynamic_cast<FileDesc*>( flnk->GetObject() );
656       
657       TFile* pFile = NULL;
658     
659       // If is opened, close it
660       if ( pFileDesc && ( pFile = *pFileDesc ) != NULL )
661         pFileDesc->CloseFile();
662       else {
663         HLTError("File already open, this should not happen.");
664         iResult=-EFAULT;
665       }
666       
667       if ( (pFile = *pFileDesc ) != NULL ) {
668         HLTError("Closing file %s failed.", pFile->GetName() );
669         iResult=-EFAULT;
670       }
671
672       flnk = flnk->Next();
673       
674     } // while ( flnk && iResult>=0 ) {
675
676     fpCurrentFileList = NULL;
677
678   } // if ( fpCurrentFileList && iResult >= 0 ) {
679   
680   return iResult;  
681 }