]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWGPP/TRD/info/AliTRDchmbInfo.cxx
Fix coverity issues
[u/mrichter/AliRoot.git] / PWGPP / TRD / info / AliTRDchmbInfo.cxx
1 ////////////////////////////////////////////////////////////////////////////
2 //                                                                        //
3 //  Chamber Info Incapsulation                                             //
4 //                                                                        //
5 //  Authors:                                                              //
6 //    Alexandru Bercuci <A.Bercuci@gsi.de>                                //
7 //                                                                        //
8 ////////////////////////////////////////////////////////////////////////////
9
10
11
12 #include "TMath.h"
13 #include "TBox.h"
14 #include "TLatex.h"
15
16 #include "AliLog.h"
17 #include "AliTRDchmbInfo.h"
18 #include "AliTRDgeometry.h"
19
20 ClassImp(AliTRDchmbInfo)
21 //____________________________________________
22 AliTRDchmbInfo::AliTRDchmbInfo()
23   :TNamed()
24   ,fDet(-1)
25   ,fStatus(0)
26   ,fBox(NULL)
27   ,fShade(NULL)
28   ,fLabel(NULL)
29 {
30 //  Constructor. Reset all fields.
31   memset(fPosition, 0, 4*sizeof(Double_t));
32 }
33
34
35 //____________________________________________
36 AliTRDchmbInfo::AliTRDchmbInfo(Int_t det, Int_t stat, Double_t p[4])
37   :TNamed(Form("D%03d", det), "")
38   ,fDet(det)
39   ,fStatus(stat)
40   ,fBox(NULL)
41   ,fShade(NULL)
42   ,fLabel(NULL)
43 {
44 //  Constructor. Set position fields.
45   SetPosition(p);
46 }
47
48 //____________________________________________
49 AliTRDchmbInfo::~AliTRDchmbInfo()
50 {
51 //  Destructor. 
52   if(fLabel) delete fLabel;
53   //if(fShade) delete fShade;
54   if(fBox) delete fBox;
55 }
56
57 //____________________________________________
58 void AliTRDchmbInfo::Print(Option_t */*o*/) const
59 {
60 //   Dump formated chamber info
61
62   printf("  DET[%03d] Status[%d]\n", fDet, fStatus);
63   printf("  eta[%f %f] phi[%f %f]\n", fPosition[0], fPosition[2], fPosition[1], fPosition[3]);
64 }
65
66 //____________________________________________
67 void AliTRDchmbInfo::SetDetector(Int_t det)
68 {
69 // register detector no.
70   fDet = det;
71   SetName(Form("D%03d", det));
72 }
73
74 //____________________________________________
75 void AliTRDchmbInfo::Draw(Option_t *opt)
76 {
77 // Set style parameters according to chamber status
78 // Options are 
79 //   p : pad number on x axis [default eta]
80 //   s : draw sector number on middle of stack 2 [default detector number] 
81   
82   Int_t style[] = {0, 3003, 3008};
83   if(!fBox) fBox = new TBox();
84   fBox->SetLineColor(kBlack);fBox->SetFillColor(kWhite);fBox->SetFillStyle(style[0]);
85   Int_t stk(AliTRDgeometry::GetStack(fDet));
86   Float_t xmin(0.), xmax(0.);
87   if(strchr(opt, 'p')){
88     xmin=-0.6+16*(4-stk)-(stk<2?4:0); xmax=xmin+(stk==2?12:16)-0.2;
89   } else {
90     xmin=fPosition[0]; xmax=fPosition[2];
91   }
92   if(strchr(opt, 's')){
93     if(stk==2){
94       if(!fLabel) fLabel = new TLatex(0.5*(fPosition[0]+fPosition[2]), 0.5*(fPosition[1]+fPosition[3]), Form("%02d", AliTRDgeometry::GetSector(fDet)));
95     }
96   } else {
97     if(!fLabel) fLabel = new TLatex(0.5*(fPosition[0]+fPosition[2]), 0.5*(fPosition[1]+fPosition[3]), Form("%03d", fDet));
98   }
99   if(fLabel){fLabel->SetTextAlign(22);fLabel->SetTextColor(kBlack); fLabel->SetTextFont(32);fLabel->SetTextSize(0.03);}
100
101   AliDebug(2, Form("D[%03d] 0[%+4.1f %+4.1f] 1[%+4.1f %+4.1f] opt[%d]", fDet, xmin, fPosition[1], xmax, fPosition[3], fStatus));
102   fBox->SetX1(xmin); fBox->SetX2(xmax); fBox->SetY1(fPosition[1]); fBox->SetY2(fPosition[3]);
103   if(fStatus==1){
104     fBox->SetFillStyle(style[1]);fBox->SetFillColor(kBlack);
105   } else {
106     if(fStatus==2){
107       fShade = fBox->DrawBox(xmin, fPosition[1], xmax, 0.5*(fPosition[3]+fPosition[1]));
108       fShade->SetFillStyle(style[2]);fShade->SetFillColor(kGreen);
109     } else if(fStatus==3){
110       fShade = fBox->DrawBox(xmin, 0.5*(fPosition[3]+fPosition[1]), xmax, fPosition[3]);
111       fShade->SetFillStyle(style[2]);fShade->SetFillColor(kRed);
112     } else if(fStatus!=0){
113       AliError(Form("Wrong chmb. status[%d] for det[%03d]", fStatus, fDet));
114       return;
115     }
116   }
117   fBox->Draw();
118   if(fLabel) fLabel->Draw();
119 }