]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TRD/TRDbase/AliTRDCalPadStatus.cxx
TENDER becomes Tender, removing .so
[u/mrichter/AliRoot.git] / TRD / TRDbase / AliTRDCalPadStatus.cxx
1 /**************************************************************************
2  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3  *                                                                        *
4  * Author: The ALICE Off-line Project.                                    *
5  * Contributors are mentioned in the code where appropriate.              *
6  *                                                                        *
7  * Permission to use, copy, modify and distribute this software and its   *
8  * documentation strictly for non-commercial purposes is hereby granted   *
9  * without fee, provided that the above copyright notice appears in all   *
10  * copies and that both the copyright notice and this permission notice   *
11  * appear in the supporting documentation. The authors make no claims     *
12  * about the suitability of this software for any purpose. It is          *
13  * provided "as is" without express or implied warranty.                  *
14  **************************************************************************/
15
16 /* $Id$ */
17
18 ///////////////////////////////////////////////////////////////////////////////
19 //                                                                           //
20 //  TRD calibration class for the single pad status                          //
21 //                                                                           //
22 ///////////////////////////////////////////////////////////////////////////////
23
24 #include <TStyle.h>
25 #include <TCanvas.h>
26 #include <TH1F.h>
27 #include <TH2F.h>
28
29 #include "AliTRDCalPadStatus.h"
30 #include "AliTRDgeometry.h"
31 #include "AliTRDpadPlane.h"
32 #include "AliTRDCalSingleChamberStatus.h"  // test
33
34 ClassImp(AliTRDCalPadStatus)
35
36 //_____________________________________________________________________________
37 AliTRDCalPadStatus::AliTRDCalPadStatus()
38   :TNamed()
39 {
40   //
41   // AliTRDCalPadStatus default constructor
42   //
43
44   for (Int_t idet = 0; idet < kNdet; idet++) {
45     fROC[idet] = 0;
46   }
47
48 }
49
50 //_____________________________________________________________________________
51 AliTRDCalPadStatus::AliTRDCalPadStatus(const Text_t *name, const Text_t *title)
52   :TNamed(name,title)
53 {
54   //
55   // AliTRDCalPadStatus constructor
56   //
57
58   for (Int_t isec = 0; isec < kNsect; isec++) {
59     for (Int_t ipla = 0; ipla < kNplan; ipla++) {
60       for (Int_t icha = 0; icha < kNcham; icha++) {
61         Int_t idet = AliTRDgeometry::GetDetector(ipla,icha,isec);
62         fROC[idet] = new AliTRDCalSingleChamberStatus(ipla,icha,144);
63       }
64     }
65   }
66
67 }
68
69 //_____________________________________________________________________________
70 AliTRDCalPadStatus::AliTRDCalPadStatus(const AliTRDCalPadStatus &c)
71   :TNamed(c)
72 {
73   //
74   // AliTRDCalPadStatus copy constructor
75   //
76
77   ((AliTRDCalPadStatus &) c).Copy(*this);
78
79 }
80
81 //_____________________________________________________________________________
82 AliTRDCalPadStatus::~AliTRDCalPadStatus()
83 {
84   //
85   // AliTRDCalPadStatus destructor
86   //
87
88   for (Int_t idet = 0; idet < kNdet; idet++) {
89     if (fROC[idet]) {
90       delete fROC[idet];
91       fROC[idet] = 0;
92     }
93   }
94
95 }
96
97 //_____________________________________________________________________________
98 AliTRDCalPadStatus &AliTRDCalPadStatus::operator=(const AliTRDCalPadStatus &c)
99 {
100   //
101   // Assignment operator
102   //
103
104   if (this != &c) ((AliTRDCalPadStatus &) c).Copy(*this);
105   return *this;
106
107 }
108
109 //_____________________________________________________________________________
110 void AliTRDCalPadStatus::Copy(TObject &c) const
111 {
112   //
113   // Copy function
114   //
115
116   for (Int_t idet = 0; idet < kNdet; idet++) {
117     if (fROC[idet]) {
118       fROC[idet]->Copy(*((AliTRDCalPadStatus &) c).fROC[idet]);
119     }
120   }
121
122   TObject::Copy(c);
123
124 }
125
126 //_____________________________________________________________________________
127 Bool_t AliTRDCalPadStatus::CheckStatus(Int_t d, Int_t col, Int_t row, Int_t bitMask) const
128 {
129   //
130   // Checks the pad status
131   //
132
133   AliTRDCalSingleChamberStatus *roc = GetCalROC(d);
134   if (!roc) {
135     return kFALSE;
136   }
137   else {
138     return (roc->GetStatus(col, row) & bitMask) ? kTRUE : kFALSE;
139   }
140
141 }
142
143 //_____________________________________________________________________________
144 AliTRDCalSingleChamberStatus* AliTRDCalPadStatus::GetCalROC(Int_t p, Int_t c, Int_t s) const
145
146   //
147   // Returns the readout chamber of this pad
148   //
149
150   return fROC[AliTRDgeometry::GetDetector(p,c,s)];   
151
152 }
153
154 //_____________________________________________________________________________
155 TH1F *AliTRDCalPadStatus::MakeHisto1D()
156 {
157   //
158   // Make 1D histo
159   //
160
161   char  name[1000];
162   snprintf(name,1000,"%s Pad 1D",GetTitle());
163   TH1F * his = new TH1F(name,name,6, -0.5,5.5);
164   his->GetXaxis()->SetBinLabel(1,"Good");
165   his->GetXaxis()->SetBinLabel(2,"Masked");
166   his->GetXaxis()->SetBinLabel(3,"PadBridgedLeft");
167   his->GetXaxis()->SetBinLabel(4,"PadBridgedRight");
168   his->GetXaxis()->SetBinLabel(5,"ReadSecond");
169   his->GetXaxis()->SetBinLabel(6,"NotConnected");
170
171   for (Int_t idet = 0; idet < kNdet; idet++) 
172     {
173       if (fROC[idet])
174         {
175           for (Int_t ichannel=0; ichannel<fROC[idet]->GetNchannels(); ichannel++)
176             {
177               Int_t status = (Int_t) fROC[idet]->GetStatus(ichannel);
178               if(status==2)  status= 1;
179               if(status==4)  status= 2;
180               if(status==8)  status= 3;
181               if(status==16) status= 4;
182               if(status==32) status= 5;
183               his->Fill(status);
184             }
185         }
186     }
187
188   return his;
189
190 }
191
192 //_____________________________________________________________________________
193 TH2F *AliTRDCalPadStatus::MakeHisto2DSmPl(Int_t sm, Int_t pl)
194 {
195   //
196   // Make 2D graph
197   //
198
199   gStyle->SetPalette(1);
200   AliTRDgeometry *trdGeo = new AliTRDgeometry();
201   AliTRDpadPlane *padPlane0 = trdGeo->GetPadPlane(pl,0);
202   Double_t row0    = padPlane0->GetRow0();
203   Double_t col0    = padPlane0->GetCol0();
204
205   char  name[1000];
206   snprintf(name,1000,"%s Pad 2D sm %d pl %d",GetTitle(),sm,pl);
207   TH2F * his = new TH2F( name, name, 88,-TMath::Abs(row0),TMath::Abs(row0)
208                                    ,148,-TMath::Abs(col0),TMath::Abs(col0));
209
210   // Where we begin
211   Int_t offsetsmpl = 30*sm+pl;
212
213   for (Int_t k = 0; k < kNcham; k++){
214     Int_t det = offsetsmpl+k*6;
215     if (fROC[det]){
216       AliTRDCalSingleChamberStatus * calRoc = fROC[det];
217       for (Int_t icol=0; icol<calRoc->GetNcols(); icol++){
218         for (Int_t irow=0; irow<calRoc->GetNrows(); irow++){
219           Int_t binz     = 0;
220           Int_t kb       = kNcham-1-k;
221           Int_t krow     = calRoc->GetNrows()-1-irow;
222           Int_t kcol     = calRoc->GetNcols()-1-icol;
223           if(kb > 2) binz = 16*(kb-1)+12+krow+1+2*(kb+1);
224           else binz = 16*kb+krow+1+2*(kb+1); 
225           Int_t biny = kcol+1+2;
226           Float_t value = calRoc->GetStatus(icol,irow);
227           his->SetBinContent(binz,biny,value);
228         }
229       }
230       for(Int_t icol = 1; icol < 147; icol++){
231         for(Int_t l = 0; l < 2; l++){
232           Int_t binz     = 0;
233           Int_t kb       = kNcham-1-k;
234           if(kb > 2) binz = 16*(kb-1)+12+1+2*(kb+1)-(l+1);
235           else binz = 16*kb+1+2*(kb+1)-(l+1); 
236           his->SetBinContent(binz,icol,50.0);
237         }
238       }
239     }
240   }
241   for(Int_t icol = 1; icol < 147; icol++){
242     his->SetBinContent(88,icol,50.0);
243     his->SetBinContent(87,icol,50.0);
244   }
245   for(Int_t irow = 1; irow < 89; irow++){
246     his->SetBinContent(irow,1,50.0);
247     his->SetBinContent(irow,2,50.0);
248     his->SetBinContent(irow,147,50.0);
249     his->SetBinContent(irow,148,50.0);
250   }
251
252   his->SetXTitle("z (cm)");
253   his->SetYTitle("y (cm)");
254   his->SetMaximum(50);
255   his->SetMinimum(0.0);
256   his->SetStats(0);
257
258   return his;
259
260 }
261
262 //_____________________________________________________________________________
263 void AliTRDCalPadStatus::PlotHistos2DSm(Int_t sm, const Char_t *name)
264 {
265   //
266   // Make 2D graph
267   //
268
269   gStyle->SetPalette(1);
270   TCanvas *c1 = new TCanvas(name,name,50,50,600,800);
271   c1->Divide(3,2);
272   c1->cd(1);
273   MakeHisto2DSmPl(sm,0)->Draw("colz");
274   c1->cd(2);
275   MakeHisto2DSmPl(sm,1)->Draw("colz");
276   c1->cd(3);
277   MakeHisto2DSmPl(sm,2)->Draw("colz");
278   c1->cd(4);
279   MakeHisto2DSmPl(sm,3)->Draw("colz");
280   c1->cd(5);
281   MakeHisto2DSmPl(sm,4)->Draw("colz");
282   c1->cd(6);
283   MakeHisto2DSmPl(sm,5)->Draw("colz");
284
285 }