2 // Visualization of an EMCAL super module.
4 // Author: Magali Estienne (magali.estienne@cern.ch)
11 #include <TEveFrameBox.h>
12 #include <TEveQuadSet.h>
13 #include <TEvePointSet.h>
14 #include <TEveRGBAPalette.h>
16 #include "AliEveEMCALSModule.h"
26 class TVirtualViewer3D;
27 class AliEveEMCALData;
30 class AliEveEMCALSModuleData;
32 ClassImp(AliEveEMCALSModule)
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;
42 AliEveEMCALSModule::AliEveEMCALSModule(Int_t smid, const Text_t* n, const Text_t* t) :
43 TEveElement(fFrameColor),
48 fFrameColor((Color_t)10),
50 fQuadSet(new TEveQuadSet(n,t)),
51 fQuadSet2(new TEveQuadSet(n,t)),
52 fPointSet(new TEvePointSet(n)),
60 snprintf(name,256,"Full Super Module %02d",smid);
62 snprintf(name,256,"Half Super Module %02d",smid);
67 fPointSet->IncDenyDestroy();
68 AddElement(fPointSet);
70 fQuadSet->IncDenyDestroy();
73 fQuadSet2->IncDenyDestroy();
74 AddElement(fQuadSet2);
78 AliEveEMCALSModule::AliEveEMCALSModule(const AliEveEMCALSModule &esm) :
79 TEveElement(fFrameColor),
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),
95 if (fSModuleID < 10) {
96 snprintf(name,256,"Full Super Module %02d",fSModuleID);
98 snprintf(name,256,"Half Super Module %02d",fSModuleID);
103 fPointSet->IncDenyDestroy();
104 AddElement(fPointSet);
106 fQuadSet->IncDenyDestroy();
107 AddElement(fQuadSet);
109 fQuadSet2->IncDenyDestroy();
110 AddElement(fQuadSet2);
114 AliEveEMCALSModule::~AliEveEMCALSModule()
120 fPointSet->DecDenyDestroy();
121 fQuadSet->DecDenyDestroy();
122 fQuadSet2->DecDenyDestroy();
124 if(fEMCALData) fEMCALData->DecRefCount();
127 //______________________________________________________________________________
128 void AliEveEMCALSModule::DropData() const
131 // release the sm data
142 //______________________________________________________________________________
143 void AliEveEMCALSModule::InitStatics(AliEveEMCALSModuleData* md)
146 // Bounding box, Framebox and Palette
149 if (fgStaticInit) return;
150 fgStaticInit = kTRUE;
152 md->GetSModuleBigBox(fgSMBigBBox[0],fgSMBigBBox[1], fgSMBigBBox[2]);
153 md->GetSModuleSmallBox(fgSMSmallBBox[0],fgSMSmallBBox[1], fgSMSmallBBox[2]);
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();
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();
172 //______________________________________________________________________________
173 void AliEveEMCALSModule::SetClusterSize(Int_t size)
176 // Cluster point size
179 fClusterSize = TMath::Max(1, size);
182 //______________________________________________________________________________
183 void AliEveEMCALSModule::SetHitSize(Int_t size)
189 fHitSize = TMath::Max(1, size);
192 //______________________________________________________________________________
193 void AliEveEMCALSModule::SetDataSource(AliEveEMCALData* const data)
196 // Set source of data.
199 if (data == fEMCALData) return;
200 if(fEMCALData) fEMCALData->DecRefCount();
202 if(fEMCALData) fEMCALData->IncRefCount();
204 // Get pointer on SM data
205 fEMCALSModuleData = GetSModuleData();
208 //______________________________________________________________________________
209 AliEveEMCALSModuleData* AliEveEMCALSModule::GetSModuleData() const
212 // Return source of data.
215 return fEMCALData ? fEMCALData->GetSModuleData(fSModuleID) : 0;
218 //______________________________________________________________________________
219 void AliEveEMCALSModule::UpdateQuads()
222 // Update hit/digit/cluster representation.
225 std::vector< std::vector<Double_t> > bufferDigit;
226 std::vector< std::vector<Double_t> > bufferCluster;
227 std::vector< std::vector<Float_t> > bufferHit;
228 Int_t nDigits, nClusters, nHits, oldSize;
229 Float_t hitX, hitY, hitZ;
230 Int_t smId = fEMCALSModuleData->GetSmId();
232 //--------------------------
233 // Hits from runloader
234 //--------------------------
238 TEvePointSet* points = fEMCALData->GetPointSetData();
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);
247 else {printf("There is no hits in Runloader \n"); }
253 InitStatics(fEMCALSModuleData);
255 // digits ------------------------
257 // Define TEveQuadSet for digits
258 fQuadSet->SetOwnIds(kTRUE);
259 fQuadSet->Reset(TEveQuadSet::kQT_RectangleYZFixedDimX, kFALSE, 32);
260 fQuadSet->SetDefWidth (fEMCALSModuleData->GetPhiTileSize());
261 fQuadSet->SetDefHeight(fEMCALSModuleData->GetEtaTileSize());
262 fQuadSet->RefMainTrans().SetFrom(*fEMCALSModuleData->GetSModuleMatrix());
263 fQuadSet->SetPalette(fgFrameDigPalette);
264 if(smId<fEMCALSModuleData->GetNsmf())
265 fQuadSet->SetFrame(fgFrameBigBox);
266 else fQuadSet->SetFrame(fgFrameSmallBox);
268 // Get the digit information from the buffer
269 bufferDigit = fEMCALSModuleData->GetDigitBuffer();
270 if(!bufferDigit.empty())
272 nDigits = fEMCALSModuleData->GetNDigits();
273 if(fDebug>1) Info("AliEveEMCALSModule::UpdateQuads", "nDigits: %d", nDigits );
275 for (Int_t id = 0; id < nDigits; id++) {
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];
284 // Add digit information to the TEveQuadSet
285 fQuadSet->AddQuad(iy, iz);
286 fQuadSet->QuadValue(amp);
289 else { if (fDebug) Info("AliEveEMCALSModule::UpdateQuads", "There is no digits in SM %d \n", smId); }
291 // hits --------------------------
292 bufferHit = fEMCALSModuleData->GetHitBuffer();
293 if(!bufferHit.empty())
296 nHits = fEMCALSModuleData->GetNHits();
297 if(fDebug>1) Info("AliEveEMCALSModule::UpdateQuads", "nHits: %d", nHits);
298 oldSize = fPointSet->GrowFor(nHits);
300 for (Int_t ih = 0; ih < nHits; ih++) {
301 hitX = bufferHit[ih][3];
302 hitY = bufferHit[ih][4];
303 hitZ = bufferHit[ih][5];
304 fPointSet->SetPoint(ih,hitX,hitY,hitZ);
305 snprintf(form,1000,"N=%d", fPointSet->Size());
306 fPointSet->SetTitle(form);
307 fPointSet->SetMarkerSize(.5);
308 fPointSet->SetMarkerColor((Color_t)2);
311 else { if (fDebug) printf("There is no hits in SM %d \n", smId); }
313 // clusters ------------------------
315 // Define TEveQuadSet for clusters
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());
321 fQuadSet2->SetPalette(fgFrameCluPalette);
322 if(smId<fEMCALSModuleData->GetNsmf())
323 fQuadSet2->SetFrame(fgFrameBigBox);
324 else fQuadSet2->SetFrame(fgFrameSmallBox);
326 // Get the cluster information from the buffer
327 bufferCluster = fEMCALSModuleData->GetClusterBuffer();
328 if(!bufferCluster.empty())
330 nClusters = fEMCALSModuleData->GetNClusters();
331 if(fDebug>1) Info("AliEveEMCALSModule::UpdateQuads", "nClusters: %d", nClusters );
332 // loop over clusters
333 for (Int_t id = 0; id < nClusters; id++) {
335 Info("AliEveEMCALSModule::UpdateQuads", "bufferCluster[%d][0]: %f", id, bufferCluster[id][0] );
336 Info("AliEveEMCALSModule::UpdateQuads", "bufferCluster[%d][1]: %f", id, bufferCluster[id][1] );
337 Info("AliEveEMCALSModule::UpdateQuads", "bufferCluster[%d][2]: %f", id, bufferCluster[id][2] );
338 Info("AliEveEMCALSModule::UpdateQuads", "bufferCluster[%d][3]: %f", id, bufferCluster[id][3] );
339 Info("AliEveEMCALSModule::UpdateQuads", "bufferCluster[%d][4]: %f", id, bufferCluster[id][4] );
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];
348 // Add cluster information to the TEveQuadSet
349 fQuadSet2->AddQuad(iy, iz);
350 fQuadSet2->QuadValue(amp);
351 // fQuadSet2->QuadId(iid);
353 } // end clusters loop
355 else { if (fDebug) Info("AliEveEMCALSModule::UpdateQuads", "There is no clusters in SM %d \n", smId); }
359 //______________________________________________________________________________
360 void AliEveEMCALSModule::SetSModuleID(Int_t id)
363 // Set id of the SM to display.
367 if (id > 12) id = 12;