]> git.uio.no Git - u/mrichter/AliRoot.git/blame - MUON/AliMUONTriggerUtilities.cxx
Update from Alberica. Addition of VZERO equalized signals and ZNC.
[u/mrichter/AliRoot.git] / MUON / AliMUONTriggerUtilities.cxx
CommitLineData
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
46ClassImp(AliMUONTriggerUtilities)
47/// \endcond
48
49
50//_____________________________________________________________________________
51AliMUONTriggerUtilities::AliMUONTriggerUtilities(AliMUONCalibrationData* calibData):
52TObject(),
53fCalibrationData(calibData),
0a2dcc83 54fTriggerStatusMap(2*AliMUONConstants::NTriggerCh()*AliMUONConstants::NTriggerCircuit()),
55fMaskedDigitsStore(new AliMUONDigitStoreV2R())
d5315275 56{
57 /// Ctor.
58 Init();
59}
60
61//_____________________________________________________________________________
62AliMUONTriggerUtilities::~AliMUONTriggerUtilities()
63{
64 /// Destructor. Note we're the owner of some pointers.
0a2dcc83 65 delete fMaskedDigitsStore;
d5315275 66}
67
68
69//_____________________________________________________________________________
70Bool_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
78// // In the trigger logic, when the regional input is masked in the
79 TArrayI activeBoards(AliMUONConstants::NTriggerCircuit());
80// for (Int_t iSide = 0; iSide < 2; iSide++) // right & left side
81// {
82// UInt_t currMaskLpt = fCalibrationData->GlobalTriggerCrateConfig()->GetGlobalMask(iSide);
83// UInt_t currMaskHpt = fCalibrationData->GlobalTriggerCrateConfig()->GetGlobalMask(2+iSide);
84// for (Int_t iReg = 0; iReg < 8; iReg++) // 8 crates/regional boards for each side.
85// {
86// Bool_t isActiveLpt = ( currMaskLpt >> (4*iReg) ) & 0xF;
87// Bool_t isActiveHpt = ( currMaskHpt >> (4*iReg) ) & 0xF;
88// if ( ! isActiveLpt && ! isActiveHpt ) continue;
89// AliMUONTriggerCrate* cr = trigElectronics.GetCrateStore()->Crate(iSide, iReg);
90// TObjArray *boards = cr->Boards();
91//
92// for ( Int_t iboard = 1; iboard < boards->GetEntries(); iboard++)
93// {
94// TObject* currBoard = boards->At(iboard);
95//
96// if ( ! currBoard ) break;
97// Int_t idx = static_cast<AliMUONLocalTriggerBoard*>(currBoard)->GetNumber()-1;
98// if ( idx < 0 ) continue; // Some boards of crates 2 and 3 do not exist, but they are still in the board list
99// activeBoards[idx] = 1;
100// } // loop on boards in crate
101// } // loop on regional
102// } // loop on side
0a2dcc83 103
104 TArrayS xyPatternAll[2];
105 for(Int_t icath=0; icath<AliMpConstants::NofCathodes(); icath++){
106 xyPatternAll[icath].Set(AliMpConstants::NofTriggerChambers());
107 xyPatternAll[icath].Reset(0xFFFF);
108 }
109
110 // Create a store with all digits in trigger
111 for ( Int_t iboard=1; iboard<=AliMpConstants::NofLocalBoards(); iboard++ ) {
112 digitMaker.TriggerDigits(iboard, xyPatternAll, digitStore, kFALSE);
1c9a6054 113
114 // For each local board, fill all the strips and check the global output:
115 // if the board is masked at the global level, the output will be 0
116 digitStorePart.Clear();
117 digitMaker.TriggerDigits(iboard, xyPatternAll, digitStorePart, kFALSE);
118 triggerStorePart.Clear();
119 trigElectronics.Digits2Trigger(digitStorePart, triggerStorePart);
120 AliMUONGlobalTrigger* globalTrig = triggerStorePart.Global();
121 if ( globalTrig->GetGlobalResponse() > 0 ) activeBoards[iboard-1] = 1;
0a2dcc83 122 }
123
124 // Create trigger with electronics (it applies masks)
125 trigElectronics.Digits2Trigger(digitStore, triggerStore);
d5315275 126
0a2dcc83 127 // Re-compute digits from triggerStore
128 // Since the masks were applied in the response,
129 // the new store do not contain masked channels
130 AliMUONDigitStoreV2R digitStoreMasked;
131 digitMaker.TriggerToDigitsStore(triggerStore, digitStoreMasked);
d5315275 132
0a2dcc83 133 // Loop on non-masked digit store
134 // Search for digits in the masked one:
135 // if digit is not found, it means it was masked
136 TIter next(digitStore.CreateIterator());
137 AliMUONVDigit* dig = 0x0;
138 while ( ( dig = static_cast<AliMUONVDigit*>(next()) ) ) {
139 Int_t cath = dig->Cathode();
140 Int_t detElemId = dig->DetElemId();
141 Int_t board = dig->ManuId();
142 Int_t strip = dig->ManuChannel();
1c9a6054 143 AliMUONVDigit* currDigit = 0x0;
144 if ( activeBoards[board-1] == 1 ) currDigit = digitStoreMasked.FindObject(detElemId, board, strip, cath);
0a2dcc83 145 Bool_t isMasked = ( currDigit ) ? kFALSE : kTRUE;
146 if ( isMasked ) fMaskedDigitsStore->Add(*((AliMUONVDigit*)dig->Clone()), AliMUONVDigitStore::kDeny);
147 else {
148 Int_t ich = detElemId/100-11;
149 const AliMpVSegmentation* seg = AliMpSegmentation::Instance()->GetMpSegmentation(detElemId, AliMp::GetCathodType(cath));
150 AliMpPad pad = seg->PadByIndices(dig->PadX(), dig->PadY(), kTRUE);
151 for (Int_t iloc=0; iloc<pad.GetNofLocations(); iloc++) {
152 Int_t currBoard = pad.GetLocalBoardId(iloc);
153 Int_t arrayIndex = GetArrayIndex(cath, ich, currBoard);
154 fTriggerStatusMap[arrayIndex] |= ( 0x1 << strip );
155 } // loop on locations (in bending plane we have to fill all copy boards)
156 }
157 }
158
159// AliMUONTriggerCrateStore crates;
160// crates.ReadFromFile(fCalibrationData);
161//
162// AliMUONRegionalTriggerConfig* regionalConfig = fCalibrationData->RegionalTriggerConfig();
163// if ( ! regionalConfig ) AliFatal("no valid regional trigger configuration in CDB\n");
164//
165// // Loop on crates
166// AliMUONTriggerCrate* cr = 0x0;
167// TIter next ( crates.CreateCrateIterator() );
168// while ( ( cr = static_cast<AliMUONTriggerCrate*>(next()) ) ) {
169// TObjArray *boards = cr->Boards();
170//
171// AliMUONTriggerCrateConfig* crateConfig = regionalConfig->FindTriggerCrate(cr->GetName());
172//
173// if ( ! crateConfig ) AliFatal(Form("Crate %s not present in configuration !!!\n", cr->GetName()));
174//
175// UShort_t regionalMask = crateConfig->GetMask();
176//
177// // Loop on boards
178// for (Int_t iboard = 1; iboard < boards->GetEntries(); iboard++ ) {
179// Bool_t activeBoard = ( ( regionalMask >> ( iboard - 1) ) & 1 );
180// AliMUONLocalTriggerBoard* board = (AliMUONLocalTriggerBoard*)boards->At(iboard);
181// Int_t cardNumber = board->GetNumber();
182// if ( cardNumber <= 0 ) continue; // interface board are not interested
183// AliMUONVCalibParam* localBoardMask = fCalibrationData->LocalTriggerBoardMasks(cardNumber);
184// for ( Int_t icath = 0; icath < 2; ++icath ) {
185// for ( Int_t ich = 0; ich < 4; ++ich ) {
186// Int_t planeIndex = icath * 4 + ich;
187// Int_t localMask = ( activeBoard ) ? localBoardMask->ValueAsInt(planeIndex) : 0;
188// Int_t arrayIndex = GetArrayIndex(icath, ich, cardNumber);
189// fTriggerStatusMap[arrayIndex] = localMask;
190// } // loop on chambers
191// } // loop on planes
192// } // loop on boards
193// } // loop on crates
d5315275 194
195 return kTRUE;
196}
197
198//_____________________________________________________________________________
199Bool_t AliMUONTriggerUtilities::IsMasked(const AliMUONVDigit& digit) const
200{
0a2dcc83 201 /// Check if pad is masked
202 return IsMasked(digit.DetElemId(), digit.Cathode(), digit.ManuId(), digit.ManuChannel());
d5315275 203}
204
205
206//_____________________________________________________________________________
207Bool_t AliMUONTriggerUtilities::IsMasked(const AliMpPad& pad, Int_t detElemId, Int_t cathode) const
0a2dcc83 208{
209 /// Check if pad is masked
210 return IsMasked(detElemId, cathode, pad.GetLocalBoardId(0), pad.GetLocalBoardChannel(0));
211}
212
213
214//_____________________________________________________________________________
215Bool_t AliMUONTriggerUtilities::IsMasked(Int_t detElemId, Int_t cathode, Int_t localCircuit, Int_t strip) const
d5315275 216{
217 /// Check if pad is masked
d5315275 218 Int_t trigCh = detElemId/100 - 11;
219
0a2dcc83 220// Int_t ibitxy = strip;
221// AliMpLocalBoard* localBoard = AliMpDDLStore::Instance()->GetLocalBoard(localCircuit);
222// if ( cathode && localBoard->GetSwitch(AliMpLocalBoard::kZeroAllYLSB) ) ibitxy += 8;
d5315275 223 Int_t arrayIndex = GetArrayIndex(cathode, trigCh, localCircuit);
0a2dcc83 224 Bool_t isMasked = ( ( ( fTriggerStatusMap[arrayIndex] >> strip ) & 0x1 ) == 0 );
225 AliDebug(1,Form("detElemId %i cath %i board %i strip %i is active %i\n", detElemId, cathode, localCircuit, strip, ! isMasked));
226 return isMasked;
d5315275 227}
228
1c9a6054 229//_____________________________________________________________________________
230Bool_t AliMUONTriggerUtilities::IsMaskedBoard ( Int_t localCircuit, Int_t detElemId, Int_t cathode ) const
231{
232 /// Check if board is masked
233 Int_t trigCh = detElemId/100-11;
234 Int_t arrayIndex = GetArrayIndex(cathode, trigCh, localCircuit);
235 return ( fTriggerStatusMap[arrayIndex] == 0 );
236}
237
238
d5315275 239
240//_____________________________________________________________________________
241Int_t AliMUONTriggerUtilities::GetArrayIndex(Int_t cathode, Int_t trigCh, Int_t localCircuit) const
242{
243 /// Get index of array with trigger status map or efficiency
244 return
245 AliMUONConstants::NTriggerCircuit() * AliMUONConstants::NTriggerCh() * cathode +
246 AliMUONConstants::NTriggerCircuit() * trigCh + localCircuit-1;
247}