3 /**************************************************************************
4 * This file is property of and copyright by the Experimental Nuclear *
5 * Physics Group, Dep. of Physics *
6 * University of Oslo, Norway, 2007 *
8 * Author: Per Thomas Hille <perthi@fys.uio.no> for the ALICE HLT Project.*
9 * Contributors are mentioned in the code where appropriate. *
10 * Please report bugs to perthi@fys.uio.no *
12 * Permission to use, copy, modify and distribute this software and its *
13 * documentation strictly for non-commercial purposes is hereby granted *
14 * without fee, provided that the above copyright notice appears in all *
15 * copies and that both the copyright notice and this permission notice *
16 * appear in the supporting documentation. The authors make no claims *
17 * about the suitability of this software for any purpose. It is *
18 * provided "as is" without express or implied warranty. *
19 **************************************************************************/
24 # include <TApplication.h>
30 #include "AliHLTPHOSOnlineDisplay.h"
31 #include "AliHLTDataTypes.h"
32 #include "AliHLTPHOSRcuCellEnergyDataStruct.h"
40 #include "AliHLTPHOSRcuCellAccumulatedEnergyDataStruct.h"
41 #include "AliHLTPHOSCommonDefs.h"
43 #include "AliHLTPHOSOnlineDisplayEventTab.h"
44 #include "AliHLTPHOSOnlineDisplayCalibTab.h"
46 //#include "AliHLTPHOSFourier.h"
49 AliHLTPHOSOnlineDisplayEventTab* AliHLTPHOSOnlineDisplay::fgEventTabPtr = 0;
50 AliHLTPHOSOnlineDisplayFourierTab* AliHLTPHOSOnlineDisplay::fgFourierTabPtr = 0;
51 AliHLTPHOSOnlineDisplayCalibTab* AliHLTPHOSOnlineDisplay::fgCalibTabPtr = 0;
52 AliHLTPHOSOnlineDisplay* AliHLTPHOSOnlineDisplay::fgInstancePtr = 0; /**<The one an only instance of PhosOnlineDisplay*/
53 HOMERReader* AliHLTPHOSOnlineDisplay::fgHomerReaderPtr = 0; /**<Homer reader that fetches events from the HLT online stream*/
54 HOMERReader* AliHLTPHOSOnlineDisplay::fgHomerReadersPtr[MAXHOSTS]; /**<Homer reader that fetches events from the HLT online stream*/
55 Bool_t AliHLTPHOSOnlineDisplay::fgAccumulate = kFALSE ; /**<If set to kFALSE reset fgLegoplot between event, kTRUE adds current energies to previous plot*/
56 Bool_t AliHLTPHOSOnlineDisplay::fgSyncronize = kFALSE ;
57 unsigned int AliHLTPHOSOnlineDisplay::fgNHosts = 0;
58 unsigned int AliHLTPHOSOnlineDisplay::fgNPorts = 0;
59 char* AliHLTPHOSOnlineDisplay::fgHosts[MAXHOSTS];
60 short unsigned int* AliHLTPHOSOnlineDisplay::fgPorts = 0;
61 TGTab* AliHLTPHOSOnlineDisplay::fgTab = 0;
65 //gStyle->SetOptStat(false);
68 AliHLTPHOSOnlineDisplay*
69 AliHLTPHOSOnlineDisplay::Instance(int argc, char** argv)
71 // See header file for documentation
72 if (!fgInstancePtr) fgInstancePtr = new AliHLTPHOSOnlineDisplay(argc, argv);
77 AliHLTPHOSOnlineDisplay::AliHLTPHOSOnlineDisplay() : AliHLTPHOSBase(), fRunNumber(-1)
79 // See header file for documentation
80 cout << "ERROR ! level: FATAL, you cannot invoke the onlinedisplay without arguments" << endl;
84 AliHLTPHOSOnlineDisplay::AliHLTPHOSOnlineDisplay(int argc, char** argv) : AliHLTPHOSBase()
86 // See header file for documentation
87 gStyle->SetOptStat(false);
89 ScanArguments(argc, argv);
91 cout << "creating new PHOS Onlinedisplay" << endl;
92 fgHomerReaderPtr = new HOMERReader(fgNHosts, (const char**)fgHosts, fgPorts);
93 cout << "AliHLTPHOSOnlineDisplay::AliHLTPHOSOnlineDisplay: fgHomerReaderPtr = " << fgHomerReaderPtr << endl;
95 for(int i = 0; i <fgNHosts; i++)
97 fgHomerReadersPtr[i] = new HOMERReader(fgHosts[i], fgPorts[i]);
103 AliHLTPHOSOnlineDisplay::~AliHLTPHOSOnlineDisplay()
105 // See header file for documentation
111 AliHLTPHOSOnlineDisplay::InitDisplay()
113 // See header file for documentation
114 char tmpHistoName[256];
115 char tmpChDtaName[256];
117 gStyle->SetPalette(1);
118 fgTab = new TGTab(this, 100, 100);
119 TGLayoutHints *fL1 = new TGLayoutHints(kLHintsBottom | kLHintsExpandX |
120 kLHintsExpandY, 2, 2, 15, 1);
121 fgEventTabPtr = new AliHLTPHOSOnlineDisplayEventTab(this, fgTab, fgHomerReaderPtr, fgHomerReadersPtr, fgNHosts, fRunNumber);
122 fgFourierTabPtr = new AliHLTPHOSOnlineDisplayFourierTab(this, fgTab, fgHomerReaderPtr, fgHomerReadersPtr, fgNHosts);
123 fgCalibTabPtr = new AliHLTPHOSOnlineDisplayCalibTab(fgTab, fgHomerReaderPtr, fgHomerReadersPtr, fgNHosts);
125 // fgEventTabPtr->SetRunNumber(fRunNumber);
126 // fgFourierTabPtr->SetRunNumber(fRunNumber);
127 // fgCalibTabPtr->SetRunNumber(fRunNumber);
129 AddFrame(fgTab, fL1);
132 SetWindowName("PHOS HLT OnlineDisplay");
134 // MoveResize(100,100, 800,1000);
135 MoveResize(100,100, 500,700);
142 AliHLTPHOSOnlineDisplay::GetNextEvent()
144 // See header file for documentation
145 cout << "AliHLTPHOSOnlineDisplay::GetNextEvent()" << endl;
146 fgEventTabPtr->GetNextEvent();
147 fgFourierTabPtr->GetNextEvent();
152 AliHLTPHOSOnlineDisplay::GetHistogram()
154 // See header file for documentation
155 fgCalibTabPtr->GetNextEvent();
161 AliHLTPHOSOnlineDisplay::ScanArguments(int argc, char** argv)
163 // See header file for documentation
164 for(int i=0; i< MAXHOSTS; i++)
166 fgHosts[i] = new char[256];
169 fgPorts = new short unsigned[100];
170 Bool_t hostIsSet = kFALSE;
171 Bool_t portIsSet = kFALSE;
175 for (int i=0; i<argc && iResult>=0; i++)
179 if (argument.IsNull())
184 if (argument.CompareTo("-sync")==0)
186 cout << "setting Synchronize to true" << endl;
187 fgSyncronize = kTRUE;
190 if (argument.CompareTo("-acc")==0)
192 cout << "setting Accumulate to true" << endl;
193 fgAccumulate = kTRUE;
196 if (argument.CompareTo("-run")==0)
201 fRunNumber = atoi(argv[i]);
202 cout << __FILE__ <<":" <<__LINE__ << ", !!!!!!!!!!!!! setting runnumber too " << fRunNumber <<endl;;
203 // fIsSetRunNumber = true;
209 if (argument.CompareTo("-host")==0)
214 sprintf(fgHosts[fgNHosts],"%s", argv[i]);
216 cout <<"fgNHosts set to "<< fgNHosts <<endl;
221 if(argument.CompareTo("-port")==0)
227 fgPorts[fgNPorts] = atoi(argv[i]);
228 cout << "A setting port to " << fgPorts[fgNPorts] <<endl;
235 fgPorts[fgNPorts] = DEFAULTEVENTPORT;
236 cout << "B setting port to " << fgPorts[fgNPorts] <<endl;
245 if(hostIsSet != kTRUE || portIsSet != kTRUE)
247 if(hostIsSet == kFALSE)
249 printf("\nERROR: no hostname is specified\n");
252 if( portIsSet == kFALSE)
254 printf("ERROR: no port spcified\n");
256 printf("\nYou must specify at least one host \n\n");
257 printf("*****************************************************************\n");
258 printf("\nUsage: ./onlinedisplay -host <hostname> -port <port>");
259 printf("\n-port is optional, if not set port 42001 will be used\n");
260 printf("*****************************************************************\n\n\n");
276 AliHLTPHOSOnlineDisplay::Gain2Text(const int gain, char *txt) const
278 // See header file for documentation
282 sprintf(txt,"Low Gain");
285 else if(gain == HIGHGAIN)
287 sprintf(txt,"High Gain");
292 sprintf(txt,"Error!! invalid gain %d", gain);