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