]> git.uio.no Git - u/mrichter/AliRoot.git/blob - EVE/EveHLT/AliEveHOMERSourceMap.cxx
Bugfixes enabling buffer navigation
[u/mrichter/AliRoot.git] / EVE / EveHLT / AliEveHOMERSourceMap.cxx
1 // $Id$
2 // Main authors: Matevz Tadel & Alja Mrak-Tadel: 2006, 2007
3
4 /**************************************************************************
5  * Copyright(c) 1998-2008, ALICE Experiment at CERN, all rights reserved. *
6  * See http://aliceinfo.cern.ch/Offline/AliRoot/License.html for          *
7  * full copyright notice.                                                 *
8  **************************************************************************/
9
10 #include "AliEveHOMERSourceMap.h"
11 #include <AliHLTHOMERSourceDesc.h>
12
13 #include <TList.h>
14
15 //______________________________________________________________________
16 // AliEveHOMERSourceMap
17 //
18 // AliEveHOMERSourceMap is an abstract container for HLT HOMER sources,
19 // see AliHLTHOMERSourceDesc.
20 //
21 // The concrete implementations AliEveHOMERSourceMapByDet and
22 // AliEveHOMERSourceMapByType allow retrieval of HOMER sources in proper
23 // order as required for their display in EVE object browser.
24 // 
25
26 ClassImp(AliEveHOMERSourceMap)
27
28 AliEveHOMERSourceMap::AliEveHOMERSourceMap(ESourceGrouping_e grouping) :
29   fGrouping(grouping)
30 {
31   // Constructor.
32 }
33
34 AliEveHOMERSourceMap* AliEveHOMERSourceMap::Create(ESourceGrouping_e grouping)
35 {
36   // Static constructor - instantiates appropriate sub-class.
37
38   switch (grouping)
39   {
40     case kSG_ByDet:  return new AliEveHOMERSourceMapByDet(grouping);
41     case kSG_ByType: return new AliEveHOMERSourceMapByType(grouping);
42   }
43   return 0;
44 }
45
46 Int_t AliEveHOMERSourceMap::iterator::level()
47 {
48   // Returns the depth in iteration:
49   // Det / Sub-Det / Sub-Sub-Det / Data-Type.
50
51   const AliEveHOMERSource::SourceId& sid = id();
52
53   Int_t lvl = 0;
54   if ( ! sid.fDet.IsNull())   ++lvl;
55   if ( ! sid.fSDet.IsNull())  ++lvl;
56   if ( ! sid.fSSDet.IsNull()) ++lvl;
57   if ( ! sid.fType.IsNull())  ++lvl;
58   return lvl;
59 }
60
61 void AliEveHOMERSourceMap::PrintXXX()
62 {
63   // Print entries in the map.
64
65   for (iterator i = begin(); i != end(); ++i)
66   {
67     printf("%*s%s [state=%d, handle=0x%lx] {ssdet='%s'}\n", 4*i.level(), "",
68            i.description().Data(), i.state().fState,
69            (ULong_t) i.state().fHandle,
70            i.id().fSSDet.Data());
71   }
72 }
73
74 /******************************************************************************/
75 // AliEveHOMERSourceMapByDet
76 /******************************************************************************/
77
78 AliEveHOMERSourceMapByDet::AliEveHOMERSourceMapByDet(ESourceGrouping_e grouping) :
79   AliEveHOMERSourceMap(grouping),
80   fMap()
81 {}
82
83 TString AliEveHOMERSourceMapByDet::iterator_imp::description() const
84 {
85   // Return identifier string for current entry.
86
87   const AliEveHOMERSource::SourceId& sid = id();
88
89   if ( ! sid.fType.IsNull())  return sid.fType;
90   if ( ! sid.fSSDet.IsNull()) return sid.fSSDet;
91   if ( ! sid.fSDet.IsNull())  return sid.fSDet;
92   if ( ! sid.fDet.IsNull())   return sid.fDet;
93   return "<empty>";
94 }
95
96 void AliEveHOMERSourceMapByDet::insert(AliEveHOMERSource::SourceId& sid,
97                                        AliEveHOMERSource::SourceState& sst,
98                                        Bool_t def_state)
99 {
100   // Insert source-state for given source-id.
101   // Does nothing if the entry already exists.
102
103   Map_i i = fMap.find(sid);
104   if (i == fMap.end())
105   {
106     // Check wildcard, else
107     sst.fState = def_state;
108     fMap.insert(std::make_pair(sid, sst));
109   }
110 }
111
112 void AliEveHOMERSourceMapByDet::FillMap(const TList* handles, Bool_t def_state)
113 {
114   // Fill the map from the list of HOMER source handles.
115
116   TIter next(handles);
117   AliHLTHOMERSourceDesc* h;
118   while ((h = (AliHLTHOMERSourceDesc*) next()))
119   {
120     AliEveHOMERSource::SourceId    srcid;
121     AliEveHOMERSource::SourceState srcst;
122
123     srcid.fDet = h->GetDetector();
124     insert(srcid, srcst, def_state);
125
126     srcid.fSDet = h->GetSubDetector();
127     if ( ! srcid.fSDet.IsNull())  insert(srcid, srcst, def_state);
128
129     srcid.fSSDet = h->GetSubSubDetector();
130     if ( ! srcid.fSSDet.IsNull()) insert(srcid, srcst, def_state);
131
132     srcid.fType   = h->GetDataType();
133     srcst.fHandle = h;
134     insert(srcid, srcst, def_state);
135   }
136 }
137
138
139 /******************************************************************************/
140 // AliEveHOMERSourceMapByType
141 /******************************************************************************/
142
143 AliEveHOMERSourceMapByType::AliEveHOMERSourceMapByType(ESourceGrouping_e grouping) :
144   AliEveHOMERSourceMap(grouping),
145   fMap()
146 {
147   // Constructor.
148 }
149
150 TString AliEveHOMERSourceMapByType::iterator_imp::description() const
151 {
152   // Return identifier string for current entry.
153
154   const AliEveHOMERSource::SourceId& sid = id();
155
156   if ( ! sid.fSSDet.IsNull()) return sid.fSSDet;
157   if ( ! sid.fSDet.IsNull())  return sid.fSDet;
158   if ( ! sid.fDet.IsNull())   return sid.fDet;
159   if ( ! sid.fType.IsNull())  return sid.fType;
160   return "<empty>";
161 }
162
163 void AliEveHOMERSourceMapByType::insert(AliEveHOMERSource::SourceId& sid,
164                                         AliEveHOMERSource::SourceState& sst,
165                                         Bool_t def_state)
166 {
167   // Insert source-state for given source-id.
168   // Does nothing if the entry already exists.
169
170   Map_i i = fMap.find(sid);
171   if (i == fMap.end())
172   {
173     // Check wildcard, else
174     sst.fState = def_state;
175     fMap.insert(std::make_pair(sid, sst));
176   }
177 }
178
179 void AliEveHOMERSourceMapByType::FillMap(const TList* handles, Bool_t def_state)
180 {
181   // Fill the map from the list of HOMER source handles.
182
183   TIter next(handles);
184   AliHLTHOMERSourceDesc* h;
185   while ((h = (AliHLTHOMERSourceDesc*) next()))
186   {
187     AliEveHOMERSource::SourceId    srcid;
188     AliEveHOMERSource::SourceState srcst;
189
190     srcid.fType   = h->GetDataType();
191     insert(srcid, srcst, def_state);
192
193     srcid.fDet = h->GetDetector();
194     if (h->GetSubDetector() == 0)
195     {
196       srcst.fHandle = h;
197       insert(srcid, srcst, def_state);
198       continue;
199     }
200     insert(srcid, srcst, def_state);
201
202     srcid.fSDet = h->GetSubDetector();
203     if (h->GetSubSubDetector() == 0)
204     {
205       srcst.fHandle = h;
206       insert(srcid, srcst, def_state);
207       continue;
208     }
209     insert(srcid, srcst, def_state);
210
211     srcid.fSSDet  = h->GetSubSubDetector();
212     srcst.fHandle = h;
213     insert(srcid, srcst, def_state);
214   }
215 }