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