]> git.uio.no Git - u/mrichter/AliRoot.git/blame - MUON/AliMUONTriggerStoreV1.cxx
ATO-98 bfield(omega tau) used for the diestortion calculation used as an argument...
[u/mrichter/AliRoot.git] / MUON / AliMUONTriggerStoreV1.cxx
CommitLineData
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 38using std::cout;
39using std::endl;
f6bdb753 40/// \cond CLASSIMP
41ClassImp(AliMUONTriggerStoreV1)
42/// \endcond
43
44//_____________________________________________________________________________
45AliMUONTriggerStoreV1::AliMUONTriggerStoreV1() : AliMUONVTriggerStore(),
12549f10 46fLocal(new TClonesArray("AliMUONLocalTrigger",242)),
f6bdb753 47fRegional(new TClonesArray("AliMUONRegionalTrigger",16)),
48fGlobal(new TClonesArray("AliMUONGlobalTrigger",1)),
12549f10 49fEmptyLocal(new TClonesArray("AliMUONLocalTrigger",242))
f6bdb753 50{
51 /// ctor
52 fLocal->SetOwner(kTRUE);
53 fRegional->SetOwner(kTRUE);
54 fGlobal->SetOwner(kTRUE);
55 fEmptyLocal->SetOwner(kTRUE);
56}
57
58//_____________________________________________________________________________
59AliMUONTriggerStoreV1::~AliMUONTriggerStoreV1()
60{
61 /// dtor
62 delete fLocal;
63 delete fRegional;
64 delete fGlobal;
65 delete fEmptyLocal;
66}
67
68//_____________________________________________________________________________
69void
70AliMUONTriggerStoreV1::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//_____________________________________________________________________________
93Bool_t
94AliMUONTriggerStoreV1::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//_____________________________________________________________________________
122void
123AliMUONTriggerStoreV1::SetGlobal(const AliMUONGlobalTrigger& globalTrigger)
124{
125 /// Set the global information
126 new((*fGlobal)[0]) AliMUONGlobalTrigger(globalTrigger);
127}
128
129//_____________________________________________________________________________
130void
131AliMUONTriggerStoreV1::Add(const AliMUONRegionalTrigger& regionalTrigger)
132{
133 /// Add regional information
134 new((*fRegional)[fRegional->GetLast()+1]) AliMUONRegionalTrigger(regionalTrigger);
135}
136
137//_____________________________________________________________________________
138TIterator*
139AliMUONTriggerStoreV1::CreateLocalIterator() const
140{
141 /// Return iterator on local cards
142 return fLocal->MakeIterator();
143}
144
145//_____________________________________________________________________________
146TIterator*
147AliMUONTriggerStoreV1::CreateRegionalIterator() const
148{
149 /// Return iterator on regional cards
150 return fRegional->MakeIterator();
151}
152
153//_____________________________________________________________________________
154AliMUONLocalTrigger*
155AliMUONTriggerStoreV1::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
12549f10 179 if ( boardNumber>=1 && boardNumber<=242 )
f6bdb753 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//_____________________________________________________________________________
191AliMUONRegionalTrigger*
192AliMUONTriggerStoreV1::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//_____________________________________________________________________________
207AliMUONGlobalTrigger*
208AliMUONTriggerStoreV1::Global() const
209{
210 /// Return global trigger
211 return static_cast<AliMUONGlobalTrigger*>(fGlobal->At(0));
212}
213
214//_____________________________________________________________________________
215void
216AliMUONTriggerStoreV1::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//_____________________________________________________________________________
226Int_t
227AliMUONTriggerStoreV1::GetSize() const
228{
229 /// Number of non-empty local boards we hold
230 return fLocal->GetSize();
231}
232
233//_____________________________________________________________________________
234void
235AliMUONTriggerStoreV1::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