ROOT logo
// $Id$
// $MpId: testSectorPadIterators.C,v 1.11 2006/03/15 13:07:07 ivana Exp $
//
// Test macro for reading  sector, and iterate over it

#if !defined(__CINT__) || defined(__MAKECINT__)

#include "AliMpStation12Type.h"
#include "AliMpPlaneType.h"
#include "AliMpDataProcessor.h"
#include "AliMpDataMap.h"
#include "AliMpDataStreams.h"
#include "AliMpSector.h"
#include "AliMpSectorPadIterator.h"
#include "AliMpSectorReader.h"
#include "AliMpArea.h"
#include "AliMpVPadIterator.h"
#include "AliMpVPainter.h"
#include "AliMpEncodePair.h"

#include <Riostream.h>
#include <TCanvas.h>
#include <TMarker.h>

#endif

TCanvas* CreateTCanvas(const TString& name, const TString& title,
                       AliMq::Station12Type station, AliMp::PlaneType plane)
{
  TString newName(name);
  TString newTitle(title);
  TString unique = AliMq::Station12TypeName(station) + AliMp::PlaneTypeName(plane);
  newName += unique;
  newTitle += unique;
  return new TCanvas(newName.Data(), newTitle.Data());
}                     

void testSectorPadIterators(AliMq::Station12Type station, AliMp::PlaneType plane)
{
  AliMpDataProcessor mp;
  AliMpDataMap* dataMap = mp.CreateDataMap("data");
  AliMpDataStreams dataStreams(dataMap);

  AliMpSectorReader r(dataStreams, station, plane);
  AliMpSector* sector = r.BuildSector();
  
  Int_t num=0;
  
  //new TCanvas("canv");
  CreateTCanvas("", "", station, plane);

  const Double_t xmax=150;
  const Double_t ymax=250;

  AliMpSectorPadIterator it = AliMpSectorPadIterator(sector);

  for (it.First(); ! it.IsDone(); it.Next()) {
    Long_t indices = it.CurrentItem().GetIndices();
    cout<<"Iterator number "<< num << " at ";
    AliMp::PairPut(cout, indices) <<  endl;
    num++;
    TMarker* marker = new TMarker( (Double_t)AliMp::PairFirst(indices) /xmax,
                                   (Double_t)AliMp::PairSecond(indices)/ymax,
                                   2);
    marker->Draw();
  }
  
  delete sector;
}

void testSt12SectorPadIterators()
{
  AliMq::Station12Type  station[2] = { AliMq::kStation1, AliMq::kStation2 }; 
  AliMp::PlaneType      plane[2]   = { AliMp::kBendingPlane, AliMp::kNonBendingPlane };
  
  for ( Int_t is = 0; is < 2; is++ ) {
    for ( Int_t ip = 0; ip < 2; ip++ ) {
    
      cout << "Running testSectorPadIterators for " 
           << AliMq::Station12TypeName(station[is]) << "  "
           << AliMp::PlaneTypeName(plane[ip])  << " ... " << endl;
       
      testSectorPadIterators(station[is], plane[ip]);
    
      cout << "... end running " << endl << endl;
    }  
  }   
}  
  
 testSt12SectorPadIterators.C:1
 testSt12SectorPadIterators.C:2
 testSt12SectorPadIterators.C:3
 testSt12SectorPadIterators.C:4
 testSt12SectorPadIterators.C:5
 testSt12SectorPadIterators.C:6
 testSt12SectorPadIterators.C:7
 testSt12SectorPadIterators.C:8
 testSt12SectorPadIterators.C:9
 testSt12SectorPadIterators.C:10
 testSt12SectorPadIterators.C:11
 testSt12SectorPadIterators.C:12
 testSt12SectorPadIterators.C:13
 testSt12SectorPadIterators.C:14
 testSt12SectorPadIterators.C:15
 testSt12SectorPadIterators.C:16
 testSt12SectorPadIterators.C:17
 testSt12SectorPadIterators.C:18
 testSt12SectorPadIterators.C:19
 testSt12SectorPadIterators.C:20
 testSt12SectorPadIterators.C:21
 testSt12SectorPadIterators.C:22
 testSt12SectorPadIterators.C:23
 testSt12SectorPadIterators.C:24
 testSt12SectorPadIterators.C:25
 testSt12SectorPadIterators.C:26
 testSt12SectorPadIterators.C:27
 testSt12SectorPadIterators.C:28
 testSt12SectorPadIterators.C:29
 testSt12SectorPadIterators.C:30
 testSt12SectorPadIterators.C:31
 testSt12SectorPadIterators.C:32
 testSt12SectorPadIterators.C:33
 testSt12SectorPadIterators.C:34
 testSt12SectorPadIterators.C:35
 testSt12SectorPadIterators.C:36
 testSt12SectorPadIterators.C:37
 testSt12SectorPadIterators.C:38
 testSt12SectorPadIterators.C:39
 testSt12SectorPadIterators.C:40
 testSt12SectorPadIterators.C:41
 testSt12SectorPadIterators.C:42
 testSt12SectorPadIterators.C:43
 testSt12SectorPadIterators.C:44
 testSt12SectorPadIterators.C:45
 testSt12SectorPadIterators.C:46
 testSt12SectorPadIterators.C:47
 testSt12SectorPadIterators.C:48
 testSt12SectorPadIterators.C:49
 testSt12SectorPadIterators.C:50
 testSt12SectorPadIterators.C:51
 testSt12SectorPadIterators.C:52
 testSt12SectorPadIterators.C:53
 testSt12SectorPadIterators.C:54
 testSt12SectorPadIterators.C:55
 testSt12SectorPadIterators.C:56
 testSt12SectorPadIterators.C:57
 testSt12SectorPadIterators.C:58
 testSt12SectorPadIterators.C:59
 testSt12SectorPadIterators.C:60
 testSt12SectorPadIterators.C:61
 testSt12SectorPadIterators.C:62
 testSt12SectorPadIterators.C:63
 testSt12SectorPadIterators.C:64
 testSt12SectorPadIterators.C:65
 testSt12SectorPadIterators.C:66
 testSt12SectorPadIterators.C:67
 testSt12SectorPadIterators.C:68
 testSt12SectorPadIterators.C:69
 testSt12SectorPadIterators.C:70
 testSt12SectorPadIterators.C:71
 testSt12SectorPadIterators.C:72
 testSt12SectorPadIterators.C:73
 testSt12SectorPadIterators.C:74
 testSt12SectorPadIterators.C:75
 testSt12SectorPadIterators.C:76
 testSt12SectorPadIterators.C:77
 testSt12SectorPadIterators.C:78
 testSt12SectorPadIterators.C:79
 testSt12SectorPadIterators.C:80
 testSt12SectorPadIterators.C:81
 testSt12SectorPadIterators.C:82
 testSt12SectorPadIterators.C:83
 testSt12SectorPadIterators.C:84
 testSt12SectorPadIterators.C:85
 testSt12SectorPadIterators.C:86
 testSt12SectorPadIterators.C:87
 testSt12SectorPadIterators.C:88
 testSt12SectorPadIterators.C:89
 testSt12SectorPadIterators.C:90