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