]>
Commit | Line | Data |
---|---|---|
92c23b09 | 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 AliMUONRegionalTriggerConfig | |
21 | // -------------------- | |
22 | // The class defines the configuration of regional trigger crate | |
23 | // Author: Ch. Finck, Subatech Nantes | |
24 | //----------------------------------------------------------------------------- | |
25 | ||
26 | #include "AliMUONRegionalTriggerConfig.h" | |
27 | #include "AliMUONTriggerCrateConfig.h" | |
28 | #include "AliMpConstants.h" | |
29 | #include "AliMpFiles.h" | |
30 | #include "AliMpHelper.h" | |
31 | ||
32 | #include "AliLog.h" | |
33 | ||
34 | #include <TArrayI.h> | |
35 | #include <Riostream.h> | |
36 | #include <TClass.h> | |
37 | #include <TSystem.h> | |
38 | ||
39 | ||
40 | /// \cond CLASSIMP | |
41 | ClassImp(AliMUONRegionalTriggerConfig) | |
42 | /// \endcond | |
43 | ||
44 | ||
45 | //______________________________________________________________________________ | |
46 | AliMUONRegionalTriggerConfig::AliMUONRegionalTriggerConfig() | |
47 | : TObject(), | |
48 | fTriggerCrates(true) | |
49 | { | |
50 | /// Standard constructor | |
51 | ||
52 | fTriggerCrates.SetOwner(true); | |
53 | fTriggerCrates.SetSize(AliMpConstants::LocalBoardNofChannels()); | |
54 | } | |
55 | ||
56 | //______________________________________________________________________________ | |
57 | AliMUONRegionalTriggerConfig::AliMUONRegionalTriggerConfig(const AliMUONRegionalTriggerConfig& rhs) | |
58 | : TObject(rhs), | |
59 | fTriggerCrates(rhs.fTriggerCrates) | |
60 | { | |
61 | /// Copy constructor | |
62 | } | |
63 | ||
64 | //______________________________________________________________________________ | |
65 | AliMUONRegionalTriggerConfig& AliMUONRegionalTriggerConfig::operator=(const AliMUONRegionalTriggerConfig& rhs) | |
66 | { | |
67 | /// Assignment operator | |
68 | ||
69 | // check assignment to self | |
70 | if (this == &rhs) return *this; | |
71 | ||
72 | // base class assignment | |
73 | TObject::operator=(rhs); | |
74 | ||
75 | // assignment operator | |
76 | fTriggerCrates = rhs.fTriggerCrates; | |
77 | ||
78 | return *this; | |
79 | } | |
80 | ||
81 | //______________________________________________________________________________ | |
82 | AliMUONRegionalTriggerConfig::~AliMUONRegionalTriggerConfig() | |
83 | { | |
84 | /// Destructor | |
85 | } | |
86 | ||
87 | // | |
88 | // public methods | |
89 | // | |
90 | ||
91 | //______________________________________________________________________________ | |
92 | Int_t AliMUONRegionalTriggerConfig::ReadData(const TString& fileName) | |
93 | { | |
94 | /// Load the Regional trigger from ASCII data files | |
95 | /// and return its instance | |
96 | ||
97 | TString inFileName(fileName); | |
98 | if ( inFileName == "" ) | |
99 | inFileName = AliMpFiles::LocalTriggerBoardMapping(); | |
100 | ||
101 | inFileName = gSystem->ExpandPathName(inFileName.Data()); | |
102 | ||
103 | ifstream in(inFileName.Data(), ios::in); | |
104 | ||
105 | if (!in) { | |
106 | AliErrorStream() | |
107 | << "Local Trigger Board Mapping File " << fileName.Data() << " not found" << endl; | |
108 | return kFALSE; | |
109 | } | |
110 | ||
111 | AliMUONTriggerCrateConfig* crate = 0x0; | |
112 | ||
113 | TArrayI list; | |
114 | UShort_t crateId, mask; | |
115 | Int_t mode, coincidence; | |
116 | Int_t localBoardId = 0; | |
117 | char line[80]; | |
118 | ||
119 | while (!in.eof()) | |
120 | { | |
121 | in.getline(line,80); | |
122 | if (!strlen(line)) break; | |
123 | TString crateName(AliMpHelper::Normalize(line)); | |
124 | ||
125 | in.getline(line,80); | |
126 | sscanf(line,"%hx",&crateId); | |
127 | ||
128 | in.getline(line,80); | |
129 | sscanf(line,"%d",&mode); | |
130 | ||
131 | in.getline(line,80); | |
132 | sscanf(line,"%d",&coincidence); | |
133 | ||
134 | in.getline(line,80); | |
135 | sscanf(line,"%hx",&mask); | |
136 | ||
137 | crate = (AliMUONTriggerCrateConfig*)(fTriggerCrates.GetValue(crateName.Data())); | |
138 | if (!crate) | |
139 | { | |
140 | // cout << "Creating crate: " << crateName.Data() << endl; | |
141 | crate = new AliMUONTriggerCrateConfig(crateName.Data(), crateId, mask, mode, coincidence); | |
142 | fTriggerCrates.Add(crateName.Data(), crate); | |
143 | } | |
144 | ||
145 | Char_t localBoardName[20]; | |
146 | Int_t slot; | |
147 | UInt_t switches; | |
148 | ||
149 | for ( Int_t i = 0; i < AliMpConstants::LocalBoardNofChannels(); ++i ) | |
150 | { | |
151 | if ( (mask >> i ) & 0x1 ) | |
152 | { | |
153 | // read local board | |
154 | in.getline(line,80); | |
155 | sscanf(line,"%02d %s %03d %03x",&slot,localBoardName,&localBoardId,&switches); | |
156 | crate->AddLocalBoard(localBoardId); | |
157 | ||
158 | // skip DEs for local board | |
159 | in.getline(line,80); | |
160 | ||
161 | // skip copy number and transverse connector | |
162 | in.getline(line,80); | |
163 | } | |
164 | } | |
165 | } | |
166 | return fTriggerCrates.GetSize(); | |
167 | } | |
168 | ||
169 | ||
170 | //______________________________________________________________________________ | |
171 | AliMUONTriggerCrateConfig* AliMUONRegionalTriggerConfig::FindTriggerCrate(TString name, | |
172 | Bool_t warn) const { | |
173 | /// Return trigger crate with given name | |
174 | ||
175 | AliMUONTriggerCrateConfig* crate | |
176 | = (AliMUONTriggerCrateConfig*) fTriggerCrates.GetValue(name.Data()); | |
177 | ||
178 | if ( ! crate && warn ) { | |
179 | AliErrorStream() | |
180 | << "Trigger crate with name = " << name.Data() << " not defined." << endl; | |
181 | } | |
182 | ||
183 | return crate; | |
184 | } | |
185 | ||
186 | //______________________________________________________________________________ | |
187 | Int_t AliMUONRegionalTriggerConfig::GetNofTriggerCrates() const | |
188 | { | |
189 | /// Return number of trigger crates | |
190 | ||
191 | return fTriggerCrates.GetSize(); | |
192 | } | |
193 | ||
194 | //______________________________________________________________________________ | |
195 | AliMUONTriggerCrateConfig* AliMUONRegionalTriggerConfig::GetTriggerCrate(Int_t index) const | |
196 | { | |
197 | /// Return the trigger crates with given index; | |
198 | ||
199 | return static_cast<AliMUONTriggerCrateConfig*>(fTriggerCrates.GetObject(index)); | |
200 | } | |
201 | ||
202 | //______________________________________________________________________________ | |
203 | AliMUONTriggerCrateConfig* AliMUONRegionalTriggerConfig::GetTriggerCrateFast(Int_t index) const | |
204 | { | |
205 | /// Return the trigger crates with given index; | |
206 | /// the index is not checked as we use the fast method in AliMpExMap. | |
207 | ||
208 | return static_cast<AliMUONTriggerCrateConfig*>(fTriggerCrates.GetObjectFast(index)); | |
209 | } | |
210 | ||
211 | ||
212 | ||
213 |