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