]> git.uio.no Git - u/mrichter/AliRoot.git/blame - EVE/Alieve/MUONData.cxx
Changes due to removal of AliMUONSim/RecData (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>
3626c858 27#include <AliMUONTriggerCrateStore.h>
8d33d1c2 28#include "AliMUONDigitStoreV1.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
3626c858 280//______________________________________________________________________
281void MUONData::LoadRaw(TString fileName)
282{
283 //
284 // load raw data from fileName; tracker and trigger data
285 //
286
287 if (fgRawReader == 0) {
288 // check extention to choose the rawdata file format
289 if (fileName.EndsWith("/")) {
290 fgRawReader = new AliRawReaderFile(fileName); // DDL files
291 } else if (fileName.EndsWith(".root")) {
292 fgRawReader = new AliRawReaderRoot(fileName); // ROOT file
293 } else if (!fileName.IsNull()) {
294 fgRawReader = new AliRawReaderDate(fileName); // DATE file
295 }
3626c858 296 }
297
3626c858 298 fgRawReader->RewindEvents();
cef26510 299 fgRawReader->Reset();
3626c858 300
301 Int_t iEvent = 0;
8d33d1c2 302 while (fgRawReader->NextEvent())
303 {
304 if (iEvent != Alieve::gEvent->GetEventId())
305 {
3626c858 306 iEvent++;
307 continue;
308 }
3626c858 309 break;
cef26510 310 }
3626c858 311
8d33d1c2 312 AliMUONDigitMaker digitMaker;
3626c858 313
8d33d1c2 314 AliMUONTriggerCrateStore crateManager;
315 crateManager.ReadFromFile();
3626c858 316
8d33d1c2 317 digitMaker.SetMakeTriggerDigits(kTRUE);
318 digitMaker.SetCrateManager(&crateManager);
3626c858 319
8d33d1c2 320 AliMUONDigitStoreV1 digitStore;
321
322 digitMaker.Raw2Digits(fgRawReader,&digitStore);
3626c858 323
8d33d1c2 324 AliMUONVDigit* digit;
325 TIter next(digitStore.CreateIterator());
326
327 Int_t cathode, detElemId, ix, iy, charge, chamber;
328
329 while ( ( digit = static_cast<AliMUONVDigit*>(next() ) ) )
330 {
cef26510 331 cathode = digit->Cathode();
332 ix = digit->PadX();
333 iy = digit->PadY();
334 detElemId = digit->DetElemId();
8d33d1c2 335 charge = (Int_t)digit->Charge();
cef26510 336 chamber = detElemId/100 - 1;
337 fChambers[chamber]->RegisterDigit(detElemId,cathode,ix,iy,charge);
cef26510 338 }
3626c858 339}
340
eadce74d 341//______________________________________________________________________
342Int_t MUONData::GetTrack(Int_t index)
343{
344 //
345 // return track stack number for "index"-th track with hits in the chambers
346 //
347
cef26510 348 if (index < 256) {
eadce74d 349 return fTrackList[index];
350 } else {
351 return -1;
352 }
353
354}
355
3626c858 356//______________________________________________________________________
357MUONChamberData* MUONData::GetChamberData(Int_t chamber)
358{
359 //
360 // return chamber data
361 //
362
363 if (chamber < 0 || chamber > 13) return 0;
364
365 //if (fChambers[chamber] == 0) CreateChamber(chamber);
366
367 return fChambers[chamber];
368
369}