add set and getter for neutral energy fraction
[u/mrichter/AliRoot.git] / EMCAL / AliEMCALSensorTemp.cxx
1 /**************************************************************************
2  * Copyright(c) 2006-07, 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 // Class describing EMCAL temperature sensors (including pointers to graphs/fits//
20 // Authors: David Silvermyr, copied from TPC (Ivanov, Helstrup, Siska)        //
21 //                                                                            //
22 ////////////////////////////////////////////////////////////////////////////////
23
24 // Running instructions:
25 /*
26   TClonesArray * arr = AliEMCALSensorTemp::ReadList("TempSensor.txt","emc_PT_%d.Temperature");
27   TFile f("TempSensors.root","RECREATE");
28   TTree * tree = new TTree("TempSensor", "TempSensor");
29   tree->Branch("Temp",&arr);
30   tree->Fill();
31   tree->Write();
32   
33 */
34
35 //
36
37 #include <strings.h>
38 #include "AliEMCALSensorTemp.h"
39 ClassImp(AliEMCALSensorTemp)
40
41 //______________________________________________________________________________________________
42
43 AliEMCALSensorTemp::AliEMCALSensorTemp(): AliDCSSensor(),
44   fSide(0),
45   fSector(0),
46   fNum(0)
47 {
48   //
49   //  Standard constructor
50   //
51 }
52 //______________________________________________________________________________________________
53
54 AliEMCALSensorTemp::AliEMCALSensorTemp(const AliEMCALSensorTemp& source) :
55   AliDCSSensor(source),
56    fSide(source.fSide),
57    fSector(source.fSector),
58    fNum(source.fNum)
59
60 //
61 //  Copy constructor
62 //
63 { }
64 //______________________________________________________________________________________________
65
66 AliEMCALSensorTemp& AliEMCALSensorTemp::operator=(const AliEMCALSensorTemp& source){
67 //
68 // assignment operator
69 //
70   if (&source == this) return *this;
71   new (this) AliEMCALSensorTemp(source);
72   
73   return *this;  
74 }
75 //______________________________________________________________________________________________
76
77 TClonesArray * AliEMCALSensorTemp::ReadList(const char *fname,
78                                           const TString& amandaString) {
79   //
80   // read values from ascii file
81   //
82   TTree * tree = new TTree("asci","asci");
83   tree->ReadFile(fname,"");
84   TClonesArray *arr = ReadTree(tree, amandaString);
85   delete tree;
86   return arr;
87 }
88      
89 //______________________________________________________________________________________________
90
91 TClonesArray * AliEMCALSensorTemp::ReadTree(TTree *tree, 
92                                           const TString& amandaString) {
93   
94   Int_t nentries = tree->GetEntries();
95   Int_t sensor=0;
96   Int_t sector=0;
97   char  side[100];
98   Int_t num=0;
99   Int_t echa=0;
100   //Double_t x=0;
101   //Double_t y=0;
102   //Double_t z=0;
103   //String_t namedtp[100];
104
105   tree->SetBranchAddress("Sensor",&sensor);
106   tree->SetBranchAddress("Side",&side);
107   tree->SetBranchAddress("Sec",&sector);
108   tree->SetBranchAddress("Num",&num);
109   tree->SetBranchAddress("ECha",&echa);
110   //tree->SetBranchAddress("X",&x);
111   //tree->SetBranchAddress("Y",&y);
112   //tree->SetBranchAddress("Z",&z);
113
114   // firstSensor = (Int_t)tree->GetMinimum("ECha");
115   // lastSensor = (Int_t)tree->GetMaximum("ECha");
116
117   TClonesArray * array = new TClonesArray("AliEMCALSensorTemp",nentries);
118
119   for (Int_t isensor=0; isensor<nentries; isensor++){
120     AliEMCALSensorTemp * temp = new ((*array)[isensor])AliEMCALSensorTemp;
121     tree->GetEntry(isensor);
122     temp->SetId(sensor);
123     temp->SetIdDCS(echa);
124     TString stringID = Form (amandaString.Data(),echa);
125     temp->SetStringID(stringID);
126     if (side[0]=='C') temp->SetSide(1);
127     temp->SetSector(sector);
128     temp->SetNum(num);
129
130     // Don't yet know the local or global coordinates for where the sensors will be placed..
131     //temp->SetX(x);
132     //temp->SetY(y);
133     //temp->SetZ(z);
134
135   }
136   return array;
137 }