]> git.uio.no Git - u/mrichter/AliRoot.git/blame - MUON/AliMUONTriggerUtilities.cxx
Compatibility with ROOT trunk
[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"
26//#include "AliMUONTriggerCrateConfig.h"
27//#include "AliMUONVCalibParam.h"
28//#include "AliMUONRegionalTriggerConfig.h"
29//#include "AliMUONLocalTriggerBoard.h"
d5315275 30#include "AliMUONVDigit.h"
31#include "AliMUONConstants.h"
0a2dcc83 32#include "AliMUONTriggerElectronics.h"
33#include "AliMUONDigitStoreV2R.h"
34#include "AliMUONDigitMaker.h"
35#include "AliMUONTriggerStoreV1.h"
d5315275 36
37#include "AliMpDDLStore.h"
38#include "AliMpPad.h"
0a2dcc83 39//#include "AliMpLocalBoard.h"
40#include "AliMpConstants.h"
41#include "AliMpVSegmentation.h"
42#include "AliMpSegmentation.h"
d5315275 43
44/// \cond CLASSIMP
45ClassImp(AliMUONTriggerUtilities)
46/// \endcond
47
48
49//_____________________________________________________________________________
50AliMUONTriggerUtilities::AliMUONTriggerUtilities(AliMUONCalibrationData* calibData):
51TObject(),
52fCalibrationData(calibData),
0a2dcc83 53fTriggerStatusMap(2*AliMUONConstants::NTriggerCh()*AliMUONConstants::NTriggerCircuit()),
54fMaskedDigitsStore(new AliMUONDigitStoreV2R())
d5315275 55{
56 /// Ctor.
57 Init();
58}
59
60//_____________________________________________________________________________
61AliMUONTriggerUtilities::~AliMUONTriggerUtilities()
62{
63 /// Destructor. Note we're the owner of some pointers.
0a2dcc83 64 delete fMaskedDigitsStore;
d5315275 65}
66
67
68//_____________________________________________________________________________
69Bool_t AliMUONTriggerUtilities::Init()
70{
71 /// Build trigger status map from masks
0a2dcc83 72 AliMUONTriggerElectronics trigElectronics(fCalibrationData);
73 AliMUONDigitMaker digitMaker(kFALSE);
74 AliMUONDigitStoreV2R digitStore;
75 AliMUONTriggerStoreV1 triggerStore;
76
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);
81 }
82
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);
86 }
87
88 // Create trigger with electronics (it applies masks)
89 trigElectronics.Digits2Trigger(digitStore, triggerStore);
d5315275 90
0a2dcc83 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);
d5315275 96
0a2dcc83 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);
110 else {
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)
119 }
120 }
121
122// AliMUONTriggerCrateStore crates;
123// crates.ReadFromFile(fCalibrationData);
124//
125// AliMUONRegionalTriggerConfig* regionalConfig = fCalibrationData->RegionalTriggerConfig();
126// if ( ! regionalConfig ) AliFatal("no valid regional trigger configuration in CDB\n");
127//
128// // Loop on crates
129// AliMUONTriggerCrate* cr = 0x0;
130// TIter next ( crates.CreateCrateIterator() );
131// while ( ( cr = static_cast<AliMUONTriggerCrate*>(next()) ) ) {
132// TObjArray *boards = cr->Boards();
133//
134// AliMUONTriggerCrateConfig* crateConfig = regionalConfig->FindTriggerCrate(cr->GetName());
135//
136// if ( ! crateConfig ) AliFatal(Form("Crate %s not present in configuration !!!\n", cr->GetName()));
137//
138// UShort_t regionalMask = crateConfig->GetMask();
139//
140// // Loop on boards
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
d5315275 157
158 return kTRUE;
159}
160
161//_____________________________________________________________________________
162Bool_t AliMUONTriggerUtilities::IsMasked(const AliMUONVDigit& digit) const
163{
0a2dcc83 164 /// Check if pad is masked
165 return IsMasked(digit.DetElemId(), digit.Cathode(), digit.ManuId(), digit.ManuChannel());
d5315275 166}
167
168
169//_____________________________________________________________________________
170Bool_t AliMUONTriggerUtilities::IsMasked(const AliMpPad& pad, Int_t detElemId, Int_t cathode) const
0a2dcc83 171{
172 /// Check if pad is masked
173 return IsMasked(detElemId, cathode, pad.GetLocalBoardId(0), pad.GetLocalBoardChannel(0));
174}
175
176
177//_____________________________________________________________________________
178Bool_t AliMUONTriggerUtilities::IsMasked(Int_t detElemId, Int_t cathode, Int_t localCircuit, Int_t strip) const
d5315275 179{
180 /// Check if pad is masked
d5315275 181 Int_t trigCh = detElemId/100 - 11;
182
0a2dcc83 183// Int_t ibitxy = strip;
184// AliMpLocalBoard* localBoard = AliMpDDLStore::Instance()->GetLocalBoard(localCircuit);
185// if ( cathode && localBoard->GetSwitch(AliMpLocalBoard::kZeroAllYLSB) ) ibitxy += 8;
d5315275 186 Int_t arrayIndex = GetArrayIndex(cathode, trigCh, localCircuit);
0a2dcc83 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));
189 return isMasked;
d5315275 190}
191
192
193//_____________________________________________________________________________
194Int_t AliMUONTriggerUtilities::GetArrayIndex(Int_t cathode, Int_t trigCh, Int_t localCircuit) const
195{
196 /// Get index of array with trigger status map or efficiency
197 return
198 AliMUONConstants::NTriggerCircuit() * AliMUONConstants::NTriggerCh() * cathode +
199 AliMUONConstants::NTriggerCircuit() * trigCh + localCircuit-1;
200}