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
227 strcpy(name,AliDAQ::DdlFileName("MUONTRK",idDDL));
228 fFile[0] = fopen(name,"w");
230 // idDDL = (ich * 2) + 1 + AliDAQ::DdlIDOffset("MUONTRK");
231 idDDL = (ich * 2) + 1;
232 strcpy(name,AliDAQ::DdlFileName("MUONTRK",idDDL));
233 fFile[1] = fopen(name,"w");
235 WriteTrackerDDL(ich);
246 strcpy(name,AliDAQ::DdlFileName("MUONTRG",idDDL));
247 fFile[0] = fopen(name,"w");
250 strcpy(name,AliDAQ::DdlFileName("MUONTRG",idDDL));
251 fFile[1] = fopen(name,"w");
259 fMUONData->ResetDigits();
260 fMUONData->ResetTrigger();
261 fMUONData->GetLoader()->UnloadDigits();
266 //____________________________________________________________________
267 Int_t AliMUONRawWriter::WriteTrackerDDL(Int_t iCh)
269 // writing DDL for tracker
270 // used inverse mapping
272 fTrackerTimer.Start(kFALSE);
275 static const Int_t kMAXADC = (1<<12)-1; // We code the charge on a 12 bits ADC.
278 TClonesArray* muonDigits = 0;
291 Int_t headerSize = sizeof(fHeader)/4;
293 // DDL event one per half chamber
298 UChar_t channelId = 0;
300 Int_t busPatchId = 0;
305 Int_t totalDspLength;
309 Int_t totalBlkLength;
313 Int_t totalDDLLength;
329 const AliMUONDigit* digit;
331 AliDebug(3, Form("WriteDDL chamber %d\n", iCh+1));
333 muonDigits = fMUONData->Digits(iCh);
335 nDigits = muonDigits->GetEntriesFast();
336 AliDebug(3,Form("ndigits = %d\n",nDigits));
339 for (Int_t idig = 0; idig < nDigits; idig++) {
341 digit = (AliMUONDigit*) muonDigits->UncheckedAt(idig);
343 padX = digit->PadX();
344 padY = digit->PadY();
345 charge = digit->ADC();
346 if ( charge > kMAXADC )
348 // This is most probably an error in the digitizer (which should insure
349 // the adc is below kMAXADC), so make it a (non-fatal) error indeed.
350 AliError(Form("adc value %d above %x. Setting to %x",
351 charge,kMAXADC,kMAXADC));
354 cathode = digit->Cathode();
355 detElemId = digit->DetElemId();
358 busPatchId = GetBusPatch(*digit);
359 if (busPatchId<0) continue;
361 if ( digit->ManuId() > 0x7FF || digit->ManuId() < 0 ||
362 digit->ManuChannel() > 0x3F || digit->ManuChannel() < 0 )
364 StdoutToAliError(digit->Print(););
365 AliFatal("ManuId,ManuChannel are invalid for the digit above.");
368 manuId = ( digit->ManuId() & 0x7FF ); // 11 bits
369 channelId = ( digit->ManuChannel() & 0x3F ); // 6 bits
371 AliDebug(3,Form("input IdDE %d busPatchId %d PadX %d PadY %d iCath %d \n",
372 detElemId, busPatchId, padX, padY, cathode));
374 AliDebug(3,Form("busPatchId %d, manuId %d channelId %d\n", busPatchId, manuId, channelId ));
378 AliBitPacking::PackWord((UInt_t)manuId,word,18,28);
379 AliBitPacking::PackWord((UInt_t)channelId,word,12,17);
380 AliBitPacking::PackWord((UInt_t)charge,word,0,11);
384 for (Int_t i = 1; i <= 30; i++)
385 parity ^= ((word >> i) & 0x1);
386 AliBitPacking::PackWord((UInt_t)parity,word,31,31);
389 fBusStruct->SetLength(0);
390 fBusStruct->AddData(word);
391 fBusStruct->SetBusPatchId(busPatchId);
393 // storing the number of identical buspatches
394 nbInBus[busPatchId]++;
395 AddData(*fBusStruct);
399 // sorting by buspatch
402 // gather datas from same bus patch
403 nEntries = fBusArray->GetEntriesFast();
405 for (Int_t i = 0; i < nEntries; i++) {
406 AliMUONBusStruct* temp = (AliMUONBusStruct*)fBusArray->At(i);
407 busPatchId = temp->GetBusPatchId();
409 // add bus patch header, length and total length managed by subevent class
410 for (Int_t j = 0; j < nbInBus[busPatchId]-1; j++) {
411 AliMUONBusStruct* temp1 = (AliMUONBusStruct*)fBusArray->At(++i);
412 temp->AddData(temp1->GetData(0));
413 fBusArray->RemoveAt(i) ;
416 fBusArray->Compress();
418 if (AliLog::GetGlobalDebugLevel() == 3) {
419 nEntries = fBusArray->GetEntriesFast();
420 for (Int_t i = 0; i < nEntries; i++) {
421 AliMUONBusStruct* temp = (AliMUONBusStruct*)fBusArray->At(i);
422 printf("busPatchid back %d\n",temp->GetBusPatchId());
423 for (Int_t j = 0; j < temp->GetLength(); j++) {
424 printf("manuId back %d, ",temp->GetManuId(j));
425 printf("channelId back %d, ",temp->GetChannelId(j));
426 printf("charge back %d\n",temp->GetCharge(j));
432 // getting info for the number of buspatches
435 Int_t iBusPerDSP[5];//number of bus patches per DSP
436 Int_t iDspMax; //number max of DSP per block
438 fBusPatchManager->GetDspInfo(iCh, iDspMax, iBusPerDSP);
440 TArrayI* vec = fBusPatchManager->GetBusfromDE((iCh+1)*100);
442 Int_t iBus0AtCh = vec->At(0); //get first bus patch id for a given ich
444 AliDebug(3,Form("iBus0AtCh %d", iBus0AtCh));
446 iBusPatch = iBus0AtCh - 1; // starting point for each chamber
448 // nEntries = fBusArray->GetEntriesFast();
450 AliMUONBusStruct* busStructPtr = 0x0;
452 // open DDL file, on per 1/2 chamber
453 for (Int_t iDDL = 0; iDDL < 2; iDDL++) {
458 buffer = new Int_t [(2048+24)*50]; // 24 words at most for one buspatch and 2048 manu info at most
464 // two blocks A and B per DDL
465 for (Int_t iBlock = 0; iBlock < 2; iBlock++) {
468 length = fBlockHeader->GetHeaderLength();
469 memcpy(&buffer[index],fBlockHeader->GetHeader(),length*4);
473 // 5 DSP's max per block
474 for (Int_t iDsp = 0; iDsp < iDspMax; iDsp++) {
477 length = fDspHeader->GetHeaderLength();
478 memcpy(&buffer[index],fDspHeader->GetHeader(),length*4);
482 //Â 5 buspatches max per DSP
483 for (Int_t i = 0; i < iBusPerDSP[iDsp]; i++) {
486 if ((fBusPatchManager->GetDDLfromBus(iBusPatch) % 2) == 0) // comparing to DDL file
491 AliDebug(3,Form("iCh %d iDDL %d iBlock %d iDsp %d busPatchId %d", iCh, iDDL, iBlock, iDsp, iBusPatch));
493 nEntries = fBusArray->GetEntriesFast();
496 for (Int_t iEntries = 0; iEntries < nEntries; iEntries++) { // method "bourrique"...
497 busStructPtr = (AliMUONBusStruct*)fBusArray->At(iEntries);
498 busPatchId = busStructPtr->GetBusPatchId();
499 if (busPatchId == iBusPatch) break;
501 AliDebug(3,Form("busPatchId %d", busStructPtr->GetBusPatchId()));
504 // check if buspatchid has digit
505 if (busPatchId != -1) {
506 // add bus patch structure header
507 length = busStructPtr->GetHeaderLength();
508 memcpy(&buffer[index],busStructPtr->GetHeader(),length*4);
511 // add bus patch data
512 for (Int_t j = 0; j < busStructPtr->GetLength(); j++) {
513 buffer[index++] = busStructPtr->GetData(j);
514 AliDebug(3,Form("busPatchId %d, manuId %d channelId %d\n",
515 busStructPtr->GetBusPatchId(),
516 busStructPtr->GetManuId(j), busStructPtr->GetChannelId(j) ));
518 // fBusArray->RemoveAt(iEntries);
519 // fBusArray->Compress();
521 // writting anyhow buspatch structure (empty ones)
522 buffer[index++] = busStructPtr->GetDefaultDataKey(); // fill it also for empty data size
523 buffer[index++] = busStructPtr->GetHeaderLength(); // header length
524 buffer[index++] = 0; // raw data length
525 buffer[index++] = iBusPatch; // bus patch
529 // check if totalLength even
530 // set padding word in case
531 // Add one word 0xBEEFFACE at the end of DSP structure
532 totalDspLength = index - indexDsp;
533 if ((totalDspLength % 2) == 1) {
534 buffer[indexDsp + fDspHeader->GetHeaderLength() - 2] = 1;
535 buffer[index++] = fDspHeader->GetDefaultPaddingWord();
539 dspLength = totalDspLength - fDspHeader->GetHeaderLength();
541 buffer[indexDsp+1] = totalDspLength; // dsp total length
542 buffer[indexDsp+2] = dspLength; // data length
546 totalBlkLength = index - indexBlk;
547 blkLength = totalBlkLength - fBlockHeader->GetHeaderLength();
548 totalDDLLength += totalBlkLength;
550 buffer[indexBlk+1] = totalBlkLength; // total block length
551 buffer[indexBlk+2] = blkLength;
557 fHeader.fSize = (totalDDLLength + headerSize) * 4;// total length in bytes
558 fwrite((char*)(&fHeader),headerSize*4,1,fFile[iFile]);
559 fwrite(buffer,sizeof(int),index,fFile[iFile]);
564 fTrackerTimer.Stop();
568 //____________________________________________________________________
569 Int_t AliMUONRawWriter::GetBusPatch(const AliMUONDigit& digit)
572 // Determine the BusPatch this digit belongs to.
574 fMappingTimer.Start(kFALSE);
578 // information from digits
579 Int_t detElemId = digit.DetElemId();
581 AliMpVSegmentation* seg =
582 fSegFactory->CreateMpSegmentationByElectronics(detElemId, digit.ManuId());
584 AliMpPlaneType plane = seg->PlaneType();
586 AliMpStationType stationType = AliMpDEManager::GetStationType(detElemId);
588 if ( stationType == kStation1 || stationType == kStation2 )
590 if (plane == kBendingPlane)
592 ptr = &fgManuPerBusSwp1B[0];
596 ptr = &fgManuPerBusSwp1NB[0];
601 if (plane == kBendingPlane)
603 ptr = &fgManuPerBusSwp2B[0];
607 ptr = &fgManuPerBusSwp2NB[0];
611 // Getting buspatch id
612 TArrayI* vec = fBusPatchManager->GetBusfromDE(detElemId);
615 Int_t m = ( digit.ManuId() & 0x3FF ); // remove bit 10
616 //FIXME : how can we remove that condition
617 // on the 10-th bit ? All the rest need not any knowledge about it,
618 // can't we find a way to get manu<->buspatch transparent to this too ?
620 if ( stationType == kStation1 || stationType == kStation2 )
622 for (Int_t i = 0; i < 12; i++)
624 if (m >= *(ptr + pos++)) break;
629 // offset of 100 in manuId for following bus patch
633 if (pos >(Int_t) vec->GetSize())
635 AliError(Form("pos greater %d than size %d manuId %d detElemId %d \n",
636 pos, (Int_t)vec->GetSize(), digit.ManuId(), detElemId));
637 AliError(Form("Chamber %s Plane %s manuId %d m %d",
638 StationTypeName(stationType).Data(),
639 PlaneTypeName(plane).Data(),
645 Int_t busPatchId = vec->At(pos);
647 fMappingTimer.Stop();
652 //____________________________________________________________________
653 Int_t AliMUONRawWriter::WriteTriggerDDL()
658 fTriggerTimer.Start(kFALSE);
660 // DDL event one per half chamber
662 // stored local id number
663 TArrayI isFired(256);
668 Int_t headerSize = sizeof(AliRawDataHeader)/4;
670 TClonesArray* localTrigger;
671 TClonesArray* globalTrigger;
672 AliMUONGlobalTrigger* gloTrg;
673 AliMUONLocalTrigger* locTrg = 0x0;
675 // global trigger for trigger pattern
676 globalTrigger = fMUONData->GlobalTrigger();
677 gloTrg = (AliMUONGlobalTrigger*)globalTrigger->UncheckedAt(0);
678 Int_t gloTrigPat = gloTrg->GetGlobalPattern();
681 localTrigger = fMUONData->LocalTrigger();
687 Int_t iLocCard, locCard;
688 Char_t locDec, trigY, posY, posX,regOut;
690 Int_t version = 1; // software version
691 Int_t eventPhys = 1; // trigger type: 1 for physics, 0 for software
692 Int_t serialNb = 0xF; // serial nb of card: all bits on for the moment
693 Int_t globalFlag = 0; // set to 1 if global info present in DDL else set to 0
696 static const Int_t kDarcHeaderLength = fDarcHeader->GetDarcHeaderLength();
697 static const Int_t kGlobalHeaderLength = fDarcHeader->GetGlobalHeaderLength();
698 static const Int_t kDarcScalerLength = fDarcHeader->GetDarcScalerLength();
699 static const Int_t kGlobalScalerLength = fDarcHeader->GetGlobalScalerLength();
700 static const Int_t kRegHeaderLength = fRegHeader->GetHeaderLength();
701 static const Int_t kRegScalerLength = fRegHeader->GetScalerLength();
702 static const Int_t kLocHeaderLength = fLocalStruct->GetLength();
703 static const Int_t kLocScalerLength = fLocalStruct->GetScalerLength();
705 // [16(local)*6 words + 6 words]*8(reg) + 8 words = 824
706 static const Int_t kBufferSize = (16 * (kLocHeaderLength+1) + (kRegHeaderLength+1))* 8
707 + kDarcHeaderLength + kGlobalHeaderLength + 2;
709 // [16(local)*51 words + 16 words]*8(reg) + 8 + 10 + 8 words scaler event 6682 words
710 static const Int_t kScalerBufferSize = (16 * (kLocHeaderLength + kLocScalerLength +1) +
711 (kRegHeaderLength + kRegScalerLength +1))* 8 +
712 (kDarcHeaderLength + kDarcScalerLength +
713 kGlobalHeaderLength + kGlobalScalerLength + 2);
715 eventPhys = 0; //set to generate scaler events
717 Int_t nEntries = (Int_t) (localTrigger->GetEntries());// 234 local cards
718 // stored the local card id that's fired
719 for (Int_t i = 0; i < nEntries; i++) {
720 locTrg = (AliMUONLocalTrigger*)localTrigger->At(i);
721 isFired[locTrg->LoCircuit()] = 1; // storing local boards with informations
725 AliInfo("No Trigger information available");
728 buffer = new Int_t [kScalerBufferSize];
730 buffer = new Int_t [kBufferSize];
733 // open DDL file, on per 1/2 chamber
734 for (Int_t iDDL = 0; iDDL < 2; iDDL++) {
738 if (iDDL == 0) // suppose global info in DDL one
744 // set darc status word
745 // see AliMUONDarcHeader.h for details
746 AliBitPacking::PackWord((UInt_t)eventPhys,word,30,30);
747 AliBitPacking::PackWord((UInt_t)serialNb,word,20,23);
748 AliBitPacking::PackWord((UInt_t)globalFlag,word,10,10);
749 AliBitPacking::PackWord((UInt_t)version,word,12,19);
750 fDarcHeader->SetWord(word);
752 memcpy(&buffer[index], fDarcHeader->GetHeader(), (kDarcHeaderLength)*4);
753 index += fDarcHeader->GetDarcHeaderLength();
756 fDarcHeader->SetGlobalOutput(gloTrigPat);// no global input for the moment....
758 fDarcHeader->SetGlobalOutput(0);
761 // 6 DARC scaler words
762 memcpy(&buffer[index], fDarcHeader->GetDarcScalers(),kDarcScalerLength*4);
763 index += fDarcHeader->GetDarcScalerLength();
766 buffer[index++] = fDarcHeader->GetEndOfDarc();
768 // 4 words of global board input + Global board output
769 memcpy(&buffer[index], fDarcHeader->GetGlobalInput(), (kGlobalHeaderLength)*4);
770 index += fDarcHeader->GetGlobalHeaderLength();
773 // 10 Global scaler words
774 memcpy(fDarcHeader->GetGlobalScalers(), &buffer[index], kGlobalScalerLength*4);
775 index += fDarcHeader->GetGlobalScalerLength();
778 // end of global word
779 buffer[index++] = fDarcHeader->GetEndOfGlobal();
781 // 8 regional cards per DDL
782 for (Int_t iReg = 0; iReg < 8; iReg++) {
784 // Regional card header
787 // set darc status word
788 fRegHeader->SetDarcWord(word);
791 // fill darc word, not darc status for the moment (empty)
792 //see AliMUONRegHeader.h for details
793 AliBitPacking::PackWord((UInt_t)eventPhys,word,31,31);
794 AliBitPacking::PackWord((UInt_t)serialNb,word,19,24);
795 AliBitPacking::PackWord((UInt_t)version,word,16,23);
796 AliBitPacking::PackWord((UInt_t)iReg,word,15,18);
797 AliBitPacking::PackWord((UInt_t)regOut,word,0,7); // whenever regional output will be implemented
798 fRegHeader->SetWord(word);
800 memcpy(&buffer[index],fRegHeader->GetHeader(),fRegHeader->GetHeaderLength()*4);
801 index += fRegHeader->GetHeaderLength();
803 // 11 regional scaler word
805 memcpy(&buffer[index], fRegHeader->GetScalers(), fRegHeader->GetScalerLength()*4);
806 index += fRegHeader->GetScalerLength();
809 // end of regional word
810 buffer[index++] = fRegHeader->GetEndOfReg();
812 // 16 local card per regional board
813 for (Int_t iLoc = 0; iLoc < 16; iLoc++) {
815 iLocCard = iLoc + iReg*16 + iDDL*128;
817 if (isFired[iLocCard]) {
818 locTrg = (AliMUONLocalTrigger*)localTrigger->At(iEntries);
819 locCard = locTrg->LoCircuit();
820 locDec = locTrg->GetLoDecision();
822 posY = locTrg->LoStripY();
823 posX = locTrg->LoStripX();
824 devX = locTrg->LoDev();
825 AliDebug(4,Form("loctrg %d, posX %d, posY %d, devX %d\n",
826 locTrg->LoCircuit(),locTrg->LoStripX(),locTrg->LoStripY(),locTrg->LoDev()));
827 } else { //no trigger (see PRR chpt 3.4)
828 locCard = -1; // not possible on 4 bits
838 AliBitPacking::PackWord((UInt_t)(iLocCard % 16),word,19,22); //card id number in crate
839 AliBitPacking::PackWord((UInt_t)locDec,word,15,18);
840 AliBitPacking::PackWord((UInt_t)trigY,word,14,14);
841 AliBitPacking::PackWord((UInt_t)posY,word,10,13);
842 AliBitPacking::PackWord((UInt_t)devX,word,5,9);
843 AliBitPacking::PackWord((UInt_t)posX,word,0,4);
845 if (locCard == iLocCard) {
846 // add local cards structure
847 buffer[index++] = (locTrg->GetX1Pattern() | (locTrg->GetX2Pattern() << 16));
848 buffer[index++] = (locTrg->GetX3Pattern() | (locTrg->GetX4Pattern() << 16));
849 buffer[index++] = (locTrg->GetY1Pattern() | (locTrg->GetY2Pattern() << 16));
850 buffer[index++] = (locTrg->GetY3Pattern() | (locTrg->GetY4Pattern() << 16));
851 buffer[index++] = (Int_t)word; // data word
852 if (iEntries < nEntries-1)
855 buffer[index++] = 0; // 4 words for x1, x2, y1, y2
859 buffer[index++] = (Int_t)word; // data word
862 // 45 regional scaler word
864 memcpy(&buffer[index], fLocalStruct->GetScalers(), fLocalStruct->GetScalerLength()*4);
865 index += fLocalStruct->GetScalerLength();
868 // end of local structure words
869 buffer[index++] = fLocalStruct->GetEndOfLocal();
876 // writting onto disk
878 fHeader.fSize = (index + headerSize) * 4;// total length in bytes
879 fwrite((char*)(&fHeader),headerSize*4,1,fFile[iDDL]);
880 fwrite(buffer,sizeof(int),index,fFile[iDDL]);
885 fTriggerTimer.Stop();
889 //____________________________________________________________________
890 void AliMUONRawWriter::SetScalersNumbers()
892 // set numbers for scaler events for trigger headers
893 // since this is provided by the experiment
894 // put dummy numbers to check the monitoring
896 fDarcHeader->SetScalersNumbers();
897 fRegHeader->SetScalersNumbers();
898 fLocalStruct->SetScalersNumbers();
900 fScalerEvent = kTRUE;