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 **************************************************************************/
13 // GetTrackerMapping = AliMUONDigitMaker::GetMapping
14 // GetTriggerMapping = AliMUONDigitMaker::TriggerDigits
15 // GetTriggerChamber = AliMUONDigitMaker::GetTriggerChamber
16 // LoadRawTracker = MUONRawStreamTracker.C
17 // LoadRawTrigger = MUONRawStreamTrigger.C
20 #include "AliEveMUONData.h"
22 #include <EveDet/AliEveMUONChamberData.h>
23 #include <EveBase/AliEveEventManager.h>
25 #include <AliRawReader.h>
26 #include <AliRawReaderFile.h>
27 #include <AliRawReaderDate.h>
28 #include <AliRawReaderRoot.h>
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"
41 #include "TClonesArray.h"
45 //______________________________________________________________________________
49 ClassImp(AliEveMUONData)
51 AliRawReader* AliEveMUONData::fgRawReader = 0;
53 //______________________________________________________________________________
54 AliEveMUONData::AliEveMUONData() :
62 for (Int_t i = 0; i < 256; i++) {
70 //______________________________________________________________________________
71 AliEveMUONData::~AliEveMUONData()
81 //______________________________________________________________________________
82 void AliEveMUONData::Reset()
91 for (Int_t i = 0; i < 256; i++) {
97 //______________________________________________________________________________
98 AliEveMUONData::AliEveMUONData(const AliEveMUONData &mdata) :
110 //______________________________________________________________________________
111 AliEveMUONData& AliEveMUONData::operator=(const AliEveMUONData &mdata)
114 // Assignment operator
117 if (this != &mdata) {
125 //______________________________________________________________________________
126 void AliEveMUONData::CreateChamber(Int_t chamber)
129 // create data for the chamber with id=chamber (0 to 13)
132 if (fChambers[chamber] == 0)
133 fChambers[chamber] = new AliEveMUONChamberData(chamber);
137 //______________________________________________________________________________
138 void AliEveMUONData::CreateAllChambers()
141 // create all 14 chambers data
144 for (Int_t c = 0; c < 14; ++c)
149 //______________________________________________________________________________
150 void AliEveMUONData::DropAllChambers()
153 // release data from all chambers
156 for (Int_t c = 0; c < 14; ++c) {
158 if (fChambers[c] != 0)
159 fChambers[c]->DropData();
165 //______________________________________________________________________________
166 void AliEveMUONData::DeleteAllChambers()
169 // delete all chambers data
172 for (Int_t c = 0; c < 14; ++c) {
181 //______________________________________________________________________________
182 void AliEveMUONData::RegisterTrack(Int_t track)
185 // register (in a list) a track with hits in the chambers
188 if (fNTrackList == (256-1)) {
189 cout << "Maximum of registered tracks reached..." << endl;
193 Bool_t inList = kFALSE;
194 for (Int_t i = 0; i < fNTrackList; i++) {
195 if (track == fTrackList[i]) {
201 fTrackList[fNTrackList] = track;
207 //______________________________________________________________________________
208 void AliEveMUONData::LoadRecPoints(TTree* tree)
211 // load reconstructed points from the TreeR
212 // load local trigger information
215 AliMUONVClusterStore *clusterStore = AliMUONVClusterStore::Create(*tree);
216 clusterStore->Clear();
217 clusterStore->Connect(*tree,kFALSE);
221 AliMUONVCluster *cluster;
223 Double_t clsX, clsY, clsZ, charge;
225 for (Int_t ch = 0; ch < 10; ++ch) {
227 if (fChambers[ch] == 0) continue;
229 TIter next(clusterStore->CreateChamberIterator(ch,ch));
231 while ( ( cluster = static_cast<AliMUONVCluster*>(next()) ) ) {
233 detElemId = cluster->GetDetElemId();
235 clsX = cluster->GetX();
236 clsY = cluster->GetY();
237 clsZ = cluster->GetZ();
238 charge = cluster->GetCharge();
240 fChambers[ch]->RegisterCluster(detElemId,0,clsX,clsY,clsZ,charge);
241 fChambers[ch]->RegisterCluster(detElemId,1,clsX,clsY,clsZ,charge);
251 //______________________________________________________________________________
252 void AliEveMUONData::LoadHits(TTree* tree)
255 // load simulation hits from the TreeH
258 TClonesArray *hits = 0;
260 Int_t cha, detElemId, nhits, ntracks;
261 Float_t hitX, hitY, hitZ;
263 ntracks = tree->GetEntries();
264 tree->SetBranchAddress("MUONHits",&hits);
266 for (Int_t it = 0; it < ntracks; it++) {
269 nhits = hits->GetEntriesFast();
271 for (Int_t ih = 0; ih < nhits; ih++) {
273 mhit = (AliMUONHit*)hits->UncheckedAt(ih);
277 detElemId = mhit->DetElemId();
278 cha = mhit->Chamber();
280 RegisterTrack(mhit->GetTrack());
282 fChambers[cha-1]->RegisterHit(detElemId,hitX,hitY,hitZ);
289 //______________________________________________________________________________
290 void AliEveMUONData::LoadDigits(TTree* tree)
293 // load digits from the TreeD
296 AliMUONVDigitStore *digitStore = AliMUONVDigitStore::Create(*tree);
298 digitStore->Connect(*tree,0);
302 AliMUONVDigit* digit;
303 TIter next(digitStore->CreateIterator());
305 Int_t cathode, detElemId, ix, iy, charge, chamber, adc;
307 while ( ( digit = static_cast<AliMUONVDigit*>(next() ) ) )
309 cathode = digit->Cathode();
312 detElemId = digit->DetElemId();
313 charge = (Int_t)digit->Charge();
315 chamber = detElemId/100 - 1;
317 fChambers[chamber]->RegisterDigit(detElemId,cathode,ix,iy,charge);
319 fChambers[chamber]->RegisterDigit(detElemId,cathode,ix,iy,adc);
327 //______________________________________________________________________________
328 void AliEveMUONData::LoadRaw(TString fileName)
331 // load raw data from fileName; tracker and trigger data
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
345 fgRawReader->RewindEvents();
346 fgRawReader->Reset();
349 while (fgRawReader->NextEvent())
351 if (iEvent != gEvent->GetEventId())
359 AliMUONDigitMaker digitMaker;
361 digitMaker.SetMakeTriggerDigits(kTRUE);
363 AliMUONDigitStoreV1 digitStore;
365 digitMaker.Raw2Digits(fgRawReader,&digitStore);
367 AliMUONVDigit* digit;
368 TIter next(digitStore.CreateIterator());
370 Int_t cathode, detElemId, ix, iy, charge, chamber, adc;
372 while ( ( digit = static_cast<AliMUONVDigit*>(next() ) ) )
374 cathode = digit->Cathode();
377 detElemId = digit->DetElemId();
378 charge = (Int_t)digit->Charge();
380 chamber = detElemId/100 - 1;
382 fChambers[chamber]->RegisterDigit(detElemId,cathode,ix,iy,charge);
384 fChambers[chamber]->RegisterDigit(detElemId,cathode,ix,iy,adc);
390 //______________________________________________________________________________
391 Int_t AliEveMUONData::GetTrack(Int_t index)
394 // return track stack number for "index"-th track with hits in the chambers
398 return fTrackList[index];
405 //______________________________________________________________________________
406 AliEveMUONChamberData* AliEveMUONData::GetChamberData(Int_t chamber)
409 // return chamber data
412 if (chamber < 0 || chamber > 13) return 0;
414 //if (fChambers[chamber] == 0) CreateChamber(chamber);
416 return fChambers[chamber];