AliRoot Core  edcc906 (edcc906)
AliMUONDigitMaker.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 //-----------------------------------------------------------------------------
43 //-----------------------------------------------------------------------------
44 
45 #include "AliMUONDigitMaker.h"
46 
47 #include "AliMUONDDLTrigger.h"
48 #include "AliMUONDarcHeader.h"
49 #include "AliMUONVDigit.h"
50 #include "AliMUONVDigitStore.h"
51 #include "AliMUONGlobalTrigger.h"
52 #include "AliMUONLocalStruct.h"
53 #include "AliMUONLocalTrigger.h"
54 #include "AliMUONLogger.h"
57 #include "AliMUONRegHeader.h"
58 #include "AliMUONVTriggerStore.h"
59 #include "AliMpCDB.h"
60 #include "AliMpDetElement.h"
61 #include "AliMpTriggerCrate.h"
62 #include "AliMpLocalBoard.h"
63 #include "AliMpCathodType.h"
64 #include "AliMpDDLStore.h"
65 #include "AliMpDEManager.h"
66 #include "AliMpPad.h"
67 #include "AliMpSegmentation.h"
68 #include "AliMpVSegmentation.h"
69 #include "AliCodeTimer.h"
70 #include "AliLog.h"
71 #include "AliRawReader.h"
72 #include <TArrayS.h>
73 #include <iostream>
74 
75 using std::endl;
76 using std::cout;
78 ClassImp(AliMUONDigitMaker) // Class implementation in ROOT context
80 
81 //__________________________________________________________________________
82 AliMUONDigitMaker::AliMUONDigitMaker(Bool_t enableErrorLogger, Bool_t a, Bool_t b) :
83 TObject(),
84 fScalerEvent(kFALSE),
85 fMakeTriggerDigits(kFALSE),
86 fMakeTrackerDigits(kFALSE),
87 fRawStreamTracker(new AliMUONRawStreamTrackerHP),
88 fRawStreamTrigger(new AliMUONRawStreamTriggerHP),
89 fDigitStore(0x0),
90 fTriggerStore(0x0),
91 fLogger(new AliMUONLogger(10000)){
93 
94  if ( !a || !b ) AliFatal("no longer supported");
95 
96  AliDebug(1,"");
97 
98  // Standard Constructor
99  if (enableErrorLogger)
100  {
101  fRawStreamTracker->EnabbleErrorLogger();
102  fRawStreamTrigger->EnabbleErrorLogger();
103  }
104  else
105  {
106  fRawStreamTracker->DisableWarnings();
107  }
108 
109  SetMakeTriggerDigits();
110  SetMakeTrackerDigits();
111 
112  // Load mapping
113  if ( ! AliMpCDB::LoadDDLStore() ) {
114  AliFatal("Could not access mapping from OCDB !");
115  }
116 }
117 
118 //__________________________________________________________________________
119 AliMUONDigitMaker::AliMUONDigitMaker(Bool_t enableErrorLogger) :
120 TObject(),
121  fScalerEvent(kFALSE),
122  fMakeTriggerDigits(kFALSE),
123  fMakeTrackerDigits(kFALSE),
124  fRawStreamTracker(new AliMUONRawStreamTrackerHP),
125  fRawStreamTrigger(new AliMUONRawStreamTriggerHP),
126  fDigitStore(0x0),
127  fTriggerStore(0x0),
128  fLogger(new AliMUONLogger(10000))
129 {
131 
132  AliDebug(1,"");
133 
134  // Standard Constructor
135  if (enableErrorLogger)
136  {
139  }
140  else
141  {
143  }
144 
147 
148  // Load mapping
149  if ( ! AliMpCDB::LoadDDLStore() ) {
150  AliFatal("Could not access mapping from OCDB !");
151  }
152 }
153 
154 //__________________________________________________________________________
156 {
159 
160  delete fRawStreamTracker;
161  delete fRawStreamTrigger;
162  delete fLogger;
163 }
164 
165 //____________________________________________________________________
166 void
167 AliMUONDigitMaker::Print(Option_t*) const
168 {
170 
171  cout << "RawStreamerTracker class=" << fRawStreamTracker->ClassName()
172  << " MakeTriggerDigits=" << fMakeTriggerDigits
173  << " ScalerEvent=" << fScalerEvent
174  << " DigitStore=" << fDigitStore
175  << " TriggerStore=" << fTriggerStore << endl;
176 
177  if ( fLogger ) fLogger->Print();
178 }
179 
180 //____________________________________________________________________
181 Int_t
182 AliMUONDigitMaker::Raw2Digits(AliRawReader* rawReader,
183  AliMUONVDigitStore* digitStore,
184  AliMUONVTriggerStore* triggerStore)
185 {
189 
190  AliDebug(1,Form("rawReader=%p digitStore=%p triggerStore=%p",
191  rawReader,digitStore,triggerStore));
192 
193  fDigitStore = digitStore;
194  fTriggerStore = triggerStore;
195 
196  if (!fDigitStore && !fTriggerStore)
197  {
198  fLogger->Log("No digit or trigger store given. Nothing to do...");
199  return kTriggerBAD & kTrackerBAD;
200  }
201 
202  Int_t tracker(kOK);
203  Int_t trigger(kOK);
204 
205  if ( fDigitStore ) fDigitStore->Clear(); // insure we start with an empty container
206 
207  if ( fMakeTrackerDigits ) {
208  if ( fDigitStore ) tracker = ReadTrackerDDL(rawReader);
209  else fLogger->Log("Asking for tracker digits but digitStore is null");
210  }
211 
213  {
215  if ( fMakeTriggerDigits && !fDigitStore )
216  {
217  fLogger->Log("Asking for trigger digits but digitStore is null");
218  }
219  else
220  {
221  trigger = ReadTriggerDDL(rawReader);
222  }
223  }
224 
225  return tracker | trigger;
226 }
227 
228 //____________________________________________________________________
229 Int_t
230 AliMUONDigitMaker::ReadTrackerDDL(AliRawReader* rawReader)
231 {
234 
235  AliDebug(1,"");
236 
237  AliCodeTimerAuto("",0);
238 
239  // elex info
240  Int_t buspatchId;
241  UChar_t channelId;
242  UShort_t manuId;
243  UShort_t charge;
244 
245  fRawStreamTracker->SetReader(rawReader);
247 
248  while ( fRawStreamTracker->Next(buspatchId,manuId,channelId,charge,kTRUE) )
249  {
250  // getting DE from buspatch
251  Int_t detElemId = AliMpDDLStore::Instance()->GetDEfromBus(buspatchId);
252 
254 
255  if (!de)
256  {
257  fLogger->Log(Form("DE %04d does not exist !", detElemId));
258  continue;
259  }
260 
261  if (!de->IsConnectedChannel(manuId,channelId))
262  {
263  // non connected pad, do nothing (this is not an error !)
264  continue;
265  }
266 
267  const AliMpVSegmentation* seg
269  manuId);
270 
271  if (!seg)
272  {
273  fLogger->Log(Form("(DE,MANUID)=(%04d,%04d) is not valid",detElemId,manuId));
274  continue;
275  }
276 
277  AliMp::CathodType cathodeType = de->GetCathodType(seg->PlaneType());
278 
279  AliMpPad pad = seg->PadByLocation(manuId,channelId,kFALSE);
280 
281  if (!pad.IsValid())
282  {
283  fLogger->Log(Form("No pad for detElemId: %d, manuId: %d, channelId: %d",
284  detElemId, manuId, channelId));
285  continue;
286  }
287 
288  AliMUONVDigit* digit = fDigitStore->Add(detElemId,manuId,channelId,cathodeType,
290 
291  if (!digit)
292  {
293  fLogger->Log(Form("Digit DE %04d Manu %04d Channel %02d could not be added",
294  detElemId, manuId, channelId));
295  continue;
296  }
297 
298  digit->SetPadXY(pad.GetIx(),pad.GetIy());
299 
300  digit->SetADC(charge);
301 
302  }
303 
305  {
306  return kTrackerBAD;
307  }
308 
309  return kOK;
310 }
311 
312 //____________________________________________________________________
313 Int_t
314 AliMUONDigitMaker::ReadTriggerDDL(AliRawReader* rawReader)
315 {
318 
319  const AliMUONRawStreamTriggerHP::AliHeader* darcHeader = 0x0;
320  const AliMUONRawStreamTriggerHP::AliRegionalHeader* regHeader = 0x0;
321  const AliMUONRawStreamTriggerHP::AliLocalStruct* localStruct = 0x0;
322 
323  Int_t loCircuit;
324 
325  fRawStreamTrigger->SetReader(rawReader);
326 
327  while (fRawStreamTrigger->NextDDL())
328  {
329  darcHeader = fRawStreamTrigger->GetHeaders();
330 
331  // fill global trigger information
332  if (fTriggerStore)
333  {
334  if (darcHeader->GetGlobalFlag())
335  {
336  AliMUONGlobalTrigger globalTrigger;
337  globalTrigger.SetFromGlobalResponse(darcHeader->GetGlobalOutput());
338  globalTrigger.SetFromGlobalInput(darcHeader->GetGlobalHeader()->fInput);
339  fTriggerStore->SetGlobal(globalTrigger);
340  }
341  }
342 
344 
345  for(Int_t iReg = 0; iReg < nReg ;iReg++)
346  { //reg loop
347 
348 
349  // crate info
351  GetTriggerCrate(fRawStreamTrigger->GetDDL(), iReg);
352 
353  if (!crate) {
354  fLogger->Log(Form("Missing crate number %d in DDL %d\n", iReg, fRawStreamTrigger->GetDDL()));
355  continue;
356  }
357 
358  regHeader = fRawStreamTrigger->GetRegionalHeader(iReg);
359 
360  Int_t nLocal = regHeader->GetLocalStructCount();
361  for(Int_t iLocal = 0; iLocal < nLocal; iLocal++)
362  {
363 
364  localStruct = regHeader->GetLocalStruct(iLocal);
365 
366  // if card exist
367  if (localStruct) {
368 
369  loCircuit = crate->GetLocalBoardId(localStruct->GetId());
370 
371  if ( !loCircuit ) continue; // empty slot
372 
373 
374  if (fTriggerStore)
375  {
376  // fill local trigger
377  AliMUONLocalTrigger localTrigger;
378  localTrigger.SetLocalStruct(loCircuit, *localStruct);
379  fTriggerStore->Add(localTrigger);
380  }
381 
382  if ( fMakeTriggerDigits )
383  {
384  //FIXEME should find something better than a TArray
385  TArrayS xyPattern[2];
386 
387  localStruct->GetXPattern(xyPattern[0]);
388  localStruct->GetYPattern(xyPattern[1]);
389 
390  TriggerDigits(loCircuit, xyPattern, *fDigitStore);
391  }
392  } // if triggerY
393  } // iLocal
394  } // iReg
395  } // NextDDL
396 
397  return kOK;
398 }
399 
400 //____________________________________________________________________
402  const TArrayS* xyPattern,
403  AliMUONVDigitStore& digitStore, Bool_t warn) const
404 {
406 
407  AliCodeTimerAuto("",0);
408 
409  Int_t detElemId;
410 
411  AliMpLocalBoard* localBoard = AliMpDDLStore::Instance()->GetLocalBoard(nBoard);
412 
413  if ( ! localBoard->IsNotified() ) {
414  // Copy board
415  // The mapping is not correct for copy boards
416  // Use the one of corresponding phyiscal board
417  nBoard = localBoard->GetInputXfrom();
418  }
419 
420  Int_t n,b;
421 
422  // loop over x1-4 and y1-4
423  for (Int_t iChamber = 0; iChamber < 4; ++iChamber)
424  {
425  for (Int_t iCath = 0; iCath < 2; ++iCath)
426  {
427  Int_t pattern = (Int_t)xyPattern[iCath].At(iChamber);
428  if (!pattern) continue;
429 
430  // get detElemId
431  detElemId = AliMpDDLStore::Instance()->GetDEfromLocalBoard(nBoard, iChamber);
432 
433  const AliMpVSegmentation* seg
435  ->GetMpSegmentation(detElemId, AliMp::GetCathodType(iCath));
436 
437  // loop over the 16 bits of pattern
438  for (Int_t ibitxy = 0; ibitxy < 16; ++ibitxy)
439  {
440  if ((pattern >> ibitxy) & 0x1)
441  {
442  // not quite sure about this
443  Int_t offset = 0;
444  if (iCath && localBoard->GetSwitch(AliMpLocalBoard::kZeroAllYLSB)) offset = -8;
445 
446  AliMpPad pad = seg->PadByLocation(nBoard,ibitxy+offset,warn);
447 
448  if (!pad.IsValid())
449  {
450  fLogger->Log(Form("No pad for detElemId: %d, nboard %d, ibitxy: %d\n",
451  detElemId, nBoard, ibitxy));
452  continue;
453  }
454 
455  n = pad.GetLocalBoardId(0); // always take first location so that digits are not inserted several times
456  b = pad.GetLocalBoardChannel(0);
457 
458  AliDebug(1,Form("Using localBoard %d ixy %d instead of %d,%d",
459  n,b,nBoard,ibitxy));
460 
461  AliMUONVDigit* digit = digitStore.Add(detElemId,n,b,iCath,AliMUONVDigitStore::kDeny);
462 
463  if (!digit)
464  {
465  AliDebug(1, Form("Digit DE %04d LocalBoard %03d ibitxy %02d cath %d already in store",
466  detElemId,nBoard,ibitxy,iCath));
467  continue;
468  }
469 
470  Int_t padX = pad.GetIx();
471  Int_t padY = pad.GetIy();
472 
473  // fill digit
474  digit->SetPadXY(padX,padY);
475  digit->SetCharge(1.);
476  }// xyPattern
477  }// ibitxy
478  }// cath
479  } // ichamber
480 
481  return kTRUE;
482 }
483 
484 //______________________________________________________________________________
485 Bool_t
487  AliMUONVDigitStore& digitStore) const
488 {
489  //
491  //
492 
493  digitStore.Clear();
494 
495  AliMUONLocalTrigger* locTrg;
496  TIter next(triggerStore.CreateLocalIterator());
497 
498  while ( ( locTrg = static_cast<AliMUONLocalTrigger*>(next()) ) )
499  {
500  if (locTrg->IsNull()) continue;
501 
502  TArrayS xyPattern[2];
503  locTrg->GetXPattern(xyPattern[0]);
504  locTrg->GetYPattern(xyPattern[1]);
505 
506  Int_t nBoard = locTrg->LoCircuit();
507  TriggerDigits(nBoard, xyPattern, digitStore);
508  }
509  return kTRUE;
510 }
511 
512 //______________________________________________________________________________
513 void
515 {
519 }
void GetYPattern(TArrayS &array) const
return Y pattern array
virtual void EnabbleErrorLogger()
Enable error logging to the raw reader.
void GetXPattern(TArrayS &array) const
return X pattern array
A high performance stream decoder for muon tracking DDL streams.
TBrowser b
Definition: RunAnaESD.C:12
const AliHeader * GetHeaders() const
Returns the DARC and global headers plus scalars if they exist.
Light weight interface class to the local trigger card data.
void SetFromGlobalInput(const UInt_t *globalInput)
Reading Raw data class for trigger and tracker chambers.
void SetMakeTriggerDigits(Bool_t flag=kFALSE)
Set flag whether or not we should generate digits for the trigger.
const AliMpVSegmentation * GetMpSegmentation(Int_t detElemId, AliMp::CathodType cath, Bool_t warn=true) const
virtual TIterator * CreateLocalIterator() const =0
Create iterator on local trigger.
AliMUONRawStreamTrackerHP * fRawStreamTracker
! pointer of raw stream for tracker
void SetFromGlobalResponse(UShort_t globalResponse)
Bool_t IsNotified() const
Return notified flag (not copy card)
virtual void SetReader(AliRawReader *rawReader)
Set object for reading the raw data.
AliMpLocalBoard * GetLocalBoard(Int_t localBoardId, Bool_t warn=true) const
Interface for a digit container.
void Print(Option_t *opt="") const
Bool_t GetGlobalFlag() const
Return global flag.
Int_t GetDEfromLocalBoard(Int_t localBoardId, Int_t chamberId) const
The class defines the properties of trigger crate.
virtual AliMp::PlaneType PlaneType() const =0
Return the plane type.
static AliMpSegmentation * Instance(Bool_t warn=true)
Int_t GetIy() const
Definition: AliMpPad.cxx:280
void SetLocalStruct(Int_t loCircuit, AliMUONLocalStruct &localStruct)
Int_t ReadTriggerDDL(AliRawReader *rawReader)
Int_t TriggerDigits(Int_t nBoard, const TArrayS *xyPattern, AliMUONVDigitStore &digitStore, Bool_t warn=kTRUE) const
virtual Bool_t NextDDL()
DDL iterator.
Int_t GetLocalBoardId(Int_t index) const
Int_t ReadTrackerDDL(AliRawReader *rawReader)
Light weight interface class to the DARC and global header data.
void GetXPattern(TArrayS &array) const
return X pattern array
void Print(Option_t *opt="") const
Int_t Log(const char *message)
virtual ~AliMUONDigitMaker(void)
Int_t GetDEfromBus(Int_t busPatchId) const
virtual void SetGlobal(const AliMUONGlobalTrigger &globalTrigger)=0
Set global trigger.
const AliRegionalHeader * GetRegionalHeader(UInt_t i) const
Return the i&#39;th regional header or NULL if not found.
const AliMUONGlobalHeaderStruct * GetGlobalHeader() const
Return the global header&#39;s raw data.
static Bool_t LoadDDLStore(Bool_t warn=false)
Definition: AliMpCDB.cxx:149
Int_t GetSwitch(Int_t index) const
Get switch bit wise (return a inteter for backware compatibility)
Higher performance decoder stream class for reading MUON raw trigger data.
const AliMpVSegmentation * GetMpSegmentationByElectronics(Int_t detElemId, Int_t elCardID, Bool_t warn=true) const
AliMpDetElement * GetDetElement(Int_t detElemId, Bool_t warn=true) const
Class that manages the properties of the local board.
The class defines the electronics properties of detection element.
virtual void SetCharge(Float_t q)=0
Set the charge of this digit.
void DisableWarnings()
Set warnings flag to disable warnings on data errors.
Bool_t fMakeTriggerDigits
! whether or not we should generate digits for the trigger
Base class of a trigger information store.
const AliLocalStruct * GetLocalStruct(UInt_t i) const
Return the i&#39;th local trigger structure in this regional structure.
Int_t Raw2Digits(AliRawReader *rawReader, AliMUONVDigitStore *digitContainer=0, AliMUONVTriggerStore *triggerStore=0)
AliMUONRawStreamTriggerHP * fRawStreamTrigger
! pointer of raw stream for trigger
A logger that keeps track of the number of times a message appeared.
Definition: AliMUONLogger.h:24
Bool_t TryRecover() const
Returns the "try to recover from errors" flag.
static AliMpDDLStore * Instance(Bool_t warn=true)
AliMUONLogger * fLogger
! to log messages
Reconstructed Local Trigger object.
AliMUONVTriggerStore * fTriggerStore
! not owner
virtual void SetADC(Int_t adc)=0
Set the ADC value.
UChar_t GetGlobalOutput() const
Return global output.
AliMUONVDigitStore * fDigitStore
! not owner
virtual Bool_t IsErrorMessage() const
check error/Warning presence
tracker part had readout errors
(1) reset the LSB for special configuration of board RC2L5B4 & RC2L6B1
#define AliCodeTimerAuto(message, counter)
Definition: AliCodeTimer.h:137
virtual void SetPadXY(Int_t padx, Int_t pady)=0
Set the ix and iy of this digit.
AliMp::CathodType GetCathodType(Int_t cathodNumber)
Convert integer number in enum;.
Int_t GetLocalBoardId(Int_t i) const
Definition: AliMpPad.cxx:347
Light weight interface class to the regional card header data.
void SetMakeTrackerDigits(Bool_t flag=kTRUE)
Set flag whether or not we should generate digits for the tracker.
#define AliFatal(message)
Definition: AliLog.h:640
void SetReader(AliRawReader *reader)
Set the raw reader.
Bool_t IsValid() const
Return validity.
Definition: AliMpPad.h:89
virtual Int_t GetDDL() const
Return number of the current DDL being handled in the range [0..1] and -1 if no DDL set...
void GetYPattern(TArrayS &array) const
return Y pattern array
#define AliDebug(logLevel, message)
Definition: AliLog.h:300
virtual void First()
Initialize iterator.
Int_t GetIx() const
Definition: AliMpPad.cxx:272
AliMp::CathodType GetCathodType(AliMp::PlaneType planeType) const
Bool_t fMakeTrackerDigits
! whether or not we should generate digits for the tracker
The abstract base class for the segmentation.
Global trigger object.
ABC of a MUON digit.
Definition: AliMUONVDigit.h:18
UInt_t fInput[4]
Global input. 8-bit words comming from the each of the 16 regional controlers.
Class which encapsuate all information about a pad.
Definition: AliMpPad.h:22
UInt_t GetRegionalHeaderCount() const
Return the number of regional structures in the DDL payload.
virtual Bool_t Add(TObject *object)
Add an object, if of the right type.
void SetTryRecover(Bool_t flag)
virtual void Clear(Option_t *opt="")=0
Clear ourselves (i.e. Reset)
virtual void EnabbleErrorLogger()
Enable error info logger.
Bool_t IsConnectedChannel(Int_t manuId, Int_t manuChannel) const
Bool_t TriggerToDigitsStore(const AliMUONVTriggerStore &triggerStore, AliMUONVDigitStore &digitStore) const
virtual AliMpPad PadByLocation(Int_t manuId, Int_t manuChannel, Bool_t warning=true) const =0
Find pad by location.
AliMUONDigitMaker(Bool_t enableErrorLogger, Bool_t a, Bool_t b)
Declaration of the high performance decoder for muon trigger chamber raw streams. ...
Int_t GetLocalBoardChannel(Int_t i) const
Definition: AliMpPad.cxx:358
trigger part had readout errors
Int_t LoCircuit() const
Return Circuit number.
virtual Bool_t Next(Int_t &busPatchId, UShort_t &manuId, UChar_t &manuChannel, UShort_t &adc)
Advance one step in the iteration. Returns false if finished.
Int_t GetInputXfrom() const
Get Id from where the X input are copied.
virtual Bool_t Add(TObject *object)
Add an object, if it is of the right class.
UInt_t GetLocalStructCount() const
Returns the number of local trigger structures within this regional structure.
Bool_t fScalerEvent
! flag to generates scaler event