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>
39 ClassImp(AliMUONTriggerStoreV1)
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))
50 fLocal->SetOwner(kTRUE);
51 fRegional->SetOwner(kTRUE);
52 fGlobal->SetOwner(kTRUE);
53 fEmptyLocal->SetOwner(kTRUE);
56 //_____________________________________________________________________________
57 AliMUONTriggerStoreV1::~AliMUONTriggerStoreV1()
66 //_____________________________________________________________________________
68 AliMUONTriggerStoreV1::Add(const AliMUONLocalTrigger& localTrigger)
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.
79 if ( !localTrigger.IsNull() )
81 new((*fLocal)[fLocal->GetLast()+1]) AliMUONLocalTrigger(localTrigger);
86 new((*fEmptyLocal)[fEmptyLocal->GetLast()+1]) AliMUONLocalTrigger(localTrigger);
90 //_____________________________________________________________________________
92 AliMUONTriggerStoreV1::Connect(TTree& tree, Bool_t alone) const
94 /// Connect this store to the tree
95 AliMUONTreeManager tman;
98 Bool_t isMaking = ( tree.GetBranch("MUONLocalTrigger") == 0 );
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());
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());
119 //_____________________________________________________________________________
121 AliMUONTriggerStoreV1::SetGlobal(const AliMUONGlobalTrigger& globalTrigger)
123 /// Set the global information
124 new((*fGlobal)[0]) AliMUONGlobalTrigger(globalTrigger);
127 //_____________________________________________________________________________
129 AliMUONTriggerStoreV1::Add(const AliMUONRegionalTrigger& regionalTrigger)
131 /// Add regional information
132 new((*fRegional)[fRegional->GetLast()+1]) AliMUONRegionalTrigger(regionalTrigger);
135 //_____________________________________________________________________________
137 AliMUONTriggerStoreV1::CreateLocalIterator() const
139 /// Return iterator on local cards
140 return fLocal->MakeIterator();
143 //_____________________________________________________________________________
145 AliMUONTriggerStoreV1::CreateRegionalIterator() const
147 /// Return iterator on regional cards
148 return fRegional->MakeIterator();
151 //_____________________________________________________________________________
153 AliMUONTriggerStoreV1::FindLocal(Int_t boardNumber) const
155 /// Find a local board, by its *number* (not to be confused with its index,
156 /// which used to be the key)
159 for ( Int_t i = 0; i <= fLocal->GetLast(); ++i )
161 AliMUONLocalTrigger* local = static_cast<AliMUONLocalTrigger*>(fLocal->At(i));
162 if (local && local->LoCircuit()==boardNumber)
168 for ( Int_t i = 0; i <= fEmptyLocal->GetLast(); ++i )
170 AliMUONLocalTrigger* local = static_cast<AliMUONLocalTrigger*>(fEmptyLocal->At(i));
171 if (local && local->LoCircuit()==boardNumber)
177 if ( boardNumber>=1 && boardNumber<=234 )
179 AliMUONLocalTrigger empty;
180 empty.SetLoCircuit(boardNumber);
181 new((*fEmptyLocal)[fEmptyLocal->GetLast()+1]) AliMUONLocalTrigger(empty);
182 return FindLocal(boardNumber);
188 //_____________________________________________________________________________
189 AliMUONRegionalTrigger*
190 AliMUONTriggerStoreV1::FindRegional(Int_t boardNumber) const
192 /// Return a given regional board
193 for ( Int_t i = 0; i <= fRegional->GetLast(); ++i )
195 AliMUONRegionalTrigger* regional = static_cast<AliMUONRegionalTrigger*>(fRegional->At(i));
196 if (regional && regional->GetId()==boardNumber)
204 //_____________________________________________________________________________
205 AliMUONGlobalTrigger*
206 AliMUONTriggerStoreV1::Global() const
208 /// Return global trigger
209 return static_cast<AliMUONGlobalTrigger*>(fGlobal->At(0));
212 //_____________________________________________________________________________
214 AliMUONTriggerStoreV1::Clear(Option_t*)
218 fRegional->Clear("C");
220 fEmptyLocal->Clear("C");
223 //_____________________________________________________________________________
225 AliMUONTriggerStoreV1::GetSize() const
227 /// Number of non-empty local boards we hold
228 return fLocal->GetSize();
231 //_____________________________________________________________________________
233 AliMUONTriggerStoreV1::Print(Option_t* what, Option_t* opt) const
236 /// \param what used to tell what to print, can be GLOBAL, LOCAL, REGIONAL
238 /// \param opt is passed to the local, regional, global object
244 if ( swhat.Length() == 0 ) swhat = "ALL";
246 if ( swhat.Contains("GLOBAL") || swhat.Contains("ALL") )
250 cout << "Global:" << endl;
251 fGlobal->Print("",opt);
255 cout << "No GlobalTrigger information" << endl;
259 if ( fLocal && ( swhat.Contains("LOCAL")|| swhat.Contains("ALL") ) )
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)
266 AliMUONLocalTrigger* local;
269 while ( ( local = static_cast<AliMUONLocalTrigger*>(next()) ) )
271 if ( local->IsNull() ) ++n;
274 cout << Form("Local: %d cards (and %d null ones)",
275 fLocal->GetLast()+1,n) << endl;
279 while ( ( local = static_cast<AliMUONLocalTrigger*>(next()) ) )
281 if ( !local->IsNull() )
288 if ( fRegional && ( swhat.Contains("REGIONAL") || swhat.Contains("ALL") ) )
290 fRegional->Print("",opt);