1 //*************************************************************************
3 // Visualization of an EMCAL super module.
5 // Author: Magali Estienne (magali.estienne@cern.ch)
7 //*************************************************************************
12 #include <TEveTrans.h>
13 #include <TEveElement.h>
14 #include <TEveFrameBox.h>
15 #include <TEveQuadSet.h>
16 #include <TEvePointSet.h>
17 #include <TClonesArray.h>
20 #include <TBuffer3DTypes.h>
21 #include <TBuffer3D.h>
22 #include <TVirtualPad.h>
23 #include <TVirtualViewer3D.h>
24 #include <TEveRGBAPalette.h>
26 #include "AliEveEMCALData.h"
27 #include "AliEveEMCALSModule.h"
28 #include "AliEveEMCALSModuleData.h"
29 #include "AliEMCALHit.h"
30 #include "AliEMCALDigit.h"
33 ClassImp(AliEveEMCALSModule)
35 Bool_t AliEveEMCALSModule::fStaticInit = kFALSE;
36 Float_t AliEveEMCALSModule::fgSMBigBBox[3];
37 Float_t AliEveEMCALSModule::fgSMSmallBBox[3];
38 TEveFrameBox* AliEveEMCALSModule::fgFrameBigBox = 0;
39 TEveFrameBox* AliEveEMCALSModule::fgFrameSmallBox = 0;
40 TEveRGBAPalette* AliEveEMCALSModule::fgFrameDigPalette = 0;
41 TEveRGBAPalette* AliEveEMCALSModule::fgFrameCluPalette = 0;
43 AliEveEMCALSModule::AliEveEMCALSModule(Int_t smid, const Text_t* n, const Text_t* t) :
44 TEveElement(fFrameColor),
49 fFrameColor((Color_t)10),
51 fQuadSet(new TEveQuadSet(n,t)),
52 fQuadSet2(new TEveQuadSet(n,t)),
53 fPointSet(new TEvePointSet(n)),
61 sprintf(name,"Full Super Module %02d",smid);
63 sprintf(name,"Half Super Module %02d",smid);
68 fPointSet->IncDenyDestroy();
69 AddElement(fPointSet);
71 fQuadSet->IncDenyDestroy();
74 fQuadSet2->IncDenyDestroy();
75 AddElement(fQuadSet2);
79 AliEveEMCALSModule::AliEveEMCALSModule(const AliEveEMCALSModule &esm) :
80 TEveElement(fFrameColor),
83 fEMCALData(esm.fEMCALData),
84 fEMCALSModuleData(esm.fEMCALSModuleData),
85 fFrameColor(esm.fFrameColor),
86 fSModuleID(esm.fSModuleID),
87 fQuadSet(esm.fQuadSet),
88 fQuadSet2(esm.fQuadSet2),
89 fPointSet(esm.fPointSet),
90 fClusterSize(esm.fClusterSize),
91 fHitSize(esm.fHitSize),
96 if (fSModuleID < 10) {
97 sprintf(name,"Full Super Module %02d",fSModuleID);
99 sprintf(name,"Half Super Module %02d",fSModuleID);
104 fPointSet->IncDenyDestroy();
105 AddElement(fPointSet);
107 fQuadSet->IncDenyDestroy();
108 AddElement(fQuadSet);
110 fQuadSet2->IncDenyDestroy();
111 AddElement(fQuadSet2);
115 AliEveEMCALSModule::~AliEveEMCALSModule()
121 fPointSet->DecDenyDestroy();
122 fQuadSet->DecDenyDestroy();
123 fQuadSet2->DecDenyDestroy();
125 if(fEMCALData) fEMCALData->DecRefCount();
128 //______________________________________________________________________________
129 void AliEveEMCALSModule::DropData()
132 // release the sm data
143 //______________________________________________________________________________
144 void AliEveEMCALSModule::InitStatics(AliEveEMCALSModuleData* md)
147 // Bounding box, Framebox and Palette
150 if (fStaticInit) return;
153 md->GetSModuleBigBox(fgSMBigBBox[0],fgSMBigBBox[1], fgSMBigBBox[2]);
154 md->GetSModuleSmallBox(fgSMSmallBBox[0],fgSMSmallBBox[1], fgSMSmallBBox[2]);
156 fgFrameBigBox = new TEveFrameBox();
157 fgFrameBigBox->SetAABoxCenterHalfSize(0, 0, 0, fgSMBigBBox[0], fgSMBigBBox[1], fgSMBigBBox[2]);
158 fgFrameBigBox->SetFrameColor((Color_t)10);
159 fgFrameBigBox->IncRefCount();
160 fgFrameDigPalette = new TEveRGBAPalette(0,512);
161 fgFrameDigPalette->SetLimits(0, 1024);
162 fgFrameDigPalette->IncRefCount();
164 fgFrameSmallBox = new TEveFrameBox();
165 fgFrameSmallBox->SetAABoxCenterHalfSize(0, 0, 0, fgSMSmallBBox[0], fgSMSmallBBox[1], fgSMSmallBBox[2]);
166 fgFrameSmallBox->SetFrameColor((Color_t)10);
167 fgFrameSmallBox->IncRefCount();
168 fgFrameCluPalette = new TEveRGBAPalette(0,512);
169 fgFrameCluPalette->SetLimits(0, 1024);
170 fgFrameCluPalette->IncRefCount();
173 //______________________________________________________________________________
174 void AliEveEMCALSModule::SetClusterSize(Int_t size)
177 // Cluster point size
180 fClusterSize = TMath::Max(1, size);
183 //______________________________________________________________________________
184 void AliEveEMCALSModule::SetHitSize(Int_t size)
190 fHitSize = TMath::Max(1, size);
193 //______________________________________________________________________________
194 void AliEveEMCALSModule::SetDataSource(AliEveEMCALData* data)
197 // Set source of data.
200 if (data == fEMCALData) return;
201 if(fEMCALData) fEMCALData->DecRefCount();
203 if(fEMCALData) fEMCALData->IncRefCount();
205 // Get pointer on SM data
206 fEMCALSModuleData = GetSModuleData();
209 //______________________________________________________________________________
210 AliEveEMCALSModuleData* AliEveEMCALSModule::GetSModuleData() const
213 // Return source of data.
216 return fEMCALData ? fEMCALData->GetSModuleData(fSModuleID) : 0;
219 //______________________________________________________________________________
220 void AliEveEMCALSModule::UpdateQuads()
223 // Update hit/digit/cluster representation.
226 vector< vector<Double_t> > bufferDigit;
227 vector< vector<Double_t> > bufferCluster;
228 vector< vector<Float_t> > bufferHit;
229 Int_t nDigits, nClusters, nHits, oldSize;
230 Float_t hitX, hitY, hitZ;
231 Int_t smId = fEMCALSModuleData->GetSmId();
233 //--------------------------
234 // Hits from runloader
235 //--------------------------
239 TEvePointSet* points = fEMCALData->GetPointSetData();
242 sprintf(form,"N=%d", points->Size());
243 points->SetTitle(form);
244 points->SetMarkerSize(.5);
245 points->SetMarkerColor((Color_t)2);
246 fPointSet->AddElement(points);
248 else {printf("There is no hits in Runloader \n"); }
252 if (fEMCALSModuleData != 0) {
255 InitStatics(fEMCALSModuleData);
257 // digits ------------------------
259 // Define TEveQuadSet for digits
260 fQuadSet->SetOwnIds(kTRUE);
261 fQuadSet->Reset(TEveQuadSet::kQT_RectangleYZFixedDimX, kFALSE, 32);
262 fQuadSet->SetDefWidth (fEMCALSModuleData->GetPhiTileSize());
263 fQuadSet->SetDefHeight(fEMCALSModuleData->GetEtaTileSize());
264 fQuadSet->RefMainTrans().SetFrom(*fEMCALSModuleData->GetSModuleMatrix());
265 fQuadSet->SetPalette(fgFrameDigPalette);
266 if(smId<fEMCALSModuleData->GetNsmf())
267 fQuadSet->SetFrame(fgFrameBigBox);
268 else fQuadSet->SetFrame(fgFrameSmallBox);
270 // Get the digit information from the buffer
271 bufferDigit = fEMCALSModuleData->GetDigitBuffer();
272 if(!bufferDigit.empty())
274 nDigits = fEMCALSModuleData->GetNDigits();
275 if(fDebug>1) cout << "nDigits: " << nDigits << endl;
277 for (Int_t id = 0; id < nDigits; id++) {
278 // Int_t iid = (Int_t)bufferDigit[id][0];
279 // Int_t isupMod = (Int_t)bufferDigit[id][1];
280 Double_t iamp = bufferDigit[id][2];
281 Int_t amp = (Int_t)(iamp+0.5);
282 // Double_t ix = bufferDigit[id][3];
283 Double_t iy = bufferDigit[id][4];
284 Double_t iz = bufferDigit[id][5];
286 // Add digit information to the TEveQuadSet
287 fQuadSet->AddQuad(iy, iz);
288 fQuadSet->QuadValue(amp);
291 else { if (fDebug) printf("There is no digits in SM %d \n", smId); }
293 // hits --------------------------
294 bufferHit = fEMCALSModuleData->GetHitBuffer();
295 if(!bufferHit.empty())
298 nHits = fEMCALSModuleData->GetNHits();
299 if(fDebug>1) cout << "nHits: " << nHits << endl;
300 oldSize = fPointSet->GrowFor(nHits);
302 for (Int_t ih = 0; ih < nHits; ih++) {
303 hitX = bufferHit[ih][3];
304 hitY = bufferHit[ih][4];
305 hitZ = bufferHit[ih][5];
306 fPointSet->SetPoint(ih,hitX,hitY,hitZ);
307 sprintf(form,"N=%d", fPointSet->Size());
308 fPointSet->SetTitle(form);
309 fPointSet->SetMarkerSize(.5);
310 fPointSet->SetMarkerColor((Color_t)2);
313 else { if (fDebug) printf("There is no hits in SM %d \n", smId); }
315 // clusters ------------------------
317 // Define TEveQuadSet for clusters
318 fQuadSet2->SetOwnIds(kTRUE);
319 fQuadSet2->Reset(TEveQuadSet::kQT_RectangleYZFixedDimX, kFALSE, 32);
320 fQuadSet2->SetDefWidth (fEMCALSModuleData->GetPhiTileSize());
321 fQuadSet2->SetDefHeight(fEMCALSModuleData->GetEtaTileSize());
322 fQuadSet2->RefMainTrans().SetFrom(*fEMCALSModuleData->GetSModuleMatrix());
323 fQuadSet2->SetPalette(fgFrameCluPalette);
324 if(smId<fEMCALSModuleData->GetNsmf())
325 fQuadSet2->SetFrame(fgFrameBigBox);
326 else fQuadSet2->SetFrame(fgFrameSmallBox);
328 // Get the cluster information from the buffer
329 bufferCluster = fEMCALSModuleData->GetClusterBuffer();
330 if(!bufferCluster.empty())
332 nClusters = fEMCALSModuleData->GetNClusters();
333 if(fDebug>1) cout << "nClusters: " << nClusters << endl;
334 // loop over clusters
335 for (Int_t id = 0; id < nClusters; id++) {
337 cout << "bufferCluster[" << id << "][0]: " << bufferCluster[id][0] << endl;
338 cout << "bufferCluster[" << id << "][1]: " << bufferCluster[id][1] << endl;
339 cout << "bufferCluster[" << id << "][2]: " << bufferCluster[id][2] << endl;
340 cout << "bufferCluster[" << id << "][3]: " << bufferCluster[id][3] << endl;
341 cout << "bufferCluster[" << id << "][4]: " << bufferCluster[id][4] << endl;
343 // Int_t isupMod = (Int_t)bufferCluster[id][0];
344 Double_t iamp = bufferCluster[id][1];
345 Int_t amp = (Int_t)(iamp+0.5);
346 // Double_t ix = bufferCluster[id][2];
347 Double_t iy = bufferCluster[id][3];
348 Double_t iz = bufferCluster[id][4];
350 // Add cluster information to the TEveQuadSet
351 fQuadSet2->AddQuad(iy, iz);
352 fQuadSet2->QuadValue(amp);
353 // fQuadSet2->QuadId(iid);
355 } // end clusters loop
357 else { if (fDebug) printf("There is no clusters in SM %d \n", smId); }
359 } // end if (fEMCALSModuleData != 0)
363 //______________________________________________________________________________
364 void AliEveEMCALSModule::SetSModuleID(Int_t id)
367 // Set id of the SM to display.
371 if (id > 12) id = 12;