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