]>
Commit | Line | Data |
---|---|---|
30dd09e2 | 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 | // $Id$ | |
17 | ||
18 | #include "AliMUONTriggerCrateStore.h" | |
630711ed | 19 | #include "AliMpExMapIterator.h" |
30dd09e2 | 20 | #include "AliMUONTriggerCrate.h" |
21 | #include "AliMUONLocalTriggerBoard.h" | |
22 | #include "AliMUONRegionalTriggerBoard.h" | |
92c23b09 | 23 | #include "AliMUONRegionalTriggerConfig.h" |
24 | #include "AliMUONGlobalCrateConfig.h" | |
25 | #include "AliMUONTriggerCrateConfig.h" | |
26 | #include "AliMUONCalibrationData.h" | |
27 | #include "AliMUONTriggerLut.h" | |
ac809573 | 28 | |
29 | #include "AliMpTriggerCrate.h" | |
30 | #include "AliMpLocalBoard.h" | |
31 | #include "AliMpDDLStore.h" | |
30dd09e2 | 32 | #include "AliMpExMap.h" |
30dd09e2 | 33 | #include "AliLog.h" |
ac809573 | 34 | |
35 | #include <TString.h> | |
36 | #include <TSystem.h> | |
37 | #include <Riostream.h> | |
30dd09e2 | 38 | |
3d1463c8 | 39 | //----------------------------------------------------------------------------- |
30dd09e2 | 40 | /// \class AliMUONTriggerCrateStore |
41 | /// | |
42 | /// A container of trigger crate objects that offers iteration | |
43 | /// over both the crates themselves and the local boards they contain | |
44 | /// | |
45 | /// \author Laurent Aphecetche | |
3d1463c8 | 46 | //----------------------------------------------------------------------------- |
30dd09e2 | 47 | |
5398f946 | 48 | /// \cond CLASSIMP |
30dd09e2 | 49 | ClassImp(AliMUONTriggerCrateStore) |
5398f946 | 50 | /// \endcond |
30dd09e2 | 51 | |
52 | //_____________________________________________________________________________ | |
53 | AliMUONTriggerCrateStore::AliMUONTriggerCrateStore() | |
54 | : TObject(), | |
55 | fCrates(0x0), | |
630711ed | 56 | fLocalBoards(0x0) |
30dd09e2 | 57 | { |
5398f946 | 58 | /// Default constructor |
30dd09e2 | 59 | } |
60 | ||
61 | //_____________________________________________________________________________ | |
62 | AliMUONTriggerCrateStore::~AliMUONTriggerCrateStore() | |
63 | { | |
5398f946 | 64 | /// Destructor |
30dd09e2 | 65 | delete fCrates; |
66 | delete fLocalBoards; | |
67 | } | |
68 | ||
69 | //_____________________________________________________________________________ | |
70 | void | |
71 | AliMUONTriggerCrateStore::AddCrate(const char *name) | |
72 | { | |
73 | /// create and add a crate to our map | |
74 | if (!fCrates) | |
75 | { | |
76 | AliError("Object not properly initialized"); | |
77 | return; | |
78 | } | |
79 | ||
80 | AliDebug(1,Form("Adding crate %s",name)); | |
81 | TObject* there = fCrates->GetValue(name); | |
82 | if (there) | |
83 | { | |
84 | AliError(Form("Cannot add crate %s because it's already there !",name)); | |
85 | } | |
86 | else | |
87 | { | |
88 | fCrates->Add(name,new AliMUONTriggerCrate(name,17)); | |
89 | } | |
90 | } | |
91 | ||
92 | //_____________________________________________________________________________ | |
93 | AliMUONLocalTriggerBoard* | |
94 | AliMUONTriggerCrateStore::LocalBoard(Int_t boardNumber) const | |
95 | { | |
96 | /// return a board by number | |
97 | ||
98 | if ( !fLocalBoards ) | |
99 | { | |
100 | AliError("Object not properly initialized"); | |
101 | return 0x0; | |
102 | } | |
103 | ||
104 | return static_cast<AliMUONLocalTriggerBoard*>(fLocalBoards->GetValue(boardNumber)); | |
105 | } | |
106 | ||
630711ed | 107 | //_____________________________________________________________________________ |
108 | TIterator* | |
109 | AliMUONTriggerCrateStore::CreateCrateIterator() const | |
110 | { | |
111 | /// Create iterator over crates | |
112 | ||
113 | return fCrates ? fCrates->CreateIterator() : 0x0; | |
114 | } | |
115 | ||
116 | //_____________________________________________________________________________ | |
117 | TIterator* | |
118 | AliMUONTriggerCrateStore::CreateLocalBoardIterator() const | |
119 | { | |
120 | /// Create iterator over local boards | |
121 | ||
122 | return fLocalBoards ? fLocalBoards->CreateIterator() : 0x0; | |
123 | } | |
124 | ||
30dd09e2 | 125 | //_____________________________________________________________________________ |
126 | AliMUONTriggerCrate* | |
127 | AliMUONTriggerCrateStore::Crate(const char *name) const | |
128 | { | |
129 | /// return a crate by name | |
130 | if ( !fCrates ) | |
131 | { | |
132 | AliError("Object not properly initialized"); | |
133 | return 0x0; | |
134 | } | |
135 | return static_cast<AliMUONTriggerCrate*>(fCrates->GetValue(name)); | |
136 | } | |
137 | ||
ac809573 | 138 | // to be removed once AliMUONDigitMaker is linked with new mapping |
aa6ecf89 | 139 | //_____________________________________________________________________________ |
140 | AliMUONTriggerCrate* | |
141 | AliMUONTriggerCrateStore::Crate(Int_t ddl, Int_t reg) const | |
142 | { | |
143 | /// return a crate by name | |
144 | if ( !fCrates ) | |
145 | { | |
146 | AliError("Object not properly initialized"); | |
147 | return 0x0; | |
148 | } | |
149 | TString name = GetCrateName(ddl, reg); | |
150 | return static_cast<AliMUONTriggerCrate*>(fCrates->GetValue(name.Data())); | |
151 | } | |
ac809573 | 152 | //____________________________________________________________________ |
aa6ecf89 | 153 | TString AliMUONTriggerCrateStore::GetCrateName(Int_t ddl, Int_t reg) const |
154 | { | |
71a2d3aa | 155 | /// set crate name from DDL & reg number |
aa6ecf89 | 156 | |
157 | Char_t name[10]; | |
158 | switch(reg) { | |
159 | case 0: | |
160 | case 1: | |
161 | sprintf(name,"%d", reg+1); | |
162 | break; | |
163 | case 2: | |
164 | strcpy(name, "2-3"); | |
165 | break; | |
166 | case 3: | |
167 | case 4: | |
168 | case 5: | |
169 | case 6: | |
170 | case 7: | |
171 | sprintf(name,"%d", reg); | |
172 | break; | |
173 | } | |
174 | ||
175 | // crate Right for first DDL | |
176 | if (ddl == 0) | |
177 | strcat(name, "R"); | |
178 | else | |
179 | strcat(name, "L"); | |
180 | ||
181 | return TString(name); | |
182 | } | |
30dd09e2 | 183 | //_____________________________________________________________________________ |
184 | Int_t | |
185 | AliMUONTriggerCrateStore::NumberOfCrates() const | |
186 | { | |
187 | /// Number of crates we're holding | |
188 | if ( fCrates ) return fCrates->GetSize(); | |
189 | return 0; | |
190 | } | |
191 | ||
192 | //_____________________________________________________________________________ | |
193 | Int_t | |
194 | AliMUONTriggerCrateStore::NumberOfLocalBoards() const | |
195 | { | |
196 | /// Number of local boards we're holding | |
197 | if ( fLocalBoards ) return fLocalBoards->GetSize(); | |
198 | return 0; | |
199 | } | |
200 | ||
201 | //_____________________________________________________________________________ | |
202 | void | |
92c23b09 | 203 | AliMUONTriggerCrateStore::ReadFromFile(AliMUONCalibrationData* calibData) |
30dd09e2 | 204 | { |
92c23b09 | 205 | /// create crate and local board objects from mapping & calib (Ch.F) |
630711ed | 206 | fCrates = new AliMpExMap; |
6e241007 | 207 | fCrates->SetOwner(kTRUE); |
630711ed | 208 | fLocalBoards = new AliMpExMap; |
6e241007 | 209 | fLocalBoards->SetOwner(kFALSE); |
30dd09e2 | 210 | |
92c23b09 | 211 | |
212 | AliMUONTriggerLut* lut = calibData->TriggerLut(); | |
ac809573 | 213 | |
92c23b09 | 214 | if (!lut) |
215 | AliWarning("No valid trigger LUT in CDB"); | |
216 | ||
217 | AliMUONRegionalTriggerConfig* regionalConfig = calibData->RegionalTriggerConfig(); | |
218 | if (!regionalConfig) | |
219 | AliWarning("No valid regional trigger configuration in CDB"); | |
220 | ||
630711ed | 221 | TIter next(AliMpDDLStore::Instance()->GetRegionalTrigger()->CreateCrateIterator()); |
222 | AliMpTriggerCrate* crateMapping; | |
92c23b09 | 223 | |
630711ed | 224 | while ( ( crateMapping = static_cast<AliMpTriggerCrate*>(next()) ) ) |
5a92f8e6 | 225 | { |
92c23b09 | 226 | |
ac809573 | 227 | TString crateName = crateMapping->GetName(); |
228 | AliMUONTriggerCrate *crate = Crate(crateName.Data()); | |
92c23b09 | 229 | |
230 | AliMUONTriggerCrateConfig* crateConfig = regionalConfig->FindTriggerCrate(crateName); | |
ac809573 | 231 | |
232 | if (!crate) | |
30dd09e2 | 233 | { |
ac809573 | 234 | AddCrate(crateName.Data()); |
235 | crate = Crate(crateName.Data()); | |
236 | AliDebug(3, Form("crate name %s\n", crateName.Data())); | |
237 | AliMUONRegionalTriggerBoard *rboard = new AliMUONRegionalTriggerBoard(); | |
238 | crate->AddBoard(rboard, 0); | |
239 | } | |
240 | ||
241 | for(Int_t iLocal = 0; iLocal < crateMapping->GetNofLocalBoards(); ++iLocal) { | |
92c23b09 | 242 | |
ac809573 | 243 | Int_t localBoardId = crateMapping->GetLocalBoardId(iLocal); |
244 | if (!localBoardId) continue; //empty slot, should not happen | |
245 | ||
246 | AliMpLocalBoard* localBoardMapping = AliMpDDLStore::Instance()->GetLocalBoard(localBoardId); | |
247 | AliDebug(3, Form("local name %s id %d\n", localBoardMapping->GetName(), localBoardId)); | |
92c23b09 | 248 | |
ac809573 | 249 | Int_t slot = localBoardMapping->GetSlot(); |
92c23b09 | 250 | AliMUONLocalTriggerBoard *board = new AliMUONLocalTriggerBoard(localBoardMapping); |
251 | board->SetCoinc44(crateConfig->GetCoinc()); | |
252 | board->SetLUT(lut); | |
ac809573 | 253 | |
92c23b09 | 254 | |
ac809573 | 255 | if (localBoardMapping->IsNotified()) { |
256 | fLocalBoards->Add(localBoardId, board); | |
5a92f8e6 | 257 | } |
92c23b09 | 258 | |
ac809573 | 259 | crate->AddBoard(board, slot); |
92c23b09 | 260 | |
ac809573 | 261 | } // iLocal |
262 | } // while | |
30dd09e2 | 263 | } |
92c23b09 | 264 |