1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
17 #include "AliMUONTriggerUtilities.h"
23 #include "AliMUONCalibrationData.h"
24 //#include "AliMUONTriggerCrateStore.h"
25 //#include "AliMUONTriggerCrate.h"
26 //#include "AliMUONTriggerCrateConfig.h"
27 //#include "AliMUONVCalibParam.h"
28 //#include "AliMUONRegionalTriggerConfig.h"
29 //#include "AliMUONLocalTriggerBoard.h"
30 #include "AliMUONVDigit.h"
31 #include "AliMUONConstants.h"
32 #include "AliMUONTriggerElectronics.h"
33 #include "AliMUONDigitStoreV2R.h"
34 #include "AliMUONDigitMaker.h"
35 #include "AliMUONTriggerStoreV1.h"
37 #include "AliMpDDLStore.h"
39 //#include "AliMpLocalBoard.h"
40 #include "AliMpConstants.h"
41 #include "AliMpVSegmentation.h"
42 #include "AliMpSegmentation.h"
45 ClassImp(AliMUONTriggerUtilities)
49 //_____________________________________________________________________________
50 AliMUONTriggerUtilities::AliMUONTriggerUtilities(AliMUONCalibrationData* calibData):
52 fCalibrationData(calibData),
53 fTriggerStatusMap(2*AliMUONConstants::NTriggerCh()*AliMUONConstants::NTriggerCircuit()),
54 fMaskedDigitsStore(new AliMUONDigitStoreV2R())
60 //_____________________________________________________________________________
61 AliMUONTriggerUtilities::~AliMUONTriggerUtilities()
63 /// Destructor. Note we're the owner of some pointers.
64 delete fMaskedDigitsStore;
68 //_____________________________________________________________________________
69 Bool_t AliMUONTriggerUtilities::Init()
71 /// Build trigger status map from masks
72 AliMUONTriggerElectronics trigElectronics(fCalibrationData);
73 AliMUONDigitMaker digitMaker(kFALSE);
74 AliMUONDigitStoreV2R digitStore;
75 AliMUONTriggerStoreV1 triggerStore;
77 TArrayS xyPatternAll[2];
78 for(Int_t icath=0; icath<AliMpConstants::NofCathodes(); icath++){
79 xyPatternAll[icath].Set(AliMpConstants::NofTriggerChambers());
80 xyPatternAll[icath].Reset(0xFFFF);
83 // Create a store with all digits in trigger
84 for ( Int_t iboard=1; iboard<=AliMpConstants::NofLocalBoards(); iboard++ ) {
85 digitMaker.TriggerDigits(iboard, xyPatternAll, digitStore, kFALSE);
88 // Create trigger with electronics (it applies masks)
89 trigElectronics.Digits2Trigger(digitStore, triggerStore);
91 // Re-compute digits from triggerStore
92 // Since the masks were applied in the response,
93 // the new store do not contain masked channels
94 AliMUONDigitStoreV2R digitStoreMasked;
95 digitMaker.TriggerToDigitsStore(triggerStore, digitStoreMasked);
97 // Loop on non-masked digit store
98 // Search for digits in the masked one:
99 // if digit is not found, it means it was masked
100 TIter next(digitStore.CreateIterator());
101 AliMUONVDigit* dig = 0x0;
102 while ( ( dig = static_cast<AliMUONVDigit*>(next()) ) ) {
103 Int_t cath = dig->Cathode();
104 Int_t detElemId = dig->DetElemId();
105 Int_t board = dig->ManuId();
106 Int_t strip = dig->ManuChannel();
107 AliMUONVDigit* currDigit = digitStoreMasked.FindObject(detElemId, board, strip, cath);
108 Bool_t isMasked = ( currDigit ) ? kFALSE : kTRUE;
109 if ( isMasked ) fMaskedDigitsStore->Add(*((AliMUONVDigit*)dig->Clone()), AliMUONVDigitStore::kDeny);
111 Int_t ich = detElemId/100-11;
112 const AliMpVSegmentation* seg = AliMpSegmentation::Instance()->GetMpSegmentation(detElemId, AliMp::GetCathodType(cath));
113 AliMpPad pad = seg->PadByIndices(dig->PadX(), dig->PadY(), kTRUE);
114 for (Int_t iloc=0; iloc<pad.GetNofLocations(); iloc++) {
115 Int_t currBoard = pad.GetLocalBoardId(iloc);
116 Int_t arrayIndex = GetArrayIndex(cath, ich, currBoard);
117 fTriggerStatusMap[arrayIndex] |= ( 0x1 << strip );
118 } // loop on locations (in bending plane we have to fill all copy boards)
122 // AliMUONTriggerCrateStore crates;
123 // crates.ReadFromFile(fCalibrationData);
125 // AliMUONRegionalTriggerConfig* regionalConfig = fCalibrationData->RegionalTriggerConfig();
126 // if ( ! regionalConfig ) AliFatal("no valid regional trigger configuration in CDB\n");
129 // AliMUONTriggerCrate* cr = 0x0;
130 // TIter next ( crates.CreateCrateIterator() );
131 // while ( ( cr = static_cast<AliMUONTriggerCrate*>(next()) ) ) {
132 // TObjArray *boards = cr->Boards();
134 // AliMUONTriggerCrateConfig* crateConfig = regionalConfig->FindTriggerCrate(cr->GetName());
136 // if ( ! crateConfig ) AliFatal(Form("Crate %s not present in configuration !!!\n", cr->GetName()));
138 // UShort_t regionalMask = crateConfig->GetMask();
141 // for (Int_t iboard = 1; iboard < boards->GetEntries(); iboard++ ) {
142 // Bool_t activeBoard = ( ( regionalMask >> ( iboard - 1) ) & 1 );
143 // AliMUONLocalTriggerBoard* board = (AliMUONLocalTriggerBoard*)boards->At(iboard);
144 // Int_t cardNumber = board->GetNumber();
145 // if ( cardNumber <= 0 ) continue; // interface board are not interested
146 // AliMUONVCalibParam* localBoardMask = fCalibrationData->LocalTriggerBoardMasks(cardNumber);
147 // for ( Int_t icath = 0; icath < 2; ++icath ) {
148 // for ( Int_t ich = 0; ich < 4; ++ich ) {
149 // Int_t planeIndex = icath * 4 + ich;
150 // Int_t localMask = ( activeBoard ) ? localBoardMask->ValueAsInt(planeIndex) : 0;
151 // Int_t arrayIndex = GetArrayIndex(icath, ich, cardNumber);
152 // fTriggerStatusMap[arrayIndex] = localMask;
153 // } // loop on chambers
154 // } // loop on planes
155 // } // loop on boards
156 // } // loop on crates
161 //_____________________________________________________________________________
162 Bool_t AliMUONTriggerUtilities::IsMasked(const AliMUONVDigit& digit) const
164 /// Check if pad is masked
165 return IsMasked(digit.DetElemId(), digit.Cathode(), digit.ManuId(), digit.ManuChannel());
169 //_____________________________________________________________________________
170 Bool_t AliMUONTriggerUtilities::IsMasked(const AliMpPad& pad, Int_t detElemId, Int_t cathode) const
172 /// Check if pad is masked
173 return IsMasked(detElemId, cathode, pad.GetLocalBoardId(0), pad.GetLocalBoardChannel(0));
177 //_____________________________________________________________________________
178 Bool_t AliMUONTriggerUtilities::IsMasked(Int_t detElemId, Int_t cathode, Int_t localCircuit, Int_t strip) const
180 /// Check if pad is masked
181 Int_t trigCh = detElemId/100 - 11;
183 // Int_t ibitxy = strip;
184 // AliMpLocalBoard* localBoard = AliMpDDLStore::Instance()->GetLocalBoard(localCircuit);
185 // if ( cathode && localBoard->GetSwitch(AliMpLocalBoard::kZeroAllYLSB) ) ibitxy += 8;
186 Int_t arrayIndex = GetArrayIndex(cathode, trigCh, localCircuit);
187 Bool_t isMasked = ( ( ( fTriggerStatusMap[arrayIndex] >> strip ) & 0x1 ) == 0 );
188 AliDebug(1,Form("detElemId %i cath %i board %i strip %i is active %i\n", detElemId, cathode, localCircuit, strip, ! isMasked));
193 //_____________________________________________________________________________
194 Int_t AliMUONTriggerUtilities::GetArrayIndex(Int_t cathode, Int_t trigCh, Int_t localCircuit) const
196 /// Get index of array with trigger status map or efficiency
198 AliMUONConstants::NTriggerCircuit() * AliMUONConstants::NTriggerCh() * cathode +
199 AliMUONConstants::NTriggerCircuit() * trigCh + localCircuit-1;