1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
18 ////////////////////////////////////
20 // MUON Raw Data generaton in ALICE-MUON
21 // This class version 3 (further details could be found in Alice-note)
23 // Implemented non-constant buspatch numbers for tracking
24 // with correct DDL id (first guess)
25 // (Ch. Finck, dec 2005)
28 // Generates raw data for MUON tracker and finally for trigger
29 // Using real mapping (inverse) for tracker
30 // For trigger there is no mapping (mapping could be found in AliMUONTriggerCircuit)
32 // Use memcpy instead of assignment elt by elt
33 // Introducing variable DSP numbers, real manu numbers per buspatch for st12
34 // Implemented scaler event for Trigger
37 ////////////////////////////////////
39 #include "AliMUONRawWriter.h"
41 #include "AliBitPacking.h"
42 #include "AliRawReader.h"
46 #include "AliMUONConstants.h"
48 #include "AliMUONDarcHeader.h"
49 #include "AliMUONRegHeader.h"
50 #include "AliMUONLocalStruct.h"
51 #include "AliMUONDspHeader.h"
52 #include "AliMUONBlockHeader.h"
54 #include "AliMUONData.h"
55 #include "AliMUONDigit.h"
56 #include "AliMUONGlobalTrigger.h"
57 #include "AliMUONLocalTrigger.h"
59 #include "AliMpBusPatch.h"
60 #include "AliMpDEManager.h"
62 #include "AliMpPlaneType.h"
63 #include "AliMpSegFactory.h"
64 #include "AliMpStationType.h"
65 #include "AliMpVSegmentation.h"
67 #include "TClonesArray.h"
69 ClassImp(AliMUONRawWriter) // Class implementation in ROOT context
71 Int_t AliMUONRawWriter::fgManuPerBusSwp1B[12] = {1, 27, 53, 79, 105, 131, 157, 183, 201, 214, 224, 232};
72 Int_t AliMUONRawWriter::fgManuPerBusSwp1NB[12] = {1, 27, 53, 79, 105, 131, 157, 183, 201, 214, 225, 233};
74 Int_t AliMUONRawWriter::fgManuPerBusSwp2B[12] = {1, 27, 53, 79, 105, 131, 157, 183, 201, 214, 226, 246};
75 Int_t AliMUONRawWriter::fgManuPerBusSwp2NB[12] = {1, 27, 53, 79, 105, 131, 157, 183, 201, 214, 227, 245};
78 //__________________________________________________________________________
79 AliMUONRawWriter::AliMUONRawWriter(AliMUONData* data)
84 // Standard Constructor
86 AliDebug(1,"Standard ctor");
88 // initialize container
92 fBusArray = new TClonesArray("AliMUONBusStruct",1000);
93 fBusArray->SetOwner(kTRUE);
95 // ddl tracker pointers
96 fBlockHeader = new AliMUONBlockHeader();
97 fDspHeader = new AliMUONDspHeader();
98 fBusStruct = new AliMUONBusStruct();
100 // setting data key to default value (only for writting)
101 fBlockHeader->SetDataKey(fBlockHeader->GetDefaultDataKey());
102 fDspHeader->SetDataKey(fDspHeader->GetDefaultDataKey());
103 fBusStruct->SetDataKey(fBusStruct->GetDefaultDataKey());
105 // ddl trigger pointers
106 fDarcHeader = new AliMUONDarcHeader();
107 fRegHeader = new AliMUONRegHeader();
108 fLocalStruct = new AliMUONLocalStruct();
110 // bus patch & Seg managers
111 fBusPatchManager = new AliMpBusPatch();
112 fBusPatchManager->ReadBusPatchFile();
114 fSegFactory = new AliMpSegFactory();
117 fTrackerTimer.Start(kTRUE); fTrackerTimer.Stop();
118 fTriggerTimer.Start(kTRUE); fTriggerTimer.Stop();
119 fMappingTimer.Start(kTRUE); fMappingTimer.Stop();
123 //__________________________________________________________________________
124 AliMUONRawWriter::AliMUONRawWriter()
134 fScalerEvent(kFALSE),
138 // Default Constructor
140 AliDebug(1,"Default ctor");
141 fFile[0] = fFile[1] = 0x0;
142 fTrackerTimer.Start(kTRUE); fTrackerTimer.Stop();
143 fTriggerTimer.Start(kTRUE); fTriggerTimer.Stop();
144 fMappingTimer.Start(kTRUE); fMappingTimer.Stop();
147 //_______________________________________________________________________
148 AliMUONRawWriter::AliMUONRawWriter (const AliMUONRawWriter& rhs)
152 // Protected copy constructor
154 AliFatal("Not implemented.");
157 //_______________________________________________________________________
159 AliMUONRawWriter::operator=(const AliMUONRawWriter& rhs)
162 // Protected assignement operator
164 if (this == &rhs) return *this;
166 AliFatal("Not implemented.");
171 //__________________________________________________________________________
172 AliMUONRawWriter::~AliMUONRawWriter(void)
188 delete fBusPatchManager;
192 AliInfo(Form("Execution time for MUON tracker : R:%.2fs C:%.2fs",
193 fTrackerTimer.RealTime(),fTrackerTimer.CpuTime()));
194 AliInfo(Form(" Execution time for MUON tracker (mapping calls part) "
196 fMappingTimer.RealTime(),fMappingTimer.CpuTime()));
197 AliInfo(Form("Execution time for MUON trigger : R:%.2fs C:%.2fs",
198 fTriggerTimer.RealTime(),fTriggerTimer.CpuTime()));
201 //____________________________________________________________________
202 Int_t AliMUONRawWriter::Digits2Raw()
205 // convert digits of the current event to raw data
210 fMUONData->GetLoader()->LoadDigits("READ");
212 fMUONData->SetTreeAddress("D,GLT");
214 fMUONData->ResetDigits();
215 fMUONData->ResetTrigger();
217 // This will get both tracker and trigger digits.
218 fMUONData->GetDigits();
222 for (Int_t ich = 0; ich < AliMUONConstants::NTrackingCh(); ich++)
225 // idDDL = ich * 2 + AliDAQ::DdlIDOffset("MUONTRK"); // waiting update in STEER
226 idDDL = ich * 2 + 0x900; // official number for MUON
227 sprintf(name, "MUON_%d.ddl",idDDL);
228 fFile[0] = fopen(name,"w");
230 // idDDL = (ich * 2) + 1 + AliDAQ::DdlIDOffset("MUONTRK");
231 idDDL = (ich * 2) + 1 + 0x900;
232 sprintf(name, "MUON_%d.ddl",idDDL);
233 fFile[1] = fopen(name,"w");
235 WriteTrackerDDL(ich);
245 // idDDL = AliDAQ::DdlIDOffset("MUONTRG");
246 idDDL = 0xA00;// official number for MUTR
247 sprintf(name, "MUTR_%d.ddl",idDDL);
248 fFile[0] = fopen(name,"w");
250 // idDDL = AliDAQ::DdlIDOffset("MUONTRG") + 1;
251 idDDL = 0xA00 + 1;// official number for MUTR
252 sprintf(name, "MUTR_%d.ddl",idDDL);
253 fFile[1] = fopen(name,"w");
261 fMUONData->ResetDigits();
262 fMUONData->ResetTrigger();
263 fMUONData->GetLoader()->UnloadDigits();
268 //____________________________________________________________________
269 Int_t AliMUONRawWriter::WriteTrackerDDL(Int_t iCh)
271 // writing DDL for tracker
272 // used inverse mapping
274 fTrackerTimer.Start(kFALSE);
277 static const Int_t kMAXADC = (1<<12)-1; // We code the charge on a 12 bits ADC.
280 TClonesArray* muonDigits = 0;
293 Int_t headerSize = sizeof(fHeader)/4;
295 // DDL event one per half chamber
300 UChar_t channelId = 0;
302 Int_t busPatchId = 0;
307 Int_t totalDspLength;
311 Int_t totalBlkLength;
315 Int_t totalDDLLength;
331 const AliMUONDigit* digit;
333 AliDebug(3, Form("WriteDDL chamber %d\n", iCh+1));
335 muonDigits = fMUONData->Digits(iCh);
337 nDigits = muonDigits->GetEntriesFast();
338 AliDebug(3,Form("ndigits = %d\n",nDigits));
341 for (Int_t idig = 0; idig < nDigits; idig++) {
343 digit = (AliMUONDigit*) muonDigits->UncheckedAt(idig);
345 padX = digit->PadX();
346 padY = digit->PadY();
347 charge = digit->ADC();
348 if ( charge > kMAXADC )
350 // This is most probably an error in the digitizer (which should insure
351 // the adc is below kMAXADC), so make it a (non-fatal) error indeed.
352 AliError(Form("adc value %d above %x. Setting to %x",
353 charge,kMAXADC,kMAXADC));
356 cathode = digit->Cathode();
357 detElemId = digit->DetElemId();
360 busPatchId = GetBusPatch(*digit);
361 if (busPatchId<0) continue;
363 if ( digit->ManuId() > 0x7FF || digit->ManuId() < 0 ||
364 digit->ManuChannel() > 0x3F || digit->ManuChannel() < 0 )
366 StdoutToAliError(digit->Print(););
367 AliFatal("ManuId,ManuChannel are invalid for the digit above.");
370 manuId = ( digit->ManuId() & 0x7FF ); // 11 bits
371 channelId = ( digit->ManuChannel() & 0x3F ); // 6 bits
373 AliDebug(3,Form("input IdDE %d busPatchId %d PadX %d PadY %d iCath %d \n",
374 detElemId, busPatchId, padX, padY, cathode));
376 AliDebug(3,Form("busPatchId %d, manuId %d channelId %d\n", busPatchId, manuId, channelId ));
380 AliBitPacking::PackWord((UInt_t)manuId,word,18,28);
381 AliBitPacking::PackWord((UInt_t)channelId,word,12,17);
382 AliBitPacking::PackWord((UInt_t)charge,word,0,11);
386 for (Int_t i = 1; i <= 30; i++)
387 parity ^= ((word >> i) & 0x1);
388 AliBitPacking::PackWord((UInt_t)parity,word,31,31);
391 fBusStruct->SetLength(0);
392 fBusStruct->AddData(word);
393 fBusStruct->SetBusPatchId(busPatchId);
395 // storing the number of identical buspatches
396 nbInBus[busPatchId]++;
397 AddData(*fBusStruct);
401 // sorting by buspatch
404 // gather datas from same bus patch
405 nEntries = fBusArray->GetEntriesFast();
407 for (Int_t i = 0; i < nEntries; i++) {
408 AliMUONBusStruct* temp = (AliMUONBusStruct*)fBusArray->At(i);
409 busPatchId = temp->GetBusPatchId();
411 // add bus patch header, length and total length managed by subevent class
412 for (Int_t j = 0; j < nbInBus[busPatchId]-1; j++) {
413 AliMUONBusStruct* temp1 = (AliMUONBusStruct*)fBusArray->At(++i);
414 temp->AddData(temp1->GetData(0));
415 fBusArray->RemoveAt(i) ;
418 fBusArray->Compress();
420 if (AliLog::GetGlobalDebugLevel() == 3) {
421 nEntries = fBusArray->GetEntriesFast();
422 for (Int_t i = 0; i < nEntries; i++) {
423 AliMUONBusStruct* temp = (AliMUONBusStruct*)fBusArray->At(i);
424 printf("busPatchid back %d\n",temp->GetBusPatchId());
425 for (Int_t j = 0; j < temp->GetLength(); j++) {
426 printf("manuId back %d, ",temp->GetManuId(j));
427 printf("channelId back %d, ",temp->GetChannelId(j));
428 printf("charge back %d\n",temp->GetCharge(j));
434 // getting info for the number of buspatches
437 Int_t iBusPerDSP[5];//number of bus patches per DSP
438 Int_t iDspMax; //number max of DSP per block
440 fBusPatchManager->GetDspInfo(iCh, iDspMax, iBusPerDSP);
442 TArrayI* vec = fBusPatchManager->GetBusfromDE((iCh+1)*100);
444 Int_t iBus0AtCh = vec->At(0); //get first bus patch id for a given ich
446 AliDebug(3,Form("iBus0AtCh %d", iBus0AtCh));
448 iBusPatch = iBus0AtCh - 1; // starting point for each chamber
450 // nEntries = fBusArray->GetEntriesFast();
452 AliMUONBusStruct* busStructPtr = 0x0;
454 // open DDL file, on per 1/2 chamber
455 for (Int_t iDDL = 0; iDDL < 2; iDDL++) {
460 buffer = new Int_t [(2048+24)*50]; // 24 words at most for one buspatch and 2048 manu info at most
466 // two blocks A and B per DDL
467 for (Int_t iBlock = 0; iBlock < 2; iBlock++) {
470 length = fBlockHeader->GetHeaderLength();
471 memcpy(&buffer[index],fBlockHeader->GetHeader(),length*4);
475 // 5 DSP's max per block
476 for (Int_t iDsp = 0; iDsp < iDspMax; iDsp++) {
479 length = fDspHeader->GetHeaderLength();
480 memcpy(&buffer[index],fDspHeader->GetHeader(),length*4);
484 //Â 5 buspatches max per DSP
485 for (Int_t i = 0; i < iBusPerDSP[iDsp]; i++) {
488 if ((fBusPatchManager->GetDDLfromBus(iBusPatch) % 2) == 0) // comparing to DDL file
493 AliDebug(3,Form("iCh %d iDDL %d iBlock %d iDsp %d busPatchId %d", iCh, iDDL, iBlock, iDsp, iBusPatch));
495 nEntries = fBusArray->GetEntriesFast();
498 for (Int_t iEntries = 0; iEntries < nEntries; iEntries++) { // method "bourrique"...
499 busStructPtr = (AliMUONBusStruct*)fBusArray->At(iEntries);
500 busPatchId = busStructPtr->GetBusPatchId();
501 if (busPatchId == iBusPatch) break;
503 AliDebug(3,Form("busPatchId %d", busStructPtr->GetBusPatchId()));
506 // check if buspatchid has digit
507 if (busPatchId != -1) {
508 // add bus patch structure header
509 length = busStructPtr->GetHeaderLength();
510 memcpy(&buffer[index],busStructPtr->GetHeader(),length*4);
513 // add bus patch data
514 for (Int_t j = 0; j < busStructPtr->GetLength(); j++) {
515 buffer[index++] = busStructPtr->GetData(j);
516 AliDebug(3,Form("busPatchId %d, manuId %d channelId %d\n",
517 busStructPtr->GetBusPatchId(),
518 busStructPtr->GetManuId(j), busStructPtr->GetChannelId(j) ));
520 // fBusArray->RemoveAt(iEntries);
521 // fBusArray->Compress();
523 // writting anyhow buspatch structure (empty ones)
524 buffer[index++] = busStructPtr->GetDefaultDataKey(); // fill it also for empty data size
525 buffer[index++] = busStructPtr->GetHeaderLength(); // header length
526 buffer[index++] = 0; // raw data length
527 buffer[index++] = iBusPatch; // bus patch
531 // check if totalLength even
532 // set padding word in case
533 // Add one word 0xBEEFFACE at the end of DSP structure
534 totalDspLength = index - indexDsp;
535 if ((totalDspLength % 2) == 1) {
536 buffer[indexDsp + fDspHeader->GetHeaderLength() - 2] = 1;
537 buffer[index++] = fDspHeader->GetDefaultPaddingWord();
541 dspLength = totalDspLength - fDspHeader->GetHeaderLength();
543 buffer[indexDsp+1] = totalDspLength; // dsp total length
544 buffer[indexDsp+2] = dspLength; // data length
548 totalBlkLength = index - indexBlk;
549 blkLength = totalBlkLength - fBlockHeader->GetHeaderLength();
550 totalDDLLength += totalBlkLength;
552 buffer[indexBlk+1] = totalBlkLength; // total block length
553 buffer[indexBlk+2] = blkLength;
559 fHeader.fSize = (totalDDLLength + headerSize) * 4;// total length in bytes
560 fwrite((char*)(&fHeader),headerSize*4,1,fFile[iFile]);
561 fwrite(buffer,sizeof(int),index,fFile[iFile]);
566 fTrackerTimer.Stop();
570 //____________________________________________________________________
571 Int_t AliMUONRawWriter::GetBusPatch(const AliMUONDigit& digit)
574 // Determine the BusPatch this digit belongs to.
576 fMappingTimer.Start(kFALSE);
580 // information from digits
581 Int_t detElemId = digit.DetElemId();
583 AliMpVSegmentation* seg =
584 fSegFactory->CreateMpSegmentationByElectronics(detElemId, digit.ManuId());
586 AliMpPlaneType plane = seg->PlaneType();
588 AliMpStationType stationType = AliMpDEManager::GetStationType(detElemId);
590 if ( stationType == kStation1 || stationType == kStation2 )
592 if (plane == kBendingPlane)
594 ptr = &fgManuPerBusSwp1B[0];
598 ptr = &fgManuPerBusSwp1NB[0];
603 if (plane == kBendingPlane)
605 ptr = &fgManuPerBusSwp2B[0];
609 ptr = &fgManuPerBusSwp2NB[0];
613 // Getting buspatch id
614 TArrayI* vec = fBusPatchManager->GetBusfromDE(detElemId);
617 Int_t m = ( digit.ManuId() & 0x3FF ); // remove bit 10
618 //FIXME : how can we remove that condition
619 // on the 10-th bit ? All the rest need not any knowledge about it,
620 // can't we find a way to get manu<->buspatch transparent to this too ?
622 if ( stationType == kStation1 || stationType == kStation2 )
624 for (Int_t i = 0; i < 12; i++)
626 if (m >= *(ptr + pos++)) break;
631 // offset of 100 in manuId for following bus patch
635 if (pos >(Int_t) vec->GetSize())
637 AliError(Form("pos greater %d than size %d manuId %d detElemId %d \n",
638 pos, (Int_t)vec->GetSize(), digit.ManuId(), detElemId));
639 AliError(Form("Chamber %s Plane %s manuId %d m %d",
640 StationTypeName(stationType).Data(),
641 PlaneTypeName(plane).Data(),
647 Int_t busPatchId = vec->At(pos);
649 fMappingTimer.Stop();
654 //____________________________________________________________________
655 Int_t AliMUONRawWriter::WriteTriggerDDL()
660 fTriggerTimer.Start(kFALSE);
662 // DDL event one per half chamber
664 // stored local id number
665 TArrayI isFired(256);
670 Int_t headerSize = sizeof(AliRawDataHeader)/4;
672 TClonesArray* localTrigger;
673 TClonesArray* globalTrigger;
674 AliMUONGlobalTrigger* gloTrg;
675 AliMUONLocalTrigger* locTrg = 0x0;
677 // global trigger for trigger pattern
678 globalTrigger = fMUONData->GlobalTrigger();
679 gloTrg = (AliMUONGlobalTrigger*)globalTrigger->UncheckedAt(0);
680 Int_t gloTrigPat = gloTrg->GetGlobalPattern();
683 localTrigger = fMUONData->LocalTrigger();
689 Int_t iLocCard, locCard;
690 Char_t locDec, trigY, posY, posX,regOut;
692 Int_t version = 1; // software version
693 Int_t eventPhys = 1; // trigger type: 1 for physics, 0 for software
694 Int_t serialNb = 0xF; // serial nb of card: all bits on for the moment
695 Int_t globalFlag = 0; // set to 1 if global info present in DDL else set to 0
698 static const Int_t kDarcHeaderLength = fDarcHeader->GetDarcHeaderLength();
699 static const Int_t kGlobalHeaderLength = fDarcHeader->GetGlobalHeaderLength();
700 static const Int_t kDarcScalerLength = fDarcHeader->GetDarcScalerLength();
701 static const Int_t kGlobalScalerLength = fDarcHeader->GetGlobalScalerLength();
702 static const Int_t kRegHeaderLength = fRegHeader->GetHeaderLength();
703 static const Int_t kRegScalerLength = fRegHeader->GetScalerLength();
704 static const Int_t kLocHeaderLength = fLocalStruct->GetLength();
705 static const Int_t kLocScalerLength = fLocalStruct->GetScalerLength();
707 // [16(local)*6 words + 6 words]*8(reg) + 8 words = 824
708 static const Int_t kBufferSize = (16 * (kLocHeaderLength+1) + (kRegHeaderLength+1))* 8
709 + kDarcHeaderLength + kGlobalHeaderLength + 2;
711 // [16(local)*51 words + 16 words]*8(reg) + 8 + 10 + 8 words scaler event 6682 words
712 static const Int_t kScalerBufferSize = (16 * (kLocHeaderLength + kLocScalerLength +1) +
713 (kRegHeaderLength + kRegScalerLength +1))* 8 +
714 (kDarcHeaderLength + kDarcScalerLength +
715 kGlobalHeaderLength + kGlobalScalerLength + 2);
717 eventPhys = 0; //set to generate scaler events
719 Int_t nEntries = (Int_t) (localTrigger->GetEntries());// 234 local cards
720 // stored the local card id that's fired
721 for (Int_t i = 0; i < nEntries; i++) {
722 locTrg = (AliMUONLocalTrigger*)localTrigger->At(i);
723 isFired[locTrg->LoCircuit()] = 1; // storing local boards with informations
727 AliInfo("No Trigger information available");
730 buffer = new Int_t [kScalerBufferSize];
732 buffer = new Int_t [kBufferSize];
735 // open DDL file, on per 1/2 chamber
736 for (Int_t iDDL = 0; iDDL < 2; iDDL++) {
740 if (iDDL == 0) // suppose global info in DDL one
746 // set darc status word
747 // see AliMUONDarcHeader.h for details
748 AliBitPacking::PackWord((UInt_t)eventPhys,word,30,30);
749 AliBitPacking::PackWord((UInt_t)serialNb,word,20,23);
750 AliBitPacking::PackWord((UInt_t)globalFlag,word,10,10);
751 AliBitPacking::PackWord((UInt_t)version,word,12,19);
752 fDarcHeader->SetWord(word);
754 memcpy(&buffer[index], fDarcHeader->GetHeader(), (kDarcHeaderLength)*4);
755 index += fDarcHeader->GetDarcHeaderLength();
758 fDarcHeader->SetGlobalOutput(gloTrigPat);// no global input for the moment....
760 fDarcHeader->SetGlobalOutput(0);
763 // 6 DARC scaler words
764 memcpy(&buffer[index], fDarcHeader->GetDarcScalers(),kDarcScalerLength*4);
765 index += fDarcHeader->GetDarcScalerLength();
768 buffer[index++] = fDarcHeader->GetEndOfDarc();
770 // 4 words of global board input + Global board output
771 memcpy(&buffer[index], fDarcHeader->GetGlobalInput(), (kGlobalHeaderLength)*4);
772 index += fDarcHeader->GetGlobalHeaderLength();
775 // 10 Global scaler words
776 memcpy(fDarcHeader->GetGlobalScalers(), &buffer[index], kGlobalScalerLength*4);
777 index += fDarcHeader->GetGlobalScalerLength();
780 // end of global word
781 buffer[index++] = fDarcHeader->GetEndOfGlobal();
783 // 8 regional cards per DDL
784 for (Int_t iReg = 0; iReg < 8; iReg++) {
786 // Regional card header
789 // set darc status word
790 fRegHeader->SetDarcWord(word);
793 // fill darc word, not darc status for the moment (empty)
794 //see AliMUONRegHeader.h for details
795 AliBitPacking::PackWord((UInt_t)eventPhys,word,31,31);
796 AliBitPacking::PackWord((UInt_t)serialNb,word,19,24);
797 AliBitPacking::PackWord((UInt_t)version,word,16,23);
798 AliBitPacking::PackWord((UInt_t)iReg,word,15,18);
799 AliBitPacking::PackWord((UInt_t)regOut,word,0,7); // whenever regional output will be implemented
800 fRegHeader->SetWord(word);
802 memcpy(&buffer[index],fRegHeader->GetHeader(),fRegHeader->GetHeaderLength()*4);
803 index += fRegHeader->GetHeaderLength();
805 // 11 regional scaler word
807 memcpy(&buffer[index], fRegHeader->GetScalers(), fRegHeader->GetScalerLength()*4);
808 index += fRegHeader->GetScalerLength();
811 // end of regional word
812 buffer[index++] = fRegHeader->GetEndOfReg();
814 // 16 local card per regional board
815 for (Int_t iLoc = 0; iLoc < 16; iLoc++) {
817 iLocCard = iLoc + iReg*16 + iDDL*128;
819 if (isFired[iLocCard]) {
820 locTrg = (AliMUONLocalTrigger*)localTrigger->At(iEntries);
821 locCard = locTrg->LoCircuit();
822 locDec = locTrg->GetLoDecision();
824 posY = locTrg->LoStripY();
825 posX = locTrg->LoStripX();
826 devX = locTrg->LoDev();
827 AliDebug(4,Form("loctrg %d, posX %d, posY %d, devX %d\n",
828 locTrg->LoCircuit(),locTrg->LoStripX(),locTrg->LoStripY(),locTrg->LoDev()));
829 } else { //no trigger (see PRR chpt 3.4)
830 locCard = -1; // not possible on 4 bits
840 AliBitPacking::PackWord((UInt_t)(iLocCard % 16),word,19,22); //card id number in crate
841 AliBitPacking::PackWord((UInt_t)locDec,word,15,18);
842 AliBitPacking::PackWord((UInt_t)trigY,word,14,14);
843 AliBitPacking::PackWord((UInt_t)posY,word,10,13);
844 AliBitPacking::PackWord((UInt_t)devX,word,5,9);
845 AliBitPacking::PackWord((UInt_t)posX,word,0,4);
847 if (locCard == iLocCard) {
848 // add local cards structure
849 buffer[index++] = (locTrg->GetX1Pattern() | (locTrg->GetX2Pattern() << 16));
850 buffer[index++] = (locTrg->GetX3Pattern() | (locTrg->GetX4Pattern() << 16));
851 buffer[index++] = (locTrg->GetY1Pattern() | (locTrg->GetY2Pattern() << 16));
852 buffer[index++] = (locTrg->GetY3Pattern() | (locTrg->GetY4Pattern() << 16));
853 buffer[index++] = (Int_t)word; // data word
854 if (iEntries < nEntries-1)
857 buffer[index++] = 0; // 4 words for x1, x2, y1, y2
861 buffer[index++] = (Int_t)word; // data word
864 // 45 regional scaler word
866 memcpy(&buffer[index], fLocalStruct->GetScalers(), fLocalStruct->GetScalerLength()*4);
867 index += fLocalStruct->GetScalerLength();
870 // end of local structure words
871 buffer[index++] = fLocalStruct->GetEndOfLocal();
878 // writting onto disk
880 fHeader.fSize = (index + headerSize) * 4;// total length in bytes
881 fwrite((char*)(&fHeader),headerSize*4,1,fFile[iDDL]);
882 fwrite(buffer,sizeof(int),index,fFile[iDDL]);
887 fTriggerTimer.Stop();
891 //____________________________________________________________________
892 void AliMUONRawWriter::SetScalersNumbers()
894 // set numbers for scaler events for trigger headers
895 // since this is provided by the experiment
896 // put dummy numbers to check the monitoring
898 fDarcHeader->SetScalersNumbers();
899 fRegHeader->SetScalersNumbers();
900 fLocalStruct->SetScalersNumbers();
902 fScalerEvent = kTRUE;