]>
Commit | Line | Data |
---|---|---|
f6bdb753 | 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 | ||
3d1463c8 | 18 | //----------------------------------------------------------------------------- |
f6bdb753 | 19 | /// \class AliMUONTriggerStoreV1 |
20 | /// | |
21 | /// Implementation of AliMUONVTriggerStore, which is backward compatible, | |
22 | /// i.e. should be able to read back old TreeR and TreeD files, produced | |
23 | /// before the introduction of the AliMUONVStore concept. | |
24 | /// | |
25 | /// \author Laurent Aphecetche, Subatech | |
3d1463c8 | 26 | //----------------------------------------------------------------------------- |
f6bdb753 | 27 | |
28 | #include "AliMUONTriggerStoreV1.h" | |
29 | ||
30 | #include "AliMUONGlobalTrigger.h" | |
31 | #include "AliMUONLocalTrigger.h" | |
32 | #include "AliMUONRegionalTrigger.h" | |
33 | #include "AliMUONTreeManager.h" | |
34 | #include <Riostream.h> | |
35 | #include <TClonesArray.h> | |
36 | #include <TTree.h> | |
37 | ||
b80faac0 | 38 | using std::cout; |
39 | using std::endl; | |
f6bdb753 | 40 | /// \cond CLASSIMP |
41 | ClassImp(AliMUONTriggerStoreV1) | |
42 | /// \endcond | |
43 | ||
44 | //_____________________________________________________________________________ | |
45 | AliMUONTriggerStoreV1::AliMUONTriggerStoreV1() : AliMUONVTriggerStore(), | |
46 | fLocal(new TClonesArray("AliMUONLocalTrigger",234)), | |
47 | fRegional(new TClonesArray("AliMUONRegionalTrigger",16)), | |
48 | fGlobal(new TClonesArray("AliMUONGlobalTrigger",1)), | |
49 | fEmptyLocal(new TClonesArray("AliMUONLocalTrigger",234)) | |
50 | { | |
51 | /// ctor | |
52 | fLocal->SetOwner(kTRUE); | |
53 | fRegional->SetOwner(kTRUE); | |
54 | fGlobal->SetOwner(kTRUE); | |
55 | fEmptyLocal->SetOwner(kTRUE); | |
56 | } | |
57 | ||
58 | //_____________________________________________________________________________ | |
59 | AliMUONTriggerStoreV1::~AliMUONTriggerStoreV1() | |
60 | { | |
61 | /// dtor | |
62 | delete fLocal; | |
63 | delete fRegional; | |
64 | delete fGlobal; | |
65 | delete fEmptyLocal; | |
66 | } | |
67 | ||
68 | //_____________________________________________________________________________ | |
69 | void | |
70 | AliMUONTriggerStoreV1::Add(const AliMUONLocalTrigger& localTrigger) | |
71 | { | |
72 | /// Add local information | |
73 | /// If the local board has no information (IsNull), we | |
74 | /// add it in the fEmpty array | |
75 | /// This is really an implementation choice, to store empty boards | |
76 | /// in order to be able to return them, if asked for, as is the case | |
77 | /// in some client code. Note that only the non-empty boards | |
78 | /// are streamed to disk. | |
79 | /// | |
80 | ||
81 | if ( !localTrigger.IsNull() ) | |
82 | { | |
83 | new((*fLocal)[fLocal->GetLast()+1]) AliMUONLocalTrigger(localTrigger); | |
84 | ||
85 | } | |
86 | else | |
87 | { | |
88 | new((*fEmptyLocal)[fEmptyLocal->GetLast()+1]) AliMUONLocalTrigger(localTrigger); | |
89 | } | |
90 | } | |
91 | ||
92 | //_____________________________________________________________________________ | |
93 | Bool_t | |
94 | AliMUONTriggerStoreV1::Connect(TTree& tree, Bool_t alone) const | |
95 | { | |
96 | /// Connect this store to the tree | |
97 | AliMUONTreeManager tman; | |
98 | Bool_t ok(kTRUE); | |
99 | ||
100 | Bool_t isMaking = ( tree.GetBranch("MUONLocalTrigger") == 0 ); | |
101 | ||
102 | if ( isMaking ) | |
103 | { | |
104 | ok = ok && tman.MakeBranch(tree,ClassName(),"TClonesArray", | |
105 | "MUONLocalTrigger",LocalPtr()); | |
106 | ok = ok && tman.MakeBranch(tree,ClassName(),"TClonesArray", | |
107 | "MUONRegionalTrigger",RegionalPtr()); | |
108 | ok = ok && tman.MakeBranch(tree,ClassName(),"TClonesArray", | |
109 | "MUONGlobalTrigger",GlobalPtr()); | |
110 | } | |
111 | else | |
112 | { | |
113 | if ( alone ) tman.UpdateBranchStatuses(tree,"Trigger"); | |
114 | ok = ok && tman.SetAddress(tree,"MUONLocalTrigger",LocalPtr()); | |
115 | ok = ok && tman.SetAddress(tree,"MUONRegionalTrigger",RegionalPtr()); | |
116 | ok = ok && tman.SetAddress(tree,"MUONGlobalTrigger",GlobalPtr()); | |
117 | } | |
118 | return ok; | |
119 | } | |
120 | ||
121 | //_____________________________________________________________________________ | |
122 | void | |
123 | AliMUONTriggerStoreV1::SetGlobal(const AliMUONGlobalTrigger& globalTrigger) | |
124 | { | |
125 | /// Set the global information | |
126 | new((*fGlobal)[0]) AliMUONGlobalTrigger(globalTrigger); | |
127 | } | |
128 | ||
129 | //_____________________________________________________________________________ | |
130 | void | |
131 | AliMUONTriggerStoreV1::Add(const AliMUONRegionalTrigger& regionalTrigger) | |
132 | { | |
133 | /// Add regional information | |
134 | new((*fRegional)[fRegional->GetLast()+1]) AliMUONRegionalTrigger(regionalTrigger); | |
135 | } | |
136 | ||
137 | //_____________________________________________________________________________ | |
138 | TIterator* | |
139 | AliMUONTriggerStoreV1::CreateLocalIterator() const | |
140 | { | |
141 | /// Return iterator on local cards | |
142 | return fLocal->MakeIterator(); | |
143 | } | |
144 | ||
145 | //_____________________________________________________________________________ | |
146 | TIterator* | |
147 | AliMUONTriggerStoreV1::CreateRegionalIterator() const | |
148 | { | |
149 | /// Return iterator on regional cards | |
150 | return fRegional->MakeIterator(); | |
151 | } | |
152 | ||
153 | //_____________________________________________________________________________ | |
154 | AliMUONLocalTrigger* | |
155 | AliMUONTriggerStoreV1::FindLocal(Int_t boardNumber) const | |
156 | { | |
157 | /// Find a local board, by its *number* (not to be confused with its index, | |
158 | /// which used to be the key) | |
159 | /// | |
160 | ||
161 | for ( Int_t i = 0; i <= fLocal->GetLast(); ++i ) | |
162 | { | |
163 | AliMUONLocalTrigger* local = static_cast<AliMUONLocalTrigger*>(fLocal->At(i)); | |
164 | if (local && local->LoCircuit()==boardNumber) | |
165 | { | |
166 | return local; | |
167 | } | |
168 | } | |
169 | ||
170 | for ( Int_t i = 0; i <= fEmptyLocal->GetLast(); ++i ) | |
171 | { | |
172 | AliMUONLocalTrigger* local = static_cast<AliMUONLocalTrigger*>(fEmptyLocal->At(i)); | |
173 | if (local && local->LoCircuit()==boardNumber) | |
174 | { | |
175 | return local; | |
176 | } | |
177 | } | |
178 | ||
179 | if ( boardNumber>=1 && boardNumber<=234 ) | |
180 | { | |
181 | AliMUONLocalTrigger empty; | |
182 | empty.SetLoCircuit(boardNumber); | |
183 | new((*fEmptyLocal)[fEmptyLocal->GetLast()+1]) AliMUONLocalTrigger(empty); | |
184 | return FindLocal(boardNumber); | |
185 | } | |
186 | ||
187 | return 0x0; | |
188 | } | |
189 | ||
190 | //_____________________________________________________________________________ | |
191 | AliMUONRegionalTrigger* | |
192 | AliMUONTriggerStoreV1::FindRegional(Int_t boardNumber) const | |
193 | { | |
194 | /// Return a given regional board | |
195 | for ( Int_t i = 0; i <= fRegional->GetLast(); ++i ) | |
196 | { | |
197 | AliMUONRegionalTrigger* regional = static_cast<AliMUONRegionalTrigger*>(fRegional->At(i)); | |
198 | if (regional && regional->GetId()==boardNumber) | |
199 | { | |
200 | return regional; | |
201 | } | |
202 | } | |
203 | return 0x0; | |
204 | } | |
205 | ||
206 | //_____________________________________________________________________________ | |
207 | AliMUONGlobalTrigger* | |
208 | AliMUONTriggerStoreV1::Global() const | |
209 | { | |
210 | /// Return global trigger | |
211 | return static_cast<AliMUONGlobalTrigger*>(fGlobal->At(0)); | |
212 | } | |
213 | ||
214 | //_____________________________________________________________________________ | |
215 | void | |
216 | AliMUONTriggerStoreV1::Clear(Option_t*) | |
217 | { | |
218 | /// Reset | |
219 | fLocal->Clear("C"); | |
220 | fRegional->Clear("C"); | |
221 | fGlobal->Clear("C"); | |
222 | fEmptyLocal->Clear("C"); | |
223 | } | |
224 | ||
225 | //_____________________________________________________________________________ | |
226 | Int_t | |
227 | AliMUONTriggerStoreV1::GetSize() const | |
228 | { | |
229 | /// Number of non-empty local boards we hold | |
230 | return fLocal->GetSize(); | |
231 | } | |
232 | ||
233 | //_____________________________________________________________________________ | |
234 | void | |
235 | AliMUONTriggerStoreV1::Print(Option_t* what, Option_t* opt) const | |
236 | { | |
237 | /// Printout | |
238 | /// \param what used to tell what to print, can be GLOBAL, LOCAL, REGIONAL | |
239 | /// or ALL | |
240 | /// \param opt is passed to the local, regional, global object | |
241 | /// | |
242 | ||
243 | TString swhat(what); | |
244 | swhat.ToUpper(); | |
245 | ||
246 | if ( swhat.Length() == 0 ) swhat = "ALL"; | |
247 | ||
248 | if ( swhat.Contains("GLOBAL") || swhat.Contains("ALL") ) | |
249 | { | |
250 | if ( fGlobal ) | |
251 | { | |
252 | cout << "Global:" << endl; | |
253 | fGlobal->Print("",opt); | |
254 | } | |
255 | else | |
256 | { | |
257 | cout << "No GlobalTrigger information" << endl; | |
258 | } | |
259 | } | |
260 | ||
261 | if ( fLocal && ( swhat.Contains("LOCAL")|| swhat.Contains("ALL") ) ) | |
262 | { | |
263 | // make loops instead of just relying on fLocal | |
264 | // to insure backward compatibility with trees where all local boards where | |
265 | // stored (even null ones) | |
266 | ||
267 | TIter next(fLocal); | |
268 | AliMUONLocalTrigger* local; | |
269 | Int_t n(0); | |
270 | ||
271 | while ( ( local = static_cast<AliMUONLocalTrigger*>(next()) ) ) | |
272 | { | |
273 | if ( local->IsNull() ) ++n; | |
274 | } | |
275 | ||
276 | cout << Form("Local: %d cards (and %d null ones)", | |
277 | fLocal->GetLast()+1,n) << endl; | |
278 | ||
279 | next.Reset(); | |
280 | ||
281 | while ( ( local = static_cast<AliMUONLocalTrigger*>(next()) ) ) | |
282 | { | |
283 | if ( !local->IsNull() ) | |
284 | { | |
285 | local->Print(opt); | |
286 | } | |
287 | } | |
288 | } | |
289 | ||
290 | if ( fRegional && ( swhat.Contains("REGIONAL") || swhat.Contains("ALL") ) ) | |
291 | { | |
292 | fRegional->Print("",opt); | |
293 | } | |
294 | } | |
295 |