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 <AliMUONDigit.h>
27 #include <AliMUONTriggerCrateStore.h>
28 #include <AliMUONData.h>
32 #include "TClonesArray.h"
36 using namespace Alieve;
38 //______________________________________________________________________
44 AliRawReader* MUONData::fgRawReader = 0;
46 //______________________________________________________________________
47 MUONData::MUONData() :
55 for (Int_t i = 0; i < 256; i++) {
63 //______________________________________________________________________
74 //______________________________________________________________________
75 void MUONData::Reset()
84 for (Int_t i = 0; i < 256; i++) {
90 //______________________________________________________________________
91 MUONData::MUONData(const MUONData &mdata) :
93 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::LoadDigits(TTree* tree)
202 // load digits from the TreeD
205 Char_t branchname[30];
206 TClonesArray *digits = 0;
209 Int_t cathode, detElemId, ix, iy, charge;
211 for (Int_t c = 0; c < 14; ++c) {
213 if (fChambers[c] == 0) continue;
214 sprintf(branchname,"MUONDigits%d",c+1);
215 tree->SetBranchAddress(branchname,&digits);
218 ndigits = digits->GetEntriesFast();
220 for (Int_t id = 0; id < ndigits; id++) {
221 mdig = (AliMUONDigit*)digits->UncheckedAt(id);
223 cathode = mdig->Cathode();
226 detElemId = mdig->DetElemId();
227 charge = (Int_t)mdig->Signal();
229 fChambers[c]->RegisterDigit(detElemId,cathode,ix,iy,charge);
237 //______________________________________________________________________
238 void MUONData::LoadRecPoints(TTree* tree)
241 // load reconstructed points from the TreeR
242 // load local trigger information
245 Char_t branchname[30];
246 TClonesArray *clusters = 0;
248 AliMUONRawCluster *mcls;
250 Float_t clsX, clsY, clsZ, charge;
252 for (Int_t c = 0; c < 10; ++c) {
254 if (fChambers[c] == 0) continue;
255 sprintf(branchname,"MUONRawClusters%d",c+1);
256 tree->SetBranchAddress(branchname,&clusters);
259 nclusters = clusters->GetEntriesFast();
261 for (Int_t ic = 0; ic < nclusters; ic++) {
262 mcls = (AliMUONRawCluster*)clusters->UncheckedAt(ic);
264 detElemId = mcls->GetDetElemId();
265 for (Int_t icath = 0; icath < 2; icath++) {
266 clsX = mcls->GetX(icath);
267 clsY = mcls->GetY(icath);
268 clsZ = mcls->GetZ(icath);
269 charge = mcls->GetCharge(icath);
271 fChambers[c]->RegisterCluster(detElemId,icath,clsX,clsY,clsZ,charge);
280 //______________________________________________________________________
281 void MUONData::LoadHits(TTree* tree)
284 // load simulation hits from the TreeH
287 TClonesArray *hits = 0;
289 Int_t cha, detElemId, nhits, ntracks;
290 Float_t hitX, hitY, hitZ;
292 ntracks = tree->GetEntries();
293 tree->SetBranchAddress("MUONHits",&hits);
295 for (Int_t it = 0; it < ntracks; it++) {
298 nhits = hits->GetEntriesFast();
300 for (Int_t ih = 0; ih < nhits; ih++) {
302 mhit = (AliMUONHit*)hits->UncheckedAt(ih);
306 detElemId = mhit->DetElemId();
307 cha = mhit->Chamber();
309 RegisterTrack(mhit->GetTrack());
311 fChambers[cha-1]->RegisterHit(detElemId,hitX,hitY,hitZ);
318 //______________________________________________________________________
319 void MUONData::LoadRaw(TString fileName)
322 // load raw data from fileName; tracker and trigger data
325 if (fgRawReader == 0) {
326 // check extention to choose the rawdata file format
327 if (fileName.EndsWith("/")) {
328 fgRawReader = new AliRawReaderFile(fileName); // DDL files
329 } else if (fileName.EndsWith(".root")) {
330 fgRawReader = new AliRawReaderRoot(fileName); // ROOT file
331 } else if (!fileName.IsNull()) {
332 fgRawReader = new AliRawReaderDate(fileName); // DATE file
336 fgRawReader->RewindEvents();
337 fgRawReader->Reset();
340 while (fgRawReader->NextEvent()) {
341 if (iEvent != Alieve::gEvent->GetEventId()) {
348 AliMUONDigitMaker *digitMaker = new AliMUONDigitMaker();
350 AliMUONTriggerCrateStore *crateManager = new AliMUONTriggerCrateStore();
351 crateManager->ReadFromFile();
353 AliMUONData *muonData = new AliMUONData(0x0,"MUON","MUON");
355 digitMaker->SetDisplayFlag();
356 digitMaker->SetCrateManager(crateManager);
357 digitMaker->SetMUONData(muonData);
358 muonData->SetDataContainer("D, GLT");
360 digitMaker->Raw2Digits(fgRawReader);
363 Int_t cathode, detElemId, ix, iy, charge, chamber, ndigits;
364 for (chamber = 0; chamber < 14; chamber++) {
365 ndigits = (Int_t)muonData->Digits(chamber)->GetEntriesFast();
366 for (Int_t id = 0; id < ndigits; id++) {
367 digit = static_cast<AliMUONDigit*>(muonData->Digits(chamber)->At(id));
368 cathode = digit->Cathode();
371 detElemId = digit->DetElemId();
372 charge = (Int_t)digit->Signal();
373 chamber = detElemId/100 - 1;
374 fChambers[chamber]->RegisterDigit(detElemId,cathode,ix,iy,charge);
384 //______________________________________________________________________
385 Int_t MUONData::GetTrack(Int_t index)
388 // return track stack number for "index"-th track with hits in the chambers
392 return fTrackList[index];
399 //______________________________________________________________________
400 MUONChamberData* MUONData::GetChamberData(Int_t chamber)
403 // return chamber data
406 if (chamber < 0 || chamber > 13) return 0;
408 //if (fChambers[chamber] == 0) CreateChamber(chamber);
410 return fChambers[chamber];