]> git.uio.no Git - u/mrichter/AliRoot.git/blame - EVE/EveDet/AliEveMUONData.cxx
Fixes for reading ITS raw-data.
[u/mrichter/AliRoot.git] / EVE / EveDet / AliEveMUONData.cxx
CommitLineData
d810d0de 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 *
51346b82 7 * full copyright notice. *
d810d0de 8 **************************************************************************/
3626c858 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
d810d0de 19#include "AliEveMUONData.h"
3626c858 20
cb4245bb 21#include <EveDet/AliEveMUONChamberData.h>
707b281a 22#include <EveBase/AliEveEventManager.h>
3626c858 23
24#include <AliRawReader.h>
25#include <AliRawReaderFile.h>
26#include <AliRawReaderDate.h>
27#include <AliRawReaderRoot.h>
28
361fa326 29#include <AliLog.h>
3626c858 30
cef26510 31#include <AliMUONDigitMaker.h>
eadce74d 32#include <AliMUONHit.h>
8c58b039 33#include <AliMUONVCluster.h>
34#include "AliMUONVClusterStore.h"
8d33d1c2 35#include <AliMUONVDigit.h>
8d33d1c2 36#include "AliMUONDigitStoreV1.h"
832dd5c9 37#include "AliMUONVDigitStore.h"
3626c858 38#include "TTree.h"
39#include "TString.h"
3626c858 40#include "TClonesArray.h"
cef26510 41#include "TList.h"
d810d0de 42
3626c858 43
57ffa5fb 44//______________________________________________________________________________
d810d0de 45// AliEveMUONData
3626c858 46//
47
d810d0de 48ClassImp(AliEveMUONData)
3626c858 49
d810d0de 50AliRawReader* AliEveMUONData::fgRawReader = 0;
3626c858 51
57ffa5fb 52//______________________________________________________________________________
d810d0de 53AliEveMUONData::AliEveMUONData() :
eadce74d 54 fChambers(14),
55 fNTrackList(0)
3626c858 56{
57 //
58 // Constructor
59 //
51346b82 60
cef26510 61 for (Int_t i = 0; i < 256; i++) {
eadce74d 62 fTrackList[i] = -1;
63 }
64
3626c858 65 CreateAllChambers();
66
67}
68
57ffa5fb 69//______________________________________________________________________________
d810d0de 70AliEveMUONData::~AliEveMUONData()
3626c858 71{
72 //
73 // Destructor
74 //
75
76 DeleteAllChambers();
77
3626c858 78}
79
57ffa5fb 80//______________________________________________________________________________
d810d0de 81void AliEveMUONData::Reset()
eadce74d 82{
83 //
84 // Reset data
85 //
86
87 //DropAllChambers();
88
89 fNTrackList = 0;
cef26510 90 for (Int_t i = 0; i < 256; i++) {
eadce74d 91 fTrackList[i] = -1;
92 }
93
94}
95
57ffa5fb 96//______________________________________________________________________________
d810d0de 97AliEveMUONData::AliEveMUONData(const AliEveMUONData &mdata) :
e4204218 98 TObject(mdata),
84aff7a4 99 TEveRefCnt(),
8d33d1c2 100 fChambers(14),
101 fNTrackList(0)
3626c858 102{
103 //
104 // Copy constructor
105 //
106
107}
108
57ffa5fb 109//______________________________________________________________________________
d810d0de 110AliEveMUONData& AliEveMUONData::operator=(const AliEveMUONData &mdata)
3626c858 111{
112 //
113 // Assignment operator
114 //
115
116 if (this != &mdata) {
117
118 }
119
120 return *this;
121
122}
123
57ffa5fb 124//______________________________________________________________________________
d810d0de 125void AliEveMUONData::CreateChamber(Int_t chamber)
3626c858 126{
51346b82 127 //
3626c858 128 // create data for the chamber with id=chamber (0 to 13)
129 //
130
131 if (fChambers[chamber] == 0)
d810d0de 132 fChambers[chamber] = new AliEveMUONChamberData(chamber);
3626c858 133
134}
135
57ffa5fb 136//______________________________________________________________________________
d810d0de 137void AliEveMUONData::CreateAllChambers()
3626c858 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
57ffa5fb 148//______________________________________________________________________________
d810d0de 149void AliEveMUONData::DropAllChambers()
3626c858 150{
51346b82 151 //
152 // release data from all chambers
3626c858 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
57ffa5fb 164//______________________________________________________________________________
d810d0de 165void AliEveMUONData::DeleteAllChambers()
3626c858 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
57ffa5fb 180//______________________________________________________________________________
d810d0de 181void AliEveMUONData::RegisterTrack(Int_t track)
eadce74d 182{
183 //
184 // register (in a list) a track with hits in the chambers
185 //
186
cef26510 187 if (fNTrackList == (256-1)) {
eadce74d 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
57ffa5fb 206//______________________________________________________________________________
d810d0de 207void AliEveMUONData::LoadRecPoints(TTree* tree)
2674c15a 208{
209 //
210 // load reconstructed points from the TreeR
211 // load local trigger information
212 //
213
8c58b039 214 AliMUONVClusterStore *clusterStore = AliMUONVClusterStore::Create(*tree);
215 clusterStore->Clear();
216 clusterStore->Connect(*tree,kFALSE);
51346b82 217
8c58b039 218 tree->GetEvent(0);
51346b82 219
8c58b039 220 AliMUONVCluster *cluster;
eadce74d 221 Int_t detElemId;
8c58b039 222 Double_t clsX, clsY, clsZ, charge;
eadce74d 223
8c58b039 224 for (Int_t ch = 0; ch < 10; ++ch) {
eadce74d 225
8c58b039 226 if (fChambers[ch] == 0) continue;
51346b82 227
8c58b039 228 TIter next(clusterStore->CreateChamberIterator(ch,ch));
51346b82 229
8c58b039 230 while ( ( cluster = static_cast<AliMUONVCluster*>(next()) ) ) {
eadce74d 231
8c58b039 232 detElemId = cluster->GetDetElemId();
51346b82 233
8c58b039 234 clsX = cluster->GetX();
235 clsY = cluster->GetY();
236 clsZ = cluster->GetZ();
237 charge = cluster->GetCharge();
eadce74d 238
8c58b039 239 fChambers[ch]->RegisterCluster(detElemId,0,clsX,clsY,clsZ,charge);
240 fChambers[ch]->RegisterCluster(detElemId,1,clsX,clsY,clsZ,charge);
eadce74d 241
242 }
243
244 }
245
8c58b039 246 delete clusterStore;
51346b82 247
eadce74d 248}
249
57ffa5fb 250//______________________________________________________________________________
d810d0de 251void AliEveMUONData::LoadHits(TTree* tree)
eadce74d 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
2674c15a 286}
287
57ffa5fb 288//______________________________________________________________________________
d810d0de 289void AliEveMUONData::LoadDigits(TTree* tree)
832dd5c9 290{
51346b82 291 //
832dd5c9 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());
51346b82 303
832dd5c9 304 Int_t cathode, detElemId, ix, iy, charge, chamber, adc;
51346b82 305
832dd5c9 306 while ( ( digit = static_cast<AliMUONVDigit*>(next() ) ) )
307 {
308 cathode = digit->Cathode();
309 ix = digit->PadX();
310 iy = digit->PadY();
51346b82 311 detElemId = digit->DetElemId();
832dd5c9 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 }
51346b82 321
832dd5c9 322 delete digitStore;
323
324}
325
57ffa5fb 326//______________________________________________________________________________
d810d0de 327void AliEveMUONData::LoadRaw(TString fileName)
3626c858 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 }
3626c858 342 }
51346b82 343
3626c858 344 fgRawReader->RewindEvents();
cef26510 345 fgRawReader->Reset();
3626c858 346
347 Int_t iEvent = 0;
51346b82 348 while (fgRawReader->NextEvent())
8d33d1c2 349 {
51346b82 350 if (iEvent != gEvent->GetEventId())
8d33d1c2 351 {
3626c858 352 iEvent++;
353 continue;
354 }
3626c858 355 break;
cef26510 356 }
3626c858 357
8d33d1c2 358 AliMUONDigitMaker digitMaker;
3626c858 359
8d33d1c2 360 digitMaker.SetMakeTriggerDigits(kTRUE);
3626c858 361
8d33d1c2 362 AliMUONDigitStoreV1 digitStore;
51346b82 363
8d33d1c2 364 digitMaker.Raw2Digits(fgRawReader,&digitStore);
3626c858 365
8d33d1c2 366 AliMUONVDigit* digit;
367 TIter next(digitStore.CreateIterator());
51346b82 368
832dd5c9 369 Int_t cathode, detElemId, ix, iy, charge, chamber, adc;
51346b82 370
8d33d1c2 371 while ( ( digit = static_cast<AliMUONVDigit*>(next() ) ) )
372 {
cef26510 373 cathode = digit->Cathode();
374 ix = digit->PadX();
375 iy = digit->PadY();
51346b82 376 detElemId = digit->DetElemId();
8d33d1c2 377 charge = (Int_t)digit->Charge();
832dd5c9 378 adc = digit->ADC();
cef26510 379 chamber = detElemId/100 - 1;
832dd5c9 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 }
cef26510 385 }
832dd5c9 386
3626c858 387}
388
57ffa5fb 389//______________________________________________________________________________
d810d0de 390Int_t AliEveMUONData::GetTrack(Int_t index)
eadce74d 391{
392 //
393 // return track stack number for "index"-th track with hits in the chambers
394 //
395
cef26510 396 if (index < 256) {
eadce74d 397 return fTrackList[index];
398 } else {
399 return -1;
400 }
401
402}
403
57ffa5fb 404//______________________________________________________________________________
d810d0de 405AliEveMUONChamberData* AliEveMUONData::GetChamberData(Int_t chamber)
3626c858 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}