Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

GetRawBlock.h

Go to the documentation of this file.
00001 
00021 #ifndef GETRAWBLOCK_H
00022 #define GETRAWBLOCK_H
00023 
00024 #include <TObject.h>
00025 #include "RawData/RawRecord.h"
00026 #include "RawData/RawDataBlock.h"
00027 #include "MinosObjectMap/MomNavigator.h"
00028 #include <vector>
00029 #include <iostream>
00030 
00031 namespace DataUtil {
00032 
00036 template<class BlockType>
00037 inline
00038 std::vector<const BlockType*> GetRawBlocks(const MomNavigator* mom)
00039 {
00040   std::vector<const BlockType*> result;
00041 
00042   if(!mom) return result;
00043 
00044   // Loop through all RawRecords in mom:
00045   TObject* tobj;
00046   TIter fragiter = mom->FragmentIter();
00047   while( ( tobj = fragiter.Next() ) ) {
00048     const RawRecord* rawrec = dynamic_cast<const RawRecord*>(tobj);
00049 
00050     if(rawrec) {
00051       // Loop through all blocks in record.
00052       TIter blockiter = rawrec->GetRawBlockIter();
00053       while( ( tobj = blockiter.Next() ) ) {
00054         const BlockType* myBlock = dynamic_cast<const BlockType*>(tobj);
00055         if(myBlock) result.push_back(myBlock);
00056       }
00057       
00058     }
00059   }
00060   return result;
00061 }
00062 
00063 template<class BlockType>
00064 inline
00065 const BlockType* GetRawBlock(const MomNavigator* mom)
00066 {
00067   std::vector<const BlockType*> v = GetRawBlocks<BlockType>(mom);
00068   if(v.size()>0) return v[0];
00069   else return NULL;
00070 }
00071 
00072 
00073 
00074 } // namespace DataUtil
00075 
00076 #endif  // GETRAWBLOCK_H

Generated on Mon Feb 15 11:06:46 2010 for loon by  doxygen 1.3.9.1