ae2f6bbbc43f1d3b495ce7277f6dbbe48ec31c2e
[u/mrichter/AliRoot.git] / TPC / AliTPCSensorPressure.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 pressure sensors (including pointers to graphs/fits   //
20 // Authors: Marian Ivanov and Haavard Helstrup                                //
21 //                                                                            //
22 ////////////////////////////////////////////////////////////////////////////////
23
24 // Running instructions:
25 /*
26   TClonesArray * arr = AliTPCSensorPressure::ReadList("PressureSensor.txt");
27   TFile f("PressureSensors.root","RECREATE");
28   TTree * tree = new TTree("PressureSensor", "PressureSensor");
29   tree->Branch("Pressure",&arr);
30   tree->Fill();
31   tree->Write();
32   
33  */
34 //
35
36
37 #include "AliTPCSensorPressure.h"
38 ClassImp(AliTPCSensorPressure)
39
40
41
42 AliTPCSensorPressure::AliTPCSensorPressure(): AliDCSSensor(),
43   fType(0),
44   fSide(0),
45   fSector(0),
46   fNum(0)
47 {
48   //
49   //  Standard constructor
50   //
51 }
52
53 AliTPCSensorPressure::AliTPCSensorPressure(const AliTPCSensorPressure& source) :
54   AliDCSSensor(source),
55    fType(source.fType),
56    fSide(source.fSide),
57    fSector(source.fSector),
58    fNum(source.fNum)
59
60 //
61 //  Copy constructor
62 //
63 { }
64
65 AliTPCSensorPressure& AliTPCSensorPressure::operator=(const AliTPCSensorPressure& source){
66 //
67 // assignment operator
68 //
69   if (&source == this) return *this;
70   new (this) AliTPCSensorPressure(source);
71   
72   return *this;  
73 }
74
75 TClonesArray * AliTPCSensorPressure::ReadList(const char *fname) {
76    
77    Int_t firstSensor, lastSensor;
78    return ReadListInd(fname,firstSensor,lastSensor);
79 }  
80
81 TClonesArray * AliTPCSensorPressure::ReadListInd(const char *fname, 
82                                           Int_t& firstSensor,
83                                           Int_t& lastSensor) {
84   //
85   // read values from ascii file
86   //
87   TTree * tree = new TTree("asci","asci");
88   tree->ReadFile(fname,"");
89   
90   Int_t nentries = tree->GetEntries();
91   Int_t sensor=0;
92   Int_t sector=0;
93   char  type[100];
94   char  side[100];
95   Int_t num=0;
96   Int_t echa=0;
97   //Double_t x=0;
98   //Double_t y=0;
99   //Double_t z=0;
100   //String_t namedtp[100];
101
102   tree->SetBranchAddress("Sensor",&sensor);
103   tree->SetBranchAddress("Type",&type);
104   tree->SetBranchAddress("Side",&side);
105   tree->SetBranchAddress("Sec",&sector);
106   tree->SetBranchAddress("Num",&num);
107   tree->SetBranchAddress("ECha",&echa);
108   //tree->SetBranchAddress("X",&x);
109   //tree->SetBranchAddress("Y",&y);
110   //tree->SetBranchAddress("Z",&z);
111
112   firstSensor = (Int_t)tree->GetMinimum("ECha");
113   lastSensor = (Int_t)tree->GetMaximum("ECha");
114
115   TClonesArray * array = new TClonesArray("AliTPCSensorPressure",nentries);
116
117   for (Int_t isensor=0; isensor<nentries; isensor++){
118     AliTPCSensorPressure * temp = new ((*array)[isensor])AliTPCSensorPressure;
119     tree->GetEntry(isensor);
120     temp->SetId(sensor);
121     temp->SetIdDCS(echa);
122     if (side[0]=='C') temp->SetSide(1);
123     temp->SetSector(sector);
124     temp->SetNum(num);
125     //temp->SetType(type);
126     if (bcmp(type,"ROC",3)==0) temp->SetType(0);
127     if (bcmp(type,"OFC",3)==0) temp->SetType(1);
128     if (bcmp(type,"IFC",3)==0) temp->SetType(2);
129     if (bcmp(type,"TPC",3)==0) temp->SetType(3); 
130     if (bcmp(type,"ELM",3)==0) temp->SetType(4);
131     if (bcmp(type,"TS",2)==0)  temp->SetType(5);
132     if (bcmp(type,"COOL",3)==0)temp->SetType(6);
133
134     temp->SetX(280.);
135     temp->SetY(0.);
136     temp->SetZ(0.);
137
138     //temp->SetX(x);
139
140 /*     if (temp->GetType()==0){
141 //      temp->SetX(TMath::Cos((2*sector+1)*0.1745)*(83+(num+1)*30));
142       if (side[0]=='C') {
143           temp->SetX(kCSideX[sector][num]);
144       } else {
145           temp->SetX(kASideX[sector][num]);
146       }      
147     }
148     if ((temp->GetType()==1) || (temp->GetType()==4)){
149       temp->SetX(TMath::Cos((2*sector+1)*0.1745)*278);
150     }
151     if ((temp->GetType()==2) || (temp->GetType()==3)){
152       temp->SetX(TMath::Cos((2*sector+1)*0.1745)*kIFCrad[num]);
153     }
154     if ((temp->GetType()==5) || (temp->GetType()==6)){
155       temp->SetX(0);
156     }
157     
158     //temp->SetY(y);
159     if (temp->GetType()==0){
160 //        temp->SetY(TMath::Sin((2*sector+1)*0.1745)*(83+(num+1)*30));
161       if (side[0]=='C') {
162           temp->SetY(kCSideY[sector][num]);
163       } else {
164           temp->SetY(kASideY[sector][num]);
165       }      
166     }
167     if ((temp->GetType()==1) || (temp->GetType()==4)){
168       temp->SetY(TMath::Sin((2*sector+1)*0.1745)*278);
169     }
170     if ((temp->GetType()==2) || (temp->GetType()==3)){
171       temp->SetY(TMath::Sin((2*sector+1)*0.1745)*kIFCrad[num]);
172     }
173     if ((temp->GetType()==5) || (temp->GetType()==6)){
174       temp->SetY(0);
175     }
176     //temp->SetZ(z);
177     if ((temp->GetType()==0 || temp->GetType()==3 || temp->GetType()==4 || temp->GetType()==5 || temp->GetType()==6) && temp->GetSide()==0) {
178       temp->SetZ(250);
179       }
180     if ((temp->GetType()==0 || temp->GetType()==3 || temp->GetType()==4 || temp->GetType()==5 || temp->GetType()==6) && temp->GetSide()==1){
181       temp->SetZ(-250);
182       }
183     if((temp->GetType()==1 || temp->GetType()==2) && (num==0)) {
184       temp->SetZ(240);
185       }
186     if((temp->GetType()==1 || temp->GetType()==2) && (num==1)) {
187       temp->SetZ(168.4);
188       }
189     if((temp->GetType()==1 || temp->GetType()==2) && (num==2)) {
190       temp->SetZ(51);
191       }
192     if((temp->GetType()==1 || temp->GetType()==2) && (num==3)) {
193       temp->SetZ(-51);
194       }
195     if((temp->GetType()==1 || temp->GetType()==2) && (num==4)) {
196       temp->SetZ(-168.4);
197       }
198     if((temp->GetType()==1 || temp->GetType()==2) && (num==5)) {
199       temp->SetZ(-240);
200       }
201
202  */
203    }
204    delete tree;  
205   return array;
206 }