]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MUON/mapping/macros/testExistingPads2.C
No need to be a singleton
[u/mrichter/AliRoot.git] / MUON / mapping / macros / testExistingPads2.C
1 // $Id$
2 // $MpId: testExistingPads2.C,v 1.3 2005/08/24 08:53:27 ivana Exp $
3 //
4 // Extended testExistingPads macro for testing which pad is seen as 
5 // "existing" by AliMpSector.
6 // The loop over pads is performed in two ways:
7 // 1) via sector area pad iterator
8 // 2) via indices
9
10 #include <iomanip>
11
12 void testExistingPads2(AliMp::StationType station = AliMp::kStation1,
13                        AliMp::PlaneType plane = AliMp::kBendingPlane) 
14 {
15   AliMpSectorReader r(station, plane);
16   AliMpSector* sector = r.BuildSector();
17   AliMpSectorSegmentation segmentation(sector);
18   
19   ofstream out1("testExistingPads2.ixiy.out", ios::out);
20   ofstream out2("testExistingPads2.iter.out", ios::out);
21   
22   // First loop over indices
23   cout << "Iterating via indices ..." << endl;
24   Int_t counter1 = 0;
25   if ( sector->GetDirection() == AliMp::kX )
26     for (Int_t i=1; i<segmentation.MaxPadIndexX()+1; i++) {
27       for (Int_t j=1; j<segmentation.MaxPadIndexY()+1; j++) {
28         AliMpIntPair indices(i,j);
29         if ( segmentation.HasPad(indices) ) 
30           out1 << std::setw(4) << ++counter1 << "  "
31                << segmentation.PadByIndices(indices) << endl;;
32       }
33     }
34
35   if ( sector->GetDirection() == AliMp::kY )
36     for (Int_t j=1; j<segmentation.MaxPadIndexY()+1; j++) {
37       for (Int_t i=1; i<segmentation.MaxPadIndexX()+1; i++) {
38         AliMpIntPair indices(i,j);
39         if ( segmentation.HasPad(indices) ) 
40           out1 << std::setw(4) << ++counter1 << "  "
41                << segmentation.PadByIndices(indices) << endl;;
42       }
43     }
44   
45   // Second loop via pad area iterator
46   cout << "Iterating via iterator ..." << endl;
47   AliMpArea area(TVector2(60.,60.), TVector2(60.,60.) );
48   AliMpVPadIterator* it = segmentation.CreateIterator(area);
49   Int_t counter2 = 0;
50   for (it->First(); ! it->IsDone(); it->Next()){
51    
52     out2 << std::setw(4) << ++counter2 << "  "
53          << it->CurrentItem() << endl;
54   }  
55 }