1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
18 //-----------------------------------------------------------------------------
19 /// \class AliMUONTriggerStoreV1
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.
25 /// \author Laurent Aphecetche, Subatech
26 //-----------------------------------------------------------------------------
28 #include "AliMUONTriggerStoreV1.h"
30 #include "AliMUONGlobalTrigger.h"
31 #include "AliMUONLocalTrigger.h"
32 #include "AliMUONRegionalTrigger.h"
33 #include "AliMUONTreeManager.h"
34 #include <Riostream.h>
35 #include <TClonesArray.h>
41 ClassImp(AliMUONTriggerStoreV1)
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))
52 fLocal->SetOwner(kTRUE);
53 fRegional->SetOwner(kTRUE);
54 fGlobal->SetOwner(kTRUE);
55 fEmptyLocal->SetOwner(kTRUE);
58 //_____________________________________________________________________________
59 AliMUONTriggerStoreV1::~AliMUONTriggerStoreV1()
68 //_____________________________________________________________________________
70 AliMUONTriggerStoreV1::Add(const AliMUONLocalTrigger& localTrigger)
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.
81 if ( !localTrigger.IsNull() )
83 new((*fLocal)[fLocal->GetLast()+1]) AliMUONLocalTrigger(localTrigger);
88 new((*fEmptyLocal)[fEmptyLocal->GetLast()+1]) AliMUONLocalTrigger(localTrigger);
92 //_____________________________________________________________________________
94 AliMUONTriggerStoreV1::Connect(TTree& tree, Bool_t alone) const
96 /// Connect this store to the tree
97 AliMUONTreeManager tman;
100 Bool_t isMaking = ( tree.GetBranch("MUONLocalTrigger") == 0 );
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());
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());
121 //_____________________________________________________________________________
123 AliMUONTriggerStoreV1::SetGlobal(const AliMUONGlobalTrigger& globalTrigger)
125 /// Set the global information
126 new((*fGlobal)[0]) AliMUONGlobalTrigger(globalTrigger);
129 //_____________________________________________________________________________
131 AliMUONTriggerStoreV1::Add(const AliMUONRegionalTrigger& regionalTrigger)
133 /// Add regional information
134 new((*fRegional)[fRegional->GetLast()+1]) AliMUONRegionalTrigger(regionalTrigger);
137 //_____________________________________________________________________________
139 AliMUONTriggerStoreV1::CreateLocalIterator() const
141 /// Return iterator on local cards
142 return fLocal->MakeIterator();
145 //_____________________________________________________________________________
147 AliMUONTriggerStoreV1::CreateRegionalIterator() const
149 /// Return iterator on regional cards
150 return fRegional->MakeIterator();
153 //_____________________________________________________________________________
155 AliMUONTriggerStoreV1::FindLocal(Int_t boardNumber) const
157 /// Find a local board, by its *number* (not to be confused with its index,
158 /// which used to be the key)
161 for ( Int_t i = 0; i <= fLocal->GetLast(); ++i )
163 AliMUONLocalTrigger* local = static_cast<AliMUONLocalTrigger*>(fLocal->At(i));
164 if (local && local->LoCircuit()==boardNumber)
170 for ( Int_t i = 0; i <= fEmptyLocal->GetLast(); ++i )
172 AliMUONLocalTrigger* local = static_cast<AliMUONLocalTrigger*>(fEmptyLocal->At(i));
173 if (local && local->LoCircuit()==boardNumber)
179 if ( boardNumber>=1 && boardNumber<=234 )
181 AliMUONLocalTrigger empty;
182 empty.SetLoCircuit(boardNumber);
183 new((*fEmptyLocal)[fEmptyLocal->GetLast()+1]) AliMUONLocalTrigger(empty);
184 return FindLocal(boardNumber);
190 //_____________________________________________________________________________
191 AliMUONRegionalTrigger*
192 AliMUONTriggerStoreV1::FindRegional(Int_t boardNumber) const
194 /// Return a given regional board
195 for ( Int_t i = 0; i <= fRegional->GetLast(); ++i )
197 AliMUONRegionalTrigger* regional = static_cast<AliMUONRegionalTrigger*>(fRegional->At(i));
198 if (regional && regional->GetId()==boardNumber)
206 //_____________________________________________________________________________
207 AliMUONGlobalTrigger*
208 AliMUONTriggerStoreV1::Global() const
210 /// Return global trigger
211 return static_cast<AliMUONGlobalTrigger*>(fGlobal->At(0));
214 //_____________________________________________________________________________
216 AliMUONTriggerStoreV1::Clear(Option_t*)
220 fRegional->Clear("C");
222 fEmptyLocal->Clear("C");
225 //_____________________________________________________________________________
227 AliMUONTriggerStoreV1::GetSize() const
229 /// Number of non-empty local boards we hold
230 return fLocal->GetSize();
233 //_____________________________________________________________________________
235 AliMUONTriggerStoreV1::Print(Option_t* what, Option_t* opt) const
238 /// \param what used to tell what to print, can be GLOBAL, LOCAL, REGIONAL
240 /// \param opt is passed to the local, regional, global object
246 if ( swhat.Length() == 0 ) swhat = "ALL";
248 if ( swhat.Contains("GLOBAL") || swhat.Contains("ALL") )
252 cout << "Global:" << endl;
253 fGlobal->Print("",opt);
257 cout << "No GlobalTrigger information" << endl;
261 if ( fLocal && ( swhat.Contains("LOCAL")|| swhat.Contains("ALL") ) )
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)
268 AliMUONLocalTrigger* local;
271 while ( ( local = static_cast<AliMUONLocalTrigger*>(next()) ) )
273 if ( local->IsNull() ) ++n;
276 cout << Form("Local: %d cards (and %d null ones)",
277 fLocal->GetLast()+1,n) << endl;
281 while ( ( local = static_cast<AliMUONLocalTrigger*>(next()) ) )
283 if ( !local->IsNull() )
290 if ( fRegional && ( swhat.Contains("REGIONAL") || swhat.Contains("ALL") ) )
292 fRegional->Print("",opt);