]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HLT/PHOS/AliHLTPHOSRcuHistogramProducer.cxx
added new files to build system
[u/mrichter/AliRoot.git] / HLT / PHOS / AliHLTPHOSRcuHistogramProducer.cxx
CommitLineData
792f66f1 1/**************************************************************************
2 * Copyright(c) 2006, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Authors: Boris Polichtchouk & Per Thomas Hille for the ALICE *
5 * offline/HLT Project. Contributors are mentioned in the code where *
6 * appropriate. *
7 * *
8 * Permission to use, copy, modify and distribute this software and its *
9 * documentation strictly for non-commercial purposes is hereby granted *
10 * without fee, provided that the above copyright notice appears in all *
11 * copies and that both the copyright notice and this permission notice *
12 * appear in the supporting documentation. The authors make no claims *
13 * about the suitability of this software for any purpose. It is *
14 * provided "as is" without express or implied warranty. *
15 **************************************************************************/
16
17#include "AliHLTPHOSRcuHistogramProducer.h"
18#include <iostream>
1b486665 19//#include "stdio.h"
20#//include <cstdlib>
792f66f1 21#include "AliHLTPHOSRcuCellEnergyDataStruct.h"
22#include "TFile.h"
23
1b486665 24using namespace std;
25
26
792f66f1 27/*************************************************************************
28* Class AliHLTPHOSRcuHistogramProducer accumulating histograms *
29* with amplitudes per PHOS channel *
30* It is intended to run at the HLT farm *
31* and it fills the histograms with amplitudes per channel. *
32* Usage example see in PHOS/macros/Shuttle/AliPHOSCalibHistoProducer.C *
33**************************************************************************/
1b486665 34
35
36AliHLTPHOSRcuHistogramProducer:: AliHLTPHOSRcuHistogramProducer(): fModuleID(0), fRcuX(0), fRcuZ(0)
37
792f66f1 38{
1b486665 39 //Default constructor
792f66f1 40 cout << "WARNING: You cannot invoke the AliHLTPHOSRcuHistogramProducer without arguments" << endl;
41 cout << "Usage AliHLTPHOSRcuHistogramProducer(ModuleID, X. Z)" << endl;
792f66f1 42}
43
1b486665 44//AliHLTPHOSRcuHistogramProducer::AliHLTPHOSRcuHistogramProducer(AliHLTUInt8_t moduleID, AliHLTUInt8_t rcuX, AliHLTUInt8_t rcuZ)
792f66f1 45AliHLTPHOSRcuHistogramProducer::AliHLTPHOSRcuHistogramProducer(AliHLTUInt8_t moduleID, AliHLTUInt8_t rcuX, AliHLTUInt8_t rcuZ)
46{
1b486665 47 //Se header file for documentation
792f66f1 48 SetModuleID(moduleID);
49 SetRcuX(rcuX);
50 SetRcuZ(rcuZ);
51 Init();
52}
53
54AliHLTPHOSRcuHistogramProducer::~ AliHLTPHOSRcuHistogramProducer()
55{
1b486665 56 //Destructor
792f66f1 57}
58
59
60void
61AliHLTPHOSRcuHistogramProducer::Init()
62{
1b486665 63 //See header file for documentation
792f66f1 64 char tmpHistoName[256];
65 int geomx;
66 int geomz;
67
68
69 for(int x = 0; x < N_XCOLUMNS_RCU; x ++)
70 {
71 for(int z = 0; z < N_ZROWS_RCU; z ++)
72 {
73 for(int gain = 0; gain < N_GAINS; gain ++)
74 {
75 geomx = x + N_XCOLUMNS_RCU*fRcuX;
76 geomz = z + N_ZROWS_RCU*fRcuZ;
77
78 fEnergyAverageValues[x][z][gain] = 0;
79 fAccumulatedValues[x][z][gain] = 0;
80 fTimingAverageValues[x][z][gain] = 0;
81 fHits[x][z][gain] = 0;
82 sprintf(tmpHistoName, "Edistribution_%d_%d_%d_%d",(int)fModuleID, geomx, geomz, gain);
83 fEnergyHistogramPtrs[x][z][gain] = 0;
84
85 fEnergyHistogramPtrs[x][z][gain] = new TH1F( tmpHistoName, tmpHistoName, N_BINS, XBIN_LOW, XBIN_UP);
86
87 sprintf(tmpHistoName, "TOFdistribution_%d_%d_%d_%d",(int)fModuleID, geomx, geomz, gain);
88
89 fTimingHistogramPtrs[x][z][gain] = 0;
90
91 fTimingHistogramPtrs[x][z][gain] = new TH1F(tmpHistoName , tmpHistoName, N_BINS, XBIN_LOW, XBIN_UP);
92
93 fCellAccEnergy.fAccumulatedEnergies[x][z][gain] = 0;
94 fCellAccEnergy.fHits[x][z][gain] = 0;
95 fCellAccEnergy.fModuleID = 0;
96 fCellAccEnergy.fRcuX = 0;
97 fCellAccEnergy.fRcuZ = 0;
98 }
99 }
100 }
101}
102
792f66f1 103
104void
105AliHLTPHOSRcuHistogramProducer::SetRcuX(AliHLTUInt8_t X)
106{
1b486665 107 //See header file for documentation
792f66f1 108 fRcuX = X;
109 fCellAccEnergy.fRcuX = X;
110}
111
112
1b486665 113
792f66f1 114void
115AliHLTPHOSRcuHistogramProducer::SetRcuZ(AliHLTUInt8_t Z)
116{
1b486665 117 //See header file for documentation
792f66f1 118 fRcuZ = Z;
119 fCellAccEnergy.fRcuZ = Z;
120}
121
122
792f66f1 123
124
125void
1b486665 126AliHLTPHOSRcuHistogramProducer::SetModuleID(AliHLTUInt8_t moduleID)
792f66f1 127{
1b486665 128 //See header file for documentation
129 fModuleID = moduleID;
792f66f1 130}
131
132
133void
134AliHLTPHOSRcuHistogramProducer::FillEnergy(AliHLTUInt8_t x, AliHLTUInt8_t z, AliHLTUInt8_t gain, float energy)
135{
1b486665 136 //See header file for documentation
792f66f1 137 fCellAccEnergy.fAccumulatedEnergies[x][z][gain] += energy;
138 fCellAccEnergy.fHits[x][z][gain] ++;
139 fEnergyHistogramPtrs[x][z][gain]->Fill(energy);
140}
141
142
143void
144AliHLTPHOSRcuHistogramProducer::FillTime(AliHLTUInt8_t x, AliHLTUInt8_t z, AliHLTUInt8_t gain, float time)
145{
1b486665 146 //See header file for documentation
792f66f1 147 fTimingHistogramPtrs[x][z][gain]->Fill(time);
148}
149
150const AliHLTPHOSRcuCellAccumulatedEnergyDataStruct&
151AliHLTPHOSRcuHistogramProducer::GetCellAccumulatedEnergies()
152{
153 // return &fCellAccEnergy ;
154 return fCellAccEnergy ;
155}
156
792f66f1 157
158void
159AliHLTPHOSRcuHistogramProducer::Reset()
160{
1b486665 161 //See header file for documentation
792f66f1 162 for(int x = 0; x < N_XCOLUMNS_RCU; x ++)
163 {
164 for(int z = 0; z < N_ZROWS_RCU; z ++)
165 {
166 for(int gain = 0; gain < N_GAINS; gain ++)
167 {
168 fEnergyAverageValues[x][z][gain] = 0;
169 fAccumulatedValues[x][z][gain] = 0;
170 fTimingAverageValues[x][z][gain] = 0;
171 fHits[x][z][gain] = 0;
172 }
173 }
174 }
175
176 for(int i = 0; i <ALTRO_MAX_SAMPLES; i++)
177 {
178 fTmpChannelData[i] = 0;
179 }
180}
181
1b486665 182
792f66f1 183void
184AliHLTPHOSRcuHistogramProducer::WriteEnergyHistograms()
185{
1b486665 186 //See header file for documentation
792f66f1 187 char tmpFileName[256];
188 sprintf(tmpFileName,"/home/aliphoshlt/rundir/outdata/calibHisto_%d_%d_%d.root", (int)fModuleID, (int)fRcuX, (int)fRcuZ);
189 TFile *histoFile = new TFile(tmpFileName,"update");
190 char hname[128];
191 if(!histoFile) return;
192 if(!histoFile->IsOpen()) return;
193
194 cout <<"printing histograms"<< endl;
195 cout <<"histofile-Getname() =" << histoFile->GetName() << endl;
196
197 for(int x = 0; x < N_XCOLUMNS_RCU; x ++)
198 {
199 for(int z = 0; z < N_ZROWS_RCU; z ++)
200 {
201 for(int gain = 0; gain < N_GAINS; gain ++)
202 {
203 fEnergyHistogramPtrs[x][z][gain]->Write();
204 }
205 }
206 }
207
208 cout << "printing histograms, finished"<< endl;
209 histoFile->Close();
210
211}