IO test for Interpolator
[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"
3626c858 28#include "TTree.h"
29#include "TString.h"
3626c858 30#include "TClonesArray.h"
cef26510 31#include "TList.h"
3626c858 32
33using namespace Reve;
34using namespace Alieve;
35
36//______________________________________________________________________
37// MUONData
38//
39
40ClassImp(MUONData)
41
42AliRawReader* MUONData::fgRawReader = 0;
3626c858 43
44//______________________________________________________________________
45MUONData::MUONData() :
eadce74d 46 fChambers(14),
47 fNTrackList(0)
3626c858 48{
49 //
50 // Constructor
51 //
52
cef26510 53 for (Int_t i = 0; i < 256; i++) {
eadce74d 54 fTrackList[i] = -1;
55 }
56
3626c858 57 CreateAllChambers();
58
59}
60
61//______________________________________________________________________
62MUONData::~MUONData()
63{
64 //
65 // Destructor
66 //
67
68 DeleteAllChambers();
69
3626c858 70}
71
eadce74d 72//______________________________________________________________________
73void MUONData::Reset()
74{
75 //
76 // Reset data
77 //
78
79 //DropAllChambers();
80
81 fNTrackList = 0;
cef26510 82 for (Int_t i = 0; i < 256; i++) {
eadce74d 83 fTrackList[i] = -1;
84 }
85
86}
87
3626c858 88//______________________________________________________________________
89MUONData::MUONData(const MUONData &mdata) :
e4204218 90 TObject(mdata),
8d33d1c2 91 Reve::ReferenceCount(),
92 fChambers(14),
93 fNTrackList(0)
3626c858 94{
95 //
96 // Copy constructor
97 //
98
99}
100
101//______________________________________________________________________
102MUONData& MUONData::operator=(const MUONData &mdata)
103{
104 //
105 // Assignment operator
106 //
107
108 if (this != &mdata) {
109
110 }
111
112 return *this;
113
114}
115
116//______________________________________________________________________
117void MUONData::CreateChamber(Int_t chamber)
118{
119 //
120 // create data for the chamber with id=chamber (0 to 13)
121 //
122
123 if (fChambers[chamber] == 0)
124 fChambers[chamber] = new MUONChamberData(chamber);
125
126}
127
128//______________________________________________________________________
129void MUONData::CreateAllChambers()
130{
131 //
132 // create all 14 chambers data
133 //
134
135 for (Int_t c = 0; c < 14; ++c)
136 CreateChamber(c);
137
138}
139
140//______________________________________________________________________
141void MUONData::DropAllChambers()
142{
143 //
144 // release data from all chambers
145 //
146
147 for (Int_t c = 0; c < 14; ++c) {
148
149 if (fChambers[c] != 0)
150 fChambers[c]->DropData();
151
152 }
153
154}
155
156//______________________________________________________________________
157void MUONData::DeleteAllChambers()
158{
159 //
160 // delete all chambers data
161 //
162
163 for (Int_t c = 0; c < 14; ++c) {
164
165 delete fChambers[c];
166 fChambers[c] = 0;
167
168 }
169
170}
171
eadce74d 172//______________________________________________________________________
173void MUONData::RegisterTrack(Int_t track)
174{
175 //
176 // register (in a list) a track with hits in the chambers
177 //
178
cef26510 179 if (fNTrackList == (256-1)) {
eadce74d 180 cout << "Maximum of registered tracks reached..." << endl;
181 return;
182 }
183
184 Bool_t inList = kFALSE;
185 for (Int_t i = 0; i < fNTrackList; i++) {
186 if (track == fTrackList[i]) {
187 inList = kTRUE;
188 break;
189 }
190 }
191 if (!inList) {
192 fTrackList[fNTrackList] = track;
193 fNTrackList++;
194 }
195
196}
197
2674c15a 198//______________________________________________________________________
eadce74d 199void MUONData::LoadRecPoints(TTree* tree)
2674c15a 200{
201 //
202 // load reconstructed points from the TreeR
203 // load local trigger information
204 //
205
eadce74d 206 Char_t branchname[30];
207 TClonesArray *clusters = 0;
208 Int_t nclusters;
209 AliMUONRawCluster *mcls;
210 Int_t detElemId;
211 Float_t clsX, clsY, clsZ, charge;
212
213 for (Int_t c = 0; c < 10; ++c) {
214
215 if (fChambers[c] == 0) continue;
216 sprintf(branchname,"MUONRawClusters%d",c+1);
217 tree->SetBranchAddress(branchname,&clusters);
218 tree->GetEntry(0);
219
220 nclusters = clusters->GetEntriesFast();
221
222 for (Int_t ic = 0; ic < nclusters; ic++) {
223 mcls = (AliMUONRawCluster*)clusters->UncheckedAt(ic);
224
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);
231
232 fChambers[c]->RegisterCluster(detElemId,icath,clsX,clsY,clsZ,charge);
233 }
234
235 }
236
237 }
238
239}
240
241//______________________________________________________________________
242void MUONData::LoadHits(TTree* tree)
243{
244 //
245 // load simulation hits from the TreeH
246 //
247
248 TClonesArray *hits = 0;
249 AliMUONHit *mhit;
250 Int_t cha, detElemId, nhits, ntracks;
251 Float_t hitX, hitY, hitZ;
252
253 ntracks = tree->GetEntries();
254 tree->SetBranchAddress("MUONHits",&hits);
255
256 for (Int_t it = 0; it < ntracks; it++) {
257
258 tree->GetEvent(it);
259 nhits = hits->GetEntriesFast();
260
261 for (Int_t ih = 0; ih < nhits; ih++) {
262
263 mhit = (AliMUONHit*)hits->UncheckedAt(ih);
264 hitX = mhit->X();
265 hitY = mhit->Y();
266 hitZ = mhit->Z();
267 detElemId = mhit->DetElemId();
268 cha = mhit->Chamber();
269
270 RegisterTrack(mhit->GetTrack());
271
272 fChambers[cha-1]->RegisterHit(detElemId,hitX,hitY,hitZ);
273
274 }
275 }
276
2674c15a 277}
278
3626c858 279//______________________________________________________________________
280void MUONData::LoadRaw(TString fileName)
281{
282 //
283 // load raw data from fileName; tracker and trigger data
284 //
285
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
294 }
3626c858 295 }
296
3626c858 297 fgRawReader->RewindEvents();
cef26510 298 fgRawReader->Reset();
3626c858 299
300 Int_t iEvent = 0;
8d33d1c2 301 while (fgRawReader->NextEvent())
302 {
303 if (iEvent != Alieve::gEvent->GetEventId())
304 {
3626c858 305 iEvent++;
306 continue;
307 }
3626c858 308 break;
cef26510 309 }
3626c858 310
8d33d1c2 311 AliMUONDigitMaker digitMaker;
3626c858 312
8d33d1c2 313 digitMaker.SetMakeTriggerDigits(kTRUE);
3626c858 314
8d33d1c2 315 AliMUONDigitStoreV1 digitStore;
316
317 digitMaker.Raw2Digits(fgRawReader,&digitStore);
3626c858 318
8d33d1c2 319 AliMUONVDigit* digit;
320 TIter next(digitStore.CreateIterator());
321
322 Int_t cathode, detElemId, ix, iy, charge, chamber;
323
324 while ( ( digit = static_cast<AliMUONVDigit*>(next() ) ) )
325 {
cef26510 326 cathode = digit->Cathode();
327 ix = digit->PadX();
328 iy = digit->PadY();
329 detElemId = digit->DetElemId();
8d33d1c2 330 charge = (Int_t)digit->Charge();
cef26510 331 chamber = detElemId/100 - 1;
332 fChambers[chamber]->RegisterDigit(detElemId,cathode,ix,iy,charge);
cef26510 333 }
3626c858 334}
335
eadce74d 336//______________________________________________________________________
337Int_t MUONData::GetTrack(Int_t index)
338{
339 //
340 // return track stack number for "index"-th track with hits in the chambers
341 //
342
cef26510 343 if (index < 256) {
eadce74d 344 return fTrackList[index];
345 } else {
346 return -1;
347 }
348
349}
350
3626c858 351//______________________________________________________________________
352MUONChamberData* MUONData::GetChamberData(Int_t chamber)
353{
354 //
355 // return chamber data
356 //
357
358 if (chamber < 0 || chamber > 13) return 0;
359
360 //if (fChambers[chamber] == 0) CreateChamber(chamber);
361
362 return fChambers[chamber];
363
364}