ROOT logo
/**************************************************************************
 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
 *                                                                        *
 * Author: The ALICE Off-line Project.                                    *
 * Contributors are mentioned in the code where appropriate.              *
 *                                                                        *
 * Permission to use, copy, modify and distribute this software and its   *
 * documentation strictly for non-commercial purposes is hereby granted   *
 * without fee, provided that the above copyright notice appears in all   *
 * copies and that both the copyright notice and this permission notice   *
 * appear in the supporting documentation. The authors make no claims     *
 * about the suitability of this software for any purpose. It is          *
 * provided "as is" without express or implied warranty.                  *
 **************************************************************************/

// $Id$
// $MpId: $

//
// Test macro for drawing slat motifs with real contours
// Christian Finck, Subatech
//
#if !defined(__CINT__) || defined(__MAKECINT__)

// MUON includes
#include "AliMpStationType.h"
#include "AliMpStation12Type.h"
#include "AliMpPlaneType.h"
#include "AliMpDataProcessor.h"
#include "AliMpDataMap.h"
#include "AliMpDataStreams.h"
#include "AliMpSt345Reader.h"
#include "AliMpPCB.h"
#include "AliMpSlat.h"
#include "AliMpVPainter.h"
#include "AliMpMotifReader.h"
#include "AliMpMotifType.h"
#include "AliMpMotifPosition.h"
#include "AliMpMotif.h"
#include "AliMpSlatMotifMap.h"
#include "AliMpDataStreams.h"

#include "TVector2.h"
#include "TCanvas.h"

#endif

void testGraphicsMotif(Option_t* motifType = "R43", Double_t padsizex=5.0, Double_t padsizey=0.5)
{
  // Warning : this function leaks memory. But should be fine as only used 
  // interactively to check a few motifs at once...
  //
  AliMpDataProcessor mp;
  AliMpDataMap* dataMap = mp.CreateDataMap("data");
  AliMpDataStreams dataStreams(dataMap);

  AliMp::StationType station = AliMp::kStation345;
  AliMq::Station12Type station12 = AliMq::kNotSt12;
  AliMp::PlaneType plane = AliMp::kBendingPlane;
  
  AliMpMotifReader reader(dataStreams, station, station12, plane);
  AliMpMotifType* type = reader.BuildMotifType(motifType);
  if (!type)
  {
    cerr << "Motif not found" << endl;
    return;
  }
  type->Print("G");
  AliMpMotif* motif = new AliMpMotif(motifType,type,padsizex,padsizey);
  AliMpMotifPosition* pos = new AliMpMotifPosition(0,motif,0,0);
  AliMpVPainter* painter = AliMpVPainter::CreatePainter(pos);
  if (!painter)
  {
    cerr << "Could not get a painter !" << endl;
    return;
  }
  new TCanvas(motifType,motifType);
  painter->Draw("PT");
}

//112230N
//112233NR3
//220000N
//122000NR1
//112200NR2
void testGraphicsSlat(AliMp::PlaneType planeType = AliMp::kBendingPlane, 
	              Option_t* option = "PMCI",
		      Bool_t saveJPG = false)
{
  // P plane
  // M motif
  // P pad
  // I indices

  AliMpDataProcessor mp;
  AliMpDataMap* dataMap = mp.CreateDataMap("data");
  AliMpDataStreams dataStreams(dataMap);

  AliMpSlatMotifMap* motifMap = new AliMpSlatMotifMap();
  AliMpSt345Reader* reader = new AliMpSt345Reader(dataStreams, motifMap);

  // PMPT to get manu channels numbering
  
  Char_t *slatName[19] = {"122000SR1", "112200SR2", "122200S", "222000N", "220000N",
			  "122000NR1", "112200NR2", "122200N",
			  "122330N", "112233NR3", "112230N", "222330N", "223300N", "333000N", "330000N",
			  "112233N", "222333N", "223330N", "333300N"};
			  
  TCanvas *c1[19];
  Char_t c1Name[255];
  Char_t c1NameJpg[255];
  
  for (Int_t i = 0; i < 19; i++) {
    sprintf(c1Name, "%s%d", "c1", i);
    c1[i]= new TCanvas(c1Name,slatName[i],10,10,1200,800);     

    Char_t* slatType = slatName[i];

    AliMpSlat* slat = reader->ReadSlat(slatType, planeType);
    AliMpVPainter* painter = AliMpVPainter::CreatePainter(slat);
    painter->Draw(option);
  
    if (planeType == AliMp::kNonBendingPlane)
      sprintf(c1NameJpg, "%s%s", slatName[i], "_NonBending.jpg");
    else 
      sprintf(c1NameJpg, "%s%s", slatName[i], "_Bending.jpg");
    
    if (saveJPG) c1[i]->Print(c1NameJpg);
  }
}

