ROOT logo
//____________________________________________________________________
//
// $Id$
//
// Test I/O of ALiFMDMap
//
/** @defgroup MAPIO_TEST Map I/O test
    @ingroup FMD_script 
*/
//____________________________________________________________________
/** @ingroup MAPIO_test
 */
void 
WriteTree()
{
  TFile* file = TFile::Open("map.root", "RECREATE");
  TTree* tree = new TTree("T", "T");
  AliFMDFloatMap* m = new AliFMDFloatMap(1, 1, 1, 3);
  tree->Branch("map", "AliFMDFloatMap", &m);
  for (int i = 0; i < 3; i++) m->operator()(1,'I',0,i) = i + 1;
  tree->Fill();
  file->Write();
  file->Close();
}

//____________________________________________________________________
/** @ingroup MAPIO_test
 */
void 
ReadTree()
{
  TFile* file = TFile::Open("map.root", "READ");
  TTree* tree = static_cast<TTree*>(file->Get("T"));
  AliFMDFloatMap* m = 0;
  tree->SetBranchAddress("map", &m);
  tree->GetEntry(0);
  for (int i = 0; i < 3; i++) {
    std::cout << "Map(1,'I',0," << i << "): " << m->operator()(1,'I',0,i)
	      << std::endl;
  }
  file->Close();
}

  
//____________________________________________________________________
/** @ingroup MAPIO_test
 */
void
WriteMap() 
{
  TFile* file = TFile::Open("map.root", "RECREATE");
  AliFMDFloatMap* m = new AliFMDFloatMap(1, 1, 1, 3);
  for (int i = 0; i < 3; i++) m->operator()(1,'I',0,i) = i + 1;
  m.Write("map");
  file->Close();
}

//____________________________________________________________________
/** @ingroup MAPIO_test
    @return  */
void
ReadMap() 
{
  TFile* file = TFile::Open("map.root", "READ");
  AliFMDFloatMap* m = static_cast<AliFMDFloatMap*>(file->Get("map"));
  std::cout << "Got map " << map << std::endl;
  for (int i = 0; i < 3; i++) {
    std::cout << "Map(1,'I',0," << i << "): " << m->operator()(1,'I',0,i)
	      << std::endl;
  }
  file->Close();
}


//____________________________________________________________________
/** @ingroup MAPIO_test
 */
void
TestMapIO()
{
  WriteMap();
  ReadMap();
  WriteTree();
  ReadTree();
}

//____________________________________________________________________
//
// EOF
//
 TestMapIO.C:1
 TestMapIO.C:2
 TestMapIO.C:3
 TestMapIO.C:4
 TestMapIO.C:5
 TestMapIO.C:6
 TestMapIO.C:7
 TestMapIO.C:8
 TestMapIO.C:9
 TestMapIO.C:10
 TestMapIO.C:11
 TestMapIO.C:12
 TestMapIO.C:13
 TestMapIO.C:14
 TestMapIO.C:15
 TestMapIO.C:16
 TestMapIO.C:17
 TestMapIO.C:18
 TestMapIO.C:19
 TestMapIO.C:20
 TestMapIO.C:21
 TestMapIO.C:22
 TestMapIO.C:23
 TestMapIO.C:24
 TestMapIO.C:25
 TestMapIO.C:26
 TestMapIO.C:27
 TestMapIO.C:28
 TestMapIO.C:29
 TestMapIO.C:30
 TestMapIO.C:31
 TestMapIO.C:32
 TestMapIO.C:33
 TestMapIO.C:34
 TestMapIO.C:35
 TestMapIO.C:36
 TestMapIO.C:37
 TestMapIO.C:38
 TestMapIO.C:39
 TestMapIO.C:40
 TestMapIO.C:41
 TestMapIO.C:42
 TestMapIO.C:43
 TestMapIO.C:44
 TestMapIO.C:45
 TestMapIO.C:46
 TestMapIO.C:47
 TestMapIO.C:48
 TestMapIO.C:49
 TestMapIO.C:50
 TestMapIO.C:51
 TestMapIO.C:52
 TestMapIO.C:53
 TestMapIO.C:54
 TestMapIO.C:55
 TestMapIO.C:56
 TestMapIO.C:57
 TestMapIO.C:58
 TestMapIO.C:59
 TestMapIO.C:60
 TestMapIO.C:61
 TestMapIO.C:62
 TestMapIO.C:63
 TestMapIO.C:64
 TestMapIO.C:65
 TestMapIO.C:66
 TestMapIO.C:67
 TestMapIO.C:68
 TestMapIO.C:69
 TestMapIO.C:70
 TestMapIO.C:71
 TestMapIO.C:72
 TestMapIO.C:73
 TestMapIO.C:74
 TestMapIO.C:75
 TestMapIO.C:76
 TestMapIO.C:77
 TestMapIO.C:78
 TestMapIO.C:79
 TestMapIO.C:80
 TestMapIO.C:81
 TestMapIO.C:82
 TestMapIO.C:83
 TestMapIO.C:84
 TestMapIO.C:85
 TestMapIO.C:86
 TestMapIO.C:87
 TestMapIO.C:88
 TestMapIO.C:89
 TestMapIO.C:90
 TestMapIO.C:91