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