New macro file demonstrating use of TPCLoader.
[u/mrichter/AliRoot.git] / EVE / test-macros / tpc_sector_raw_test.C
CommitLineData
092578a7 1// $Header$
2
3// Functions to read rootified raw-data from TPC sector test.
4//
5// Use tpc_sector_raw_test("filename.root") for initialization,
6// next_event() to advance along the data stream.
7// When there is no more data ROOT will crash.
8
9class AliRawReaderRoot;
10
11namespace Alieve {
12class TPCData;
13class TPCSector2D;
14class TPCSector3D;
15}
16
17using namespace Alieve;
18
19TPCData* x = 0;
20TPCSector2D* s = 0;
21TPCSector3D* t = 0;
22
5987168b 23AliRawReaderRoot* reader = 0;
092578a7 24Int_t event = -1;
5987168b 25Int_t default_sector = 13;
092578a7 26
27void tpc_sector_raw_test(const char *file = "", Int_t ievent = 0)
28{
092578a7 29 gStyle->SetPalette(1, 0);
30
31 reader = new AliRawReaderRoot(file);
5987168b 32 reader->LoadEquipmentIdsMap
33 (gSystem->ExpandPathName("$(ALICE_ROOT)/TPC/mapping/EquipmentIdMap.data"));
092578a7 34 reader->Reset();
5987168b 35 for(Int_t i=0; i<ievent; ++i, ++event) {
36 if(reader->NextEvent() == kFALSE) {
37 printf("End of raw stream at event %d (reqired event %d).\n", i, ievent);
38 return;
39 }
40 }
092578a7 41
42 x = new TPCData;
5987168b 43 // x->SetLoadPedestal(5);
092578a7 44 x->SetLoadThreshold(5);
45 x->SetAutoPedestal(kTRUE);
46
47 s = new TPCSector2D();
5987168b 48 s->SetSectorID(default_sector);
49 s->SetTrans(kTRUE); // place on proper 3D coordinates
092578a7 50 s->SetDataSource(x);
51 s->SetFrameColor(36);
52 gReve->AddRenderElement(s);
53 gReve->DrawRenderElement(s);
54
55 t = new TPCSector3D();
5987168b 56 t->SetSectorID(default_sector);
57 t->SetTrans(kTRUE);
092578a7 58 t->SetDataSource(x);
59 t->SetMaxTime(1023);
60 t->SetDriftVel(2.273);
61 gReve->AddRenderElement(t);
62 gReve->DrawRenderElement(t);
63
64 next_event();
65}
66
67void next_event()
68{
5987168b 69 if(reader->NextEvent() == kTRUE) {
70 ++event;
71 } else {
72 printf("Reached end of stream, rewinding to first event.\n");
73 event = 0;
74 reader->RewindEvents();
75 reader->NextEvent();
76 }
092578a7 77
78 printf("Now loading event %d\n", event);
5987168b 79 reader->Reset();
80 AliTPCRawStream input(reader);
81 input.SetOldRCUFormat(kTRUE);
82 // reader->Select(0, firstRCU, lastRCU);
83
84 x->DropAllSectors();
092578a7 85 x->LoadRaw(input, kTRUE, kTRUE);
86
87 printf("Updating scene\n");
88 s->IncRTS();
89 t->IncRTS();
90 gReve->Redraw3D();
91}
92
93void tpc_raw_pad_dump(Int_t s, Int_t r, Int_t p)
94{
092578a7 95 if(r >= TPCSectorData::GetInnSeg().GetNRows()) {
96 r -= TPCSectorData::GetInnSeg().GetNRows();
97 s += 36;
98 }
99
5987168b 100 reader->Reset();
101 AliTPCRawStream input(reader);
102 input.SetOldRCUFormat(kTRUE);
103 // reader->Select(0, firstRCU, lastRCU);
092578a7 104
105 Int_t sector = input.GetSector();
106 Int_t row = input.GetRow();
107
108 while (input.Next()) {
109 if (input.IsNewRow()) {
110 sector = input.GetSector();
111 row = input.GetRow();
112 }
113 if(sector != s || row != r) continue;
114
115 Int_t signal = input.GetSignal();
116 Int_t pad = input.GetPad();
117 Int_t time = input.GetTime();
118
119 if(pad == p)
120 printf("%d %d\n", time, signal);
121 }
122}