Do not assume operator==/!=() is a member function.
[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//
18
19ClassImp(AliEveHOMERSourceMap)
20
21AliEveHOMERSourceMap::AliEveHOMERSourceMap(ESourceGrouping_e grouping) :
22 fGrouping(grouping)
23{
24
25}
26
27AliEveHOMERSourceMap* AliEveHOMERSourceMap::Create(ESourceGrouping_e grouping)
28{
29 switch (grouping)
30 {
31 case kSG_ByDet: return new AliEveHOMERSourceMapByDet(grouping);
32 case kSG_ByType: return new AliEveHOMERSourceMapByType(grouping);
33 }
34 return 0;
35}
36
37Int_t AliEveHOMERSourceMap::iterator::level()
38{
39 const AliEveHOMERSource::SourceId& sid = id();
40
41 Int_t lvl = 0;
42 if ( ! sid.fDet.IsNull()) ++lvl;
43 if ( ! sid.fSDet.IsNull()) ++lvl;
44 if ( ! sid.fSSDet.IsNull()) ++lvl;
45 if ( ! sid.fType.IsNull()) ++lvl;
46 return lvl;
47}
48
49void AliEveHOMERSourceMap::PrintXXX()
50{
51 for (iterator i = begin(); i != end(); ++i)
52 {
53 printf("%*s%s [state=%d, handle=0x%lx] {ssdet='%s'}\n", 4*i.level(), "",
54 i.description().Data(), i.state().fState,
55 (ULong_t) i.state().fHandle,
56 i.id().fSSDet.Data());
57 }
58}
59
60/******************************************************************************/
61// AliEveHOMERSourceMapByDet
62/******************************************************************************/
63
64AliEveHOMERSourceMapByDet::AliEveHOMERSourceMapByDet(ESourceGrouping_e grouping) :
c61a7285 65 AliEveHOMERSourceMap(grouping),
66 fMap()
a15e6d7d 67{}
68
25c3aaf7 69TString AliEveHOMERSourceMapByDet::iterator_imp::description() const
a15e6d7d 70{
71 const AliEveHOMERSource::SourceId& sid = id();
72
73 if ( ! sid.fType.IsNull()) return sid.fType;
74 if ( ! sid.fSSDet.IsNull()) return sid.fSSDet;
75 if ( ! sid.fSDet.IsNull()) return sid.fSDet;
76 if ( ! sid.fDet.IsNull()) return sid.fDet;
77 return "<empty>";
78}
79
80void AliEveHOMERSourceMapByDet::insert(AliEveHOMERSource::SourceId& sid,
81 AliEveHOMERSource::SourceState& sst,
82 Bool_t def_state)
83{
84 Map_i i = fMap.find(sid);
85 if (i == fMap.end())
86 {
87 // Check wildcard, else
88 sst.fState = def_state;
89 fMap.insert(std::make_pair(sid, sst));
90 }
91}
92
93void AliEveHOMERSourceMapByDet::FillMap(TList* handles, Bool_t def_state)
94{
95 TIter next(handles);
96 AliHLTHOMERSourceDesc* h;
97 while ((h = (AliHLTHOMERSourceDesc*) next()))
98 {
99 AliEveHOMERSource::SourceId srcid;
100 AliEveHOMERSource::SourceState srcst;
101
102 srcid.fDet = h->GetDetector();
103 insert(srcid, srcst, def_state);
104
105 srcid.fSDet = h->GetSubDetector();
106 if ( ! srcid.fSDet.IsNull()) insert(srcid, srcst, def_state);
107
108 srcid.fSSDet = h->GetSubSubDetector();
109 if ( ! srcid.fSSDet.IsNull()) insert(srcid, srcst, def_state);
110
111 srcid.fType = h->GetDataType();
112 srcst.fHandle = h;
113 insert(srcid, srcst, def_state);
114 }
115}
116
117
118/******************************************************************************/
119// AliEveHOMERSourceMapByType
120/******************************************************************************/
121
122AliEveHOMERSourceMapByType::AliEveHOMERSourceMapByType(ESourceGrouping_e grouping) :
c61a7285 123 AliEveHOMERSourceMap(grouping),
124 fMap()
a15e6d7d 125{}
126
25c3aaf7 127TString AliEveHOMERSourceMapByType::iterator_imp::description() const
a15e6d7d 128{
129 const AliEveHOMERSource::SourceId& sid = id();
130
131 if ( ! sid.fSSDet.IsNull()) return sid.fSSDet;
132 if ( ! sid.fSDet.IsNull()) return sid.fSDet;
133 if ( ! sid.fDet.IsNull()) return sid.fDet;
134 if ( ! sid.fType.IsNull()) return sid.fType;
135 return "<empty>";
136}
137
138void AliEveHOMERSourceMapByType::insert(AliEveHOMERSource::SourceId& sid,
139 AliEveHOMERSource::SourceState& sst,
140 Bool_t def_state)
141{
142 Map_i i = fMap.find(sid);
143 if (i == fMap.end())
144 {
145 // Check wildcard, else
146 sst.fState = def_state;
147 fMap.insert(std::make_pair(sid, sst));
148 }
149}
150
151void AliEveHOMERSourceMapByType::FillMap(TList* handles, Bool_t def_state)
152{
153 TIter next(handles);
154 AliHLTHOMERSourceDesc* h;
155 while ((h = (AliHLTHOMERSourceDesc*) next()))
156 {
157 AliEveHOMERSource::SourceId srcid;
158 AliEveHOMERSource::SourceState srcst;
159
160 srcid.fType = h->GetDataType();
161 insert(srcid, srcst, def_state);
162
163 srcid.fDet = h->GetDetector();
164 if (h->GetSubDetector().IsNull())
165 {
166 srcst.fHandle = h;
167 insert(srcid, srcst, def_state);
168 continue;
169 }
170 insert(srcid, srcst, def_state);
171
172 srcid.fSDet = h->GetSubDetector();
173 if (h->GetSubSubDetector().IsNull())
174 {
175 srcst.fHandle = h;
176 insert(srcid, srcst, def_state);
177 continue;
178 }
179 insert(srcid, srcst, def_state);
180
181 srcid.fSSDet = h->GetSubSubDetector();
182 srcst.fHandle = h;
183 insert(srcid, srcst, def_state);
184 }
185}