]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TPC/AliTPCSensorTemp.cxx
b265a88ab394445bcc828a22a11e14702732f6e3
[u/mrichter/AliRoot.git] / TPC / AliTPCSensorTemp.cxx
1 /**************************************************************************
2  * Copyright(c) 2006-07, 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
17 ////////////////////////////////////////////////////////////////////////////////
18 //                                                                            //
19 // Class describing TPC temperature sensors (including pointers to graphs/fits//
20 // Authors: Marian Ivanov, Haavard Helstrup and Martin Siska                  //
21 //                                                                            //
22 ////////////////////////////////////////////////////////////////////////////////
23
24 // Running instructions:
25 /*
26   TClonesArray * arr = AliTPCSensorTemp::ReadList("TempSensor.txt");
27   TFile f("TempSensors.root","RECREATE");
28   TTree * tree = new TTree("TempSensor", "TempSensor");
29   tree->Branch("Temp",&arr);
30   tree->Fill();
31   tree->Write();
32   
33  */
34 //
35
36 #include <strings.h>
37 #include "AliTPCSensorTemp.h"
38 ClassImp(AliTPCSensorTemp)
39
40 const char kAmandaString[] = "tpc_temp:PT_%d.Temperature";
41
42 const Float_t kASideX[18][5]={
43         { 99.56,  117.59,  160.82,  186.92,  213.11},
44         { 87.56,  103.4,   141.42,  164.37,  187.41},
45         { 64.99,   76.75,  104.97,  122.00,  139.1},
46         { 34.58,   40.84,   55.85,   64.92,  74.01},
47         {    0,    0,    0,    0,    0},
48         {-34.58,  -40.84,  -55.85,  -64.92,  -74.01},
49         {-64.99,  -76.75, -104.97, -122.0,  -139.1},
50         {-87.56, -103.4,  -141.42, -164.37, -187.41},
51         {-99.56, -117.59, -160.82, -186.92, -213.11},
52         {-99.56, -117.59, -160.82, -186.92, -213.11},
53         {-87.56, -103.4,  -141.42, -164.37, -187.41},
54         {-64.99,  -76.75, -104.97, -122,    -139.1},
55         {-34.58,  -40.84,  -55.85,  -64.92,  -74.01},
56         {    0,    0,    0,   0,   0},
57         { 34.58,   40.84,   55.85,   64.92,   74.01},
58         { 64.99,   76.75,  104.97,  122,     139.1},
59         { 87.56,  103.4,   141.42,  164.37,  187.41},
60         { 99.56,  117.59,  160.82,  186.92,  213.11}};
61         
62 const Float_t kASideY[18][5]={
63         { 17.56,   20.73,   28.36,   32.96,   37.58},
64         { 50.55,   59.7,    81.65,   94.9,   108.2},
65         { 77.45,   91.47,  125.1,   145.4,   165.77},
66         { 95.0,  112.3,    153.45,  178.35,  203.35},
67         {101.1,  119.4,  163.3,  189.8,  216.4},
68         { 95.0,  112.2,  153.45,  178.35,  203.35},
69         { 77.45,   91.47,  125.1,  145.4,  165.77},
70         { 50.55,   59.7,   81.65,   94.9,  108.2},
71         { 17.56,   20.73,  28.36,   32.96,  37.58},
72         {-17.56,  -20.73, -28.36,  -32.96, -37.58},
73         {-50.55,  -59.7,  -81.65,  -94.9, -108.2},
74         {-77.45,  -91.47, -125.1, -145.4, -165.77},
75         {-95.0, -112.2, -153.45, -178.35, -203.35},
76        {-101.1, -119.4, -163.3,  -189.8, -216.4},
77         {-95.0, -112.2, -153.45, -178.35, -203.35},
78         {-77.45,  -91.47, -125.1, -145.4, -165.77},
79         {-50.55,  -59.7,  -81.65,  -94.9, -108.2},
80         {-17.56,  -20.73, -28.36,  -32.96, -37.58}};  
81         
82 const Float_t kCSideX[18][5]={
83         { 99.56,  117.59,  160.82,  186.92,  213.11},
84         { 87.56,  103.4,   141.42,  164.37,  187.41},
85         { 64.99,   76.75,  104.97,  122,     139.1},
86         { 34.58,   40.84,   55.85,   64.92,   74.01},
87         {    0,    0,    0,   0,   0},
88         {-34.58,  -40.84,  -55.85,  -64.92,  -74.01},
89         {-64.99,  -76.75, -104.97, -122,    -139.1},
90         {-87.56, -103.4,  -141.42, -164.37, -187.41},
91         {-99.56, -117.59, -160.82, -186.92, -213.11},
92         {-99.56, -117.59, -160.82, -186.92, -213.11},
93         {-87.56, -103.4,  -141.42, -164.37, -187.41},
94         {-64.99,  -76.75, -104.97, -122,    -139.1},
95         {-34.58,  -40.84,  -55.85,  -64.92,  -74.01},
96         {    0,    0,    0,    0,    0},
97         { 34.58,   40.84,   55.85,   64.92,   74.01},
98         { 64.99,   76.75,  104.97,  122,     139.1},
99         { 87.56,  103.4,   141.42,  164.37,  187.41},
100         { 99.56,  117.59,  160.82,  186.92,  213.11}};
101
102 const Float_t kCSideY[18][5]={
103         { 17.56,   20.73,   28.36,   32.96,   37.58},
104         { 50.55,   59.7,    81.65,   94.9,   108.2},
105         { 77.45,   91.47,  125.1,   145.4,   165.77},
106         { 95.0,   112.2,   153.54,  178.35,  203.35},
107         {101.1,  119.4,  163.3,  189.8,  216.4},
108         { 95.0,   112.2,   153.45,  178.35,  203.35},
109         { 77.45,   91.47,  125.1,   145.4,   165.77},
110         { 50.55,   59.7,    81.65,   94.9,   108.2},
111         { 17.56,   20.73,   28.36,   32.96,   37.58},
112         {-17.56,  -20.73,  -28.36,  -32.96,  -37.58},
113         {-50.55,  -59.7,   -81.56,  -94.9,  -108.2},
114         {-77.45,  -91.47, -125.1,  -145.4,  -165.77},
115         {-95.0,  -112.2,  -153.45, -178.35, -203.35},
116        {-101.1, -119.4, -163.3, -189.8, -216.4},
117         {-95.0, -112.2, -153.45, -178.35, -203.35},
118         {-77.45,  -91.47, -125.1, -145.4, -165.77},
119         {-50.55,  -59.7,  -81.65,  -94.9, -108.2},
120         {-17.56,  -20.73, -28.36,  -32.96,  -37.58}};  
121
122 const Float_t kIFCrad[5] = {67.2, 64.4, 60.7, 64.4, 67.2};
123
124 const Float_t kTSrad[4] =  {67.2, 61.5, 67.2, 61.5}; 
125 const Float_t kTSz[4] =  {240.0, 90.0, 240.0, 90.0}; 
126
127 //______________________________________________________________________________________________
128
129 AliTPCSensorTemp::AliTPCSensorTemp(): AliDCSSensor(),
130   fType(0),
131   fSide(0),
132   fSector(0),
133   fNum(0)
134 {
135   //
136   //  Standard constructor
137   //
138 }
139 //______________________________________________________________________________________________
140
141 AliTPCSensorTemp::AliTPCSensorTemp(const AliTPCSensorTemp& source) :
142   AliDCSSensor(source),
143    fType(source.fType),
144    fSide(source.fSide),
145    fSector(source.fSector),
146    fNum(source.fNum)
147
148 //
149 //  Copy constructor
150 //
151 { }
152 //______________________________________________________________________________________________
153
154 AliTPCSensorTemp& AliTPCSensorTemp::operator=(const AliTPCSensorTemp& source){
155 //
156 // assignment operator
157 //
158   if (&source == this) return *this;
159   new (this) AliTPCSensorTemp(source);
160   
161   return *this;  
162 }
163 //______________________________________________________________________________________________
164
165 TClonesArray * AliTPCSensorTemp::ReadList(const char *fname) {
166   //
167   // read values from ascii file
168   //
169   TTree * tree = new TTree("asci","asci");
170   tree->ReadFile(fname,"");
171   TClonesArray *arr = ReadTree(tree);
172   delete tree;
173   return arr;
174 }
175      
176 //______________________________________________________________________________________________
177
178 TClonesArray * AliTPCSensorTemp::ReadTree(TTree *tree) {
179   
180   Int_t nentries = tree->GetEntries();
181   Int_t sensor=0;
182   Int_t sector=0;
183   char  type[100];
184   char  side[100];
185   Int_t num=0;
186   Int_t echa=0;
187   //Double_t x=0;
188   //Double_t y=0;
189   //Double_t z=0;
190   //String_t namedtp[100];
191
192   tree->SetBranchAddress("Sensor",&sensor);
193   tree->SetBranchAddress("Type",&type);
194   tree->SetBranchAddress("Side",&side);
195   tree->SetBranchAddress("Sec",&sector);
196   tree->SetBranchAddress("Num",&num);
197   tree->SetBranchAddress("ECha",&echa);
198   //tree->SetBranchAddress("X",&x);
199   //tree->SetBranchAddress("Y",&y);
200   //tree->SetBranchAddress("Z",&z);
201
202   // firstSensor = (Int_t)tree->GetMinimum("ECha");
203   // lastSensor = (Int_t)tree->GetMaximum("ECha");
204
205   TClonesArray * array = new TClonesArray("AliTPCSensorTemp",nentries);
206
207   for (Int_t isensor=0; isensor<nentries; isensor++){
208     AliTPCSensorTemp * temp = new ((*array)[isensor])AliTPCSensorTemp;
209     tree->GetEntry(isensor);
210     temp->SetId(sensor);
211     temp->SetIdDCS(echa);
212     TString stringID = Form (kAmandaString,echa);
213     temp->SetStringID(stringID);
214     if (side[0]=='C') temp->SetSide(1);
215     temp->SetSector(sector);
216     temp->SetNum(num);
217     //temp->SetType(type);
218     if (bcmp(type,"ROC",3)==0) temp->SetType(0);
219     if (bcmp(type,"OFC",3)==0) temp->SetType(1);
220     if (bcmp(type,"IFC",3)==0) temp->SetType(2);
221     if (bcmp(type,"TPC",3)==0) temp->SetType(3); 
222     if (bcmp(type,"ELM",3)==0) temp->SetType(4);
223     if (bcmp(type,"TS",2)==0)  temp->SetType(5);
224     if (bcmp(type,"COOL",3)==0)temp->SetType(6);
225     //temp->SetX(x);
226
227     if (temp->GetType()==0){
228 //      temp->SetX(TMath::Cos((2*sector+1)*0.1745)*(83+(num+1)*30));
229       if (side[0]=='C') {
230           temp->SetX(kCSideX[sector][num]);
231       } else {
232           temp->SetX(kASideX[sector][num]);
233       }      
234     }
235     if ((temp->GetType()==1) || (temp->GetType()==4)){
236       temp->SetX(TMath::Cos((2*sector+1)*0.1745)*278);
237     }
238     if (temp->GetType()==2) {
239       temp->SetX(TMath::Cos((2*sector+1)*0.1745)*60.7);
240     }
241     if (temp->GetType()==3) {
242       if (num==0) {
243         temp->SetX(TMath::Cos((2*sector+1)*0.1745)*87.5);
244       } else {
245         temp->SetX(TMath::Cos((2*sector+1)*0.1745)*241.8);
246       }
247     } 
248     if (temp->GetType()==5){
249       temp->SetX(TMath::Cos(sector*0.524+(num+1)*0.131)*kTSrad[num]);
250     }
251     if (temp->GetType()==6){
252       temp->SetX(0);
253     }
254     
255     //temp->SetY(y);
256     if (temp->GetType()==0){
257 //        temp->SetY(TMath::Sin((2*sector+1)*0.1745)*(83+(num+1)*30));
258       if (side[0]=='C') {
259           temp->SetY(kCSideY[sector][num]);
260       } else {
261           temp->SetY(kASideY[sector][num]);
262       }      
263     }
264     if ((temp->GetType()==1) || (temp->GetType()==4)){
265       temp->SetY(TMath::Sin((2*sector+1)*0.1745)*278);
266     }
267     if (temp->GetType()==2){
268       temp->SetY(TMath::Sin((2*sector+1)*0.1745)*60.7);
269     }
270     if (temp->GetType()==3) {
271       if (num==0) {
272         temp->SetY(TMath::Sin((2*sector+1)*0.1745)*87.5);
273       } else {
274         temp->SetY(TMath::Sin((2*sector+1)*0.1745)*241.8);
275       }
276     } 
277
278     if (temp->GetType()==5){
279       temp->SetY(TMath::Sin(sector*0.524+(num+1)*0.131)*kTSrad[num]);
280     }
281
282     if (temp->GetType()==6){
283       temp->SetY(0);
284     }
285
286     //temp->SetZ(z);
287     if ((temp->GetType()==0 || 
288          temp->GetType()==4 || temp->GetType()==6) && 
289          temp->GetSide()==0) {
290              temp->SetZ(250);
291       }
292     if ((temp->GetType()==0 || temp->GetType()==4 ||
293          temp->GetType()==6) && temp->GetSide()==1){
294              temp->SetZ(-250);
295       }
296     if(temp->GetType()==2 && temp->GetSide()==0) {
297          temp->SetZ(52.4);
298       }
299     if(temp->GetType()==2 && temp->GetSide()==1) {
300          temp->SetZ(-52.4);
301       }
302
303     if(temp->GetType()==3 && temp->GetSide()==0) {
304          temp->SetZ(247);
305       }
306     if(temp->GetType()==3 && temp->GetSide()==1) {
307          temp->SetZ(-247);
308       }
309
310     if((temp->GetType()==1 ) && (num==0)) {
311       temp->SetZ(240);
312       }
313     if((temp->GetType()==1 ) && (num==1)) {
314       temp->SetZ(168.4);
315       }
316     if((temp->GetType()==1 ) && (num==2)) {
317       temp->SetZ(51);
318       }
319     if((temp->GetType()==1 ) && (num==3)) {
320       temp->SetZ(-51);
321       }
322     if((temp->GetType()==1 ) && (num==4)) {
323       temp->SetZ(-168.4);
324       }
325     if((temp->GetType()==1 ) && (num==5)) {
326       temp->SetZ(-240);
327       }
328
329     if(temp->GetType()==5 && temp->GetSide()==0) {
330          temp->SetZ(kTSz[num]);
331       }
332     if(temp->GetType()==5 && temp->GetSide()==1) {
333          temp->SetZ(-kTSz[num]);
334       }
335
336
337   }
338   return array;
339 }