Mapping test macros (D. Guez, I. Hrivnacova)
[u/mrichter/AliRoot.git] / MUON / mapping / macros / testMotifTypeIterators.C
1 // $Id$
2 //
3 // Test macro for reading motif type data and iterate over them.
4
5 void testMotifTypeIterators(AliMpStationType station = kStation1,
6                             AliMpPlaneType plane = kBendingPlane)
7 {
8   TString names="ABCDEFGHI";
9   //TString names="FEG";
10     
11   TH2C* histos[] = new TH2C* [names.Length()];
12   TCanvas* canv[] = new TCanvas* [1+(names.Length()-1)/4];
13   Int_t i;
14   for (i=0;i<1+(names.Length()-1)/4;++i){
15     // canv[i] = new TCanvas(Form("canv%d",i),"Iterator viewing...");
16                // CINT limitation on DEC
17                
18     TString cname("canv"); cname += i;
19     canv[i] = new TCanvas(cname.Data(),"Iterator viewing...");
20     
21     canv[i]->Divide(2,2); 
22   }
23     
24   AliMpReader r(station, plane);
25   //r.SetVerboseLevel(2);
26
27   for (i=0;i<names.Length();++i){
28     AliMpMotifType *mt = r.BuildMotifType(names[i]);
29     canv[i/4]->cd(1+ (i%4));
30     //histos[i] = new TH2C(Form("h%d",i),Form("Motif type %c",names[i]),
31     //                     mt->GetNofPadsX(),-0.5,mt->GetNofPadsX()-0.5,
32     //                     mt->GetNofPadsY(),-0.5,mt->GetNofPadsY()-0.5);
33                // CINT limitation on DEC
34
35     TString hname("h"); hname += i;
36     TString mname = names(i,1);        
37
38     histos[i] = new TH2C(hname.Data(), mname.Data(),
39                          mt->GetNofPadsX(),-0.5,mt->GetNofPadsX()-0.5,
40                          mt->GetNofPadsY(),-0.5,mt->GetNofPadsY()-0.5);
41
42     cout<<"Motif Type "<<mt->GetID()<<endl;
43     cout<<"--------------------------------"<<endl;
44     Int_t num=0;
45
46     AliMpMotifTypePadIterator it = AliMpMotifTypePadIterator(mt);
47
48     for (it.First(); ! it.IsDone(); it.Next()) {
49       cout << "Iterator " << num << ' '<< it.CurrentItem().GetIndices() << endl;
50       ++num;
51       histos[i]->Fill(it.CurrentItem().GetIndices().GetFirst(),
52                       it.CurrentItem().GetIndices().GetSecond(),num);
53     }
54
55     delete mt;
56
57     histos[i]->Draw("text");
58     canv[i/4]->Update();
59     
60   }
61 }