]>
Commit | Line | Data |
---|---|---|
c3e34498 | 1 | // EMCAL event display |
2 | // Visualization of an EMCAL super module. | |
3 | // | |
4 | // Author: Magali Estienne (magali.estienne@cern.ch) | |
5 | // June 30 2008 | |
c3e34498 | 6 | |
345a46b0 | 7 | #include "AliEveEMCALSModule.h" |
8 | ||
9 | //#include <vector> | |
c3e34498 | 10 | |
c3e34498 | 11 | #include <TEveFrameBox.h> |
12 | #include <TEveQuadSet.h> | |
13 | #include <TEvePointSet.h> | |
c3e34498 | 14 | #include <TEveRGBAPalette.h> |
15 | ||
c3e34498 | 16 | |
345a46b0 | 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; | |
c3e34498 | 31 | |
32 | ClassImp(AliEveEMCALSModule) | |
33 | ||
345a46b0 | 34 | Bool_t AliEveEMCALSModule::fgStaticInit = kFALSE; |
ebedba59 | 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; | |
c3e34498 | 41 | |
42 | AliEveEMCALSModule::AliEveEMCALSModule(Int_t smid, const Text_t* n, const Text_t* t) : | |
43 | TEveElement(fFrameColor), | |
44 | TNamed(n,t), | |
a312477b | 45 | TAtt3D(), |
c3e34498 | 46 | fEMCALData(0), |
47 | fEMCALSModuleData(0), | |
48 | fFrameColor((Color_t)10), | |
c3e34498 | 49 | fSModuleID(smid), |
50 | fQuadSet(new TEveQuadSet(n,t)), | |
51 | fQuadSet2(new TEveQuadSet(n,t)), | |
52 | fPointSet(new TEvePointSet(n)), | |
c3e34498 | 53 | fClusterSize(5), |
54 | fHitSize(5), | |
c3e34498 | 55 | fDebug(0) |
56 | { | |
57 | // Constructor. | |
58 | Char_t name[256]; | |
59 | if (smid < 10) { | |
81480403 | 60 | snprintf(name,256,"Full Super Module %02d",smid); |
c3e34498 | 61 | } else { |
81480403 | 62 | snprintf(name,256,"Half Super Module %02d",smid); |
c3e34498 | 63 | } |
64 | SetName(name); | |
65 | ||
c3e34498 | 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(), | |
a312477b | 81 | TAtt3D(), |
c3e34498 | 82 | fEMCALData(esm.fEMCALData), |
83 | fEMCALSModuleData(esm.fEMCALSModuleData), | |
84 | fFrameColor(esm.fFrameColor), | |
c3e34498 | 85 | fSModuleID(esm.fSModuleID), |
86 | fQuadSet(esm.fQuadSet), | |
87 | fQuadSet2(esm.fQuadSet2), | |
88 | fPointSet(esm.fPointSet), | |
c3e34498 | 89 | fClusterSize(esm.fClusterSize), |
90 | fHitSize(esm.fHitSize), | |
c3e34498 | 91 | fDebug(esm.fDebug) |
92 | { | |
a312477b | 93 | // Copy constructor. |
c3e34498 | 94 | Char_t name[256]; |
95 | if (fSModuleID < 10) { | |
d71af8e3 | 96 | snprintf(name,256,"Full Super Module %02d",fSModuleID); |
c3e34498 | 97 | } else { |
d71af8e3 | 98 | snprintf(name,256,"Half Super Module %02d",fSModuleID); |
c3e34498 | 99 | } |
100 | SetName(name); | |
101 | ||
c3e34498 | 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(); | |
ef3891ac | 122 | fQuadSet2->DecDenyDestroy(); |
c3e34498 | 123 | |
124 | if(fEMCALData) fEMCALData->DecRefCount(); | |
c3e34498 | 125 | } |
126 | ||
127 | //______________________________________________________________________________ | |
345a46b0 | 128 | void AliEveEMCALSModule::DropData() const |
c3e34498 | 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 | //______________________________________________________________________________ | |
ebedba59 | 143 | void AliEveEMCALSModule::InitStatics(AliEveEMCALSModuleData* md) |
c3e34498 | 144 | { |
145 | // | |
a312477b | 146 | // Bounding box, Framebox and Palette |
c3e34498 | 147 | // |
148 | ||
345a46b0 | 149 | if (fgStaticInit) return; |
150 | fgStaticInit = kTRUE; | |
c3e34498 | 151 | |
ebedba59 | 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(); | |
c3e34498 | 170 | } |
171 | ||
c3e34498 | 172 | //______________________________________________________________________________ |
173 | void AliEveEMCALSModule::SetClusterSize(Int_t size) | |
174 | { | |
175 | // | |
a312477b | 176 | // Cluster point size |
c3e34498 | 177 | // |
178 | ||
179 | fClusterSize = TMath::Max(1, size); | |
c3e34498 | 180 | } |
181 | ||
182 | //______________________________________________________________________________ | |
183 | void AliEveEMCALSModule::SetHitSize(Int_t size) | |
184 | { | |
185 | // | |
186 | // hit point size | |
187 | // | |
188 | ||
189 | fHitSize = TMath::Max(1, size); | |
c3e34498 | 190 | } |
191 | ||
192 | //______________________________________________________________________________ | |
345a46b0 | 193 | void AliEveEMCALSModule::SetDataSource(AliEveEMCALData* const data) |
c3e34498 | 194 | { |
a312477b | 195 | // |
c3e34498 | 196 | // Set source of data. |
a312477b | 197 | // |
c3e34498 | 198 | |
199 | if (data == fEMCALData) return; | |
200 | if(fEMCALData) fEMCALData->DecRefCount(); | |
201 | fEMCALData = data; | |
202 | if(fEMCALData) fEMCALData->IncRefCount(); | |
203 | ||
a312477b | 204 | // Get pointer on SM data |
c3e34498 | 205 | fEMCALSModuleData = GetSModuleData(); |
c3e34498 | 206 | } |
207 | ||
208 | //______________________________________________________________________________ | |
209 | AliEveEMCALSModuleData* AliEveEMCALSModule::GetSModuleData() const | |
210 | { | |
a312477b | 211 | // |
c3e34498 | 212 | // Return source of data. |
a312477b | 213 | // |
c3e34498 | 214 | |
215 | return fEMCALData ? fEMCALData->GetSModuleData(fSModuleID) : 0; | |
216 | } | |
217 | ||
218 | //______________________________________________________________________________ | |
219 | void AliEveEMCALSModule::UpdateQuads() | |
220 | { | |
a312477b | 221 | // |
c3e34498 | 222 | // Update hit/digit/cluster representation. |
a312477b | 223 | // |
c3e34498 | 224 | |
a312477b | 225 | vector< vector<Double_t> > bufferDigit; |
226 | vector< vector<Double_t> > bufferCluster; | |
c3e34498 | 227 | vector< vector<Float_t> > bufferHit; |
a312477b | 228 | Int_t nDigits, nClusters, nHits, oldSize; |
c3e34498 | 229 | Float_t hitX, hitY, hitZ; |
230 | Int_t smId = fEMCALSModuleData->GetSmId(); | |
231 | ||
232 | //-------------------------- | |
233 | // Hits from runloader | |
234 | //-------------------------- | |
235 | fPointSet->Reset(); | |
236 | ||
a312477b | 237 | /* |
c3e34498 | 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 | ||
a312477b | 249 | */ |
250 | ||
ebedba59 | 251 | |
5039c05a | 252 | if (!fgStaticInit) |
253 | InitStatics(fEMCALSModuleData); | |
ebedba59 | 254 | |
5039c05a | 255 | // digits ------------------------ |
a312477b | 256 | |
5039c05a | 257 | // Define TEveQuadSet for digits |
258 | fQuadSet->SetOwnIds(kTRUE); | |
259 | fQuadSet->Reset(TEveQuadSet::kQT_RectangleYZFixedDimX, kFALSE, 32); | |
c3e34498 | 260 | fQuadSet->SetDefWidth (fEMCALSModuleData->GetPhiTileSize()); |
261 | fQuadSet->SetDefHeight(fEMCALSModuleData->GetEtaTileSize()); | |
262 | fQuadSet->RefMainTrans().SetFrom(*fEMCALSModuleData->GetSModuleMatrix()); | |
ebedba59 | 263 | fQuadSet->SetPalette(fgFrameDigPalette); |
c3e34498 | 264 | if(smId<fEMCALSModuleData->GetNsmf()) |
ebedba59 | 265 | fQuadSet->SetFrame(fgFrameBigBox); |
266 | else fQuadSet->SetFrame(fgFrameSmallBox); | |
c3e34498 | 267 | |
a312477b | 268 | // Get the digit information from the buffer |
c3e34498 | 269 | bufferDigit = fEMCALSModuleData->GetDigitBuffer(); |
270 | if(!bufferDigit.empty()) | |
271 | { | |
272 | nDigits = fEMCALSModuleData->GetNDigits(); | |
273 | if(fDebug>1) cout << "nDigits: " << nDigits << endl; | |
274 | // loop over digits | |
275 | for (Int_t id = 0; id < nDigits; id++) { | |
a312477b | 276 | // Int_t iid = (Int_t)bufferDigit[id][0]; |
277 | // Int_t isupMod = (Int_t)bufferDigit[id][1]; | |
278 | Double_t iamp = bufferDigit[id][2]; | |
279 | Int_t amp = (Int_t)(iamp+0.5); | |
280 | // Double_t ix = bufferDigit[id][3]; | |
281 | Double_t iy = bufferDigit[id][4]; | |
282 | Double_t iz = bufferDigit[id][5]; | |
c3e34498 | 283 | |
a312477b | 284 | // Add digit information to the TEveQuadSet |
c3e34498 | 285 | fQuadSet->AddQuad(iy, iz); |
a312477b | 286 | fQuadSet->QuadValue(amp); |
c3e34498 | 287 | } // end digits loop |
288 | } | |
ef3891ac | 289 | else { if (fDebug) printf("There is no digits in SM %d \n", smId); } |
c3e34498 | 290 | |
291 | // hits -------------------------- | |
a312477b | 292 | bufferHit = fEMCALSModuleData->GetHitBuffer(); |
c3e34498 | 293 | if(!bufferHit.empty()) |
294 | { | |
a312477b | 295 | char form[1000]; |
c3e34498 | 296 | nHits = fEMCALSModuleData->GetNHits(); |
297 | if(fDebug>1) cout << "nHits: " << nHits << endl; | |
298 | oldSize = fPointSet->GrowFor(nHits); | |
299 | // Loop over hits | |
300 | for (Int_t ih = 0; ih < nHits; ih++) { | |
a312477b | 301 | hitX = bufferHit[ih][3]; |
302 | hitY = bufferHit[ih][4]; | |
303 | hitZ = bufferHit[ih][5]; | |
c3e34498 | 304 | fPointSet->SetPoint(ih,hitX,hitY,hitZ); |
d71af8e3 | 305 | snprintf(form,1000,"N=%d", fPointSet->Size()); |
a312477b | 306 | fPointSet->SetTitle(form); |
307 | fPointSet->SetMarkerSize(.5); | |
308 | fPointSet->SetMarkerColor((Color_t)2); | |
c3e34498 | 309 | } |
310 | } | |
ef3891ac | 311 | else { if (fDebug) printf("There is no hits in SM %d \n", smId); } |
c3e34498 | 312 | |
313 | // clusters ------------------------ | |
a312477b | 314 | |
315 | // Define TEveQuadSet for clusters | |
c3e34498 | 316 | fQuadSet2->SetOwnIds(kTRUE); |
317 | fQuadSet2->Reset(TEveQuadSet::kQT_RectangleYZFixedDimX, kFALSE, 32); | |
318 | fQuadSet2->SetDefWidth (fEMCALSModuleData->GetPhiTileSize()); | |
319 | fQuadSet2->SetDefHeight(fEMCALSModuleData->GetEtaTileSize()); | |
320 | fQuadSet2->RefMainTrans().SetFrom(*fEMCALSModuleData->GetSModuleMatrix()); | |
ebedba59 | 321 | fQuadSet2->SetPalette(fgFrameCluPalette); |
c3e34498 | 322 | if(smId<fEMCALSModuleData->GetNsmf()) |
ebedba59 | 323 | fQuadSet2->SetFrame(fgFrameBigBox); |
324 | else fQuadSet2->SetFrame(fgFrameSmallBox); | |
c3e34498 | 325 | |
a312477b | 326 | // Get the cluster information from the buffer |
c3e34498 | 327 | bufferCluster = fEMCALSModuleData->GetClusterBuffer(); |
328 | if(!bufferCluster.empty()) | |
329 | { | |
330 | nClusters = fEMCALSModuleData->GetNClusters(); | |
331 | if(fDebug>1) cout << "nClusters: " << nClusters << endl; | |
332 | // loop over clusters | |
333 | for (Int_t id = 0; id < nClusters; id++) { | |
334 | if(fDebug>1) { | |
335 | cout << "bufferCluster[" << id << "][0]: " << bufferCluster[id][0] << endl; | |
336 | cout << "bufferCluster[" << id << "][1]: " << bufferCluster[id][1] << endl; | |
337 | cout << "bufferCluster[" << id << "][2]: " << bufferCluster[id][2] << endl; | |
338 | cout << "bufferCluster[" << id << "][3]: " << bufferCluster[id][3] << endl; | |
339 | cout << "bufferCluster[" << id << "][4]: " << bufferCluster[id][4] << endl; | |
340 | } | |
a312477b | 341 | // Int_t isupMod = (Int_t)bufferCluster[id][0]; |
342 | Double_t iamp = bufferCluster[id][1]; | |
343 | Int_t amp = (Int_t)(iamp+0.5); | |
344 | // Double_t ix = bufferCluster[id][2]; | |
345 | Double_t iy = bufferCluster[id][3]; | |
346 | Double_t iz = bufferCluster[id][4]; | |
c3e34498 | 347 | |
a312477b | 348 | // Add cluster information to the TEveQuadSet |
c3e34498 | 349 | fQuadSet2->AddQuad(iy, iz); |
a312477b | 350 | fQuadSet2->QuadValue(amp); |
c3e34498 | 351 | // fQuadSet2->QuadId(iid); |
352 | ||
353 | } // end clusters loop | |
354 | } | |
ef3891ac | 355 | else { if (fDebug) printf("There is no clusters in SM %d \n", smId); } |
c3e34498 | 356 | |
c3e34498 | 357 | } |
358 | ||
359 | //______________________________________________________________________________ | |
360 | void AliEveEMCALSModule::SetSModuleID(Int_t id) | |
361 | { | |
a312477b | 362 | // |
363 | // Set id of the SM to display. | |
364 | // | |
c3e34498 | 365 | |
366 | if (id < 0) id = 0; | |
367 | if (id > 12) id = 12; | |
368 | ||
369 | fSModuleID = id; | |
c3e34498 | 370 | } |