ROOT logo
/**************************************************************************
 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
 *                                                                        *
 * Author: The ALICE Off-line Project.                                    *
 * Contributors are mentioned in the code where appropriate.              *
 *                                                                        *
 * Permission to use, copy, modify and distribute this software and its   *
 * documentation strictly for non-commercial purposes is hereby granted   *
 * without fee, provided that the above copyright notice appears in all   *
 * copies and that both the copyright notice and this permission notice   *
 * appear in the supporting documentation. The authors make no claims     *
 * about the suitability of this software for any purpose. It is          *
 * provided "as is" without express or implied warranty.                  *
 **************************************************************************/


///////////////////////////////////////////////////////////////////////////////
//                                                                           //
//  TPC calibration class for parameters which saved per pad                 //
//  Authors: Marian Ivanov and Haavard Helstrup                              //
//                                                                           //
///////////////////////////////////////////////////////////////////////////////

#include "AliTPCSensorTempArray.h"
#include "TLinearFitter.h"
#include "TVectorD.h"
#include "AliLog.h"



ClassImp(AliTPCSensorTempArray)


//_____________________________________________________________________________
AliTPCSensorTempArray::AliTPCSensorTempArray():AliDCSSensorArray()
{
  //
  // AliTPCSensorTempArray default constructor
  //
 
}
//_____________________________________________________________________________
AliTPCSensorTempArray::AliTPCSensorTempArray(Int_t run) : AliDCSSensorArray() 
{
  //
  // Read configuration from OCDB
  //

     
  AliCDBEntry *entry =
            AliCDBManager::Instance()->Get("TPC/Config/Temperature",run); 
  if (entry) {
    TTree *tree = (TTree*) entry->GetObject();
    fSensors = AliTPCSensorTemp::ReadTree(tree);
    fSensors->BypassStreamer(kFALSE);
  }
}
//_____________________________________________________________________________
AliTPCSensorTempArray::AliTPCSensorTempArray(UInt_t startTime, UInt_t endTime,
                       TTree* confTree, const TString& amandaString)
             :AliDCSSensorArray()
{
  //
  // AliTPCSensorTempArray constructor for Shuttle preprocessor 
  //  (confTree read from OCDB)
  //
  fSensors = AliTPCSensorTemp::ReadTree(confTree,amandaString);
  fSensors->BypassStreamer(kFALSE);
  fStartTime = TTimeStamp((time_t)startTime,0);
  fEndTime   = TTimeStamp((time_t)endTime,0);
}

//_____________________________________________________________________________
AliTPCSensorTempArray::AliTPCSensorTempArray(const char *fname,
                                          const TString& amandaString) :
                                                  AliDCSSensorArray()
{
  //
  // AliTPCSensorTempArray constructor
  //
  fSensors = AliTPCSensorTemp::ReadList(fname,amandaString);
  fSensors->BypassStreamer(kFALSE);
}


//_____________________________________________________________________________
AliTPCSensorTempArray::AliTPCSensorTempArray(const AliTPCSensorTempArray &c):
  AliDCSSensorArray(c)
{
  //
  // AliTPCSensorTempArray copy constructor
  //

}

///_____________________________________________________________________________
AliTPCSensorTempArray::~AliTPCSensorTempArray()
{
  //
  // AliTPCSensorTempArray destructor
  //
}

//_____________________________________________________________________________
AliTPCSensorTempArray &AliTPCSensorTempArray::operator=(const AliTPCSensorTempArray &c)
{
  //
  // Assignment operator
  //
  if (this != &c) {
     fSensors->Delete();
     new (this) AliTPCSensorTempArray(c);
     fSensors = (TClonesArray*)c.fSensors->Clone();
  }
  return *this;
}


//_____________________________________________________________________________
void AliTPCSensorTempArray::ReadSensors(const char *dbEntry)
{
  //
  // Read list of temperature sensors from text file
  //
  AliCDBEntry *entry = AliCDBManager::Instance()->Get(dbEntry);
  if (!entry) {
     AliWarning(Form("No OCDB entry  %s available\n",dbEntry));
     return;
  }        
  TTree *tree = (TTree*) entry->GetObject();
  if (tree) fSensors = AliTPCSensorTemp::ReadTree(tree);

}  

