AliRoot Core  edcc906 (edcc906)
AliMUONTriggerUtilities.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 
18 
19 #include "TArrayS.h"
20 
21 #include "AliLog.h"
22 
23 #include "AliMUONCalibrationData.h"
24 //#include "AliMUONTriggerCrateStore.h"
25 //#include "AliMUONTriggerCrate.h"
26 //#include "AliMUONGlobalCrateConfig.h"
27 //#include "AliMUONVCalibParam.h"
28 //#include "AliMUONRegionalTriggerConfig.h"
29 #include "AliMUONGlobalTrigger.h"
31 #include "AliMUONVDigit.h"
32 #include "AliMUONConstants.h"
34 #include "AliMUONDigitStoreV2R.h"
35 #include "AliMUONDigitMaker.h"
36 #include "AliMUONTriggerStoreV1.h"
37 
38 #include "AliMpDDLStore.h"
39 #include "AliMpPad.h"
40 //#include "AliMpLocalBoard.h"
41 #include "AliMpConstants.h"
42 #include "AliMpVSegmentation.h"
43 #include "AliMpSegmentation.h"
44 
48 
49 
50 //_____________________________________________________________________________
52 TObject(),
53 fCalibrationData(calibData),
54 fTriggerStatusMap(2*AliMUONConstants::NTriggerCh()*AliMUONConstants::NTriggerCircuit()),
55 fMaskedDigitsStore(new AliMUONDigitStoreV2R())
56 {
58  Init();
59 }
60 
61 //_____________________________________________________________________________
63 {
65  delete fMaskedDigitsStore;
66 }
67 
68 
69 //_____________________________________________________________________________
71 {
74  AliMUONDigitMaker digitMaker(kFALSE);
75  AliMUONDigitStoreV2R digitStore, digitStorePart;
76  AliMUONTriggerStoreV1 triggerStore, triggerStorePart;
77 
78  TArrayI activeBoards(AliMUONConstants::NTriggerCircuit());
79 // for (Int_t iSide = 0; iSide < 2; iSide++) // right & left side
80 // {
81 // UInt_t currMaskLpt = fCalibrationData->GlobalTriggerCrateConfig()->GetGlobalMask(iSide);
82 // UInt_t currMaskHpt = fCalibrationData->GlobalTriggerCrateConfig()->GetGlobalMask(2+iSide);
83 // for (Int_t iReg = 0; iReg < 8; iReg++) // 8 crates/regional boards for each side.
84 // {
85 // Bool_t isActiveLpt = ( currMaskLpt >> (4*iReg) ) & 0xF;
86 // Bool_t isActiveHpt = ( currMaskHpt >> (4*iReg) ) & 0xF;
87 // if ( ! isActiveLpt && ! isActiveHpt ) continue;
88 // AliMUONTriggerCrate* cr = trigElectronics.GetCrateStore()->Crate(iSide, iReg);
89 // TObjArray *boards = cr->Boards();
90 //
91 // for ( Int_t iboard = 1; iboard < boards->GetEntries(); iboard++)
92 // {
93 // TObject* currBoard = boards->At(iboard);
94 //
95 // if ( ! currBoard ) break;
96 // Int_t idx = static_cast<AliMUONLocalTriggerBoard*>(currBoard)->GetNumber()-1;
97 // if ( idx < 0 ) continue; // Some boards of crates 2 and 3 do not exist, but they are still in the board list
98 // activeBoards[idx] = 1;
99 // } // loop on boards in crate
100 // } // loop on regional
101 // } // loop on side
102 
103  TArrayS xyPatternAll[2];
104  for(Int_t icath=0; icath<AliMpConstants::NofCathodes(); icath++){
105  xyPatternAll[icath].Set(AliMpConstants::NofTriggerChambers());
106  xyPatternAll[icath].Reset(0xFFFF);
107  }
108 
109  // Create a store with all digits in trigger
110  for ( Int_t iboard=1; iboard<=AliMpConstants::NofLocalBoards(); iboard++ ) {
111  digitMaker.TriggerDigits(iboard, xyPatternAll, digitStore, kFALSE);
112 
113  // For each local board, fill all the strips and check the global output:
114  // if the board is masked at the global level, the output will be 0
115  digitStorePart.Clear();
116  digitMaker.TriggerDigits(iboard, xyPatternAll, digitStorePart, kFALSE);
117  triggerStorePart.Clear();
118  trigElectronics.Digits2Trigger(digitStorePart, triggerStorePart);
119  AliMUONGlobalTrigger* globalTrig = triggerStorePart.Global();
120  if ( globalTrig->GetGlobalResponse() > 0 ) activeBoards[iboard-1] = 1;
121  }
122 
123  // Create trigger with electronics (it applies masks)
124  trigElectronics.Digits2Trigger(digitStore, triggerStore);
125 
126  // Re-compute digits from triggerStore
127  // Since the masks were applied in the response,
128  // the new store do not contain masked channels
129  AliMUONDigitStoreV2R digitStoreMasked;
130  digitMaker.TriggerToDigitsStore(triggerStore, digitStoreMasked);
131 
132  // Loop on non-masked digit store
133  // Search for digits in the masked one:
134  // if digit is not found, it means it was masked
135  TIter next(digitStore.CreateIterator());
136  AliMUONVDigit* dig = 0x0;
137  while ( ( dig = static_cast<AliMUONVDigit*>(next()) ) ) {
138  Int_t cath = dig->Cathode();
139  Int_t detElemId = dig->DetElemId();
140  Int_t board = dig->ManuId();
141  Int_t strip = dig->ManuChannel();
142  AliMUONVDigit* currDigit = digitStoreMasked.FindObject(detElemId, board, strip, cath);
143  Int_t ich = detElemId/100-11;
145  AliMpPad pad = seg->PadByIndices(dig->PadX(), dig->PadY(), kTRUE);
146  Bool_t isMasked = ( currDigit ) ? kFALSE : kTRUE;
147 
148  if ( currDigit ) {
149  // Check if board is active
150  // For the non-bending plane the digit is created for the first board only
151  // The first board may be masked, but there may be some boards which are not.
152  // If so, the strip won't be masked, so we should keep it
153  Bool_t allBoardsMasked = kTRUE;
154  for (Int_t iloc=0; iloc<pad.GetNofLocations(); iloc++) {
155  Int_t currBoard = pad.GetLocalBoardId(iloc);
156  if ( activeBoards[currBoard-1] == 1 ) {
157  allBoardsMasked = kFALSE;
158  break;
159  }
160  }
161  isMasked = allBoardsMasked;
162  }
163 
164  if ( isMasked ) fMaskedDigitsStore->Add(*((AliMUONVDigit*)dig->Clone()), AliMUONVDigitStore::kDeny);
165  else {
166  for (Int_t iloc=0; iloc<pad.GetNofLocations(); iloc++) {
167  Int_t currBoard = pad.GetLocalBoardId(iloc);
168  Int_t arrayIndex = GetArrayIndex(cath, ich, currBoard);
169  fTriggerStatusMap[arrayIndex] |= ( 0x1 << strip );
170  } // loop on locations (in bending plane we have to fill all copy boards)
171  }
172  }
173 
174 // AliMUONTriggerCrateStore crates;
175 // crates.ReadFromFile(fCalibrationData);
176 //
177 // AliMUONRegionalTriggerConfig* regionalConfig = fCalibrationData->RegionalTriggerConfig();
178 // if ( ! regionalConfig ) AliFatal("no valid regional trigger configuration in CDB\n");
179 //
180 // // Loop on crates
181 // AliMUONTriggerCrate* cr = 0x0;
182 // TIter next ( crates.CreateCrateIterator() );
183 // while ( ( cr = static_cast<AliMUONTriggerCrate*>(next()) ) ) {
184 // TObjArray *boards = cr->Boards();
185 //
186 // AliMUONTriggerCrateConfig* crateConfig = regionalConfig->FindTriggerCrate(cr->GetName());
187 //
188 // if ( ! crateConfig ) AliFatal(Form("Crate %s not present in configuration !!!\n", cr->GetName()));
189 //
190 // UShort_t regionalMask = crateConfig->GetMask();
191 //
192 // // Loop on boards
193 // for (Int_t iboard = 1; iboard < boards->GetEntries(); iboard++ ) {
194 // Bool_t activeBoard = ( ( regionalMask >> ( iboard - 1) ) & 1 );
195 // AliMUONLocalTriggerBoard* board = (AliMUONLocalTriggerBoard*)boards->At(iboard);
196 // Int_t cardNumber = board->GetNumber();
197 // if ( cardNumber <= 0 ) continue; // interface board are not interested
198 // AliMUONVCalibParam* localBoardMask = fCalibrationData->LocalTriggerBoardMasks(cardNumber);
199 // for ( Int_t icath = 0; icath < 2; ++icath ) {
200 // for ( Int_t ich = 0; ich < 4; ++ich ) {
201 // Int_t planeIndex = icath * 4 + ich;
202 // Int_t localMask = ( activeBoard ) ? localBoardMask->ValueAsInt(planeIndex) : 0;
203 // Int_t arrayIndex = GetArrayIndex(icath, ich, cardNumber);
204 // fTriggerStatusMap[arrayIndex] = localMask;
205 // } // loop on chambers
206 // } // loop on planes
207 // } // loop on boards
208 // } // loop on crates
209 
210  return kTRUE;
211 }
212 
213 //_____________________________________________________________________________
215 {
217  return IsMasked(digit.DetElemId(), digit.Cathode(), digit.ManuId(), digit.ManuChannel());
218 }
219 
220 
221 //_____________________________________________________________________________
222 Bool_t AliMUONTriggerUtilities::IsMasked(const AliMpPad& pad, Int_t detElemId, Int_t cathode) const
223 {
225  return IsMasked(detElemId, cathode, pad.GetLocalBoardId(0), pad.GetLocalBoardChannel(0));
226 }
227 
228 
229 //_____________________________________________________________________________
230 Bool_t AliMUONTriggerUtilities::IsMasked(Int_t detElemId, Int_t cathode, Int_t localCircuit, Int_t strip) const
231 {
233  Int_t trigCh = detElemId/100 - 11;
234 
235 // Int_t ibitxy = strip;
236 // AliMpLocalBoard* localBoard = AliMpDDLStore::Instance()->GetLocalBoard(localCircuit);
237 // if ( cathode && localBoard->GetSwitch(AliMpLocalBoard::kZeroAllYLSB) ) ibitxy += 8;
238  Int_t arrayIndex = GetArrayIndex(cathode, trigCh, localCircuit);
239  Bool_t isMasked = ( ( ( fTriggerStatusMap[arrayIndex] >> strip ) & 0x1 ) == 0 );
240  AliDebug(1,Form("detElemId %i cath %i board %i strip %i is active %i\n", detElemId, cathode, localCircuit, strip, ! isMasked));
241  return isMasked;
242 }
243 
244 //_____________________________________________________________________________
245 Bool_t AliMUONTriggerUtilities::IsMaskedBoard ( Int_t localCircuit, Int_t detElemId, Int_t cathode ) const
246 {
248  Int_t trigCh = detElemId/100-11;
249  Int_t arrayIndex = GetArrayIndex(cathode, trigCh, localCircuit);
250  return ( fTriggerStatusMap[arrayIndex] == 0 );
251 }
252 
253 
254 
255 //_____________________________________________________________________________
256 Int_t AliMUONTriggerUtilities::GetArrayIndex(Int_t cathode, Int_t trigCh, Int_t localCircuit) const
257 {
259  return
261  AliMUONConstants::NTriggerCircuit() * trigCh + localCircuit-1;
262 }
Int_t GetNofLocations() const
Definition: AliMpPad.cxx:325
virtual Int_t ManuChannel() const =0
The channel within ManuId() this digit belongs to (manuChannel for tracker, localBoardChannel for tri...
Reading Raw data class for trigger and tracker chambers.
const AliMpVSegmentation * GetMpSegmentation(Int_t detElemId, AliMp::CathodType cath, Bool_t warn=true) const
Implementation of AliMUONVTriggerStore.
static AliMpSegmentation * Instance(Bool_t warn=true)
Concrete implementation of AliMUONVDigitStore for real digits.
AliRunLoader * Init()
Int_t TriggerDigits(Int_t nBoard, const TArrayS *xyPattern, AliMUONVDigitStore &digitStore, Bool_t warn=kTRUE) const
virtual void Clear(Option_t *opt="")
Clear ourselves (i.e. Reset)
TArrayI fTriggerStatusMap
! Trigger masks
Utilities for trigger (check if pad is masked)
static Int_t NofLocalBoards()
Return number of trigger local boards.
virtual AliMpPad PadByIndices(Int_t ix, Int_t iy, Bool_t warning=true) const =0
Find pad by indices.
virtual Int_t DetElemId() const =0
The detection element this digit belongs to.
Int_t GetArrayIndex(Int_t cathode, Int_t trigCh, Int_t localCircuit) const
Manager class for muon trigger electronics.
static Int_t NofCathodes()
Return number of cathodes.
virtual Int_t Cathode() const =0
Cathode number this digit is on (0 or 1)
Bool_t IsMasked(const AliMUONVDigit &digit) const
MUON global constants.
virtual TIterator * CreateIterator() const
Create an iterator to loop over all our digits.
virtual AliMUONGlobalTrigger * Global() const
Return global trigger.
AliMp::CathodType GetCathodType(Int_t cathodNumber)
Convert integer number in enum;.
static Int_t NTriggerCh()
Return number of trigger chambers.
Int_t GetLocalBoardId(Int_t i) const
Definition: AliMpPad.cxx:347
AliMUONVDigitStore * fMaskedDigitsStore
! Masked digits store
AliMUONCalibrationData * calibData
Bool_t IsMaskedBoard(Int_t localCircuit, Int_t detElemId=1100, Int_t cathode=0) const
#define AliDebug(logLevel, message)
Definition: AliLog.h:300
Single entry point to access MUON calibration data.
AliMUONCalibrationData * fCalibrationData
! pointer to access calib parameters
The abstract base class for the segmentation.
UChar_t GetGlobalResponse() const
virtual AliMUONVDigit * FindObject(UInt_t uniqueID) const
Find an object by its uniqueID.
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
Class which encapsuate all information about a pad.
Definition: AliMpPad.h:22
virtual void Clear(Option_t *opt="")
Clear ourselves (i.e. Reset)
Bool_t TriggerToDigitsStore(const AliMUONVTriggerStore &triggerStore, AliMUONVDigitStore &digitStore) const
virtual void Digits2Trigger(const AliMUONVDigitStore &digitStore, AliMUONVTriggerStore &triggerStore)
static Int_t NTriggerCircuit()
Return number of trigger circuits.
Int_t GetLocalBoardChannel(Int_t i) const
Definition: AliMpPad.cxx:358
virtual Bool_t Add(TObject *object)
Add an object, if it is of the right class.
static Int_t NofTriggerChambers()