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