5 #include "AliRawEventHeaderBase.h"
6 #include "AliRawReaderRoot.h"
10 //_____________________________________________________________________________
11 TMCal::TMCal(const TGWindow *p, UInt_t w, UInt_t h, AliCaloCalibPedestal::kDetType detectorType) :
12 TMBaseModule(p, w, h),
13 fDetType(detectorType),
28 //PHOS/EMCAL MOOD Module;
29 // GUI related pointers (frames, canvases, buttons are initialized in the Construct* methods
30 // called later in this ctor.
32 //Create the object for making the histograms
33 fPedestals = new AliCaloCalibPedestal( fDetType );
34 // AliCaloCalibPedestal knows how many modules we have for PHOS or EMCAL
35 fNumModules = fPedestals->GetModules();
37 //Load the reference object (Note: a fixed path. This should be made a variable that can somehow be set other than via the constants file and recompiled..)
38 if (fDetType == AliCaloCalibPedestal::kPhos) {
39 if (fPedestals->LoadReferenceCalib(fgkReferenceFilePhos, fgkReferenceObject) != kTRUE) {
40 printf("Could not load PHOS reference calib.\n");
44 if (fPedestals->LoadReferenceCalib(fgkReferenceFileEmCal, fgkReferenceObject) != kTRUE) {
45 printf("Could not load EMCAL reference calib.\n");
49 //Init the readers and streams
50 InitRawReaderAndStream(fgkDefaultRunNo);
52 // standard style options:
53 //Make all histos use a more sensible palette.
54 gStyle->SetPalette(1);
55 //Kill the titles etc...
56 gStyle->SetOptStat(0);
57 //gStyle->SetOptTitle(0);
58 gStyle->SetTitleW(0.8);
59 gStyle->SetTitleH(0.08);
60 gStyle->SetTitleX(0.1);
61 gROOT->ForceStyle(kFALSE);
63 //Construct the various buttons and info 'menu' for the lower panel
66 //Construct the various tabs and frames
69 //Set the handler to handle the tab changing, so we can enforce the palette we like.
70 #ifdef fgkCustomDeadMapPalette
71 GetTab()->Connect("Selected(Int_t)", "TMCal", this, "OnTabChange(Int_t)");
75 //_____________________________________________________________________________
76 void TMCal::InitRawReaderAndStream(unsigned int runNo)
79 if (fDetType == AliCaloCalibPedestal::kPhos) {
80 snprintf(file, 256, fgkSourceFileTemplatePhos, runNo);
83 snprintf(file, 256, fgkSourceFileTemplateEmCal, runNo);
85 printf("\n TMCal::InitRawReaderAndStream file= %s \n", file);
89 //Initialize the raw readers
91 delete fCaloRawStream;
97 fRawReader = new AliRawReaderRoot(file);
98 fCaloRawStream = new AliCaloRawStream(fRawReader, (fDetType==AliCaloCalibPedestal::kPhos) ? "PHOS" : "EMCAL");
100 fCaloRawStream->SetOldRCUFormat(kTRUE); // should maybe have a switch for this later?
102 //Not sure if this should be here... get to the first event, or never look at the first one?
103 fRawReader->NextEvent();
105 //Reset the actual analysis, since we changed the source file
108 fPedestals->SetRunNumber(runNo);
110 //Set the histo titles
112 printf("Reference run #%i.\n", fPedestals->GetRefRunNumber());
115 //_____________________________________________________________________________
116 void TMCal::SetTitles()
119 for (int i = 0; i < fNumModules; i++) {
120 sprintf(title, "Pedestals, high gain, run #%.4i, module %i", fPedestals->GetRunNumber(), i);
121 fPedestals->GetPedProfileHighGain(i)->SetTitle(title);
122 sprintf(title, "Peak-Pedestals, high gain, run #%.4i, module %i", fPedestals->GetRunNumber(), i);
123 fPedestals->GetPeakProfileHighGain(i)->SetTitle(title);
125 sprintf(title, "Pedestals, low gain, run #%.4i, module %i", fPedestals->GetRunNumber(), i);
126 fPedestals->GetPedProfileLowGain(i)->SetTitle(title);
127 sprintf(title, "Peak-Pedestals, low gain, run #%.4i, module %i", fPedestals->GetRunNumber(), i);
128 fPedestals->GetPeakProfileLowGain(i)->SetTitle(title);
130 sprintf(title, "Peak-Pedestals difference, high gain, run #%.4i, module %i", fPedestals->GetRunNumber(), i);
131 fPedestals->GetPeakProfileHighGainDiff(i)->SetTitle(title);
132 sprintf(title, "Pedestals difference, high gain, run #%.4i, module %i", fPedestals->GetRunNumber(), i);
133 fPedestals->GetPedProfileHighGainDiff(i)->SetTitle(title);
135 sprintf(title, "Peak-Pedestals difference, low gain, run #%.4i, module %i", fPedestals->GetRunNumber(), i);
136 fPedestals->GetPeakProfileLowGainDiff(i)->SetTitle(title);
137 sprintf(title, "Pedestals difference, low gain, run #%.4i, module %i", fPedestals->GetRunNumber(), i);
138 fPedestals->GetPedProfileLowGainDiff(i)->SetTitle(title);
140 sprintf(title, "Peak-Pedestals ratio, high gain, run #%.4i, module %i", fPedestals->GetRunNumber(), i);
141 fPedestals->GetPeakProfileHighGainRatio(i)->SetTitle(title);
142 sprintf(title, "Pedestals ratio, high gain, run #%.4i, module %i", fPedestals->GetRunNumber(), i);
143 fPedestals->GetPedProfileHighGainRatio(i)->SetTitle(title);
145 sprintf(title, "Peak-Pedestals ratio, low gain, run #%.4i, module %i", fPedestals->GetRunNumber(), i);
146 fPedestals->GetPeakProfileLowGainRatio(i)->SetTitle(title);
147 sprintf(title, "Pedestals ratio, low gain, run #%.4i, module %i", fPedestals->GetRunNumber(), i);
148 fPedestals->GetPedProfileLowGainRatio(i)->SetTitle(title);
152 // Note: Dead map is currently only for high gain.. and we try to use a special palette style for it
153 gStyle->SetPalette(AliCaloCalibPedestal::kNumDeadMapStates, fDeadMapPalette);
154 for (int i = 0; i < fNumModules; i++) {
155 sprintf(title, "Dead map, high gain, run #%.4i, module %i", fPedestals->GetRunNumber(), i);
156 fPedestals->GetDeadMap(i)->SetTitle(title);
157 fPedestals->GetDeadMap(i)->UseCurrentStyle();
159 // back to standard palette
160 gStyle->SetPalette(1);
164 //_____________________________________________________________________________
165 void TMCal::ConstructMenu(UInt_t w)
166 {//Constructs the buttons and info 'menu'
168 //create frame for the High gain/Low gain -button
169 TGHorizontalFrame *buttonFrame = new TGHorizontalFrame(GetMainViewFrame(),(UInt_t)w,(UInt_t)30);
170 GetMainViewFrame()->AddFrame(buttonFrame,new TGLayoutHints(kLHintsTop|kLHintsExpandX,0,0,0,0));
172 //Create the high/lowgain button
173 fGainButton = new TGTextButton(buttonFrame,"Low gain");
174 fGainButton->Connect("Clicked()","TMCal",this,"OnGainButton()");
175 //fGainButton->AllowStayDown(kTRUE);
176 buttonFrame->AddFrame(fGainButton,new TGLayoutHints(kLHintsCenterY,0,(UInt_t)5,0,0));
178 fDeadCountText = new TGLabel(buttonFrame,"Run #0000: Dead: 000, 000%; 000 new, 0000 recov.; ref. run 0000");
179 //We set generous margins for the label to make sure the text fits even with 4-digit numbers.
180 fDeadCountText->SetMargins(fDeadCountText->GetLeftMargin()+fgkDeadCountTextMargin, fDeadCountText->GetRightMargin()+fgkDeadCountTextMargin, fDeadCountText->GetTopMargin(), fDeadCountText->GetBottomMargin());
181 buttonFrame->AddFrame(fDeadCountText, new TGLayoutHints(kLHintsCenterY, 0, (UInt_t)5, 0, 0));
183 //Create the one histo/multi-histo -selection buttons
184 TGButtonGroup * buttGr = new TGButtonGroup(buttonFrame, "Display module", kHorizontalFrame);
185 TGRadioButton * radButts[fNumModules + 1];
187 for (int i = 0; i < fNumModules; i++) {
188 sprintf(txt, "%i", i);
189 radButts[i] = new TGRadioButton(buttGr, new TGHotString(txt));
190 sprintf(txt, "OnModeButton(=%i)", i);
191 radButts[i]->Connect("Clicked()", "TMCal", this, txt);
194 radButts[fNumModules] = new TGRadioButton(buttGr, new TGHotString("All"));
195 sprintf(txt, "OnModeButton(=%i)", fNumModules);
196 radButts[fNumModules]->Connect("Clicked()", "TMCal", this, txt);
198 radButts[fVisibleModule]->SetState(kButtonDown);
199 buttonFrame->AddFrame(buttGr,new TGLayoutHints(kLHintsCenterY,0,(UInt_t)5,0,0));
202 //Add the run number entry
203 TGLabel * runnoText = new TGLabel(buttonFrame,"Run #: ");;
204 buttonFrame->AddFrame(runnoText, new TGLayoutHints(kLHintsCenterY, 0, (UInt_t)5, 0, 0));
205 fRunNoEntry = new TGNumberEntry(buttonFrame, fgkDefaultRunNo, 6, -1,TGNumberFormat::kNESInteger, //style
206 TGNumberFormat::kNEAPositive//input value filter
208 fRunNoEntry->Connect("ValueSet(Long_t)", "TMCal",this,"OnRunNoChange(Long_t)");
209 buttonFrame->AddFrame(fRunNoEntry,new TGLayoutHints(kLHintsCenterY|kLHintsLeft,0,(UInt_t)5,0,0));
214 //_____________________________________________________________________________
215 void TMCal::ConstructFullGUI()
216 {//Constructs the GUI
218 //We need to set the palette for drawing the dead map
219 fDeadMapPalette[AliCaloCalibPedestal::kAlive] = fgkLiveTowerColor;
220 fDeadMapPalette[AliCaloCalibPedestal::kDead] = fgkDeadTowerColor;
221 fDeadMapPalette[AliCaloCalibPedestal::kResurrected] = fgkResurrectedTowerColor;
222 fDeadMapPalette[AliCaloCalibPedestal::kRecentlyDeceased] = fgkRecentlyDeceasedTowerColor;
224 // set up the TPaveText to have the info on the palette also
225 fDeadMapPaveText = new TPaveText(0.9,0.7,0.995,0.9,"brNDC");
226 /* alive ones are not shown really..
227 TText *tAlive = fDeadMapPaveText->AddText("OK");
228 tAlive->SetTextColor(fgkLiveTowerColor);
230 TText *tDead = fDeadMapPaveText->AddText("Dead");
231 TText *tResurrected = fDeadMapPaveText->AddText("New OK");
232 TText *tRecentlyDeceased = fDeadMapPaveText->AddText("New Dead");
233 tDead->SetTextColor(fgkDeadTowerColor);
234 tResurrected->SetTextColor(fgkResurrectedTowerColor);
235 tRecentlyDeceased->SetTextColor(fgkRecentlyDeceasedTowerColor);
237 fPeaksTab = GetTab()->AddTab("Peak-Pedestal");
238 fPeaksFrameSingle = MakeSingleModuleTab(fPeaksTab, &fPeaksCanvasSingle, &fPeaksRangeSingle, kPeaksSingle, AliCaloCalibPedestal::GetSampleMin(),
239 AliCaloCalibPedestal::GetSampleMax(), fMaxPeak);
240 fPeaksFrame = MakeAllModulesTab(fPeaksTab, fPeaksCanvas, &fPeaksRange, kPeaks, AliCaloCalibPedestal::GetSampleMin(),
241 AliCaloCalibPedestal::GetSampleMax(), fMaxPeak);
242 fPeaksCanvas[fNumModules] = fPeaksCanvasSingle;
244 fPedsTab = GetTab()->AddTab("Pedestal");
245 fPedsFrameSingle = MakeSingleModuleTab(fPedsTab, &fPedsCanvasSingle, &fPedsRangeSingle, kPedsSingle, AliCaloCalibPedestal::GetSampleMin(),
246 AliCaloCalibPedestal::GetSampleMax(), fMaxPed);
247 fPedsFrame = MakeAllModulesTab(fPedsTab, fPedsCanvas, &fPedsRange, kPeds, AliCaloCalibPedestal::GetSampleMin(),
248 AliCaloCalibPedestal::GetSampleMax(), fMaxPed); //Create the all modules version of the tab
249 fPedsCanvas[fNumModules] = fPedsCanvasSingle;
252 fPeaksDiffTab = GetTab()->AddTab("Peak diff");
253 fPeaksDiffFrameSingle = MakeSingleModuleTab(fPeaksDiffTab, &fPeaksDiffCanvasSingle, &fPeaksDiffRangeSingle, kPeaksDiffSingle, AliCaloCalibPedestal::GetSampleMin(),
254 AliCaloCalibPedestal::GetSampleMax(), fMaxPeakDiff);
255 fPeaksDiffFrame = MakeAllModulesTab(fPeaksDiffTab, fPeaksDiffCanvas, &fPeaksDiffRange, kPeaksDiff, AliCaloCalibPedestal::GetSampleMin(),
256 AliCaloCalibPedestal::GetSampleMax(), fMaxPeakDiff);
257 fPeaksDiffTab->MapSubwindows();
258 fPeaksDiffCanvas[fNumModules] = fPeaksDiffCanvasSingle; //Copy the pointer to the array, so we can just loop over this one too
261 fPedsDiffTab = GetTab()->AddTab("Pedestal diff");
262 fPedsDiffFrameSingle = MakeSingleModuleTab(fPedsDiffTab, &fPedsDiffCanvasSingle, &fPedsDiffRangeSingle, kPedsDiffSingle, AliCaloCalibPedestal::GetSampleMin(),
263 AliCaloCalibPedestal::GetSampleMax(), fMaxPedDiff);
264 fPedsDiffFrame = MakeAllModulesTab(fPedsDiffTab, fPedsDiffCanvas, &fPedsDiffRange, kPedsDiff, AliCaloCalibPedestal::GetSampleMin(),
265 AliCaloCalibPedestal::GetSampleMax(), fMaxPedDiff);
266 fPedsDiffCanvas[fNumModules] = fPedsDiffCanvasSingle;
268 fPeaksRatioTab = GetTab()->AddTab("Peak ratio");
269 fPeaksRatioFrameSingle = MakeSingleModuleTab(fPeaksRatioTab, &fPeaksRatioCanvasSingle, &fPeaksRatioRangeSingle, kPeaksRatioSingle,
270 fgkMinMaxRatioExp*fgkRatioStepScale, fgkMaxMaxRatioExp*fgkRatioStepScale,
271 -(log(fMaxPeakRatio)/log(2))*fgkRatioStepScale + fgkMaxMaxRatioExp*fgkRatioStepScale);
272 fPeaksRatioFrame = MakeAllModulesTab(fPeaksRatioTab, fPeaksRatioCanvas, &fPeaksRatioRange, kPeaksRatio,
273 fgkMinMaxRatioExp*fgkRatioStepScale, fgkMaxMaxRatioExp*fgkRatioStepScale,
274 -(log(fMaxPeakRatio)/log(2))*fgkRatioStepScale + fgkMaxMaxRatioExp*fgkRatioStepScale);
275 fPeaksRatioCanvas[fNumModules] = fPeaksRatioCanvasSingle;
277 fPedsRatioTab = GetTab()->AddTab("Pedestal ratio");
278 fPedsRatioFrameSingle = MakeSingleModuleTab(fPedsRatioTab, &fPedsRatioCanvasSingle, &fPedsRatioRangeSingle, kPedsRatioSingle,
279 fgkMinMaxRatioExp*fgkRatioStepScale, fgkMaxMaxRatioExp*fgkRatioStepScale,
280 -(log(fMaxPedRatio)/log(2))*fgkRatioStepScale + fgkMaxMaxRatioExp*fgkRatioStepScale);
281 fPedsRatioFrame = MakeAllModulesTab(fPedsRatioTab, fPedsRatioCanvas, &fPedsRatioRange, kPedsRatio,
282 fgkMinMaxRatioExp*fgkRatioStepScale, fgkMaxMaxRatioExp*fgkRatioStepScale,
283 -(log(fMaxPedRatio)/log(2))*fgkRatioStepScale + fgkMaxMaxRatioExp*fgkRatioStepScale);
284 fPedsRatioCanvas[fNumModules] = fPedsRatioCanvasSingle;
286 fDeadMapTab = GetTab()->AddTab(fgkDeadMapTabName);
287 fDeadMapFrameSingle = MakeSingleModuleTab(fDeadMapTab, &fDeadMapCanvasSingle);
288 fDeadMapFrame = MakeAllModulesTab(fDeadMapTab, fDeadMapCanvas);
289 fDeadMapCanvas[fNumModules] = fDeadMapCanvasSingle;
293 UpdateMonitors();//This is actually just to update the status text... which should then perhaps be done elsewhere, so we could call that separately,
294 //but since it's needed in exactly one place, I'm too lazy...
299 //_____________________________________________________________________________
300 TGCompositeFrame * TMCal::MakeAllModulesTab(TGCompositeFrame * tab,
301 TCanvas **canvArray, //Array of pointers to the canvases to which the histos have been drawn. MUST be initialized.
302 TGVSlider **slider, //The pointer to the pointer to the slider, which to put the pointer to the slider to
303 kTab tabId, //The tab Id which the slider should give as a parameter when connecting
304 double sliderMin, double sliderMax, double sliderPos //The range and position of the slider
306 {//The function to create a tab full of histos
308 //The frames. The magic numbers here don't really matter, because the ExpandX and ExpandY
309 //hints will override them anyway. If this behaviour is modified, then these numbers
310 //should be properly declared as constants.
311 TGHorizontalFrame * verFrame = new TGHorizontalFrame(tab, (UInt_t)5*400, (UInt_t)600);
312 TGCompositeFrame * histoFrame = new TGCompositeFrame(verFrame,(UInt_t)40, (UInt_t)400);
314 //Make the layout manager a matrix style
315 histoFrame->SetLayoutManager(new TGMatrixLayout(histoFrame, 0, fgkHistosPerRow));
317 //Add a vertical frame to stack the high/low -gain histos on top of each others
318 tab->AddFrame(verFrame, new TGLayoutHints(kLHintsExpandX, 0, 0, 0, 0));
321 if (slider) {//Add the slider to the histoframe
322 TGVSlider * range = new TGVSlider(verFrame, fgk2DHistoHeight, kSlider1);
323 range->SetRange((int)sliderMin, (int)sliderMax);
324 range->SetPosition( (int)(sliderMax - sliderPos) ); //We have to invert this by hand
326 sprintf(str, "OnRange(=%u)", (int)tabId);
327 //range->Connect("PositionChanged(Int_t)", "TMCal",this,str);
328 range->Connect("Released()", "TMCal",this,str);
329 verFrame->AddFrame(range,new TGLayoutHints(0,0,fgk2DHistoMarginX,0,0));
333 //Add the horizontal frames which layout the individual histos for each module
334 verFrame->AddFrame(histoFrame, new TGLayoutHints(kLHintsExpandX|kLHintsExpandY, 0, 0, 0, 0));
336 //-------------------------------------
337 //Create the canvases
339 TString canvasName = tab->GetName();
340 for (int i = 0; i < fNumModules; i++) {
342 TRootEmbeddedCanvas *ECanvas = new TRootEmbeddedCanvas(canvasName + " " + (TString)i,histoFrame,fgk2DHistoWidth,fgk2DHistoHeight);
345 histoFrame->AddFrame(ECanvas, new TGLayoutHints(0, fgk2DHistoMarginX,0, fgk2DHistoMarginY, 0));
347 canvArray[i] = ECanvas->GetCanvas();
353 //_____________________________________________________________________________
354 TGCompositeFrame * TMCal::MakeSingleModuleTab(TGCompositeFrame * tab,
356 TGVSlider **slider, //The pointer to the pointer to the slider, which to put the pointer to the slider to
357 kTab tabId, //The tab Id which the slider should give as a parameter when connecting
358 double sliderMin, double sliderMax, double sliderPos //The range and position of the slider
360 {//The function to create a tab with a single big histo.
362 //TODO: consider if we really need the vertical frame at all, or should just arrange everything to the horizontal frame...
364 //The frames. The magic numbers here don't really matter, because the ExpandX and ExpandY
365 //hints will override them anyway. If this behaviour is modified, then these numbers
366 //should be properly declared as constants.
367 TGVerticalFrame * verFrame = new TGVerticalFrame(tab, (UInt_t)5*400, (UInt_t)600);
368 TGHorizontalFrame * histoFrame = new TGHorizontalFrame(verFrame,(UInt_t)400, (UInt_t)400);
370 //Add a vertical frame to stack the high/low -gain histos on top of each others
371 tab->AddFrame(verFrame, new TGLayoutHints(kLHintsExpandX, 0, 0, 0, 0));
373 //Add the horizontal frames which layout the individual histos for each module
374 verFrame->AddFrame(histoFrame, new TGLayoutHints(kLHintsExpandX|kLHintsExpandY, 0, 0, 0, 0));
376 if (slider) {//Add the slider to the histoframe
377 TGVSlider * range = new TGVSlider(histoFrame, fgk2DSingleHistoHeight, kSlider1);
378 range->SetRange((int)sliderMin, (int)sliderMax);
379 range->SetPosition( (int)(sliderMax - sliderPos) ); //We have to invert this by hand
381 sprintf(str, "OnRange(=%u)", (int)tabId);
382 //range->Connect("PositionChanged(Int_t)", "TMCal",this,str);
383 range->Connect("Released()", "TMCal",this,str);
384 histoFrame->AddFrame(range,new TGLayoutHints(0,0,0,0,0));
388 //-------------------------------------
391 TString canvasName = tab->GetName();
393 TRootEmbeddedCanvas *ECanvas = new TRootEmbeddedCanvas(canvasName + " single",histoFrame,fgk2DSingleHistoWidth,fgk2DSingleHistoHeight);
395 histoFrame->AddFrame(ECanvas, new TGLayoutHints(0, fgk2DSingleHistoMarginX,0, fgk2DSingleHistoMarginY, 0));
397 *canvas = ECanvas->GetCanvas();
402 //_____________________________________________________________________________
403 void TMCal::MonitorEvent(void)
405 // printf("Monitoring for the %ith time this evening.\n", i);
406 //Process the next event
407 if (fRawReader->NextEvent())
409 AliRawEventHeaderBase *aliHeader = (AliRawEventHeaderBase*) fRawReader->GetEventHeader();
411 if (aliHeader->Get("Type") == AliRawEventHeaderBase::kPhysicsEvent)
414 //printf("A physics event.\n");
415 fPedestals->ProcessEvent(fCaloRawStream);
417 // printf("A non-physics event.\n");
422 //_____________________________________________________________________________
423 void TMCal::UpdateMonitors(void)
425 //Just update all the histograms
426 fPedestals->ComputeDiffAndRatio();//Re-compute the difference and the ratio
427 //Update the dead cells count
428 fPedestals->ComputeDeadTowers(fgkDeadThreshold);
429 for (int i = 0; (i < fNumModules) && (!fSingleModule); i++) {
430 fPeaksCanvas[i]->Paint();
431 fPeaksCanvas[i]->Update();
432 fPeaksCanvas[i]->Paint();
434 fPedsCanvas[i]->Paint();
435 fPedsCanvas[i]->Update();
436 fPedsCanvas[i]->Paint();
438 fPedsDiffCanvas[i]->Paint();
439 fPedsDiffCanvas[i]->Update();
440 fPedsDiffCanvas[i]->Paint();
442 fPeaksDiffCanvas[i]->Paint();
443 fPeaksDiffCanvas[i]->Update();
444 fPeaksDiffCanvas[i]->Paint();
446 fPedsRatioCanvas[i]->Paint();
447 fPedsRatioCanvas[i]->Update();
448 fPedsRatioCanvas[i]->Paint();
450 fPeaksRatioCanvas[i]->Paint();
451 fPeaksRatioCanvas[i]->Update();
452 fPeaksRatioCanvas[i]->Paint();
454 fPedestals->GetDeadMap(i)->UseCurrentStyle();
455 fDeadMapCanvas[i]->Paint();
456 fDeadMapCanvas[i]->Update();
457 fDeadMapCanvas[i]->Paint();
461 fPeaksCanvasSingle->Paint();
462 fPeaksCanvasSingle->Update();
463 fPeaksCanvasSingle->Paint();
465 fPeaksCanvasSingle->Paint();
466 fPedsCanvasSingle->Update();
467 fPedsCanvasSingle->Paint();
469 fPeaksCanvasSingle->Paint();
470 fPedsDiffCanvasSingle->Update();
471 fPedsDiffCanvasSingle->Paint();
473 fPeaksCanvasSingle->Paint();
474 fPeaksDiffCanvasSingle->Update();
475 fPeaksDiffCanvasSingle->Paint();
477 fPeaksCanvasSingle->Paint();
478 fPedsRatioCanvasSingle->Update();
479 fPedsRatioCanvasSingle->Paint();
481 fPeaksCanvasSingle->Paint();
482 fPeaksRatioCanvasSingle->Update();
483 fPeaksRatioCanvasSingle->Paint();
485 fPedestals->GetDeadMap(fVisibleModule)->UseCurrentStyle();
486 fDeadMapCanvasSingle->Paint();
487 fDeadMapCanvasSingle->Update();
488 fDeadMapCanvasSingle->Paint();
492 sprintf(tmp, "Run #%.4i: Dead: %i, %.1f%%; %i new, %i recov.; Ref. run %i",
493 fPedestals->GetRunNumber(), (int)fPedestals->GetDeadTowerCount(),
494 (float)(100.0*fPedestals->GetDeadTowerRatio()),
495 (int)fPedestals->GetDeadTowerNew(),
496 (int)fPedestals->GetDeadTowerResurrected(), (int)fPedestals->GetRefRunNumber());
498 fDeadCountText->SetText(tmp);
503 //_____________________________________________________________________________
504 void TMCal::PostMonitor(void)
506 fPedestals->ComputeDeadTowers(fgkDeadThreshold, fgkDeadMapName);//Write out the deadmap
510 //_____________________________________________________________________________
513 if (fCaloRawStream) delete fCaloRawStream;
514 if (fRawReader) delete fRawReader;
515 if (fPedestals) delete fPedestals;
518 //_____________________________________________________________________________
519 void TMCal::DrawHistos() { // Gain button handler
520 //Recalculate the differences and ratios (because this causes a screen update)
521 fPedestals->ComputeDiffAndRatio();
523 //Finally draw the deadmap. This has to be done outside the low/highgain iffing.
524 //There is probably a smoother way to do this than by repeating the loop, though...
525 for (int i = 0; (i < fNumModules) && (!fSingleModule); i++) {
526 fDeadMapCanvas[i]->cd();
528 fPedestals->GetDeadMap(i)->Draw("col");
529 // also a TPaveText with info on what the colors mean
530 fDeadMapPaveText->Draw();
531 fDeadMapCanvas[i]->Update();
532 fDeadMapCanvas[i]->Paint();
536 fDeadMapCanvasSingle->cd();
537 fPedestals->GetDeadMap(fVisibleModule)->Draw("col");
538 // also a TPaveText with info on what the colors mean
539 fDeadMapPaveText->Draw();
540 fDeadMapCanvasSingle->Update();
541 fDeadMapCanvasSingle->Paint();
545 for (int i = 0; (i < fNumModules) && (!fSingleModule); i++) {
546 fPeaksCanvas[i]->cd();
547 //Draw the high gain peak-minus pedestals
548 fPedestals->GetPeakProfileHighGain((i < fNumModules) ? i : fVisibleModule)->Draw("colz");
549 fPeaksCanvas[i]->Update();
550 fPeaksCanvas[i]->Paint();
552 fPedsCanvas[i]->cd();
553 //Draw the high gain peak-minus pedestals
554 fPedestals->GetPedProfileHighGain((i < fNumModules) ? i : fVisibleModule)->Draw("colz");
555 fPedsCanvas[i]->Update();
556 fPedsCanvas[i]->Paint();
558 fPedsDiffCanvas[i]->cd();
559 //Draw the high gain peak-minus pedestals
560 fPedestals->GetPedProfileHighGainDiff((i < fNumModules) ? i : fVisibleModule)->Draw("colz");
561 fPedsDiffCanvas[i]->Update();
562 fPedsDiffCanvas[i]->Paint();
564 fPeaksDiffCanvas[i]->cd();
565 //Draw the high gain peak-minus pedestals
566 fPedestals->GetPeakProfileHighGainDiff((i < fNumModules) ? i : fVisibleModule)->Draw("colz");
567 fPeaksDiffCanvas[i]->Update();
568 fPeaksDiffCanvas[i]->Paint();
570 fPeaksRatioCanvas[i]->cd();
571 //Draw the high gain peak-minus pedestals
572 fPedestals->GetPeakProfileHighGainRatio((i < fNumModules) ? i : fVisibleModule)->Draw("colz");
573 fPeaksRatioCanvas[i]->Update();
574 fPeaksRatioCanvas[i]->Paint();
576 fPedsRatioCanvas[i]->cd();
577 //Draw the high gain peak-minus pedestals
578 fPedestals->GetPedProfileHighGainRatio((i < fNumModules) ? i : fVisibleModule)->Draw("colz");
579 fPedsRatioCanvas[i]->Update();
580 fPedsRatioCanvas[i]->Paint();
584 fPeaksCanvas[fNumModules]->cd();
585 //Draw the high gain peak-minus pedestals
586 fPedestals->GetPeakProfileHighGain(fVisibleModule)->Draw("colz");
587 fPeaksCanvas[fNumModules]->Update();
588 fPeaksCanvas[fNumModules]->Paint();
590 fPedsCanvas[fNumModules]->cd();
591 //Draw the high gain peak-minus pedestals
592 fPedestals->GetPedProfileHighGain(fVisibleModule)->Draw("colz");
593 fPedsCanvas[fNumModules]->Update();
594 fPedsCanvas[fNumModules]->Paint();
596 fPedsDiffCanvas[fNumModules]->cd();
597 //Draw the high gain peak-minus pedestals
598 fPedestals->GetPedProfileHighGainDiff(fVisibleModule)->Draw("colz");
599 fPedsDiffCanvas[fNumModules]->Update();
600 fPedsDiffCanvas[fNumModules]->Paint();
602 fPeaksDiffCanvas[fNumModules]->cd();
603 //Draw the high gain peak-minus pedestals
604 fPedestals->GetPeakProfileHighGainDiff(fVisibleModule)->Draw("colz");
605 fPeaksDiffCanvas[fNumModules]->Update();
606 fPeaksDiffCanvas[fNumModules]->Paint();
608 fPeaksRatioCanvas[fNumModules]->cd();
609 //Draw the high gain peak-minus pedestals
610 fPedestals->GetPeakProfileHighGainRatio(fVisibleModule)->Draw("colz");
611 fPeaksRatioCanvas[fNumModules]->Update();
612 fPeaksRatioCanvas[fNumModules]->Paint();
614 fPedsRatioCanvas[fNumModules]->cd();
615 //Draw the high gain peak-minus pedestals
616 fPedestals->GetPedProfileHighGainRatio(fVisibleModule)->Draw("colz");
617 fPedsRatioCanvas[fNumModules]->Update();
618 fPedsRatioCanvas[fNumModules]->Paint();
622 for (int i = 0; (i < fNumModules) && (!fSingleModule); i++) {
623 fPeaksCanvas[i]->cd();
624 //Draw the high gain peak-minus pedestals
625 fPedestals->GetPeakProfileLowGain((i < fNumModules) ? i : fVisibleModule)->Draw("colz");
626 fPeaksCanvas[i]->Update();
627 fPeaksCanvas[i]->Paint();
629 fPedsCanvas[i]->cd();
630 //Draw the high gain peak-minus pedestals
631 fPedestals->GetPedProfileLowGain((i < fNumModules) ? i : fVisibleModule)->Draw("colz");
632 fPedsCanvas[i]->Update();
633 fPedsCanvas[i]->Paint();
635 fPedsDiffCanvas[i]->cd();
636 //Draw the high gain peak-minus pedestals
637 fPedestals->GetPedProfileLowGainDiff((i < fNumModules) ? i : fVisibleModule)->Draw("colz");
638 fPedsDiffCanvas[i]->Update();
639 fPedsDiffCanvas[i]->Paint();
641 fPeaksDiffCanvas[i]->cd();
642 //Draw the high gain peak-minus pedestals
643 fPedestals->GetPeakProfileLowGainDiff((i < fNumModules) ? i : fVisibleModule)->Draw("colz");
644 fPeaksDiffCanvas[i]->Update();
645 fPeaksDiffCanvas[i]->Paint();
647 fPeaksRatioCanvas[i]->cd();
648 //Draw the high gain peak-minus pedestals
649 fPedestals->GetPeakProfileLowGainRatio((i < fNumModules) ? i : fVisibleModule)->Draw("colz");
650 fPeaksRatioCanvas[i]->Update();
651 fPeaksRatioCanvas[i]->Paint();
653 fPedsRatioCanvas[i]->cd();
654 //Draw the high gain peak-minus pedestals
655 fPedestals->GetPedProfileLowGainRatio((i < fNumModules) ? i : fVisibleModule)->Draw("colz");
656 fPedsRatioCanvas[i]->Update();
657 fPedsRatioCanvas[i]->Paint();
661 fPeaksCanvas[fNumModules]->cd();
662 //Draw the high gain peak-minus pedestals
663 fPedestals->GetPeakProfileLowGain(fVisibleModule)->Draw("colz");
664 fPeaksCanvas[fNumModules]->Update();
665 fPeaksCanvas[fNumModules]->Paint();
667 fPedsCanvas[fNumModules]->cd();
668 //Draw the high gain peak-minus pedestals
669 fPedestals->GetPedProfileLowGain(fVisibleModule)->Draw("colz");
670 fPedsCanvas[fNumModules]->Update();
671 fPedsCanvas[fNumModules]->Paint();
673 fPedsDiffCanvas[fNumModules]->cd();
674 //Draw the high gain peak-minus pedestals
675 fPedestals->GetPedProfileLowGainDiff(fVisibleModule)->Draw("colz");
676 fPedsDiffCanvas[fNumModules]->Update();
677 fPedsDiffCanvas[fNumModules]->Paint();
679 fPeaksDiffCanvas[fNumModules]->cd();
680 //Draw the high gain peak-minus pedestals
681 fPedestals->GetPeakProfileLowGainDiff(fVisibleModule)->Draw("colz");
682 fPeaksDiffCanvas[fNumModules]->Update();
683 fPeaksDiffCanvas[fNumModules]->Paint();
685 fPeaksRatioCanvas[fNumModules]->cd();
686 //Draw the high gain peak-minus pedestals
687 fPedestals->GetPeakProfileLowGainRatio(fVisibleModule)->Draw("colz");
688 fPeaksRatioCanvas[fNumModules]->Update();
689 fPeaksRatioCanvas[fNumModules]->Paint();
691 fPedsRatioCanvas[fNumModules]->cd();
692 //Draw the high gain peak-minus pedestals
693 fPedestals->GetPedProfileLowGainRatio(fVisibleModule)->Draw("colz");
694 fPedsRatioCanvas[fNumModules]->Update();
695 fPedsRatioCanvas[fNumModules]->Paint();
702 //_____________________________________________________________________________
703 void TMCal::OnGainButton()
704 { // Gain button handler
707 fLowGainMode = kFALSE;
708 fGainButton->SetText("Low gain");
711 fLowGainMode = kTRUE;
712 fGainButton->SetText("High gain");
720 //_____________________________________________________________________________
721 void TMCal::OnRange(kTab tab)
722 {//Range change handler
727 fPedsRangeSingle->SetPosition(fPedsRange->GetPosition());
728 fMaxPed = AliCaloCalibPedestal::GetSampleMax() - fPedsRange->GetPosition();
729 //printf("Value changed to %u.\n", (unsigned int)fMaxPedDiff);
730 for (i = 0; i < fNumModules; i++) {
731 fPedestals->GetPedProfileHighGain(i)->GetZaxis()->SetRangeUser(-1.0*fMaxPed, fMaxPed);
732 fPedestals->GetPedProfileLowGain(i)->GetZaxis()->SetRangeUser(-1.0*fMaxPed, fMaxPed);
733 if (!fSingleModule) {//Don't update all the monitors if we're in single module mode, to speed up the redraw there
734 fPedsCanvas[i]->Paint(); //For some reason we need paint-update-paint, just update-paint or paint-update won't do...
735 fPedsCanvas[i]->Update();
736 fPedsCanvas[i]->Paint();
739 fPedsCanvasSingle->Paint(); //For some reason we need paint-update-paint, just update-paint or paint-update won't do...
740 fPedsCanvasSingle->Update();
741 fPedsCanvasSingle->Paint();
745 fPeaksRangeSingle->SetPosition(fPeaksRange->GetPosition());
746 fMaxPeak = AliCaloCalibPedestal::GetSampleMax() - fPeaksRange->GetPosition();
747 //printf("Value changed to %u.\n", (unsigned int)fMaxPedDiff);
748 for (i = 0; i < fNumModules; i++) {
749 fPedestals->GetPeakProfileHighGain(i)->GetZaxis()->SetRangeUser(-1.0*fMaxPeak, fMaxPeak);
750 fPedestals->GetPeakProfileLowGain(i)->GetZaxis()->SetRangeUser(-1.0*fMaxPeak, fMaxPeak);
751 if (!fSingleModule) {//Don't update all the monitors if we're in single module mode, to speed up the redraw there
752 fPeaksCanvas[i]->Paint(); //For some reason we need paint-update-paint, just update-paint or paint-update won't do...
753 fPeaksCanvas[i]->Update();
754 fPeaksCanvas[i]->Paint();
757 fPeaksCanvasSingle->Paint(); //For some reason we need paint-update-paint, just update-paint or paint-update won't do...
758 fPeaksCanvasSingle->Update();
759 fPeaksCanvasSingle->Paint();
763 fPedsDiffRangeSingle->SetPosition(fPedsDiffRange->GetPosition());
764 fMaxPedDiff = AliCaloCalibPedestal::GetSampleMax() - fPedsDiffRange->GetPosition();
765 //printf("Value changed to %u.\n", (unsigned int)fMaxPedDiff);
766 for (i = 0; i < fNumModules; i++) {
767 fPedestals->GetPedProfileHighGainDiff(i)->GetZaxis()->SetRangeUser(-1.0*fMaxPedDiff, fMaxPedDiff);
768 fPedestals->GetPedProfileLowGainDiff(i)->GetZaxis()->SetRangeUser(-1.0*fMaxPedDiff, fMaxPedDiff);
769 if (!fSingleModule) {//Don't update all the monitors if we're in single module mode, to speed up the redraw there
770 fPedsDiffCanvas[i]->Paint(); //For some reason we need paint-update-paint, just update-paint or paint-update won't do...
771 fPedsDiffCanvas[i]->Update();
772 fPedsDiffCanvas[i]->Paint();
775 fPedsDiffCanvasSingle->Paint(); //For some reason we need paint-update-paint, just update-paint or paint-update won't do...
776 fPedsDiffCanvasSingle->Update();
777 fPedsDiffCanvasSingle->Paint();
781 fPeaksDiffRangeSingle->SetPosition(fPeaksDiffRange->GetPosition());
782 fMaxPeakDiff = AliCaloCalibPedestal::GetSampleMax() - fPeaksDiffRange->GetPosition();
783 //printf("Value changed to %u.\n", (unsigned int)fMaxPedDiff);
784 for (i = 0; i < fNumModules; i++) {
785 fPedestals->GetPeakProfileHighGainDiff(i)->GetZaxis()->SetRangeUser(-1.0*fMaxPeakDiff, fMaxPeakDiff);
786 fPedestals->GetPeakProfileLowGainDiff(i)->GetZaxis()->SetRangeUser(-1.0*fMaxPeakDiff, fMaxPeakDiff);
787 if (!fSingleModule) {//Don't update all the monitors if we're in single module mode, to speed up the redraw there
788 fPeaksDiffCanvas[i]->Paint();
789 fPeaksDiffCanvas[i]->Update();
790 fPeaksDiffCanvas[i]->Paint();
793 fPeaksDiffCanvasSingle->Paint();
794 fPeaksDiffCanvasSingle->Update();
795 fPeaksDiffCanvasSingle->Paint();
799 fPedsRatioRangeSingle->SetPosition(fPedsRatioRange->GetPosition());
800 //fMaxPedRatio = fgkMaxMaxRatio - fPedsDiffRange->GetPosition() + fgkMinMaxRatio;
801 fMaxPedRatio = pow(2.0, -fPedsRatioRange->GetPosition()/fgkRatioStepScale);//Make the control logarithmic
802 //printf("Pedsratio changed to %g, position is set at %i.\n", fMaxPedRatio, (int)fPedsRatioRange->GetPosition());
803 for (i = 0; i < fNumModules; i++) {
804 fPedestals->GetPedProfileHighGainRatio(i)->GetZaxis()->SetRangeUser(0.0, fMaxPedRatio);
805 fPedestals->GetPedProfileLowGainRatio(i)->GetZaxis()->SetRangeUser(0.0, fMaxPedRatio);
806 if (!fSingleModule) {//Don't update all the monitors if we're in single module mode, to speed up the redraw there
807 fPedsRatioCanvas[i]->Paint();
808 fPedsRatioCanvas[i]->Update();
809 fPedsRatioCanvas[i]->Paint();
812 fPedsRatioCanvasSingle->Paint();
813 fPedsRatioCanvasSingle->Update();
814 fPedsRatioCanvasSingle->Paint();
818 fPeaksRatioRangeSingle->SetPosition(fPeaksRatioRange->GetPosition());
819 fMaxPeakRatio = pow(2.0, -fPeaksRatioRange->GetPosition()/fgkRatioStepScale);//Make the control logarithmic
820 //printf("Pedsratio changed to %g, position is set at %i.\n", fMaxPeakRatio, (int)fPeaksRatioRange->GetPosition());
821 for (i = 0; i < fNumModules; i++) {
822 fPedestals->GetPeakProfileHighGainRatio(i)->GetZaxis()->SetRangeUser(0.0, fMaxPeakRatio);
823 fPedestals->GetPeakProfileLowGainRatio(i)->GetZaxis()->SetRangeUser(0.0, fMaxPeakRatio);
824 if (!fSingleModule) {//Don't update all the monitors if we're in single module mode, to speed up the redraw there
825 fPeaksRatioCanvas[i]->Paint();
826 fPeaksRatioCanvas[i]->Update();
827 fPeaksRatioCanvas[i]->Paint();
830 fPeaksRatioCanvasSingle->Paint();
831 fPeaksRatioCanvasSingle->Update();
832 fPeaksRatioCanvasSingle->Paint();
835 //The single-histo-at-a-time sliders. We'll just set the other slider to match and call the normal handler :)
837 fPedsRange->SetPosition(fPedsRangeSingle->GetPosition());
841 fPeaksRange->SetPosition(fPeaksRangeSingle->GetPosition());
844 case kPedsDiffSingle:
845 fPedsDiffRange->SetPosition(fPedsDiffRangeSingle->GetPosition());
848 case kPeaksDiffSingle:
849 fPeaksDiffRange->SetPosition(fPeaksDiffRangeSingle->GetPosition());
852 case kPedsRatioSingle:
853 fPedsRatioRange->SetPosition(fPedsRatioRangeSingle->GetPosition());
856 case kPeaksRatioSingle:
857 fPeaksRatioRange->SetPosition(fPeaksRatioRangeSingle->GetPosition());
858 OnRange(kPeaksRatio);
861 printf("Unknown tab slider %u.\n", (int)tab);
868 //_____________________________________________________________________________
869 void TMCal::OnModeButton(int button)
870 { // Module selection radio button handler
871 if (button < fNumModules) {
872 fVisibleModule = button;
873 fSingleModule = true;
875 fPeaksTab->HideFrame(fPeaksFrame);
876 fPeaksTab->ShowFrame(fPeaksFrameSingle);
878 fPedsTab->HideFrame(fPedsFrame);
879 fPedsTab->ShowFrame(fPedsFrameSingle);
881 fPeaksDiffTab->HideFrame(fPeaksDiffFrame);
882 fPeaksDiffTab->ShowFrame(fPeaksDiffFrameSingle);
884 fPedsDiffTab->HideFrame(fPedsDiffFrame);
885 fPedsDiffTab->ShowFrame(fPedsDiffFrameSingle);
887 fPeaksRatioTab->HideFrame(fPeaksRatioFrame);
888 fPeaksRatioTab->ShowFrame(fPeaksRatioFrameSingle);
890 fPedsRatioTab->HideFrame(fPedsRatioFrame);
891 fPedsRatioTab->ShowFrame(fPedsRatioFrameSingle);
893 fDeadMapTab->HideFrame(fDeadMapFrame);
894 fDeadMapTab->ShowFrame(fDeadMapFrameSingle);
899 fSingleModule = false;
900 fPeaksTab->HideFrame(fPeaksFrameSingle);
901 fPeaksTab->ShowFrame(fPeaksFrame);
903 fPedsTab->HideFrame(fPedsFrameSingle);
904 fPedsTab->ShowFrame(fPedsFrame);
906 fPeaksDiffTab->HideFrame(fPeaksDiffFrameSingle);
907 fPeaksDiffTab->ShowFrame(fPeaksDiffFrame);
909 fPedsDiffTab->HideFrame(fPedsDiffFrameSingle);
910 fPedsDiffTab->ShowFrame(fPedsDiffFrame);
912 fPeaksRatioTab->HideFrame(fPeaksRatioFrameSingle);
913 fPeaksRatioTab->ShowFrame(fPeaksRatioFrame);
915 fPedsRatioTab->HideFrame(fPedsRatioFrameSingle);
916 fPedsRatioTab->ShowFrame(fPedsRatioFrame);
918 fDeadMapTab->HideFrame(fDeadMapFrameSingle);
919 fDeadMapTab->ShowFrame(fDeadMapFrame);
921 DrawHistos();//this is because we may not have drawn the histos to their canvases.
927 //_____________________________________________________________________________
928 void TMCal::OnRunNoChange(Long_t val)
930 //printf("Run number changed to %u.\n", (int)fRunNoEntry->GetIntNumber());
931 InitRawReaderAndStream(fRunNoEntry->GetIntNumber());
933 //We still need to re-paint the tabs to make the change visible
934 fPeaksFrame->Paint();
938 //_____________________________________________________________________________
939 void TMCal::OnTabChange(Int_t Id)
941 //This sets the palette for the deadmap tab to the four colors we want there, and otherwise to
942 //the standard no. 1 palette. To make this work, we need to do updatemonitors, which is slow,
943 //so in case you're willing to sacrifice the custom palette for the deadmap in favor of speed,
944 //just comment out/remove this function and the GetTab()->Connect(...) in the constructor.
945 if (!strcmp(GetTab()->GetTabTab(Id)->GetString(), fgkDeadMapTabName)) {
946 gStyle->SetPalette(AliCaloCalibPedestal::kNumDeadMapStates, fDeadMapPalette);
949 gStyle->SetPalette(1);