]>
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 | ||
9265505b | 16 | /// \class AliMUONDigitMaker |
8c51a32f | 17 | /// MUON Digit maker from rawdata. |
a3283a4c | 18 | /// |
19 | /// Raw2Digits: | |
20 | /// Using real mapping for tracker | |
21 | /// Indranil Das (Adapted for runloader: Ch. Finck) july 05 | |
8c51a32f | 22 | /// |
23 | /// Implemented non-constant buspatch numbers for tracking | |
24 | /// with correct DDL id. | |
25 | /// (Ch. Finck, dec 05) | |
26 | /// | |
a3283a4c | 27 | /// Add reader for scaler trigger events |
28 | /// Use memcpy instead of assignment elt by elt | |
29 | /// (Ch. Finck, Jan 06) | |
8c51a32f | 30 | /// |
31 | /// Using new interface with AliMUONRawStreamTracker(Trigger) | |
32 | /// (New interface of AliMUONRawReader class) | |
33 | /// (further details could be found in Alice-note) | |
34 | /// (Ch. Finck, March 06) | |
35 | /// | |
36 | /// Add (S)Digit maker tracker (for free) | |
37 | /// and for trigger. Create trigger inverse mapping. | |
78649106 | 38 | /// |
39 | /// \author Ch. Finck, oct 06 | |
a3283a4c | 40 | |
a3283a4c | 41 | #include "AliMUONDigitMaker.h" |
a3283a4c | 42 | |
40e382ae | 43 | #include "AliLog.h" |
a3283a4c | 44 | #include "AliMUONDDLTrigger.h" |
45 | #include "AliMUONDarcHeader.h" | |
40e382ae | 46 | #include "AliMUONVDigit.h" |
47 | #include "AliMUONVDigitStore.h" | |
48 | #include "AliMUONGlobalTrigger.h" | |
a3283a4c | 49 | #include "AliMUONLocalStruct.h" |
a3283a4c | 50 | #include "AliMUONLocalTrigger.h" |
40e382ae | 51 | #include "AliMUONLocalTriggerBoard.h" |
52 | #include "AliMUONRawStreamTracker.h" | |
53 | #include "AliMUONRawStreamTrigger.h" | |
54 | #include "AliMUONRegHeader.h" | |
e1a10d41 | 55 | #include "AliMUONTriggerCircuit.h" |
40e382ae | 56 | #include "AliMUONTriggerCrate.h" |
57 | #include "AliMUONTriggerCrateStore.h" | |
58 | #include "AliMUONVTriggerStore.h" | |
59 | #include "AliMpCathodType.h" | |
60 | #include "AliMpDDLStore.h" | |
61 | #include "AliMpDEManager.h" | |
62 | #include "AliMpPad.h" | |
9265505b | 63 | #include "AliMpSegmentation.h" |
a3283a4c | 64 | #include "AliMpVSegmentation.h" |
9265505b | 65 | #include "AliRawReader.h" |
7771752e | 66 | #include <TArrayS.h> |
9265505b | 67 | |
9265505b | 68 | /// \cond CLASSIMP |
a3283a4c | 69 | ClassImp(AliMUONDigitMaker) // Class implementation in ROOT context |
9265505b | 70 | /// \endcond |
71 | ||
a3283a4c | 72 | //__________________________________________________________________________ |
40e382ae | 73 | AliMUONDigitMaker::AliMUONDigitMaker() |
a3283a4c | 74 | : TObject(), |
9f5dcca3 | 75 | fScalerEvent(kFALSE), |
40e382ae | 76 | fMakeTriggerDigits(kFALSE), |
9f5dcca3 | 77 | fRawStreamTracker(new AliMUONRawStreamTracker()), |
78 | fRawStreamTrigger(new AliMUONRawStreamTrigger()), | |
fe5010dd | 79 | fCrateManager(0x0), |
9f5dcca3 | 80 | fTrackerTimer(), |
81 | fTriggerTimer(), | |
40e382ae | 82 | fMappingTimer(), |
83 | fDigitStore(0x0), | |
84 | fTriggerStore(0x0) | |
a3283a4c | 85 | { |
40e382ae | 86 | /// ctor |
a3283a4c | 87 | |
88 | AliDebug(1,""); | |
89 | ||
90 | // Standard Constructor | |
91 | ||
a3283a4c | 92 | fTrackerTimer.Start(kTRUE); fTrackerTimer.Stop(); |
93 | fTriggerTimer.Start(kTRUE); fTriggerTimer.Stop(); | |
94 | fMappingTimer.Start(kTRUE); fMappingTimer.Stop(); | |
40e382ae | 95 | |
96 | SetMakeTriggerDigits(); | |
a3283a4c | 97 | |
98 | } | |
99 | ||
a3283a4c | 100 | //__________________________________________________________________________ |
9f5dcca3 | 101 | AliMUONDigitMaker::~AliMUONDigitMaker() |
a3283a4c | 102 | { |
9265505b | 103 | /// clean up |
104 | /// and time processing measure | |
105 | ||
a3283a4c | 106 | delete fRawStreamTracker; |
107 | delete fRawStreamTrigger; | |
108 | ||
a7b01aa5 | 109 | AliDebug(1, Form("Execution time for MUON tracker : R:%.2fs C:%.2fs", |
a3283a4c | 110 | fTrackerTimer.RealTime(),fTrackerTimer.CpuTime())); |
a7b01aa5 | 111 | AliDebug(1, Form(" Execution time for MUON tracker (mapping calls part) " |
a3283a4c | 112 | ": R:%.2fs C:%.2fs", |
113 | fMappingTimer.RealTime(),fMappingTimer.CpuTime())); | |
a7b01aa5 | 114 | AliDebug(1, Form("Execution time for MUON trigger : R:%.2fs C:%.2fs", |
a3283a4c | 115 | fTriggerTimer.RealTime(),fTriggerTimer.CpuTime())); |
116 | ||
a3283a4c | 117 | } |
118 | ||
119 | //____________________________________________________________________ | |
40e382ae | 120 | Int_t AliMUONDigitMaker::Raw2Digits(AliRawReader* rawReader, |
121 | AliMUONVDigitStore* digitStore, | |
122 | AliMUONVTriggerStore* triggerStore) | |
a3283a4c | 123 | { |
9265505b | 124 | /// Main method to creates digit |
125 | /// for tracker | |
126 | /// and trigger | |
a3283a4c | 127 | |
40e382ae | 128 | AliDebug(1,Form("rawReader=%p digitStore=%p triggerStore=%p", |
129 | rawReader,digitStore,triggerStore)); | |
130 | ||
131 | fDigitStore = digitStore; | |
132 | fTriggerStore = triggerStore; | |
133 | ||
134 | if (!fDigitStore && !fTriggerStore) | |
135 | { | |
136 | AliError("No digit or trigger store given. Nothing to do..."); | |
137 | return kFALSE; | |
138 | } | |
139 | ||
140 | if ( fDigitStore ) | |
141 | { | |
142 | fDigitStore->Clear(); // insure we start with an empty container | |
143 | ReadTrackerDDL(rawReader); | |
144 | } | |
145 | ||
146 | if ( fTriggerStore || fMakeTriggerDigits ) | |
147 | { | |
148 | if ( fTriggerStore ) fTriggerStore->Clear(); | |
149 | if ( fMakeTriggerDigits && !fDigitStore ) | |
150 | { | |
151 | AliError("Asking for trigger digits but digitStore is null"); | |
152 | } | |
153 | else | |
154 | { | |
e604ac4c | 155 | ReadTriggerDDL(rawReader); |
40e382ae | 156 | } |
157 | } | |
158 | ||
a3283a4c | 159 | return kTRUE; |
a3283a4c | 160 | } |
161 | ||
162 | //____________________________________________________________________ | |
163 | Int_t AliMUONDigitMaker::ReadTrackerDDL(AliRawReader* rawReader) | |
164 | { | |
40e382ae | 165 | /// Reading tracker DDL |
166 | /// filling the fDigitStore container, which must not be null | |
a3283a4c | 167 | |
40e382ae | 168 | AliDebug(1,""); |
169 | ||
a3283a4c | 170 | fTrackerTimer.Start(kFALSE); |
171 | ||
172 | // elex info | |
173 | Int_t buspatchId; | |
174 | UChar_t channelId; | |
175 | UShort_t manuId; | |
a3283a4c | 176 | UShort_t charge; |
a3283a4c | 177 | |
a3283a4c | 178 | fRawStreamTracker->SetReader(rawReader); |
1bc885f3 | 179 | fRawStreamTracker->First(); |
180 | ||
181 | while ( fRawStreamTracker->Next(buspatchId,manuId,channelId,charge) ) | |
182 | { | |
40e382ae | 183 | // getting DE from buspatch |
184 | Int_t detElemId = AliMpDDLStore::Instance()->GetDEfromBus(buspatchId); | |
a3283a4c | 185 | |
40e382ae | 186 | const AliMpVSegmentation* seg |
187 | = AliMpSegmentation::Instance()->GetMpSegmentationByElectronics(detElemId, | |
188 | manuId); | |
a3283a4c | 189 | |
40e382ae | 190 | AliMp::CathodType cathodeType = AliMpDEManager::GetCathod(detElemId, |
191 | seg->PlaneType()); | |
1bc885f3 | 192 | |
40e382ae | 193 | AliMpPad pad = seg->PadByLocation(AliMpIntPair(manuId,channelId),kFALSE); |
194 | ||
195 | if (!pad.IsValid()) | |
196 | { | |
197 | AliError(Form("No pad for detElemId: %d, manuId: %d, channelId: %d", | |
198 | detElemId, manuId, channelId)); | |
199 | continue; | |
200 | } | |
201 | ||
202 | AliMUONVDigit* digit = fDigitStore->Add(detElemId,manuId,channelId,cathodeType, | |
203 | AliMUONVDigitStore::kDeny); | |
204 | if (!digit) | |
205 | { | |
206 | AliError(Form("Digit DE %04d Manu %04d Channel %02d could not be added", | |
207 | detElemId, manuId, channelId)); | |
208 | continue; | |
209 | } | |
210 | ||
211 | digit->SetPadXY(pad.GetIndices().GetFirst(), | |
212 | pad.GetIndices().GetSecond()); | |
213 | ||
214 | digit->SetADC(charge); | |
9265505b | 215 | |
40e382ae | 216 | } |
a3283a4c | 217 | |
40e382ae | 218 | fTrackerTimer.Stop(); |
a3283a4c | 219 | |
40e382ae | 220 | return kTRUE; |
a3283a4c | 221 | } |
222 | ||
223 | //____________________________________________________________________ | |
224 | Int_t AliMUONDigitMaker::ReadTriggerDDL(AliRawReader* rawReader) | |
225 | { | |
9265505b | 226 | /// reading tracker DDL |
40e382ae | 227 | /// filling the fTriggerStore container, which must not be null |
a3283a4c | 228 | |
40e382ae | 229 | AliDebug(1,""); |
230 | ||
a3283a4c | 231 | AliMUONDDLTrigger* ddlTrigger = 0x0; |
232 | AliMUONDarcHeader* darcHeader = 0x0; | |
233 | AliMUONRegHeader* regHeader = 0x0; | |
234 | AliMUONLocalStruct* localStruct = 0x0; | |
235 | ||
236 | Int_t loCircuit; | |
d2d759cf | 237 | |
a3283a4c | 238 | fTriggerTimer.Start(kFALSE); |
239 | ||
240 | fRawStreamTrigger->SetReader(rawReader); | |
241 | ||
40e382ae | 242 | while (fRawStreamTrigger->NextDDL()) |
243 | { | |
a3283a4c | 244 | ddlTrigger = fRawStreamTrigger->GetDDLTrigger(); |
245 | darcHeader = ddlTrigger->GetDarcHeader(); | |
40e382ae | 246 | |
247 | // fill global trigger information | |
248 | if (fTriggerStore) | |
249 | { | |
250 | if (darcHeader->GetGlobalFlag()) | |
251 | { | |
252 | AliMUONGlobalTrigger globalTrigger; | |
253 | globalTrigger.SetFromGlobalResponse(darcHeader->GetGlobalOutput()); | |
254 | fTriggerStore->SetGlobal(globalTrigger); | |
d2d759cf | 255 | } |
a3283a4c | 256 | } |
40e382ae | 257 | |
a3283a4c | 258 | Int_t nReg = darcHeader->GetRegHeaderEntries(); |
40e382ae | 259 | |
260 | for(Int_t iReg = 0; iReg < nReg ;iReg++) | |
261 | { //reg loop | |
262 | ||
fe5010dd | 263 | // crate info |
264 | if (!fCrateManager) AliFatal("Crate Store not defined"); | |
aa6ecf89 | 265 | AliMUONTriggerCrate* crate = fCrateManager->Crate(fRawStreamTrigger->GetDDL(), iReg); |
40e382ae | 266 | |
d53fb0de | 267 | if (!crate) |
40e382ae | 268 | AliWarning(Form("Missing crate number %d in DDL %d\n", iReg, fRawStreamTrigger->GetDDL())); |
269 | ||
d53fb0de | 270 | TObjArray *boards = crate->Boards(); |
40e382ae | 271 | |
a3283a4c | 272 | regHeader = darcHeader->GetRegHeaderEntry(iReg); |
40e382ae | 273 | |
a3283a4c | 274 | Int_t nLocal = regHeader->GetLocalEntries(); |
40e382ae | 275 | for(Int_t iLocal = 0; iLocal < nLocal; iLocal++) |
276 | { | |
277 | ||
278 | localStruct = regHeader->GetLocalEntry(iLocal); | |
279 | ||
280 | // if card exist | |
281 | if (localStruct) { | |
282 | ||
283 | AliMUONLocalTriggerBoard* localBoard = | |
284 | (AliMUONLocalTriggerBoard*)boards->At(localStruct->GetId()+1); | |
285 | ||
286 | // skip copy cards | |
287 | if( !(loCircuit = localBoard->GetNumber()) ) | |
288 | continue; | |
289 | ||
290 | if (fTriggerStore) | |
291 | { | |
292 | // fill local trigger | |
293 | AliMUONLocalTrigger localTrigger; | |
294 | localTrigger.SetLocalStruct(loCircuit, *localStruct); | |
295 | fTriggerStore->Add(localTrigger); | |
296 | } | |
297 | ||
298 | if ( fMakeTriggerDigits ) | |
299 | { | |
300 | //FIXEME should find something better than a TArray | |
301 | TArrayS xyPattern[2]; | |
302 | xyPattern[0].Set(4); | |
303 | xyPattern[1].Set(4); | |
304 | ||
305 | xyPattern[0].AddAt(localStruct->GetX1(),0); | |
306 | xyPattern[0].AddAt(localStruct->GetX2(),1); | |
307 | xyPattern[0].AddAt(localStruct->GetX3(),2); | |
308 | xyPattern[0].AddAt(localStruct->GetX4(),3); | |
309 | ||
310 | xyPattern[1].AddAt(localStruct->GetY1(),0); | |
311 | xyPattern[1].AddAt(localStruct->GetY2(),1); | |
312 | xyPattern[1].AddAt(localStruct->GetY3(),2); | |
313 | xyPattern[1].AddAt(localStruct->GetY4(),3); | |
314 | ||
315 | TriggerDigits(loCircuit, xyPattern, *fDigitStore); | |
316 | } | |
317 | } // if triggerY | |
a3283a4c | 318 | } // iLocal |
319 | } // iReg | |
320 | } // NextDDL | |
40e382ae | 321 | |
a3283a4c | 322 | fTriggerTimer.Stop(); |
323 | ||
324 | return kTRUE; | |
325 | ||
326 | } | |
7771752e | 327 | |
d2d759cf | 328 | //____________________________________________________________________ |
7771752e | 329 | Int_t AliMUONDigitMaker::TriggerDigits(Int_t nBoard, |
40e382ae | 330 | TArrayS* xyPattern, |
331 | AliMUONVDigitStore& digitStore) const | |
d2d759cf | 332 | { |
40e382ae | 333 | /// make digits for trigger from pattern, and add them to digitStore |
d2d759cf | 334 | |
335 | // loop over x1-4 and y1-4 | |
40e382ae | 336 | for (Int_t iChamber = 0; iChamber < 4; ++iChamber) |
337 | { | |
338 | for (Int_t iCath = 0; iCath < 2; ++iCath) | |
339 | { | |
7771752e | 340 | Int_t pattern = (Int_t)xyPattern[iCath].At(iChamber); |
341 | if (!pattern) continue; | |
40e382ae | 342 | |
7771752e | 343 | // get detElemId |
344 | AliMUONTriggerCircuit triggerCircuit; | |
345 | AliMUONLocalTriggerBoard* localBoard = fCrateManager->LocalBoard(nBoard); | |
40e382ae | 346 | Int_t detElemId = triggerCircuit.DetElemId(iChamber+10, localBoard->GetName());//FIXME +/-10 (should be ok with new mapping) |
347 | ||
348 | const AliMpVSegmentation* seg | |
349 | = AliMpSegmentation::Instance() | |
350 | ->GetMpSegmentation(detElemId, AliMp::GetCathodType(iCath)); | |
351 | ||
352 | // loop over the 16 bits of pattern | |
353 | for (Int_t ibitxy = 0; ibitxy < 16; ++ibitxy) | |
354 | { | |
355 | if ((pattern >> ibitxy) & 0x1) | |
356 | { | |
357 | // not quite sure about this | |
358 | Int_t offset = 0; | |
359 | if (iCath && localBoard->GetSwitch(6)) offset = -8; | |
360 | ||
361 | AliMpPad pad = seg->PadByLocation(AliMpIntPair(nBoard,ibitxy+offset),kTRUE); | |
362 | ||
363 | if (!pad.IsValid()) | |
364 | { | |
365 | AliWarning(Form("No pad for detElemId: %d, nboard %d, ibitxy: %d\n", | |
366 | detElemId, nBoard, ibitxy)); | |
367 | continue; | |
368 | } | |
369 | ||
370 | AliMUONVDigit* digit = digitStore.Add(detElemId,nBoard,ibitxy,iCath,AliMUONVDigitStore::kDeny); | |
371 | ||
372 | if (!digit) | |
373 | { | |
374 | AliError(Form("Could not add digit DE %04d LocalBoard %03d ibitxy %02d cath %d", | |
375 | detElemId,nBoard,ibitxy,iCath)); | |
376 | continue; | |
377 | } | |
378 | ||
379 | Int_t padX = pad.GetIndices().GetFirst(); | |
380 | Int_t padY = pad.GetIndices().GetSecond(); | |
381 | ||
382 | // fill digit | |
383 | digit->SetPadXY(padX,padY); | |
384 | digit->SetCharge(1.); | |
385 | }// xyPattern | |
386 | }// ibitxy | |
7771752e | 387 | }// cath |
388 | } // ichamber | |
40e382ae | 389 | |
d2d759cf | 390 | return kTRUE; |
391 | } | |
d53fb0de | 392 | //____________________________________________________________________ |
40e382ae | 393 | void |
394 | AliMUONDigitMaker::GetCrateName(Char_t* name, Int_t iDDL, Int_t iReg) const | |
d53fb0de | 395 | { |
9265505b | 396 | /// set crate name from DDL & reg number |
397 | /// method same as in RawWriter, not so nice | |
398 | /// should be put in AliMUONTriggerCrateStore | |
d53fb0de | 399 | |
400 | switch(iReg) { | |
401 | case 0: | |
402 | case 1: | |
403 | sprintf(name,"%d", iReg+1); | |
404 | break; | |
405 | case 2: | |
406 | strcpy(name, "2-3"); | |
407 | break; | |
408 | case 3: | |
409 | case 4: | |
410 | case 5: | |
411 | case 6: | |
412 | case 7: | |
413 | sprintf(name,"%d", iReg); | |
414 | break; | |
415 | } | |
416 | ||
417 | // crate Right for first DDL | |
418 | if (iDDL == 0) | |
419 | strcat(name, "R"); | |
420 | else | |
421 | strcat(name, "L"); | |
422 | } |