Adding class AliMUONClusterStoreV2 (Philippe P., Laurent)
[u/mrichter/AliRoot.git] / EVE / Alieve / MUONData.cxx
CommitLineData
3626c858 1//
2// Sources:
3//
4// GetTrackerMapping = AliMUONDigitMaker::GetMapping
5// GetTriggerMapping = AliMUONDigitMaker::TriggerDigits
6// GetTriggerChamber = AliMUONDigitMaker::GetTriggerChamber
7// LoadRawTracker = MUONRawStreamTracker.C
8// LoadRawTrigger = MUONRawStreamTrigger.C
9//
10
11#include "MUONData.h"
12
13#include <Alieve/MUONChamberData.h>
14#include <Alieve/EventAlieve.h>
15
16#include <AliRawReader.h>
17#include <AliRawReaderFile.h>
18#include <AliRawReaderDate.h>
19#include <AliRawReaderRoot.h>
20
361fa326 21#include <AliLog.h>
3626c858 22
cef26510 23#include <AliMUONDigitMaker.h>
eadce74d 24#include <AliMUONHit.h>
25#include <AliMUONRawCluster.h>
8d33d1c2 26#include <AliMUONVDigit.h>
8d33d1c2 27#include "AliMUONDigitStoreV1.h"
832dd5c9 28#include "AliMUONVDigitStore.h"
3626c858 29#include "TTree.h"
30#include "TString.h"
3626c858 31#include "TClonesArray.h"
cef26510 32#include "TList.h"
3626c858 33
34using namespace Reve;
35using namespace Alieve;
36
37//______________________________________________________________________
38// MUONData
39//
40
41ClassImp(MUONData)
42
43AliRawReader* MUONData::fgRawReader = 0;
3626c858 44
45//______________________________________________________________________
46MUONData::MUONData() :
eadce74d 47 fChambers(14),
48 fNTrackList(0)
3626c858 49{
50 //
51 // Constructor
52 //
53
cef26510 54 for (Int_t i = 0; i < 256; i++) {
eadce74d 55 fTrackList[i] = -1;
56 }
57
3626c858 58 CreateAllChambers();
59
60}
61
62//______________________________________________________________________
63MUONData::~MUONData()
64{
65 //
66 // Destructor
67 //
68
69 DeleteAllChambers();
70
3626c858 71}
72
eadce74d 73//______________________________________________________________________
74void MUONData::Reset()
75{
76 //
77 // Reset data
78 //
79
80 //DropAllChambers();
81
82 fNTrackList = 0;
cef26510 83 for (Int_t i = 0; i < 256; i++) {
eadce74d 84 fTrackList[i] = -1;
85 }
86
87}
88
3626c858 89//______________________________________________________________________
90MUONData::MUONData(const MUONData &mdata) :
e4204218 91 TObject(mdata),
8d33d1c2 92 Reve::ReferenceCount(),
93 fChambers(14),
94 fNTrackList(0)
3626c858 95{
96 //
97 // Copy constructor
98 //
99
100}
101
102//______________________________________________________________________
103MUONData& MUONData::operator=(const MUONData &mdata)
104{
105 //
106 // Assignment operator
107 //
108
109 if (this != &mdata) {
110
111 }
112
113 return *this;
114
115}
116
117//______________________________________________________________________
118void MUONData::CreateChamber(Int_t chamber)
119{
120 //
121 // create data for the chamber with id=chamber (0 to 13)
122 //
123
124 if (fChambers[chamber] == 0)
125 fChambers[chamber] = new MUONChamberData(chamber);
126
127}
128
129//______________________________________________________________________
130void MUONData::CreateAllChambers()
131{
132 //
133 // create all 14 chambers data
134 //
135
136 for (Int_t c = 0; c < 14; ++c)
137 CreateChamber(c);
138
139}
140
141//______________________________________________________________________
142void MUONData::DropAllChambers()
143{
144 //
145 // release data from all chambers
146 //
147
148 for (Int_t c = 0; c < 14; ++c) {
149
150 if (fChambers[c] != 0)
151 fChambers[c]->DropData();
152
153 }
154
155}
156
157//______________________________________________________________________
158void MUONData::DeleteAllChambers()
159{
160 //
161 // delete all chambers data
162 //
163
164 for (Int_t c = 0; c < 14; ++c) {
165
166 delete fChambers[c];
167 fChambers[c] = 0;
168
169 }
170
171}
172
eadce74d 173//______________________________________________________________________
174void MUONData::RegisterTrack(Int_t track)
175{
176 //
177 // register (in a list) a track with hits in the chambers
178 //
179
cef26510 180 if (fNTrackList == (256-1)) {
eadce74d 181 cout << "Maximum of registered tracks reached..." << endl;
182 return;
183 }
184
185 Bool_t inList = kFALSE;
186 for (Int_t i = 0; i < fNTrackList; i++) {
187 if (track == fTrackList[i]) {
188 inList = kTRUE;
189 break;
190 }
191 }
192 if (!inList) {
193 fTrackList[fNTrackList] = track;
194 fNTrackList++;
195 }
196
197}
198
2674c15a 199//______________________________________________________________________
eadce74d 200void MUONData::LoadRecPoints(TTree* tree)
2674c15a 201{
202 //
203 // load reconstructed points from the TreeR
204 // load local trigger information
205 //
206
eadce74d 207 Char_t branchname[30];
208 TClonesArray *clusters = 0;
209 Int_t nclusters;
210 AliMUONRawCluster *mcls;
211 Int_t detElemId;
212 Float_t clsX, clsY, clsZ, charge;
213
214 for (Int_t c = 0; c < 10; ++c) {
215
216 if (fChambers[c] == 0) continue;
217 sprintf(branchname,"MUONRawClusters%d",c+1);
218 tree->SetBranchAddress(branchname,&clusters);
219 tree->GetEntry(0);
220
221 nclusters = clusters->GetEntriesFast();
222
223 for (Int_t ic = 0; ic < nclusters; ic++) {
224 mcls = (AliMUONRawCluster*)clusters->UncheckedAt(ic);
225
226 detElemId = mcls->GetDetElemId();
227 for (Int_t icath = 0; icath < 2; icath++) {
228 clsX = mcls->GetX(icath);
229 clsY = mcls->GetY(icath);
230 clsZ = mcls->GetZ(icath);
231 charge = mcls->GetCharge(icath);
232
233 fChambers[c]->RegisterCluster(detElemId,icath,clsX,clsY,clsZ,charge);
234 }
235
236 }
237
238 }
239
240}
241
242//______________________________________________________________________
243void MUONData::LoadHits(TTree* tree)
244{
245 //
246 // load simulation hits from the TreeH
247 //
248
249 TClonesArray *hits = 0;
250 AliMUONHit *mhit;
251 Int_t cha, detElemId, nhits, ntracks;
252 Float_t hitX, hitY, hitZ;
253
254 ntracks = tree->GetEntries();
255 tree->SetBranchAddress("MUONHits",&hits);
256
257 for (Int_t it = 0; it < ntracks; it++) {
258
259 tree->GetEvent(it);
260 nhits = hits->GetEntriesFast();
261
262 for (Int_t ih = 0; ih < nhits; ih++) {
263
264 mhit = (AliMUONHit*)hits->UncheckedAt(ih);
265 hitX = mhit->X();
266 hitY = mhit->Y();
267 hitZ = mhit->Z();
268 detElemId = mhit->DetElemId();
269 cha = mhit->Chamber();
270
271 RegisterTrack(mhit->GetTrack());
272
273 fChambers[cha-1]->RegisterHit(detElemId,hitX,hitY,hitZ);
274
275 }
276 }
277
2674c15a 278}
279
832dd5c9 280//______________________________________________________________________
281void MUONData::LoadDigits(TTree* tree)
282{
283 //
284 // load digits from the TreeD
285 //
286
287 AliMUONVDigitStore *digitStore = AliMUONVDigitStore::Create(*tree);
288 digitStore->Clear();
289 digitStore->Connect(*tree,0);
290
291 tree->GetEvent(0);
292
293 AliMUONVDigit* digit;
294 TIter next(digitStore->CreateIterator());
295
296 Int_t cathode, detElemId, ix, iy, charge, chamber, adc;
297
298 while ( ( digit = static_cast<AliMUONVDigit*>(next() ) ) )
299 {
300 cathode = digit->Cathode();
301 ix = digit->PadX();
302 iy = digit->PadY();
303 detElemId = digit->DetElemId();
304 charge = (Int_t)digit->Charge();
305 adc = digit->ADC();
306 chamber = detElemId/100 - 1;
307 if (chamber > 9) {
308 fChambers[chamber]->RegisterDigit(detElemId,cathode,ix,iy,charge);
309 } else {
310 fChambers[chamber]->RegisterDigit(detElemId,cathode,ix,iy,adc);
311 }
312 }
313
314 delete digitStore;
315
316}
317
3626c858 318//______________________________________________________________________
319void MUONData::LoadRaw(TString fileName)
320{
321 //
322 // load raw data from fileName; tracker and trigger data
323 //
324
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
333 }
3626c858 334 }
335
3626c858 336 fgRawReader->RewindEvents();
cef26510 337 fgRawReader->Reset();
3626c858 338
339 Int_t iEvent = 0;
8d33d1c2 340 while (fgRawReader->NextEvent())
341 {
342 if (iEvent != Alieve::gEvent->GetEventId())
343 {
3626c858 344 iEvent++;
345 continue;
346 }
3626c858 347 break;
cef26510 348 }
3626c858 349
8d33d1c2 350 AliMUONDigitMaker digitMaker;
3626c858 351
8d33d1c2 352 digitMaker.SetMakeTriggerDigits(kTRUE);
3626c858 353
8d33d1c2 354 AliMUONDigitStoreV1 digitStore;
355
356 digitMaker.Raw2Digits(fgRawReader,&digitStore);
3626c858 357
8d33d1c2 358 AliMUONVDigit* digit;
359 TIter next(digitStore.CreateIterator());
360
832dd5c9 361 Int_t cathode, detElemId, ix, iy, charge, chamber, adc;
8d33d1c2 362
363 while ( ( digit = static_cast<AliMUONVDigit*>(next() ) ) )
364 {
cef26510 365 cathode = digit->Cathode();
366 ix = digit->PadX();
367 iy = digit->PadY();
368 detElemId = digit->DetElemId();
8d33d1c2 369 charge = (Int_t)digit->Charge();
832dd5c9 370 adc = digit->ADC();
cef26510 371 chamber = detElemId/100 - 1;
832dd5c9 372 if (chamber > 9) {
373 fChambers[chamber]->RegisterDigit(detElemId,cathode,ix,iy,charge);
374 } else {
375 fChambers[chamber]->RegisterDigit(detElemId,cathode,ix,iy,adc);
376 }
cef26510 377 }
832dd5c9 378
3626c858 379}
380
eadce74d 381//______________________________________________________________________
382Int_t MUONData::GetTrack(Int_t index)
383{
384 //
385 // return track stack number for "index"-th track with hits in the chambers
386 //
387
cef26510 388 if (index < 256) {
eadce74d 389 return fTrackList[index];
390 } else {
391 return -1;
392 }
393
394}
395
3626c858 396//______________________________________________________________________
397MUONChamberData* MUONData::GetChamberData(Int_t chamber)
398{
399 //
400 // return chamber data
401 //
402
403 if (chamber < 0 || chamber > 13) return 0;
404
405 //if (fChambers[chamber] == 0) CreateChamber(chamber);
406
407 return fChambers[chamber];
408
409}