]>
Commit | Line | Data |
---|---|---|
ab38011b | 1 | /************************************************************************** |
2 | * This file is property of and copyright by the ALICE HLT Project * | |
3 | * All rights reserved. * | |
4 | * * | |
5 | * Primary Authors: Oystein Djuvsland * | |
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 | **************************************************************************/ | |
5c6503dc | 15 | |
16 | #include "AliHLTPHOSChannelCounter.h" | |
17 | #include "AliHLTPHOSRcuCellEnergyDataStruct.h" | |
18 | #include "AliHLTPHOSValidCellDataStruct.h" | |
19 | #include "AliHLTPHOSConstants.h" | |
20 | #include "TFile.h" | |
21 | #include "TH2F.h" | |
22 | #include "TH2D.h" | |
23 | ||
24 | //ClassImp(AliHLTPHOSChannelCounter); | |
25 | ||
26 | using namespace PhosHLTConst; | |
27 | ||
28 | AliHLTPHOSChannelCounter::AliHLTPHOSChannelCounter() : | |
29 | AliHLTPHOSBase(), | |
30 | // fChannelArrayPtr(0), | |
31 | fHistHighGainPtr(0), | |
32 | fHistLowGainPtr(0), | |
33 | fHistHighRatioPtr(0), | |
34 | fHistLowRatioPtr(0) | |
35 | { | |
ab38011b | 36 | //comment |
5c6503dc | 37 | // fChannelArrayPtr = new UInt_t[N_XCOLUMNS_MOD][N_ZROWS_MOD][N_GAINS]; |
38 | ||
39 | fHistHighGainPtr = new TH2I("highchannelcount", "High gain channel count", | |
40 | 64, 0, 63, 56, 0, 56); | |
41 | fHistLowGainPtr = new TH2I("lowchannelcount", "Low gain channel count", | |
42 | 64, 0, 63, 56, 0, 56); | |
43 | fHistHighRatioPtr = new TH2F("highoutofsync", "High gain channel count divided by number of events", | |
44 | 64, 0, 63, 56, 0, 56); | |
45 | fHistLowRatioPtr = new TH2F("lowoutofsync", "Low gain channel count divided by number of events", | |
46 | 64, 0, 63, 56, 0, 56); | |
47 | ||
1804b020 | 48 | for(UInt_t x = 0; x < N_XCOLUMNS_MOD; x++) |
5c6503dc | 49 | { |
1804b020 | 50 | for(UInt_t z = 0; z < N_ZROWS_MOD; z++) |
5c6503dc | 51 | { |
1804b020 | 52 | for(UInt_t gain = 0; gain < 2; gain++) |
5c6503dc | 53 | { |
54 | fChannelArrayPtr[x][z][gain] = 0; | |
55 | } | |
56 | } | |
57 | } | |
58 | } | |
59 | ||
60 | AliHLTPHOSChannelCounter::~AliHLTPHOSChannelCounter() | |
61 | { | |
ab38011b | 62 | //comment |
5c6503dc | 63 | } |
64 | ||
65 | void | |
66 | AliHLTPHOSChannelCounter::CountChannels(AliHLTPHOSRcuCellEnergyDataStruct* channelDataPtr) | |
67 | { | |
ab38011b | 68 | //comment |
5c6503dc | 69 | Int_t tmp[N_XCOLUMNS_MOD][N_ZROWS_MOD][N_GAINS]; |
1804b020 | 70 | for(UInt_t x = 0; x < N_XCOLUMNS_MOD; x++) |
5c6503dc | 71 | { |
1804b020 | 72 | for(UInt_t z = 0; z < N_ZROWS_MOD; z++) |
5c6503dc | 73 | { |
1804b020 | 74 | for(UInt_t gain = 0; gain < 2; gain++) |
5c6503dc | 75 | { |
76 | tmp[x][z][gain] = 0; | |
77 | } | |
78 | } | |
79 | } | |
80 | for(Int_t i = 0; i < channelDataPtr->fCnt; i++) | |
81 | { | |
82 | AliHLTPHOSValidCellDataStruct *validDataPtr = &(channelDataPtr->fValidData[i]); | |
83 | ||
84 | tmp[validDataPtr->fX + channelDataPtr->fRcuX*N_XCOLUMNS_RCU] | |
85 | [validDataPtr->fZ + channelDataPtr->fRcuZ*N_ZROWS_RCU] | |
86 | [validDataPtr->fGain]++; | |
87 | } | |
1804b020 | 88 | for(UInt_t x = 0; x < N_XCOLUMNS_MOD; x++) |
5c6503dc | 89 | { |
1804b020 | 90 | for(UInt_t z = 0; z < N_ZROWS_MOD; z++) |
5c6503dc | 91 | { |
1804b020 | 92 | for(UInt_t gain = 0; gain < N_ZROWS_MOD; gain++) |
5c6503dc | 93 | { |
94 | if(tmp[x][z][gain] > 1) | |
95 | fChannelArrayPtr[x][z][gain] = fChannelArrayPtr[x][z][gain] + 1; | |
96 | } | |
97 | } | |
98 | } | |
99 | } | |
100 | ||
101 | void | |
102 | AliHLTPHOSChannelCounter::PrintOutOfSyncChannels(Int_t nEvents) | |
103 | { | |
ab38011b | 104 | //comment |
5c6503dc | 105 | printf("After %d events:\n", nEvents); |
1804b020 | 106 | for(UInt_t x = 0; x < N_XCOLUMNS_MOD; x++) |
107 | //for(UInt_t x = 0; x < 63; x++) | |
5c6503dc | 108 | { |
1804b020 | 109 | for(UInt_t z = 0; z < N_ZROWS_MOD; z++) |
110 | //for(UInt_t z = 0; z < 55; z++) | |
5c6503dc | 111 | { |
1804b020 | 112 | for(UInt_t gain = 0; gain < N_GAINS; gain++) |
113 | //for(UInt_t gain = 0; gain < 2; gain++) | |
5c6503dc | 114 | { |
115 | printf("x = %d -- z = %d -- gain = %d: %d\n", x, z, gain, (fChannelArrayPtr[x][z][gain])); | |
116 | } | |
117 | } | |
118 | } | |
119 | printf("\n"); | |
120 | } | |
121 | ||
122 | void | |
123 | AliHLTPHOSChannelCounter::FillHistograms(Int_t nEvents) | |
124 | { | |
ab38011b | 125 | //comment |
5c6503dc | 126 | printf("Filling histograms..."); |
127 | //for(Int_t x = 0; x < N_XCOLUMNS_MOD; x++) | |
128 | for(Int_t x = 0; x < 63; x++) | |
129 | { | |
130 | // for(Int_t z = 0; z < N_ZROWS_MOD; z++) | |
131 | for(Int_t z = 0; z < 55; z++) | |
132 | { | |
133 | for(Int_t gain = 0; gain < 2; gain++) | |
134 | { | |
135 | ||
1804b020 | 136 | if(gain == 0) //TODO: this line was "if(gain = 0)" I presume that was a bug. Please check. |
5c6503dc | 137 | { |
138 | fHistHighGainPtr->SetBinContent(x, z, fChannelArrayPtr[x][z][gain]); | |
139 | fHistHighRatioPtr->SetBinContent(x, z, fChannelArrayPtr[x][z][gain]/(float)nEvents); | |
140 | continue; | |
141 | } | |
142 | ||
143 | fHistLowGainPtr->SetBinContent(x, z, fChannelArrayPtr[x][z][gain]); | |
144 | fHistLowRatioPtr->SetBinContent(x, z, fChannelArrayPtr[x][z][gain]/(float)nEvents); | |
145 | } | |
146 | } | |
147 | } | |
148 | printf("Done!\n"); | |
149 | } | |
150 | ||
151 | void | |
152 | AliHLTPHOSChannelCounter::WriteHistograms(const char* filename) | |
153 | { | |
ab38011b | 154 | //comment |
5c6503dc | 155 | printf("Writing histograms to file..."); |
156 | ||
157 | TFile *outfile = new TFile(filename,"recreate"); | |
158 | ||
159 | fHistHighGainPtr->Write(); | |
160 | fHistLowGainPtr->Write(); | |
161 | fHistHighRatioPtr->Write(); | |
162 | fHistLowRatioPtr->Write(); | |
163 | ||
164 | outfile->Close(); | |
165 | ||
166 | delete outfile; | |
167 | outfile = 0; | |
168 | printf("Done!\n"); | |
169 | } |