void testGraphicsPCB(const char* pcbName="S2B",
                      Option_t* option = "MZT",
                      Bool_t savePNG = false)
{
  
  TCanvas* c = new TCanvas(pcbName,pcbName,10,10,1200,800);     
    
  AliMpDataProcessor mp;
  AliMpDataMap* dataMap = mp.CreateDataMap("data");
  AliMpDataStreams dataStreams(dataMap);

  AliMpSlatMotifMap* motifMap = new AliMpSlatMotifMap();
  AliMpSt345Reader* reader = new AliMpSt345Reader(dataStreams, motifMap);
  AliMpPCB* pcb = reader->ReadPCB(pcbName);
  if (!pcb) 
  {
    cerr << "PCB " << pcbName << " does not exist" << endl;
    return;
  }
  
  AliMpVPainter* painter = AliMpVPainter::CreatePainter(pcb);
  painter->Draw(option);
    
  if (savePNG) c->Print(Form("%s-%s.png",pcbName,option));
  
}
 testGraphicsSlat.C:1
 testGraphicsSlat.C:2
 testGraphicsSlat.C:3
 testGraphicsSlat.C:4
 testGraphicsSlat.C:5
 testGraphicsSlat.C:6
 testGraphicsSlat.C:7
 testGraphicsSlat.C:8
 testGraphicsSlat.C:9
 testGraphicsSlat.C:10
 testGraphicsSlat.C:11
 testGraphicsSlat.C:12
 testGraphicsSlat.C:13
 testGraphicsSlat.C:14
 testGraphicsSlat.C:15
 testGraphicsSlat.C:16
 testGraphicsSlat.C:17
 testGraphicsSlat.C:18
 testGraphicsSlat.C:19
 testGraphicsSlat.C:20
 testGraphicsSlat.C:21
 testGraphicsSlat.C:22
 testGraphicsSlat.C:23
 testGraphicsSlat.C:24
 testGraphicsSlat.C:25
 testGraphicsSlat.C:26
 testGraphicsSlat.C:27
 testGraphicsSlat.C:28
 testGraphicsSlat.C:29
 testGraphicsSlat.C:30
 testGraphicsSlat.C:31
 testGraphicsSlat.C:32
 testGraphicsSlat.C:33
 testGraphicsSlat.C:34
 testGraphicsSlat.C:35
 testGraphicsSlat.C:36
 testGraphicsSlat.C:37
 testGraphicsSlat.C:38
 testGraphicsSlat.C:39
 testGraphicsSlat.C:40
 testGraphicsSlat.C:41
 testGraphicsSlat.C:42
 testGraphicsSlat.C:43
 testGraphicsSlat.C:44
 testGraphicsSlat.C:45
 testGraphicsSlat.C:46
 testGraphicsSlat.C:47
 testGraphicsSlat.C:48
 testGraphicsSlat.C:49
 testGraphicsSlat.C:50
 testGraphicsSlat.C:51
 testGraphicsSlat.C:52
 testGraphicsSlat.C:53
 testGraphicsSlat.C:54
 testGraphicsSlat.C:55
 testGraphicsSlat.C:56
 testGraphicsSlat.C:57
 testGraphicsSlat.C:58
 testGraphicsSlat.C:59
 testGraphicsSlat.C:60
 testGraphicsSlat.C:61
 testGraphicsSlat.C:62
 testGraphicsSlat.C:63
 testGraphicsSlat.C:64
 testGraphicsSlat.C:65
 testGraphicsSlat.C:66
 testGraphicsSlat.C:67
 testGraphicsSlat.C:68
 testGraphicsSlat.C:69
 testGraphicsSlat.C:70
 testGraphicsSlat.C:71
 testGraphicsSlat.C:72
 testGraphicsSlat.C:73
 testGraphicsSlat.C:74
 testGraphicsSlat.C:75
 testGraphicsSlat.C:76
 testGraphicsSlat.C:77
 testGraphicsSlat.C:78
 testGraphicsSlat.C:79
 testGraphicsSlat.C:80
 testGraphicsSlat.C:81
 testGraphicsSlat.C:82
 testGraphicsSlat.C:83
 testGraphicsSlat.C:84
 testGraphicsSlat.C:85
 testGraphicsSlat.C:86
 testGraphicsSlat.C:87
 testGraphicsSlat.C:88
 testGraphicsSlat.C:89
 testGraphicsSlat.C:90
 testGraphicsSlat.C:91
 testGraphicsSlat.C:92
 testGraphicsSlat.C:93
 testGraphicsSlat.C:94
 testGraphicsSlat.C:95
 testGraphicsSlat.C:96
 testGraphicsSlat.C:97
 testGraphicsSlat.C:98
 testGraphicsSlat.C:99
 testGraphicsSlat.C:100
 testGraphicsSlat.C:101
 testGraphicsSlat.C:102
 testGraphicsSlat.C:103
 testGraphicsSlat.C:104
 testGraphicsSlat.C:105
 testGraphicsSlat.C:106
 testGraphicsSlat.C:107
 testGraphicsSlat.C:108
 testGraphicsSlat.C:109
 testGraphicsSlat.C:110
 testGraphicsSlat.C:111
 testGraphicsSlat.C:112
 testGraphicsSlat.C:113
 testGraphicsSlat.C:114
 testGraphicsSlat.C:115
 testGraphicsSlat.C:116
 testGraphicsSlat.C:117
 testGraphicsSlat.C:118
 testGraphicsSlat.C:119
 testGraphicsSlat.C:120
 testGraphicsSlat.C:121
 testGraphicsSlat.C:122
 testGraphicsSlat.C:123
 testGraphicsSlat.C:124
 testGraphicsSlat.C:125
 testGraphicsSlat.C:126
 testGraphicsSlat.C:127
 testGraphicsSlat.C:128
 testGraphicsSlat.C:129
 testGraphicsSlat.C:130
 testGraphicsSlat.C:131
 testGraphicsSlat.C:132
 testGraphicsSlat.C:133
 testGraphicsSlat.C:134
 testGraphicsSlat.C:135
 testGraphicsSlat.C:136
 testGraphicsSlat.C:137
 testGraphicsSlat.C:138
 testGraphicsSlat.C:139
 testGraphicsSlat.C:140
 testGraphicsSlat.C:141
 testGraphicsSlat.C:142
 testGraphicsSlat.C:143
 testGraphicsSlat.C:144
 testGraphicsSlat.C:145
 testGraphicsSlat.C:146
 testGraphicsSlat.C:147
 testGraphicsSlat.C:148
 testGraphicsSlat.C:149
 testGraphicsSlat.C:150
 testGraphicsSlat.C:151
 testGraphicsSlat.C:152
 testGraphicsSlat.C:153
 testGraphicsSlat.C:154
 testGraphicsSlat.C:155
 testGraphicsSlat.C:156
 testGraphicsSlat.C:157
 testGraphicsSlat.C:158