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 **************************************************************************/
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"
29 #include "AliMpTriggerCrate.h"
30 #include "AliMpLocalBoard.h"
31 #include "AliMpDDLStore.h"
32 #include "AliMpExMap.h"
37 #include <Riostream.h>
41 //-----------------------------------------------------------------------------
42 /// \class AliMUONTriggerCrateStore
44 /// A container of trigger crate objects that offers iteration
45 /// over both the crates themselves and the local boards they contain
47 /// \author Laurent Aphecetche
48 //-----------------------------------------------------------------------------
51 ClassImp(AliMUONTriggerCrateStore)
54 //_____________________________________________________________________________
55 AliMUONTriggerCrateStore::AliMUONTriggerCrateStore()
60 /// Default constructor
63 //_____________________________________________________________________________
64 AliMUONTriggerCrateStore::~AliMUONTriggerCrateStore()
71 //_____________________________________________________________________________
73 AliMUONTriggerCrateStore::AddCrate(const char *name)
75 /// create and add a crate to our map
78 AliError("Object not properly initialized");
82 AliDebug(1,Form("Adding crate %s",name));
83 TObject* there = fCrates->GetValue(name);
86 AliError(Form("Cannot add crate %s because it's already there !",name));
90 fCrates->Add(name,new AliMUONTriggerCrate(name,17));
94 //_____________________________________________________________________________
95 AliMUONLocalTriggerBoard*
96 AliMUONTriggerCrateStore::LocalBoard(Int_t boardNumber) const
98 /// return a board by number
102 AliError("Object not properly initialized");
106 return static_cast<AliMUONLocalTriggerBoard*>(fLocalBoards->GetValue(boardNumber));
109 //_____________________________________________________________________________
111 AliMUONTriggerCrateStore::CreateCrateIterator() const
113 /// Create iterator over crates
115 return fCrates ? fCrates->CreateIterator() : 0x0;
118 //_____________________________________________________________________________
120 AliMUONTriggerCrateStore::CreateLocalBoardIterator() const
122 /// Create iterator over local boards
124 return fLocalBoards ? fLocalBoards->CreateIterator() : 0x0;
127 //_____________________________________________________________________________
129 AliMUONTriggerCrateStore::Crate(const char *name) const
131 /// return a crate by name
134 AliError("Object not properly initialized");
137 return static_cast<AliMUONTriggerCrate*>(fCrates->GetValue(name));
140 // to be removed once AliMUONDigitMaker is linked with new mapping
141 //_____________________________________________________________________________
143 AliMUONTriggerCrateStore::Crate(Int_t ddl, Int_t reg) const
145 /// return a crate by name
148 AliError("Object not properly initialized");
151 TString name = GetCrateName(ddl, reg);
152 return static_cast<AliMUONTriggerCrate*>(fCrates->GetValue(name.Data()));
154 //____________________________________________________________________
155 TString AliMUONTriggerCrateStore::GetCrateName(Int_t ddl, Int_t reg) const
157 /// set crate name from DDL & reg number
163 snprintf(name,10,"%d", reg+1);
173 snprintf(name,10,"%d", reg);
177 // crate Right for first DDL
179 strncat(name, "R", 1);
181 strncat(name, "L", 1);
183 return TString(name);
185 //_____________________________________________________________________________
187 AliMUONTriggerCrateStore::NumberOfCrates() const
189 /// Number of crates we're holding
190 if ( fCrates ) return fCrates->GetSize();
194 //_____________________________________________________________________________
196 AliMUONTriggerCrateStore::NumberOfLocalBoards() const
198 /// Number of local boards we're holding
199 if ( fLocalBoards ) return fLocalBoards->GetSize();
203 //_____________________________________________________________________________
205 AliMUONTriggerCrateStore::ReadFromFile(AliMUONCalibrationData* calibData)
207 /// create crate and local board objects from mapping & calib (Ch.F)
208 fCrates = new AliMpExMap;
209 fCrates->SetOwner(kTRUE);
210 fLocalBoards = new AliMpExMap;
211 fLocalBoards->SetOwner(kFALSE);
214 AliMUONTriggerLut* lut = calibData->TriggerLut();
217 AliWarning("No valid trigger LUT in CDB");
219 AliMUONRegionalTriggerConfig* regionalConfig = calibData->RegionalTriggerConfig();
220 if (!regionalConfig) {
221 AliError("No valid regional trigger configuration in CDB");
225 TIter next(AliMpDDLStore::Instance()->GetRegionalTrigger()->CreateCrateIterator());
226 AliMpTriggerCrate* crateMapping;
228 while ( ( crateMapping = static_cast<AliMpTriggerCrate*>(next()) ) )
231 TString crateName = crateMapping->GetName();
232 AliMUONTriggerCrate *crate = Crate(crateName.Data());
234 AliMUONTriggerCrateConfig* crateConfig = regionalConfig->FindTriggerCrate(crateName);
238 AddCrate(crateName.Data());
239 crate = Crate(crateName.Data());
240 AliDebug(3, Form("crate name %s\n", crateName.Data()));
241 AliMUONRegionalTriggerBoard *rboard = new AliMUONRegionalTriggerBoard();
242 crate->AddBoard(rboard, 0);
245 for(Int_t iLocal = 0; iLocal < crateMapping->GetNofLocalBoards(); ++iLocal) {
247 Int_t localBoardId = crateMapping->GetLocalBoardId(iLocal);
248 if (!localBoardId) continue; //empty slot, should not happen
250 AliMpLocalBoard* localBoardMapping = AliMpDDLStore::Instance()->GetLocalBoard(localBoardId);
251 AliDebug(3, Form("local name %s id %d\n", localBoardMapping->GetName(), localBoardId));
253 Int_t slot = localBoardMapping->GetSlot();
254 AliMUONLocalTriggerBoard *board = new AliMUONLocalTriggerBoard(localBoardMapping);
255 board->SetCoinc44(crateConfig->GetCoinc());
259 if (localBoardMapping->IsNotified()) {
260 fLocalBoards->Add(localBoardId, board);
263 crate->AddBoard(board, slot);