]>
Commit | Line | Data |
---|---|---|
a3283a4c | 1 | /************************************************************************** |
2 | * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * | |
3 | * * | |
4 | * Author: The ALICE Off-line Project. * | |
5 | * Contributors are mentioned in the code where appropriate. * | |
6 | * * | |
7 | * Permission to use, copy, modify and distribute this software and its * | |
8 | * documentation strictly for non-commercial purposes is hereby granted * | |
9 | * without fee, provided that the above copyright notice appears in all * | |
10 | * copies and that both the copyright notice and this permission notice * | |
11 | * appear in the supporting documentation. The authors make no claims * | |
12 | * about the suitability of this software for any purpose. It is * | |
13 | * provided "as is" without express or implied warranty. * | |
14 | **************************************************************************/ | |
15 | ||
16 | //////////////////////////////////// | |
17 | /// | |
18 | /// MUON Digit maker from rawdata in ALICE-MUON | |
19 | /// Using new interface with AliMUONRawStreamTracker(Trigger) | |
20 | /// (New interface of AliMUONRawReader class) | |
21 | /// Class version 1 (further details could be found in Alice-note) | |
22 | /// | |
23 | /// Implemented non-constant buspatch numbers for tracking | |
24 | /// with correct DDL id (first guess) | |
25 | /// (Ch. Finck, dec 2005) | |
26 | /// | |
27 | /// | |
28 | /// Raw2Digits: | |
29 | /// Using real mapping for tracker | |
30 | /// Indranil Das (Adapted for runloader: Ch. Finck) july 05 | |
31 | /// Add reader for scaler trigger events | |
32 | /// Use memcpy instead of assignment elt by elt | |
33 | /// (Ch. Finck, Jan 06) | |
34 | /// | |
35 | //////////////////////////////////// | |
36 | ||
37 | #include <fstream> | |
38 | #include <string> | |
39 | ||
40 | #include <TClonesArray.h> | |
41 | ||
42 | #include "AliRawReader.h" | |
43 | #include "AliRawDataHeader.h" | |
44 | #include "AliLog.h" | |
45 | #include "AliRun.h" | |
46 | ||
84ceeb06 | 47 | #include "AliMpBusPatch.h" |
a3283a4c | 48 | #include "AliMUON.h" |
49 | #include "AliMUONDigitMaker.h" | |
50 | #include "AliMUONDigit.h" | |
51 | ||
52 | #include "AliMUONConstants.h" | |
53 | #include "AliMUONData.h" | |
54 | ||
55 | #include "AliMUONRawStreamTracker.h" | |
56 | #include "AliMUONDDLTracker.h" | |
57 | #include "AliMUONDspHeader.h" | |
58 | #include "AliMUONBlockHeader.h" | |
59 | #include "AliMUONBusStruct.h" | |
60 | ||
61 | #include "AliMUONRawStreamTrigger.h" | |
62 | #include "AliMUONDDLTrigger.h" | |
63 | #include "AliMUONDarcHeader.h" | |
64 | #include "AliMUONRegHeader.h" | |
65 | #include "AliMUONLocalStruct.h" | |
66 | ||
67 | #include "AliMUONLocalTrigger.h" | |
68 | #include "AliMUONGlobalTrigger.h" | |
69 | ||
70 | #include "AliMpSegFactory.h" | |
71 | #include "AliMpVSegmentation.h" | |
72 | #include "AliMpPad.h" | |
73 | #include "AliMpDEManager.h" | |
74 | ||
75 | ClassImp(AliMUONDigitMaker) // Class implementation in ROOT context | |
76 | //__________________________________________________________________________ | |
77 | AliMUONDigitMaker::AliMUONDigitMaker(AliMUONData* data) | |
78 | : TObject(), | |
79 | fScalerEvent(kFALSE) | |
80 | { | |
81 | // | |
82 | // ctor with AliMUONData as argument | |
83 | // for reconstruction | |
84 | // | |
85 | ||
86 | AliDebug(1,""); | |
87 | ||
88 | // Standard Constructor | |
89 | ||
90 | // initialize segmentation factory | |
91 | fSegFactory = new AliMpSegFactory(); | |
92 | ||
93 | // initialize container | |
94 | fMUONData = data; | |
95 | ||
96 | // bus patch | |
97 | fBusPatchManager = new AliMpBusPatch(); | |
98 | fBusPatchManager->ReadBusPatchFile(); | |
99 | ||
100 | // raw streamers | |
101 | fRawStreamTracker = new AliMUONRawStreamTracker(); | |
102 | fRawStreamTrigger = new AliMUONRawStreamTrigger(); | |
103 | ||
104 | // digit | |
105 | fDigit = new AliMUONDigit(); | |
106 | ||
107 | // local trigger | |
108 | fLocalTrigger = new AliMUONLocalTrigger(); | |
109 | fGlobalTrigger = new AliMUONGlobalTrigger(); | |
110 | ||
111 | fTrackerTimer.Start(kTRUE); fTrackerTimer.Stop(); | |
112 | fTriggerTimer.Start(kTRUE); fTriggerTimer.Stop(); | |
113 | fMappingTimer.Start(kTRUE); fMappingTimer.Stop(); | |
114 | ||
115 | } | |
116 | ||
117 | //__________________________________________________________________________ | |
118 | AliMUONDigitMaker::AliMUONDigitMaker() | |
119 | : TObject(), | |
120 | fMUONData(0), | |
121 | fSegFactory(0), | |
122 | fBusPatchManager(0), | |
123 | fScalerEvent(kFALSE), | |
124 | fRawStreamTracker(0), | |
125 | fRawStreamTrigger(0), | |
126 | fDigit(0), | |
127 | fLocalTrigger(0) | |
128 | { | |
129 | // | |
130 | // Default Constructor | |
131 | // | |
132 | AliDebug(1,""); | |
133 | fTrackerTimer.Start(kTRUE); fTrackerTimer.Stop(); | |
134 | fTriggerTimer.Start(kTRUE); fTriggerTimer.Stop(); | |
135 | fMappingTimer.Start(kTRUE); fMappingTimer.Stop(); | |
136 | ||
137 | } | |
138 | ||
139 | //_______________________________________________________________________ | |
140 | AliMUONDigitMaker::AliMUONDigitMaker (const AliMUONDigitMaker& rhs) | |
141 | : TObject(rhs) | |
142 | { | |
143 | // | |
144 | // Protected copy constructor | |
145 | // | |
146 | AliFatal("Not implemented."); | |
147 | } | |
148 | ||
149 | //_______________________________________________________________________ | |
150 | AliMUONDigitMaker & | |
151 | AliMUONDigitMaker::operator=(const AliMUONDigitMaker& rhs) | |
152 | { | |
153 | // | |
154 | // Protected assignement operator | |
155 | // | |
156 | if (this == &rhs) return *this; | |
157 | ||
158 | AliFatal("Not implemented."); | |
159 | ||
160 | return *this; | |
161 | } | |
162 | ||
163 | //__________________________________________________________________________ | |
164 | AliMUONDigitMaker::~AliMUONDigitMaker(void) | |
165 | { | |
166 | // | |
167 | // clean up | |
168 | // and time processing measure | |
169 | // | |
170 | delete fSegFactory; | |
171 | ||
172 | delete fRawStreamTracker; | |
173 | delete fRawStreamTrigger; | |
174 | ||
175 | delete fDigit; | |
176 | delete fLocalTrigger; | |
177 | delete fGlobalTrigger; | |
178 | ||
179 | delete fBusPatchManager; | |
180 | ||
181 | AliInfo(Form("Execution time for MUON tracker : R:%.2fs C:%.2fs", | |
182 | fTrackerTimer.RealTime(),fTrackerTimer.CpuTime())); | |
183 | AliInfo(Form(" Execution time for MUON tracker (mapping calls part) " | |
184 | ": R:%.2fs C:%.2fs", | |
185 | fMappingTimer.RealTime(),fMappingTimer.CpuTime())); | |
186 | AliInfo(Form("Execution time for MUON trigger : R:%.2fs C:%.2fs", | |
187 | fTriggerTimer.RealTime(),fTriggerTimer.CpuTime())); | |
188 | ||
189 | return; | |
190 | } | |
191 | ||
192 | //____________________________________________________________________ | |
193 | Int_t AliMUONDigitMaker::Raw2Digits(AliRawReader* rawReader) | |
194 | { | |
195 | // Main method to creates digit | |
196 | // for tracker | |
197 | // and trigger | |
198 | ||
199 | // generate digits | |
200 | ReadTrackerDDL(rawReader); | |
201 | ||
202 | // generate trigger | |
203 | ReadTriggerDDL(rawReader); | |
204 | ||
205 | return kTRUE; | |
206 | ||
207 | } | |
208 | ||
209 | //____________________________________________________________________ | |
210 | Int_t AliMUONDigitMaker::ReadTrackerDDL(AliRawReader* rawReader) | |
211 | { | |
212 | ||
213 | // reading tracker DDL | |
214 | // filling the TClonesArray in MUONData | |
215 | // | |
216 | fTrackerTimer.Start(kFALSE); | |
217 | ||
218 | // elex info | |
219 | Int_t buspatchId; | |
220 | UChar_t channelId; | |
221 | UShort_t manuId; | |
222 | Char_t parity; | |
223 | UShort_t charge; | |
224 | Int_t dataSize; | |
225 | ||
226 | AliMUONDDLTracker* ddlTracker = 0x0; | |
227 | AliMUONBlockHeader* blkHeader = 0x0; | |
228 | AliMUONDspHeader* dspHeader = 0x0; | |
229 | AliMUONBusStruct* busStruct = 0x0; | |
230 | ||
231 | ||
232 | fRawStreamTracker->SetReader(rawReader); | |
233 | ||
234 | while(fRawStreamTracker->NextDDL()) { | |
235 | ||
236 | ddlTracker = fRawStreamTracker->GetDDLTracker(); | |
237 | ||
238 | Int_t nBlock = ddlTracker->GetBlkHeaderEntries(); | |
239 | for(Int_t iBlock = 0; iBlock < nBlock ;iBlock++){ | |
240 | ||
241 | blkHeader = ddlTracker->GetBlkHeaderEntry(iBlock); | |
242 | ||
243 | Int_t nDsp = blkHeader->GetDspHeaderEntries(); | |
244 | ||
245 | for(Int_t iDsp = 0; iDsp < nDsp ;iDsp++){ //DSP loop | |
246 | ||
247 | dspHeader = blkHeader->GetDspHeaderEntry(iDsp); | |
248 | ||
249 | Int_t nBusPatch = dspHeader->GetBusPatchEntries(); | |
250 | ||
251 | for(Int_t iBusPatch = 0; iBusPatch < nBusPatch; iBusPatch++) { | |
252 | ||
253 | busStruct = dspHeader->GetBusPatchEntry(iBusPatch); | |
254 | ||
255 | dataSize = busStruct->GetLength(); | |
256 | buspatchId = busStruct->GetBusPatchId(); | |
257 | ||
258 | for (Int_t iData = 0; iData < dataSize; iData++) { | |
259 | ||
260 | // digits info | |
261 | parity = busStruct->GetParity(iData); // test later for parity | |
262 | manuId = busStruct->GetManuId(iData); | |
263 | channelId = busStruct->GetChannelId(iData); | |
264 | charge = busStruct->GetCharge(iData); | |
265 | // set charge | |
266 | fDigit->SetSignal(charge); | |
267 | fDigit->SetPhysicsSignal(charge); | |
268 | fDigit->SetADC(charge); | |
269 | ||
270 | // Get Back the hits at pads | |
271 | Int_t error = GetMapping(buspatchId,manuId,channelId,fDigit); | |
84ceeb06 | 272 | if (error) { |
273 | printf("Mapping Error\n"); | |
274 | continue; | |
275 | } | |
a3283a4c | 276 | // debugging |
277 | if (AliLog::GetGlobalDebugLevel() == 3) { | |
278 | Int_t padX = fDigit->PadX(); | |
279 | Int_t padY = fDigit->PadY(); | |
280 | Int_t iCath = fDigit->Cathode(); | |
281 | Int_t idDE = fDigit->DetElemId(); | |
282 | ||
283 | AliDebug(1,Form("output IdDE %d busPatchid %d PadX %d PadY %d iCath %d \n", | |
284 | idDE, buspatchId, padX, padY, iCath)); | |
285 | ||
286 | AliDebug(3,Form("idDE %d Padx %d Pady %d, Cath %d, charge %d", | |
287 | idDE, padX, padY, iCath, charge)); | |
288 | } | |
289 | ||
290 | // fill digits | |
291 | fMUONData->AddDigit(fRawStreamTracker->GetDDL()/2, *fDigit); | |
292 | ||
293 | } // iData | |
294 | } // iBusPatch | |
295 | } // iDsp | |
296 | } // iBlock | |
297 | } // NextDDL | |
298 | ||
299 | fTrackerTimer.Stop(); | |
300 | ||
301 | return kTRUE; | |
302 | } | |
303 | //____________________________________________________________________ | |
304 | Int_t AliMUONDigitMaker::GetMapping(Int_t busPatchId, UShort_t manuId, | |
305 | UChar_t channelId, AliMUONDigit* digit ) | |
306 | { | |
307 | // | |
308 | // mapping for tracker | |
309 | // | |
310 | fMappingTimer.Start(kFALSE); | |
311 | ||
312 | // getting DE from buspatch | |
313 | Int_t detElemId = fBusPatchManager->GetDEfromBus(busPatchId); | |
314 | AliDebug(3,Form("detElemId: %d busPatchId %d\n", detElemId, busPatchId)); | |
315 | ||
316 | AliMpVSegmentation* seg = fSegFactory->CreateMpSegmentationByElectronics(detElemId, manuId); | |
317 | AliMpPad pad = seg->PadByLocation(AliMpIntPair(manuId,channelId),kTRUE); | |
318 | ||
319 | if (!pad.IsValid()) | |
320 | { | |
321 | AliWarning(Form("No pad for detElemId: %d, busPatchId %d, manuId: %d, channelId: %d\n", | |
322 | detElemId, busPatchId, manuId, channelId)); | |
323 | fMappingTimer.Stop(); | |
324 | return kTRUE; | |
325 | } // return error | |
326 | ||
327 | // Getting padX, padY and cathode number. | |
328 | Int_t padX = pad.GetIndices().GetFirst(); | |
329 | Int_t padY = pad.GetIndices().GetSecond(); | |
330 | Int_t iCath = AliMpDEManager::GetCathod(detElemId,seg->PlaneType()); | |
331 | ||
332 | // storing into digits | |
333 | digit->SetPadX(padX); | |
334 | digit->SetPadY(padY); | |
335 | digit->SetCathode(iCath); | |
336 | digit->SetDetElemId(detElemId); | |
337 | digit->SetElectronics(manuId,channelId); | |
338 | ||
339 | AliDebug(3,Form("detElemId: %d, busPatchId %d, manuId: %d, channelId: %d, padx: %d pady %d\n", | |
340 | detElemId, busPatchId, manuId, channelId, padX, padY)); | |
341 | StdoutToAliDebug(3,digit->Print();); | |
342 | ||
343 | fMappingTimer.Stop(); | |
344 | return kFALSE; | |
345 | } | |
346 | ||
347 | //____________________________________________________________________ | |
348 | Int_t AliMUONDigitMaker::ReadTriggerDDL(AliRawReader* rawReader) | |
349 | { | |
350 | // reading tracker DDL | |
351 | // filling the TClonesArray in MUONData | |
352 | // | |
353 | ||
354 | AliMUONDDLTrigger* ddlTrigger = 0x0; | |
355 | AliMUONDarcHeader* darcHeader = 0x0; | |
356 | AliMUONRegHeader* regHeader = 0x0; | |
357 | AliMUONLocalStruct* localStruct = 0x0; | |
358 | ||
359 | Int_t loCircuit; | |
360 | ||
361 | fTriggerTimer.Start(kFALSE); | |
362 | ||
363 | fRawStreamTrigger->SetReader(rawReader); | |
364 | ||
365 | while(fRawStreamTrigger->NextDDL()) { | |
366 | ||
367 | ddlTrigger = fRawStreamTrigger->GetDDLTrigger(); | |
368 | darcHeader = ddlTrigger->GetDarcHeader(); | |
369 | ||
370 | // fill global trigger information | |
af3c5ff4 | 371 | if (darcHeader->GetGlobalFlag()) { |
a3283a4c | 372 | fGlobalTrigger->SetGlobalPattern(darcHeader->GetGlobalOutput()); |
373 | fMUONData->AddGlobalTrigger(*fGlobalTrigger); | |
374 | } | |
375 | ||
376 | Int_t nReg = darcHeader->GetRegHeaderEntries(); | |
377 | ||
378 | for(Int_t iReg = 0; iReg < nReg ;iReg++){ //reg loop | |
379 | ||
380 | regHeader = darcHeader->GetRegHeaderEntry(iReg); | |
381 | ||
382 | Int_t nLocal = regHeader->GetLocalEntries(); | |
383 | ||
384 | for(Int_t iLocal = 0; iLocal < nLocal; iLocal++) { | |
385 | ||
386 | localStruct = regHeader->GetLocalEntry(iLocal); | |
387 | ||
388 | if (localStruct->GetTriggerY() == 0) { | |
389 | loCircuit = localStruct->GetId()+ 16*regHeader->GetId() | |
390 | + 128*fRawStreamTrigger->GetDDL(); | |
391 | ||
392 | // fill local trigger | |
393 | fLocalTrigger->SetLocalStruct(loCircuit, *localStruct); | |
394 | ||
395 | fMUONData->AddLocalTrigger(*fLocalTrigger); | |
396 | } // if triggerY | |
397 | } // iLocal | |
398 | } // iReg | |
399 | } // NextDDL | |
400 | ||
401 | fTriggerTimer.Stop(); | |
402 | ||
403 | return kTRUE; | |
404 | ||
405 | } | |
406 |