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