]>
Commit | Line | Data |
---|---|---|
f6762c71 | 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 Raw Data generator in ALICE-MUON | |
19 | // | |
c8b4255f | 20 | // This class version 1 (further details could be found in Alice-note coming soon right in our direction) |
21 | // Generates raw data for MUON tracker and finally for trigger | |
f6762c71 | 22 | // * a simple mapping is used (see below) |
69be760c | 23 | // * the bus patch id is calculated with an absolute number 0 - 999 |
c8b4255f | 24 | // * one DDL per 1/2 chamber is created for both cathode. |
25 | // For trigger there is no mapping (mapping could be found in AliMUONTriggerCircuit) | |
26 | // don't need for digits2raw but needed in raw2Reco | |
27 | // the position are given per local card | |
f6762c71 | 28 | //////////////////////////////////// |
c8b4255f | 29 | |
69be760c | 30 | #include <TClonesArray.h> |
f6762c71 | 31 | #include "AliMUONRawData.h" |
32 | #include "AliMUONDigit.h" | |
1195fa7b | 33 | |
f6762c71 | 34 | #include "AliMUONConstants.h" |
35 | #include "AliMUONData.h" | |
f6762c71 | 36 | #include "AliLoader.h" |
37 | #include "AliBitPacking.h" | |
1195fa7b | 38 | |
39 | #include "AliMUONSubEventTrigger.h" | |
69be760c | 40 | #include "AliMUONDDLTracker.h" |
41 | #include "AliMUONDDLTrigger.h" | |
42 | ||
c8b4255f | 43 | #include "AliMUONLocalTrigger.h" |
44 | #include "AliMUONGlobalTrigger.h" | |
f6762c71 | 45 | |
46 | const Int_t AliMUONRawData::fgkDefaultPrintLevel = 0; | |
47 | ||
48 | ClassImp(AliMUONRawData) // Class implementation in ROOT context | |
49 | ||
50 | //__________________________________________________________________________ | |
51 | AliMUONRawData::AliMUONRawData(AliLoader* loader) | |
69be760c | 52 | : TObject(), |
53 | fDebug(0) | |
f6762c71 | 54 | { |
55 | // Standard Constructor | |
56 | ||
f6762c71 | 57 | fPrintLevel = fgkDefaultPrintLevel; |
58 | ||
59 | // initialize loader's | |
60 | fLoader = loader; | |
61 | ||
62 | // initialize container | |
63 | fMUONData = new AliMUONData(fLoader,"MUON","MUON"); | |
69be760c | 64 | |
65 | // trigger decision, temp solution, local & global has to move to Digits Tree | |
66 | // fTrigDec = new AliMUONTriggerDecision(fLoader); | |
67 | // fTrigData = fTrigDec->GetMUONData(); | |
68 | ||
69 | // initialize array | |
70 | fSubEventArray[0] = new TClonesArray("AliMUONSubEventTracker",1000); | |
71 | fSubEventArray[1] = new TClonesArray("AliMUONSubEventTracker",1000); | |
72 | ||
73 | // initialize array | |
74 | fSubEventTrigArray[0] = new TClonesArray("AliMUONSubEventTrigger",1000); | |
75 | fSubEventTrigArray[1] = new TClonesArray("AliMUONSubEventTrigger",1000); | |
76 | ||
77 | // ddl pointer | |
78 | fDDLTracker = new AliMUONDDLTracker(); | |
79 | fDDLTrigger= new AliMUONDDLTrigger(); | |
f6762c71 | 80 | } |
81 | ||
82 | //__________________________________________________________________________ | |
83 | AliMUONRawData::AliMUONRawData() | |
84 | : TObject(), | |
f6762c71 | 85 | fMUONData(0), |
86 | fPrintLevel(fgkDefaultPrintLevel), | |
87 | fDebug(0), | |
88 | fLoader(0) | |
89 | { | |
90 | // Default Constructor | |
91 | } | |
92 | ||
93 | //_______________________________________________________________________ | |
94 | AliMUONRawData::AliMUONRawData (const AliMUONRawData& rhs) | |
95 | : TObject(rhs) | |
96 | { | |
97 | // Protected copy constructor | |
98 | ||
e516b01d | 99 | Fatal("AliMUONRawData", "Not implemented."); |
f6762c71 | 100 | } |
101 | ||
102 | //_______________________________________________________________________ | |
103 | AliMUONRawData & | |
104 | AliMUONRawData::operator=(const AliMUONRawData& rhs) | |
105 | { | |
106 | // Protected assignement operator | |
107 | ||
108 | if (this == &rhs) return *this; | |
109 | ||
e516b01d | 110 | Fatal("operator=", "Not implemented."); |
f6762c71 | 111 | |
112 | return *this; | |
113 | } | |
114 | ||
115 | //__________________________________________________________________________ | |
116 | AliMUONRawData::~AliMUONRawData(void) | |
117 | { | |
118 | if (fMUONData) | |
119 | delete fMUONData; | |
69be760c | 120 | if (fSubEventArray[0]) |
121 | fSubEventArray[0]->Delete(); //using delete cos allocating memory in copy ctor. | |
122 | if (fSubEventArray[1]) | |
123 | fSubEventArray[1]->Delete(); | |
124 | ||
125 | if (fSubEventTrigArray[0]) | |
126 | fSubEventTrigArray[0]->Delete(); | |
127 | if (fSubEventTrigArray[1]) | |
128 | fSubEventTrigArray[1]->Delete(); | |
129 | ||
130 | if (fDDLTracker) | |
131 | delete fDDLTracker; | |
132 | if (fDDLTrigger) | |
133 | delete fDDLTrigger; | |
134 | ||
f6762c71 | 135 | return; |
136 | } | |
137 | //____________________________________________________________________ | |
138 | Int_t AliMUONRawData::WriteRawData() | |
139 | { | |
140 | // convert digits of the current event to raw data | |
141 | ||
1195fa7b | 142 | Int_t idDDL; |
f6762c71 | 143 | Char_t name[20]; |
144 | ||
145 | fLoader->LoadDigits("READ"); | |
69be760c | 146 | |
c8b4255f | 147 | fMUONData->SetTreeAddress("D,GLT"); |
f6762c71 | 148 | |
f6762c71 | 149 | |
c8b4255f | 150 | // tracking chambers |
151 | ||
152 | for (Int_t ich = 0; ich < AliMUONConstants::NTrackingCh(); ich++) { | |
153 | ||
f6762c71 | 154 | // open files |
1195fa7b | 155 | idDDL = ich * 2 + 0x900; |
156 | sprintf(name, "MUON_%d.ddl",idDDL); | |
f6762c71 | 157 | fFile1 = fopen(name,"w"); |
158 | ||
1195fa7b | 159 | idDDL = (ich * 2) + 1 + 0x900; |
160 | sprintf(name, "MUON_%d.ddl",idDDL); | |
f6762c71 | 161 | fFile2 = fopen(name,"w"); |
162 | ||
69be760c | 163 | WriteTrackerDDL(ich); |
f6762c71 | 164 | |
165 | // reset and close | |
166 | fclose(fFile1); | |
167 | fclose(fFile2); | |
168 | fMUONData->ResetDigits(); | |
169 | } | |
69be760c | 170 | |
171 | // trigger chambers | |
c8b4255f | 172 | |
69be760c | 173 | // open files |
1195fa7b | 174 | idDDL = 0xA00; |
175 | sprintf(name, "MUTR_%d.ddl",idDDL); | |
c8b4255f | 176 | fFile1 = fopen(name,"w"); |
69be760c | 177 | |
1195fa7b | 178 | idDDL = 0xA00 + 1; |
179 | sprintf(name, "MUTR_%d.ddl",idDDL); | |
c8b4255f | 180 | fFile2 = fopen(name,"w"); |
69be760c | 181 | |
c8b4255f | 182 | WriteTriggerDDL(); |
183 | ||
184 | // reset and close | |
185 | fclose(fFile1); | |
186 | fclose(fFile2); | |
187 | fMUONData->ResetTrigger(); | |
f6762c71 | 188 | |
c8b4255f | 189 | fLoader->UnloadDigits(); |
69be760c | 190 | |
f6762c71 | 191 | return kTRUE; |
192 | } | |
193 | //____________________________________________________________________ | |
69be760c | 194 | Int_t AliMUONRawData::WriteTrackerDDL(Int_t iCh) |
f6762c71 | 195 | { |
69be760c | 196 | // resets |
f6762c71 | 197 | TClonesArray* muonDigits = 0; |
69be760c | 198 | fSubEventArray[0]->Clear(); |
199 | fSubEventArray[1]->Clear(); | |
200 | ||
201 | // | |
202 | TArrayI nbInBus[2]; | |
203 | ||
204 | nbInBus[0].Set(5000); | |
205 | nbInBus[1].Set(5000); | |
206 | ||
207 | nbInBus[0].Reset(); | |
208 | nbInBus[1].Reset(); | |
209 | ||
210 | // DDL header | |
211 | AliRawDataHeader header = fDDLTracker->GetHeader(); | |
212 | Int_t headerSize = fDDLTracker->GetHeaderSize(); | |
f6762c71 | 213 | |
214 | // DDL event one per half chamber | |
69be760c | 215 | AliMUONSubEventTracker* subEvent; |
f6762c71 | 216 | |
217 | // data format | |
218 | Char_t parity = 0x4; | |
69be760c | 219 | UShort_t manuId = 0; |
220 | UChar_t channelId = 0; | |
221 | UShort_t charge = 0; | |
222 | Int_t busPatchId = 0; | |
f6762c71 | 223 | |
224 | UInt_t word; | |
69be760c | 225 | Int_t nEntries = 0; |
226 | Int_t* buffer = 0; | |
227 | Int_t index; | |
228 | Int_t indexDsp; | |
229 | Int_t indexBlk; | |
f6762c71 | 230 | |
231 | Int_t nDigits; | |
69be760c | 232 | const AliMUONDigit* digit; |
f6762c71 | 233 | |
c8b4255f | 234 | if (fPrintLevel == 1) |
69be760c | 235 | printf("WriteDDL chamber %d\n", iCh+1); |
f6762c71 | 236 | |
237 | for (Int_t iCath = 0; iCath < 2; iCath++) { | |
238 | ||
f6762c71 | 239 | fMUONData->ResetDigits(); |
240 | fMUONData->GetCathode(iCath); | |
241 | muonDigits = fMUONData->Digits(iCh); | |
242 | ||
243 | nDigits = muonDigits->GetEntriesFast(); | |
69be760c | 244 | if (fPrintLevel == 2) |
f6762c71 | 245 | printf("ndigits = %d\n",nDigits); |
246 | ||
247 | // open DDL file, on per 1/2 chamber | |
248 | ||
249 | for (Int_t idig = 0; idig < nDigits; idig++) { | |
250 | ||
251 | digit = (AliMUONDigit*) muonDigits->UncheckedAt(idig); | |
252 | ||
69be760c | 253 | // mapping |
254 | GetDummyMapping(iCh, iCath, digit, busPatchId, manuId, channelId, charge); | |
255 | ||
256 | //packing word | |
257 | AliBitPacking::PackWord((UInt_t)parity,word,29,31); | |
258 | AliBitPacking::PackWord((UInt_t)manuId,word,18,28); | |
259 | AliBitPacking::PackWord((UInt_t)channelId,word,12,17); | |
260 | AliBitPacking::PackWord((UInt_t)charge,word,0,11); | |
261 | ||
262 | // set sub Event | |
263 | subEvent = new AliMUONSubEventTracker(); | |
264 | subEvent->AddData(word); | |
265 | subEvent->SetBusPatchId(busPatchId); | |
266 | if (digit->PadX() > 0) { | |
267 | nbInBus[0][busPatchId]++; | |
268 | AddData1(subEvent); | |
269 | } else { | |
270 | nbInBus[1][busPatchId]++; | |
271 | AddData2(subEvent); | |
272 | } | |
273 | delete subEvent; | |
274 | } | |
275 | } | |
276 | fSubEventArray[0]->Sort(); | |
277 | fSubEventArray[1]->Sort(); | |
278 | ||
279 | // gather datas from same bus patch | |
280 | for (Int_t iDDL = 0; iDDL < 2; iDDL++) { | |
281 | nEntries = fSubEventArray[iDDL]->GetEntriesFast(); | |
282 | ||
283 | for (Int_t i = 0; i < nEntries; i++) { | |
284 | AliMUONSubEventTracker* temp = (AliMUONSubEventTracker*)fSubEventArray[iDDL]->At(i); | |
285 | busPatchId = temp->GetBusPatchId(); | |
286 | ||
287 | // add bus patch header, length and total length managed by subevent class | |
288 | temp->SetTriggerWord(0xdeadbeef); | |
289 | for (Int_t j = 0; j < nbInBus[iDDL][busPatchId]-1; j++) { | |
290 | AliMUONSubEventTracker* temp1 = (AliMUONSubEventTracker*)fSubEventArray[iDDL]->At(++i); | |
291 | temp->AddData(temp1->GetData(0)); | |
292 | fSubEventArray[iDDL]->RemoveAt(i) ; | |
293 | } | |
294 | } | |
295 | fSubEventArray[iDDL]->Compress(); | |
296 | ||
297 | if (fPrintLevel == 3) { | |
298 | nEntries = fSubEventArray[iDDL]->GetEntriesFast(); | |
299 | for (Int_t i = 0; i < nEntries; i++) { | |
300 | AliMUONSubEventTracker* temp = (AliMUONSubEventTracker*)fSubEventArray[iDDL]->At(i); | |
301 | printf("busPatchid back %d\n",temp->GetBusPatchId()); | |
302 | for (Int_t j = 0; j < temp->GetLength(); j++) { | |
303 | printf("manuId back %d, ",temp->GetManuId(j)); | |
304 | printf("channelId back %d, ",temp->GetChannelId(j)); | |
305 | printf("charge back %d\n",temp->GetCharge(j)); | |
306 | } | |
307 | } | |
308 | printf("\n"); | |
309 | } | |
310 | ||
311 | } | |
312 | ||
313 | Int_t iBusPatch; | |
314 | Int_t iEntries; | |
315 | ||
316 | for (Int_t iDDL = 0; iDDL < 2; iDDL++) { | |
317 | ||
318 | ||
319 | // filling buffer | |
320 | nEntries = fSubEventArray[iDDL]->GetEntriesFast(); | |
321 | buffer = new Int_t [(2048+24)*50]; // 24 words in average for one buspatch and 2048 manu info at most | |
322 | ||
323 | indexBlk = 0; | |
324 | indexDsp = 0; | |
325 | index = 0; | |
326 | iBusPatch = 0; | |
327 | iEntries = 0; | |
328 | ||
329 | for (Int_t iBlock = 0; iBlock < 2; iBlock++) { | |
330 | ||
331 | // block header | |
332 | fDDLTracker->SetTotalBlkLength(0xFFFFFFFF); | |
333 | memcpy(&buffer[index],fDDLTracker->GetBlkHeader(),32); | |
334 | indexBlk = index; | |
335 | index += 8; | |
336 | ||
337 | for (Int_t iDsp = 0; iDsp < 5; iDsp++) { | |
338 | ||
339 | // DSP header | |
340 | fDDLTracker->SetTotalDspLength(0xEEEEEEEE); | |
341 | memcpy(&buffer[index],fDDLTracker->GetDspHeader(),32); | |
342 | indexDsp = index; | |
343 | index += 8; | |
344 | ||
345 | for (Int_t i = 0; i < 5; i++) { | |
346 | ||
347 | iBusPatch = i + iBlock*25 + iDsp*5 + 50*(2*iCh + iDDL); | |
348 | ||
349 | AliMUONSubEventTracker* temp = (AliMUONSubEventTracker*)fSubEventArray[iDDL]->At(iEntries); | |
350 | if (nEntries > 0) | |
351 | busPatchId = temp->GetBusPatchId(); | |
352 | else | |
353 | busPatchId = -1; | |
354 | ||
355 | if (busPatchId == iBusPatch) { | |
356 | // add bus patch structure | |
357 | memcpy(&buffer[index],temp->GetAddress(),16); | |
358 | index+= 4; | |
359 | for (Int_t j = 0; j < temp->GetLength(); j++) | |
360 | buffer[index++] = temp->GetData(j); | |
361 | if (iEntries < nEntries-1) | |
362 | iEntries++; | |
363 | } else { | |
364 | buffer[index++] = 4; // total length | |
365 | buffer[index++] = 0; // raw data length | |
366 | buffer[index++] = iBusPatch; // bus patch | |
367 | buffer[index++] = 0xdeadbeef; // trigger word | |
368 | } | |
369 | } // bus patch | |
370 | buffer[indexDsp] = index - indexDsp; | |
371 | buffer[indexDsp+1] = index - indexDsp -8; | |
372 | if ((index - indexDsp) % 2 == 0) | |
373 | buffer[indexDsp+7] = 0; | |
374 | else | |
375 | buffer[indexDsp+7] = 1; | |
376 | } // dsp | |
377 | buffer[indexBlk] = index - indexBlk; | |
378 | buffer[indexBlk+1] = index - indexBlk -8; | |
379 | } | |
380 | if (iDDL == 0) { | |
381 | // write DDL 1 | |
382 | header.fSize = index + headerSize;// total length in word | |
383 | fwrite((char*)(&header),headerSize*4,1,fFile1); | |
384 | fwrite(buffer,sizeof(int),index,fFile1); | |
385 | } | |
386 | if (iDDL == 1) { | |
387 | // write DDL 2 | |
388 | header.fSize = index + headerSize;// total length in word | |
389 | fwrite((char*)(&header),headerSize*4,1,fFile2); | |
390 | fwrite(buffer,sizeof(int),index,fFile2); | |
391 | } | |
392 | delete[] buffer; | |
393 | } | |
394 | ||
395 | return kTRUE; | |
396 | } | |
397 | //____________________________________________________________________ | |
398 | Int_t AliMUONRawData::WriteTriggerDDL() | |
399 | { | |
400 | ||
c8b4255f | 401 | // DDL event one per half chamber |
402 | AliMUONSubEventTrigger* subEvent = 0x0; | |
69be760c | 403 | |
69be760c | 404 | |
c8b4255f | 405 | // stored local id number |
406 | TArrayI isFired(256); | |
407 | isFired.Reset(); | |
69be760c | 408 | |
69be760c | 409 | |
c8b4255f | 410 | // DDL header |
411 | AliRawDataHeader header = fDDLTrigger->GetHeader(); | |
412 | Int_t headerSize = fDDLTrigger->GetHeaderSize(); | |
413 | ||
414 | TClonesArray* localTrigger; | |
415 | TClonesArray* globalTrigger; | |
416 | AliMUONGlobalTrigger* gloTrg; | |
417 | AliMUONLocalTrigger* locTrg = 0x0; | |
418 | ||
419 | fMUONData->GetTriggerD(); | |
420 | ||
421 | // global trigger for trigger pattern | |
422 | globalTrigger = fMUONData->GlobalTrigger(); | |
423 | gloTrg = (AliMUONGlobalTrigger*)globalTrigger->UncheckedAt(0); | |
424 | Int_t gloTrigPat = GetGlobalTriggerPattern(gloTrg); | |
425 | ||
426 | // local trigger | |
427 | localTrigger = fMUONData->LocalTrigger(); | |
428 | ||
429 | UInt_t word; | |
430 | Int_t* buffer = 0; | |
431 | Int_t index; | |
432 | Int_t iEntries = 0; | |
433 | Int_t iLocCard, locCard; | |
e516b01d | 434 | Char_t locDec, trigY, posY, devX, posX,regOut; |
c8b4255f | 435 | Int_t version = 1; // software version |
436 | Int_t eventType =1; // trigger type: 1 for physics ? | |
437 | Int_t serialNb = 0xF; // serial nb of card: all bits on for the moment | |
438 | ||
439 | Int_t nEntries = (Int_t) (localTrigger->GetEntries());// 234 local cards | |
440 | // stored the local card id that's fired | |
441 | for (Int_t i = 0; i < nEntries; i++) { | |
442 | locTrg = (AliMUONLocalTrigger*)localTrigger->At(i); | |
443 | isFired[locTrg->LoCircuit()] = 1; | |
444 | } | |
445 | ||
446 | if (!nEntries) | |
e516b01d | 447 | Error("AliMUONRawData::WriteTriggerDDL","No Trigger information available"); |
c8b4255f | 448 | |
a0b2ac9a | 449 | buffer = new Int_t [680]; // [16(local)*5 words + 4 words]*8(reg) + 8 words = 680 |
c8b4255f | 450 | |
451 | for (Int_t iDDL = 0; iDDL < 2; iDDL++) { | |
452 | ||
453 | index = 0; | |
454 | ||
455 | // DDL enhanced header | |
456 | word =0; | |
457 | AliBitPacking::PackWord((UInt_t)iDDL+1,word,30,31); //see AliMUONDDLTrigger.h for details | |
458 | AliBitPacking::PackWord((UInt_t)version,word,22,29); | |
459 | AliBitPacking::PackWord((UInt_t)serialNb,word,18,21); | |
460 | AliBitPacking::PackWord((UInt_t)eventType,word,14,17); | |
461 | ||
462 | fDDLTrigger->SetDDLWord(word); | |
463 | fDDLTrigger->SetGlobalOutput(gloTrigPat); | |
464 | memcpy(&buffer[index],fDDLTrigger->GetEnhancedHeader(),24); | |
465 | index += 6; | |
466 | ||
467 | for (Int_t iReg = 0; iReg < 8; iReg++) { | |
468 | ||
469 | subEvent = new AliMUONSubEventTrigger(); | |
470 | ||
471 | // Regional card header | |
472 | word = 0; | |
e516b01d | 473 | regOut = 0; |
474 | AliBitPacking::PackWord((UInt_t)serialNb,word,24,28); //see AliMUONSubEventTrigger.h for details | |
475 | AliBitPacking::PackWord((UInt_t)version,word,16,23); | |
476 | AliBitPacking::PackWord((UInt_t)iReg,word,12,15); | |
477 | AliBitPacking::PackWord((UInt_t)regOut,word,0,7); // whenever regional output will be implemented | |
478 | ||
c8b4255f | 479 | subEvent->SetRegWord(word); |
480 | memcpy(&buffer[index++],subEvent->GetAddress(),4); | |
481 | ||
e516b01d | 482 | buffer[index++] = 0;// 2 words of regional input |
483 | buffer[index++] = 0; | |
484 | ||
c8b4255f | 485 | for (Int_t iLoc = 0; iLoc < 16; iLoc++) { |
486 | ||
487 | iLocCard = iLoc + iReg*16 + iDDL*128; | |
488 | ||
489 | if (isFired[iLocCard]) { | |
490 | locTrg = (AliMUONLocalTrigger*)localTrigger->At(iEntries); | |
491 | locCard = locTrg->LoCircuit(); | |
492 | locDec = locTrg->GetLoDecision(); | |
493 | trigY = 0; | |
494 | posY = locTrg->LoStripY(); | |
495 | posX = locTrg->LoStripX(); | |
496 | devX = locTrg->LoDev(); | |
497 | if (fPrintLevel == 4) | |
498 | printf("loctrg %d, posX %d, posY %d, devX %d\n", | |
499 | locTrg-> LoCircuit(),locTrg->LoStripX(),locTrg->LoStripY(),locTrg->LoDev()); | |
500 | } else { //no trigger (see PRR chpt 3.4) | |
501 | locCard = -1; | |
502 | locDec = 0; | |
503 | trigY = 1; | |
504 | posY = 15; | |
505 | posX = 0; | |
506 | devX = 0x8000; | |
507 | } | |
508 | ||
509 | //packing word | |
510 | word = 0; | |
511 | AliBitPacking::PackWord((UInt_t)(iLocCard % 16),word,19,22); //card id number in crate | |
512 | AliBitPacking::PackWord((UInt_t)locDec,word,15,18); | |
513 | AliBitPacking::PackWord((UInt_t)trigY,word,14,14); | |
514 | AliBitPacking::PackWord((UInt_t)posY,word,10,13); | |
515 | AliBitPacking::PackWord((UInt_t)devX,word,5,9); | |
516 | AliBitPacking::PackWord((UInt_t)posX,word,0,4); | |
517 | ||
518 | if (locCard == iLocCard) { | |
519 | // add local cards structure | |
520 | buffer[index++] = (locTrg->GetX1Pattern() | (locTrg->GetX2Pattern() << 16)); | |
521 | buffer[index++] = (locTrg->GetX3Pattern() | (locTrg->GetX4Pattern() << 16)); | |
522 | buffer[index++] = (locTrg->GetY1Pattern() | (locTrg->GetY2Pattern() << 16)); | |
523 | buffer[index++] = (locTrg->GetY3Pattern() | (locTrg->GetY4Pattern() << 16)); | |
524 | buffer[index++] = (Int_t)word; // data word | |
525 | if (iEntries < nEntries-1) | |
526 | iEntries++; | |
527 | } else { | |
528 | buffer[index++] = 0; // 4 words for x1, x2, y1, y2 | |
529 | buffer[index++] = 0; | |
530 | buffer[index++] = 0; | |
531 | buffer[index++] = 0; | |
532 | buffer[index++] = (Int_t)word; // data word | |
533 | ||
534 | } | |
535 | } // local card | |
c8b4255f | 536 | |
537 | delete subEvent; | |
538 | ||
539 | } // Regional card | |
540 | ||
541 | buffer[index++] = fDDLTrigger->GetEoD(); // End of DDL word | |
a0b2ac9a | 542 | buffer[index++] = fDDLTrigger->GetEoD(); // End of DDL word for 64 bits transfer purpose |
c8b4255f | 543 | |
544 | ||
545 | if (iDDL == 0) { | |
546 | // write DDL 1 | |
547 | header.fSize = index + headerSize;// total length in word | |
548 | fwrite((char*)(&header),headerSize*4,1,fFile1); | |
549 | fwrite(buffer,sizeof(int),index,fFile1); | |
550 | } | |
551 | if (iDDL == 1) { | |
552 | // write DDL 2 | |
553 | header.fSize = index + headerSize;// total length in word | |
554 | fwrite((char*)(&header),headerSize*4,1,fFile2); | |
555 | fwrite(buffer,sizeof(int),index,fFile2); | |
556 | } | |
557 | } | |
558 | delete[] buffer; | |
69be760c | 559 | |
560 | return kTRUE; | |
561 | } | |
562 | //____________________________________________________________________ | |
563 | void AliMUONRawData::GetDummyMapping(Int_t iCh, Int_t iCath, const AliMUONDigit* digit, | |
564 | Int_t &busPatchId, UShort_t &manuId, UChar_t &channelId, UShort_t &charge) | |
565 | { | |
1195fa7b | 566 | // Dummy mapping for tracker |
69be760c | 567 | |
568 | Int_t offsetX = 0; // offet row | |
569 | Int_t offsetY = 0; // offset columns | |
570 | Int_t offsetCath = 0; //offset from one cathod to the other | |
571 | Int_t maxChannel = 0; // maximum nb of channel in 1/2 chamber | |
572 | Int_t id; | |
f6762c71 | 573 | switch (iCh+1) { |
574 | case 1: | |
575 | case 2: | |
576 | case 3: | |
577 | case 4: | |
578 | offsetX = 512; | |
579 | offsetY = 256; | |
580 | offsetCath = 65536; | |
581 | maxChannel = (offsetY * offsetX + 2* offsetY + offsetCath); | |
582 | break; | |
583 | case 5: | |
584 | case 6: | |
585 | case 7: | |
586 | case 8: | |
587 | case 9: | |
588 | case 10: | |
589 | offsetX = 1024; | |
590 | offsetY = 0; | |
591 | offsetCath = 65536; | |
592 | maxChannel = (256 * offsetX + offsetX + offsetCath); | |
593 | break; | |
594 | } | |
595 | // dummy mapping | |
596 | // manu Id directly from a matrix 8*8, same segmentation for B and NB | |
597 | // 50 buspatches for 1/2 chamber | |
f6762c71 | 598 | |
69be760c | 599 | id = (TMath::Abs(digit->PadX()) * offsetX + digit->PadY() + offsetY + |
600 | offsetCath * iCath); | |
601 | Int_t chPerBus = maxChannel/50; | |
602 | busPatchId = id/chPerBus; // start at zero | |
603 | if (digit->PadX() > 0) | |
604 | busPatchId += 50*iCh*2; | |
605 | else | |
606 | busPatchId += 50*(2*iCh+1); | |
f6762c71 | 607 | // 64 manu cards for one buspatch |
69be760c | 608 | manuId = (id % chPerBus)/64; //start at zero |
f6762c71 | 609 | manuId &= 0x7FF; // 11 bits |
610 | ||
611 | // channel id | |
69be760c | 612 | channelId = (id % chPerBus) % 64; //start at zero |
f6762c71 | 613 | channelId &= 0x3F; // 6 bits |
614 | ||
69be760c | 615 | // id = (TMath::Abs(digit->PadX()) * offsetX + digit->PadY() + offsetY + |
616 | // offsetCath * iCath); | |
617 | // busPatchId = id/50; | |
618 | ||
619 | // Int_t inBusId = id - (maxChannel/50 * busPatchId);// id channel in buspatch | |
620 | // Int_t manuPerBus = (maxChannel/(50*64)); // number of manus per buspatch | |
621 | ||
622 | // // 64 manu cards for one buspatch | |
623 | // manuId = inBusId/manuPerBus; | |
624 | // manuId &= 0x7FF; // 11 bits | |
625 | ||
626 | // // channel id | |
627 | // channelId = (inBusId % manuPerBus); | |
628 | // channelId &= 0x3F; // 6 bits | |
629 | ||
630 | if (fPrintLevel == 2) | |
631 | printf("id: %d, busPatchId %d, manuId: %d, channelId: %d, maxchannel: %d, chPerBus %d\n", | |
632 | id, busPatchId, manuId, channelId, maxChannel, chPerBus); | |
f6762c71 | 633 | // charge |
634 | charge = digit->Signal(); | |
635 | charge &= 0xFFF; | |
636 | ||
69be760c | 637 | if (fPrintLevel == 2) |
f6762c71 | 638 | printf("id: %d, busPatchId %d, manuId: %d, channelId: %d, padx: %d pady %d, charge %d\n", |
639 | id, busPatchId, manuId, channelId, digit->PadX(), digit->PadY(), digit->Signal()); | |
f6762c71 | 640 | |
f6762c71 | 641 | } |
c8b4255f | 642 | |
643 | //____________________________________________________________________ | |
1195fa7b | 644 | Int_t AliMUONRawData::GetGlobalTriggerPattern(const AliMUONGlobalTrigger* gloTrg) |
c8b4255f | 645 | { |
1195fa7b | 646 | // global trigger pattern calculation |
647 | ||
c8b4255f | 648 | Int_t gloTrigPat = 0; |
649 | ||
650 | if (gloTrg->SinglePlusLpt()) gloTrigPat|= 0x1; | |
651 | if (gloTrg->SinglePlusHpt()) gloTrigPat|= 0x2; | |
652 | if (gloTrg->SinglePlusApt()) gloTrigPat|= 0x4; | |
653 | ||
654 | if (gloTrg->SingleMinusLpt()) gloTrigPat|= 0x8; | |
655 | if (gloTrg->SingleMinusHpt()) gloTrigPat|= 0x10; | |
656 | if (gloTrg->SingleMinusApt()) gloTrigPat|= 0x20; | |
657 | ||
658 | if (gloTrg->SingleUndefLpt()) gloTrigPat|= 0x40; | |
659 | if (gloTrg->SingleUndefHpt()) gloTrigPat|= 0x80; | |
660 | if (gloTrg->SingleUndefApt()) gloTrigPat|= 0x100; | |
661 | ||
662 | if (gloTrg->PairUnlikeLpt()) gloTrigPat|= 0x200; | |
663 | if (gloTrg->PairUnlikeHpt()) gloTrigPat|= 0x400; | |
664 | if (gloTrg->PairUnlikeApt()) gloTrigPat|= 0x800; | |
665 | ||
666 | if (gloTrg->PairLikeLpt()) gloTrigPat|= 0x1000; | |
667 | if (gloTrg->PairLikeHpt()) gloTrigPat|= 0x2000; | |
668 | if (gloTrg->PairLikeApt()) gloTrigPat|= 0x4000; | |
669 | ||
670 | return gloTrigPat; | |
671 | } |