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