The AliDCSSensor classes were recently upgraded to include start and end time entries...
[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    
76
77 TClonesArray * AliTPCSensorPressure::ReadList(const char *fname) {
78   //
79   // read values from ascii file
80   //
81   TTree * tree = new TTree("asci","asci");
82   tree->ReadFile(fname,"");
83   
84   Int_t nentries = tree->GetEntries();
85   Int_t sensor=0;
86   Int_t sector=0;
87   char  type[100];
88   char  side[100];
89   Int_t num=0;
90   Int_t echa=0;
91   //Double_t x=0;
92   //Double_t y=0;
93   //Double_t z=0;
94   //String_t namedtp[100];
95
96   tree->SetBranchAddress("Sensor",&sensor);
97   tree->SetBranchAddress("Type",&type);
98   tree->SetBranchAddress("Side",&side);
99   tree->SetBranchAddress("Sec",&sector);
100   tree->SetBranchAddress("Num",&num);
101   tree->SetBranchAddress("ECha",&echa);
102   //tree->SetBranchAddress("X",&x);
103   //tree->SetBranchAddress("Y",&y);
104   //tree->SetBranchAddress("Z",&z);
105
106   // firstSensor = (Int_t)tree->GetMinimum("ECha");
107   // lastSensor = (Int_t)tree->GetMaximum("ECha");
108
109   TClonesArray * array = new TClonesArray("AliTPCSensorPressure",nentries);
110
111   for (Int_t isensor=0; isensor<nentries; isensor++){
112     AliTPCSensorPressure * temp = new ((*array)[isensor])AliTPCSensorPressure;
113     tree->GetEntry(isensor);
114     temp->SetId(sensor);
115     temp->SetIdDCS(echa);
116     if (side[0]=='C') temp->SetSide(1);
117     temp->SetSector(sector);
118     temp->SetNum(num);
119     //temp->SetType(type);
120     if (bcmp(type,"ROC",3)==0) temp->SetType(0);
121     if (bcmp(type,"OFC",3)==0) temp->SetType(1);
122     if (bcmp(type,"IFC",3)==0) temp->SetType(2);
123     if (bcmp(type,"TPC",3)==0) temp->SetType(3); 
124     if (bcmp(type,"ELM",3)==0) temp->SetType(4);
125     if (bcmp(type,"TS",2)==0)  temp->SetType(5);
126     if (bcmp(type,"COOL",3)==0)temp->SetType(6);
127
128     temp->SetX(280.);
129     temp->SetY(0.);
130     temp->SetZ(0.);
131
132     //temp->SetX(x);
133
134 /*     if (temp->GetType()==0){
135 //      temp->SetX(TMath::Cos((2*sector+1)*0.1745)*(83+(num+1)*30));
136       if (side[0]=='C') {
137           temp->SetX(kCSideX[sector][num]);
138       } else {
139           temp->SetX(kASideX[sector][num]);
140       }      
141     }
142     if ((temp->GetType()==1) || (temp->GetType()==4)){
143       temp->SetX(TMath::Cos((2*sector+1)*0.1745)*278);
144     }
145     if ((temp->GetType()==2) || (temp->GetType()==3)){
146       temp->SetX(TMath::Cos((2*sector+1)*0.1745)*kIFCrad[num]);
147     }
148     if ((temp->GetType()==5) || (temp->GetType()==6)){
149       temp->SetX(0);
150     }
151     
152     //temp->SetY(y);
153     if (temp->GetType()==0){
154 //        temp->SetY(TMath::Sin((2*sector+1)*0.1745)*(83+(num+1)*30));
155       if (side[0]=='C') {
156           temp->SetY(kCSideY[sector][num]);
157       } else {
158           temp->SetY(kASideY[sector][num]);
159       }      
160     }
161     if ((temp->GetType()==1) || (temp->GetType()==4)){
162       temp->SetY(TMath::Sin((2*sector+1)*0.1745)*278);
163     }
164     if ((temp->GetType()==2) || (temp->GetType()==3)){
165       temp->SetY(TMath::Sin((2*sector+1)*0.1745)*kIFCrad[num]);
166     }
167     if ((temp->GetType()==5) || (temp->GetType()==6)){
168       temp->SetY(0);
169     }
170     //temp->SetZ(z);
171     if ((temp->GetType()==0 || temp->GetType()==3 || temp->GetType()==4 || temp->GetType()==5 || temp->GetType()==6) && temp->GetSide()==0) {
172       temp->SetZ(250);
173       }
174     if ((temp->GetType()==0 || temp->GetType()==3 || temp->GetType()==4 || temp->GetType()==5 || temp->GetType()==6) && temp->GetSide()==1){
175       temp->SetZ(-250);
176       }
177     if((temp->GetType()==1 || temp->GetType()==2) && (num==0)) {
178       temp->SetZ(240);
179       }
180     if((temp->GetType()==1 || temp->GetType()==2) && (num==1)) {
181       temp->SetZ(168.4);
182       }
183     if((temp->GetType()==1 || temp->GetType()==2) && (num==2)) {
184       temp->SetZ(51);
185       }
186     if((temp->GetType()==1 || temp->GetType()==2) && (num==3)) {
187       temp->SetZ(-51);
188       }
189     if((temp->GetType()==1 || temp->GetType()==2) && (num==4)) {
190       temp->SetZ(-168.4);
191       }
192     if((temp->GetType()==1 || temp->GetType()==2) && (num==5)) {
193       temp->SetZ(-240);
194       }
195
196  */
197    }
198    delete tree;  
199   return array;
200 }