]>
Commit | Line | Data |
---|---|---|
1b41ab20 | 1 | // $Id$ |
2 | ||
36f19b25 | 3 | /************************************************************************** |
4 | * Copyright(c) 2006, ALICE Experiment at CERN, All rights reserved. * | |
5 | * * | |
6 | * Authors: Per Thomas Hille for the ALICE * | |
7 | * offline/HLT Project. Contributors are mentioned in the code where * | |
8 | * appropriate. * | |
9 | * * | |
10 | * Permission to use, copy, modify and distribute this software and its * | |
11 | * documentation strictly for non-commercial purposes is hereby granted * | |
12 | * without fee, provided that the above copyright notice appears in all * | |
13 | * copies and that both the copyright notice and this permission notice * | |
14 | * appear in the supporting documentation. The authors make no claims * | |
15 | * about the suitability of this software for any purpose. It is * | |
16 | * provided "as is" without express or implied warranty. * | |
17 | **************************************************************************/ | |
18 | ||
f704525c | 19 | #include "AliHLTPHOSOnlineDisplayFourierTab.h" |
20 | #include <iostream> | |
21 | #include "TGFrame.h" | |
22 | #include "AliHLTPHOSGetEventButton.h" | |
23 | #include "AliHLTPHOSCommonDefs.h" | |
24 | #include "AliHLTDataTypes.h" | |
25 | #include "AliHLTHOMERData.h" | |
26 | #include "AliHLTHOMERReader.h" | |
27 | #include "AliHLTHOMERWriter.h" | |
f704525c | 28 | //#include "AliHLTPHOSRcuCellEnergyDataStruct.h" |
cf91bd75 | 29 | //#include "AliHLTPHOSRcuCellEnergyDataStruct.h" |
30 | //#include "AliHLTPHOSRcuCellEnergyDataStruct.h" | |
f704525c | 31 | #include "AliHLTPHOSOnlineDisplay.h" |
cf91bd75 | 32 | #include "AliHLTPHOSSharedMemoryInterfacev2.h" |
f704525c | 33 | #include "AliHLTPHOSFourier.h" |
36f19b25 | 34 | #include "AliHLTPHOSOnlineDisplayTH2D.h" |
d456fffb | 35 | |
36 | ||
f704525c | 37 | #include "AliHLTPHOSRcuFFTDataStruct.h" |
38 | #include "TStyle.h" | |
39 | ||
27029341 | 40 | #define SAMPLINGFREQUENCY 10 |
f704525c | 41 | |
f704525c | 42 | // MT Crap |
43 | #include <TMath.h> | |
44 | //#include <TEveManager.h> | |
45 | //#include <TEveBoxSet.h> | |
46 | ||
a7f38894 | 47 | using namespace std; |
48 | ||
f704525c | 49 | //TEveBoxSet* gAliEveBoxSet = 0; |
50 | ||
51 | AliHLTPHOSOnlineDisplayFourierTab::AliHLTPHOSOnlineDisplayFourierTab() | |
52 | { | |
36f19b25 | 53 | // See header file for documentation |
f704525c | 54 | cout << "ERROR: You cannot create a onlinedisplay Tab without arguments" << endl; |
55 | } | |
56 | ||
57 | ||
36f19b25 | 58 | AliHLTPHOSOnlineDisplayFourierTab::AliHLTPHOSOnlineDisplayFourierTab(AliHLTPHOSOnlineDisplay * const onlineDisplayPtr, TGTab *tabPtr, |
59 | const AliHLTHOMERReader * homerSyncPtr, const AliHLTHOMERReader * const homerPtrs[MAXHOSTS], int nHosts) : AliHLTPHOSOnlineDisplayTab(), fEvtCnt(0) | |
f704525c | 60 | { |
36f19b25 | 61 | // See header file for documentation |
f704525c | 62 | // gStyle->SetOptLogy(); |
63 | // gStyle->SetOptStat(false); | |
64 | ||
65 | ||
cf91bd75 | 66 | fShmPtr = new AliHLTPHOSSharedMemoryInterfacev2(); |
f704525c | 67 | fOnlineDisplayPtr = onlineDisplayPtr; |
68 | fFourierPtr = new AliHLTPHOSFourier(); | |
69 | ||
27029341 | 70 | for(int gain = 0; gain < NGAINS; gain ++ ) |
f704525c | 71 | { |
72 | fFourierHistoNew[gain] = 0; | |
73 | fFourierHistoOld[gain] = 0; | |
74 | fFourierHistoAccumulated[gain] = 0; | |
75 | } | |
76 | ||
27029341 | 77 | for(int i=0; i<MAXHOSTS; i++) |
f704525c | 78 | { |
79 | fgHomerReadersPtr[i] = 0; | |
80 | } | |
81 | ||
36f19b25 | 82 | fgHomerReaderPtr = const_cast<AliHLTHOMERReader*>(homerSyncPtr); |
f704525c | 83 | |
84 | for(int i=0; i<nHosts; i++) | |
85 | { | |
36f19b25 | 86 | fgHomerReadersPtr[i] = const_cast<AliHLTHOMERReader*>(homerPtrs[i]); |
f704525c | 87 | |
88 | } | |
89 | ||
90 | fgNHosts = nHosts; | |
91 | InitDisplay(tabPtr); | |
92 | } | |
93 | ||
94 | ||
95 | AliHLTPHOSOnlineDisplayFourierTab::~AliHLTPHOSOnlineDisplayFourierTab() | |
f704525c | 96 | |
36f19b25 | 97 | { |
98 | // See header file for documentation | |
f704525c | 99 | } |
100 | ||
101 | ||
102 | ||
103 | int | |
104 | AliHLTPHOSOnlineDisplayFourierTab::GetNextEvent() | |
105 | { | |
36f19b25 | 106 | // See header file for documentation |
f704525c | 107 | // ResetDisplay(); |
108 | DoGetNextEvent(); | |
109 | // FillHistograms(); | |
110 | UpdateDisplay(); | |
111 | fEvtCnt ++; | |
112 | // fgEvntCnt ++; | |
113 | ||
114 | ||
115 | } | |
116 | ||
117 | ||
118 | ||
119 | void | |
36f19b25 | 120 | AliHLTPHOSOnlineDisplayFourierTab::ReadBlockData(AliHLTHOMERReader * const homeReaderPtr) |
121 | { | |
122 | // See header file for documentation | |
cf91bd75 | 123 | // AliHLTPHOSValidCellDataStruct *currentChannel =0; |
f704525c | 124 | cout << "AliHLTPHOSOnlineDisplayFourierTab::ReadBlockDat, Reading block data, therere are " << homeReaderPtr->GetBlockCnt() << " blocks " <<endl; |
d456fffb | 125 | // unsigned long blk = homeReaderPtr->FindBlockNdx("RENELLEC","SOHP", 0xFFFFFFFF ); |
126 | ||
127 | // while ( blk != ~(unsigned long)0 ) | |
128 | // { | |
129 | // Int_t moduleID; | |
130 | // Int_t rcuX = 0; | |
131 | // Int_t rcuZ = 0; | |
132 | // AliHLTPHOSRcuCellEnergyDataStruct* cellEnergiesPtr = (AliHLTPHOSRcuCellEnergyDataStruct*)homeReaderPtr->GetBlockData( blk ); | |
f704525c | 133 | |
d456fffb | 134 | // unsigned int *t = (unsigned int*)cellEnergiesPtr; |
f704525c | 135 | |
d456fffb | 136 | // moduleID = cellEnergiesPtr->fModuleID ; |
137 | // rcuX = cellEnergiesPtr->fRcuX; | |
138 | // rcuZ = cellEnergiesPtr->fRcuZ; | |
139 | ||
140 | // cout << "AliHLTPHOSOnlineDisplayFourierTab::ReadBlockData, fModuleID =" <<moduleID << endl; | |
141 | ||
142 | // Int_t tmpZ; | |
143 | // Int_t tmpX; | |
144 | // Int_t tmpGain; | |
145 | // int cnt = 0; | |
146 | // Int_t* tmpPtr = 0; | |
147 | ||
148 | // fShmPtr->SetMemory(cellEnergiesPtr); | |
149 | // currentChannel = fShmPtr->NextChannel(); | |
150 | ||
151 | // while(currentChannel != 0) | |
152 | // { | |
153 | // cnt ++; | |
154 | // tmpZ = currentChannel->fZ; | |
155 | // tmpX = currentChannel->fX; | |
156 | // tmpGain = currentChannel->fGain; | |
157 | ||
158 | // if(cellEnergiesPtr->fHasRawData == true) | |
159 | // { | |
160 | // Int_t nSamples = 0; | |
161 | // Int_t* rawPtr = 0; | |
162 | // rawPtr = fShmPtr->GetRawData(nSamples); | |
163 | // fFourierPtr->ProcessFourier(rawPtr, nSamples, tmpZ, tmpX, tmpGain, fEvtCnt); | |
164 | // } | |
165 | ||
166 | // currentChannel = fShmPtr->NextChannel(); | |
167 | // } | |
168 | // blk = homeReaderPtr->FindBlockNdx("RENELLEC","SOHP", 0xFFFFFFFF, blk+1); | |
169 | // } | |
f704525c | 170 | |
d456fffb | 171 | // FillHistograms(fFourierPtr->GetPSD(), fFourierPtr->GetDataSize()); |
f704525c | 172 | |
d456fffb | 173 | unsigned long blk = homeReaderPtr->FindBlockNdx("TREIRUOF","SOHP", 0x0); |
174 | while ( blk != ~(unsigned long)0 ) | |
175 | { | |
176 | AliHLTPHOSRcuFFTDataStruct* fftDataPtr = (AliHLTPHOSRcuFFTDataStruct*)homeReaderPtr->GetBlockData( blk ); | |
177 | FillHistograms(*fftDataPtr, fftDataPtr->fDataLength); | |
f704525c | 178 | |
d456fffb | 179 | blk = homeReaderPtr->FindBlockNdx("TREIRUOF","SOHP", blk+1); |
f704525c | 180 | } |
f704525c | 181 | } |
182 | ||
183 | ||
184 | ||
185 | void | |
186 | AliHLTPHOSOnlineDisplayFourierTab::FillHistograms(const AliHLTPHOSRcuFFTDataStruct psd, const int size) | |
187 | { | |
36f19b25 | 188 | // See header file for documentation |
f704525c | 189 | // gStyle->SetOptLogy(); |
190 | // gStyle->SetOptStat(false); | |
191 | ||
192 | char tmpname[256]; | |
193 | char tmptitle[256]; | |
194 | ||
195 | int linewidth = 0; | |
196 | // double linewidth = 1.2; | |
197 | ||
27029341 | 198 | for(int gain = 0; gain < NGAINS; gain ++ ) |
f704525c | 199 | { |
200 | if( fFourierHistoNew[gain] == 0) | |
201 | { | |
202 | sprintf(tmptitle, "PSD averaged over all %s channels: Most recent event", Gain2Text(gain, ' ')); | |
203 | sprintf(tmpname, "PSD_averaged_over_all_%s_channels__most_recent_event", Gain2Text(gain, '_')); | |
27029341 | 204 | fFourierHistoNew[gain] = new TH1D(tmpname, tmptitle, (size/2) +1, 0, SAMPLINGFREQUENCY/2); |
f704525c | 205 | fFourierHistoNew[gain]->GetXaxis()->SetTitle("f/MHz"); |
206 | fFourierHistoNew[gain]->GetYaxis()->SetTitle("Power (arbitrary units)"); | |
207 | fFourierHistoNew[gain]->SetLineWidth(linewidth); | |
208 | ||
209 | } | |
210 | if (fFourierHistoOld[gain] == 0) | |
211 | { | |
212 | sprintf(tmptitle, "PSD averaged over all %s channels: Previous event", Gain2Text(gain, ' ')); | |
213 | sprintf(tmpname, "PSD_averaged_over_all_%s_channels__previous_event", Gain2Text(gain, '_')); | |
27029341 | 214 | fFourierHistoOld[gain] = new TH1D(tmpname, tmptitle, (size/2) +1, 0, SAMPLINGFREQUENCY/2); |
f704525c | 215 | fFourierHistoOld[gain]->GetXaxis()->SetTitle("f/MHz"); |
216 | fFourierHistoOld[gain]->GetYaxis()->SetTitle("Power (arbitrary units)"); | |
217 | fFourierHistoOld[gain]->SetLineWidth(linewidth); | |
218 | ||
219 | } | |
220 | if( fFourierHistoAccumulated[gain] == 0 ) | |
221 | { | |
222 | sprintf(tmptitle, "PSD averaged over all %s channels: All events", Gain2Text(gain, ' ')); | |
223 | sprintf(tmpname, "PSD_averaged_over_all_%s_channels__All_events", Gain2Text(gain, '_')); | |
27029341 | 224 | fFourierHistoAccumulated[gain] = new TH1D(tmpname, tmptitle, (size/2) +1, 0, SAMPLINGFREQUENCY/2); |
f704525c | 225 | fFourierHistoAccumulated[gain]->GetXaxis()->SetTitle("f/MHz"); |
226 | fFourierHistoAccumulated[gain]->GetYaxis()->SetTitle("Power (arbitrary units)"); | |
227 | fFourierHistoAccumulated[gain]->SetLineWidth(linewidth); | |
228 | ||
229 | } | |
230 | ||
d456fffb | 231 | // fFourierHistoNew[gain]->Reset(); |
232 | // fFourierHistoOld[gain]->Reset(); | |
233 | // fFourierHistoAccumulated[gain]->Reset(); | |
234 | ||
f704525c | 235 | for(int i = 0; i <size/2; i++) |
236 | { | |
237 | fFourierHistoOld[gain]->SetBinContent(i+1, fFourierHistoNew[gain]->GetBinContent(i+1)); | |
238 | fFourierHistoNew[gain]->SetBinContent(i+1, psd.fGlobalLastPSD[gain][i] ); | |
239 | fFourierHistoAccumulated[gain]->SetBinContent(i+1, psd.fGlobalAccumulatedPSD[gain][i] ); | |
240 | } | |
241 | ||
242 | } | |
243 | } | |
244 | ||
245 | ||
246 | ||
247 | ||
248 | void | |
249 | AliHLTPHOSOnlineDisplayFourierTab::InitDisplay(TGTab *tabPtr) | |
250 | { | |
36f19b25 | 251 | // See header file for documentatino |
27029341 | 252 | for(int gain=0; gain < NGAINS; gain++) |
f704525c | 253 | { |
254 | char gainLabel[100]; | |
255 | char label[256]; | |
256 | ||
257 | // Gain2Text | |
258 | fOnlineDisplayPtr->Gain2Text(gain,gainLabel); | |
259 | sprintf(label, "PHOS Fourier transform %s", gainLabel); | |
260 | fgLegoPlotPtr[gain] = new AliHLTPHOSOnlineDisplayTH2D(fOnlineDisplayPtr, label, label, | |
27029341 | 261 | NXCOLUMNSMOD*NMODULES , 0, NXCOLUMNSMOD*NMODULES, |
262 | NZROWSMOD, 0, NZROWSMOD); | |
263 | // fgLegoPlotPtr[gain]->SetGain(HIGHGAIN); | |
f704525c | 264 | fgLegoPlotPtr[gain]->SetMaximum(1023); |
265 | fgLegoPlotPtr[gain]->Reset(); | |
27029341 | 266 | fgLegoPlotPtr[gain]->GetXaxis()->SetRange(XRANGESTART, XRANGEEND); |
f704525c | 267 | |
268 | } | |
269 | ||
270 | ||
271 | ||
272 | TGLayoutHints *fL1 = new TGLayoutHints(kLHintsBottom | kLHintsExpandX | | |
273 | kLHintsExpandY, 2, 2, 15, 1); | |
274 | ||
275 | TGCompositeFrame *tf = tabPtr->AddTab("Power spectrum"); | |
276 | fSubTab1 = new TGTab(tf, 100, 100); | |
277 | TGCompositeFrame *tf2 = fSubTab1->AddTab("Most recent event"); | |
278 | fSubF1 = new TGCompositeFrame(tf2, 60, 20, kVerticalFrame); | |
279 | fEc1 = new TRootEmbeddedCanvas("ecf1", fSubF1, 100, 100); | |
280 | fSubF1->AddFrame(fEc1, fL1); | |
281 | fEc2 = new TRootEmbeddedCanvas("ecf2", fSubF1, 100, 100); | |
282 | fSubF1->AddFrame(fEc2, fL1); | |
283 | tf2->AddFrame(fSubF1, fL1); | |
284 | ||
285 | tf2 = fSubTab1->AddTab("Previous event"); | |
286 | fSubF2 = new TGCompositeFrame(tf2, 60, 20, kVerticalFrame); | |
287 | tf2->AddFrame(fSubF2, fL1); | |
288 | fEc3 = new TRootEmbeddedCanvas("ecf3", fSubF2, 100, 100); | |
289 | fSubF2->AddFrame(fEc3, fL1); | |
290 | fEc4 = new TRootEmbeddedCanvas("ecf4", fSubF2, 100, 100); | |
291 | fSubF2->AddFrame(fEc4, fL1); | |
292 | ||
293 | ||
294 | tf2 = fSubTab1->AddTab("Accumulated"); | |
295 | fSubF3 = new TGCompositeFrame(tf2, 60, 20, kVerticalFrame); | |
296 | tf2->AddFrame(fSubF3, fL1); | |
297 | fEc5 = new TRootEmbeddedCanvas("ecf5", fSubF3, 100, 100); | |
298 | fSubF3->AddFrame(fEc5, fL1); | |
299 | fEc6 = new TRootEmbeddedCanvas("ecf6", fSubF3, 100, 100); | |
300 | fSubF3->AddFrame(fEc6, fL1); | |
301 | fSubTab1->Resize(); | |
302 | tf->AddFrame(fSubTab1, fL1); | |
303 | ||
304 | ||
305 | fgEventButtPtr = new AliHLTPHOSGetEventButton(fSubF1, "get fourier", 'e'); | |
306 | } | |
307 | ||
308 | ||
309 | ||
310 | void | |
311 | AliHLTPHOSOnlineDisplayFourierTab::UpdateDisplay() | |
312 | { | |
36f19b25 | 313 | // See header file for documentation |
27029341 | 314 | if( fFourierHistoNew[HIGHGAIN]) |
d456fffb | 315 | { |
27029341 | 316 | fgCanvasPtr[HIGHGAIN] = fEc1->GetCanvas(); |
317 | fgCanvasPtr[HIGHGAIN]->cd(); | |
d456fffb | 318 | gPad->SetLogy(); |
27029341 | 319 | // fgLegoPlotPtr[HIGHGAIN]->Draw("LGZ"); |
320 | fFourierHistoNew[HIGHGAIN]->Draw(); | |
321 | fgCanvasPtr[HIGHGAIN]->Update(); | |
d456fffb | 322 | } |
323 | ||
27029341 | 324 | if( fFourierHistoNew[LOWGAIN]) |
d456fffb | 325 | { |
27029341 | 326 | fgCanvasPtr[LOWGAIN] = fEc2->GetCanvas(); |
327 | fgCanvasPtr[LOWGAIN]->cd(); | |
d456fffb | 328 | gPad->SetLogy(); |
27029341 | 329 | // fgLegoPlotPtr[LOWGAIN]->Draw("HGZ"); |
330 | fFourierHistoNew[LOWGAIN]->Draw(); | |
331 | fgCanvasPtr[LOWGAIN]->Update(); | |
d456fffb | 332 | } |
27029341 | 333 | if( fFourierHistoOld[HIGHGAIN]) |
d456fffb | 334 | { |
27029341 | 335 | fgCanvasPtr[HIGHGAIN] = fEc3->GetCanvas(); |
336 | fgCanvasPtr[HIGHGAIN]->cd(); | |
d456fffb | 337 | gPad->SetLogy(); |
27029341 | 338 | // fgLegoPlotPtr[HIGHGAIN]->Draw("Low gain"); |
339 | fFourierHistoOld[HIGHGAIN]->Draw(); | |
340 | fgCanvasPtr[HIGHGAIN]->Update(); | |
d456fffb | 341 | } |
342 | ||
27029341 | 343 | if( fFourierHistoOld[LOWGAIN]) |
d456fffb | 344 | { |
27029341 | 345 | fgCanvasPtr[LOWGAIN] = fEc4->GetCanvas(); |
346 | fgCanvasPtr[LOWGAIN]->cd(); | |
347 | //fgLegoPlotPtr[LOWGAIN]->Draw("High gain"); | |
d456fffb | 348 | gPad->SetLogy(); |
27029341 | 349 | fFourierHistoOld[LOWGAIN]->Draw(); |
350 | fgCanvasPtr[LOWGAIN]->Update(); | |
d456fffb | 351 | } |
352 | ||
27029341 | 353 | if( fFourierHistoAccumulated[HIGHGAIN]) |
d456fffb | 354 | { |
27029341 | 355 | fgCanvasPtr[HIGHGAIN] = fEc5->GetCanvas(); |
356 | fgCanvasPtr[HIGHGAIN]->cd(); | |
d456fffb | 357 | gPad->SetLogy(); |
27029341 | 358 | fFourierHistoAccumulated[HIGHGAIN]->Draw(); |
359 | // fgLegoPlotPtr[HIGHGAIN]->Draw("CONTZ"); | |
360 | fgCanvasPtr[HIGHGAIN]->Update(); | |
d456fffb | 361 | } |
362 | ||
27029341 | 363 | if( fFourierHistoAccumulated[LOWGAIN]) |
d456fffb | 364 | { |
27029341 | 365 | fgCanvasPtr[LOWGAIN] = fEc6->GetCanvas(); |
366 | fgCanvasPtr[LOWGAIN]->cd(); | |
d456fffb | 367 | gPad->SetLogy(); |
27029341 | 368 | // fgLegoPlotPtr[LOWGAIN]->Draw("CONTZ"); |
369 | fFourierHistoAccumulated[LOWGAIN]->Draw(); | |
370 | fgCanvasPtr[LOWGAIN]->Update(); | |
d456fffb | 371 | } |
f704525c | 372 | |
373 | } | |
374 | ||
375 | ||
376 | const char* | |
377 | AliHLTPHOSOnlineDisplayFourierTab::Gain2Text(const int gain, const char delimeter) | |
378 | { | |
36f19b25 | 379 | // See header file for documentation |
27029341 | 380 | if(gain == LOWGAIN) |
f704525c | 381 | { |
382 | sprintf(fGainText, "low%cgain", delimeter); | |
383 | ||
384 | } | |
27029341 | 385 | else if(gain == HIGHGAIN) |
f704525c | 386 | { |
387 | sprintf(fGainText, "high%cgain", delimeter); | |
388 | } | |
389 | else | |
390 | { | |
391 | sprintf(fGainText, "Error, invalid gain"); | |
392 | } | |
393 | return fGainText; | |
394 | } |