]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MUON/mapping/macros/testSt12ExistingPads2.C
Replacement of AliMpIntPair object with algoritmic
[u/mrichter/AliRoot.git] / MUON / mapping / macros / testSt12ExistingPads2.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 AliMpSectorSegmentation or AliMpFastSegmentation.
6 // The loop over pads is performed in two ways:
7 // 1) via sector area pad iterator
8 // 2) via indices
9 // To run macro:
10 // root [0] .L testExistingPads2.C+
11 // root [1] testExistingPads2();
12
13
14 #if !defined(__CINT__) || defined(__MAKECINT__)
15
16 #include "AliMpStation12Type.h"
17 #include "AliMpPlaneType.h"
18 #include "AliMpDataProcessor.h"
19 #include "AliMpDataMap.h"
20 #include "AliMpDataStreams.h"
21 #include "AliMpSector.h"
22 #include "AliMpSectorReader.h"
23 #include "AliMpSectorSegmentation.h"
24 #include "AliMpFastSegmentation.h"
25 #include "AliMpArea.h"
26 #include "AliMpVPadIterator.h"
27
28 #include <Riostream.h>
29 #include <TString.h>
30
31 #endif
32
33 void testExistingPads2(AliMq::Station12Type station, AliMp::PlaneType plane,
34                        Bool_t useFastSegmentation = kTRUE) 
35 {
36   // Read data
37   AliMpDataProcessor mp;
38   AliMpDataMap* dataMap = mp.CreateDataMap("data");
39   AliMpDataStreams dataStreams(dataMap);
40   AliMpSectorReader r(dataStreams, station, plane);
41   AliMpSector* sector = r.BuildSector();
42
43   // Segmentation
44   AliMpVSegmentation* segmentation;
45   if ( useFastSegmentation)
46     segmentation = new AliMpFastSegmentation(new AliMpSectorSegmentation(sector));
47   else
48     segmentation = new AliMpSectorSegmentation(sector);
49     
50   // Output files 
51   TString outName = "testExistingPads.";
52   outName += AliMq::Station12TypeName(station);
53   outName += AliMp::PlaneTypeName(plane);
54   TString out1Name = outName + ".ixiy.out";
55   TString out2Name = outName + ".iter.out";
56
57   ofstream out1(out1Name.Data(), ios::out);
58   ofstream out2(out2Name.Data(), ios::out);
59   
60   // First loop over indices
61   cout << "Iterating via indices ..." << endl;
62   Int_t counter1 = 0;
63   if ( sector->GetDirection() == AliMp::kX )
64     for (Int_t i=1; i<segmentation->MaxPadIndexX()+1; i++) {
65       for (Int_t j=1; j<segmentation->MaxPadIndexY()+1; j++) {
66         if ( segmentation->HasPadByIndices(i,j) ) 
67           out1 << std::setw(4) << ++counter1 << "  "
68                << segmentation->PadByIndices(i,j) << endl;;
69       }
70     }
71
72   if ( sector->GetDirection() == AliMp::kY )
73     for (Int_t j=1; j<segmentation->MaxPadIndexY()+1; j++) {
74       for (Int_t i=1; i<segmentation->MaxPadIndexX()+1; i++) {
75         if ( segmentation->HasPadByIndices(i,j) ) 
76           out1 << std::setw(4) << ++counter1 << "  "
77                << segmentation->PadByIndices(i,j) << endl;;
78       }
79     }
80   
81   // Second loop via pad area iterator
82   cout << "Iterating via iterator ..." << endl;
83   AliMpArea area(TVector2(60.,60.), TVector2(60.,60.) );
84   AliMpVPadIterator* it = segmentation->CreateIterator(area);
85   Int_t counter2 = 0;
86   for (it->First(); ! it->IsDone(); it->Next()){
87    
88     out2 << std::setw(4) << ++counter2 << "  "
89          << it->CurrentItem() << endl;
90   }  
91   
92   delete segmentation;
93 }
94
95 void testSt12ExistingPads2()
96 {
97   AliMq::Station12Type  station[2] = { AliMq::kStation1, AliMq::kStation2 }; 
98   AliMp::PlaneType      plane[2]   = { AliMp::kBendingPlane, AliMp::kNonBendingPlane };
99   
100   for ( Int_t is = 0; is < 2; is++ ) {
101     for ( Int_t ip = 0; ip < 2; ip++ ) {
102     
103       cout << "Running testExistingPads2 for " 
104            << AliMq::Station12TypeName(station[is]) << "  "
105            << AliMp::PlaneTypeName(plane[ip])  << " ... " << endl;
106        
107       testExistingPads2(station[is], plane[ip]);
108     
109       cout << "... end running " << endl << endl;
110     }  
111   }   
112 }  
113