]> git.uio.no Git - u/mrichter/AliRoot.git/blob - EMCAL/AliEMCALSensorTempArray.cxx
correcting AliHLTGlobalTriggerDecision::Clear(): using Delete instead of Clear for...
[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   TTree *tree = (TTree*) entry->GetObject();
120   fSensors = AliEMCALSensorTemp::ReadTree(tree);
121 }  
122
123 //_____________________________________________________________________________
124 AliEMCALSensorTemp* AliEMCALSensorTempArray::GetSensor(Int_t side, Int_t sector, Int_t num) 
125 {
126   //
127   //  Return sensor information for sensor specified by side, sector and num
128   //
129   Int_t nsensors = fSensors->GetEntries();
130   for (Int_t isensor=0; isensor<nsensors; isensor++) {
131     AliEMCALSensorTemp *entry = (AliEMCALSensorTemp*)fSensors->At(isensor);
132     if (entry->GetSide() == side &&
133         entry->GetSector() == sector &&
134         entry->GetNum() == num ) return entry;
135   }
136   return 0;
137 }
138
139 //_____________________________________________________________________________
140
141 AliEMCALSensorTemp* AliEMCALSensorTempArray::GetSensor(Int_t IdDCS){
142   return dynamic_cast<AliEMCALSensorTemp*>(AliDCSSensorArray::GetSensor(IdDCS));
143 }
144
145 //_____________________________________________________________________________
146 AliEMCALSensorTemp* AliEMCALSensorTempArray::GetSensor(Double_t x, Double_t y, Double_t z){
147   return dynamic_cast<AliEMCALSensorTemp*>(AliDCSSensorArray::GetSensor(x,y,z));
148 }
149
150 //_____________________________________________________________________________
151 Double_t AliEMCALSensorTempArray::GetTempGradientY(UInt_t timeSec, Int_t side){
152   //
153   // Extract Linear Vertical Temperature Gradient [K/cm] within the EMCAL on
154   // Shaft Side(A): 0
155   // Muon  Side(C): 1
156   // Values based on TemperatureSensors within the EMCAL 
157   //
158   // FIXME: Also return residual-distribution, covariance Matrix
159   //        or simply chi2 for validity check?
160   //
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     AliEMCALSensorTemp *entry = (AliEMCALSensorTemp*)fSensors->At(isensor);
169     
170     if (entry->GetSide()==side) { // only the selected side
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  }