]>
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 | ||
d53fb0de | 67 | #include "AliMUONTriggerCrateStore.h" |
68 | #include "AliMUONTriggerCrate.h" | |
69 | #include "AliMUONLocalTriggerBoard.h" | |
a3283a4c | 70 | #include "AliMUONLocalTrigger.h" |
71 | #include "AliMUONGlobalTrigger.h" | |
72 | ||
73 | #include "AliMpSegFactory.h" | |
74 | #include "AliMpVSegmentation.h" | |
75 | #include "AliMpPad.h" | |
76 | #include "AliMpDEManager.h" | |
77 | ||
78 | ClassImp(AliMUONDigitMaker) // Class implementation in ROOT context | |
79 | //__________________________________________________________________________ | |
80 | AliMUONDigitMaker::AliMUONDigitMaker(AliMUONData* data) | |
81 | : TObject(), | |
9f5dcca3 | 82 | fMUONData(data), |
83 | fSegFactory(new AliMpSegFactory()), | |
84 | fBusPatchManager(new AliMpBusPatch()), | |
85 | fScalerEvent(kFALSE), | |
86 | fRawStreamTracker(new AliMUONRawStreamTracker()), | |
87 | fRawStreamTrigger(new AliMUONRawStreamTrigger()), | |
88 | fDigit(new AliMUONDigit()), | |
89 | fLocalTrigger(new AliMUONLocalTrigger()), | |
90 | fGlobalTrigger(new AliMUONGlobalTrigger()), | |
d53fb0de | 91 | fCrateManager(new AliMUONTriggerCrateStore()), |
9f5dcca3 | 92 | fTrackerTimer(), |
93 | fTriggerTimer(), | |
94 | fMappingTimer() | |
a3283a4c | 95 | { |
96 | // | |
97 | // ctor with AliMUONData as argument | |
98 | // for reconstruction | |
99 | // | |
100 | ||
101 | AliDebug(1,""); | |
102 | ||
103 | // Standard Constructor | |
104 | ||
a3283a4c | 105 | // bus patch |
a3283a4c | 106 | fBusPatchManager->ReadBusPatchFile(); |
107 | ||
d53fb0de | 108 | // Crate manager |
109 | fCrateManager->ReadFromFile(); | |
a3283a4c | 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), | |
9f5dcca3 | 127 | fLocalTrigger(0), |
128 | fGlobalTrigger(0), | |
d53fb0de | 129 | fCrateManager(0), |
9f5dcca3 | 130 | fTrackerTimer(), |
131 | fTriggerTimer(), | |
132 | fMappingTimer() | |
a3283a4c | 133 | { |
134 | // | |
135 | // Default Constructor | |
136 | // | |
137 | AliDebug(1,""); | |
138 | fTrackerTimer.Start(kTRUE); fTrackerTimer.Stop(); | |
139 | fTriggerTimer.Start(kTRUE); fTriggerTimer.Stop(); | |
140 | fMappingTimer.Start(kTRUE); fMappingTimer.Stop(); | |
141 | ||
142 | } | |
143 | ||
a3283a4c | 144 | //__________________________________________________________________________ |
9f5dcca3 | 145 | AliMUONDigitMaker::~AliMUONDigitMaker() |
a3283a4c | 146 | { |
147 | // | |
148 | // clean up | |
149 | // and time processing measure | |
150 | // | |
151 | delete fSegFactory; | |
152 | ||
153 | delete fRawStreamTracker; | |
154 | delete fRawStreamTrigger; | |
155 | ||
156 | delete fDigit; | |
157 | delete fLocalTrigger; | |
158 | delete fGlobalTrigger; | |
159 | ||
d53fb0de | 160 | delete fCrateManager; |
161 | ||
a3283a4c | 162 | delete fBusPatchManager; |
163 | ||
164 | AliInfo(Form("Execution time for MUON tracker : R:%.2fs C:%.2fs", | |
165 | fTrackerTimer.RealTime(),fTrackerTimer.CpuTime())); | |
166 | AliInfo(Form(" Execution time for MUON tracker (mapping calls part) " | |
167 | ": R:%.2fs C:%.2fs", | |
168 | fMappingTimer.RealTime(),fMappingTimer.CpuTime())); | |
169 | AliInfo(Form("Execution time for MUON trigger : R:%.2fs C:%.2fs", | |
170 | fTriggerTimer.RealTime(),fTriggerTimer.CpuTime())); | |
171 | ||
172 | return; | |
173 | } | |
174 | ||
175 | //____________________________________________________________________ | |
176 | Int_t AliMUONDigitMaker::Raw2Digits(AliRawReader* rawReader) | |
177 | { | |
178 | // Main method to creates digit | |
179 | // for tracker | |
180 | // and trigger | |
181 | ||
182 | // generate digits | |
183 | ReadTrackerDDL(rawReader); | |
184 | ||
185 | // generate trigger | |
186 | ReadTriggerDDL(rawReader); | |
187 | ||
188 | return kTRUE; | |
189 | ||
190 | } | |
191 | ||
192 | //____________________________________________________________________ | |
193 | Int_t AliMUONDigitMaker::ReadTrackerDDL(AliRawReader* rawReader) | |
194 | { | |
195 | ||
196 | // reading tracker DDL | |
197 | // filling the TClonesArray in MUONData | |
198 | // | |
199 | fTrackerTimer.Start(kFALSE); | |
200 | ||
201 | // elex info | |
202 | Int_t buspatchId; | |
203 | UChar_t channelId; | |
204 | UShort_t manuId; | |
205 | Char_t parity; | |
206 | UShort_t charge; | |
207 | Int_t dataSize; | |
208 | ||
e6e1f642 | 209 | Int_t iChamber; |
210 | ||
a3283a4c | 211 | AliMUONDDLTracker* ddlTracker = 0x0; |
212 | AliMUONBlockHeader* blkHeader = 0x0; | |
213 | AliMUONDspHeader* dspHeader = 0x0; | |
214 | AliMUONBusStruct* busStruct = 0x0; | |
215 | ||
216 | ||
217 | fRawStreamTracker->SetReader(rawReader); | |
218 | ||
219 | while(fRawStreamTracker->NextDDL()) { | |
220 | ||
221 | ddlTracker = fRawStreamTracker->GetDDLTracker(); | |
222 | ||
223 | Int_t nBlock = ddlTracker->GetBlkHeaderEntries(); | |
224 | for(Int_t iBlock = 0; iBlock < nBlock ;iBlock++){ | |
225 | ||
226 | blkHeader = ddlTracker->GetBlkHeaderEntry(iBlock); | |
227 | ||
228 | Int_t nDsp = blkHeader->GetDspHeaderEntries(); | |
229 | ||
230 | for(Int_t iDsp = 0; iDsp < nDsp ;iDsp++){ //DSP loop | |
231 | ||
232 | dspHeader = blkHeader->GetDspHeaderEntry(iDsp); | |
233 | ||
234 | Int_t nBusPatch = dspHeader->GetBusPatchEntries(); | |
235 | ||
236 | for(Int_t iBusPatch = 0; iBusPatch < nBusPatch; iBusPatch++) { | |
237 | ||
238 | busStruct = dspHeader->GetBusPatchEntry(iBusPatch); | |
239 | ||
240 | dataSize = busStruct->GetLength(); | |
241 | buspatchId = busStruct->GetBusPatchId(); | |
242 | ||
243 | for (Int_t iData = 0; iData < dataSize; iData++) { | |
244 | ||
245 | // digits info | |
246 | parity = busStruct->GetParity(iData); // test later for parity | |
247 | manuId = busStruct->GetManuId(iData); | |
248 | channelId = busStruct->GetChannelId(iData); | |
249 | charge = busStruct->GetCharge(iData); | |
250 | // set charge | |
251 | fDigit->SetSignal(charge); | |
252 | fDigit->SetPhysicsSignal(charge); | |
253 | fDigit->SetADC(charge); | |
254 | ||
255 | // Get Back the hits at pads | |
256 | Int_t error = GetMapping(buspatchId,manuId,channelId,fDigit); | |
84ceeb06 | 257 | if (error) { |
e6e1f642 | 258 | AliWarning("Mapping Error\n"); |
84ceeb06 | 259 | continue; |
260 | } | |
a3283a4c | 261 | // debugging |
262 | if (AliLog::GetGlobalDebugLevel() == 3) { | |
263 | Int_t padX = fDigit->PadX(); | |
264 | Int_t padY = fDigit->PadY(); | |
265 | Int_t iCath = fDigit->Cathode(); | |
266 | Int_t idDE = fDigit->DetElemId(); | |
267 | ||
268 | AliDebug(1,Form("output IdDE %d busPatchid %d PadX %d PadY %d iCath %d \n", | |
269 | idDE, buspatchId, padX, padY, iCath)); | |
270 | ||
271 | AliDebug(3,Form("idDE %d Padx %d Pady %d, Cath %d, charge %d", | |
272 | idDE, padX, padY, iCath, charge)); | |
273 | } | |
274 | ||
275 | // fill digits | |
e6e1f642 | 276 | iChamber = fDigit->DetElemId()/100 - 1; |
277 | fMUONData->AddDigit(iChamber, *fDigit); | |
a3283a4c | 278 | |
279 | } // iData | |
280 | } // iBusPatch | |
281 | } // iDsp | |
282 | } // iBlock | |
283 | } // NextDDL | |
284 | ||
285 | fTrackerTimer.Stop(); | |
286 | ||
287 | return kTRUE; | |
288 | } | |
289 | //____________________________________________________________________ | |
290 | Int_t AliMUONDigitMaker::GetMapping(Int_t busPatchId, UShort_t manuId, | |
291 | UChar_t channelId, AliMUONDigit* digit ) | |
292 | { | |
293 | // | |
294 | // mapping for tracker | |
295 | // | |
296 | fMappingTimer.Start(kFALSE); | |
297 | ||
298 | // getting DE from buspatch | |
e6e1f642 | 299 | Int_t detElemId = fBusPatchManager->GetDEfromBus(busPatchId); |
a3283a4c | 300 | AliDebug(3,Form("detElemId: %d busPatchId %d\n", detElemId, busPatchId)); |
301 | ||
302 | AliMpVSegmentation* seg = fSegFactory->CreateMpSegmentationByElectronics(detElemId, manuId); | |
303 | AliMpPad pad = seg->PadByLocation(AliMpIntPair(manuId,channelId),kTRUE); | |
304 | ||
305 | if (!pad.IsValid()) | |
306 | { | |
307 | AliWarning(Form("No pad for detElemId: %d, busPatchId %d, manuId: %d, channelId: %d\n", | |
308 | detElemId, busPatchId, manuId, channelId)); | |
309 | fMappingTimer.Stop(); | |
310 | return kTRUE; | |
311 | } // return error | |
312 | ||
313 | // Getting padX, padY and cathode number. | |
314 | Int_t padX = pad.GetIndices().GetFirst(); | |
315 | Int_t padY = pad.GetIndices().GetSecond(); | |
316 | Int_t iCath = AliMpDEManager::GetCathod(detElemId,seg->PlaneType()); | |
317 | ||
318 | // storing into digits | |
319 | digit->SetPadX(padX); | |
320 | digit->SetPadY(padY); | |
321 | digit->SetCathode(iCath); | |
322 | digit->SetDetElemId(detElemId); | |
323 | digit->SetElectronics(manuId,channelId); | |
324 | ||
325 | AliDebug(3,Form("detElemId: %d, busPatchId %d, manuId: %d, channelId: %d, padx: %d pady %d\n", | |
326 | detElemId, busPatchId, manuId, channelId, padX, padY)); | |
327 | StdoutToAliDebug(3,digit->Print();); | |
328 | ||
329 | fMappingTimer.Stop(); | |
330 | return kFALSE; | |
331 | } | |
332 | ||
333 | //____________________________________________________________________ | |
334 | Int_t AliMUONDigitMaker::ReadTriggerDDL(AliRawReader* rawReader) | |
335 | { | |
336 | // reading tracker DDL | |
337 | // filling the TClonesArray in MUONData | |
338 | // | |
339 | ||
340 | AliMUONDDLTrigger* ddlTrigger = 0x0; | |
341 | AliMUONDarcHeader* darcHeader = 0x0; | |
342 | AliMUONRegHeader* regHeader = 0x0; | |
343 | AliMUONLocalStruct* localStruct = 0x0; | |
344 | ||
345 | Int_t loCircuit; | |
346 | ||
347 | fTriggerTimer.Start(kFALSE); | |
348 | ||
349 | fRawStreamTrigger->SetReader(rawReader); | |
350 | ||
351 | while(fRawStreamTrigger->NextDDL()) { | |
352 | ||
353 | ddlTrigger = fRawStreamTrigger->GetDDLTrigger(); | |
354 | darcHeader = ddlTrigger->GetDarcHeader(); | |
355 | ||
356 | // fill global trigger information | |
af3c5ff4 | 357 | if (darcHeader->GetGlobalFlag()) { |
a3283a4c | 358 | fGlobalTrigger->SetGlobalPattern(darcHeader->GetGlobalOutput()); |
359 | fMUONData->AddGlobalTrigger(*fGlobalTrigger); | |
360 | } | |
361 | ||
362 | Int_t nReg = darcHeader->GetRegHeaderEntries(); | |
363 | ||
364 | for(Int_t iReg = 0; iReg < nReg ;iReg++){ //reg loop | |
365 | ||
d53fb0de | 366 | // crate info |
367 | Char_t crateName[10]; | |
368 | GetCrateName(crateName, fRawStreamTrigger->GetDDL(), iReg); | |
369 | ||
370 | AliMUONTriggerCrate* crate = fCrateManager->Crate(crateName); | |
371 | ||
372 | if (!crate) | |
373 | AliWarning(Form("Missing crate number %d in DDL %d\n", iReg, fRawStreamTrigger->GetDDL())); | |
374 | ||
375 | TObjArray *boards = crate->Boards(); | |
376 | ||
377 | ||
a3283a4c | 378 | regHeader = darcHeader->GetRegHeaderEntry(iReg); |
379 | ||
380 | Int_t nLocal = regHeader->GetLocalEntries(); | |
381 | ||
382 | for(Int_t iLocal = 0; iLocal < nLocal; iLocal++) { | |
383 | ||
384 | localStruct = regHeader->GetLocalEntry(iLocal); | |
385 | ||
d53fb0de | 386 | // if card has triggered |
a3283a4c | 387 | if (localStruct->GetTriggerY() == 0) { |
d53fb0de | 388 | |
389 | AliMUONLocalTriggerBoard* localBoard = | |
390 | (AliMUONLocalTriggerBoard*)boards->At(localStruct->GetId()+1); | |
391 | ||
392 | loCircuit = localBoard->GetNumber(); | |
a3283a4c | 393 | |
394 | // fill local trigger | |
395 | fLocalTrigger->SetLocalStruct(loCircuit, *localStruct); | |
396 | ||
397 | fMUONData->AddLocalTrigger(*fLocalTrigger); | |
398 | } // if triggerY | |
399 | } // iLocal | |
400 | } // iReg | |
401 | } // NextDDL | |
402 | ||
403 | fTriggerTimer.Stop(); | |
404 | ||
405 | return kTRUE; | |
406 | ||
407 | } | |
408 | ||
d53fb0de | 409 | //____________________________________________________________________ |
410 | void AliMUONDigitMaker::GetCrateName(Char_t* name, Int_t iDDL, Int_t iReg) | |
411 | { | |
412 | // set crate name from DDL & reg number | |
413 | // method same as in RawWriter, not so nice | |
414 | // should be put in AliMUONTriggerCrateStore | |
415 | ||
416 | switch(iReg) { | |
417 | case 0: | |
418 | case 1: | |
419 | sprintf(name,"%d", iReg+1); | |
420 | break; | |
421 | case 2: | |
422 | strcpy(name, "2-3"); | |
423 | break; | |
424 | case 3: | |
425 | case 4: | |
426 | case 5: | |
427 | case 6: | |
428 | case 7: | |
429 | sprintf(name,"%d", iReg); | |
430 | break; | |
431 | } | |
432 | ||
433 | // crate Right for first DDL | |
434 | if (iDDL == 0) | |
435 | strcat(name, "R"); | |
436 | else | |
437 | strcat(name, "L"); | |
438 | } |