]> git.uio.no Git - u/mrichter/AliRoot.git/blame - MUON/mapping/AliMpRegionalTrigger.cxx
Updated serial number for station 345
[u/mrichter/AliRoot.git] / MUON / mapping / AliMpRegionalTrigger.cxx
CommitLineData
cde9ca47 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// $MpId: AliMpTrigger.cxx,v 1.4 2006/05/24 13:58:52 ivana Exp $
18
19//-----------------------------------------------------------------------------
20// Class AliMpRegionalTrigger
21// --------------------
22// The class defines the properties of regional trigger crate
23// Author: Ch. Finck, Subatech Nantes
24//-----------------------------------------------------------------------------
25
26#include "AliMpRegionalTrigger.h"
113ad708 27#include "AliMpRegionalTriggerReader.h"
630711ed 28#include "AliMpExMapIterator.h"
cde9ca47 29#include "AliMpTriggerCrate.h"
30#include "AliMpLocalBoard.h"
31#include "AliMpConstants.h"
32#include "AliMpFiles.h"
228fd720 33#include "AliMpDataStreams.h"
cde9ca47 34#include "AliMpHelper.h"
35
36#include "AliLog.h"
37
38#include <TArrayI.h>
39#include <Riostream.h>
40#include <TClass.h>
41#include <TSystem.h>
42
43
44/// \cond CLASSIMP
45ClassImp(AliMpRegionalTrigger)
46/// \endcond
47
48
49//______________________________________________________________________________
50AliMpRegionalTrigger::AliMpRegionalTrigger()
51 : TObject(),
630711ed 52 fTriggerCrates(),
53 fLocalBoardMap(),
54 fLocalBoardArray(AliMpConstants::TotalNofLocalBoards()+1) // included non-notified boards
cde9ca47 55{
630711ed 56 /// Standard constructor
cde9ca47 57
58 fTriggerCrates.SetOwner(true);
59 fTriggerCrates.SetSize(AliMpConstants::LocalBoardNofChannels());
cde9ca47 60}
61
62//______________________________________________________________________________
63AliMpRegionalTrigger::AliMpRegionalTrigger(const AliMpRegionalTrigger& rhs)
64 : TObject(rhs),
65 fTriggerCrates(rhs.fTriggerCrates),
630711ed 66 fLocalBoardMap(rhs.fLocalBoardMap),
67 fLocalBoardArray(rhs.fLocalBoardArray)
cde9ca47 68{
69/// Copy constructor
70}
71
72//______________________________________________________________________________
630711ed 73AliMpRegionalTrigger::AliMpRegionalTrigger(TRootIOCtor* ioCtor)
cde9ca47 74 : TObject(),
630711ed 75 fTriggerCrates(ioCtor),
76 fLocalBoardMap(ioCtor),
77 fLocalBoardArray()
cde9ca47 78{
79/// Constructor for I0
80}
81
82//______________________________________________________________________________
83AliMpRegionalTrigger& AliMpRegionalTrigger::operator=(const AliMpRegionalTrigger& rhs)
84{
85/// Assignment operator
86
87 // check assignment to self
88 if (this == &rhs) return *this;
89
90 // base class assignment
91 TObject::operator=(rhs);
92
93 // assignment operator
94 fTriggerCrates = rhs.fTriggerCrates;
630711ed 95 fLocalBoardArray = rhs.fLocalBoardArray;
cde9ca47 96
97 return *this;
98}
99
100//______________________________________________________________________________
101AliMpRegionalTrigger::~AliMpRegionalTrigger()
102{
103/// Destructor
104}
105
228fd720 106
cde9ca47 107//
228fd720 108// private methods
cde9ca47 109//
110
111//______________________________________________________________________________
228fd720 112Bool_t AliMpRegionalTrigger::ReadData(istream& in)
cde9ca47 113{
114/// Load the Regional trigger from ASCII data files
115/// and return its instance
116
113ad708 117 TList list;
118 list.AddAt(&fTriggerCrates, 0);
119 list.AddAt(&fLocalBoardMap, 1);
120 list.AddAt(&fLocalBoardArray, 2);
cde9ca47 121
113ad708 122 Int_t status = AliMpRegionalTriggerReader::ReadData(list, in);
cde9ca47 123
113ad708 124 if (status == -1) {
125 AliErrorStream()
126 << "Regional Trigger Mapping File not found" << endl;
127 return kFALSE;
128 }
cde9ca47 129
113ad708 130 if (!status)
131 return kFALSE;
132
228fd720 133
cde9ca47 134 return kTRUE;
135}
136
228fd720 137//
138// public methods
139//
140
141//______________________________________________________________________________
142Bool_t AliMpRegionalTrigger::ReadData(const TString& fileName)
143{
144/// Load the Regional trigger from ASCII data files
145/// and return its instance
146
147 if ( fileName != "" ) {
148 AliDebugStream(2) << "Read data from file " << fileName.Data() << endl;
149
150 TString inFileName(fileName);
151 inFileName = gSystem->ExpandPathName(inFileName.Data());
152 ifstream inFile(inFileName.Data(), ios::in);
153 if ( ! inFile.good() ) {
154 AliErrorStream()
155 << "Local Trigger Board Mapping File " << fileName.Data() << " not found" << endl;
156 return kFALSE;
157 }
158
159 return ReadData(inFile);
160 }
161 else {
162 AliDebugStream(2) << "Read data from stream " << fileName.Data() << endl;
163 istream& in
164 = AliMpDataStreams::Instance()
165 ->CreateDataStream(AliMpFiles::LocalTriggerBoardMapping());
166
167 Bool_t result = ReadData(in);
168
169 delete &in;
170 return result;
171 }
172}
173
cde9ca47 174//______________________________________________________________________________
175AliMpLocalBoard* AliMpRegionalTrigger::FindLocalBoard(Int_t localBoardId,
176 Bool_t warn) const {
630711ed 177 /// Return local board with given Id
cde9ca47 178
179 AliMpLocalBoard* localBoard
630711ed 180 = static_cast<AliMpLocalBoard*>(fLocalBoardMap.GetValue(localBoardId));
181
cde9ca47 182 if ( ! localBoard && warn ) {
183 AliErrorStream()
630711ed 184 << "Loacl board with localBoardId = " << localBoardId << " not found." << endl;
185 }
cde9ca47 186
187 return localBoard;
188}
189
190//______________________________________________________________________________
191AliMpTriggerCrate* AliMpRegionalTrigger::FindTriggerCrate(TString name,
192 Bool_t warn) const {
193 /// Return trigger crate with given name
194
195 AliMpTriggerCrate* crate
196 = (AliMpTriggerCrate*) fTriggerCrates.GetValue(name.Data());
197
198 if ( ! crate && warn ) {
199 AliErrorStream()
200 << "Trigger crate with name = " << name.Data() << " not defined." << endl;
201 }
202
203 return crate;
204}
205
206//______________________________________________________________________________
207Int_t AliMpRegionalTrigger::GetNofTriggerCrates() const
208{
209 /// Return number of trigger crates
210
211 return fTriggerCrates.GetSize();
212}
213
214//______________________________________________________________________________
630711ed 215Int_t AliMpRegionalTrigger::GetNofLocalBoards() const
cde9ca47 216{
630711ed 217 /// Return number of local boards
218
219 return fLocalBoardArray.GetSize();
cde9ca47 220}
221
222//______________________________________________________________________________
630711ed 223TIterator*
224AliMpRegionalTrigger::CreateCrateIterator() const
225{
226 /// Create iterator over crates
cde9ca47 227
630711ed 228 return fTriggerCrates.CreateIterator();
cde9ca47 229}
230
231//______________________________________________________________________________
630711ed 232TIterator*
233AliMpRegionalTrigger::CreateLocalBoardIterator() const
234{
235 /// Create iterator over local boards
cde9ca47 236
630711ed 237 return fLocalBoardArray.MakeIterator();
cde9ca47 238}
239
240//______________________________________________________________________________
630711ed 241Int_t
242AliMpRegionalTrigger::LocalBoardId(Int_t index) const
243{
244 /// Return local board Id for the local boards with a given index
245
246 AliMpLocalBoard* lb = static_cast<AliMpLocalBoard*>(fLocalBoardArray.At(index));
247 if (lb)
248 {
249 return lb->GetId();
250 }
251 AliError(Form("Could not get local board at index %d",index));
252 return -1;
cde9ca47 253}
254
255