]> git.uio.no Git - u/mrichter/AliRoot.git/blob - EVE/EveDet/AliEveTRDData.cxx
Fixed effc++ warnings.
[u/mrichter/AliRoot.git] / EVE / EveDet / AliEveTRDData.cxx
1 // $Id$
2 // Main authors: Matevz Tadel & Alja Mrak-Tadel: 2006, 2007
3
4 /**************************************************************************
5  * Copyright(c) 1998-2008, ALICE Experiment at CERN, all rights reserved. *
6  * See http://aliceinfo.cern.ch/Offline/AliRoot/License.html for          *
7  * full copyright notice.                                                 *
8  **************************************************************************/
9
10 #include "AliEveTRDData.h"
11 #include "AliEveTRDModuleImp.h"
12
13 #include "AliLog.h"
14 #include "AliTRDhit.h"
15 #include "AliTRDcluster.h"
16 #include "AliTRDcalibDB.h"
17 #include "AliTRDpadPlane.h"
18 #include "AliTRDgeometry.h"
19 #include "AliTRDdigitsManager.h"
20
21 ClassImp(AliEveTRDHits)
22 ClassImp(AliEveTRDDigits)
23 ClassImp(AliEveTRDClusters)
24
25 ///////////////////////////////////////////////////////////
26 /////////////   AliEveTRDDigits       /////////////////////
27 ///////////////////////////////////////////////////////////
28
29 //______________________________________________________________________________
30 AliEveTRDDigits::AliEveTRDDigits(AliEveTRDChamber *p) :
31   TEveQuadSet("digits", ""), fParent(p), fBoxes(), fData()
32 {}
33
34 //______________________________________________________________________________
35 void AliEveTRDDigits::SetData(AliTRDdigitsManager *digits)
36 {
37
38   fData.Allocate(fParent->fRowMax, fParent->fColMax, fParent->fTimeMax);
39   //    digits->Expand();
40   for (Int_t  row = 0;  row <  fParent->fRowMax;  row++)
41     for (Int_t  col = 0;  col <  fParent->fColMax;  col++)
42       for (Int_t time = 0; time < fParent->fTimeMax; time++) {
43         if(digits->GetDigitAmp(row, col, time, fParent->GetID()) < 0) continue;
44         fData.SetDataUnchecked(row, col, time, digits->GetDigitAmp(row, col, time, fParent->GetID()));
45       }
46 }
47
48 //______________________________________________________________________________
49 void AliEveTRDDigits::ComputeRepresentation()
50 {
51   // Calculate digits representation according to user settings. The
52   // user can set the following parameters:
53   // - digits scale (log/lin)
54   // - digits threshold
55   // - digits apparence (quads/boxes)
56
57   TEveQuadSet::Reset(TEveQuadSet::kQT_FreeQuad, kTRUE, 64);
58   // MT fBoxes.fBoxes.clear();
59
60   Double_t colSize, rowSize, scale;
61   Double_t x, y, z;
62
63   Int_t charge;
64   Float_t t0;
65   Float_t timeBinSize;
66
67   AliTRDcalibDB* calibration = AliTRDcalibDB::Instance();
68   Double_t cloc[4][3], cglo[3];
69   Int_t color, dimension;
70   fData.Expand();
71   for (Int_t  row = 0;  row <  fParent->fRowMax;  row++) {
72     rowSize = .5 * fParent->fPadPlane->GetRowSize(row);
73     z = fParent->fPadPlane->GetRowPos(row) - rowSize;
74
75     for (Int_t  col = 0;  col <  fParent->fColMax;  col++) {
76       colSize = .5 * fParent->fPadPlane->GetColSize(col);
77       y = fParent->fPadPlane->GetColPos(col) - colSize;
78       t0 = calibration->GetT0(fParent->fDet, col, row);
79       timeBinSize = calibration->GetVdrift(fParent->fDet, col, row)/fParent->fSamplingFrequency;
80
81       for (Int_t time = 0; time < fParent->fTimeMax; time++) {
82         charge = fData.GetDataUnchecked(row, col, time);
83         if (charge < fParent->GetDigitsThreshold()) continue;
84
85         x = fParent->fX0 - (time+0.5-t0)*timeBinSize;
86         scale = fParent->GetDigitsLog() ? TMath::Log(float(charge))/TMath::Log(1024.) : charge/1024.;
87         color  = 50+int(scale*50.);
88
89         cloc[0][2] = z - rowSize * scale;
90         cloc[0][1] = y - colSize * scale;
91         cloc[0][0] = x;
92
93         cloc[1][2] = z - rowSize * scale;
94         cloc[1][1] = y + colSize * scale;
95         cloc[1][0] = x;
96
97         cloc[2][2] = z + rowSize * scale;
98         cloc[2][1] = y + colSize * scale;
99         cloc[2][0] = x;
100
101         cloc[3][2] = z + rowSize * scale;
102         cloc[3][1] = y - colSize * scale;
103         cloc[3][0] = x;
104
105         Float_t* p = 0;
106         if( fParent->GetDigitsBox()){
107           // MT fBoxes.fBoxes.push_back(Box());
108           // MT fBoxes.fBoxes.back().color[0] = (UChar_t)color;
109           // MT fBoxes.fBoxes.back().color[1] = (UChar_t)color;
110           // MT fBoxes.fBoxes.back().color[2] = (UChar_t)color;
111           // MT fBoxes.fBoxes.back().color[3] = (UChar_t)color;
112           // MT p = fBoxes.fBoxes.back().vertices;
113           dimension = 2;
114         } else {
115           AddQuad((Float_t*)0);
116           QuadColor(color);
117           p = ((QFreeQuad_t*) fLastDigit)->fVertices;
118           dimension = 1;
119         }
120
121         for(int id=0; id<dimension; id++)
122           for (Int_t ic = 0; ic < 4; ic++) {
123             cloc[ic][0] -= .5 * id * timeBinSize;
124             fParent->fGeo->RotateBack(fParent->fDet,cloc[ic],cglo);
125             p[0] = cglo[0]; p[1] = cglo[1]; p[2] = cglo[2];
126             p+=3;
127           }
128       }  // end time loop
129     }  // end col loop
130   }  // end row loop
131   fData.Compress(1);
132 }
133
134 //______________________________________________________________________________
135 void AliEveTRDDigits::Paint(Option_t *option)
136 {
137   if(fParent->GetDigitsBox()) fBoxes.Paint(option);
138   else TEveQuadSet::Paint(option);
139 }
140
141 //______________________________________________________________________________
142 void AliEveTRDDigits::Reset()
143 {
144   TEveQuadSet::Reset(TEveQuadSet::kQT_FreeQuad, kTRUE, 64);
145   // MT fBoxes.fBoxes.clear();
146   fData.Reset();
147 }
148
149 ///////////////////////////////////////////////////////////
150 /////////////   AliEveTRDHits         /////////////////////
151 ///////////////////////////////////////////////////////////
152
153 //______________________________________________________________________________
154 AliEveTRDHits::AliEveTRDHits(AliEveTRDChamber *p) :
155   TEvePointSet("hits", 20), fParent(p)
156 {}
157
158 //______________________________________________________________________________
159 void AliEveTRDHits::PointSelected(Int_t n)
160 {
161   fParent->SpawnEditor();
162   AliTRDhit *h = dynamic_cast<AliTRDhit*>(GetPointId(n));
163   printf("\nDetector             : %d\n", h->GetDetector());
164   printf("Region of production : %c\n", h->FromAmplification() ? 'A' : 'D');
165   printf("TR photon            : %s\n", h->FromTRphoton() ? "Yes" : "No");
166   printf("Charge               : %d\n", h->GetCharge());
167   printf("MC track label       : %d\n", h->GetTrack());
168   printf("Time from collision  : %f\n", h->GetTime());
169 }
170
171
172 ///////////////////////////////////////////////////////////
173 /////////////   AliEveTRDHits               /////////////////////
174 ///////////////////////////////////////////////////////////
175
176 //______________________________________________________________________________
177 AliEveTRDClusters::AliEveTRDClusters(AliEveTRDChamber *p):AliEveTRDHits(p)
178 {}
179
180 //______________________________________________________________________________
181 void AliEveTRDClusters::PointSelected(Int_t n)
182 {
183   fParent->SpawnEditor();
184   AliTRDcluster *c = dynamic_cast<AliTRDcluster*>(GetPointId(n));
185   printf("\nDetector             : %d\n", c->GetDetector());
186   printf("Charge               : %f\n", c->GetQ());
187   printf("Sum S                : %4.0f\n", c->GetSumS());
188   printf("Time bin             : %d\n", c->GetLocalTimeBin());
189   printf("Signals              : ");
190   Short_t *cSignals = c->GetSignals();
191   for(Int_t ipad=0; ipad<7; ipad++) printf("%d ", cSignals[ipad]); printf("\n");
192   printf("Central pad          : %d\n", c->GetPadCol());
193   printf("MC track labels      : ");
194   for(Int_t itrk=0; itrk<3; itrk++) printf("%d ", c->GetLabel(itrk)); printf("\n");
195   // Bool_t     AliCluster::GetGlobalCov(Float_t* cov) const
196   // Bool_t     AliCluster::GetGlobalXYZ(Float_t* xyz) const
197   // Float_t    AliCluster::GetSigmaY2() const
198   // Float_t    AliCluster::GetSigmaYZ() const
199   // Float_t    AliCluster::GetSigmaZ2() const
200 }
201
202 ///////////////////////////////////////////////////////////
203 /////////////   AliEveTRDHitsEditor         /////////////////////
204 ///////////////////////////////////////////////////////////
205 AliEveTRDHitsEditor::AliEveTRDHitsEditor(const TGWindow* p, Int_t width, Int_t height,
206                                          UInt_t options, Pixel_t back) :
207   TGedFrame(p, width, height, options, back),
208   fM(0)
209 {
210   MakeTitle("TRD Hits");
211
212 }
213
214 AliEveTRDHitsEditor::~AliEveTRDHitsEditor()
215 {}
216
217 void AliEveTRDHitsEditor::SetModel(TObject* obj)
218 {
219   fM = dynamic_cast<AliEveTRDHits*>(obj);
220
221   //    Float_t x, y, z;
222   //    for(int ihit=0; ihit<fM->GetN(); ihit++){
223   //            fM->GetPoint(ihit, x, y, z);
224   //            printf("%3d : x=%6.3f y=%6.3f z=%6.3f\n", ihit, x, y, z);
225   //    }
226 }
227
228 ///////////////////////////////////////////////////////////
229 /////////////   AliEveTRDDigitsEditor /////////////////////
230 ///////////////////////////////////////////////////////////
231 AliEveTRDDigitsEditor::AliEveTRDDigitsEditor(const TGWindow* p, Int_t width, Int_t height,
232                                              UInt_t options, Pixel_t back) :
233   TGedFrame(p, width, height, options, back),
234   fM(0)
235 {
236   MakeTitle("TRD Digits");
237
238 }
239
240 AliEveTRDDigitsEditor::~AliEveTRDDigitsEditor()
241 {}
242
243 void AliEveTRDDigitsEditor::SetModel(TObject* obj)
244 {
245   fM = dynamic_cast<AliEveTRDDigits*>(obj);
246   fM->fParent->SpawnEditor();
247
248   //    printf("Chamber %d", fM->fParent->GetID());
249   //    for (Int_t  row = 0;  row <  fM->fParent->GetRowMax();  row++)
250   //            for (Int_t  col = 0;  col <  fM->fParent->GetColMax();  col++)
251   //                    for (Int_t time = 0; time < fM->fParent->GetTimeMax(); time++) {
252   //                            printf("\tA(%d %d %d) = %d\n", row, col, time, fM->fData.GetDataUnchecked(row, col, time));
253   //                    }
254 }