Fixing ompilation warnings
[u/mrichter/AliRoot.git] / PHOS / AliPHOSCpvDA1.cxx
CommitLineData
55ec1be0 1/**************************************************************************
2 * Copyright(c) 1998-2008, 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// Class AliPHOSCpvDA1 accumulates histograms with amplitudes per CPV channel.
18// It is intended to run at DAQ or HLT computers.
19// Author: Boris Polishchuk, 25 January 2008.
20///////////////////////////////////////////////////////////////////////////////
21
22#include "AliPHOSCpvDA1.h"
23#include "TString.h"
24
25ClassImp(AliPHOSCpvDA1)
26
27//----------------------------------------------------------------
28AliPHOSCpvDA1::AliPHOSCpvDA1(int module) : TNamed(),
29 fHistoFile(0),fMod(module)
30
31{
32 // Create DA1 ("Calibration DA") object.
33 // module is the CPV module number (0..4).
34 // Checks existence of histograms which might have been left
35 // from the previous runs to continue their filling.
36 // Histogram names: module_iX_iZ.
37 // Root file name: CPV_ModuleX_Calib.root, where X - module number.
38
39 char name[128];
40 sprintf(name,"CPV_Module%d_Calib",fMod);
41 SetName(name);
42
43 char title[128];
44 sprintf(title,"Calibration Detector Algorithm for CPV module %d",fMod);
45 SetTitle(title);
46
47 char rootname[128];
48 sprintf(rootname,"%s.root",GetName());
49
50 fHistoFile = new TFile(rootname,"update");
51
52 char hname[128];
53 TH1F* hist1=0;
54
55 for(Int_t iX=0; iX<128; iX++) {
56 for(Int_t iZ=0; iZ<56; iZ++) {
57
58 sprintf(hname,"%d_%d_%d",fMod,iX,iZ);
59 hist1 = (TH1F*)fHistoFile->Get(hname);
60 if(hist1) fCharge[iX][iZ] = hist1;
61 else
62 fCharge[iX][iZ] = 0;
63 }
64 }
65
66}
67
68//-------------------------------------------------------------------
69AliPHOSCpvDA1::AliPHOSCpvDA1(const AliPHOSCpvDA1& da) : TNamed(da),
70 fHistoFile(0),fMod(da.fMod)
71{
72 // Copy constructor.
73
74 fHistoFile = new TFile(da.GetName(),"update");
75
76 char hname[128];
77 TH1F* hist1=0;
78
79 for(Int_t iX=0; iX<128; iX++) {
80 for(Int_t iZ=0; iZ<56; iZ++) {
81
82 sprintf(hname,"%d_%d_%d",fMod,iX,iZ);
83 hist1 = (TH1F*)da.fHistoFile->Get(hname);
84 if(hist1) fCharge[iX][iZ] = new TH1F(*hist1);
85 else
86 fCharge[iX][iZ] = 0;
87 }
88 }
89
90}
91
92//-------------------------------------------------------------------
93AliPHOSCpvDA1& AliPHOSCpvDA1::operator= (const AliPHOSCpvDA1& da)
94{
95 //Assignment operator.
96
97 if(this != &da) {
98
99 TString oldname(fHistoFile->GetName());
100 TString newname(da.fHistoFile->GetName());
101
102 if(oldname != newname) {
103 delete fHistoFile;
104 fHistoFile = new TFile(da.fHistoFile->GetName(),"update");
105 }
106
107 fMod = da.fMod;
108
109 SetName(da.GetName());
110 SetTitle(da.GetTitle());
111
112 for(Int_t iX=0; iX<128; iX++) {
113 for(Int_t iZ=0; iZ<56; iZ++) {
114
115 if(fCharge[iX][iZ]) delete fCharge[iX][iZ];
116 fCharge[iX][iZ] = da.fCharge[iX][iZ];
117 }
118 }
119
120 }
121
122 return *this;
123}
124
125
126//-------------------------------------------------------------------
127AliPHOSCpvDA1::~AliPHOSCpvDA1()
128{
129 // Destructor
130
131 UpdateHistoFile();
132 if(fHistoFile) delete fHistoFile;
133
134}
135
136//-------------------------------------------------------------------
137void AliPHOSCpvDA1::FillHistograms(Float_t e[128][56])
138{
139 // Fill charge deposit histograms of one event.
140 // Charge data is encoded as e[X][Z],
141 // where X(0..127) and Z(0..55) - pad position in the CPV module,
142 // Charge in ADC counts.
143 // If no charge read for particular channel,
144 // the correspondent array entry should be filled by zero.
145 // WARNING: this function should be called once per event!
146
147 char hname[128];
148 char htitl[128];
149
150 for(Int_t iX=0; iX<128; iX++) {
151 for (Int_t iZ=0; iZ<56; iZ++) {
152
153 if(!e[iX][iZ]) continue;
154
155 if(fCharge[iX][iZ])
156 fCharge[iX][iZ]->Fill(e[iX][iZ]);
157 else {
158 sprintf(hname,"%d_%d_%d",fMod,iX,iZ);
159 sprintf(htitl,"Charge deposited on the pad %d_%d_%d",fMod,iX,iZ);
160 fCharge[iX][iZ] = new TH1F(hname,htitl,1024,0.,1024.);
161 fCharge[iX][iZ]->Fill(e[iX][iZ]);
162 }
163
164 }
165 }
166
167}
168
169//-------------------------------------------------------------------
170void AliPHOSCpvDA1::UpdateHistoFile()
171{
172 // Write histograms to file
173
174 if(!fHistoFile) return;
175 if(!fHistoFile->IsOpen()) return;
176
177 TH1F* hist1=0;
178
179 for(Int_t iX=0; iX<128; iX++) {
180 for(Int_t iZ=0; iZ<56; iZ++) {
181
182 hist1 = fCharge[iX][iZ];
183 if(hist1) hist1->Write(hist1->GetName(),TObject::kWriteDelete);
184 }
185 }
186
187}
188