removed redundant check
[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);
217e7091 86 reader->Select("TPC"); // ("TPC", firstRCU, lastRCU);
5987168b 87
88 x->DropAllSectors();
092578a7 89 x->LoadRaw(input, kTRUE, kTRUE);
90
91 printf("Updating scene\n");
92 s->IncRTS();
93 t->IncRTS();
84aff7a4 94 gEve->Redraw3D();
092578a7 95}
96
97void tpc_raw_pad_dump(Int_t s, Int_t r, Int_t p)
98{
d810d0de 99 if(r >= AliEveTPCSectorData::GetInnSeg().GetNRows()) {
100 r -= AliEveTPCSectorData::GetInnSeg().GetNRows();
092578a7 101 s += 36;
102 }
103
5987168b 104 reader->Reset();
105 AliTPCRawStream input(reader);
5987168b 106 // reader->Select(0, firstRCU, lastRCU);
092578a7 107
108 Int_t sector = input.GetSector();
109 Int_t row = input.GetRow();
110
111 while (input.Next()) {
112 if (input.IsNewRow()) {
113 sector = input.GetSector();
114 row = input.GetRow();
115 }
116 if(sector != s || row != r) continue;
117
118 Int_t signal = input.GetSignal();
119 Int_t pad = input.GetPad();
120 Int_t time = input.GetTime();
121
122 if(pad == p)
123 printf("%d %d\n", time, signal);
124 }
125}