ROOT logo
// $Id$
// $MpId: testReadSector.C,v 1.16 2006/01/11 10:00:50 ivana Exp $
//
// Test macro for reading 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 "AliMpVMotif.h"
#include "AliMpMotifMap.h"
#include "AliMpConstants.h"

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

#endif

void testReadSector(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();
  // Sector geometry
  sector->PrintGeometry();

  cout << endl;

  // Find row test
/*
  if (plane == AliMp::kBendingPlane)
    cout << "0th row low border " << sector->FindRow(TVector2(0., 0.))->GetID() << endl;
  if (plane == AliMp::kNonBendingPlane)
    cout << "0th row low border " << sector->FindRow(TVector2(0., 0.215))->GetID() << endl;
  cout << "in 0th row         " << sector->FindRow(TVector2(0., 2.5))->GetID() << endl;
  cout << "0th row up border  " << sector->FindRow(TVector2(0., 6.72))->GetID() << endl;
  cout << "in 4th row         " << sector->FindRow(TVector2(0., 30.))->GetID() << endl;
  if (plane == AliMp::kBendingPlane)
    cout << "12th row up border " << sector->FindRow(TVector2(0., 89.46))->GetID() << endl;
  if (plane == AliMp::kNonBendingPlane)
    cout << "12th row up border " << sector->FindRow(TVector2(0., 84.84))->GetID() << endl;
  cout << endl;
*/ 
 
  // Find motif position test
/*  
  Int_t ids[15] = { 19, 14, 9, 32, 36, 136, 187, 212, 207, 220, 1, 131, 239, 243, 250 };  
  for (Int_t i=0; i<15 ; i++) {
    Int_t id = ids[i];
    id |= AliMpConstants::ManuMask(plane);
    cout << "Motif pos " << std::setw(3) << id;
    if (!sector->FindRowSegment(id)) {
       cout << " not found." << endl;
    }
    else {	 
       cout << " found in : "
            << sector->FindRow(id)->GetID() << " row, "
            << " motif id: "
            << sector->FindRowSegment(id)->GetMotif(0)->GetID().Data()
	    << endl;
    }      
  }
  cout << endl;
*/
  // Find motif by coordinates test
/*
  for (Int_t i=0; i<2 ; i++) {
    TVector2 pos(0.5, 18.6 - i*2.);  // i=0 in motif 1001,
                                     // i=1 outside (below) motif 1001
    AliMpVMotif* motif = sector->FindMotif(pos);
    cout << "In the position " << pos.X() << " " << pos.Y();
    
    if (motif)
      cout << " found motif " << motif->GetID() << endl;
    else  
      cout << " motif not found " << endl;
  }
*/
  // Find special motif test
/*
  if (plane == AliMp::kNonBendingPlane) {
  
    Int_t ids[6] = { 20, 46, 47, 74, 75, 76 };
    for (Int_t i=0; i<6 ; i++) {
      
      Int_t id = ids[i];
      cout << "Motif pos " << id;
      if (!sector->FindRowSegment(id)) {
         cout << " not found." << endl;
      }
      else {	 
         cout << " found in : "
              << sector->FindRow(id)->GetID() << " row, "
	      << " position : "
	      << sector->FindPosition(id).X() << "  " <<  sector->FindPosition(id).Y()
	      << endl;
      }
    }
  }             
  cout << endl;
*/
  // Motif map
  sector->GetMotifMap()->Print();    
  
  delete sector;
}			       
     
