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"
41 //#include "AliHLTPHOSRcuCellAccumulatedEnergyDataStruct.h"
42 #include "AliHLTCaloRcuCellAccumulatedEnergyDataStruct.h"
44 #include "AliHLTPHOSCommonDefs.h"
46 #include "AliHLTPHOSOnlineDisplayEventTab.h"
47 #include "AliHLTPHOSOnlineDisplayCalibTab.h"
48 #include "AliHLTPHOSOnlineDisplayFourierTab.h"
50 //#include "AliHLTPHOSFourier.h"
53 AliHLTPHOSOnlineDisplayEventTab* AliHLTPHOSOnlineDisplay::fgEventTabPtr = 0;
54 AliHLTPHOSOnlineDisplayFourierTab* AliHLTPHOSOnlineDisplay::fgFourierTabPtr = 0;
55 AliHLTPHOSOnlineDisplayCalibTab* AliHLTPHOSOnlineDisplay::fgCalibTabPtr = 0;
56 AliHLTPHOSOnlineDisplay* AliHLTPHOSOnlineDisplay::fgInstancePtr = 0; /**<The one an only instance of PhosOnlineDisplay*/
57 HOMERReader* AliHLTPHOSOnlineDisplay::fgHomerReaderPtr = 0; /**<Homer reader that fetches events from the HLT online stream*/
58 HOMERReader* AliHLTPHOSOnlineDisplay::fgHomerReadersPtr[MAXHOSTS]; /**<Homer reader that fetches events from the HLT online stream*/
59 Bool_t AliHLTPHOSOnlineDisplay::fgAccumulate = kFALSE ; /**<If set to kFALSE reset fgLegoplot between event, kTRUE adds current energies to previous plot*/
60 Bool_t AliHLTPHOSOnlineDisplay::fgSyncronize = kFALSE ;
61 unsigned int AliHLTPHOSOnlineDisplay::fgNHosts = 0;
62 unsigned int AliHLTPHOSOnlineDisplay::fgNPorts = 0;
63 char* AliHLTPHOSOnlineDisplay::fgHosts[MAXHOSTS];
64 short unsigned int* AliHLTPHOSOnlineDisplay::fgPorts = 0;
65 TGTab* AliHLTPHOSOnlineDisplay::fgTab = 0;
69 //gStyle->SetOptStat(false);
72 AliHLTPHOSOnlineDisplay*
73 AliHLTPHOSOnlineDisplay::Instance(int argc, char** argv)
75 // See header file for documentation
76 if (!fgInstancePtr) fgInstancePtr = new AliHLTPHOSOnlineDisplay(argc, argv);
81 //AliHLTPHOSOnlineDisplay::AliHLTPHOSOnlineDisplay() : AliHLTPHOSBase(), fRunNumber(-1)
82 AliHLTPHOSOnlineDisplay::AliHLTPHOSOnlineDisplay() : fRunNumber(-1)
85 // See header file for documentation
86 cout << "ERROR ! level: FATAL, you cannot invoke the onlinedisplay without arguments" << endl;
90 //AliHLTPHOSOnlineDisplay::AliHLTPHOSOnlineDisplay(int argc, char** argv) : AliHLTPHOSBase()
91 AliHLTPHOSOnlineDisplay::AliHLTPHOSOnlineDisplay(int argc, char** argv)
93 // See header file for documentation
94 gStyle->SetOptStat(false);
96 ScanArguments(argc, argv);
98 cout << "creating new PHOS Onlinedisplay" << endl;
99 fgHomerReaderPtr = new HOMERReader(fgNHosts, (const char**)fgHosts, fgPorts);
100 cout << "AliHLTPHOSOnlineDisplay::AliHLTPHOSOnlineDisplay: fgHomerReaderPtr = " << fgHomerReaderPtr << endl;
102 for(int i = 0; i <fgNHosts; i++)
104 fgHomerReadersPtr[i] = new HOMERReader(fgHosts[i], fgPorts[i]);
110 AliHLTPHOSOnlineDisplay::~AliHLTPHOSOnlineDisplay()
112 // See header file for documentation
118 AliHLTPHOSOnlineDisplay::InitDisplay()
120 // See header file for documentation
121 char tmpHistoName[256];
122 char tmpChDtaName[256];
124 gStyle->SetPalette(1);
125 fgTab = new TGTab(this, 100, 100);
126 TGLayoutHints *fL1 = new TGLayoutHints(kLHintsBottom | kLHintsExpandX |
127 kLHintsExpandY, 2, 2, 15, 1);
128 fgEventTabPtr = new AliHLTPHOSOnlineDisplayEventTab(this, fgTab, fgHomerReaderPtr, fgHomerReadersPtr, fgNHosts, fRunNumber);
129 fgFourierTabPtr = new AliHLTPHOSOnlineDisplayFourierTab(this, fgTab, fgHomerReaderPtr, fgHomerReadersPtr, fgNHosts);
130 fgCalibTabPtr = new AliHLTPHOSOnlineDisplayCalibTab(fgTab, fgHomerReaderPtr, fgHomerReadersPtr, fgNHosts);
132 // fgEventTabPtr->SetRunNumber(fRunNumber);
133 // fgFourierTabPtr->SetRunNumber(fRunNumber);
134 // fgCalibTabPtr->SetRunNumber(fRunNumber);
136 AddFrame(fgTab, fL1);
139 SetWindowName("PHOS HLT OnlineDisplay");
141 // MoveResize(100,100, 800,1000);
142 MoveResize(100,100, 500,700);
149 AliHLTPHOSOnlineDisplay::GetNextEvent()
151 // See header file for documentation
152 cout << "AliHLTPHOSOnlineDisplay::GetNextEvent()" << endl;
153 fgEventTabPtr->GetNextEvent();
154 fgFourierTabPtr->GetNextEvent();
159 AliHLTPHOSOnlineDisplay::GetHistogram()
161 // See header file for documentation
162 fgCalibTabPtr->GetNextEvent();
168 AliHLTPHOSOnlineDisplay::ScanArguments(int argc, char** argv)
170 // See header file for documentation
171 for(int i=0; i< MAXHOSTS; i++)
173 fgHosts[i] = new char[256];
176 fgPorts = new short unsigned[100];
177 Bool_t hostIsSet = kFALSE;
178 Bool_t portIsSet = kFALSE;
182 for (int i=0; i<argc && iResult>=0; i++)
186 if (argument.IsNull())
191 if (argument.CompareTo("-sync")==0)
193 cout << "setting Synchronize to true" << endl;
194 fgSyncronize = kTRUE;
197 if (argument.CompareTo("-acc")==0)
199 cout << "setting Accumulate to true" << endl;
200 fgAccumulate = kTRUE;
203 if (argument.CompareTo("-run")==0)
208 fRunNumber = atoi(argv[i]);
209 cout << __FILE__ <<":" <<__LINE__ << ", !!!!!!!!!!!!! setting runnumber too " << fRunNumber <<endl;;
210 // fIsSetRunNumber = true;
216 if (argument.CompareTo("-host")==0)
221 sprintf(fgHosts[fgNHosts],"%s", argv[i]);
223 cout <<"fgNHosts set to "<< fgNHosts <<endl;
228 if(argument.CompareTo("-port")==0)
234 fgPorts[fgNPorts] = atoi(argv[i]);
235 cout << "A setting port to " << fgPorts[fgNPorts] <<endl;
242 fgPorts[fgNPorts] = DEFAULTEVENTPORT;
243 cout << "B setting port to " << fgPorts[fgNPorts] <<endl;
252 if(hostIsSet != kTRUE || portIsSet != kTRUE)
254 if(hostIsSet == kFALSE)
256 printf("\nERROR: no hostname is specified\n");
259 if( portIsSet == kFALSE)
261 printf("ERROR: no port spcified\n");
263 printf("\nYou must specify at least one host \n\n");
264 printf("*****************************************************************\n");
265 printf("\nUsage: ./onlinedisplay -host <hostname> -port <port>");
266 printf("\n-port is optional, if not set port 42001 will be used\n");
267 printf("*****************************************************************\n\n\n");
283 AliHLTPHOSOnlineDisplay::Gain2Text(const int gain, char *txt) const
285 // See header file for documentation
289 sprintf(txt,"Low Gain");
292 else if(gain == HIGHGAIN)
294 sprintf(txt,"High Gain");
299 sprintf(txt,"Error!! invalid gain %d", gain);