From Cvetan: new macro to load ITS clusters.
[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);
217e7091 32 //reader->LoadEquipmentIdsMap
33 // (gSystem->ExpandPathName("$(ALICE_ROOT)/TPC/mapping/EquipmentIdMap.data"));
34 // (gSystem->ExpandPathName("EquipmentIdMap.data"));
7ffb2ef3 35
092578a7 36 reader->Reset();
5987168b 37 for(Int_t i=0; i<ievent; ++i, ++event) {
38 if(reader->NextEvent() == kFALSE) {
39 printf("End of raw stream at event %d (reqired event %d).\n", i, ievent);
40 return;
41 }
42 }
092578a7 43
44 x = new TPCData;
5987168b 45 // x->SetLoadPedestal(5);
092578a7 46 x->SetLoadThreshold(5);
47 x->SetAutoPedestal(kTRUE);
48
49 s = new TPCSector2D();
5987168b 50 s->SetSectorID(default_sector);
601bca51 51 s->SetAutoTrans(kTRUE); // place on proper 3D coordinates
092578a7 52 s->SetDataSource(x);
53 s->SetFrameColor(36);
54 gReve->AddRenderElement(s);
55 gReve->DrawRenderElement(s);
56
57 t = new TPCSector3D();
5987168b 58 t->SetSectorID(default_sector);
601bca51 59 t->SetAutoTrans(kTRUE);
092578a7 60 t->SetDataSource(x);
61 t->SetMaxTime(1023);
62 t->SetDriftVel(2.273);
63 gReve->AddRenderElement(t);
64 gReve->DrawRenderElement(t);
65
66 next_event();
67}
68
69void next_event()
70{
5987168b 71 if(reader->NextEvent() == kTRUE) {
72 ++event;
73 } else {
74 printf("Reached end of stream, rewinding to first event.\n");
75 event = 0;
76 reader->RewindEvents();
77 reader->NextEvent();
78 }
092578a7 79
80 printf("Now loading event %d\n", event);
5987168b 81 reader->Reset();
82 AliTPCRawStream input(reader);
83 input.SetOldRCUFormat(kTRUE);
217e7091 84 reader->Select("TPC"); // ("TPC", firstRCU, lastRCU);
5987168b 85
86 x->DropAllSectors();
092578a7 87 x->LoadRaw(input, kTRUE, kTRUE);
88
89 printf("Updating scene\n");
90 s->IncRTS();
91 t->IncRTS();
92 gReve->Redraw3D();
93}
94
95void tpc_raw_pad_dump(Int_t s, Int_t r, Int_t p)
96{
092578a7 97 if(r >= TPCSectorData::GetInnSeg().GetNRows()) {
98 r -= TPCSectorData::GetInnSeg().GetNRows();
99 s += 36;
100 }
101
5987168b 102 reader->Reset();
103 AliTPCRawStream input(reader);
104 input.SetOldRCUFormat(kTRUE);
105 // reader->Select(0, firstRCU, lastRCU);
092578a7 106
107 Int_t sector = input.GetSector();
108 Int_t row = input.GetRow();
109
110 while (input.Next()) {
111 if (input.IsNewRow()) {
112 sector = input.GetSector();
113 row = input.GetRow();
114 }
115 if(sector != s || row != r) continue;
116
117 Int_t signal = input.GetSignal();
118 Int_t pad = input.GetPad();
119 Int_t time = input.GetTime();
120
121 if(pad == p)
122 printf("%d %d\n", time, signal);
123 }
124}