#include <strings.h>
#include "AliTPCSensorTemp.h"
ClassImp(AliTPCSensorTemp)
const Float_t kASideX[18][5]={
{ 99.56, 117.59, 160.82, 186.92, 213.11},
{ 87.56, 103.4, 141.42, 164.37, 187.41},
{ 64.99, 76.75, 104.97, 122.00, 139.1},
{ 34.58, 40.84, 55.85, 64.92, 74.01},
{ 0, 0, 0, 0, 0},
{-34.58, -40.84, -55.85, -64.92, -74.01},
{-64.99, -76.75, -104.97, -122.0, -139.1},
{-87.56, -103.4, -141.42, -164.37, -187.41},
{-99.56, -117.59, -160.82, -186.92, -213.11},
{-99.56, -117.59, -160.82, -186.92, -213.11},
{-87.56, -103.4, -141.42, -164.37, -187.41},
{-64.99, -76.75, -104.97, -122, -139.1},
{-34.58, -40.84, -55.85, -64.92, -74.01},
{ 0, 0, 0, 0, 0},
{ 34.58, 40.84, 55.85, 64.92, 74.01},
{ 64.99, 76.75, 104.97, 122, 139.1},
{ 87.56, 103.4, 141.42, 164.37, 187.41},
{ 99.56, 117.59, 160.82, 186.92, 213.11}};
const Float_t kASideY[18][5]={
{ 17.56, 20.73, 28.36, 32.96, 37.58},
{ 50.55, 59.7, 81.65, 94.9, 108.2},
{ 77.45, 91.47, 125.1, 145.4, 165.77},
{ 95.0, 112.3, 153.45, 178.35, 203.35},
{101.1, 119.4, 163.3, 189.8, 216.4},
{ 95.0, 112.2, 153.45, 178.35, 203.35},
{ 77.45, 91.47, 125.1, 145.4, 165.77},
{ 50.55, 59.7, 81.65, 94.9, 108.2},
{ 17.56, 20.73, 28.36, 32.96, 37.58},
{-17.56, -20.73, -28.36, -32.96, -37.58},
{-50.55, -59.7, -81.65, -94.9, -108.2},
{-77.45, -91.47, -125.1, -145.4, -165.77},
{-95.0, -112.2, -153.45, -178.35, -203.35},
{-101.1, -119.4, -163.3, -189.8, -216.4},
{-95.0, -112.2, -153.45, -178.35, -203.35},
{-77.45, -91.47, -125.1, -145.4, -165.77},
{-50.55, -59.7, -81.65, -94.9, -108.2},
{-17.56, -20.73, -28.36, -32.96, -37.58}};
const Float_t kCSideX[18][5]={
{ 99.56, 117.59, 160.82, 186.92, 213.11},
{ 87.56, 103.4, 141.42, 164.37, 187.41},
{ 64.99, 76.75, 104.97, 122, 139.1},
{ 34.58, 40.84, 55.85, 64.92, 74.01},
{ 0, 0, 0, 0, 0},
{-34.58, -40.84, -55.85, -64.92, -74.01},
{-64.99, -76.75, -104.97, -122, -139.1},
{-87.56, -103.4, -141.42, -164.37, -187.41},
{-99.56, -117.59, -160.82, -186.92, -213.11},
{-99.56, -117.59, -160.82, -186.92, -213.11},
{-87.56, -103.4, -141.42, -164.37, -187.41},
{-64.99, -76.75, -104.97, -122, -139.1},
{-34.58, -40.84, -55.85, -64.92, -74.01},
{ 0, 0, 0, 0, 0},
{ 34.58, 40.84, 55.85, 64.92, 74.01},
{ 64.99, 76.75, 104.97, 122, 139.1},
{ 87.56, 103.4, 141.42, 164.37, 187.41},
{ 99.56, 117.59, 160.82, 186.92, 213.11}};
const Float_t kCSideY[18][5]={
{ 17.56, 20.73, 28.36, 32.96, 37.58},
{ 50.55, 59.7, 81.65, 94.9, 108.2},
{ 77.45, 91.47, 125.1, 145.4, 165.77},
{ 95.0, 112.2, 153.54, 178.35, 203.35},
{101.1, 119.4, 163.3, 189.8, 216.4},
{ 95.0, 112.2, 153.45, 178.35, 203.35},
{ 77.45, 91.47, 125.1, 145.4, 165.77},
{ 50.55, 59.7, 81.65, 94.9, 108.2},
{ 17.56, 20.73, 28.36, 32.96, 37.58},
{-17.56, -20.73, -28.36, -32.96, -37.58},
{-50.55, -59.7, -81.56, -94.9, -108.2},
{-77.45, -91.47, -125.1, -145.4, -165.77},
{-95.0, -112.2, -153.45, -178.35, -203.35},
{-101.1, -119.4, -163.3, -189.8, -216.4},
{-95.0, -112.2, -153.45, -178.35, -203.35},
{-77.45, -91.47, -125.1, -145.4, -165.77},
{-50.55, -59.7, -81.65, -94.9, -108.2},
{-17.56, -20.73, -28.36, -32.96, -37.58}};
const Float_t kIFCrad[5] = {67.2, 64.4, 60.7, 64.4, 67.2};
const Float_t kTSrad[4] = {67.2, 61.5, 67.2, 61.5};
const Float_t kTSz[4] = {240.0, 90.0, 240.0, 90.0};
AliTPCSensorTemp::AliTPCSensorTemp(): AliDCSSensor(),
fType(0),
fSide(0),
fSector(0),
fNum(0)
{
}
AliTPCSensorTemp::AliTPCSensorTemp(const AliTPCSensorTemp& source) :
AliDCSSensor(source),
fType(source.fType),
fSide(source.fSide),
fSector(source.fSector),
fNum(source.fNum)
{ }
AliTPCSensorTemp& AliTPCSensorTemp::operator=(const AliTPCSensorTemp& source){
if (&source == this) return *this;
new (this) AliTPCSensorTemp(source);
return *this;
}
TClonesArray * AliTPCSensorTemp::ReadList(const char *fname,
const TString& amandaString) {
TTree * tree = new TTree("asci","asci");
tree->ReadFile(fname,"");
TClonesArray *arr = ReadTree(tree, amandaString);
delete tree;
return arr;
}
TClonesArray * AliTPCSensorTemp::ReadTree(TTree *tree,
const TString& amandaString) {
Int_t nentries = tree->GetEntries();
Int_t sensor=0;
Int_t sector=0;
char type[100];
char side[100];
Int_t num=0;
Int_t echa=0;
tree->SetBranchAddress("Sensor",&sensor);
tree->SetBranchAddress("Type",&type);
tree->SetBranchAddress("Side",&side);
tree->SetBranchAddress("Sec",§or);
tree->SetBranchAddress("Num",&num);
tree->SetBranchAddress("ECha",&echa);
TClonesArray * array = new TClonesArray("AliTPCSensorTemp",nentries);
for (Int_t isensor=0; isensor<nentries; isensor++){
AliTPCSensorTemp * temp = new ((*array)[isensor])AliTPCSensorTemp;
tree->GetEntry(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);
if (bcmp(type,"ROC",3)==0) temp->SetType(0);
if (bcmp(type,"OFC",3)==0) temp->SetType(1);
if (bcmp(type,"IFC",3)==0) temp->SetType(2);
if (bcmp(type,"TPC",3)==0) temp->SetType(3);
if (bcmp(type,"ELM",3)==0) temp->SetType(4);
if (bcmp(type,"TS",2)==0) temp->SetType(5);
if (bcmp(type,"COOL",3)==0)temp->SetType(6);
if (temp->GetType()==0){
if (side[0]=='C') {
temp->SetX(kCSideX[sector][num]);
} else {
temp->SetX(kASideX[sector][num]);
}
}
if ((temp->GetType()==1) || (temp->GetType()==4)){
temp->SetX(TMath::Cos((2*sector+1)*0.1745)*278);
}
if (temp->GetType()==2) {
temp->SetX(TMath::Cos((2*sector+1)*0.1745)*60.7);
}
if (temp->GetType()==3) {
if (num==0) {
temp->SetX(TMath::Cos((2*sector+1)*0.1745)*87.5);
} else {
temp->SetX(TMath::Cos((2*sector+1)*0.1745)*241.8);
}
}
if (temp->GetType()==5){
temp->SetX(TMath::Cos(sector*0.524+(num+1)*0.131)*kTSrad[num]);
}
if (temp->GetType()==6){
temp->SetX(0);
}
if (temp->GetType()==0){
if (side[0]=='C') {
temp->SetY(kCSideY[sector][num]);
} else {
temp->SetY(kASideY[sector][num]);
}
}
if ((temp->GetType()==1) || (temp->GetType()==4)){
temp->SetY(TMath::Sin((2*sector+1)*0.1745)*278);
}
if (temp->GetType()==2){
temp->SetY(TMath::Sin((2*sector+1)*0.1745)*60.7);
}
if (temp->GetType()==3) {
if (num==0) {
temp->SetY(TMath::Sin((2*sector+1)*0.1745)*87.5);
} else {
temp->SetY(TMath::Sin((2*sector+1)*0.1745)*241.8);
}
}
if (temp->GetType()==5){
temp->SetY(TMath::Sin(sector*0.524+(num+1)*0.131)*kTSrad[num]);
}
if (temp->GetType()==6){
temp->SetY(0);
}
if ((temp->GetType()==0 ||
temp->GetType()==4 || temp->GetType()==6) &&
temp->GetSide()==0) {
temp->SetZ(250);
}
if ((temp->GetType()==0 || temp->GetType()==4 ||
temp->GetType()==6) && temp->GetSide()==1){
temp->SetZ(-250);
}
if(temp->GetType()==2 && temp->GetSide()==0) {
temp->SetZ(52.4);
}
if(temp->GetType()==2 && temp->GetSide()==1) {
temp->SetZ(-52.4);
}
if(temp->GetType()==3 && temp->GetSide()==0) {
temp->SetZ(247);
}
if(temp->GetType()==3 && temp->GetSide()==1) {
temp->SetZ(-247);
}
if((temp->GetType()==1 ) && (num==0)) {
temp->SetZ(240);
}
if((temp->GetType()==1 ) && (num==1)) {
temp->SetZ(168.4);
}
if((temp->GetType()==1 ) && (num==2)) {
temp->SetZ(51);
}
if((temp->GetType()==1 ) && (num==3)) {
temp->SetZ(-51);
}
if((temp->GetType()==1 ) && (num==4)) {
temp->SetZ(-168.4);
}
if((temp->GetType()==1 ) && (num==5)) {
temp->SetZ(-240);
}
if ( num < (Int_t)(sizeof(kTSz)/sizeof(kTSz[0]))) {
if(temp->GetType()==5 && temp->GetSide()==0) {
temp->SetZ(kTSz[num]);
}
if(temp->GetType()==5 && temp->GetSide()==1) {
temp->SetZ(-kTSz[num]);
}
}
}
return array;
}