ROOT logo
// $Id$
// $MpId: testGraphics.C,v 1.13 2005/10/28 15:36:08 ivana Exp $
//
// Test macro for drawing sector data.

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

#include "AliMpStation12Type.h"
#include "AliMpPlaneType.h"
#include "AliMpDataProcessor.h"
#include "AliMpDataMap.h"
#include "AliMpDataStreams.h"
#include "AliMpSector.h"
#include "AliMpSectorReader.h"
#include "AliMpRow.h"
#include "AliMpVRowSegment.h"
#include "AliMpMotifMap.h"
#include "AliMpMotifPosition.h"
#include "AliMpVPainter.h"

#include <Riostream.h>
#include <TCanvas.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 testGraphics(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();
    
  AliMpVPainter* painter = AliMpVPainter::CreatePainter(sector);

  TCanvas* canvas  = new TCanvas();
  TCanvas* canvas2 = new TCanvas();
  TCanvas* c[4];
  for (int i=0;i<4;++i) {
    c[i] = new TCanvas();
    c[i]->Divide(2,2);
  }  

  //first, paint the whole sector
  canvas->cd();
  painter->Draw("");
  //now paint each rows
  c[0]->cd(1);
  painter->Draw("R");
  //paint each row segments in each row
  c[0]->cd(2);
  painter->Draw("RS");
  //paint each motifs, in each row segments in each row
  c[0]->cd(3);
  painter->Draw("RSMP");
  //paint each pads, in each motifs, in each row segments in each row
  c[0]->cd(4);
  painter->Draw("RSMT");

  ///////////////////////////////
  //now paint each rows, wwith its name
  c[1]->cd(1);
  painter->Draw("RT");
  //paint each row segments in each row, and its name
  c[1]->cd(2);
  painter->Draw("RST");
  //paint each motifs, in each row segments in each row
  c[1]->cd(3);
  painter->Draw("RSMX");
  c[1]->cd(4);
  painter->Draw("RSMI");

  ///////////////////////////////
  //now paint each zones
  c[2]->cd(1);
  painter->Draw("Z");
  //paint each sub-zones, in each zones
  c[2]->cd(2);
  painter->Draw("ZS");
  //paint each row segments, in each sub-zone, ...
  c[2]->cd(3);
  painter->Draw("ZSS");
  // each motifs, in each row segments, ...
  c[2]->cd(4);
  painter->Draw("ZSSM");

  ///////////////////////////////
  //now paint each zones with its name
  c[3]->cd(1);
  painter->Draw("ZT");
  //paint each sub-zones, in each zones with its name
  c[3]->cd(2);
  painter->Draw("ZST");
  //paint each row segments, in each sub-zone, ... with its name
  c[3]->cd(3);
  painter->Draw("ZSST");
  // each motifs, in each row segments, ... with its name
  c[3]->cd(4);
  painter->Draw("ZSSMT");

  // now, draw a specific motif, in a whole canvas, and
  // print all its pad names
  Int_t id = sector->GetRow(5)->GetRowSegment(0)->GetMotifPositionId(0);
  AliMpMotifPosition* motifPos = sector->GetMotifMap()->FindMotifPosition(id);
  AliMpVPainter* motifPainter = AliMpVPainter::CreatePainter(motifPos);
  CreateTCanvas("onepad ","One motif ", station, plane);
  motifPainter->Draw("PT");
  
  //////////////////////////////  
  //now paint motifs with their real contours and mani Ids
  canvas2->cd();
  painter->Draw("RSMCI");
}

