]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MUON/mapping/macros/testMotifTypeIterators.C
In mapping/macros:
[u/mrichter/AliRoot.git] / MUON / mapping / macros / testMotifTypeIterators.C
1 // $Id$
2 // $MpId: testMotifTypeIterators.C,v 1.11 2005/09/26 16:05:25 ivana Exp $
3 //
4 // Test macro for reading motif type data and iterate over them.
5
6 #if !defined(__CINT__) || defined(__MAKECINT__)
7
8 #include "AliMpStation12Type.h"
9 #include "AliMpPlaneType.h"
10 #include "AliMpDataProcessor.h"
11 #include "AliMpDataMap.h"
12 #include "AliMpDataStreams.h"
13 #include "AliMpMotifReader.h"
14 #include "AliMpMotifType.h"
15 #include "AliMpMotifTypePadIterator.h"
16
17 #include <Riostream.h>
18 #include <TCanvas.h>
19 #include <TMarker.h>
20 #include <TH2.h>
21
22 #include <vector>
23
24 #endif
25
26 void testMotifTypeIterators(AliMq::Station12Type station, AliMp::PlaneType plane)
27 {
28   TString names;
29   TString names2;
30   Int_t nv =0;
31   if ( station == AliMq::kStation1 ) {
32     if ( plane == AliMp::kBendingPlane ) 
33       names ="ABCDEFGHI";
34     else
35       names = "ABCDEFGHIJKLMN";
36   }    
37   else if ( station == AliMq::kStation2 ) {
38     if ( plane == AliMp::kBendingPlane ) {
39       names ="ABCDEFGHIJKLMNOPQRSTUVWXY";
40       names2 ="abcdefghimnptuvvvvv";
41       nv = 5;
42     }  
43     else {
44       names = "ABCEFGHIJKLMN";
45       names2 ="abcdefgijklmnopqrstuwvvvvv";
46       nv = 5;
47     }  
48   }  
49   Int_t nofMotifs = names.Length() + names2.Length(); 
50   // cout << " nofMotifs: " << nofMotifs << endl;   
51     
52   std::vector<TH2C*> histos;
53   std::vector<TCanvas*> cvs;
54   Int_t i;
55   for (i=0;i<1+(nofMotifs-1)/4;++i){
56     TString cname("canv"); cname += i;
57     TCanvas* canv = new TCanvas(cname.Data(),"Iterator viewing...");
58     canv->Divide(2,2); 
59     cvs.push_back(canv);
60   }
61     
62   AliMpDataProcessor mp;
63   AliMpDataMap* dataMap = mp.CreateDataMap("data");
64   AliMpDataStreams dataStreams(dataMap);
65
66   AliMpMotifReader r(dataStreams, AliMp::kStation12, station, plane);
67   //r.SetVerboseLevel(2);
68
69   for (i=0;i<nofMotifs;++i){
70
71     // Get motif name
72     TString mname;
73     if (i<names.Length())
74       mname = names(i, 1);
75     else {
76       mname = names2(i-names.Length(), 1); 
77       if (mname == "v")
78         mname += i - names.Length() - (names2.Length()-nv-1);
79       else         
80         mname += "1";
81     }   
82     //if (i==36) continue;  
83         // break for these motifs (St2, BP) - to be investigated
84    
85     AliMpMotifType *mt = r.BuildMotifType(mname);
86
87     cvs[i/4]->cd(1+ (i%4));
88     //histos[i] = new TH2C(Form("h%d",i),Form("Motif type %c",names[i]),
89     //                     mt->GetNofPadsX(),-0.5,mt->GetNofPadsX()-0.5,
90     //                     mt->GetNofPadsY(),-0.5,mt->GetNofPadsY()-0.5);
91                // CINT limitation on DEC
92
93     TString hname("h"); hname += i;
94
95     TH2C* histo = new TH2C(hname.Data(), mname.Data(),
96                          mt->GetNofPadsX(),-0.5,mt->GetNofPadsX()-0.5,
97                          mt->GetNofPadsY(),-0.5,mt->GetNofPadsY()-0.5);
98     histos.push_back(histo);                         
99
100     cout<<"Motif Type "<<mt->GetID()<<endl;
101     cout<<"--------------------------------"<<endl;
102     Int_t num=0;
103
104     AliMpMotifTypePadIterator it = AliMpMotifTypePadIterator(mt);
105
106     for (it.First(); ! it.IsDone(); it.Next()) {
107       cout << "Iterator " << num << ' '<< it.CurrentItem().GetIndices() << endl;
108       ++num;
109       histo->Fill(it.CurrentItem().GetIndices().GetFirst(),
110                   it.CurrentItem().GetIndices().GetSecond(),num);
111     }
112
113     //delete mt;
114     histo->Draw("text");
115     cvs[i/4]->Update();
116   }
117 }
118 void testMotifTypeIterators()
119 {
120   AliMq::Station12Type  station[2] = { AliMq::kStation1, AliMq::kStation2 }; 
121   AliMp::PlaneType      plane[2]   = { AliMp::kBendingPlane, AliMp::kNonBendingPlane };
122   
123   for ( Int_t is = 0; is < 2; is++ ) {
124     for ( Int_t ip = 0; ip < 2; ip++ ) {
125     
126       cout << "Running testMotifTypeIterators for " 
127            << AliMq::Station12TypeName(station[is]) << "  "
128            << AliMp::PlaneTypeName(plane[ip])  << " ... " << endl;
129        
130       testMotifTypeIterators(station[is], plane[ip]);
131     
132       cout << "... end running " << endl << endl;
133     }  
134   }   
135 }  
136