AliRoot Core  3abf5b4 (3abf5b4)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
AliMUONRawWriter.cxx
Go to the documentation of this file.
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 /* $Id$ */
17 
18 //-----------------------------------------------------------------------------
44 //-----------------------------------------------------------------------------
45 
46 
47 #include "AliMUONRawWriter.h"
48 
49 #include "AliMUONBlockHeader.h"
50 #include "AliMUONBusStruct.h"
51 #include "AliMUONConstants.h"
52 #include "AliMUONDarcHeader.h"
53 #include "AliMUONVDigit.h"
54 #include "AliMUONVDigitStore.h"
55 #include "AliMUONDspHeader.h"
56 #include "AliMUONGlobalTrigger.h"
57 #include "AliMUONLocalStruct.h"
58 #include "AliMUONLocalTrigger.h"
60 #include "AliMUONRegionalTrigger.h"
61 #include "AliMUONRegHeader.h"
62 
63 #include "AliMUONVTriggerStore.h"
64 #include "AliCodeTimer.h"
65 
66 #include "AliMpCDB.h"
67 #include "AliMpDDLStore.h"
68 #include "AliMpDDL.h"
69 #include "AliMpRegionalTrigger.h"
70 #include "AliMpTriggerCrate.h"
71 #include "AliMpLocalBoard.h"
72 #include "AliMpDetElement.h"
73 #include "AliMpDEManager.h"
74 #include "AliMpExMap.h"
75 #include "AliMpConstants.h"
76 #include "AliMpPlaneType.h"
77 #include "AliMpSegmentation.h"
78 #include "AliMpStationType.h"
79 #include "AliMpVSegmentation.h"
80 
81 #include "AliRawReader.h"
82 #include "AliRawDataHeaderSim.h"
83 #include "AliBitPacking.h"
84 #include "AliDAQ.h"
85 #include "AliLog.h"
86 
87 #include "TObjArray.h"
88 #include "TStopwatch.h"
89 #include <Riostream.h>
90 
92 ClassImp(AliMUONRawWriter) // Class implementation in ROOT context
94 
95 //__________________________________________________________________________
97  : TObject(),
98  fBlockHeader(new AliMUONBlockHeader()),
99  fDspHeader(new AliMUONDspHeader()),
100  fDarcHeader(new AliMUONDarcHeader()),
101  fRegHeader(new AliMUONRegHeader()),
102  fLocalStruct(new AliMUONLocalStruct()),
103  fDDLStore(AliMpDDLStore::Instance()),
104  fScalerEvent(kFALSE),
105  fHeader(0x0),
106  fBufferSize((((43*AliMpConstants::ManuNofChannels() + 4)*5 + 10)*5 + 8)*2),
107  fBuffer(new Int_t [fBufferSize])
108 {
110 
111  AliDebug(1,"Standard ctor");
112 
113  // setting data key to default value (only for writting)
114  fBlockHeader->SetDataKey(fBlockHeader->GetDefaultDataKey());
115  fDspHeader->SetDataKey(fDspHeader->GetDefaultDataKey());
116 
117  // Load mapping
118  if ( ! fDDLStore ) {
119  if ( ! AliMpCDB::LoadDDLStore() ) {
120  AliFatal("Could not access mapping from OCDB !");
121  }
122  fDDLStore = AliMpDDLStore::Instance();
123  }
124 }
125 
126 //__________________________________________________________________________
128 {
130 
131  AliDebug(1,"dtor");
132 
133  delete fBlockHeader;
134  delete fDspHeader;
135  delete fDarcHeader;
136  delete fRegHeader;
137  delete fLocalStruct;
138  delete[] fBuffer;
139 }
140 
141 //____________________________________________________________________
142 void AliMUONRawWriter::LocalWordPacking(UInt_t& word, UInt_t locId, UInt_t locDec,
143  UInt_t trigY, UInt_t posY, UInt_t posX,
144  UInt_t sdevX, UInt_t devX)
145 {
147 
148  AliBitPacking::PackWord(locId,word,19,22); //card id number in crate
149  AliBitPacking::PackWord(locDec,word,15,18);
150  AliBitPacking::PackWord(trigY,word,14,14);
151  AliBitPacking::PackWord(posY,word,10,13);
152  AliBitPacking::PackWord(sdevX,word,9,9);
153  AliBitPacking::PackWord(devX,word,5,8);
154  AliBitPacking::PackWord(posX,word,0,4);
155 
156 }
157 
158 //____________________________________________________________________
160  const AliMUONVTriggerStore* triggerStore)
161 {
163 
164  AliCodeTimerAuto("",0)
165 
166  Int_t idDDL;
167 
168  // tracking chambers
169 
170  if ( digitStore )
171  {
172  AliCodeTimerAuto("for Tracker",1)
173 
174  AliMpExMap busPatchMap;
175 
176  Int_t nDDLs = AliDAQ::NumberOfDdls("MUONTRK");
177 
178  Int_t nofBusPatches(0);
179 
180  for (Int_t iDDL = 0; iDDL < nDDLs; ++iDDL )
181  {
182  AliMpDDL* ddl = fDDLStore->GetDDL(iDDL);
183  nofBusPatches += ddl->GetNofBusPatches();
184  }
185 
186  busPatchMap.SetSize(nofBusPatches);
187 
188  Digits2BusPatchMap(*digitStore,busPatchMap);
189 
190  for (Int_t iDDL = 0; iDDL < nDDLs; ++iDDL )
191  {
192  WriteTrackerDDL(busPatchMap,iDDL);
193  }
194  AliDebug(1,"Tracker written");
195  }
196 
197  if ( triggerStore )
198  {
199  AliCodeTimerAuto("for Trigger",1)
200 
201  // trigger chambers
202 
203  AliFstream* file[2];
204 
205  // open files
206  idDDL = 0;// MUTR
207  file[0] = new AliFstream(AliDAQ::DdlFileName("MUONTRG",idDDL));
208 
209  idDDL = 1;// MUTR
210  file[1] = new AliFstream(AliDAQ::DdlFileName("MUONTRG",idDDL));
211 
212  WriteTriggerDDL(*triggerStore,file);
213 
214  // reset and close
215  delete file[0];
216  delete file[1];
217 
218  AliDebug(1,"Trigger written");
219  }
220 
221  return kTRUE;
222 }
223 
224 //______________________________________________________________________________
225 void
227  AliMpExMap& busPatchMap)
228 {
230 
231  AliCodeTimerAuto("",0)
232 
233  static const Int_t kMAXADC = (1<<12)-1; // We code the charge on a 12 bits ADC.
234 
235  // DDL event one per half chamber
236 
237  // raw data
238  Char_t parity = 0x4;
239  UShort_t manuId = 0;
240  UChar_t channelId = 0;
241  UShort_t charge = 0;
242  Int_t busPatchId = 0;
243  Int_t currentBusPatchId = -1;
244  UInt_t word;
245 
246  AliMUONBusStruct* busStruct(0x0);
247 
248  TIter next(digitStore.CreateTrackerIterator());
249  AliMUONVDigit* digit;
250 
251  while ( ( digit = static_cast<AliMUONVDigit*>(next()) ) )
252  {
253  charge = digit->ADC();
254  if ( charge > kMAXADC )
255  {
256  // This is most probably an error in the digitizer (which should insure
257  // the adc is below kMAXADC), so make it a (non-fatal) error indeed.
258  AliError(Form("adc value %d above 0x%x for DE %d . Setting to 0x%x. Digit is:",
259  charge,kMAXADC,digit->DetElemId(),kMAXADC));
260  StdoutToAliError(digit->Print());
261  charge = kMAXADC;
262  }
263 
264  // inverse mapping
265  busPatchId = GetBusPatch(*digit);
266 
267  if (busPatchId<0) continue;
268 
269  if ( digit->ManuId() > 0x7FF ||
270  digit->ManuChannel() > 0x3F )
271  {
272  StdoutToAliError(digit->Print(););
273  AliFatal("ManuId,ManuChannel are invalid for the digit above.");
274  }
275 
276  manuId = ( digit->ManuId() & 0x7FF ); // 11 bits
277  channelId = ( digit->ManuChannel() & 0x3F ); // 6 bits
278 
279  //packing word
280  word = 0;
281  AliBitPacking::PackWord((UInt_t)manuId,word,18,28);
282  AliBitPacking::PackWord((UInt_t)channelId,word,12,17);
283  AliBitPacking::PackWord((UInt_t)charge,word,0,11);
284 
285  // parity word
286  parity = word & 0x1;
287  for (Int_t i = 1; i <= 30; ++i)
288  {
289  parity ^= ((word >> i) & 0x1);
290  }
291  AliBitPacking::PackWord((UInt_t)parity,word,31,31);
292 
293  if ( currentBusPatchId != busPatchId )
294  {
295  busStruct =
296  static_cast<AliMUONBusStruct*>(busPatchMap.GetValue(busPatchId));
297  currentBusPatchId = busPatchId;
298  }
299 
300  if (!busStruct)
301  {
302  busStruct = new AliMUONBusStruct;
303  busStruct->SetDataKey(busStruct->GetDefaultDataKey());
304  busStruct->SetBusPatchId(busPatchId);
305  busStruct->SetLength(0);
306  busPatchMap.Add(busPatchId,busStruct);
307  }
308 
309  // set sub Event
310  busStruct->AddData(word);
311  }
312 }
313 
314 //______________________________________________________________________________
315 void
317 {
319 
320  // buffer size (max'ed out)
321  // (((43 manus max per bus patch *64 channels + 4 bus patch words) * 5 bus patch
322  // + 10 dsp words)*5 dsps + 8 block words)*2 blocks
323 
324  AliCodeTimerAuto("",0)
325 
326  if (fHeader == 0x0) {
327  AliError("Raw data header must be set");
328  return;
329  }
330  memset(fBuffer,0,fBufferSize*sizeof(Int_t));
331 
332  AliMpDDL* ddl = fDDLStore->GetDDL(iDDL);
333  Int_t iDspMax = ddl->GetMaxDsp();
334  Int_t iBusPerDSP[5]; //number of bus patches per DSP
335  ddl->GetBusPerDsp(iBusPerDSP);
336  Int_t busIter = 0;
337 
338  Int_t totalDDLLength = 0;
339 
340  Int_t index = 0;
341 
342  // two blocks A and B per DDL
343  for (Int_t iBlock = 0; iBlock < 2; ++iBlock)
344  {
345  // block header
346  Int_t length = fBlockHeader->GetHeaderLength();
347  memcpy(&fBuffer[index],fBlockHeader->GetHeader(),length*4);
348  Int_t indexBlk = index;
349  index += length;
350 
351  // 5 DSP's max per block
352  for (Int_t iDsp = 0; iDsp < iDspMax; ++iDsp)
353  {
354  // DSP header
355  Int_t dspHeaderLength = fDspHeader->GetHeaderLength();
356  memcpy(&fBuffer[index],fDspHeader->GetHeader(),dspHeaderLength*4);
357  Int_t indexDsp = index;
358  index += dspHeaderLength;
359 
360  // 5 buspatches max per DSP
361  for (Int_t i = 0; i < iBusPerDSP[iDsp]; ++i)
362  {
363  Int_t iBusPatch = ddl->GetBusPatchId(busIter++);
364 
365  // iteration over bus patch in DDL
366  if (iBusPatch == -1)
367  {
368  AliWarning(Form("Error in bus itr in DDL %d\n", iDDL));
369  continue;
370  }
371 
372  AliMUONBusStruct* busStructPtr = static_cast<AliMUONBusStruct*>(busPatchMap.GetValue(iBusPatch));
373 
374  // check if buspatchid has digit
375  if (busStructPtr)
376  {
377  // add bus patch structure header
378  Int_t busHeaderLength = busStructPtr->GetHeaderLength();
379  memcpy(&fBuffer[index],busStructPtr->GetHeader(),busHeaderLength*4);
380  index += busHeaderLength;
381 
382  // add bus patch data
383  Int_t busLength = busStructPtr->GetLength();
384  memcpy(&fBuffer[index],busStructPtr->GetData(),busLength*4);
385  index += busLength;
386  }
387  else
388  {
389  // writting anyhow buspatch structure (empty ones)
390  fBuffer[index++] = busStructPtr->GetDefaultDataKey(); // fill it also for empty data size
391  fBuffer[index++] = busStructPtr->GetHeaderLength(); // header length
392  fBuffer[index++] = 0; // raw data length
393  fBuffer[index++] = iBusPatch; // bus patch
394  }
395  } // bus patch
396 
397  // check if totalLength even
398  // set padding word in case
399  // Add one word 0xBEEFFACE at the end of DSP structure
400  Int_t totalDspLength = index - indexDsp;
401  if ((totalDspLength % 2) == 1)
402  {
403  fBuffer[indexDsp + fDspHeader->GetHeaderLength() - 2] = 1;
405  totalDspLength++;
406  }
407 
408  Int_t dspLength = totalDspLength - fDspHeader->GetHeaderLength();
409 
410  fBuffer[indexDsp+1] = totalDspLength; // dsp total length
411  fBuffer[indexDsp+2] = dspLength; // data length
412 
413  } // dsp
414 
415  Int_t totalBlkLength = index - indexBlk;
416  Int_t blkLength = totalBlkLength - fBlockHeader->GetHeaderLength();
417  totalDDLLength += totalBlkLength;
418 
419  fBuffer[indexBlk+1] = totalBlkLength; // total block length
420  fBuffer[indexBlk+2] = blkLength;
421 
422  } // block
423 
424  // add twice the end of CRT structure data key
425  // hope it's good placed (ChF)
426  fBuffer[index++] = fBlockHeader->GetDdlDataKey();
427  fBuffer[index++] = fBlockHeader->GetDdlDataKey();
428  totalDDLLength += 2;
429 
430  // writting onto disk
431  // total length in bytes
432  // DDL header
433 
434  Int_t headerSize = sizeof(AliRawDataHeaderV3)/4;
435 
436  fHeader->fSize = (totalDDLLength + headerSize) * 4;
437 
438  AliFstream* file = new AliFstream(AliDAQ::DdlFileName("MUONTRK",iDDL));
439 
440  file->WriteBuffer((char*)fHeader,headerSize*4);
441  file->WriteBuffer((char*)fBuffer,sizeof(int)*index);
442  delete file;
443 }
444 
445 //______________________________________________________________________________
447 {
449 
450  return fDDLStore->GetBusPatchId(digit.DetElemId(),digit.ManuId());
451 }
452 
453 //______________________________________________________________________________
454 Int_t AliMUONRawWriter::WriteTriggerDDL(const AliMUONVTriggerStore& triggerStore, AliFstream* file[2])
455 {
457 
458  AliCodeTimerAuto("",0)
459 
460  if (fHeader == 0x0) {
461  AliError("Raw data header must be set");
462  return 0;
463  }
464 
465  // DDL event one per half chamber
466 
467  // DDL header size
468  Int_t headerSize = sizeof(AliRawDataHeaderV3)/4;
469 
470  // global trigger for trigger pattern
471  AliMUONGlobalTrigger* gloTrg = triggerStore.Global();
472  if (!gloTrg)
473  {
474  return 0;
475  }
476 
477  Int_t gloTrigResp = gloTrg->GetGlobalResponse();
478  UInt_t *gloTrigInput = gloTrg->GetGlobalInput();
479 
480  UInt_t word;
481  Int_t* buffer = 0;
482  Int_t index;
483  UChar_t locDec, trigY, posY, posX, regOut;
484  UInt_t regInpLpt;
485  UInt_t regInpHpt;
486 
487  UInt_t devX;
488  UChar_t sdevX;
489  UInt_t version = 1; // software version
490  UInt_t eventPhys = 1; // trigger type: 1 for physics, 0 for software
491  UInt_t serialNb = 0xF; // serial nb of card: all bits on for the moment
492  Int_t globalFlag = 0; // set to 1 if global info present in DDL else set to 0
493 
494  // size of headers
495  static const Int_t kDarcHeaderLength = fDarcHeader->GetDarcHeaderLength();
496  static const Int_t kGlobalHeaderLength = fDarcHeader->GetGlobalHeaderLength();
497  static const Int_t kDarcScalerLength = fDarcHeader->GetDarcScalerLength();
498  static const Int_t kGlobalScalerLength = fDarcHeader->GetGlobalScalerLength();
499  static const Int_t kRegHeaderLength = fRegHeader->GetHeaderLength();
500  static const Int_t kRegScalerLength = fRegHeader->GetScalerLength();
501  static const Int_t kLocHeaderLength = fLocalStruct->GetLength();
502  static const Int_t kLocScalerLength = fLocalStruct->GetScalerLength();
503 
504  // [16(local)*6 words + 6 words]*8(reg) + 8 words = 824
505  static const Int_t kBufferSize = (16 * (kLocHeaderLength+1) + (kRegHeaderLength+1))* 8
506  + kDarcHeaderLength + kGlobalHeaderLength + 2;
507 
508  // [16(local)*51 words + 16 words]*8(reg) + 8 + 10 + 8 words scaler event 6682 words
509  static const Int_t kScalerBufferSize = (16 * (kLocHeaderLength + kLocScalerLength +1) +
510  (kRegHeaderLength + kRegScalerLength +1))* 8 +
511  (kDarcHeaderLength + kDarcScalerLength +
512  kGlobalHeaderLength + kGlobalScalerLength + 2);
513  if(fScalerEvent) {
514  eventPhys = 0; //set to generate scaler events
515  fHeader->fWord2 |= (0x1 << 14); // set L1SwC bit on
516  }
517  if(fScalerEvent)
518  buffer = new Int_t [kScalerBufferSize];
519  else
520  buffer = new Int_t [kBufferSize];
521 
522  // reset crate
523 
524  // open DDL file, on per 1/2 chamber
525  for ( Int_t iDDL = 0; iDDL < 2; ++iDDL )
526  {
527  index = 0;
528 
529  if (iDDL == 0) // suppose global info in DDL one
530  globalFlag = 1;
531  else
532  globalFlag = 0;
533 
534  word = 0;
535  // set darc status word
536  // see AliMUONDarcHeader.h for details
537  AliBitPacking::PackWord((UInt_t)eventPhys,word,30,30);
538  AliBitPacking::PackWord((UInt_t)serialNb,word,20,23);
539  AliBitPacking::PackWord((UInt_t)globalFlag,word,10,10);
540  AliBitPacking::PackWord((UInt_t)version,word,12,19);
541  fDarcHeader->SetWord(word);
542 
543  memcpy(&buffer[index], fDarcHeader->GetHeader(), (kDarcHeaderLength)*4);
544  index += kDarcHeaderLength;
545 
546  // no global input for the moment....
547  if (iDDL == 0) {
548  fDarcHeader->SetGlobalOutput(gloTrigResp);
549  for (Int_t ii = 0; ii < 4; ii++) {
550  fDarcHeader->SetGlobalInput(gloTrigInput[ii],ii);
551  }
552  } else {
554  }
555 
556  if (fScalerEvent) {
557  // 6 DARC scaler words
558  memcpy(&buffer[index], fDarcHeader->GetDarcScalers(),kDarcScalerLength*4);
559  index += kDarcScalerLength;
560  }
561  // end of darc word
562  buffer[index++] = fDarcHeader->GetEndOfDarc();
563 
564  // 4 words of global board input + Global board output
565  memcpy(&buffer[index], fDarcHeader->GetGlobalInput(), (kGlobalHeaderLength)*4);
566  index += kGlobalHeaderLength;
567 
568  if (fScalerEvent) {
569  // 10 Global scaler words
570  memcpy(&buffer[index], fDarcHeader->GetGlobalScalers(), kGlobalScalerLength*4);
571  index += kGlobalScalerLength;
572  }
573 
574  // end of global word
575  buffer[index++] = fDarcHeader->GetEndOfGlobal();
577 
578  Int_t nCrate = reg->GetNofTriggerCrates()/2;
579  // 8 regional cards per DDL
580  for (Int_t iReg = 0; iReg < nCrate; ++iReg) {
581 
582  // crate info
584 
585  if (!crate) {
586  AliError(Form("Missing crate number %d in DDL %d\n", iReg, iDDL));
587  continue;
588  }
589 
590  // regional info tree, make sure that no reg card missing
591  AliMUONRegionalTrigger* regTrg = triggerStore.FindRegional(crate->GetId());
592  if (!regTrg) {
593  AliError(Form("Missing regional board %d in trigger Store\n", crate->GetId()));
594  continue;
595  }
596 
597  // Regional card header
598  word = 0;
599 
600  // set darc status word
601  fRegHeader->SetDarcWord(word);
602 
603  regOut = regTrg->GetOutput();
604  regInpLpt = regTrg->GetLocalOutput(0);
605  regInpHpt = regTrg->GetLocalOutput(1);
606 
607  // fill darc word, not darc status for the moment (empty)
608  //see AliMUONRegHeader.h for details
609  AliBitPacking::PackWord((UInt_t)eventPhys,word,31,31);
610  AliBitPacking::PackWord((UInt_t)serialNb,word,20,25);
611  AliBitPacking::PackWord((UInt_t)version,word,8,15);
612  AliBitPacking::PackWord((UInt_t)crate->GetId(),word,16,19);
613  AliBitPacking::PackWord((UInt_t)regOut,word,0,7);
614  fRegHeader->SetWord(word);
615 
616 
617  // fill header later, need local response
618  Int_t indexReg = index;
619  index += kRegHeaderLength;
620 
621  // 11 regional scaler word
622  if (fScalerEvent) {
623  memcpy(&buffer[index], fRegHeader->GetScalers(), kRegScalerLength*4);
624  index += kRegScalerLength;
625  }
626 
627  // end of regional word
628  buffer[index++] = fRegHeader->GetEndOfReg();
629 
630  // 16 local card per regional board
631  // UShort_t localMask = 0x0;
632 
633  Int_t nLocalBoard = AliMpConstants::LocalBoardNofChannels();
634 
635  for (Int_t iLoc = 0; iLoc < nLocalBoard; iLoc++) {
636 
637  // slot zero for Regional card
638  Int_t localBoardId = crate->GetLocalBoardId(iLoc);
639 
640  if (localBoardId) { // if not empty slot
641  AliMpLocalBoard* localBoard = AliMpDDLStore::Instance()->GetLocalBoard(localBoardId);
642 
643  if (localBoard->IsNotified()) {// if notified board
644  AliMUONLocalTrigger* locTrg = triggerStore.FindLocal(localBoardId);
645 
646  if (locTrg)
647  {
648  locDec = locTrg->GetLoDecision();
649  trigY = locTrg->LoTrigY();
650  posY = locTrg->LoStripY();
651  posX = locTrg->LoStripX();
652  devX = locTrg->LoDev();
653  sdevX = locTrg->LoSdev();
654 
655  AliDebug(4,Form("loctrg %d, posX %d, posY %d, devX %d\n",
656  locTrg->LoCircuit(),locTrg->LoStripX(),locTrg->LoStripY(),locTrg->LoDev()));
657  //packing word
658  word = 0;
659  LocalWordPacking(word, (UInt_t)iLoc, (UInt_t)locDec, (UInt_t)trigY, (UInt_t)posY,
660  (UInt_t)posX, (UInt_t)sdevX, (UInt_t)devX);
661 
662  buffer[index++] = (locTrg->GetX1Pattern() | (locTrg->GetX2Pattern() << 16));
663  buffer[index++] = (locTrg->GetX3Pattern() | (locTrg->GetX4Pattern() << 16));
664  buffer[index++] = (locTrg->GetY1Pattern() | (locTrg->GetY2Pattern() << 16));
665  buffer[index++] = (locTrg->GetY3Pattern() | (locTrg->GetY4Pattern() << 16));
666  buffer[index++] = (Int_t)word; // data word
667  }
668  }
669  // fill copy card X-Y inputs from the notified cards
670  if (localBoard->GetInputXfrom() && localBoard->GetInputYfrom())
671  {
672  // not triggered
673  locDec = 0; trigY = 1; posY = 15;
674  posX = 0; devX = 0; sdevX = 1;
675  LocalWordPacking(word, (UInt_t)iLoc, (UInt_t)locDec, (UInt_t)trigY, (UInt_t)posY,
676  (UInt_t)posX, (UInt_t)sdevX, (UInt_t)devX);
677 
678  Int_t localFromId = localBoard->GetInputXfrom();
679  AliMUONLocalTrigger* locTrgfrom = triggerStore.FindLocal(localFromId);
680 
681  if ( locTrgfrom )
682  {
683  buffer[index++] = 0; // copy only X3-4 & Y1-4
684  buffer[index++] = (locTrgfrom->GetX3Pattern() | (locTrgfrom->GetX4Pattern() << 16));
685  buffer[index++] = (locTrgfrom->GetY1Pattern() | (locTrgfrom->GetY2Pattern() << 16));
686  buffer[index++] = (locTrgfrom->GetY3Pattern() | (locTrgfrom->GetY4Pattern() << 16));
687  buffer[index++] = word;
688  }
689  }
690 
691  } else {
692  // fill with 10CDEAD word for empty slots
693  for (Int_t i = 0; i < fLocalStruct->GetLength(); i++)
694  buffer[index++] = fLocalStruct->GetDisableWord();
695  }// condition localBoard
696 
697  // 45 regional scaler word
698  if (fScalerEvent) {
699  memcpy(&buffer[index], fLocalStruct->GetScalers(), kLocScalerLength*4);
700  index += kLocScalerLength;
701  }
702 
703  // end of local structure words
704  buffer[index++] = fLocalStruct->GetEndOfLocal();
705 
706  } // local card
707  // fill regional header with local output
708  fRegHeader->SetInput(regInpLpt, 0);
709  fRegHeader->SetInput(regInpHpt, 1);
710  memcpy(&buffer[indexReg],fRegHeader->GetHeader(),kRegHeaderLength*4);
711 
712  } // Regional card
713 
714 
715  // writting onto disk
716  // write DDL's
717  fHeader->fSize = (index + headerSize) * 4;// total length in bytes
718  file[iDDL]->WriteBuffer((char*)fHeader,headerSize*4);
719  file[iDDL]->WriteBuffer((char*)buffer,sizeof(int)*index);
720 
721  }
722  delete[] buffer;
723 
724  return kTRUE;
725 }
726 
727 //____________________________________________________________________
729 {
733 
737 
738  fScalerEvent = kTRUE;
739 }
740 
UInt_t GetEndOfReg() const
Return end of regional info word.
Int_t GetLength() const
Return length of raw data.
Int_t GetGlobalHeaderLength() const
Return global header length.
Int_t * GetHeader()
Return header.
void SetScalersNumbers()
set random numbers to fill variable
Rawdata local card structure for trigger.
Bool_t IsNotified() const
Return notified flag (not copy card)
Int_t GetHeaderLength() const
Return header length.
void GetBusPerDsp(Int_t *iBusPerDSP) const
Definition: AliMpDDL.cxx:265
AliMpLocalBoard * GetLocalBoard(Int_t localBoardId, Bool_t warn=true) const
UInt_t GetDefaultPaddingWord() const
Return default padding word value.
UInt_t GetEndOfLocal() const
Return end of local info word.
Interface for a digit container.
UShort_t GetId() const
Return Id.
Int_t GetNofTriggerCrates() const
The class defines the properties of trigger crate.
UInt_t GetDdlDataKey() const
Return data key end word for CRT header.
UInt_t * GetGlobalInput()
Return global input to the global trigger board.
The top container class for DDLs, det elements and bus patched.
Definition: AliMpDDLStore.h:35
Int_t * GetHeader()
Return header.
UInt_t * GetDarcScalers()
Return DARC L0 received and used.
Int_t GetDarcScalerLength() const
Return length of DARC scaler in word.
Int_t GetLocalBoardId(Int_t index) const
UInt_t GetLocalOutput(Int_t n) const
Return local output Lpt & Hpt.
Int_t GetLength() const
Return local info length in word.
virtual Int_t ADC() const =0
Raw ADC value of this digit.
Int_t GetInputYfrom() const
Get Id from where the Y input are copied.
void SetSize(Int_t size)
Definition: AliMpExMap.cxx:322
Int_t GetScalerLength() const
Return scaler length in word.
Bool_t fScalerEvent
flag to generates scaler event
Int_t GetGlobalScalerLength() const
Return length of global scaler in word.
MUON DSP header for tracker event.
AliMUONDspHeader * fDspHeader
! DDL Dsp header class pointers
static Bool_t LoadDDLStore(Bool_t warn=false)
Definition: AliMpCDB.cxx:149
const AliMpRegionalTrigger * GetRegionalTrigger() const
Return regional trigger object.
Definition: AliMpDDLStore.h:55
Int_t * fBuffer
! internal data buffer
UInt_t GetDisableWord() const
Return Word for "empty" slots.
UInt_t * GetData() const
Return data.
Class that manages the properties of the local board.
void Digits2BusPatchMap(const AliMUONVDigitStore &digitStore, AliMpExMap &busPatchMap)
MUON regional header for trigger.
UShort_t GetX3Pattern() const
Return X strip pattern for chamber 21.
virtual Int_t DetElemId() const =0
The detection element this digit belongs to.
static Int_t GetHeaderLength()
Return header length in word.
Int_t LoStripY() const
Return Y strip in MT11.
Base class of a trigger information store.
void AddData(UInt_t d)
UShort_t GetY4Pattern() const
Return Y strip pattern for chamber 22.
The class defined electronics properties of DDL.
Definition: AliMpDDL.h:20
UShort_t GetX4Pattern() const
Return X strip pattern for chamber 22.
ClassImp(TPCGenInfo)
Definition: AliTPCCmpNG.C:254
Char_t GetOutput() const
Return regional output (single muon:2, unlike sign:1, like sign:1)
Int_t * GetHeader()
Return header.
void WriteTrackerDDL(AliMpExMap &busPatchMap, Int_t iDDL)
Reconstructed regional Trigger object.
static AliMpDDLStore * Instance(Bool_t warn=true)
UInt_t GetEndOfDarc() const
Return end of darc info word.
Int_t LoStripX() const
Return X strip in MT11.
UShort_t GetX1Pattern() const
Return X strip pattern for chamber 11.
static UInt_t GetDefaultDataKey()
Return default data key word for Bus Patch Header.
Int_t GetNofBusPatches() const
Definition: AliMpDDL.cxx:203
Int_t Digits2Raw(const AliMUONVDigitStore *digitStore, const AliMUONVTriggerStore *triggerStore)
Int_t WriteTriggerDDL(const AliMUONVTriggerStore &triggerStore, AliFstream *file[2])
Int_t GetBusPatchId(Int_t detElemId, Int_t manuId) const
AliMUONLocalStruct * fLocalStruct
! DDL local structure class pointers
UInt_t * GetScalers()
Return scalers.
Int_t GetScalerLength() const
get scaler length
Reconstructed Local Trigger object.
UInt_t * GetHeader()
Return header.
AliRawDataHeaderSim * fHeader
header of DDL
UInt_t * GetHeader()
Return header.
AliMpDDL * GetDDL(Int_t ddlId, Bool_t warn=true) const
virtual AliMUONRegionalTrigger * FindRegional(Int_t boardNumber) const =0
Find a regional trigger by the board number (not an index, it is a number really) ...
void SetGlobalOutput(Int_t out)
Set global output.
UShort_t GetY1Pattern() const
Return Y strip pattern for chamber 11.
UShort_t GetY3Pattern() const
Return Y strip pattern for chamber 21.
Int_t GetHeaderLength() const
Return header length in word.
Int_t LoSdev() const
Return Sign of Deviation.
virtual TIterator * CreateTrackerIterator() const =0
Create an iterator to loop over tracker digits only.
TObject * GetValue(Int_t keyFirst, Int_t keySecond) const
Definition: AliMpExMap.cxx:365
MUON Darc header for Trigger.
UShort_t GetY2Pattern() const
Return Y strip pattern for chamber 12.
virtual AliMUONGlobalTrigger * Global() const =0
Return global trigger.
Int_t GetHeaderLength() const
Return header length in word.
void SetBusPatchId(Int_t b)
Set bus patch id.
void SetWord(UInt_t w)
Set first word.
Int_t LoDev() const
Return Deviation.
The class defines the properties of regional trigger crate.
void SetGlobalInput(UInt_t in, Int_t n)
Set global input.
static Int_t LocalBoardNofChannels()
Max number of channels per local board.
AliMUONRegHeader * fRegHeader
! DDL regional header class pointers
void Add(Int_t keyFirst, Int_t keySecond, TObject *object)
Definition: AliMpExMap.cxx:292
void SetDataKey(Int_t d)
Set Data key word for bus patch header.
Raw data class for trigger and tracker chambers.
UInt_t GetGlobalInput(Int_t n) const
Return global input.
Int_t GetMaxDsp() const
Definition: AliMpDDL.cxx:251
static void LocalWordPacking(UInt_t &word, UInt_t locId, UInt_t locDec, UInt_t trigY, UInt_t posY, UInt_t posX, UInt_t sdevX, UInt_t devX)
Char_t GetLoDecision() const
AliMpTriggerCrate * GetTriggerCrate(TString crateName, Bool_t warn=true) const
AliMUONDarcHeader * fDarcHeader
! DDL darc header class pointers
UChar_t GetGlobalResponse() const
void SetInput(UInt_t in, Int_t n)
Set regional input.
void SetWord(UInt_t w)
Set first reg word.
MUON block (Crocus CRT) header for tracker event.
virtual Int_t ManuId() const =0
The electronic card id this digit belongs to (manuId for tracker, localboardId for trigger) ...
Global trigger object.
ABC of a MUON digit.
Definition: AliMUONVDigit.h:18
Int_t LoTrigY() const
Return Trig Y.
UShort_t GetX2Pattern() const
Return X strip pattern for chamber 12.
void SetLength(Int_t l)
Set length of raw data.
Int_t GetBusPatchId(Int_t index) const
Definition: AliMpDDL.cxx:211
Int_t fBufferSize
! size of internal data buffer
Globally used constants definition.
UInt_t * GetScalers()
Return scalers.
UInt_t GetEndOfGlobal() const
Return end of global info word.
AliMpDDLStore * fDDLStore
! DDL store pointer
Int_t GetBusPatch(const AliMUONVDigit &digit) const
MUON buspatch structure for tracker.
virtual AliMUONLocalTrigger * FindLocal(Int_t boardNumber) const =0
Find a local trigger by the board number (not an index, it is a number really)
UInt_t * GetGlobalScalers()
Return global L0.
Int_t LoCircuit() const
Return Circuit number.
Int_t GetInputXfrom() const
Get Id from where the X input are copied.
Helper class making Root persistent TExMap.
Definition: AliMpExMap.h:28
void SetDarcWord(UInt_t w)
Set darc word.
Int_t GetDarcHeaderLength() const
Return darc header length.
AliMUONBlockHeader * fBlockHeader
! DDL block header class pointers