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