//_____________________________________________________________________________
AliTPCSensorTemp* AliTPCSensorTempArray::GetSensor(Int_t type, Int_t side, Int_t sector, Int_t num) 
{
 //
 //  Return sensor information for sensor specified by type, side, sector and num
 //
 Int_t nsensors = fSensors->GetEntries();
 for (Int_t isensor=0; isensor<nsensors; isensor++) {
   AliTPCSensorTemp *entry = (AliTPCSensorTemp*)fSensors->At(isensor);
   if (entry->GetSide() == side &&
       entry->GetType() == type &&
       entry->GetSector() == sector &&
       entry->GetNum() == num ) return entry;
 }
 return 0;
}
//_____________________________________________________________________________

AliTPCSensorTemp* AliTPCSensorTempArray::GetSensor(Int_t IdDCS){
  return dynamic_cast<AliTPCSensorTemp*>(AliDCSSensorArray::GetSensor(IdDCS));
}
//_____________________________________________________________________________

AliTPCSensorTemp* AliTPCSensorTempArray::GetSensor(Double_t x, Double_t y, Double_t z){
  return dynamic_cast<AliTPCSensorTemp*>(AliDCSSensorArray::GetSensor(x,y,z));
}
//_____________________________________________________________________________

Double_t AliTPCSensorTempArray::GetTempGradientY(UInt_t timeSec, Int_t side){
 //
 // Extract Linear Vertical Temperature Gradient [K/cm] within the TPC on
 // Shaft Side(A): 0
 // Muon  Side(C): 1
 // Values based on TemperatureSensors within the TPC (type: 3(TPC))
 //
 // FIXME: Also return residual-distribution, covariance Matrix
 //        or simply chi2 for validity check?
 //

 TLinearFitter fitter(3,"x0++x1++x2");
 TVectorD param(3);
 Int_t i = 0;

 Int_t nsensors = fSensors->GetEntries();
 for (Int_t isensor=0; isensor<nsensors; isensor++) { // loop over all sensors
   AliTPCSensorTemp *entry = (AliTPCSensorTemp*)fSensors->At(isensor);

   if (entry->GetType()==3 && entry->GetSide()==side) { // take SensorType:TPC
     Double_t x[3];
     x[0]=1;
     x[1]=entry->GetX();
     x[2]=entry->GetY();
     Double_t y = entry->GetValue(timeSec); // get temperature value
     fitter.AddPoint(x,y,1); // add values to LinearFitter
     i++;
   }

 }
 fitter.Eval();
 fitter.GetParameters(param);

 return param[2]; // return vertical (Y) tempGradient

 }
 AliTPCSensorTempArray.cxx:1
 AliTPCSensorTempArray.cxx:2
 AliTPCSensorTempArray.cxx:3
 AliTPCSensorTempArray.cxx:4
 AliTPCSensorTempArray.cxx:5
 AliTPCSensorTempArray.cxx:6
 AliTPCSensorTempArray.cxx:7
 AliTPCSensorTempArray.cxx:8
 AliTPCSensorTempArray.cxx:9
 AliTPCSensorTempArray.cxx:10
 AliTPCSensorTempArray.cxx:11
 AliTPCSensorTempArray.cxx:12
 AliTPCSensorTempArray.cxx:13
 AliTPCSensorTempArray.cxx:14
 AliTPCSensorTempArray.cxx:15
 AliTPCSensorTempArray.cxx:16
 AliTPCSensorTempArray.cxx:17
 AliTPCSensorTempArray.cxx:18
 AliTPCSensorTempArray.cxx:19
 AliTPCSensorTempArray.cxx:20
 AliTPCSensorTempArray.cxx:21
 AliTPCSensorTempArray.cxx:22
 AliTPCSensorTempArray.cxx:23
 AliTPCSensorTempArray.cxx:24
 AliTPCSensorTempArray.cxx:25
 AliTPCSensorTempArray.cxx:26
 AliTPCSensorTempArray.cxx:27
 AliTPCSensorTempArray.cxx:28
 AliTPCSensorTempArray.cxx:29
 AliTPCSensorTempArray.cxx:30
 AliTPCSensorTempArray.cxx:31
 AliTPCSensorTempArray.cxx:32
 AliTPCSensorTempArray.cxx:33
 AliTPCSensorTempArray.cxx:34
 AliTPCSensorTempArray.cxx:35
 AliTPCSensorTempArray.cxx:36
 AliTPCSensorTempArray.cxx:37
 AliTPCSensorTempArray.cxx:38
 AliTPCSensorTempArray.cxx:39
 AliTPCSensorTempArray.cxx:40
 AliTPCSensorTempArray.cxx:41
 AliTPCSensorTempArray.cxx:42
 AliTPCSensorTempArray.cxx:43
 AliTPCSensorTempArray.cxx:44
 AliTPCSensorTempArray.cxx:45
 AliTPCSensorTempArray.cxx:46
 AliTPCSensorTempArray.cxx:47
 AliTPCSensorTempArray.cxx:48
 AliTPCSensorTempArray.cxx:49
 AliTPCSensorTempArray.cxx:50
 AliTPCSensorTempArray.cxx:51
 AliTPCSensorTempArray.cxx:52
 AliTPCSensorTempArray.cxx:53
 AliTPCSensorTempArray.cxx:54
 AliTPCSensorTempArray.cxx:55
 AliTPCSensorTempArray.cxx:56
 AliTPCSensorTempArray.cxx:57
 AliTPCSensorTempArray.cxx:58
 AliTPCSensorTempArray.cxx:59
 AliTPCSensorTempArray.cxx:60
 AliTPCSensorTempArray.cxx:61
 AliTPCSensorTempArray.cxx:62
 AliTPCSensorTempArray.cxx:63
 AliTPCSensorTempArray.cxx:64
 AliTPCSensorTempArray.cxx:65
 AliTPCSensorTempArray.cxx:66
 AliTPCSensorTempArray.cxx:67
 AliTPCSensorTempArray.cxx:68
 AliTPCSensorTempArray.cxx:69
 AliTPCSensorTempArray.cxx:70
 AliTPCSensorTempArray.cxx:71
 AliTPCSensorTempArray.cxx:72
 AliTPCSensorTempArray.cxx:73
 AliTPCSensorTempArray.cxx:74
 AliTPCSensorTempArray.cxx:75
 AliTPCSensorTempArray.cxx:76
 AliTPCSensorTempArray.cxx:77
 AliTPCSensorTempArray.cxx:78
 AliTPCSensorTempArray.cxx:79
 AliTPCSensorTempArray.cxx:80
 AliTPCSensorTempArray.cxx:81
 AliTPCSensorTempArray.cxx:82
 AliTPCSensorTempArray.cxx:83
 AliTPCSensorTempArray.cxx:84
 AliTPCSensorTempArray.cxx:85
 AliTPCSensorTempArray.cxx:86
 AliTPCSensorTempArray.cxx:87
 AliTPCSensorTempArray.cxx:88
 AliTPCSensorTempArray.cxx:89
 AliTPCSensorTempArray.cxx:90
 AliTPCSensorTempArray.cxx:91
 AliTPCSensorTempArray.cxx:92
 AliTPCSensorTempArray.cxx:93
 AliTPCSensorTempArray.cxx:94
 AliTPCSensorTempArray.cxx:95
 AliTPCSensorTempArray.cxx:96
 AliTPCSensorTempArray.cxx:97
 AliTPCSensorTempArray.cxx:98
 AliTPCSensorTempArray.cxx:99
 AliTPCSensorTempArray.cxx:100
 AliTPCSensorTempArray.cxx:101
 AliTPCSensorTempArray.cxx:102
 AliTPCSensorTempArray.cxx:103
 AliTPCSensorTempArray.cxx:104
 AliTPCSensorTempArray.cxx:105
 AliTPCSensorTempArray.cxx:106
 AliTPCSensorTempArray.cxx:107
 AliTPCSensorTempArray.cxx:108
 AliTPCSensorTempArray.cxx:109
 AliTPCSensorTempArray.cxx:110
 AliTPCSensorTempArray.cxx:111
 AliTPCSensorTempArray.cxx:112
 AliTPCSensorTempArray.cxx:113
 AliTPCSensorTempArray.cxx:114
 AliTPCSensorTempArray.cxx:115
 AliTPCSensorTempArray.cxx:116
 AliTPCSensorTempArray.cxx:117
 AliTPCSensorTempArray.cxx:118
 AliTPCSensorTempArray.cxx:119
 AliTPCSensorTempArray.cxx:120
 AliTPCSensorTempArray.cxx:121
 AliTPCSensorTempArray.cxx:122
 AliTPCSensorTempArray.cxx:123
 AliTPCSensorTempArray.cxx:124
 AliTPCSensorTempArray.cxx:125
 AliTPCSensorTempArray.cxx:126
 AliTPCSensorTempArray.cxx:127
 AliTPCSensorTempArray.cxx:128
 AliTPCSensorTempArray.cxx:129
 AliTPCSensorTempArray.cxx:130
 AliTPCSensorTempArray.cxx:131
 AliTPCSensorTempArray.cxx:132
 AliTPCSensorTempArray.cxx:133
 AliTPCSensorTempArray.cxx:134
 AliTPCSensorTempArray.cxx:135
 AliTPCSensorTempArray.cxx:136
 AliTPCSensorTempArray.cxx:137
 AliTPCSensorTempArray.cxx:138
 AliTPCSensorTempArray.cxx:139
 AliTPCSensorTempArray.cxx:140
 AliTPCSensorTempArray.cxx:141
 AliTPCSensorTempArray.cxx:142
 AliTPCSensorTempArray.cxx:143
 AliTPCSensorTempArray.cxx:144
 AliTPCSensorTempArray.cxx:145
 AliTPCSensorTempArray.cxx:146
 AliTPCSensorTempArray.cxx:147
 AliTPCSensorTempArray.cxx:148
 AliTPCSensorTempArray.cxx:149
 AliTPCSensorTempArray.cxx:150
 AliTPCSensorTempArray.cxx:151
 AliTPCSensorTempArray.cxx:152
 AliTPCSensorTempArray.cxx:153
 AliTPCSensorTempArray.cxx:154
 AliTPCSensorTempArray.cxx:155
 AliTPCSensorTempArray.cxx:156
 AliTPCSensorTempArray.cxx:157
 AliTPCSensorTempArray.cxx:158
 AliTPCSensorTempArray.cxx:159
 AliTPCSensorTempArray.cxx:160
 AliTPCSensorTempArray.cxx:161
 AliTPCSensorTempArray.cxx:162
 AliTPCSensorTempArray.cxx:163
 AliTPCSensorTempArray.cxx:164
 AliTPCSensorTempArray.cxx:165
 AliTPCSensorTempArray.cxx:166
 AliTPCSensorTempArray.cxx:167
 AliTPCSensorTempArray.cxx:168
 AliTPCSensorTempArray.cxx:169
 AliTPCSensorTempArray.cxx:170
 AliTPCSensorTempArray.cxx:171
 AliTPCSensorTempArray.cxx:172
 AliTPCSensorTempArray.cxx:173
 AliTPCSensorTempArray.cxx:174
 AliTPCSensorTempArray.cxx:175
 AliTPCSensorTempArray.cxx:176
 AliTPCSensorTempArray.cxx:177
 AliTPCSensorTempArray.cxx:178
 AliTPCSensorTempArray.cxx:179
 AliTPCSensorTempArray.cxx:180
 AliTPCSensorTempArray.cxx:181
 AliTPCSensorTempArray.cxx:182
 AliTPCSensorTempArray.cxx:183
 AliTPCSensorTempArray.cxx:184
 AliTPCSensorTempArray.cxx:185
 AliTPCSensorTempArray.cxx:186
 AliTPCSensorTempArray.cxx:187
 AliTPCSensorTempArray.cxx:188
 AliTPCSensorTempArray.cxx:189
 AliTPCSensorTempArray.cxx:190
 AliTPCSensorTempArray.cxx:191
 AliTPCSensorTempArray.cxx:192
 AliTPCSensorTempArray.cxx:193
 AliTPCSensorTempArray.cxx:194
 AliTPCSensorTempArray.cxx:195
 AliTPCSensorTempArray.cxx:196
 AliTPCSensorTempArray.cxx:197
 AliTPCSensorTempArray.cxx:198