Line data Source code
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 :
17 : #include "AliMUONTriggerUtilities.h"
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"
30 : #include "AliMUONLocalTriggerBoard.h"
31 : #include "AliMUONVDigit.h"
32 : #include "AliMUONConstants.h"
33 : #include "AliMUONTriggerElectronics.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 :
45 : /// \cond CLASSIMP
46 18 : ClassImp(AliMUONTriggerUtilities)
47 : /// \endcond
48 :
49 :
50 : //_____________________________________________________________________________
51 : AliMUONTriggerUtilities::AliMUONTriggerUtilities(AliMUONCalibrationData* calibData):
52 3 : TObject(),
53 3 : fCalibrationData(calibData),
54 6 : fTriggerStatusMap(2*AliMUONConstants::NTriggerCh()*AliMUONConstants::NTriggerCircuit()),
55 9 : fMaskedDigitsStore(new AliMUONDigitStoreV2R())
56 15 : {
57 : /// Ctor.
58 3 : Init();
59 6 : }
60 :
61 : //_____________________________________________________________________________
62 : AliMUONTriggerUtilities::~AliMUONTriggerUtilities()
63 18 : {
64 : /// Destructor. Note we're the owner of some pointers.
65 6 : delete fMaskedDigitsStore;
66 9 : }
67 :
68 :
69 : //_____________________________________________________________________________
70 : Bool_t AliMUONTriggerUtilities::Init()
71 : {
72 : /// Build trigger status map from masks
73 6 : AliMUONTriggerElectronics trigElectronics(fCalibrationData);
74 3 : AliMUONDigitMaker digitMaker(kFALSE);
75 6 : AliMUONDigitStoreV2R digitStore, digitStorePart;
76 6 : AliMUONTriggerStoreV1 triggerStore, triggerStorePart;
77 :
78 3 : 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 15 : TArrayS xyPatternAll[2];
104 18 : for(Int_t icath=0; icath<AliMpConstants::NofCathodes(); icath++){
105 12 : xyPatternAll[icath].Set(AliMpConstants::NofTriggerChambers());
106 6 : xyPatternAll[icath].Reset(0xFFFF);
107 : }
108 :
109 : // Create a store with all digits in trigger
110 1410 : for ( Int_t iboard=1; iboard<=AliMpConstants::NofLocalBoards(); iboard++ ) {
111 702 : 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 702 : digitStorePart.Clear();
116 702 : digitMaker.TriggerDigits(iboard, xyPatternAll, digitStorePart, kFALSE);
117 702 : triggerStorePart.Clear();
118 702 : trigElectronics.Digits2Trigger(digitStorePart, triggerStorePart);
119 702 : AliMUONGlobalTrigger* globalTrig = triggerStorePart.Global();
120 2808 : if ( globalTrig->GetGlobalResponse() > 0 ) activeBoards[iboard-1] = 1;
121 : }
122 :
123 : // Create trigger with electronics (it applies masks)
124 3 : 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 3 : AliMUONDigitStoreV2R digitStoreMasked;
130 3 : 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 6 : TIter next(digitStore.CreateIterator());
136 : AliMUONVDigit* dig = 0x0;
137 188937 : while ( ( dig = static_cast<AliMUONVDigit*>(next()) ) ) {
138 62976 : Int_t cath = dig->Cathode();
139 62976 : Int_t detElemId = dig->DetElemId();
140 62976 : Int_t board = dig->ManuId();
141 62976 : Int_t strip = dig->ManuChannel();
142 62976 : AliMUONVDigit* currDigit = digitStoreMasked.FindObject(detElemId, board, strip, cath);
143 62976 : Int_t ich = detElemId/100-11;
144 188928 : const AliMpVSegmentation* seg = AliMpSegmentation::Instance()->GetMpSegmentation(detElemId, AliMp::GetCathodType(cath));
145 188928 : AliMpPad pad = seg->PadByIndices(dig->PadX(), dig->PadY(), kTRUE);
146 62976 : Bool_t isMasked = ( currDigit ) ? kFALSE : kTRUE;
147 :
148 62976 : 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 188928 : for (Int_t iloc=0; iloc<pad.GetNofLocations(); iloc++) {
155 62976 : Int_t currBoard = pad.GetLocalBoardId(iloc);
156 125952 : if ( activeBoards[currBoard-1] == 1 ) {
157 : allBoardsMasked = kFALSE;
158 62976 : break;
159 : }
160 0 : }
161 62976 : isMasked = allBoardsMasked;
162 62976 : }
163 :
164 62976 : if ( isMasked ) fMaskedDigitsStore->Add(*((AliMUONVDigit*)dig->Clone()), AliMUONVDigitStore::kDeny);
165 : else {
166 429696 : for (Int_t iloc=0; iloc<pad.GetNofLocations(); iloc++) {
167 80256 : Int_t currBoard = pad.GetLocalBoardId(iloc);
168 80256 : Int_t arrayIndex = GetArrayIndex(cath, ich, currBoard);
169 160512 : fTriggerStatusMap[arrayIndex] |= ( 0x1 << strip );
170 : } // loop on locations (in bending plane we have to fill all copy boards)
171 : }
172 62976 : }
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 12 : }
212 :
213 : //_____________________________________________________________________________
214 : Bool_t AliMUONTriggerUtilities::IsMasked(const AliMUONVDigit& digit) const
215 : {
216 : /// Check if pad is masked
217 224 : 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 : {
224 : /// Check if pad is masked
225 0 : 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 : {
232 : /// Check if pad is masked
233 224 : 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 112 : Int_t arrayIndex = GetArrayIndex(cathode, trigCh, localCircuit);
239 112 : Bool_t isMasked = ( ( ( fTriggerStatusMap[arrayIndex] >> strip ) & 0x1 ) == 0 );
240 336 : AliDebug(1,Form("detElemId %i cath %i board %i strip %i is active %i\n", detElemId, cathode, localCircuit, strip, ! isMasked));
241 112 : return isMasked;
242 : }
243 :
244 : //_____________________________________________________________________________
245 : Bool_t AliMUONTriggerUtilities::IsMaskedBoard ( Int_t localCircuit, Int_t detElemId, Int_t cathode ) const
246 : {
247 : /// Check if board is masked
248 0 : Int_t trigCh = detElemId/100-11;
249 0 : Int_t arrayIndex = GetArrayIndex(cathode, trigCh, localCircuit);
250 0 : 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 : {
258 : /// Get index of array with trigger status map or efficiency
259 80368 : return
260 241104 : AliMUONConstants::NTriggerCircuit() * AliMUONConstants::NTriggerCh() * cathode +
261 160736 : AliMUONConstants::NTriggerCircuit() * trigCh + localCircuit-1;
262 : }
|