2 // Main authors: Matevz Tadel & Alja Mrak-Tadel: 2006, 2007
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 **************************************************************************/
12 // GetTrackerMapping = AliMUONDigitMaker::GetMapping
13 // GetTriggerMapping = AliMUONDigitMaker::TriggerDigits
14 // GetTriggerChamber = AliMUONDigitMaker::GetTriggerChamber
15 // LoadRawTracker = MUONRawStreamTracker.C
16 // LoadRawTrigger = MUONRawStreamTrigger.C
19 #include "AliEveMUONData.h"
21 #include <Alieve/AliEveMUONChamberData.h>
22 #include <Alieve/AliEveEventManager.h>
24 #include <AliRawReader.h>
25 #include <AliRawReaderFile.h>
26 #include <AliRawReaderDate.h>
27 #include <AliRawReaderRoot.h>
31 #include <AliMUONDigitMaker.h>
32 #include <AliMUONHit.h>
33 #include <AliMUONVCluster.h>
34 #include "AliMUONVClusterStore.h"
35 #include <AliMUONVDigit.h>
36 #include "AliMUONDigitStoreV1.h"
37 #include "AliMUONVDigitStore.h"
40 #include "TClonesArray.h"
44 //______________________________________________________________________
48 ClassImp(AliEveMUONData)
50 AliRawReader* AliEveMUONData::fgRawReader = 0;
52 //______________________________________________________________________
53 AliEveMUONData::AliEveMUONData() :
61 for (Int_t i = 0; i < 256; i++) {
69 //______________________________________________________________________
70 AliEveMUONData::~AliEveMUONData()
80 //______________________________________________________________________
81 void AliEveMUONData::Reset()
90 for (Int_t i = 0; i < 256; i++) {
96 //______________________________________________________________________
97 AliEveMUONData::AliEveMUONData(const AliEveMUONData &mdata) :
109 //______________________________________________________________________
110 AliEveMUONData& AliEveMUONData::operator=(const AliEveMUONData &mdata)
113 // Assignment operator
116 if (this != &mdata) {
124 //______________________________________________________________________
125 void AliEveMUONData::CreateChamber(Int_t chamber)
128 // create data for the chamber with id=chamber (0 to 13)
131 if (fChambers[chamber] == 0)
132 fChambers[chamber] = new AliEveMUONChamberData(chamber);
136 //______________________________________________________________________
137 void AliEveMUONData::CreateAllChambers()
140 // create all 14 chambers data
143 for (Int_t c = 0; c < 14; ++c)
148 //______________________________________________________________________
149 void AliEveMUONData::DropAllChambers()
152 // release data from all chambers
155 for (Int_t c = 0; c < 14; ++c) {
157 if (fChambers[c] != 0)
158 fChambers[c]->DropData();
164 //______________________________________________________________________
165 void AliEveMUONData::DeleteAllChambers()
168 // delete all chambers data
171 for (Int_t c = 0; c < 14; ++c) {
180 //______________________________________________________________________
181 void AliEveMUONData::RegisterTrack(Int_t track)
184 // register (in a list) a track with hits in the chambers
187 if (fNTrackList == (256-1)) {
188 cout << "Maximum of registered tracks reached..." << endl;
192 Bool_t inList = kFALSE;
193 for (Int_t i = 0; i < fNTrackList; i++) {
194 if (track == fTrackList[i]) {
200 fTrackList[fNTrackList] = track;
206 //______________________________________________________________________
207 void AliEveMUONData::LoadRecPoints(TTree* tree)
210 // load reconstructed points from the TreeR
211 // load local trigger information
214 AliMUONVClusterStore *clusterStore = AliMUONVClusterStore::Create(*tree);
215 clusterStore->Clear();
216 clusterStore->Connect(*tree,kFALSE);
220 AliMUONVCluster *cluster;
222 Double_t clsX, clsY, clsZ, charge;
224 for (Int_t ch = 0; ch < 10; ++ch) {
226 if (fChambers[ch] == 0) continue;
228 TIter next(clusterStore->CreateChamberIterator(ch,ch));
230 while ( ( cluster = static_cast<AliMUONVCluster*>(next()) ) ) {
232 detElemId = cluster->GetDetElemId();
234 clsX = cluster->GetX();
235 clsY = cluster->GetY();
236 clsZ = cluster->GetZ();
237 charge = cluster->GetCharge();
239 fChambers[ch]->RegisterCluster(detElemId,0,clsX,clsY,clsZ,charge);
240 fChambers[ch]->RegisterCluster(detElemId,1,clsX,clsY,clsZ,charge);
250 //______________________________________________________________________
251 void AliEveMUONData::LoadHits(TTree* tree)
254 // load simulation hits from the TreeH
257 TClonesArray *hits = 0;
259 Int_t cha, detElemId, nhits, ntracks;
260 Float_t hitX, hitY, hitZ;
262 ntracks = tree->GetEntries();
263 tree->SetBranchAddress("MUONHits",&hits);
265 for (Int_t it = 0; it < ntracks; it++) {
268 nhits = hits->GetEntriesFast();
270 for (Int_t ih = 0; ih < nhits; ih++) {
272 mhit = (AliMUONHit*)hits->UncheckedAt(ih);
276 detElemId = mhit->DetElemId();
277 cha = mhit->Chamber();
279 RegisterTrack(mhit->GetTrack());
281 fChambers[cha-1]->RegisterHit(detElemId,hitX,hitY,hitZ);
288 //______________________________________________________________________
289 void AliEveMUONData::LoadDigits(TTree* tree)
292 // load digits from the TreeD
295 AliMUONVDigitStore *digitStore = AliMUONVDigitStore::Create(*tree);
297 digitStore->Connect(*tree,0);
301 AliMUONVDigit* digit;
302 TIter next(digitStore->CreateIterator());
304 Int_t cathode, detElemId, ix, iy, charge, chamber, adc;
306 while ( ( digit = static_cast<AliMUONVDigit*>(next() ) ) )
308 cathode = digit->Cathode();
311 detElemId = digit->DetElemId();
312 charge = (Int_t)digit->Charge();
314 chamber = detElemId/100 - 1;
316 fChambers[chamber]->RegisterDigit(detElemId,cathode,ix,iy,charge);
318 fChambers[chamber]->RegisterDigit(detElemId,cathode,ix,iy,adc);
326 //______________________________________________________________________
327 void AliEveMUONData::LoadRaw(TString fileName)
330 // load raw data from fileName; tracker and trigger data
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
344 fgRawReader->RewindEvents();
345 fgRawReader->Reset();
348 while (fgRawReader->NextEvent())
350 if (iEvent != gEvent->GetEventId())
358 AliMUONDigitMaker digitMaker;
360 digitMaker.SetMakeTriggerDigits(kTRUE);
362 AliMUONDigitStoreV1 digitStore;
364 digitMaker.Raw2Digits(fgRawReader,&digitStore);
366 AliMUONVDigit* digit;
367 TIter next(digitStore.CreateIterator());
369 Int_t cathode, detElemId, ix, iy, charge, chamber, adc;
371 while ( ( digit = static_cast<AliMUONVDigit*>(next() ) ) )
373 cathode = digit->Cathode();
376 detElemId = digit->DetElemId();
377 charge = (Int_t)digit->Charge();
379 chamber = detElemId/100 - 1;
381 fChambers[chamber]->RegisterDigit(detElemId,cathode,ix,iy,charge);
383 fChambers[chamber]->RegisterDigit(detElemId,cathode,ix,iy,adc);
389 //______________________________________________________________________
390 Int_t AliEveMUONData::GetTrack(Int_t index)
393 // return track stack number for "index"-th track with hits in the chambers
397 return fTrackList[index];
404 //______________________________________________________________________
405 AliEveMUONChamberData* AliEveMUONData::GetChamberData(Int_t chamber)
408 // return chamber data
411 if (chamber < 0 || chamber > 13) return 0;
413 //if (fChambers[chamber] == 0) CreateChamber(chamber);
415 return fChambers[chamber];