Merge changes from branches/dev/EVE. This branch was following development in ROOT...
[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) :
65 AliEveHOMERSourceMap(grouping)
66{}
67
68TString AliEveHOMERSourceMapByDet::iterator_imp::description()
69{
70 const AliEveHOMERSource::SourceId& sid = id();
71
72 if ( ! sid.fType.IsNull()) return sid.fType;
73 if ( ! sid.fSSDet.IsNull()) return sid.fSSDet;
74 if ( ! sid.fSDet.IsNull()) return sid.fSDet;
75 if ( ! sid.fDet.IsNull()) return sid.fDet;
76 return "<empty>";
77}
78
79void AliEveHOMERSourceMapByDet::insert(AliEveHOMERSource::SourceId& sid,
80 AliEveHOMERSource::SourceState& sst,
81 Bool_t def_state)
82{
83 Map_i i = fMap.find(sid);
84 if (i == fMap.end())
85 {
86 // Check wildcard, else
87 sst.fState = def_state;
88 fMap.insert(std::make_pair(sid, sst));
89 }
90}
91
92void AliEveHOMERSourceMapByDet::FillMap(TList* handles, Bool_t def_state)
93{
94 TIter next(handles);
95 AliHLTHOMERSourceDesc* h;
96 while ((h = (AliHLTHOMERSourceDesc*) next()))
97 {
98 AliEveHOMERSource::SourceId srcid;
99 AliEveHOMERSource::SourceState srcst;
100
101 srcid.fDet = h->GetDetector();
102 insert(srcid, srcst, def_state);
103
104 srcid.fSDet = h->GetSubDetector();
105 if ( ! srcid.fSDet.IsNull()) insert(srcid, srcst, def_state);
106
107 srcid.fSSDet = h->GetSubSubDetector();
108 if ( ! srcid.fSSDet.IsNull()) insert(srcid, srcst, def_state);
109
110 srcid.fType = h->GetDataType();
111 srcst.fHandle = h;
112 insert(srcid, srcst, def_state);
113 }
114}
115
116
117/******************************************************************************/
118// AliEveHOMERSourceMapByType
119/******************************************************************************/
120
121AliEveHOMERSourceMapByType::AliEveHOMERSourceMapByType(ESourceGrouping_e grouping) :
122 AliEveHOMERSourceMap(grouping)
123{}
124
125TString AliEveHOMERSourceMapByType::iterator_imp::description()
126{
127 const AliEveHOMERSource::SourceId& sid = id();
128
129 if ( ! sid.fSSDet.IsNull()) return sid.fSSDet;
130 if ( ! sid.fSDet.IsNull()) return sid.fSDet;
131 if ( ! sid.fDet.IsNull()) return sid.fDet;
132 if ( ! sid.fType.IsNull()) return sid.fType;
133 return "<empty>";
134}
135
136void AliEveHOMERSourceMapByType::insert(AliEveHOMERSource::SourceId& sid,
137 AliEveHOMERSource::SourceState& sst,
138 Bool_t def_state)
139{
140 Map_i i = fMap.find(sid);
141 if (i == fMap.end())
142 {
143 // Check wildcard, else
144 sst.fState = def_state;
145 fMap.insert(std::make_pair(sid, sst));
146 }
147}
148
149void AliEveHOMERSourceMapByType::FillMap(TList* handles, Bool_t def_state)
150{
151 TIter next(handles);
152 AliHLTHOMERSourceDesc* h;
153 while ((h = (AliHLTHOMERSourceDesc*) next()))
154 {
155 AliEveHOMERSource::SourceId srcid;
156 AliEveHOMERSource::SourceState srcst;
157
158 srcid.fType = h->GetDataType();
159 insert(srcid, srcst, def_state);
160
161 srcid.fDet = h->GetDetector();
162 if (h->GetSubDetector().IsNull())
163 {
164 srcst.fHandle = h;
165 insert(srcid, srcst, def_state);
166 continue;
167 }
168 insert(srcid, srcst, def_state);
169
170 srcid.fSDet = h->GetSubDetector();
171 if (h->GetSubSubDetector().IsNull())
172 {
173 srcst.fHandle = h;
174 insert(srcid, srcst, def_state);
175 continue;
176 }
177 insert(srcid, srcst, def_state);
178
179 srcid.fSSDet = h->GetSubSubDetector();
180 srcst.fHandle = h;
181 insert(srcid, srcst, def_state);
182 }
183}