From 60ea8d388176e39bb989fd822de5575e1c5dca97 Mon Sep 17 00:00:00 2001 From: dsilverm Date: Tue, 8 Apr 2008 12:06:03 +0000 Subject: [PATCH] silvermy@ornl.gov - first version of temperature sensor handling; based on TPC classes (H Helstrup) --- EMCAL/AliEMCALSensorTemp.cxx | 137 ++++++++++++++++++++++ EMCAL/AliEMCALSensorTemp.h | 63 ++++++++++ EMCAL/AliEMCALSensorTempArray.cxx | 183 ++++++++++++++++++++++++++++++ EMCAL/AliEMCALSensorTempArray.h | 51 +++++++++ 4 files changed, 434 insertions(+) create mode 100644 EMCAL/AliEMCALSensorTemp.cxx create mode 100644 EMCAL/AliEMCALSensorTemp.h create mode 100644 EMCAL/AliEMCALSensorTempArray.cxx create mode 100644 EMCAL/AliEMCALSensorTempArray.h diff --git a/EMCAL/AliEMCALSensorTemp.cxx b/EMCAL/AliEMCALSensorTemp.cxx new file mode 100644 index 00000000000..8487d96d081 --- /dev/null +++ b/EMCAL/AliEMCALSensorTemp.cxx @@ -0,0 +1,137 @@ +/************************************************************************** + * Copyright(c) 2006-07, 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. * + **************************************************************************/ + + +//////////////////////////////////////////////////////////////////////////////// +// // +// Class describing EMCAL temperature sensors (including pointers to graphs/fits// +// Authors: David Silvermyr, copied from TPC (Ivanov, Helstrup, Siska) // +// // +//////////////////////////////////////////////////////////////////////////////// + +// Running instructions: +/* + TClonesArray * arr = AliEMCALSensorTemp::ReadList("TempSensor.txt","emc_PT_%d.Temperature"); + TFile f("TempSensors.root","RECREATE"); + TTree * tree = new TTree("TempSensor", "TempSensor"); + tree->Branch("Temp",&arr); + tree->Fill(); + tree->Write(); + +*/ + +// + +#include +#include "AliEMCALSensorTemp.h" +ClassImp(AliEMCALSensorTemp) + +//______________________________________________________________________________________________ + +AliEMCALSensorTemp::AliEMCALSensorTemp(): AliDCSSensor(), + fSide(0), + fSector(0), + fNum(0) +{ + // + // Standard constructor + // +} +//______________________________________________________________________________________________ + +AliEMCALSensorTemp::AliEMCALSensorTemp(const AliEMCALSensorTemp& source) : + AliDCSSensor(source), + fSide(source.fSide), + fSector(source.fSector), + fNum(source.fNum) + +// +// Copy constructor +// +{ } +//______________________________________________________________________________________________ + +AliEMCALSensorTemp& AliEMCALSensorTemp::operator=(const AliEMCALSensorTemp& source){ +// +// assignment operator +// + if (&source == this) return *this; + new (this) AliEMCALSensorTemp(source); + + return *this; +} +//______________________________________________________________________________________________ + +TClonesArray * AliEMCALSensorTemp::ReadList(const char *fname, + const TString& amandaString) { + // + // read values from ascii file + // + TTree * tree = new TTree("asci","asci"); + tree->ReadFile(fname,""); + TClonesArray *arr = ReadTree(tree, amandaString); + delete tree; + return arr; +} + +//______________________________________________________________________________________________ + +TClonesArray * AliEMCALSensorTemp::ReadTree(TTree *tree, + const TString& amandaString) { + + Int_t nentries = tree->GetEntries(); + Int_t sensor=0; + Int_t sector=0; + char side[100]; + Int_t num=0; + Int_t echa=0; + //Double_t x=0; + //Double_t y=0; + //Double_t z=0; + //String_t namedtp[100]; + + tree->SetBranchAddress("Sensor",&sensor); + tree->SetBranchAddress("Side",&side); + tree->SetBranchAddress("Sec",§or); + tree->SetBranchAddress("Num",&num); + tree->SetBranchAddress("ECha",&echa); + //tree->SetBranchAddress("X",&x); + //tree->SetBranchAddress("Y",&y); + //tree->SetBranchAddress("Z",&z); + + // firstSensor = (Int_t)tree->GetMinimum("ECha"); + // lastSensor = (Int_t)tree->GetMaximum("ECha"); + + TClonesArray * array = new TClonesArray("AliEMCALSensorTemp",nentries); + + for (Int_t isensor=0; isensorGetEntry(isensor); + temp->SetId(sensor); + temp->SetIdDCS(echa); + TString stringID = Form (amandaString.Data(),echa); + temp->SetStringID(stringID); + if (side[0]=='C') temp->SetSide(1); + temp->SetSector(sector); + temp->SetNum(num); + + // Don't yet know the local or global coordinates for where the sensors will be placed.. + //temp->SetX(x); + //temp->SetY(y); + //temp->SetZ(z); + + } + return array; +} diff --git a/EMCAL/AliEMCALSensorTemp.h b/EMCAL/AliEMCALSensorTemp.h new file mode 100644 index 00000000000..81fe01c537a --- /dev/null +++ b/EMCAL/AliEMCALSensorTemp.h @@ -0,0 +1,63 @@ +#ifndef AliEMCALSensorTemp_H +#define AliEMCALSensorTemp_H +/* Copyright(c) 2006-07, ALICE Experiment at CERN, All rights reserved. * + * See cxx source for full Copyright notice */ + + +//////////////////////////////////////////////////////////////////////////// +// Container class for temperature sensor positions +//////////////////////////////////////////////////////////////////////////// + + +#include "TMath.h" +#include "AliSplineFit.h" +#include "AliDCSSensor.h" +#include "TTree.h" + +class TObject; +class TClonesArray; +class TObjArray; +class TGraph; +class TVector3; +class TFile; +class TString; +class TTimeStamp; + + +//////////////////////////////////////////////////////////////////////// +// Class AliEMCALSensorTempSensors +//////////////////////////////////////////////////////////////////////// + +const TString kAmandaString = "emc_temp:PT_%d.Temperature"; + +class AliEMCALSensorTemp : public AliDCSSensor { + +public: + AliEMCALSensorTemp(); + AliEMCALSensorTemp(const AliEMCALSensorTemp& source); + virtual ~AliEMCALSensorTemp(){} + AliEMCALSensorTemp& operator=(const AliEMCALSensorTemp& source); + + Int_t GetSide() const {return fSide; } + Int_t GetSector() const {return fSector; } + Int_t GetNum() const {return fNum; } + + void SetSide (Int_t side) {fSide = side; } + void SetSector (Int_t sector) {fSector = sector;} + void SetNum (Int_t num) {fNum = num; } + + + static TClonesArray * ReadList(const char *fname, + const TString& amandaString = kAmandaString); + static TClonesArray * ReadTree(TTree *tree, + const TString& amandaString = kAmandaString); + +protected: + // A SuperModule is defined in hardware land with a sector and a side index + Int_t fSide; // EMCAL side; 0:Shaft Side (A) -- 1:Muon Side (C) + Int_t fSector; // Number of sector (0-5) + Int_t fNum; // Number within a SuperModule: 8 sensors => index range 0-7 + + ClassDef(AliEMCALSensorTemp,1) +}; +#endif diff --git a/EMCAL/AliEMCALSensorTempArray.cxx b/EMCAL/AliEMCALSensorTempArray.cxx new file mode 100644 index 00000000000..2c819198c9c --- /dev/null +++ b/EMCAL/AliEMCALSensorTempArray.cxx @@ -0,0 +1,183 @@ +/************************************************************************** + * 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. * + **************************************************************************/ + + +/////////////////////////////////////////////////////////////////////////////// +// // +// EMCAL calibration class for saved temperature sensor parameters // +// Authors: David Silvermyr, copied from TPC (Ivanov, Helstrup) // +// // +/////////////////////////////////////////////////////////////////////////////// + +#include "AliEMCALSensorTempArray.h" +#include "TLinearFitter.h" +#include "TVectorD.h" +#include "AliLog.h" + +ClassImp(AliEMCALSensorTempArray) + +//_____________________________________________________________________________ +AliEMCALSensorTempArray::AliEMCALSensorTempArray():AliDCSSensorArray() +{ + // + // AliEMCALSensorTempArray default constructor + // +} +//_____________________________________________________________________________ +AliEMCALSensorTempArray::AliEMCALSensorTempArray(Int_t run) : AliDCSSensorArray() +{ + // + // Read configuration from OCDB + // + + AliCDBEntry *entry = + AliCDBManager::Instance()->Get("EMCAL/Config/Temperature",run); + TTree *tree = (TTree*) entry->GetObject(); + fSensors = AliEMCALSensorTemp::ReadTree(tree); + fSensors->BypassStreamer(kFALSE); +} +//_____________________________________________________________________________ +AliEMCALSensorTempArray::AliEMCALSensorTempArray(UInt_t startTime, UInt_t endTime, + TTree* confTree, const TString& amandaString) + :AliDCSSensorArray() +{ + // + // AliEMCALSensorTempArray constructor for Shuttle preprocessor + // (confTree read from OCDB) + // + fSensors = AliEMCALSensorTemp::ReadTree(confTree,amandaString); + fSensors->BypassStreamer(kFALSE); + fStartTime = TTimeStamp((time_t)startTime,0); + fEndTime = TTimeStamp((time_t)endTime,0); +} + +//_____________________________________________________________________________ +AliEMCALSensorTempArray::AliEMCALSensorTempArray(const char *fname, + const TString& amandaString) : + AliDCSSensorArray() +{ + // + // AliEMCALSensorTempArray constructor + // + fSensors = AliEMCALSensorTemp::ReadList(fname,amandaString); + fSensors->BypassStreamer(kFALSE); +} + +//_____________________________________________________________________________ +AliEMCALSensorTempArray::AliEMCALSensorTempArray(const AliEMCALSensorTempArray &c): + AliDCSSensorArray(c) +{ + // + // AliEMCALSensorTempArray copy constructor + // +} + +//_____________________________________________________________________________ +AliEMCALSensorTempArray::~AliEMCALSensorTempArray() +{ + // + // AliEMCALSensorTempArray destructor + // +} + +//_____________________________________________________________________________ +AliEMCALSensorTempArray &AliEMCALSensorTempArray::operator=(const AliEMCALSensorTempArray &c) +{ + // + // Assignment operator + // + if (this != &c) { + fSensors->Delete(); + new (this) AliEMCALSensorTempArray(c); + fSensors = (TClonesArray*)c.fSensors->Clone(); + } + return *this; +} + +//_____________________________________________________________________________ +void AliEMCALSensorTempArray::ReadSensors(const char *dbEntry) +{ + // + // Read list of temperature sensors from text file + // + AliCDBEntry *entry = AliCDBManager::Instance()->Get(dbEntry); + TTree *tree = (TTree*) entry->GetObject(); + fSensors = AliEMCALSensorTemp::ReadTree(tree); +} + +//_____________________________________________________________________________ +AliEMCALSensorTemp* AliEMCALSensorTempArray::GetSensor(Int_t side, Int_t sector, Int_t num) +{ + // + // Return sensor information for sensor specified by side, sector and num + // + Int_t nsensors = fSensors->GetEntries(); + for (Int_t isensor=0; isensorAt(isensor); + if (entry->GetSide() == side && + entry->GetSector() == sector && + entry->GetNum() == num ) return entry; + } + return 0; +} + +//_____________________________________________________________________________ + +AliEMCALSensorTemp* AliEMCALSensorTempArray::GetSensor(Int_t IdDCS){ + return dynamic_cast(AliDCSSensorArray::GetSensor(IdDCS)); +} + +//_____________________________________________________________________________ +AliEMCALSensorTemp* AliEMCALSensorTempArray::GetSensor(Double_t x, Double_t y, Double_t z){ + return dynamic_cast(AliDCSSensorArray::GetSensor(x,y,z)); +} + +//_____________________________________________________________________________ +Double_t AliEMCALSensorTempArray::GetTempGradientY(UInt_t timeSec, Int_t side){ + // + // Extract Linear Vertical Temperature Gradient [K/cm] within the EMCAL on + // Shaft Side(A): 0 + // Muon Side(C): 1 + // Values based on TemperatureSensors within the EMCAL + // + // 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; isensorAt(isensor); + + if (entry->GetSide()==side) { // only the selected side + 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 + + } diff --git a/EMCAL/AliEMCALSensorTempArray.h b/EMCAL/AliEMCALSensorTempArray.h new file mode 100644 index 00000000000..22b9585bceb --- /dev/null +++ b/EMCAL/AliEMCALSensorTempArray.h @@ -0,0 +1,51 @@ +#ifndef AliEMCALSensorTempArray_H +#define AliEMCALSensorTempArray_H +/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * + * See cxx source for full Copyright notice */ + + +/////////////////////////////////////////////////////////////////////////////// +// // +// EMCAL calibration class for temperature sensors // +// // +/////////////////////////////////////////////////////////////////////////////// + +#include "TSystem.h" + +#include "AliDCSSensorArray.h" +#include "AliEMCALSensorTemp.h" + +class TTimeStamp; +class TMap; +class TGraph; +class TObjString; +class AliSplineFit; +class AliDCSSensor; + +#include "TString.h" + + +class AliEMCALSensorTempArray : public AliDCSSensorArray { + public: + AliEMCALSensorTempArray(); + AliEMCALSensorTempArray(Int_t run); + AliEMCALSensorTempArray(const char *fname, + const TString& amandaString = kAmandaString); + AliEMCALSensorTempArray (UInt_t startTime, UInt_t endTime, TTree* confTree, + const TString& amandaString = kAmandaString); + AliEMCALSensorTempArray(const AliEMCALSensorTempArray &c); + virtual ~AliEMCALSensorTempArray(); + AliEMCALSensorTempArray &operator=(const AliEMCALSensorTempArray &c); + void ReadSensors (const char *dbEntry); + AliEMCALSensorTemp* GetSensor (Int_t side, Int_t sector, Int_t num); + AliEMCALSensorTemp* GetSensor (Int_t IdDCS); + AliEMCALSensorTemp* GetSensor (Double_t x, Double_t y, Double_t z); + Double_t GetTempGradientY(UInt_t timeSec, Int_t side); + + protected: + + ClassDef(AliEMCALSensorTempArray,1) // EMCAL calibration class for saved temperature sensor parameters + +}; + +#endif -- 2.43.0