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