]>
Commit | Line | Data |
---|---|---|
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 | 24 | using namespace std; |
25 | ||
26 | ||
792f66f1 | 27 | /************************************************************************* |
c37f821f | 28 | * Class AliHLTPHOSRcuHistogramProducer accumulating histograms * |
792f66f1 | 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 | ||
36 | AliHLTPHOSRcuHistogramProducer:: 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 | 45 | AliHLTPHOSRcuHistogramProducer::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 | ||
54 | AliHLTPHOSRcuHistogramProducer::~ AliHLTPHOSRcuHistogramProducer() | |
55 | { | |
1b486665 | 56 | //Destructor |
792f66f1 | 57 | } |
58 | ||
59 | ||
60 | void | |
61 | AliHLTPHOSRcuHistogramProducer::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; | |
792f66f1 | 84 | fEnergyHistogramPtrs[x][z][gain] = new TH1F( tmpHistoName, tmpHistoName, N_BINS, XBIN_LOW, XBIN_UP); |
792f66f1 | 85 | sprintf(tmpHistoName, "TOFdistribution_%d_%d_%d_%d",(int)fModuleID, geomx, geomz, gain); |
792f66f1 | 86 | fTimingHistogramPtrs[x][z][gain] = 0; |
792f66f1 | 87 | fTimingHistogramPtrs[x][z][gain] = new TH1F(tmpHistoName , tmpHistoName, N_BINS, XBIN_LOW, XBIN_UP); |
792f66f1 | 88 | fCellAccEnergy.fAccumulatedEnergies[x][z][gain] = 0; |
89 | fCellAccEnergy.fHits[x][z][gain] = 0; | |
90 | fCellAccEnergy.fModuleID = 0; | |
91 | fCellAccEnergy.fRcuX = 0; | |
92 | fCellAccEnergy.fRcuZ = 0; | |
93 | } | |
94 | } | |
95 | } | |
96 | } | |
97 | ||
792f66f1 | 98 | |
99 | void | |
100 | AliHLTPHOSRcuHistogramProducer::SetRcuX(AliHLTUInt8_t X) | |
101 | { | |
1b486665 | 102 | //See header file for documentation |
792f66f1 | 103 | fRcuX = X; |
104 | fCellAccEnergy.fRcuX = X; | |
105 | } | |
106 | ||
107 | ||
1b486665 | 108 | |
792f66f1 | 109 | void |
110 | AliHLTPHOSRcuHistogramProducer::SetRcuZ(AliHLTUInt8_t Z) | |
111 | { | |
1b486665 | 112 | //See header file for documentation |
792f66f1 | 113 | fRcuZ = Z; |
114 | fCellAccEnergy.fRcuZ = Z; | |
115 | } | |
116 | ||
117 | ||
792f66f1 | 118 | |
119 | ||
120 | void | |
1b486665 | 121 | AliHLTPHOSRcuHistogramProducer::SetModuleID(AliHLTUInt8_t moduleID) |
792f66f1 | 122 | { |
1b486665 | 123 | //See header file for documentation |
124 | fModuleID = moduleID; | |
792f66f1 | 125 | } |
126 | ||
127 | ||
128 | void | |
129 | AliHLTPHOSRcuHistogramProducer::FillEnergy(AliHLTUInt8_t x, AliHLTUInt8_t z, AliHLTUInt8_t gain, float energy) | |
130 | { | |
43dd7c5e | 131 | // cout << "AliHLTPHOSRcuHistogramProducer::FillEnergy x = " << (int)x<< " z= " << (int)z; |
132 | // cout << " Energy =" << energy; | |
133 | // cout << " Accumulated energy" <<fCellAccEnergy.fAccumulatedEnergies[x][z][gain] << endl; | |
1b486665 | 134 | //See header file for documentation |
792f66f1 | 135 | fCellAccEnergy.fAccumulatedEnergies[x][z][gain] += energy; |
136 | fCellAccEnergy.fHits[x][z][gain] ++; | |
137 | fEnergyHistogramPtrs[x][z][gain]->Fill(energy); | |
138 | } | |
139 | ||
140 | ||
141 | void | |
142 | AliHLTPHOSRcuHistogramProducer::FillTime(AliHLTUInt8_t x, AliHLTUInt8_t z, AliHLTUInt8_t gain, float time) | |
143 | { | |
1b486665 | 144 | //See header file for documentation |
792f66f1 | 145 | fTimingHistogramPtrs[x][z][gain]->Fill(time); |
146 | } | |
147 | ||
148 | const AliHLTPHOSRcuCellAccumulatedEnergyDataStruct& | |
149 | AliHLTPHOSRcuHistogramProducer::GetCellAccumulatedEnergies() | |
150 | { | |
151 | // return &fCellAccEnergy ; | |
152 | return fCellAccEnergy ; | |
153 | } | |
154 | ||
792f66f1 | 155 | |
156 | void | |
157 | AliHLTPHOSRcuHistogramProducer::Reset() | |
158 | { | |
1b486665 | 159 | //See header file for documentation |
792f66f1 | 160 | for(int x = 0; x < N_XCOLUMNS_RCU; x ++) |
161 | { | |
162 | for(int z = 0; z < N_ZROWS_RCU; z ++) | |
163 | { | |
164 | for(int gain = 0; gain < N_GAINS; gain ++) | |
165 | { | |
166 | fEnergyAverageValues[x][z][gain] = 0; | |
167 | fAccumulatedValues[x][z][gain] = 0; | |
168 | fTimingAverageValues[x][z][gain] = 0; | |
169 | fHits[x][z][gain] = 0; | |
170 | } | |
171 | } | |
172 | } | |
173 | ||
174 | for(int i = 0; i <ALTRO_MAX_SAMPLES; i++) | |
175 | { | |
176 | fTmpChannelData[i] = 0; | |
177 | } | |
178 | } | |
179 | ||
1b486665 | 180 | |
792f66f1 | 181 | void |
182 | AliHLTPHOSRcuHistogramProducer::WriteEnergyHistograms() | |
183 | { | |
1b486665 | 184 | //See header file for documentation |
792f66f1 | 185 | char tmpFileName[256]; |
186 | sprintf(tmpFileName,"/home/aliphoshlt/rundir/outdata/calibHisto_%d_%d_%d.root", (int)fModuleID, (int)fRcuX, (int)fRcuZ); | |
187 | TFile *histoFile = new TFile(tmpFileName,"update"); | |
188 | char hname[128]; | |
189 | if(!histoFile) return; | |
190 | if(!histoFile->IsOpen()) return; | |
191 | ||
192 | cout <<"printing histograms"<< endl; | |
193 | cout <<"histofile-Getname() =" << histoFile->GetName() << endl; | |
194 | ||
195 | for(int x = 0; x < N_XCOLUMNS_RCU; x ++) | |
196 | { | |
197 | for(int z = 0; z < N_ZROWS_RCU; z ++) | |
198 | { | |
199 | for(int gain = 0; gain < N_GAINS; gain ++) | |
200 | { | |
201 | fEnergyHistogramPtrs[x][z][gain]->Write(); | |
202 | } | |
203 | } | |
204 | } | |
205 | ||
206 | cout << "printing histograms, finished"<< endl; | |
207 | histoFile->Close(); | |
208 | ||
209 | } |