]>
Commit | Line | Data |
---|---|---|
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 "AliMpHelper.h" | |
30 | #include "AliMpExMapIterator.h" | |
31 | #include "AliMpRegionalTrigger.h" | |
32 | #include "AliLog.h" | |
33 | ||
34 | #include <TArrayI.h> | |
35 | #include <Riostream.h> | |
36 | #include <TClass.h> | |
37 | #include <TSystem.h> | |
38 | #include <TList.h> | |
39 | ||
40 | ||
41 | using std::cout; | |
42 | using std::endl; | |
43 | using std::ifstream; | |
44 | using std::ios; | |
45 | /// \cond CLASSIMP | |
46 | ClassImp(AliMUONRegionalTriggerConfig) | |
47 | /// \endcond | |
48 | ||
49 | ||
50 | //______________________________________________________________________________ | |
51 | AliMUONRegionalTriggerConfig::AliMUONRegionalTriggerConfig() | |
52 | : TObject(), | |
53 | fTriggerCrates() | |
54 | { | |
55 | /// Standard constructor | |
56 | ||
57 | fTriggerCrates.SetOwner(true); | |
58 | fTriggerCrates.SetSize(AliMpConstants::LocalBoardNofChannels()); | |
59 | } | |
60 | ||
61 | //______________________________________________________________________________ | |
62 | AliMUONRegionalTriggerConfig::AliMUONRegionalTriggerConfig(const AliMUONRegionalTriggerConfig& rhs) | |
63 | : TObject(rhs), | |
64 | fTriggerCrates(rhs.fTriggerCrates) | |
65 | { | |
66 | /// Copy constructor | |
67 | } | |
68 | ||
69 | //______________________________________________________________________________ | |
70 | AliMUONRegionalTriggerConfig& AliMUONRegionalTriggerConfig::operator=(const AliMUONRegionalTriggerConfig& rhs) | |
71 | { | |
72 | /// Assignment operator | |
73 | ||
74 | // check assignment to self | |
75 | if (this == &rhs) return *this; | |
76 | ||
77 | // base class assignment | |
78 | TObject::operator=(rhs); | |
79 | ||
80 | // assignment operator | |
81 | fTriggerCrates = rhs.fTriggerCrates; | |
82 | ||
83 | return *this; | |
84 | } | |
85 | ||
86 | //______________________________________________________________________________ | |
87 | AliMUONRegionalTriggerConfig::~AliMUONRegionalTriggerConfig() | |
88 | { | |
89 | /// Destructor | |
90 | } | |
91 | ||
92 | // | |
93 | // public methods | |
94 | // | |
95 | ||
96 | //______________________________________________________________________________ | |
97 | Int_t AliMUONRegionalTriggerConfig::ReadData(const TString& fileName) | |
98 | { | |
99 | /// Load the Regional trigger from ASCII data file | |
100 | ||
101 | // Read first data contained in mapping object | |
102 | // | |
103 | AliMpRegionalTrigger mpRegionalTrigger; | |
104 | mpRegionalTrigger.SetTriggerCratesOwner(kFALSE); | |
105 | if ( ! mpRegionalTrigger.ReadData(fileName) ) { | |
106 | AliErrorStream() | |
107 | << "Reading mapping regional trigger from file " << fileName.Data() << " failed." | |
108 | << endl; | |
109 | return 0; | |
110 | } | |
111 | ||
112 | // Fill calibration object from mapping object | |
113 | // | |
114 | TIterator* it = mpRegionalTrigger.CreateCrateIterator(); | |
115 | AliMpTriggerCrate* mpTriggerCrate; | |
116 | while ( ( mpTriggerCrate = (AliMpTriggerCrate*)it->Next() ) ) { | |
117 | fTriggerCrates.Add( | |
118 | mpTriggerCrate->GetName(), new AliMUONTriggerCrateConfig(mpTriggerCrate)); | |
119 | } | |
120 | delete it; | |
121 | ||
122 | // | |
123 | ||
124 | // Read remaining calibration data from file | |
125 | // | |
126 | ifstream in(fileName.Data(), ios::in); | |
127 | if ( ! in.good() ) { | |
128 | AliErrorStream() | |
129 | << "Local Trigger Board Mapping File " << fileName.Data() << " not found" << endl; | |
130 | return 0; | |
131 | } | |
132 | ||
133 | UShort_t mask; | |
134 | Int_t mode, coincidence; | |
135 | Int_t nofBoards; | |
136 | char line[80]; | |
137 | ||
138 | // decode file and store in objects | |
139 | while (!in.eof()) | |
140 | { | |
141 | // Get name | |
142 | in.getline(line,80); | |
143 | if (!strlen(line)) break; | |
144 | TString crateName(AliMpHelper::Normalize(line)); | |
145 | ||
146 | in.getline(line,80); | |
147 | ||
148 | // read mode | |
149 | in.getline(line,80); | |
150 | sscanf(line,"%d",&mode); | |
151 | ||
152 | // read coincidence | |
153 | in.getline(line,80); | |
154 | sscanf(line,"%d",&coincidence); | |
155 | ||
156 | // read mask | |
157 | in.getline(line,80); | |
158 | sscanf(line,"%hx",&mask); | |
159 | ||
160 | // read # local board | |
161 | in.getline(line,80); | |
162 | sscanf(line,"%d",&nofBoards); | |
163 | ||
164 | AliMUONTriggerCrateConfig* crateConfig | |
165 | = (AliMUONTriggerCrateConfig*)(fTriggerCrates.GetValue(crateName.Data())); | |
166 | ||
167 | // This should never happen, but let's test it anyway | |
168 | if ( ! crateConfig ) { | |
169 | AliErrorStream() | |
170 | << "Cannot find AliMUONTriggerCrateConfig " << crateName.Data() << endl; | |
171 | return 0; | |
172 | } | |
173 | ||
174 | crateConfig->SetMode(mode); | |
175 | crateConfig->SetCoinc(coincidence); | |
176 | crateConfig->SetMask(mask); | |
177 | ||
178 | // Skipp local board data | |
179 | for ( Int_t i = 0; i < 3*nofBoards; ++i ) | |
180 | in.getline(line,80); | |
181 | } | |
182 | ||
183 | return fTriggerCrates.GetSize(); | |
184 | } | |
185 | ||
186 | //______________________________________________________________________________ | |
187 | AliMUONTriggerCrateConfig* AliMUONRegionalTriggerConfig::FindTriggerCrate(TString name, | |
188 | Bool_t warn) const | |
189 | { | |
190 | /// Return trigger crate with given name | |
191 | ||
192 | AliMUONTriggerCrateConfig* crate | |
193 | = (AliMUONTriggerCrateConfig*) fTriggerCrates.GetValue(name.Data()); | |
194 | ||
195 | if ( ! crate && warn ) { | |
196 | AliErrorStream() | |
197 | << "Trigger crate with name = " << name.Data() << " not defined." << endl; | |
198 | } | |
199 | ||
200 | return crate; | |
201 | } | |
202 | ||
203 | //______________________________________________________________________________ | |
204 | Int_t AliMUONRegionalTriggerConfig::GetNofTriggerCrates() const | |
205 | { | |
206 | /// Return number of trigger crates | |
207 | ||
208 | return fTriggerCrates.GetSize(); | |
209 | } | |
210 | ||
211 | //______________________________________________________________________________ | |
212 | TIterator* | |
213 | AliMUONRegionalTriggerConfig::CreateCrateIterator() const | |
214 | { | |
215 | /// Return trigger crates iterator | |
216 | return fTriggerCrates.CreateIterator(); | |
217 | } | |
218 | ||
219 | ||
220 | ||
221 |