1 // $Id: AliHLTPHOSOnlineDisplay.cxx 33100 2009-06-22 09:47:35Z odjuvsla $
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"
45 #include "AliHLTPHOSOnlineDisplayFourierTab.h"
47 //#include "AliHLTPHOSFourier.h"
50 AliHLTPHOSOnlineDisplayEventTab* AliHLTPHOSOnlineDisplay::fgEventTabPtr = 0;
51 AliHLTPHOSOnlineDisplayFourierTab* AliHLTPHOSOnlineDisplay::fgFourierTabPtr = 0;
52 AliHLTPHOSOnlineDisplayCalibTab* AliHLTPHOSOnlineDisplay::fgCalibTabPtr = 0;
53 AliHLTPHOSOnlineDisplay* AliHLTPHOSOnlineDisplay::fgInstancePtr = 0; /**<The one an only instance of PhosOnlineDisplay*/
54 HOMERReader* AliHLTPHOSOnlineDisplay::fgHomerReaderPtr = 0; /**<Homer reader that fetches events from the HLT online stream*/
55 HOMERReader* AliHLTPHOSOnlineDisplay::fgHomerReadersPtr[MAXHOSTS]; /**<Homer reader that fetches events from the HLT online stream*/
56 Bool_t AliHLTPHOSOnlineDisplay::fgAccumulate = kFALSE ; /**<If set to kFALSE reset fgLegoplot between event, kTRUE adds current energies to previous plot*/
57 Bool_t AliHLTPHOSOnlineDisplay::fgSyncronize = kFALSE ;
58 unsigned int AliHLTPHOSOnlineDisplay::fgNHosts = 0;
59 unsigned int AliHLTPHOSOnlineDisplay::fgNPorts = 0;
60 char* AliHLTPHOSOnlineDisplay::fgHosts[MAXHOSTS];
61 short unsigned int* AliHLTPHOSOnlineDisplay::fgPorts = 0;
62 TGTab* AliHLTPHOSOnlineDisplay::fgTab = 0;
66 //gStyle->SetOptStat(false);
69 AliHLTPHOSOnlineDisplay*
70 AliHLTPHOSOnlineDisplay::Instance(int argc, char** argv)
72 // See header file for documentation
73 if (!fgInstancePtr) fgInstancePtr = new AliHLTPHOSOnlineDisplay(argc, argv);
78 AliHLTPHOSOnlineDisplay::AliHLTPHOSOnlineDisplay() : AliHLTPHOSBase(), fRunNumber(-1)
80 // See header file for documentation
81 cout << "ERROR ! level: FATAL, you cannot invoke the onlinedisplay without arguments" << endl;
85 AliHLTPHOSOnlineDisplay::AliHLTPHOSOnlineDisplay(int argc, char** argv) : AliHLTPHOSBase()
87 // See header file for documentation
88 gStyle->SetOptStat(false);
90 ScanArguments(argc, argv);
92 cout << "creating new PHOS Onlinedisplay" << endl;
93 fgHomerReaderPtr = new HOMERReader(fgNHosts, (const char**)fgHosts, fgPorts);
94 cout << "AliHLTPHOSOnlineDisplay::AliHLTPHOSOnlineDisplay: fgHomerReaderPtr = " << fgHomerReaderPtr << endl;
96 for(int i = 0; i <fgNHosts; i++)
98 fgHomerReadersPtr[i] = new HOMERReader(fgHosts[i], fgPorts[i]);
104 AliHLTPHOSOnlineDisplay::~AliHLTPHOSOnlineDisplay()
106 // See header file for documentation
112 AliHLTPHOSOnlineDisplay::InitDisplay()
114 // See header file for documentation
115 char tmpHistoName[256];
116 char tmpChDtaName[256];
118 gStyle->SetPalette(1);
119 fgTab = new TGTab(this, 100, 100);
120 TGLayoutHints *fL1 = new TGLayoutHints(kLHintsBottom | kLHintsExpandX |
121 kLHintsExpandY, 2, 2, 15, 1);
122 fgEventTabPtr = new AliHLTPHOSOnlineDisplayEventTab(this, fgTab, fgHomerReaderPtr, fgHomerReadersPtr, fgNHosts, fRunNumber);
123 fgFourierTabPtr = new AliHLTPHOSOnlineDisplayFourierTab(this, fgTab, fgHomerReaderPtr, fgHomerReadersPtr, fgNHosts);
124 fgCalibTabPtr = new AliHLTPHOSOnlineDisplayCalibTab(fgTab, fgHomerReaderPtr, fgHomerReadersPtr, fgNHosts);
126 // fgEventTabPtr->SetRunNumber(fRunNumber);
127 // fgFourierTabPtr->SetRunNumber(fRunNumber);
128 // fgCalibTabPtr->SetRunNumber(fRunNumber);
130 AddFrame(fgTab, fL1);
133 SetWindowName("PHOS HLT OnlineDisplay");
135 // MoveResize(100,100, 800,1000);
136 MoveResize(100,100, 500,700);
143 AliHLTPHOSOnlineDisplay::GetNextEvent()
145 // See header file for documentation
146 cout << "AliHLTPHOSOnlineDisplay::GetNextEvent()" << endl;
147 fgEventTabPtr->GetNextEvent();
148 fgFourierTabPtr->GetNextEvent();
153 AliHLTPHOSOnlineDisplay::GetHistogram()
155 // See header file for documentation
156 fgCalibTabPtr->GetNextEvent();
162 AliHLTPHOSOnlineDisplay::ScanArguments(int argc, char** argv)
164 // See header file for documentation
165 for(int i=0; i< MAXHOSTS; i++)
167 fgHosts[i] = new char[256];
170 fgPorts = new short unsigned[100];
171 Bool_t hostIsSet = kFALSE;
172 Bool_t portIsSet = kFALSE;
176 for (int i=0; i<argc && iResult>=0; i++)
180 if (argument.IsNull())
185 if (argument.CompareTo("-sync")==0)
187 cout << "setting Synchronize to true" << endl;
188 fgSyncronize = kTRUE;
191 if (argument.CompareTo("-acc")==0)
193 cout << "setting Accumulate to true" << endl;
194 fgAccumulate = kTRUE;
197 if (argument.CompareTo("-run")==0)
202 fRunNumber = atoi(argv[i]);
203 cout << __FILE__ <<":" <<__LINE__ << ", !!!!!!!!!!!!! setting runnumber too " << fRunNumber <<endl;;
204 // fIsSetRunNumber = true;
210 if (argument.CompareTo("-host")==0)
215 sprintf(fgHosts[fgNHosts],"%s", argv[i]);
217 cout <<"fgNHosts set to "<< fgNHosts <<endl;
222 if(argument.CompareTo("-port")==0)
228 fgPorts[fgNPorts] = atoi(argv[i]);
229 cout << "A setting port to " << fgPorts[fgNPorts] <<endl;
236 fgPorts[fgNPorts] = DEFAULTEVENTPORT;
237 cout << "B setting port to " << fgPorts[fgNPorts] <<endl;
246 if(hostIsSet != kTRUE || portIsSet != kTRUE)
248 if(hostIsSet == kFALSE)
250 printf("\nERROR: no hostname is specified\n");
253 if( portIsSet == kFALSE)
255 printf("ERROR: no port spcified\n");
257 printf("\nYou must specify at least one host \n\n");
258 printf("*****************************************************************\n");
259 printf("\nUsage: ./onlinedisplay -host <hostname> -port <port>");
260 printf("\n-port is optional, if not set port 42001 will be used\n");
261 printf("*****************************************************************\n\n\n");
277 AliHLTPHOSOnlineDisplay::Gain2Text(const int gain, char *txt) const
279 // See header file for documentation
283 sprintf(txt,"Low Gain");
286 else if(gain == HIGHGAIN)
288 sprintf(txt,"High Gain");
293 sprintf(txt,"Error!! invalid gain %d", gain);