]> git.uio.no Git - u/mrichter/AliRoot.git/blob - EVE/test-macros/tpc_sector_raw_test.C
0360c2d330f8c72f84b247e1176d0fa275a61b39
[u/mrichter/AliRoot.git] / EVE / test-macros / tpc_sector_raw_test.C
1 // $Id$
2 // Main authors: Matevz Tadel & Alja Mrak-Tadel: 2006, 2007
3
4 /**************************************************************************
5  * Copyright(c) 1998-2008, ALICE Experiment at CERN, all rights reserved. *
6  * See http://aliceinfo.cern.ch/Offline/AliRoot/License.html for          *
7  * full copyright notice.                                                 * 
8  **************************************************************************/
9
10 // Functions to read rootified raw-data from TPC sector test.
11 //
12 // Use tpc_sector_raw_test("filename.root") for initialization,
13 // next_event() to advance along the data stream.
14 // When there is no more data ROOT will crash.
15
16 class AliRawReaderRoot;
17
18 namespace Alieve {
19 class AliEveTPCData;
20 class AliEveTPCSector2D;
21 class AliEveTPCSector3D;
22 }
23
24
25 AliEveTPCData*     x = 0;
26 AliEveTPCSector2D* s = 0;
27 AliEveTPCSector3D* t = 0;
28
29 AliRawReaderRoot* reader =  0;
30 Int_t             event  = -1;
31 Int_t     default_sector =  13;
32
33 void tpc_sector_raw_test(const char *file = "", Int_t ievent = 0)
34 {
35   gStyle->SetPalette(1, 0);
36
37   reader = new AliRawReaderRoot(file);
38   //reader->LoadEquipmentIdsMap
39   //  (gSystem->ExpandPathName("$(ALICE_ROOT)/TPC/mapping/EquipmentIdMap.data"));
40   //  (gSystem->ExpandPathName("EquipmentIdMap.data"));
41
42   reader->Reset();
43   for(Int_t i=0; i<ievent; ++i, ++event) {
44     if(reader->NextEvent() == kFALSE) {
45       printf("End of raw stream at event %d (reqired event %d).\n", i, ievent);
46       return;
47     }
48   }
49
50   x = new AliEveTPCData;
51   // x->SetLoadPedestal(5);
52   x->SetLoadThreshold(5);
53   x->SetAutoPedestal(kTRUE);
54
55   s = new AliEveTPCSector2D();
56   s->SetSectorID(default_sector);
57   s->SetAutoTrans(kTRUE); // place on proper 3D coordinates
58   s->SetDataSource(x);
59   s->SetFrameColor(36);
60   gEve->AddElement(s);
61   gEve->DrawElement(s);
62
63   t = new AliEveTPCSector3D();
64   t->SetSectorID(default_sector);
65   t->SetAutoTrans(kTRUE);
66   t->SetDataSource(x);
67   t->SetMaxTime(1023);
68   t->SetDriftVel(2.273);
69   gEve->AddElement(t);
70   gEve->DrawElement(t);
71
72   next_event();
73 }
74
75 void next_event()
76 {
77   if(reader->NextEvent() == kTRUE) {
78     ++event;
79   } else {
80     printf("Reached end of stream, rewinding to first event.\n");
81     event = 0;
82     reader->RewindEvents();
83     reader->NextEvent();
84   }
85
86   printf("Now loading event %d\n", event);
87   reader->Reset();
88   AliTPCRawStream input(reader);
89   input.SetOldRCUFormat(kTRUE);
90   reader->Select("TPC"); // ("TPC", firstRCU, lastRCU);
91
92   x->DropAllSectors();
93   x->LoadRaw(input, kTRUE, kTRUE);
94
95   printf("Updating scene\n");
96   s->IncRTS();
97   t->IncRTS();
98   gEve->Redraw3D();
99 }
100
101 void tpc_raw_pad_dump(Int_t s, Int_t r, Int_t p)
102 {
103   if(r >= AliEveTPCSectorData::GetInnSeg().GetNRows()) {
104     r -=  AliEveTPCSectorData::GetInnSeg().GetNRows();
105     s += 36;
106   }
107
108   reader->Reset();
109   AliTPCRawStream input(reader);
110   input.SetOldRCUFormat(kTRUE);
111   // reader->Select(0, firstRCU, lastRCU);
112
113   Int_t sector = input.GetSector();
114   Int_t row    = input.GetRow();
115
116   while (input.Next()) {
117     if (input.IsNewRow()) {
118       sector = input.GetSector();
119       row    = input.GetRow();
120     }
121     if(sector != s || row != r) continue;
122
123     Int_t signal = input.GetSignal();
124     Int_t pad    = input.GetPad();
125     Int_t time   = input.GetTime();
126
127     if(pad == p)
128       printf("%d %d\n", time, signal);
129   }
130 }