]>
Commit | Line | Data |
---|---|---|
1 | // EMCAL event display | |
2 | // Visualization of an EMCAL super module. | |
3 | // | |
4 | // Author: Magali Estienne (magali.estienne@cern.ch) | |
5 | // June 30 2008 | |
6 | ||
7 | #include "AliEveEMCALSModule.h" | |
8 | ||
9 | //#include <vector> | |
10 | ||
11 | #include <TEveFrameBox.h> | |
12 | #include <TEveQuadSet.h> | |
13 | #include <TEvePointSet.h> | |
14 | #include <TEveRGBAPalette.h> | |
15 | ||
16 | ||
17 | class Riostream; | |
18 | //class vector; | |
19 | class TEveTrans; | |
20 | class TEveElement; | |
21 | class TClonesArray; | |
22 | class TStyle; | |
23 | class TBuffer3DTypes; | |
24 | class TBuffer3D; | |
25 | class TVirtualPad; | |
26 | class TVirtualViewer3D; | |
27 | class AliEveEMCALData; | |
28 | class AliEMCALHit; | |
29 | class AliEMCALDigit; | |
30 | class AliEveEMCALSModuleData; | |
31 | ||
32 | ClassImp(AliEveEMCALSModule) | |
33 | ||
34 | Bool_t AliEveEMCALSModule::fgStaticInit = kFALSE; | |
35 | Float_t AliEveEMCALSModule::fgSMBigBBox[3]; | |
36 | Float_t AliEveEMCALSModule::fgSMSmallBBox[3]; | |
37 | TEveFrameBox* AliEveEMCALSModule::fgFrameBigBox = 0; | |
38 | TEveFrameBox* AliEveEMCALSModule::fgFrameSmallBox = 0; | |
39 | TEveRGBAPalette* AliEveEMCALSModule::fgFrameDigPalette = 0; | |
40 | TEveRGBAPalette* AliEveEMCALSModule::fgFrameCluPalette = 0; | |
41 | ||
42 | AliEveEMCALSModule::AliEveEMCALSModule(Int_t smid, const Text_t* n, const Text_t* t) : | |
43 | TEveElement(fFrameColor), | |
44 | TNamed(n,t), | |
45 | TAtt3D(), | |
46 | fEMCALData(0), | |
47 | fEMCALSModuleData(0), | |
48 | fFrameColor((Color_t)10), | |
49 | fSModuleID(smid), | |
50 | fQuadSet(new TEveQuadSet(n,t)), | |
51 | fQuadSet2(new TEveQuadSet(n,t)), | |
52 | fPointSet(new TEvePointSet(n)), | |
53 | fClusterSize(5), | |
54 | fHitSize(5), | |
55 | fDebug(0) | |
56 | { | |
57 | // Constructor. | |
58 | Char_t name[256]; | |
59 | if (smid < 10) { | |
60 | snprintf(name,256,"Full Super Module %02d",smid); | |
61 | } else { | |
62 | snprintf(name,256,"Half Super Module %02d",smid); | |
63 | } | |
64 | SetName(name); | |
65 | ||
66 | // Hits | |
67 | fPointSet->IncDenyDestroy(); | |
68 | AddElement(fPointSet); | |
69 | // Digits | |
70 | fQuadSet->IncDenyDestroy(); | |
71 | AddElement(fQuadSet); | |
72 | // Clusters | |
73 | fQuadSet2->IncDenyDestroy(); | |
74 | AddElement(fQuadSet2); | |
75 | ||
76 | } | |
77 | ||
78 | AliEveEMCALSModule::AliEveEMCALSModule(const AliEveEMCALSModule &esm) : | |
79 | TEveElement(fFrameColor), | |
80 | TNamed(), | |
81 | TAtt3D(), | |
82 | fEMCALData(esm.fEMCALData), | |
83 | fEMCALSModuleData(esm.fEMCALSModuleData), | |
84 | fFrameColor(esm.fFrameColor), | |
85 | fSModuleID(esm.fSModuleID), | |
86 | fQuadSet(esm.fQuadSet), | |
87 | fQuadSet2(esm.fQuadSet2), | |
88 | fPointSet(esm.fPointSet), | |
89 | fClusterSize(esm.fClusterSize), | |
90 | fHitSize(esm.fHitSize), | |
91 | fDebug(esm.fDebug) | |
92 | { | |
93 | // Copy constructor. | |
94 | Char_t name[256]; | |
95 | if (fSModuleID < 10) { | |
96 | snprintf(name,256,"Full Super Module %02d",fSModuleID); | |
97 | } else { | |
98 | snprintf(name,256,"Half Super Module %02d",fSModuleID); | |
99 | } | |
100 | SetName(name); | |
101 | ||
102 | // Hits | |
103 | fPointSet->IncDenyDestroy(); | |
104 | AddElement(fPointSet); | |
105 | // Digits | |
106 | fQuadSet->IncDenyDestroy(); | |
107 | AddElement(fQuadSet); | |
108 | // Clusters | |
109 | fQuadSet2->IncDenyDestroy(); | |
110 | AddElement(fQuadSet2); | |
111 | ||
112 | } | |
113 | ||
114 | AliEveEMCALSModule::~AliEveEMCALSModule() | |
115 | { | |
116 | // | |
117 | // Destructor. | |
118 | // | |
119 | ||
120 | fPointSet->DecDenyDestroy(); | |
121 | fQuadSet->DecDenyDestroy(); | |
122 | fQuadSet2->DecDenyDestroy(); | |
123 | ||
124 | if(fEMCALData) fEMCALData->DecRefCount(); | |
125 | } | |
126 | ||
127 | //______________________________________________________________________________ | |
128 | void AliEveEMCALSModule::DropData() const | |
129 | { | |
130 | // | |
131 | // release the sm data | |
132 | // | |
133 | ||
134 | // fNDigits = 0; | |
135 | // fNClusters = 0; | |
136 | // fNHits = 0; | |
137 | ||
138 | return; | |
139 | ||
140 | } | |
141 | ||
142 | //______________________________________________________________________________ | |
143 | void AliEveEMCALSModule::InitStatics(AliEveEMCALSModuleData* md) | |
144 | { | |
145 | // | |
146 | // Bounding box, Framebox and Palette | |
147 | // | |
148 | ||
149 | if (fgStaticInit) return; | |
150 | fgStaticInit = kTRUE; | |
151 | ||
152 | md->GetSModuleBigBox(fgSMBigBBox[0],fgSMBigBBox[1], fgSMBigBBox[2]); | |
153 | md->GetSModuleSmallBox(fgSMSmallBBox[0],fgSMSmallBBox[1], fgSMSmallBBox[2]); | |
154 | ||
155 | fgFrameBigBox = new TEveFrameBox(); | |
156 | fgFrameBigBox->SetAABoxCenterHalfSize(0, 0, 0, fgSMBigBBox[0], fgSMBigBBox[1], fgSMBigBBox[2]); | |
157 | fgFrameBigBox->SetFrameColor((Color_t)10); | |
158 | fgFrameBigBox->IncRefCount(); | |
159 | fgFrameDigPalette = new TEveRGBAPalette(0,512); | |
160 | fgFrameDigPalette->SetLimits(0, 1024); | |
161 | fgFrameDigPalette->IncRefCount(); | |
162 | ||
163 | fgFrameSmallBox = new TEveFrameBox(); | |
164 | fgFrameSmallBox->SetAABoxCenterHalfSize(0, 0, 0, fgSMSmallBBox[0], fgSMSmallBBox[1], fgSMSmallBBox[2]); | |
165 | fgFrameSmallBox->SetFrameColor((Color_t)10); | |
166 | fgFrameSmallBox->IncRefCount(); | |
167 | fgFrameCluPalette = new TEveRGBAPalette(0,512); | |
168 | fgFrameCluPalette->SetLimits(0, 1024); | |
169 | fgFrameCluPalette->IncRefCount(); | |
170 | } | |
171 | ||
172 | //______________________________________________________________________________ | |
173 | void AliEveEMCALSModule::SetClusterSize(Int_t size) | |
174 | { | |
175 | // | |
176 | // Cluster point size | |
177 | // | |
178 | ||
179 | fClusterSize = TMath::Max(1, size); | |
180 | } | |
181 | ||
182 | //______________________________________________________________________________ | |
183 | void AliEveEMCALSModule::SetHitSize(Int_t size) | |
184 | { | |
185 | // | |
186 | // hit point size | |
187 | // | |
188 | ||
189 | fHitSize = TMath::Max(1, size); | |
190 | } | |
191 | ||
192 | //______________________________________________________________________________ | |
193 | void AliEveEMCALSModule::SetDataSource(AliEveEMCALData* const data) | |
194 | { | |
195 | // | |
196 | // Set source of data. | |
197 | // | |
198 | ||
199 | if (data == fEMCALData) return; | |
200 | if(fEMCALData) fEMCALData->DecRefCount(); | |
201 | fEMCALData = data; | |
202 | if(fEMCALData) fEMCALData->IncRefCount(); | |
203 | ||
204 | // Get pointer on SM data | |
205 | fEMCALSModuleData = GetSModuleData(); | |
206 | } | |
207 | ||
208 | //______________________________________________________________________________ | |
209 | AliEveEMCALSModuleData* AliEveEMCALSModule::GetSModuleData() const | |
210 | { | |
211 | // | |
212 | // Return source of data. | |
213 | // | |
214 | ||
215 | return fEMCALData ? fEMCALData->GetSModuleData(fSModuleID) : 0; | |
216 | } | |
217 | ||
218 | //______________________________________________________________________________ | |
219 | void AliEveEMCALSModule::UpdateQuads() | |
220 | { | |
221 | // | |
222 | // Update hit/digit/cluster representation. | |
223 | // | |
224 | ||
225 | vector< vector<Double_t> > bufferDigit; | |
226 | vector< vector<Double_t> > bufferCluster; | |
227 | vector< vector<Float_t> > bufferHit; | |
228 | Int_t nDigits, nClusters, nHits, oldSize; | |
229 | Float_t hitX, hitY, hitZ; | |
230 | Int_t smId = fEMCALSModuleData->GetSmId(); | |
231 | ||
232 | //-------------------------- | |
233 | // Hits from runloader | |
234 | //-------------------------- | |
235 | fPointSet->Reset(); | |
236 | ||
237 | /* | |
238 | TEvePointSet* points = fEMCALData->GetPointSetData(); | |
239 | char form[1000]; | |
240 | if(points){ | |
241 | sprintf(form,"N=%d", points->Size()); | |
242 | points->SetTitle(form); | |
243 | points->SetMarkerSize(.5); | |
244 | points->SetMarkerColor((Color_t)2); | |
245 | fPointSet->AddElement(points); | |
246 | } | |
247 | else {printf("There is no hits in Runloader \n"); } | |
248 | ||
249 | */ | |
250 | ||
251 | if (fEMCALSModuleData != 0) { | |
252 | ||
253 | if (!fgStaticInit) | |
254 | InitStatics(fEMCALSModuleData); | |
255 | ||
256 | // digits ------------------------ | |
257 | ||
258 | // Define TEveQuadSet for digits | |
259 | fQuadSet->SetOwnIds(kTRUE); | |
260 | fQuadSet->Reset(TEveQuadSet::kQT_RectangleYZFixedDimX, kFALSE, 32); | |
261 | fQuadSet->SetDefWidth (fEMCALSModuleData->GetPhiTileSize()); | |
262 | fQuadSet->SetDefHeight(fEMCALSModuleData->GetEtaTileSize()); | |
263 | fQuadSet->RefMainTrans().SetFrom(*fEMCALSModuleData->GetSModuleMatrix()); | |
264 | fQuadSet->SetPalette(fgFrameDigPalette); | |
265 | if(smId<fEMCALSModuleData->GetNsmf()) | |
266 | fQuadSet->SetFrame(fgFrameBigBox); | |
267 | else fQuadSet->SetFrame(fgFrameSmallBox); | |
268 | ||
269 | // Get the digit information from the buffer | |
270 | bufferDigit = fEMCALSModuleData->GetDigitBuffer(); | |
271 | if(!bufferDigit.empty()) | |
272 | { | |
273 | nDigits = fEMCALSModuleData->GetNDigits(); | |
274 | if(fDebug>1) cout << "nDigits: " << nDigits << endl; | |
275 | // loop over digits | |
276 | for (Int_t id = 0; id < nDigits; id++) { | |
277 | // Int_t iid = (Int_t)bufferDigit[id][0]; | |
278 | // Int_t isupMod = (Int_t)bufferDigit[id][1]; | |
279 | Double_t iamp = bufferDigit[id][2]; | |
280 | Int_t amp = (Int_t)(iamp+0.5); | |
281 | // Double_t ix = bufferDigit[id][3]; | |
282 | Double_t iy = bufferDigit[id][4]; | |
283 | Double_t iz = bufferDigit[id][5]; | |
284 | ||
285 | // Add digit information to the TEveQuadSet | |
286 | fQuadSet->AddQuad(iy, iz); | |
287 | fQuadSet->QuadValue(amp); | |
288 | } // end digits loop | |
289 | } | |
290 | else { if (fDebug) printf("There is no digits in SM %d \n", smId); } | |
291 | ||
292 | // hits -------------------------- | |
293 | bufferHit = fEMCALSModuleData->GetHitBuffer(); | |
294 | if(!bufferHit.empty()) | |
295 | { | |
296 | char form[1000]; | |
297 | nHits = fEMCALSModuleData->GetNHits(); | |
298 | if(fDebug>1) cout << "nHits: " << nHits << endl; | |
299 | oldSize = fPointSet->GrowFor(nHits); | |
300 | // Loop over hits | |
301 | for (Int_t ih = 0; ih < nHits; ih++) { | |
302 | hitX = bufferHit[ih][3]; | |
303 | hitY = bufferHit[ih][4]; | |
304 | hitZ = bufferHit[ih][5]; | |
305 | fPointSet->SetPoint(ih,hitX,hitY,hitZ); | |
306 | snprintf(form,1000,"N=%d", fPointSet->Size()); | |
307 | fPointSet->SetTitle(form); | |
308 | fPointSet->SetMarkerSize(.5); | |
309 | fPointSet->SetMarkerColor((Color_t)2); | |
310 | } | |
311 | } | |
312 | else { if (fDebug) printf("There is no hits in SM %d \n", smId); } | |
313 | ||
314 | // clusters ------------------------ | |
315 | ||
316 | // Define TEveQuadSet for clusters | |
317 | fQuadSet2->SetOwnIds(kTRUE); | |
318 | fQuadSet2->Reset(TEveQuadSet::kQT_RectangleYZFixedDimX, kFALSE, 32); | |
319 | fQuadSet2->SetDefWidth (fEMCALSModuleData->GetPhiTileSize()); | |
320 | fQuadSet2->SetDefHeight(fEMCALSModuleData->GetEtaTileSize()); | |
321 | fQuadSet2->RefMainTrans().SetFrom(*fEMCALSModuleData->GetSModuleMatrix()); | |
322 | fQuadSet2->SetPalette(fgFrameCluPalette); | |
323 | if(smId<fEMCALSModuleData->GetNsmf()) | |
324 | fQuadSet2->SetFrame(fgFrameBigBox); | |
325 | else fQuadSet2->SetFrame(fgFrameSmallBox); | |
326 | ||
327 | // Get the cluster information from the buffer | |
328 | bufferCluster = fEMCALSModuleData->GetClusterBuffer(); | |
329 | if(!bufferCluster.empty()) | |
330 | { | |
331 | nClusters = fEMCALSModuleData->GetNClusters(); | |
332 | if(fDebug>1) cout << "nClusters: " << nClusters << endl; | |
333 | // loop over clusters | |
334 | for (Int_t id = 0; id < nClusters; id++) { | |
335 | if(fDebug>1) { | |
336 | cout << "bufferCluster[" << id << "][0]: " << bufferCluster[id][0] << endl; | |
337 | cout << "bufferCluster[" << id << "][1]: " << bufferCluster[id][1] << endl; | |
338 | cout << "bufferCluster[" << id << "][2]: " << bufferCluster[id][2] << endl; | |
339 | cout << "bufferCluster[" << id << "][3]: " << bufferCluster[id][3] << endl; | |
340 | cout << "bufferCluster[" << id << "][4]: " << bufferCluster[id][4] << endl; | |
341 | } | |
342 | // Int_t isupMod = (Int_t)bufferCluster[id][0]; | |
343 | Double_t iamp = bufferCluster[id][1]; | |
344 | Int_t amp = (Int_t)(iamp+0.5); | |
345 | // Double_t ix = bufferCluster[id][2]; | |
346 | Double_t iy = bufferCluster[id][3]; | |
347 | Double_t iz = bufferCluster[id][4]; | |
348 | ||
349 | // Add cluster information to the TEveQuadSet | |
350 | fQuadSet2->AddQuad(iy, iz); | |
351 | fQuadSet2->QuadValue(amp); | |
352 | // fQuadSet2->QuadId(iid); | |
353 | ||
354 | } // end clusters loop | |
355 | } | |
356 | else { if (fDebug) printf("There is no clusters in SM %d \n", smId); } | |
357 | ||
358 | } // end if (fEMCALSModuleData != 0) | |
359 | ||
360 | } | |
361 | ||
362 | //______________________________________________________________________________ | |
363 | void AliEveEMCALSModule::SetSModuleID(Int_t id) | |
364 | { | |
365 | // | |
366 | // Set id of the SM to display. | |
367 | // | |
368 | ||
369 | if (id < 0) id = 0; | |
370 | if (id > 12) id = 12; | |
371 | ||
372 | fSModuleID = id; | |
373 | } |