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

testDigiList.cc

Go to the documentation of this file.
00001 
00002 // $Id: testDigiList.cc,v 1.2 2003/04/15 15:51:10 tagg Exp $
00003 //
00004 // Test the DigiList container class
00005 //
00006 // messier@indiana.edu
00008 #include <iostream>
00009 #include "TFile.h"
00010 #include "Digitization/DigiList.h"
00011 #include "Digitization/test/DigiObject.h"
00012 #include "MinosObjectMap/MomNavigator.h"
00013 
00014 //......................................................................
00015 
00016 int main(void) 
00017 {
00018   int nerr = 0;
00019   
00020   // Test simple creation and manipulation
00021   DigiList<DigiObject> digiList;
00022   for (int i=10; i<20; ++i) {
00023     DigiObject rc(i);
00024     digiList.push_back(rc);
00025   }
00026   DigiList<DigiObject>::iterator itr(digiList.begin());
00027   DigiList<DigiObject>::iterator itrEnd(digiList.end());
00028   for (; itr!=itrEnd; ++itr) {
00029     std::cerr << itr->fNumber[0] << std::endl;
00030   }
00031 
00032   // Test putting into and getting out of MomNavigator
00033   MomNavigator mom;
00034   mom.AdoptFragment(digiList.CreateObjArray("DigiListObjA"));
00035 
00036   for (int i=0; mom.At(i); ++i) {
00037     std::cerr << mom.At(i)->GetName() << 
00038       std::endl;
00039   }
00040   
00041   TObjArray* objaIn = (TObjArray*)mom.GetFragment(0,"DigiListObjA");
00042   if (objaIn == 0) {
00043     std::cerr << "Bloody Murder!\n";
00044     ++nerr;
00045   }
00046   else {
00047     std::cerr << "Read OK.\n";
00048   }
00049   
00050   // Confirm that input and output lists match...
00051   DigiList<DigiObject> digiListIn(*objaIn);
00052 
00053   std::cerr << "Items in = " << digiList.size() 
00054             << "  Items out = " << digiListIn.size() << std::endl;
00055 
00056   itr    = digiList.begin();
00057   itrEnd = digiList.end();
00058   DigiList<DigiObject>::iterator itrIn(digiListIn.begin());
00059   DigiList<DigiObject>::iterator itrInEnd(digiListIn.end());
00060   for (; itr!=itrEnd && itrIn!=itrInEnd; ++itr, ++itrIn) {
00061     if (itr->fNumber[0] != itrIn->fNumber[0]) {
00062       std::cerr << 
00063         "Input and output do not match! " <<
00064         itr->fNumber[0] << "!=" << itrIn->fNumber[0] << std::endl;
00065       ++nerr;
00066     }
00067   }
00068 
00069   return nerr;
00070 }
00071 
00073 

Generated on Mon Feb 15 11:07:41 2010 for loon by  doxygen 1.3.9.1