]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MUON/AliMUONTriggerUtilities.cxx
Fix for DDLs chamber2 cables inversion (DAQ people mistake) for the interested runs
[u/mrichter/AliRoot.git] / MUON / AliMUONTriggerUtilities.cxx
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
17 #include "AliLog.h"
18
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"
28
29 #include "AliMpDDLStore.h"
30 #include "AliMpPad.h"
31 #include "AliMpLocalBoard.h"
32
33 #include "AliMUONTriggerUtilities.h"
34
35 /// \cond CLASSIMP
36 ClassImp(AliMUONTriggerUtilities)
37 /// \endcond
38
39
40 //_____________________________________________________________________________
41 AliMUONTriggerUtilities::AliMUONTriggerUtilities(AliMUONCalibrationData* calibData):
42 TObject(),
43 fCalibrationData(calibData),
44 fTriggerStatusMap(2*AliMUONConstants::NTriggerCh()*AliMUONConstants::NTriggerCircuit())
45 {
46   /// Ctor.
47   Init();
48 }
49
50 //_____________________________________________________________________________
51 AliMUONTriggerUtilities::~AliMUONTriggerUtilities()
52 {
53   /// Destructor. Note we're the owner of some pointers.
54   
55 }
56
57
58 //_____________________________________________________________________________
59 Bool_t AliMUONTriggerUtilities::Init()
60 {
61   /// Build trigger status map from masks
62   AliMUONTriggerCrateStore crates;
63   crates.ReadFromFile(fCalibrationData);
64   
65   AliMUONRegionalTriggerConfig* regionalConfig = fCalibrationData->RegionalTriggerConfig();
66   if ( ! regionalConfig ) AliFatal("no valid regional trigger configuration in CDB\n");
67   
68   // Loop on crates
69   AliMUONTriggerCrate* cr = 0x0;
70   TIter next ( crates.CreateCrateIterator() );
71   while ( ( cr = static_cast<AliMUONTriggerCrate*>(next()) ) ) {
72     TObjArray *boards = cr->Boards();
73     
74     AliMUONTriggerCrateConfig* crateConfig = regionalConfig->FindTriggerCrate(cr->GetName());
75     
76     if ( ! crateConfig ) AliFatal(Form("Crate %s not present in configuration !!!\n", cr->GetName()));
77     
78     UShort_t regionalMask = crateConfig->GetMask();
79     
80     // Loop on boards
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;
93         } // loop on chambers
94       } // loop on planes
95     } // loop on boards
96   } // loop on crates
97   
98   return kTRUE;
99 }
100
101 //_____________________________________________________________________________
102 Bool_t AliMUONTriggerUtilities::IsMasked(const AliMUONVDigit& digit) const
103 {
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;
110   
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 );
117 }
118
119
120 //_____________________________________________________________________________
121 Bool_t AliMUONTriggerUtilities::IsMasked(const AliMpPad& pad, Int_t detElemId, Int_t cathode) const
122 {
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;
127   
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 );
134 }
135
136
137 //_____________________________________________________________________________
138 Int_t AliMUONTriggerUtilities::GetArrayIndex(Int_t cathode, Int_t trigCh, Int_t localCircuit) const
139 {
140   /// Get index of array with trigger status map or efficiency
141   return
142   AliMUONConstants::NTriggerCircuit() * AliMUONConstants::NTriggerCh() * cathode +
143   AliMUONConstants::NTriggerCircuit() * trigCh + localCircuit-1;
144 }