]> git.uio.no Git - u/mrichter/AliRoot.git/blob - EVE/EveHLT/AliEveHOMERManager.cxx
Merge branch 'master' of https://git.cern.ch/reps/AliRoot
[u/mrichter/AliRoot.git] / EVE / EveHLT / AliEveHOMERManager.cxx
1 //-*- Mode: C++ -*-
2
3 // $Id$
4 // Main authors: Matevz Tadel & Alja Mrak-Tadel: 2006, 2007              *
5 // Author: Jochen Thaeder <thaeder@kip.uni-heidelberg.de>                *
6 // Author: 2010 Svein Lindal <slindal@fys.uio.no>                        *
7 //         for The ALICE HLT Project.                                    *
8
9
10
11 /** @file   AliEveHOMERManager.cxx
12     @author Jochen Thaeder,  
13     @author Svein Lindal <slindal@fys.uio.no>
14     @date
15     @brief  Manager for HOMER events
16 */
17
18 #if __GNUC__>= 3
19    using namespace std;
20 #endif
21
22 #include "unistd.h"
23
24 #include "AliHLTTriggerDecision.h"
25 #include "AliEveHOMERManager.h"
26 #include "AliHLTHOMERBlockDesc.h"
27 #include "AliHLTHOMERManager.h"
28 #include "AliEveHOMERSourceList.h"
29
30 #include "TTimer.h"
31
32 ClassImp(AliEveHOMERManager)
33   
34 //____________________________________________________________________________________
35 AliEveHOMERManager::AliEveHOMERManager() :
36 TEveElementList("Homer Manager"),
37   AliHLTHOMERManager(), 
38   fSrcList(NULL),
39   fRetryCount(1000),
40   fRetrySleeptime(15),
41   fSourceListTimer(NULL)
42 {
43   fSourceListTimer = new TTimer();
44   fSourceListTimer->Connect("Timeout()", "AliEveHOMERManager", this, "CreateEveSourcesListLoop()");
45 }
46
47 //____________________________________________________________________________________
48 AliEveHOMERManager::~AliEveHOMERManager() {
49   // see header file for class documentation 
50   
51   if (fSrcList)
52     delete fSrcList;
53   fSrcList = NULL;
54   
55   
56
57
58 }
59
60  //____________________________________________________________________________________
61 Int_t AliEveHOMERManager::CreateEveSourcesList() {
62   // see header file for class documentation
63
64   DestroyElements();
65
66   Int_t iResult = CreateSourcesList();
67
68   fStateHasChanged = kTRUE;
69   
70   HLTDebug(Form("iResult XXX %d", iResult));
71   if ( iResult )
72     return iResult;
73
74  
75
76   HLTDebug(Form("iResult %d", iResult));
77   if (fSrcList) {
78     HLTInfo("delete source list");
79     DestroyElements();
80     //delete fSrcList;
81     fSrcList = NULL;
82     //fSrcList->Clear();
83     HLTInfo("cleared source list");
84   }
85
86
87   // -- Create new AliEVE sources list 
88   if(!fSrcList){
89     HLTInfo("no source list");
90     fSrcList = new AliEveHOMERSourceList("HLT Sources");
91     fSrcList->SetManager(this);
92     AddElement(fSrcList);
93   }
94   
95   //HLTInfo(Form("createbytype", iResult));
96   fSrcList->CreateByDet();
97   
98   HLTDebug(Form("Done creating source list %d", iResult));    
99     
100   return iResult;
101 }
102
103 ///_______________________________________________________________
104 void AliEveHOMERManager::StartEveSourceListLoop() {
105   HLTInfo("Starting source list timer");
106   fSourceListTimer->Start(5000); 
107 }
108 ///_______________________________________________________________
109 void AliEveHOMERManager::StopEveSourceListLoop() {
110   fSourceListTimer->Stop(); 
111 }
112
113
114 //________________________________________________________________###
115 Int_t AliEveHOMERManager::CreateEveSourcesListLoop() {
116   // see header file for class documentation
117
118   HLTInfo("Attempting to create source list");
119   Int_t iResult = CreateEveSourcesList();
120
121   if (!iResult) {
122     HLTInfo("Source list successfully created.");
123     StopEveSourceListLoop();
124     HLTInfo("Conneting to sources");
125     return ConnectEVEtoHOMER();
126   }
127   
128
129   else if (iResult == 1) {
130     HLTWarning( Form("Couldn't find active services,"));
131   
132   } else if (iResult == 2) {
133     HLTWarning( Form("Services List empty, sleeping %d s before making new attempt.", fRetrySleeptime) ) ;
134   
135   } else {
136     HLTError( Form("Other problem ... \n") ); 
137   } 
138   
139   return iResult;
140 }
141
142 //________________________________________________________________
143 Int_t AliEveHOMERManager::ConnectEVEtoHOMER( TString detector ) {
144   // see header file for class documentation
145   HLTInfo("");
146   fStateHasChanged = fSrcList->GetSelectedSources();
147   HLTInfo(Form("has state changed % d", fStateHasChanged));
148   return ConnectHOMER(detector);
149 }
150
151
152 //________________________________________________________________
153 Int_t AliEveHOMERManager::ReConnectHOMER( TString /*detector*/ ){
154   // see header file for class documentation
155   Int_t iResult = 0;
156   if (Connected()) DisconnectHOMER();
157   CreateEveSourcesListLoop();
158   return iResult;
159 }
160
161 //_____________________________________________________________________________________
162 TList * AliEveHOMERManager::NextHOMEREvent() {
163   //See header file for documentation  
164   
165   if(!Connected()) {
166     HLTInfo("Homer is not connected, trying to reconnect!");
167     ReConnectHOMER();
168     return NULL;
169   }
170   
171   
172   if ( NextEvent() ) {
173     HLTInfo("Failed getting next event, trying to reconnect");
174     ReConnectHOMER();
175     return NULL;
176   }
177   
178   return GetBlockList();
179   
180 }