]> git.uio.no Git - u/mrichter/AliRoot.git/blame - EVE/Alieve/ITSScaledModuleEditor.cxx
Add the det.element id for each local board
[u/mrichter/AliRoot.git] / EVE / Alieve / ITSScaledModuleEditor.cxx
CommitLineData
3b868b75 1// $Header$
2
3#include "ITSScaledModuleEditor.h"
4#include <Alieve/ITSScaledModule.h>
5#include <Reve/ZTransEditor.h>
6#include <Reve/RGValuators.h>
7
8#include <TVirtualPad.h>
9#include <TColor.h>
10#include <TMath.h>
11
12#include <TGedEditor.h>
13#include <TGLabel.h>
14#include <TGButton.h>
15#include <TGNumberEntry.h>
16#include <TGColorSelect.h>
17#include <TGComboBox.h>
18
19using namespace Reve;
20using namespace Alieve;
21
22//______________________________________________________________________
23// SDPaletteSubEditor
24//
25ITSSDSubEditor::ITSSDSubEditor(const TGWindow* p) :
26 RGBAPaletteSubEditor(p),
27 fModule(0),
28 fScale(0),
29 fStatistic(0),
30 fInfoLabel0(0),
31 fInfoLabel1(0),
32 fInfoLabel2(0)
33{
34 // Create widgets
35 {
36 TGHorizontalFrame* f = new TGHorizontalFrame(this);
37 TGLabel *l = new TGLabel(f, "Scale:");
38 f->AddFrame(l, new TGLayoutHints(kLHintsTop | kLHintsCenterY, 0, 5, 1, 1));
39 fScale = new TGNumberEntry(f, 0, 2, -1,
40 TGNumberFormat::kNESInteger, TGNumberFormat::kNEAPositive,
41 TGNumberFormat::kNELLimitMinMax, 1, 5);
42 fScale->GetNumberEntry()->SetToolTipText("Set cell size.");
43 f->AddFrame(fScale, new TGLayoutHints(kLHintsLeft, 1, 7, 1, 1));
44 fScale->Associate(f);
45 fScale->Connect("ValueSet(Long_t)", "Alieve::ITSSDSubEditor", this, "DoScale()");
46
47 TGLabel* lab = new TGLabel(f, "Statistic:");
48 f->AddFrame(lab, new TGLayoutHints(kLHintsLeft|kLHintsBottom, 1, 2, 1, 2));
49 fStatistic = new TGComboBox(f);
50 fStatistic->AddEntry("Occup", 0);
51 fStatistic->AddEntry("Average", 1);
52 fStatistic->AddEntry("RMS", 2);
53 TGListBox* lb = fStatistic->GetListBox();
54 lb->Resize(lb->GetWidth(), 3*16);
55 fStatistic->Resize(74, 20);
56 fStatistic->Connect("Selected(Int_t)", "Alieve::ITSSDSubEditor", this, "DoStatType(Int_t)");
57 f->AddFrame(fStatistic, new TGLayoutHints(kLHintsLeft, 1, 2, 1, 1));
58 AddFrame(f, new TGLayoutHints(kLHintsTop, 1, 1, 1, 1));
59 }
60
61 Int_t lp = 2;
62 fInfoLabel0 = new TGLabel(this);
63 fInfoLabel0->SetTextJustify(kTextLeft);
64 AddFrame(fInfoLabel0, new TGLayoutHints(kLHintsLeft|kLHintsExpandX,
65 lp, 0, 8, 0));
66
67 fInfoLabel1 = new TGLabel(this);
68 fInfoLabel1->SetTextJustify(kTextLeft);
69 AddFrame(fInfoLabel1, new TGLayoutHints(kLHintsLeft|kLHintsExpandX,
70 lp, 0, 2, 0));
71
72 fInfoLabel2 = new TGLabel(this);
73 fInfoLabel2->SetTextJustify(kTextLeft);
74 AddFrame(fInfoLabel2, new TGLayoutHints(kLHintsLeft|kLHintsExpandX,
75 lp, 0, 2, 0));
76}
77
78/**************************************************************************/
79
80void ITSSDSubEditor::SetModel(ITSScaledModule* mod)
81{
82 fModule = mod;
83 RGBAPaletteSubEditor::SetModel(fModule->GetPalette());
84
03dfc4a7 85 fScale->SetIntNumber(fModule->GetScaleInfo()->GetScale());
86 fStatistic->Select(fModule->GetScaleInfo()->GetStatType(), kFALSE);
3b868b75 87
88 Int_t cnx, cnz, total;
89 Float_t maxoc;
90 GetSubDetScaleData(cnx, cnz, total, maxoc);
91 fInfoLabel0->SetText(Form("Cell size: Nx=%d Nz=%d", cnx, cnz));
92 fInfoLabel1->SetText(Form("Num cells: %d", total));
93 fInfoLabel2->SetText(Form("Max occupancy: %5.3f%%", maxoc));
94
95 SetPaletteFromDigitInfo();
96}
97
98/**************************************************************************/
99
100void ITSSDSubEditor::GetSubDetScaleData(Int_t& cnx, Int_t& cnz, Int_t& total, Float_t& maxoc)
101{
102 Int_t scale = fScale->GetIntNumber() -1;
103 Alieve::ITSDigitsInfo* di = fModule->GetDigitsInfo();
104 switch(fModule->fDetID)
105 {
106 case 0:
107 cnx = di->fSPDScaleX[scale], cnz = di->fSPDScaleZ[scale];
108 total = di->fSegSPD->Npx()*di->fSegSPD->Npz();
109 maxoc = di->fSPDMaxOcc;;
110 break;
111 case 1:
112 cnx = di->fSDDScaleX[scale], cnz = di->fSDDScaleZ[scale];
113 total = di->fSegSDD->Npx()*di->fSegSDD->Npz();
114 maxoc = di->fSDDMaxOcc;;
115 break;
116 case 2:
117 cnx = di->fSSDScale[scale], cnz = 1;
118 total = di->fSegSSD->Npx()*di->fSegSSD->Npz();
119 maxoc = di->fSSDMaxOcc;;
120 break;
121 }
122}
123
124/**************************************************************************/
125
126void ITSSDSubEditor::SetPaletteFromDigitInfo()
127{
03dfc4a7 128 // apply values for color palettefgdif
129 if(fModule->GetScaleInfo()->fAutoUpdatePalette)
3b868b75 130 {
131 Int_t cnx, cnz, total;
132 Float_t maxoc;
133 GetSubDetScaleData(cnx, cnz, total, maxoc);
134 Alieve::ITSDigitsInfo* di = fModule->GetDigitsInfo();
135 if(fStatistic->GetSelected() == DigitScaleInfo::ST_Occup)
136 {
137 Int_t scale = fScale->GetIntNumber() -1;
138 fMinMax->SetValues(0, TMath::Max(Int_t(cnx*cnz*maxoc),1), kFALSE);
139 ITSModule::fgSPDPalette->SetMinMax(0,TMath::Max(Int_t(di->fSPDScaleZ[scale]*di->fSPDScaleX[scale]*di->fSPDMaxOcc), 1));
140 ITSModule::fgSDDPalette->SetMinMax(0,TMath::Max(Int_t(di->fSDDScaleZ[scale]*di->fSDDScaleX[scale]*di->fSPDMaxOcc), 1));
141 ITSModule::fgSSDPalette->SetMinMax(0,TMath::Max(Int_t(di->fSSDScale[scale]*di->fSPDMaxOcc), 1));
142 }
143 else
144 {
145 ITSModule::fgSPDPalette->SetMinMax(di->fSPDMinVal,di->fSPDMaxVal);
146 ITSModule::fgSDDPalette->SetMinMax(di->fSDDMinVal,di->fSDDMaxVal);
147 ITSModule::fgSSDPalette->SetMinMax(di->fSSDMinVal,di->fSSDMaxVal);
148 }
149 }
150}
151
152/**************************************************************************/
153
154void ITSSDSubEditor::DoScale()
155{
156 Int_t cnx, cnz, total; Float_t maxoc;
157 GetSubDetScaleData(cnx, cnz, total, maxoc);
158 fInfoLabel0->SetText(Form("Cell size: Nx=%d Nz=%d", cnx, cnz));
159
160 SetPaletteFromDigitInfo();
161
03dfc4a7 162 fModule->GetScaleInfo()->ScaleChanged(fScale->GetIntNumber());
3b868b75 163 Changed();
164}
165
166/**************************************************************************/
167
168void ITSSDSubEditor::DoStatType(Int_t v)
169{
170 // update palette
171 SetPaletteFromDigitInfo();
172
03dfc4a7 173 fModule->GetScaleInfo()->StatTypeChanged(v);
3b868b75 174
175 Changed();
176}
177
178//______________________________________________________________________
179// ITSScaledModuleEditor
180//
181
182ClassImp(ITSScaledModuleEditor)
183
184ITSScaledModuleEditor::ITSScaledModuleEditor(const TGWindow *p, Int_t width, Int_t height,
185 UInt_t options, Pixel_t back) :
186 TGedFrame(p, width, height, options | kVerticalFrame, back),
187 fM(0),
188 fHMTrans (0),
189 fSDPalette (0)
190{
191 MakeTitle("ITSScaledModule");
192
193 fHMTrans = new ZTransSubEditor(this);
194 fHMTrans->Connect("UseTrans()", "Alieve::ITSScaledModuleEditor", this, "Update()");
195 fHMTrans->Connect("TransChanged()", "Alieve::ITSScaledModuleEditor", this, "Update()");
196 AddFrame(fHMTrans, new TGLayoutHints(kLHintsTop | kLHintsExpandX, 2, 0, 0, 0));
197
198 MakeTitle("Palette controls");
199
200 fSDPalette = new ITSSDSubEditor(this);
201 fSDPalette->Connect("Changed", "Alieve::ITSScaledModuleEditor", this, "Update()");
202 AddFrame(fSDPalette, new TGLayoutHints(kLHintsTop | kLHintsExpandX, 2, 0, 0, 0));
203}
204
205/*************************************************************************/
206ITSScaledModuleEditor::~ITSScaledModuleEditor()
207{}
208
209/**************************************************************************/
210
211void ITSScaledModuleEditor::ActivateBaseClassEditors(TClass* cl)
212{
213 // exclude QuadSet editor
214 fGedEditor->ExcludeClassEditor(QuadSet::Class());
215 TGedFrame::ActivateBaseClassEditors(cl);
216}
217
218/**************************************************************************/
219
220void ITSScaledModuleEditor::SetModel(TObject* obj)
221{
222 fM = dynamic_cast<ITSScaledModule*>(obj);
223
224 fHMTrans->SetDataFromTrans(&fM->RefHMTrans());
225
226 if (fM->GetValueIsColor() || fM->GetPalette() == 0) {
227 fSDPalette->UnmapWindow();
228 } else {
229 fSDPalette->SetModel(fM);
230 fSDPalette->MapWindow();
231 }
232}