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>
39 //-----------------------------------------------------------------------------
40 /// \class AliMUONTriggerCrateStore
42 /// A container of trigger crate objects that offers iteration
43 /// over both the crates themselves and the local boards they contain
45 /// \author Laurent Aphecetche
46 //-----------------------------------------------------------------------------
49 ClassImp(AliMUONTriggerCrateStore)
52 //_____________________________________________________________________________
53 AliMUONTriggerCrateStore::AliMUONTriggerCrateStore()
58 /// Default constructor
61 //_____________________________________________________________________________
62 AliMUONTriggerCrateStore::~AliMUONTriggerCrateStore()
69 //_____________________________________________________________________________
71 AliMUONTriggerCrateStore::AddCrate(const char *name)
73 /// create and add a crate to our map
76 AliError("Object not properly initialized");
80 AliDebug(1,Form("Adding crate %s",name));
81 TObject* there = fCrates->GetValue(name);
84 AliError(Form("Cannot add crate %s because it's already there !",name));
88 fCrates->Add(name,new AliMUONTriggerCrate(name,17));
92 //_____________________________________________________________________________
93 AliMUONLocalTriggerBoard*
94 AliMUONTriggerCrateStore::LocalBoard(Int_t boardNumber) const
96 /// return a board by number
100 AliError("Object not properly initialized");
104 return static_cast<AliMUONLocalTriggerBoard*>(fLocalBoards->GetValue(boardNumber));
107 //_____________________________________________________________________________
109 AliMUONTriggerCrateStore::CreateCrateIterator() const
111 /// Create iterator over crates
113 return fCrates ? fCrates->CreateIterator() : 0x0;
116 //_____________________________________________________________________________
118 AliMUONTriggerCrateStore::CreateLocalBoardIterator() const
120 /// Create iterator over local boards
122 return fLocalBoards ? fLocalBoards->CreateIterator() : 0x0;
125 //_____________________________________________________________________________
127 AliMUONTriggerCrateStore::Crate(const char *name) const
129 /// return a crate by name
132 AliError("Object not properly initialized");
135 return static_cast<AliMUONTriggerCrate*>(fCrates->GetValue(name));
138 // to be removed once AliMUONDigitMaker is linked with new mapping
139 //_____________________________________________________________________________
141 AliMUONTriggerCrateStore::Crate(Int_t ddl, Int_t reg) const
143 /// return a crate by name
146 AliError("Object not properly initialized");
149 TString name = GetCrateName(ddl, reg);
150 return static_cast<AliMUONTriggerCrate*>(fCrates->GetValue(name.Data()));
152 //____________________________________________________________________
153 TString AliMUONTriggerCrateStore::GetCrateName(Int_t ddl, Int_t reg) const
155 /// set crate name from DDL & reg number
161 sprintf(name,"%d", reg+1);
171 sprintf(name,"%d", reg);
175 // crate Right for first DDL
181 return TString(name);
183 //_____________________________________________________________________________
185 AliMUONTriggerCrateStore::NumberOfCrates() const
187 /// Number of crates we're holding
188 if ( fCrates ) return fCrates->GetSize();
192 //_____________________________________________________________________________
194 AliMUONTriggerCrateStore::NumberOfLocalBoards() const
196 /// Number of local boards we're holding
197 if ( fLocalBoards ) return fLocalBoards->GetSize();
201 //_____________________________________________________________________________
203 AliMUONTriggerCrateStore::ReadFromFile(AliMUONCalibrationData* calibData)
205 /// create crate and local board objects from mapping & calib (Ch.F)
206 fCrates = new AliMpExMap;
207 fCrates->SetOwner(kTRUE);
208 fLocalBoards = new AliMpExMap;
209 fLocalBoards->SetOwner(kFALSE);
212 AliMUONTriggerLut* lut = calibData->TriggerLut();
215 AliWarning("No valid trigger LUT in CDB");
217 AliMUONRegionalTriggerConfig* regionalConfig = calibData->RegionalTriggerConfig();
219 AliWarning("No valid regional trigger configuration in CDB");
221 TIter next(AliMpDDLStore::Instance()->GetRegionalTrigger()->CreateCrateIterator());
222 AliMpTriggerCrate* crateMapping;
224 while ( ( crateMapping = static_cast<AliMpTriggerCrate*>(next()) ) )
227 TString crateName = crateMapping->GetName();
228 AliMUONTriggerCrate *crate = Crate(crateName.Data());
230 AliMUONTriggerCrateConfig* crateConfig = regionalConfig->FindTriggerCrate(crateName);
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);
241 for(Int_t iLocal = 0; iLocal < crateMapping->GetNofLocalBoards(); ++iLocal) {
243 Int_t localBoardId = crateMapping->GetLocalBoardId(iLocal);
244 if (!localBoardId) continue; //empty slot, should not happen
246 AliMpLocalBoard* localBoardMapping = AliMpDDLStore::Instance()->GetLocalBoard(localBoardId);
247 AliDebug(3, Form("local name %s id %d\n", localBoardMapping->GetName(), localBoardId));
249 Int_t slot = localBoardMapping->GetSlot();
250 AliMUONLocalTriggerBoard *board = new AliMUONLocalTriggerBoard(localBoardMapping);
251 board->SetCoinc44(crateConfig->GetCoinc());
255 if (localBoardMapping->IsNotified()) {
256 fLocalBoards->Add(localBoardId, board);
259 crate->AddBoard(board, slot);