void testSt12ReadSector()
{
  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 testReadSector for " 
           << AliMq::Station12TypeName(station[is]) << "  "
           << AliMp::PlaneTypeName(plane[ip])  << " ... " << endl;
       
      testReadSector(station[is], plane[ip]);
    
      cout << "... end running " << endl << endl;
    }  
  }   
}  
  
 
 testSt12ReadSector.C:1
 testSt12ReadSector.C:2
 testSt12ReadSector.C:3
 testSt12ReadSector.C:4
 testSt12ReadSector.C:5
 testSt12ReadSector.C:6
 testSt12ReadSector.C:7
 testSt12ReadSector.C:8
 testSt12ReadSector.C:9
 testSt12ReadSector.C:10
 testSt12ReadSector.C:11
 testSt12ReadSector.C:12
 testSt12ReadSector.C:13
 testSt12ReadSector.C:14
 testSt12ReadSector.C:15
 testSt12ReadSector.C:16
 testSt12ReadSector.C:17
 testSt12ReadSector.C:18
 testSt12ReadSector.C:19
 testSt12ReadSector.C:20
 testSt12ReadSector.C:21
 testSt12ReadSector.C:22
 testSt12ReadSector.C:23
 testSt12ReadSector.C:24
 testSt12ReadSector.C:25
 testSt12ReadSector.C:26
 testSt12ReadSector.C:27
 testSt12ReadSector.C:28
 testSt12ReadSector.C:29
 testSt12ReadSector.C:30
 testSt12ReadSector.C:31
 testSt12ReadSector.C:32
 testSt12ReadSector.C:33
 testSt12ReadSector.C:34
 testSt12ReadSector.C:35
 testSt12ReadSector.C:36
 testSt12ReadSector.C:37
 testSt12ReadSector.C:38
 testSt12ReadSector.C:39
 testSt12ReadSector.C:40
 testSt12ReadSector.C:41
 testSt12ReadSector.C:42
 testSt12ReadSector.C:43
 testSt12ReadSector.C:44
 testSt12ReadSector.C:45
 testSt12ReadSector.C:46
 testSt12ReadSector.C:47
 testSt12ReadSector.C:48
 testSt12ReadSector.C:49
 testSt12ReadSector.C:50
 testSt12ReadSector.C:51
 testSt12ReadSector.C:52
 testSt12ReadSector.C:53
 testSt12ReadSector.C:54
 testSt12ReadSector.C:55
 testSt12ReadSector.C:56
 testSt12ReadSector.C:57
 testSt12ReadSector.C:58
 testSt12ReadSector.C:59
 testSt12ReadSector.C:60
 testSt12ReadSector.C:61
 testSt12ReadSector.C:62
 testSt12ReadSector.C:63
 testSt12ReadSector.C:64
 testSt12ReadSector.C:65
 testSt12ReadSector.C:66
 testSt12ReadSector.C:67
 testSt12ReadSector.C:68
 testSt12ReadSector.C:69
 testSt12ReadSector.C:70
 testSt12ReadSector.C:71
 testSt12ReadSector.C:72
 testSt12ReadSector.C:73
 testSt12ReadSector.C:74
 testSt12ReadSector.C:75
 testSt12ReadSector.C:76
 testSt12ReadSector.C:77
 testSt12ReadSector.C:78
 testSt12ReadSector.C:79
 testSt12ReadSector.C:80
 testSt12ReadSector.C:81
 testSt12ReadSector.C:82
 testSt12ReadSector.C:83
 testSt12ReadSector.C:84
 testSt12ReadSector.C:85
 testSt12ReadSector.C:86
 testSt12ReadSector.C:87
 testSt12ReadSector.C:88
 testSt12ReadSector.C:89
 testSt12ReadSector.C:90
 testSt12ReadSector.C:91
 testSt12ReadSector.C:92
 testSt12ReadSector.C:93
 testSt12ReadSector.C:94
 testSt12ReadSector.C:95
 testSt12ReadSector.C:96
 testSt12ReadSector.C:97
 testSt12ReadSector.C:98
 testSt12ReadSector.C:99
 testSt12ReadSector.C:100
 testSt12ReadSector.C:101
 testSt12ReadSector.C:102
 testSt12ReadSector.C:103
 testSt12ReadSector.C:104
 testSt12ReadSector.C:105
 testSt12ReadSector.C:106
 testSt12ReadSector.C:107
 testSt12ReadSector.C:108
 testSt12ReadSector.C:109
 testSt12ReadSector.C:110
 testSt12ReadSector.C:111
 testSt12ReadSector.C:112
 testSt12ReadSector.C:113
 testSt12ReadSector.C:114
 testSt12ReadSector.C:115
 testSt12ReadSector.C:116
 testSt12ReadSector.C:117
 testSt12ReadSector.C:118
 testSt12ReadSector.C:119
 testSt12ReadSector.C:120
 testSt12ReadSector.C:121
 testSt12ReadSector.C:122
 testSt12ReadSector.C:123
 testSt12ReadSector.C:124
 testSt12ReadSector.C:125
 testSt12ReadSector.C:126
 testSt12ReadSector.C:127
 testSt12ReadSector.C:128
 testSt12ReadSector.C:129
 testSt12ReadSector.C:130
 testSt12ReadSector.C:131
 testSt12ReadSector.C:132
 testSt12ReadSector.C:133
 testSt12ReadSector.C:134
 testSt12ReadSector.C:135
 testSt12ReadSector.C:136
 testSt12ReadSector.C:137
 testSt12ReadSector.C:138
 testSt12ReadSector.C:139