]>
Commit | Line | Data |
---|---|---|
d5315275 | 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 | ||
0a2dcc83 | 17 | #include "AliMUONTriggerUtilities.h" |
18 | ||
19 | #include "TArrayS.h" | |
20 | ||
d5315275 | 21 | #include "AliLog.h" |
22 | ||
23 | #include "AliMUONCalibrationData.h" | |
0a2dcc83 | 24 | //#include "AliMUONTriggerCrateStore.h" |
25 | //#include "AliMUONTriggerCrate.h" | |
1c9a6054 | 26 | //#include "AliMUONGlobalCrateConfig.h" |
0a2dcc83 | 27 | //#include "AliMUONVCalibParam.h" |
28 | //#include "AliMUONRegionalTriggerConfig.h" | |
1c9a6054 | 29 | #include "AliMUONGlobalTrigger.h" |
30 | #include "AliMUONLocalTriggerBoard.h" | |
d5315275 | 31 | #include "AliMUONVDigit.h" |
32 | #include "AliMUONConstants.h" | |
0a2dcc83 | 33 | #include "AliMUONTriggerElectronics.h" |
34 | #include "AliMUONDigitStoreV2R.h" | |
35 | #include "AliMUONDigitMaker.h" | |
36 | #include "AliMUONTriggerStoreV1.h" | |
d5315275 | 37 | |
38 | #include "AliMpDDLStore.h" | |
39 | #include "AliMpPad.h" | |
0a2dcc83 | 40 | //#include "AliMpLocalBoard.h" |
41 | #include "AliMpConstants.h" | |
42 | #include "AliMpVSegmentation.h" | |
43 | #include "AliMpSegmentation.h" | |
d5315275 | 44 | |
45 | /// \cond CLASSIMP | |
46 | ClassImp(AliMUONTriggerUtilities) | |
47 | /// \endcond | |
48 | ||
49 | ||
50 | //_____________________________________________________________________________ | |
51 | AliMUONTriggerUtilities::AliMUONTriggerUtilities(AliMUONCalibrationData* calibData): | |
52 | TObject(), | |
53 | fCalibrationData(calibData), | |
0a2dcc83 | 54 | fTriggerStatusMap(2*AliMUONConstants::NTriggerCh()*AliMUONConstants::NTriggerCircuit()), |
55 | fMaskedDigitsStore(new AliMUONDigitStoreV2R()) | |
d5315275 | 56 | { |
57 | /// Ctor. | |
58 | Init(); | |
59 | } | |
60 | ||
61 | //_____________________________________________________________________________ | |
62 | AliMUONTriggerUtilities::~AliMUONTriggerUtilities() | |
63 | { | |
64 | /// Destructor. Note we're the owner of some pointers. | |
0a2dcc83 | 65 | delete fMaskedDigitsStore; |
d5315275 | 66 | } |
67 | ||
68 | ||
69 | //_____________________________________________________________________________ | |
70 | Bool_t AliMUONTriggerUtilities::Init() | |
71 | { | |
72 | /// Build trigger status map from masks | |
0a2dcc83 | 73 | AliMUONTriggerElectronics trigElectronics(fCalibrationData); |
74 | AliMUONDigitMaker digitMaker(kFALSE); | |
1c9a6054 | 75 | AliMUONDigitStoreV2R digitStore, digitStorePart; |
76 | AliMUONTriggerStoreV1 triggerStore, triggerStorePart; | |
77 | ||
1c9a6054 | 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 | |
0a2dcc83 | 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); | |
1c9a6054 | 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; | |
0a2dcc83 | 121 | } |
122 | ||
123 | // Create trigger with electronics (it applies masks) | |
124 | trigElectronics.Digits2Trigger(digitStore, triggerStore); | |
d5315275 | 125 | |
0a2dcc83 | 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); | |
d5315275 | 131 | |
0a2dcc83 | 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(); | |
12549f10 VB |
142 | AliMUONVDigit* currDigit = digitStoreMasked.FindObject(detElemId, board, strip, cath); |
143 | Int_t ich = detElemId/100-11; | |
144 | const AliMpVSegmentation* seg = AliMpSegmentation::Instance()->GetMpSegmentation(detElemId, AliMp::GetCathodType(cath)); | |
145 | AliMpPad pad = seg->PadByIndices(dig->PadX(), dig->PadY(), kTRUE); | |
0a2dcc83 | 146 | Bool_t isMasked = ( currDigit ) ? kFALSE : kTRUE; |
12549f10 VB |
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 | ||
0a2dcc83 | 164 | if ( isMasked ) fMaskedDigitsStore->Add(*((AliMUONVDigit*)dig->Clone()), AliMUONVDigitStore::kDeny); |
165 | else { | |
0a2dcc83 | 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 | |
d5315275 | 209 | |
210 | return kTRUE; | |
211 | } | |
212 | ||
213 | //_____________________________________________________________________________ | |
214 | Bool_t AliMUONTriggerUtilities::IsMasked(const AliMUONVDigit& digit) const | |
215 | { | |
0a2dcc83 | 216 | /// Check if pad is masked |
217 | return IsMasked(digit.DetElemId(), digit.Cathode(), digit.ManuId(), digit.ManuChannel()); | |
d5315275 | 218 | } |
219 | ||
220 | ||
221 | //_____________________________________________________________________________ | |
222 | Bool_t AliMUONTriggerUtilities::IsMasked(const AliMpPad& pad, Int_t detElemId, Int_t cathode) const | |
0a2dcc83 | 223 | { |
224 | /// Check if pad is masked | |
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 | |
d5315275 | 231 | { |
232 | /// Check if pad is masked | |
d5315275 | 233 | Int_t trigCh = detElemId/100 - 11; |
234 | ||
0a2dcc83 | 235 | // Int_t ibitxy = strip; |
236 | // AliMpLocalBoard* localBoard = AliMpDDLStore::Instance()->GetLocalBoard(localCircuit); | |
237 | // if ( cathode && localBoard->GetSwitch(AliMpLocalBoard::kZeroAllYLSB) ) ibitxy += 8; | |
d5315275 | 238 | Int_t arrayIndex = GetArrayIndex(cathode, trigCh, localCircuit); |
0a2dcc83 | 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; | |
d5315275 | 242 | } |
243 | ||
1c9a6054 | 244 | //_____________________________________________________________________________ |
245 | Bool_t AliMUONTriggerUtilities::IsMaskedBoard ( Int_t localCircuit, Int_t detElemId, Int_t cathode ) const | |
246 | { | |
247 | /// Check if board is masked | |
248 | Int_t trigCh = detElemId/100-11; | |
249 | Int_t arrayIndex = GetArrayIndex(cathode, trigCh, localCircuit); | |
250 | return ( fTriggerStatusMap[arrayIndex] == 0 ); | |
251 | } | |
252 | ||
253 | ||
d5315275 | 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 | return | |
260 | AliMUONConstants::NTriggerCircuit() * AliMUONConstants::NTriggerCh() * cathode + | |
261 | AliMUONConstants::NTriggerCircuit() * trigCh + localCircuit-1; | |
262 | } |