]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TRD/AliTRDclusterCorrection.cxx
First upload of a macro to create raw data manually
[u/mrichter/AliRoot.git] / TRD / AliTRDclusterCorrection.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 //  TRD clusterCorrection                                                    //
19 //  Author:                                                                  //
20 //    Marian Ivanov (marian.ivanov@cern.ch)                                  //
21 //                                                                           //
22 /////////////////////////////////////////////////////////////////////////////// 
23
24 #include "AliTRDclusterCorrection.h"
25 #include "TFile.h"
26
27 ClassImp(AliTRDclusterCorrection)
28
29 AliTRDclusterCorrection *gAliTRDclusterCorrection = 0;
30
31 //_____________________________________________________________________________
32 AliTRDclusterCorrection::AliTRDclusterCorrection()
33   :TObject()
34   ,fOffsetAngle(0)
35 {
36   //
37   // Default constructor for AliTRDclusterCorrection
38   //
39
40   for (Int_t iplane = 0; iplane <  6; iplane++) {
41     for (Int_t itime  = 0; itime  < 30; itime++) {
42       for (Int_t iangle = 0; iangle < 20; iangle++) {   
43         fCorrections[iplane][itime][iangle][0] = 0.0;
44         fCorrections[iplane][itime][iangle][1] = 0.0;
45       }
46     }
47   }
48
49 }
50
51 //_____________________________________________________________________________
52 AliTRDclusterCorrection::~AliTRDclusterCorrection()
53 {
54   //
55   // Destructor
56   //
57
58 }
59
60 //_____________________________________________________________________________
61 void AliTRDclusterCorrection::SetCorrection(Int_t plane,Int_t timebin, Float_t angle
62                                           , Float_t value, Float_t sigma)
63 {
64   //
65   // Set the correction factors
66   //
67
68   Int_t iangle = Int_t((angle - fOffsetAngle + 1.0) * 10.0 + 0.5);
69   if (iangle <   0) return;
70   if (iangle >= 20) return;
71   fCorrections[plane][timebin][iangle][0] = value;
72   fCorrections[plane][timebin][iangle][1] = sigma;
73
74 }
75
76 //_____________________________________________________________________________
77 Float_t AliTRDclusterCorrection::GetCorrection(Int_t plane, Int_t timebin, Float_t angle) const
78 {
79   //
80   // Get the correction factors
81   //
82
83   Int_t iangle = Int_t((angle - fOffsetAngle + 1.0) * 10.0 + 0.5);
84   if (iangle <   0) return 0.0;
85   if (iangle >= 20) return 0.0;
86
87   return fCorrections[plane][timebin][iangle][0];
88
89 }
90
91 //_____________________________________________________________________________
92 Float_t AliTRDclusterCorrection::GetSigma(Int_t plane, Int_t timebin, Float_t angle) const
93 {
94   //
95   // Returns the sigma
96   //
97
98   Int_t iangle = Int_t((angle - fOffsetAngle + 1.0) * 10.0 + 0.5);
99   if (iangle <   0) return 1.0;
100   if (iangle >= 20) return 1.0;
101
102   return fCorrections[plane][timebin][iangle][1];
103
104 }
105
106 //_____________________________________________________________________________
107 AliTRDclusterCorrection *AliTRDclusterCorrection::GetCorrection()
108 {
109   //
110   // Return an instance of AliTRDclusterCorrection and sets the global
111   // pointer gAliTRDclusterCorrection (Is this needed somewhere ????)
112   //
113
114   if (gAliTRDclusterCorrection != 0) {
115     return gAliTRDclusterCorrection;
116   }
117
118   TFile *fileIn = new TFile("$ALICE_ROOT/TRD/TRDcorrection.root");
119   if (!fileIn){
120     gAliTRDclusterCorrection = new AliTRDclusterCorrection();
121     return gAliTRDclusterCorrection;
122   }
123
124   gAliTRDclusterCorrection = (AliTRDclusterCorrection *) 
125                              fileIn->Get("TRDcorrection");
126   if (gAliTRDclusterCorrection == 0) {  
127     gAliTRDclusterCorrection = new AliTRDclusterCorrection();
128   }
129
130   return gAliTRDclusterCorrection;
131   
132 }