void testSt12Graphics()
{
  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 testGraphics for " 
           << AliMq::Station12TypeName(station[is]) << "  "
           << AliMp::PlaneTypeName(plane[ip])  << " ... " << endl;
       
      testGraphics(station[is], plane[ip]);
    
      cout << "... end running " << endl << endl;
    }  
  }   
}  
  
 testSt12Graphics.C:1
 testSt12Graphics.C:2
 testSt12Graphics.C:3
 testSt12Graphics.C:4
 testSt12Graphics.C:5
 testSt12Graphics.C:6
 testSt12Graphics.C:7
 testSt12Graphics.C:8
 testSt12Graphics.C:9
 testSt12Graphics.C:10
 testSt12Graphics.C:11
 testSt12Graphics.C:12
 testSt12Graphics.C:13
 testSt12Graphics.C:14
 testSt12Graphics.C:15
 testSt12Graphics.C:16
 testSt12Graphics.C:17
 testSt12Graphics.C:18
 testSt12Graphics.C:19
 testSt12Graphics.C:20
 testSt12Graphics.C:21
 testSt12Graphics.C:22
 testSt12Graphics.C:23
 testSt12Graphics.C:24
 testSt12Graphics.C:25
 testSt12Graphics.C:26
 testSt12Graphics.C:27
 testSt12Graphics.C:28
 testSt12Graphics.C:29
 testSt12Graphics.C:30
 testSt12Graphics.C:31
 testSt12Graphics.C:32
 testSt12Graphics.C:33
 testSt12Graphics.C:34
 testSt12Graphics.C:35
 testSt12Graphics.C:36
 testSt12Graphics.C:37
 testSt12Graphics.C:38
 testSt12Graphics.C:39
 testSt12Graphics.C:40
 testSt12Graphics.C:41
 testSt12Graphics.C:42
 testSt12Graphics.C:43
 testSt12Graphics.C:44
 testSt12Graphics.C:45
 testSt12Graphics.C:46
 testSt12Graphics.C:47
 testSt12Graphics.C:48
 testSt12Graphics.C:49
 testSt12Graphics.C:50
 testSt12Graphics.C:51
 testSt12Graphics.C:52
 testSt12Graphics.C:53
 testSt12Graphics.C:54
 testSt12Graphics.C:55
 testSt12Graphics.C:56
 testSt12Graphics.C:57
 testSt12Graphics.C:58
 testSt12Graphics.C:59
 testSt12Graphics.C:60
 testSt12Graphics.C:61
 testSt12Graphics.C:62
 testSt12Graphics.C:63
 testSt12Graphics.C:64
 testSt12Graphics.C:65
 testSt12Graphics.C:66
 testSt12Graphics.C:67
 testSt12Graphics.C:68
 testSt12Graphics.C:69
 testSt12Graphics.C:70
 testSt12Graphics.C:71
 testSt12Graphics.C:72
 testSt12Graphics.C:73
 testSt12Graphics.C:74
 testSt12Graphics.C:75
 testSt12Graphics.C:76
 testSt12Graphics.C:77
 testSt12Graphics.C:78
 testSt12Graphics.C:79
 testSt12Graphics.C:80
 testSt12Graphics.C:81
 testSt12Graphics.C:82
 testSt12Graphics.C:83
 testSt12Graphics.C:84
 testSt12Graphics.C:85
 testSt12Graphics.C:86
 testSt12Graphics.C:87
 testSt12Graphics.C:88
 testSt12Graphics.C:89
 testSt12Graphics.C:90
 testSt12Graphics.C:91
 testSt12Graphics.C:92
 testSt12Graphics.C:93
 testSt12Graphics.C:94
 testSt12Graphics.C:95
 testSt12Graphics.C:96
 testSt12Graphics.C:97
 testSt12Graphics.C:98
 testSt12Graphics.C:99
 testSt12Graphics.C:100
 testSt12Graphics.C:101
 testSt12Graphics.C:102
 testSt12Graphics.C:103
 testSt12Graphics.C:104
 testSt12Graphics.C:105
 testSt12Graphics.C:106
 testSt12Graphics.C:107
 testSt12Graphics.C:108
 testSt12Graphics.C:109
 testSt12Graphics.C:110
 testSt12Graphics.C:111
 testSt12Graphics.C:112
 testSt12Graphics.C:113
 testSt12Graphics.C:114
 testSt12Graphics.C:115
 testSt12Graphics.C:116
 testSt12Graphics.C:117
 testSt12Graphics.C:118
 testSt12Graphics.C:119
 testSt12Graphics.C:120
 testSt12Graphics.C:121
 testSt12Graphics.C:122
 testSt12Graphics.C:123
 testSt12Graphics.C:124
 testSt12Graphics.C:125
 testSt12Graphics.C:126
 testSt12Graphics.C:127
 testSt12Graphics.C:128
 testSt12Graphics.C:129
 testSt12Graphics.C:130
 testSt12Graphics.C:131
 testSt12Graphics.C:132
 testSt12Graphics.C:133
 testSt12Graphics.C:134
 testSt12Graphics.C:135
 testSt12Graphics.C:136
 testSt12Graphics.C:137
 testSt12Graphics.C:138
 testSt12Graphics.C:139
 testSt12Graphics.C:140
 testSt12Graphics.C:141
 testSt12Graphics.C:142
 testSt12Graphics.C:143
 testSt12Graphics.C:144
 testSt12Graphics.C:145
 testSt12Graphics.C:146