bugfix
[u/mrichter/AliRoot.git] / EVE / EveHLT / AliEveHOMERSourceList.cxx
CommitLineData
a82a31af 1//-*- Mode: C++ -*-
2
d810d0de 3// $Id$
4// Main authors: Matevz Tadel & Alja Mrak-Tadel: 2006, 2007
5
6/**************************************************************************
7 * Copyright(c) 1998-2008, ALICE Experiment at CERN, all rights reserved. *
8 * See http://aliceinfo.cern.ch/Offline/AliRoot/License.html for *
51346b82 9 * full copyright notice. *
d810d0de 10 **************************************************************************/
11
12#include "AliEveHOMERSourceList.h"
a15e6d7d 13#include "AliEveHOMERSourceMap.h"
14#include "AliEveHOMERManager.h"
d810d0de 15
57ffa5fb 16//______________________________________________________________________________
d810d0de 17// AliEveHOMERSourceList
18//
19
20ClassImp(AliEveHOMERSourceList)
21
22AliEveHOMERSourceList::AliEveHOMERSourceList(const Text_t* n, const Text_t* t) :
a15e6d7d 23 TEveElementList(n, t),
24 fManager (0),
25 fSrcMap (0)
d810d0de 26{
27
28}
29
a15e6d7d 30AliEveHOMERSourceList::~AliEveHOMERSourceList()
31{
32 // !!!!! delete maps
33}
34
35/******************************************************************************/
36
37void AliEveHOMERSourceList::CreateByDet()
38{
39 delete fSrcMap;
40 fSrcMap = AliEveHOMERSourceMap::Create(AliEveHOMERSourceMap::kSG_ByDet);
41 RebuildSourceReps();
42}
43
44void AliEveHOMERSourceList::CreateByType()
45{
46 delete fSrcMap;
47 fSrcMap = AliEveHOMERSourceMap::Create(AliEveHOMERSourceMap::kSG_ByType);
48 RebuildSourceReps();
49}
50
51void AliEveHOMERSourceList::RebuildSourceReps()
52{
53 DestroyElements();
a15e6d7d 54 TList* srcList = fManager->GetSourceList();
55 fSrcMap->FillMap(srcList, 1);
56
57 List_t parentStack;
58 parentStack.push_back(this);
59 Int_t parentLvl = 1;
60 for (AliEveHOMERSourceMap::iterator i=fSrcMap->begin(); i!=fSrcMap->end(); ++i)
61 {
62 while (parentLvl > i.level()) { parentStack.pop_back(); --parentLvl; }
63
64 AliEveHOMERSource* src = new AliEveHOMERSource(i.description());
65 src->SetSource(&i.id(), &i.state());
66
67 parentStack.back()->AddElement(src);
68
69 parentStack.push_back(src); ++parentLvl;
a82a31af 70
a15e6d7d 71 printf("%*s%s [state=%d, handle=0x%lx] {ssdet='%s'}\n", 4*i.level(), "",
72 i.description().Data(), i.state().fState,
73 (ULong_t) i.state().fHandle,
74 i.id().fSSDet.Data());
46eadbb4 75
a82a31af 76
46eadbb4 77 }
78}
79
80
81Bool_t AliEveHOMERSourceList::GetSelectedSources() {
82 // Set selected source in HOMER sources list, of HOMERManager
83
84 if ( ! fManager ) {
85 printf ( "Error : no ptr to HomerManager!");
86 return kFALSE;
87 }
88
89
90 Bool_t bResult = kFALSE;
91
92 for ( AliEveHOMERSourceMap::iterator iter=fSrcMap->begin(); iter!=fSrcMap->end(); ++iter ) {
93
94 if ( ! iter.state().fHandle )
95 continue;
96
97 fManager->SetSourceState( (AliHLTHOMERSourceDesc*) iter.state().fHandle,iter.state().fState );
98 bResult = kTRUE;
99
a82a31af 100#if 0 // EVE_DEBUG
46eadbb4 101 printf("%*s%s [state=%d, handle=0x%lx] {ssdet='%s'}\n", 4*iter.level(), "",
102 iter.description().Data(), iter.state().fState,
103 (ULong_t) iter.state().fHandle,
104 iter.id().fSSDet.Data());
a82a31af 105
106#endif
46eadbb4 107
108
109
a15e6d7d 110 }
46eadbb4 111
112
113 return bResult;
a15e6d7d 114}
115
46eadbb4 116
a15e6d7d 117/******************************************************************************/
118/*
d810d0de 119void AliEveHOMERSourceList::SelectAll()
120{
121 EnableListElements(kTRUE, kTRUE);
122}
123
124void AliEveHOMERSourceList::DeselectAll()
125{
126 DisableListElements (kFALSE, kFALSE);
127}
a15e6d7d 128*/