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

DigiList.h

Go to the documentation of this file.
00001 
00002 // $Id: DigiList.h,v 1.3 2003/05/22 13:14:38 tagg Exp $
00003 //
00004 // A list for storing digitization objects
00005 //
00006 // messier@indiana.edu
00008 #ifndef DIGILIST_H
00009 #define DIGILIST_H
00010 #include <vector>
00011 #include "TObjArray.h"
00012 
00013 template <class T>
00014 class DigiList : public std::vector<T> 
00015 { 
00016 public:
00017   DigiList()                   : std::vector<T>()   { this->reserve(4096);}
00018   DigiList(int n)              : std::vector<T>(n)  { }
00019   DigiList(const DigiList& dl) : std::vector<T>(dl) { }
00020   virtual ~DigiList()                               { }
00021   
00022   //....................................................................
00023 
00024   DigiList(const TObjArray& o) {
00025     // Construct list from a TObject array
00026     register int j     = 0;
00027     register int i     = o.LowerBound();
00028     register int iLast = o.GetLast();
00029     this->reserve(o.GetEntries());
00030     for (; i<=iLast; ++i, ++j) {
00031       this->push_back(*dynamic_cast<T*>(o.At(i)));
00032     }
00033   }
00034 
00035   //....................................................................
00036   
00037   TObjArray* CreateObjArray(const char* name) const {
00038     unsigned int sz = this->size();
00039     TObjArray* o = new TObjArray(sz); // "Create": caller takes ownership
00040     o->SetName(name);
00041     for (register unsigned int i=0; i<sz; ++i) o->AddAt(new T((*this)[i]),i);    
00042     o->SetOwner(true);
00043     return o;
00044   }
00045 
00046 private:
00047 };
00048 
00049 #endif
00050 

Generated on Thu Nov 1 11:50:24 2007 for loon by  doxygen 1.3.9.1