4 // GetTrackerMapping = AliMUONDigitMaker::GetMapping
5 // GetTriggerMapping = AliMUONDigitMaker::TriggerDigits
6 // GetTriggerChamber = AliMUONDigitMaker::GetTriggerChamber
7 // LoadRawTracker = MUONRawStreamTracker.C
8 // LoadRawTrigger = MUONRawStreamTrigger.C
13 #include <Alieve/MUONChamberData.h>
14 #include <Alieve/EventAlieve.h>
16 #include <AliRawReader.h>
17 #include <AliRawReaderFile.h>
18 #include <AliRawReaderDate.h>
19 #include <AliRawReaderRoot.h>
23 #include <AliMUONDigitMaker.h>
24 #include <AliMUONHit.h>
25 #include <AliMUONRawCluster.h>
26 #include <AliMUONVDigit.h>
27 #include "AliMUONDigitStoreV1.h"
30 #include "TClonesArray.h"
34 using namespace Alieve;
36 //______________________________________________________________________
42 AliRawReader* MUONData::fgRawReader = 0;
44 //______________________________________________________________________
45 MUONData::MUONData() :
53 for (Int_t i = 0; i < 256; i++) {
61 //______________________________________________________________________
72 //______________________________________________________________________
73 void MUONData::Reset()
82 for (Int_t i = 0; i < 256; i++) {
88 //______________________________________________________________________
89 MUONData::MUONData(const MUONData &mdata) :
91 Reve::ReferenceCount(),
101 //______________________________________________________________________
102 MUONData& MUONData::operator=(const MUONData &mdata)
105 // Assignment operator
108 if (this != &mdata) {
116 //______________________________________________________________________
117 void MUONData::CreateChamber(Int_t chamber)
120 // create data for the chamber with id=chamber (0 to 13)
123 if (fChambers[chamber] == 0)
124 fChambers[chamber] = new MUONChamberData(chamber);
128 //______________________________________________________________________
129 void MUONData::CreateAllChambers()
132 // create all 14 chambers data
135 for (Int_t c = 0; c < 14; ++c)
140 //______________________________________________________________________
141 void MUONData::DropAllChambers()
144 // release data from all chambers
147 for (Int_t c = 0; c < 14; ++c) {
149 if (fChambers[c] != 0)
150 fChambers[c]->DropData();
156 //______________________________________________________________________
157 void MUONData::DeleteAllChambers()
160 // delete all chambers data
163 for (Int_t c = 0; c < 14; ++c) {
172 //______________________________________________________________________
173 void MUONData::RegisterTrack(Int_t track)
176 // register (in a list) a track with hits in the chambers
179 if (fNTrackList == (256-1)) {
180 cout << "Maximum of registered tracks reached..." << endl;
184 Bool_t inList = kFALSE;
185 for (Int_t i = 0; i < fNTrackList; i++) {
186 if (track == fTrackList[i]) {
192 fTrackList[fNTrackList] = track;
198 //______________________________________________________________________
199 void MUONData::LoadRecPoints(TTree* tree)
202 // load reconstructed points from the TreeR
203 // load local trigger information
206 Char_t branchname[30];
207 TClonesArray *clusters = 0;
209 AliMUONRawCluster *mcls;
211 Float_t clsX, clsY, clsZ, charge;
213 for (Int_t c = 0; c < 10; ++c) {
215 if (fChambers[c] == 0) continue;
216 sprintf(branchname,"MUONRawClusters%d",c+1);
217 tree->SetBranchAddress(branchname,&clusters);
220 nclusters = clusters->GetEntriesFast();
222 for (Int_t ic = 0; ic < nclusters; ic++) {
223 mcls = (AliMUONRawCluster*)clusters->UncheckedAt(ic);
225 detElemId = mcls->GetDetElemId();
226 for (Int_t icath = 0; icath < 2; icath++) {
227 clsX = mcls->GetX(icath);
228 clsY = mcls->GetY(icath);
229 clsZ = mcls->GetZ(icath);
230 charge = mcls->GetCharge(icath);
232 fChambers[c]->RegisterCluster(detElemId,icath,clsX,clsY,clsZ,charge);
241 //______________________________________________________________________
242 void MUONData::LoadHits(TTree* tree)
245 // load simulation hits from the TreeH
248 TClonesArray *hits = 0;
250 Int_t cha, detElemId, nhits, ntracks;
251 Float_t hitX, hitY, hitZ;
253 ntracks = tree->GetEntries();
254 tree->SetBranchAddress("MUONHits",&hits);
256 for (Int_t it = 0; it < ntracks; it++) {
259 nhits = hits->GetEntriesFast();
261 for (Int_t ih = 0; ih < nhits; ih++) {
263 mhit = (AliMUONHit*)hits->UncheckedAt(ih);
267 detElemId = mhit->DetElemId();
268 cha = mhit->Chamber();
270 RegisterTrack(mhit->GetTrack());
272 fChambers[cha-1]->RegisterHit(detElemId,hitX,hitY,hitZ);
279 //______________________________________________________________________
280 void MUONData::LoadRaw(TString fileName)
283 // load raw data from fileName; tracker and trigger data
286 if (fgRawReader == 0) {
287 // check extention to choose the rawdata file format
288 if (fileName.EndsWith("/")) {
289 fgRawReader = new AliRawReaderFile(fileName); // DDL files
290 } else if (fileName.EndsWith(".root")) {
291 fgRawReader = new AliRawReaderRoot(fileName); // ROOT file
292 } else if (!fileName.IsNull()) {
293 fgRawReader = new AliRawReaderDate(fileName); // DATE file
297 fgRawReader->RewindEvents();
298 fgRawReader->Reset();
301 while (fgRawReader->NextEvent())
303 if (iEvent != Alieve::gEvent->GetEventId())
311 AliMUONDigitMaker digitMaker;
313 digitMaker.SetMakeTriggerDigits(kTRUE);
315 AliMUONDigitStoreV1 digitStore;
317 digitMaker.Raw2Digits(fgRawReader,&digitStore);
319 AliMUONVDigit* digit;
320 TIter next(digitStore.CreateIterator());
322 Int_t cathode, detElemId, ix, iy, charge, chamber;
324 while ( ( digit = static_cast<AliMUONVDigit*>(next() ) ) )
326 cathode = digit->Cathode();
329 detElemId = digit->DetElemId();
330 charge = (Int_t)digit->Charge();
331 chamber = detElemId/100 - 1;
332 fChambers[chamber]->RegisterDigit(detElemId,cathode,ix,iy,charge);
336 //______________________________________________________________________
337 Int_t MUONData::GetTrack(Int_t index)
340 // return track stack number for "index"-th track with hits in the chambers
344 return fTrackList[index];
351 //______________________________________________________________________
352 MUONChamberData* MUONData::GetChamberData(Int_t chamber)
355 // return chamber data
358 if (chamber < 0 || chamber > 13) return 0;
360 //if (fChambers[chamber] == 0) CreateChamber(chamber);
362 return fChambers[chamber];