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