Coverity
[u/mrichter/AliRoot.git] / EVE / EveDet / AliEveVZEROModule.cxx
CommitLineData
ad080421 1/**************************************************************************
2 * Copyright(c) 1998-2008, ALICE Experiment at CERN, all rights reserved. *
3 * See http://aliceinfo.cern.ch/Offline/AliRoot/License.html for *
4 * full copyright notice. *
5 **************************************************************************/
6
7//////////////////////////////////////////////////////////////////////////
8// //
9// The drawing module for the VZERO detector //
10// //
11//////////////////////////////////////////////////////////////////////////
12
13#include "AliEveVZEROModule.h"
14
15#include <TH1.h>
16#include <TEveManager.h>
17#include <EveBase/AliEveEventManager.h>
18#include <TEveTrans.h>
19
20#include <AliRawReader.h>
21#include <AliVZERORawStream.h>
22#include <AliESDEvent.h>
23
24static const Float_t RadC[] = { 4.6, 7.1, 11.5, 18.9, 31.4 };
25static const Float_t RadA[] = { 4.2, 7.6, 13.8, 22.7, 41.4 };
26static const Float_t RadEps = 0.4;
27static const Float_t PhiEps = 0.025;
28static const Float_t PhiStp = TMath::TwoPi()/8.0;
29
30ClassImp(AliEveVZEROModule)
31
32/******************************************************************************/
33AliEveVZEROModule::AliEveVZEROModule(const Text_t* n, Bool_t side)
34 : TEveQuadSet(n),
35 fStream(NULL),
36 fSampleIndex(AliVZERORawStream::kNEvOfInt/2),
37 fIsASide(side)
38{
39 //
40 // Default constructor
41 //
42 TEveRGBAPalette* rawPalette = new TEveRGBAPalette(0, 1023);
43 rawPalette->SetLimits(0, 1023);
44 SetPalette(rawPalette);
45 Reset(TEveQuadSet::kQT_FreeQuad, kFALSE, 32);
46}
47
48/******************************************************************************/
49AliEveVZEROModule::~AliEveVZEROModule()
50{
51 //
52 // Destructor
53 //
54 delete fStream;
55}
56
57/******************************************************************************/
58void AliEveVZEROModule::LoadRaw(AliRawReader *rawReader)
59{
60 //
61 // Load VZERO raw-data
62 //
63 if (fStream) delete fStream;
64 fStream = new AliVZERORawStream(rawReader);
65 if (!fStream->Next()) {
66 delete fStream;
67 fStream = NULL;
68 return;
69 }
70
71 for (Int_t iChannel=0; iChannel < AliVZERORawStream::kNChannels; ++iChannel) {
72 Int_t offChannel = fStream->GetOfflineChannel(iChannel);
73 Float_t minR,maxR,minP,maxP;
74 if (fIsASide) {
75 if (offChannel < 32) continue;
76
77 Int_t ri = (offChannel-32) / 8;
78 Int_t pi = (offChannel-32) % 8;
79 minR = RadA[ri] + RadEps, maxR = RadA[ri+1] - RadEps;
80 minP = pi*PhiStp + PhiEps, maxP = (pi+1)*PhiStp - PhiEps;
81 }
82 else {
83 if (offChannel >= 32) continue;
84
85 Int_t ri = offChannel / 8;
86 Int_t pi = offChannel % 8;
87 minR = RadC[ri] + RadEps, maxR = RadC[ri+1] - RadEps;
88 minP = pi*PhiStp + PhiEps, maxP = (pi+1)*PhiStp - PhiEps;
89 }
90 Float_t v[12];
91 v[ 0] = minR*TMath::Cos(minP); v[ 1] = minR*TMath::Sin(minP); v[ 2] = 0;
92 v[ 3] = maxR*TMath::Cos(minP); v[ 4] = maxR*TMath::Sin(minP); v[ 5] = 0;
93 v[ 6] = maxR*TMath::Cos(maxP); v[ 7] = maxR*TMath::Sin(maxP); v[ 8] = 0;
94 v[ 9] = minR*TMath::Cos(maxP); v[10] = minR*TMath::Sin(maxP); v[11] = 0;
95
96 AddQuad(v);
97 QuadValue(fStream->GetPedestal(iChannel,fSampleIndex));
98 }
99
100 if (fIsASide)
101 RefMainTrans().SetPos(0, 0, 324);
102 else
103 RefMainTrans().SetPos(0, 0, -84);
104
105 gEve->AddElement(this);
106 gEve->Redraw3D();
107}
108
109/******************************************************************************/
110void AliEveVZEROModule::DigitSelected(Int_t idx)
111{
112 //
113 // Override control-click from TEveQuadSet
114 //
115 if (!fStream) return;
116
117 Int_t iPMT = idx;
118 if (!fIsASide) iPMT += 32;
119 printf("PMT = %2d ADC = ",iPMT);
120 TH1S *hADC = new TH1S(Form("VZERO_ADC_%d",iPMT),
121 Form("ADC samples for PMT %d, Time/Width = %3.1f/%3.1f ns",
122 iPMT,
123 (Float_t)fStream->GetTime(iPMT)/10.,(Float_t)fStream->GetWidth(iPMT)/10.),
124 AliVZERORawStream::kNEvOfInt,-0.5,(Float_t)AliVZERORawStream::kNEvOfInt-0.5);
125 hADC->SetXTitle("Sample index");
126 hADC->SetYTitle("ADC value");
127 hADC->SetStats(kFALSE);
128 for (Int_t iEv = 0; iEv < AliVZERORawStream::kNEvOfInt; ++iEv) {
c023384e 129 printf("%4d ",fStream->GetPedestal(iPMT,iEv));
ad080421 130 hADC->SetBinContent(iEv+1,fStream->GetPedestal(iPMT,iEv));
131 }
132 printf("\nTime = %3.1f ns Width = %3.1f ns\n",(Float_t)fStream->GetTime(iPMT)/10.,(Float_t)fStream->GetWidth(iPMT)/10.);
133 hADC->Draw();
134 gPad->Modified();
135 gPad->Update();
136}
137
138/******************************************************************************/
139void AliEveVZEROModule::SetSampleIndex(Int_t index)
140{
141 fSampleIndex = index;
142 if (!fStream) return;
143
144 for(Int_t idx = 0; idx < (AliVZERORawStream::kNChannels/2); ++idx) {
145 Int_t iPMT = idx;
146 if (!fIsASide) iPMT += 32;
147 DigitBase_t *qb = GetDigit(idx);
148 qb->fValue = fStream->GetPedestal(iPMT,fSampleIndex);
149 }
150}