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