Fix some coding convention violations.
[u/mrichter/AliRoot.git] / EVE / EveHLT / AliEveHOMERSourceMap.cxx
CommitLineData
a15e6d7d 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//
ca8fb7ae 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//
a15e6d7d 25
26ClassImp(AliEveHOMERSourceMap)
27
28AliEveHOMERSourceMap::AliEveHOMERSourceMap(ESourceGrouping_e grouping) :
29 fGrouping(grouping)
30{
ca8fb7ae 31 // Constructor.
a15e6d7d 32}
33
34AliEveHOMERSourceMap* AliEveHOMERSourceMap::Create(ESourceGrouping_e grouping)
35{
ca8fb7ae 36 // Static constructor - instantiates appropriate sub-class.
37
a15e6d7d 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
46Int_t AliEveHOMERSourceMap::iterator::level()
47{
ca8fb7ae 48 // Returns the depth in iteration:
49 // Det / Sub-Det / Sub-Sub-Det / Data-Type.
50
a15e6d7d 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
61void AliEveHOMERSourceMap::PrintXXX()
62{
ca8fb7ae 63 // Print entries in the map.
64
a15e6d7d 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
78AliEveHOMERSourceMapByDet::AliEveHOMERSourceMapByDet(ESourceGrouping_e grouping) :
c61a7285 79 AliEveHOMERSourceMap(grouping),
80 fMap()
a15e6d7d 81{}
82
25c3aaf7 83TString AliEveHOMERSourceMapByDet::iterator_imp::description() const
a15e6d7d 84{
ca8fb7ae 85 // Return identifier string for current entry.
86
a15e6d7d 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
96void AliEveHOMERSourceMapByDet::insert(AliEveHOMERSource::SourceId& sid,
97 AliEveHOMERSource::SourceState& sst,
98 Bool_t def_state)
99{
ca8fb7ae 100 // Insert source-state for given source-id.
101 // Does nothing if the entry already exists.
102
a15e6d7d 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
ca8fb7ae 112void AliEveHOMERSourceMapByDet::FillMap(const TList* handles, Bool_t def_state)
a15e6d7d 113{
ca8fb7ae 114 // Fill the map from the list of HOMER source handles.
115
a15e6d7d 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
143AliEveHOMERSourceMapByType::AliEveHOMERSourceMapByType(ESourceGrouping_e grouping) :
c61a7285 144 AliEveHOMERSourceMap(grouping),
145 fMap()
ca8fb7ae 146{
147 // Constructor.
148}
a15e6d7d 149
25c3aaf7 150TString AliEveHOMERSourceMapByType::iterator_imp::description() const
a15e6d7d 151{
ca8fb7ae 152 // Return identifier string for current entry.
153
a15e6d7d 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
163void AliEveHOMERSourceMapByType::insert(AliEveHOMERSource::SourceId& sid,
164 AliEveHOMERSource::SourceState& sst,
165 Bool_t def_state)
166{
ca8fb7ae 167 // Insert source-state for given source-id.
168 // Does nothing if the entry already exists.
169
a15e6d7d 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
ca8fb7ae 179void AliEveHOMERSourceMapByType::FillMap(const TList* handles, Bool_t def_state)
a15e6d7d 180{
ca8fb7ae 181 // Fill the map from the list of HOMER source handles.
182
a15e6d7d 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().IsNull())
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().IsNull())
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}