AliRoot Core  3dc7879 (3dc7879)
AliMUONTriggerStoreV1.cxx
Go to the documentation of this file.
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 
18 //-----------------------------------------------------------------------------
26 //-----------------------------------------------------------------------------
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 using std::cout;
39 using std::endl;
41 ClassImp(AliMUONTriggerStoreV1)
43 
44 //_____________________________________________________________________________
46 fLocal(new TClonesArray("AliMUONLocalTrigger",242)),
47 fRegional(new TClonesArray("AliMUONRegionalTrigger",16)),
48 fGlobal(new TClonesArray("AliMUONGlobalTrigger",1)),
49 fEmptyLocal(new TClonesArray("AliMUONLocalTrigger",242))
50 {
52  fLocal->SetOwner(kTRUE);
53  fRegional->SetOwner(kTRUE);
54  fGlobal->SetOwner(kTRUE);
55  fEmptyLocal->SetOwner(kTRUE);
56 }
57 
58 //_____________________________________________________________________________
60 {
62  delete fLocal;
63  delete fRegional;
64  delete fGlobal;
65  delete fEmptyLocal;
66 }
67 
68 //_____________________________________________________________________________
69 void
71 {
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 {
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
124 {
126  new((*fGlobal)[0]) AliMUONGlobalTrigger(globalTrigger);
127 }
128 
129 //_____________________________________________________________________________
130 void
132 {
134  new((*fRegional)[fRegional->GetLast()+1]) AliMUONRegionalTrigger(regionalTrigger);
135 }
136 
137 //_____________________________________________________________________________
138 TIterator*
140 {
142  return fLocal->MakeIterator();
143 }
144 
145 //_____________________________________________________________________________
146 TIterator*
148 {
150  return fRegional->MakeIterator();
151 }
152 
153 //_____________________________________________________________________________
155 AliMUONTriggerStoreV1::FindLocal(Int_t boardNumber) const
156 {
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<=242 )
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 //_____________________________________________________________________________
192 AliMUONTriggerStoreV1::FindRegional(Int_t boardNumber) const
193 {
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 //_____________________________________________________________________________
209 {
211  return static_cast<AliMUONGlobalTrigger*>(fGlobal->At(0));
212 }
213 
214 //_____________________________________________________________________________
215 void
217 {
219  fLocal->Clear("C");
220  fRegional->Clear("C");
221  fGlobal->Clear("C");
222  fEmptyLocal->Clear("C");
223 }
224 
225 //_____________________________________________________________________________
226 Int_t
228 {
230  return fLocal->GetSize();
231 }
232 
233 //_____________________________________________________________________________
234 void
235 AliMUONTriggerStoreV1::Print(Option_t* what, Option_t* opt) const
236 {
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 
virtual Bool_t Connect(TTree &tree, Bool_t alone=kTRUE) const
Connect us to a TTree (only valid if CanConnect()==kTRUE)
Bool_t SetAddress(TTree &tree, const char *branchName, void *address) const
virtual void Add(const AliMUONLocalTrigger &localTrigger)
Add local trigger.
Implementation of AliMUONVTriggerStore.
virtual Int_t GetSize() const
The number of objects stored.
virtual AliMUONRegionalTrigger * FindRegional(Int_t boardNumber) const
Find a regional trigger by the board number (not an index, it is a number really) ...
Int_t GetId() const
Return regional id.
Helper class to ease TTree (MUON) branches manipulations.
Base class of a trigger information store.
virtual void Print(Option_t *wildcard, Option_t *opt) const
Print, with option, all objects whose name matches wildcard.
TClonesArray * fEmptyLocal
! internal array of empty local trigger
TClonesArray ** RegionalPtr() const
Return the address of the array of regional trigger information.
Reconstructed regional Trigger object.
virtual void SetGlobal(const AliMUONGlobalTrigger &globalTrigger)
Set global trigger.
TTree * tree
virtual void Print(Option_t *opt="") const
Reconstructed Local Trigger object.
virtual TIterator * CreateLocalIterator() const
Create iterator on local trigger.
TClonesArray ** GlobalPtr() const
Return the address of the array of global trigger information.
virtual TIterator * CreateRegionalIterator() const
Create iterator on regional trigger.
virtual AliMUONGlobalTrigger * Global() const
Return global trigger.
TClonesArray * fRegional
internal array of regional trigger information
TClonesArray * fLocal
internal array of local trigger information
void UpdateBranchStatuses(TTree &tree, const char *pattern) const
Global trigger object.
Bool_t MakeBranch(TTree &tree, const char *storeClassName, const char *branchClassName, const char *branchName, void *address, Int_t bufferSize=4000, Int_t splitLevel=99) const
virtual void Clear(Option_t *opt="")
Clear ourselves (i.e. Reset)
virtual AliMUONLocalTrigger * FindLocal(Int_t boardNumber) const
Find a local trigger by the board number (not an index, it is a number really)
TClonesArray ** LocalPtr() const
Return the address of the array of local trigger information.
Int_t LoCircuit() const
Return Circuit number.
TClonesArray * fGlobal
internal array of global trigger information
void SetLoCircuit(Int_t loCir)
Set Circuit number.