Some of the coding violations corrected
[u/mrichter/AliRoot.git] / TPC / AliTPCSensorTempArray.cxx
CommitLineData
54472e4f 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
17///////////////////////////////////////////////////////////////////////////////
18// //
19// TPC calibration class for parameters which saved per pad //
20// Authors: Marian Ivanov and Haavard Helstrup //
21// //
22///////////////////////////////////////////////////////////////////////////////
23
24#include "AliTPCSensorTempArray.h"
3a887e1a 25#include "TLinearFitter.h"
26#include "TVectorD.h"
67a165ed 27#include "AliLog.h"
28
29
54472e4f 30
31ClassImp(AliTPCSensorTempArray)
32
54472e4f 33
34//_____________________________________________________________________________
24938b4c 35AliTPCSensorTempArray::AliTPCSensorTempArray():AliDCSSensorArray()
54472e4f 36{
37 //
38 // AliTPCSensorTempArray default constructor
39 //
ffa7e8be 40
54472e4f 41}
42//_____________________________________________________________________________
24938b4c 43AliTPCSensorTempArray::AliTPCSensorTempArray(Int_t run) : AliDCSSensorArray()
54472e4f 44{
24938b4c 45 //
46 // Read configuration from OCDB
47 //
48
49
50 AliCDBEntry *entry =
51 AliCDBManager::Instance()->Get("TPC/Config/Temperature",run);
0938d4f8 52 if (entry) {
53 TTree *tree = (TTree*) entry->GetObject();
54 fSensors = AliTPCSensorTemp::ReadTree(tree);
55 fSensors->BypassStreamer(kFALSE);
56 }
54472e4f 57}
58//_____________________________________________________________________________
ffa7e8be 59AliTPCSensorTempArray::AliTPCSensorTempArray(UInt_t startTime, UInt_t endTime,
67a165ed 60 TTree* confTree, const TString& amandaString)
24938b4c 61 :AliDCSSensorArray()
54472e4f 62{
63 //
24938b4c 64 // AliTPCSensorTempArray constructor for Shuttle preprocessor
65 // (confTree read from OCDB)
54472e4f 66 //
67a165ed 67 fSensors = AliTPCSensorTemp::ReadTree(confTree,amandaString);
24938b4c 68 fSensors->BypassStreamer(kFALSE);
63f49d7b 69 fStartTime = TTimeStamp((time_t)startTime,0);
70 fEndTime = TTimeStamp((time_t)endTime,0);
54472e4f 71}
72
73//_____________________________________________________________________________
5a163c08 74AliTPCSensorTempArray::AliTPCSensorTempArray(const char *fname,
75 const TString& amandaString) :
24938b4c 76 AliDCSSensorArray()
54472e4f 77{
78 //
79 // AliTPCSensorTempArray constructor
80 //
5a163c08 81 fSensors = AliTPCSensorTemp::ReadList(fname,amandaString);
54472e4f 82 fSensors->BypassStreamer(kFALSE);
54472e4f 83}
84
85
86//_____________________________________________________________________________
87AliTPCSensorTempArray::AliTPCSensorTempArray(const AliTPCSensorTempArray &c):
24938b4c 88 AliDCSSensorArray(c)
54472e4f 89{
90 //
91 // AliTPCSensorTempArray copy constructor
92 //
93
94}
95
96///_____________________________________________________________________________
97AliTPCSensorTempArray::~AliTPCSensorTempArray()
98{
99 //
100 // AliTPCSensorTempArray destructor
101 //
54472e4f 102}
103
104//_____________________________________________________________________________
105AliTPCSensorTempArray &AliTPCSensorTempArray::operator=(const AliTPCSensorTempArray &c)
106{
107 //
108 // Assignment operator
109 //
67a165ed 110 if (this != &c) {
111 fSensors->Delete();
112 new (this) AliTPCSensorTempArray(c);
113 fSensors = (TClonesArray*)c.fSensors->Clone();
114 }
54472e4f 115 return *this;
54472e4f 116}
117
54472e4f 118
54472e4f 119//_____________________________________________________________________________
67a165ed 120void AliTPCSensorTempArray::ReadSensors(const char *dbEntry)
54472e4f 121{
122 //
123 // Read list of temperature sensors from text file
124 //
67a165ed 125 AliCDBEntry *entry = AliCDBManager::Instance()->Get(dbEntry);
ff7d4b88 126 if (!entry) {
127 AliWarning(Form("No OCDB entry %s available\n",dbEntry));
128 return;
129 }
24938b4c 130 TTree *tree = (TTree*) entry->GetObject();
ff7d4b88 131 if (tree) fSensors = AliTPCSensorTemp::ReadTree(tree);
54472e4f 132
24938b4c 133}
54472e4f 134
e4dce695 135//_____________________________________________________________________________
136AliTPCSensorTemp* AliTPCSensorTempArray::GetSensor(Int_t type, Int_t side, Int_t sector, Int_t num)
137{
138 //
139 // Return sensor information for sensor specified by type, side, sector and num
140 //
141 Int_t nsensors = fSensors->GetEntries();
142 for (Int_t isensor=0; isensor<nsensors; isensor++) {
143 AliTPCSensorTemp *entry = (AliTPCSensorTemp*)fSensors->At(isensor);
144 if (entry->GetSide() == side &&
145 entry->GetType() == type &&
146 entry->GetSector() == sector &&
147 entry->GetNum() == num ) return entry;
148 }
149 return 0;
150}
151//_____________________________________________________________________________
49dfd67a 152
e4dce695 153AliTPCSensorTemp* AliTPCSensorTempArray::GetSensor(Int_t IdDCS){
154 return dynamic_cast<AliTPCSensorTemp*>(AliDCSSensorArray::GetSensor(IdDCS));
155}
156//_____________________________________________________________________________
49dfd67a 157
e4dce695 158AliTPCSensorTemp* AliTPCSensorTempArray::GetSensor(Double_t x, Double_t y, Double_t z){
159 return dynamic_cast<AliTPCSensorTemp*>(AliDCSSensorArray::GetSensor(x,y,z));
160}
3a887e1a 161//_____________________________________________________________________________
162
163Double_t AliTPCSensorTempArray::GetTempGradientY(UInt_t timeSec, Int_t side){
164 //
165 // Extract Linear Vertical Temperature Gradient [K/cm] within the TPC on
166 // Shaft Side(A): 0
167 // Muon Side(C): 1
168 // Values based on TemperatureSensors within the TPC (type: 3(TPC))
169 //
170 // FIXME: Also return residual-distribution, covariance Matrix
171 // or simply chi2 for validity check?
172 //
173
174 TLinearFitter fitter(3,"x0++x1++x2");
175 TVectorD param(3);
176 Int_t i = 0;
177
178 Int_t nsensors = fSensors->GetEntries();
179 for (Int_t isensor=0; isensor<nsensors; isensor++) { // loop over all sensors
180 AliTPCSensorTemp *entry = (AliTPCSensorTemp*)fSensors->At(isensor);
181
182 if (entry->GetType()==3 && entry->GetSide()==side) { // take SensorType:TPC
183 Double_t x[3];
184 x[0]=1;
185 x[1]=entry->GetX();
186 x[2]=entry->GetY();
187 Double_t y = entry->GetValue(timeSec); // get temperature value
188 fitter.AddPoint(x,y,1); // add values to LinearFitter
189 i++;
190 }
191
192 }
193 fitter.Eval();
194 fitter.GetParameters(param);
195
196 return param[2]; // return vertical (Y) tempGradient
197
198 }