From Alexandru
[u/mrichter/AliRoot.git] / EVE / test-macros / tpc_sector_raw_test.C
CommitLineData
d810d0de 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 *
51346b82 7 * full copyright notice. *
d810d0de 8 **************************************************************************/
092578a7 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
16class AliRawReaderRoot;
17
d810d0de 18class AliEveTPCData;
19class AliEveTPCSector2D;
20class AliEveTPCSector3D;
092578a7 21
d810d0de 22AliEveTPCData* x = 0;
23AliEveTPCSector2D* s = 0;
24AliEveTPCSector3D* t = 0;
092578a7 25
5987168b 26AliRawReaderRoot* reader = 0;
092578a7 27Int_t event = -1;
5987168b 28Int_t default_sector = 13;
092578a7 29
30void tpc_sector_raw_test(const char *file = "", Int_t ievent = 0)
31{
092578a7 32 gStyle->SetPalette(1, 0);
33
34 reader = new AliRawReaderRoot(file);
217e7091 35 //reader->LoadEquipmentIdsMap
36 // (gSystem->ExpandPathName("$(ALICE_ROOT)/TPC/mapping/EquipmentIdMap.data"));
37 // (gSystem->ExpandPathName("EquipmentIdMap.data"));
7ffb2ef3 38
092578a7 39 reader->Reset();
5987168b 40 for(Int_t i=0; i<ievent; ++i, ++event) {
41 if(reader->NextEvent() == kFALSE) {
42 printf("End of raw stream at event %d (reqired event %d).\n", i, ievent);
43 return;
44 }
45 }
092578a7 46
d810d0de 47 x = new AliEveTPCData;
5987168b 48 // x->SetLoadPedestal(5);
092578a7 49 x->SetLoadThreshold(5);
50 x->SetAutoPedestal(kTRUE);
51
d810d0de 52 s = new AliEveTPCSector2D();
5987168b 53 s->SetSectorID(default_sector);
601bca51 54 s->SetAutoTrans(kTRUE); // place on proper 3D coordinates
092578a7 55 s->SetDataSource(x);
56 s->SetFrameColor(36);
84aff7a4 57 gEve->AddElement(s);
58 gEve->DrawElement(s);
092578a7 59
d810d0de 60 t = new AliEveTPCSector3D();
5987168b 61 t->SetSectorID(default_sector);
601bca51 62 t->SetAutoTrans(kTRUE);
092578a7 63 t->SetDataSource(x);
64 t->SetMaxTime(1023);
65 t->SetDriftVel(2.273);
84aff7a4 66 gEve->AddElement(t);
67 gEve->DrawElement(t);
092578a7 68
69 next_event();
70}
71
72void next_event()
73{
5987168b 74 if(reader->NextEvent() == kTRUE) {
75 ++event;
76 } else {
77 printf("Reached end of stream, rewinding to first event.\n");
78 event = 0;
79 reader->RewindEvents();
80 reader->NextEvent();
81 }
092578a7 82
83 printf("Now loading event %d\n", event);
5987168b 84 reader->Reset();
85 AliTPCRawStream input(reader);
86 input.SetOldRCUFormat(kTRUE);
217e7091 87 reader->Select("TPC"); // ("TPC", firstRCU, lastRCU);
5987168b 88
89 x->DropAllSectors();
092578a7 90 x->LoadRaw(input, kTRUE, kTRUE);
91
92 printf("Updating scene\n");
93 s->IncRTS();
94 t->IncRTS();
84aff7a4 95 gEve->Redraw3D();
092578a7 96}
97
98void tpc_raw_pad_dump(Int_t s, Int_t r, Int_t p)
99{
d810d0de 100 if(r >= AliEveTPCSectorData::GetInnSeg().GetNRows()) {
101 r -= AliEveTPCSectorData::GetInnSeg().GetNRows();
092578a7 102 s += 36;
103 }
104
5987168b 105 reader->Reset();
106 AliTPCRawStream input(reader);
107 input.SetOldRCUFormat(kTRUE);
108 // reader->Select(0, firstRCU, lastRCU);
092578a7 109
110 Int_t sector = input.GetSector();
111 Int_t row = input.GetRow();
112
113 while (input.Next()) {
114 if (input.IsNewRow()) {
115 sector = input.GetSector();
116 row = input.GetRow();
117 }
118 if(sector != s || row != r) continue;
119
120 Int_t signal = input.GetSignal();
121 Int_t pad = input.GetPad();
122 Int_t time = input.GetTime();
123
124 if(pad == p)
125 printf("%d %d\n", time, signal);
126 }
127}