]> git.uio.no Git - u/mrichter/AliRoot.git/blob - EVE/Alieve/AliEveMUONData.cxx
Put black-listed classes out of Alieve namespace.
[u/mrichter/AliRoot.git] / EVE / Alieve / AliEveMUONData.cxx
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 // Sources:
11 //
12 // GetTrackerMapping = AliMUONDigitMaker::GetMapping
13 // GetTriggerMapping = AliMUONDigitMaker::TriggerDigits
14 // GetTriggerChamber = AliMUONDigitMaker::GetTriggerChamber
15 // LoadRawTracker    = MUONRawStreamTracker.C
16 // LoadRawTrigger    = MUONRawStreamTrigger.C
17 //
18
19 #include "AliEveMUONData.h"
20
21 #include <Alieve/AliEveMUONChamberData.h>
22 #include <Alieve/AliEveEventManager.h>
23
24 #include <AliRawReader.h>
25 #include <AliRawReaderFile.h>
26 #include <AliRawReaderDate.h>
27 #include <AliRawReaderRoot.h>
28
29 #include <AliLog.h>
30
31 #include <AliMUONDigitMaker.h>
32 #include <AliMUONHit.h>
33 #include <AliMUONVCluster.h>
34 #include "AliMUONVClusterStore.h"
35 #include <AliMUONVDigit.h>
36 #include "AliMUONDigitStoreV1.h"
37 #include "AliMUONVDigitStore.h"
38 #include "TTree.h"
39 #include "TString.h"
40 #include "TClonesArray.h"
41 #include "TList.h"
42
43
44 //______________________________________________________________________
45 // AliEveMUONData
46 //
47
48 ClassImp(AliEveMUONData)
49
50 AliRawReader*            AliEveMUONData::fgRawReader        = 0;
51
52 //______________________________________________________________________
53 AliEveMUONData::AliEveMUONData() :
54   fChambers(14),
55   fNTrackList(0)
56 {
57   //
58   // Constructor
59   //
60   
61   for (Int_t i = 0; i < 256; i++) {
62     fTrackList[i] = -1;
63   }
64
65   CreateAllChambers();
66
67 }
68
69 //______________________________________________________________________
70 AliEveMUONData::~AliEveMUONData()
71 {
72   //
73   // Destructor
74   //
75
76   DeleteAllChambers();
77
78 }
79
80 //______________________________________________________________________
81 void AliEveMUONData::Reset()
82 {
83   //
84   // Reset data
85   //
86
87   //DropAllChambers();
88
89   fNTrackList = 0;
90   for (Int_t i = 0; i < 256; i++) {
91     fTrackList[i] = -1;
92   }
93
94 }
95
96 //______________________________________________________________________
97 AliEveMUONData::AliEveMUONData(const AliEveMUONData &mdata) :
98   TObject(mdata),
99   TEveRefCnt(),
100   fChambers(14),
101   fNTrackList(0)
102 {
103   //
104   // Copy constructor
105   //
106
107 }
108
109 //______________________________________________________________________
110 AliEveMUONData& AliEveMUONData::operator=(const AliEveMUONData &mdata)
111 {
112   //
113   // Assignment operator
114   //
115
116   if (this != &mdata) {
117
118   }
119
120   return *this;
121
122 }
123
124 //______________________________________________________________________
125 void AliEveMUONData::CreateChamber(Int_t chamber)
126 {
127   // 
128   // create data for the chamber with id=chamber (0 to 13)
129   //
130
131   if (fChambers[chamber] == 0)
132     fChambers[chamber] = new AliEveMUONChamberData(chamber);
133
134 }
135
136 //______________________________________________________________________
137 void AliEveMUONData::CreateAllChambers()
138 {
139   //
140   // create all 14 chambers data
141   //
142
143   for (Int_t c = 0; c < 14; ++c)
144     CreateChamber(c);
145
146 }
147
148 //______________________________________________________________________
149 void AliEveMUONData::DropAllChambers()
150 {
151   // 
152   // release data from all chambers 
153   //
154
155   for (Int_t c = 0; c < 14; ++c) {
156
157     if (fChambers[c] != 0)
158       fChambers[c]->DropData();
159
160   }
161
162 }
163
164 //______________________________________________________________________
165 void AliEveMUONData::DeleteAllChambers()
166 {
167   //
168   // delete all chambers data
169   //
170
171   for (Int_t c = 0; c < 14; ++c) {
172
173     delete fChambers[c];
174     fChambers[c] = 0;
175
176   }
177
178 }
179
180 //______________________________________________________________________
181 void AliEveMUONData::RegisterTrack(Int_t track)
182 {
183   //
184   // register (in a list) a track with hits in the chambers
185   //
186
187   if (fNTrackList == (256-1)) {
188     cout << "Maximum of registered tracks reached..." << endl;
189     return;
190   }
191
192   Bool_t inList = kFALSE;
193   for (Int_t i = 0; i < fNTrackList; i++) {
194     if (track == fTrackList[i]) {
195       inList = kTRUE;
196       break;
197     }
198   }
199   if (!inList) {
200     fTrackList[fNTrackList] = track;
201     fNTrackList++;
202   }
203
204 }
205
206 //______________________________________________________________________
207 void AliEveMUONData::LoadRecPoints(TTree* tree)
208 {
209   //
210   // load reconstructed points from the TreeR
211   // load local trigger information
212   //
213
214   AliMUONVClusterStore *clusterStore = AliMUONVClusterStore::Create(*tree);
215   clusterStore->Clear();
216   clusterStore->Connect(*tree,kFALSE);
217   
218   tree->GetEvent(0);
219   
220   AliMUONVCluster *cluster;
221   Int_t detElemId;
222   Double_t clsX, clsY, clsZ, charge;
223
224   for (Int_t ch = 0; ch < 10; ++ch) {
225
226     if (fChambers[ch] == 0) continue;
227     
228     TIter next(clusterStore->CreateChamberIterator(ch,ch));
229     
230     while ( ( cluster = static_cast<AliMUONVCluster*>(next()) ) ) {
231
232       detElemId = cluster->GetDetElemId();
233       
234       clsX   = cluster->GetX();
235       clsY   = cluster->GetY();
236       clsZ   = cluster->GetZ();
237       charge = cluster->GetCharge();
238
239       fChambers[ch]->RegisterCluster(detElemId,0,clsX,clsY,clsZ,charge);
240       fChambers[ch]->RegisterCluster(detElemId,1,clsX,clsY,clsZ,charge);
241
242     }
243
244   }
245
246   delete clusterStore;
247   
248 }
249
250 //______________________________________________________________________
251 void AliEveMUONData::LoadHits(TTree* tree)
252 {
253   //
254   // load simulation hits from the TreeH
255   //
256
257   TClonesArray *hits = 0;
258   AliMUONHit  *mhit;
259   Int_t cha, detElemId, nhits, ntracks;
260   Float_t hitX, hitY, hitZ;
261
262   ntracks = tree->GetEntries();
263   tree->SetBranchAddress("MUONHits",&hits);
264
265   for (Int_t it = 0; it < ntracks; it++) {
266
267     tree->GetEvent(it);
268     nhits = hits->GetEntriesFast();
269
270     for (Int_t ih = 0; ih < nhits; ih++) {
271
272       mhit = (AliMUONHit*)hits->UncheckedAt(ih);
273       hitX = mhit->X();
274       hitY = mhit->Y();
275       hitZ = mhit->Z();
276       detElemId = mhit->DetElemId();
277       cha = mhit->Chamber();
278
279       RegisterTrack(mhit->GetTrack());
280
281       fChambers[cha-1]->RegisterHit(detElemId,hitX,hitY,hitZ);
282
283     }
284   }
285
286 }
287
288 //______________________________________________________________________
289 void AliEveMUONData::LoadDigits(TTree* tree)
290 {
291   // 
292   // load digits from the TreeD
293   //
294
295   AliMUONVDigitStore *digitStore = AliMUONVDigitStore::Create(*tree);
296   digitStore->Clear();
297   digitStore->Connect(*tree,0);
298
299   tree->GetEvent(0);
300
301   AliMUONVDigit* digit;
302   TIter next(digitStore->CreateIterator());
303   
304   Int_t cathode, detElemId, ix, iy, charge, chamber, adc;
305   
306   while ( ( digit = static_cast<AliMUONVDigit*>(next() ) ) )
307     {
308       cathode   = digit->Cathode();
309       ix        = digit->PadX();
310       iy        = digit->PadY();
311       detElemId = digit->DetElemId();      
312       charge    = (Int_t)digit->Charge();
313       adc       = digit->ADC();
314       chamber   = detElemId/100 - 1;
315       if (chamber > 9) {
316         fChambers[chamber]->RegisterDigit(detElemId,cathode,ix,iy,charge);
317       } else {
318         fChambers[chamber]->RegisterDigit(detElemId,cathode,ix,iy,adc);
319       }
320     }
321     
322   delete digitStore;
323
324 }
325
326 //______________________________________________________________________
327 void AliEveMUONData::LoadRaw(TString fileName)
328 {
329   //
330   // load raw data from fileName; tracker and trigger data
331   //
332
333   if (fgRawReader == 0) {
334     // check extention to choose the rawdata file format
335     if (fileName.EndsWith("/")) {
336       fgRawReader = new AliRawReaderFile(fileName); // DDL files
337     } else if (fileName.EndsWith(".root")) {
338       fgRawReader = new AliRawReaderRoot(fileName); // ROOT file
339     } else if (!fileName.IsNull()) {
340       fgRawReader = new AliRawReaderDate(fileName); // DATE file
341     }
342   }
343   
344   fgRawReader->RewindEvents();
345   fgRawReader->Reset();
346
347   Int_t iEvent = 0;
348   while (fgRawReader->NextEvent()) 
349   {
350     if (iEvent != gEvent->GetEventId()) 
351     {
352       iEvent++;
353       continue;
354     }
355     break;
356   }
357
358   AliMUONDigitMaker digitMaker;
359
360   digitMaker.SetMakeTriggerDigits(kTRUE);
361
362   AliMUONDigitStoreV1 digitStore;
363   
364   digitMaker.Raw2Digits(fgRawReader,&digitStore);
365
366   AliMUONVDigit* digit;
367   TIter next(digitStore.CreateIterator());
368   
369   Int_t cathode, detElemId, ix, iy, charge, chamber, adc;
370   
371   while ( ( digit = static_cast<AliMUONVDigit*>(next() ) ) )
372   {
373       cathode   = digit->Cathode();
374       ix        = digit->PadX();
375       iy        = digit->PadY();
376       detElemId = digit->DetElemId();      
377       charge    = (Int_t)digit->Charge();
378       adc       = digit->ADC();
379       chamber   = detElemId/100 - 1;
380       if (chamber > 9) {
381         fChambers[chamber]->RegisterDigit(detElemId,cathode,ix,iy,charge);
382       } else {
383         fChambers[chamber]->RegisterDigit(detElemId,cathode,ix,iy,adc);
384       }
385   }
386
387 }
388
389 //______________________________________________________________________
390 Int_t AliEveMUONData::GetTrack(Int_t index)
391 {
392   //
393   // return track stack number for "index"-th track with hits in the chambers
394   //
395
396   if (index < 256) {
397     return fTrackList[index];
398   } else {
399     return -1;
400   }
401
402 }
403
404 //______________________________________________________________________
405 AliEveMUONChamberData* AliEveMUONData::GetChamberData(Int_t chamber)
406 {
407   //
408   // return chamber data
409   //
410
411   if (chamber < 0 || chamber > 13) return 0;
412
413   //if (fChambers[chamber] == 0) CreateChamber(chamber);
414
415   return fChambers[chamber];
416
417 }