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 **************************************************************************/
19 #include "AliMUONCalibrationData.h"
20 #include "AliMUONTriggerCrateStore.h"
21 #include "AliMUONTriggerCrate.h"
22 #include "AliMUONTriggerCrateConfig.h"
23 #include "AliMUONVCalibParam.h"
24 #include "AliMUONRegionalTriggerConfig.h"
25 #include "AliMUONLocalTriggerBoard.h"
26 #include "AliMUONVDigit.h"
27 #include "AliMUONConstants.h"
29 #include "AliMpDDLStore.h"
31 #include "AliMpLocalBoard.h"
33 #include "AliMUONTriggerUtilities.h"
36 ClassImp(AliMUONTriggerUtilities)
40 //_____________________________________________________________________________
41 AliMUONTriggerUtilities::AliMUONTriggerUtilities(AliMUONCalibrationData* calibData):
43 fCalibrationData(calibData),
44 fTriggerStatusMap(2*AliMUONConstants::NTriggerCh()*AliMUONConstants::NTriggerCircuit())
50 //_____________________________________________________________________________
51 AliMUONTriggerUtilities::~AliMUONTriggerUtilities()
53 /// Destructor. Note we're the owner of some pointers.
58 //_____________________________________________________________________________
59 Bool_t AliMUONTriggerUtilities::Init()
61 /// Build trigger status map from masks
62 AliMUONTriggerCrateStore crates;
63 crates.ReadFromFile(fCalibrationData);
65 AliMUONRegionalTriggerConfig* regionalConfig = fCalibrationData->RegionalTriggerConfig();
66 if ( ! regionalConfig ) AliFatal("no valid regional trigger configuration in CDB\n");
69 AliMUONTriggerCrate* cr = 0x0;
70 TIter next ( crates.CreateCrateIterator() );
71 while ( ( cr = static_cast<AliMUONTriggerCrate*>(next()) ) ) {
72 TObjArray *boards = cr->Boards();
74 AliMUONTriggerCrateConfig* crateConfig = regionalConfig->FindTriggerCrate(cr->GetName());
76 if ( ! crateConfig ) AliFatal(Form("Crate %s not present in configuration !!!\n", cr->GetName()));
78 UShort_t regionalMask = crateConfig->GetMask();
81 for (Int_t iboard = 1; iboard < boards->GetEntries(); iboard++ ) {
82 Bool_t activeBoard = ( ( regionalMask >> ( iboard - 1) ) & 1 );
83 AliMUONLocalTriggerBoard* board = (AliMUONLocalTriggerBoard*)boards->At(iboard);
84 Int_t cardNumber = board->GetNumber();
85 if ( cardNumber <= 0 ) continue; // interface board are not interested
86 AliMUONVCalibParam* localBoardMask = fCalibrationData->LocalTriggerBoardMasks(cardNumber);
87 for ( Int_t icath = 0; icath < 2; ++icath ) {
88 for ( Int_t ich = 0; ich < 4; ++ich ) {
89 Int_t planeIndex = icath * 4 + ich;
90 Int_t localMask = ( activeBoard ) ? localBoardMask->ValueAsInt(planeIndex) : 0;
91 Int_t arrayIndex = GetArrayIndex(icath, ich, cardNumber);
92 fTriggerStatusMap[arrayIndex] = localMask;
101 //_____________________________________________________________________________
102 Bool_t AliMUONTriggerUtilities::IsMasked(const AliMUONVDigit& digit) const
104 /// Check if pad is masked
105 Int_t detElemId = digit.DetElemId();
106 Int_t localCircuit = digit.ManuId();
107 Int_t strip = digit.ManuChannel();
108 Int_t cathode = digit.Cathode();
109 Int_t trigCh = detElemId/100 - 11;
111 AliMpLocalBoard* localBoard = AliMpDDLStore::Instance()->GetLocalBoard(localCircuit);
112 Int_t ibitxy = strip;
113 if (cathode && localBoard->GetSwitch(AliMpLocalBoard::kZeroAllYLSB)) ibitxy += 8;
114 Int_t arrayIndex = GetArrayIndex(cathode, trigCh, localCircuit);
115 AliDebug(1,Form("ch %i cath %i board %i strip %i mask %i\n", trigCh, cathode, localCircuit, strip, (fTriggerStatusMap[arrayIndex] >> ibitxy ) & 0x1));
116 return ((( fTriggerStatusMap[arrayIndex] >> ibitxy ) & 0x1 ) == 0 );
120 //_____________________________________________________________________________
121 Bool_t AliMUONTriggerUtilities::IsMasked(const AliMpPad& pad, Int_t detElemId, Int_t cathode) const
123 /// Check if pad is masked
124 Int_t localCircuit = pad.GetLocalBoardId(0);
125 Int_t strip = pad.GetLocalBoardChannel(0);
126 Int_t trigCh = detElemId/100 - 11;
128 AliMpLocalBoard* localBoard = AliMpDDLStore::Instance()->GetLocalBoard(localCircuit);
129 Int_t ibitxy = strip;
130 if (cathode && localBoard->GetSwitch(AliMpLocalBoard::kZeroAllYLSB)) ibitxy += 8;
131 Int_t arrayIndex = GetArrayIndex(cathode, trigCh, localCircuit);
132 AliDebug(1,Form("ch %i cath %i board %i strip %i mask %i\n", trigCh, cathode, localCircuit, strip, (fTriggerStatusMap[arrayIndex] >> ibitxy ) & 0x1));
133 return ((( fTriggerStatusMap[arrayIndex] >> ibitxy ) & 0x1 ) == 0 );
137 //_____________________________________________________________________________
138 Int_t AliMUONTriggerUtilities::GetArrayIndex(Int_t cathode, Int_t trigCh, Int_t localCircuit) const
140 /// Get index of array with trigger status map or efficiency
142 AliMUONConstants::NTriggerCircuit() * AliMUONConstants::NTriggerCh() * cathode +
143 AliMUONConstants::NTriggerCircuit() * trigCh + localCircuit-1;