]> git.uio.no Git - u/mrichter/AliRoot.git/blob - EVE/test-macros/tpc_sector_raw_test.C
Move contents of EVE/Alieve to EVE/EveDet as most code will remain there.
[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 class AliEveTPCData;
19 class AliEveTPCSector2D;
20 class AliEveTPCSector3D;
21
22 AliEveTPCData*     x = 0;
23 AliEveTPCSector2D* s = 0;
24 AliEveTPCSector3D* t = 0;
25
26 AliRawReaderRoot* reader =  0;
27 Int_t             event  = -1;
28 Int_t     default_sector =  13;
29
30 void tpc_sector_raw_test(const char *file = "", Int_t ievent = 0)
31 {
32   gStyle->SetPalette(1, 0);
33
34   reader = new AliRawReaderRoot(file);
35   //reader->LoadEquipmentIdsMap
36   //  (gSystem->ExpandPathName("$(ALICE_ROOT)/TPC/mapping/EquipmentIdMap.data"));
37   //  (gSystem->ExpandPathName("EquipmentIdMap.data"));
38
39   reader->Reset();
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   }
46
47   x = new AliEveTPCData;
48   // x->SetLoadPedestal(5);
49   x->SetLoadThreshold(5);
50   x->SetAutoPedestal(kTRUE);
51
52   s = new AliEveTPCSector2D();
53   s->SetSectorID(default_sector);
54   s->SetAutoTrans(kTRUE); // place on proper 3D coordinates
55   s->SetDataSource(x);
56   s->SetFrameColor(36);
57   gEve->AddElement(s);
58   gEve->DrawElement(s);
59
60   t = new AliEveTPCSector3D();
61   t->SetSectorID(default_sector);
62   t->SetAutoTrans(kTRUE);
63   t->SetDataSource(x);
64   t->SetMaxTime(1023);
65   t->SetDriftVel(2.273);
66   gEve->AddElement(t);
67   gEve->DrawElement(t);
68
69   next_event();
70 }
71
72 void next_event()
73 {
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   }
82
83   printf("Now loading event %d\n", event);
84   reader->Reset();
85   AliTPCRawStream input(reader);
86   input.SetOldRCUFormat(kTRUE);
87   reader->Select("TPC"); // ("TPC", firstRCU, lastRCU);
88
89   x->DropAllSectors();
90   x->LoadRaw(input, kTRUE, kTRUE);
91
92   printf("Updating scene\n");
93   s->IncRTS();
94   t->IncRTS();
95   gEve->Redraw3D();
96 }
97
98 void tpc_raw_pad_dump(Int_t s, Int_t r, Int_t p)
99 {
100   if(r >= AliEveTPCSectorData::GetInnSeg().GetNRows()) {
101     r -=  AliEveTPCSectorData::GetInnSeg().GetNRows();
102     s += 36;
103   }
104
105   reader->Reset();
106   AliTPCRawStream input(reader);
107   input.SetOldRCUFormat(kTRUE);
108   // reader->Select(0, firstRCU, lastRCU);
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 }