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