]>
Commit | Line | Data |
---|---|---|
3bd993ba | 1 | /************************************************************************** |
2 | * Copyright(c) 2004, 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 | /** @file AliFMDPedestalDA.cxx | |
17 | @author Hans Hjersing Dalsgaard <canute@nbi.dk> | |
18 | @date Mon Mar 10 09:46:05 2008 | |
19 | @brief Derived class for the pedestal detector algorithm. | |
20 | */ | |
21 | // | |
e9c06036 | 22 | // This class implements the virtual functions of the AliFMDBaseDA |
23 | // class. The most important of these functions, FillChannels(..) and | |
24 | // Analyse(...) collect and analyse the data of each channel. The | |
25 | // resulting pedestal and noise values are written to a comma | |
26 | // separated values (csv) file on the go. The csv files produced in | |
27 | // this way are the basic input to the AliFMDPreprocessor. | |
3bd993ba | 28 | // |
29 | ||
30 | #include "AliFMDPedestalDA.h" | |
31 | #include "iostream" | |
32 | #include "fstream" | |
33 | #include "AliLog.h" | |
34 | #include "TF1.h" | |
f7f0b643 | 35 | #include "TObject.h" |
3bd993ba | 36 | |
37 | //_____________________________________________________________________ | |
38 | ClassImp(AliFMDPedestalDA) | |
39 | ||
40 | //_____________________________________________________________________ | |
f7f0b643 | 41 | AliFMDPedestalDA::AliFMDPedestalDA() : AliFMDBaseDA(), |
f14ede67 | 42 | fCurrentChannel(1), |
f7f0b643 | 43 | fPedSummary("PedestalSummary","pedestals",51200,0,51200), |
44 | fNoiseSummary("NoiseSummary","noise",51200,0,51200) | |
3bd993ba | 45 | { |
46 | fOutputFile.open("peds.csv"); | |
47 | ||
48 | } | |
49 | ||
50 | //_____________________________________________________________________ | |
51 | AliFMDPedestalDA::AliFMDPedestalDA(const AliFMDPedestalDA & pedDA) : | |
f7f0b643 | 52 | AliFMDBaseDA(pedDA), |
f14ede67 | 53 | fCurrentChannel(1), |
f7f0b643 | 54 | fPedSummary("PedestalSummary","pedestals",51200,0,51200), |
55 | fNoiseSummary("NoiseSummary","noise",51200,0,51200) | |
3bd993ba | 56 | { |
57 | ||
58 | } | |
59 | ||
60 | //_____________________________________________________________________ | |
e9c06036 | 61 | AliFMDPedestalDA::~AliFMDPedestalDA() |
62 | { | |
3bd993ba | 63 | } |
64 | ||
65 | //_____________________________________________________________________ | |
e9c06036 | 66 | void AliFMDPedestalDA::Init() |
67 | { | |
3bd993ba | 68 | SetRequiredEvents(1000); |
69 | } | |
70 | ||
71 | //_____________________________________________________________________ | |
72 | void AliFMDPedestalDA::AddChannelContainer(TObjArray* sectorArray, | |
73 | UShort_t det, | |
e9c06036 | 74 | Char_t ring, |
3bd993ba | 75 | UShort_t sec, |
e9c06036 | 76 | UShort_t strip) |
77 | { | |
78 | #ifdef USE_SAMPLES | |
79 | AliFMDParameters* pars = AliFMDParameters::Instance(); | |
80 | Int_t samples = pars->GetSampleRate(det, ring, sec, strip); | |
81 | TObjArray* sampleArray = new TObjArray(samples); | |
82 | for (size_t sample = 0; sample < samples; sample++) { | |
83 | TH1S* hSample = new TH1S(Form("FMD%d%c[%02d,03%d]_%d", | |
84 | det,ring,sec,strip,sample), | |
85 | Form("FMD%d%c[%02d,%03%d]_%d", | |
86 | det,ring,sec,strip), | |
87 | 1024,-.5,1023.5); | |
88 | hSample->SetXTitle("ADC"); | |
89 | hSample->SetYTitle("Events"); | |
90 | sampleArray->AddAt(hSample, sample); | |
91 | } | |
92 | sectorArray->AddAtAndExpand(sampleArray, strip); | |
93 | #else | |
3bd993ba | 94 | TH1S* hChannel = new TH1S(Form("hFMD%d%c_%d_%d",det,ring,sec,strip), |
95 | Form("hFMD%d%c_%d_%d",det,ring,sec,strip), | |
e9c06036 | 96 | 1024,-.5,1023.5); |
3bd993ba | 97 | |
98 | hChannel->SetDirectory(0); | |
99 | sectorArray->AddAtAndExpand(hChannel,strip); | |
e9c06036 | 100 | #endif |
101 | ||
3bd993ba | 102 | } |
103 | ||
104 | //_____________________________________________________________________ | |
e9c06036 | 105 | void AliFMDPedestalDA::FillChannels(AliFMDDigit* digit) |
106 | { | |
3bd993ba | 107 | UShort_t det = digit->Detector(); |
108 | Char_t ring = digit->Ring(); | |
109 | UShort_t sec = digit->Sector(); | |
110 | UShort_t strip = digit->Strip(); | |
e9c06036 | 111 | |
112 | #ifdef USE_SAMPLES | |
113 | AliFMDParameters* pars = AliFMDParameters::Instance(); | |
114 | Int_t samples = pars->GetSampleRate(det, ring, sec, strip); | |
115 | for (size_t sample = 0; sample < samples; sample++) { | |
116 | TH1S* hSample = GetChannel(det, ring, sec, strip, sample); | |
117 | hSample->Fill(digit->Count(sample)); | |
118 | } | |
119 | #else | |
120 | TH1S* hChannel = GetChannel(det, ring, sec, strip); | |
3bd993ba | 121 | hChannel->Fill(digit->Counts()); |
e9c06036 | 122 | #endif |
3bd993ba | 123 | } |
124 | ||
125 | //_____________________________________________________________________ | |
126 | void AliFMDPedestalDA::Analyse(UShort_t det, | |
e9c06036 | 127 | Char_t ring, |
3bd993ba | 128 | UShort_t sec, |
129 | UShort_t strip) { | |
130 | ||
131 | TH1S* hChannel = GetChannel(det, ring, sec, strip); | |
80fdb9f3 | 132 | if(hChannel->GetEntries() == 0) { |
e9c06036 | 133 | // AliWarning(Form("No entries for FMD%d%c, sector %d, strip %d", |
134 | // det,ring,sec,strip)); | |
3bd993ba | 135 | return; |
136 | } | |
80fdb9f3 | 137 | |
e9c06036 | 138 | AliDebug(50, Form("Fitting FMD%d%c_%d_%d with %d entries",det,ring,sec,strip, |
139 | hChannel->GetEntries())); | |
3bd993ba | 140 | |
141 | Float_t mean = hChannel->GetMean(); | |
142 | Float_t rms = hChannel->GetRMS(); | |
143 | ||
80fdb9f3 | 144 | hChannel->GetXaxis()->SetRangeUser(mean-4*rms,mean+4*rms); |
3bd993ba | 145 | |
146 | mean = hChannel->GetMean(); | |
147 | rms = hChannel->GetRMS(); | |
148 | ||
e9c06036 | 149 | hChannel->Fit("gaus","Q0+","",mean-5*rms,mean+5*rms); |
3bd993ba | 150 | TF1* fitFunc = hChannel->GetFunction("gaus"); |
151 | ||
3bd993ba | 152 | Float_t chi2ndf = 0; |
153 | if(fitFunc->GetNDF()) | |
154 | chi2ndf = fitFunc->GetChisquare() / fitFunc->GetNDF(); | |
e9c06036 | 155 | |
f7f0b643 | 156 | fOutputFile << det << ',' |
157 | << ring << ',' | |
158 | << sec << ',' | |
159 | << strip << ',' | |
3bd993ba | 160 | << mean << ',' |
161 | << rms << ',' | |
162 | << fitFunc->GetParameter(1) << ',' | |
163 | << fitFunc->GetParameter(2) << ',' | |
164 | << chi2ndf <<"\n"; | |
165 | ||
166 | if(fSaveHistograms) { | |
e9c06036 | 167 | gDirectory->cd(GetSectorPath(det, ring, sec, kTRUE)); |
168 | TH1F* sumPed = dynamic_cast<TH1F*>(gDirectory->Get("Pedestals")); | |
169 | TH1F* sumNoise = dynamic_cast<TH1F*>(gDirectory->Get("Noise")); | |
170 | Int_t nStr = (ring == 'I' ? 512 : 256); | |
171 | if (!sumPed) { | |
172 | sumPed = new TH1F("Pedestals", | |
173 | Form("Summary of pedestals in FMD%d%c[%02d]", | |
174 | det, ring, sec), | |
175 | nStr, -.5, nStr-.5); | |
176 | sumPed->SetXTitle("Strip"); | |
177 | sumPed->SetYTitle("Pedestal [ADC]"); | |
178 | sumPed->SetDirectory(gDirectory); | |
179 | } | |
180 | if (!sumNoise) { | |
181 | sumNoise = new TH1F("Noise", | |
182 | Form("Summary of noise in FMD%d%c[%02d]", | |
183 | det, ring, sec), | |
184 | nStr, -.5, nStr-.5); | |
185 | sumNoise->SetXTitle("Strip"); | |
186 | sumNoise->SetYTitle("Noise [ADC]"); | |
f7f0b643 | 187 | |
e9c06036 | 188 | sumNoise->SetDirectory(gDirectory); |
189 | } | |
190 | sumPed->SetBinContent(strip+1, mean); | |
191 | sumPed->SetBinError(strip+1, rms); | |
192 | sumNoise->SetBinContent(strip+1, rms); | |
f7f0b643 | 193 | |
194 | if(sumNoise->GetEntries() == nStr) | |
195 | sumNoise->Write(sumNoise->GetName(),TObject::kOverwrite); | |
196 | if(sumPed->GetEntries() == nStr) | |
197 | sumPed->Write(sumPed->GetName(),TObject::kOverwrite); | |
198 | ||
199 | fPedSummary.SetBinContent(fCurrentChannel,mean); | |
200 | fNoiseSummary.SetBinContent(fCurrentChannel,rms); | |
201 | fCurrentChannel++; | |
202 | ||
e9c06036 | 203 | gDirectory->cd(GetStripPath(det, ring, sec, strip, kTRUE)); |
f7f0b643 | 204 | hChannel->GetXaxis()->SetRange(1,1024); |
205 | ||
3bd993ba | 206 | hChannel->Write(); |
e9c06036 | 207 | } |
3bd993ba | 208 | } |
209 | ||
f7f0b643 | 210 | //_____________________________________________________________________ |
211 | void AliFMDPedestalDA::Terminate(TFile* diagFile) | |
212 | { | |
213 | diagFile->cd(); | |
214 | ||
215 | fPedSummary.Write(); | |
216 | fNoiseSummary.Write(); | |
217 | ||
218 | } | |
219 | ||
3bd993ba | 220 | //_____________________________________________________________________ |
e9c06036 | 221 | void AliFMDPedestalDA::WriteHeaderToFile() |
222 | { | |
80fdb9f3 | 223 | AliFMDParameters* pars = AliFMDParameters::Instance(); |
224 | fOutputFile.write(Form("# %s \n",pars->GetPedestalShuttleID()),13); | |
f7f0b643 | 225 | fOutputFile.write("# Detector, " |
226 | "Ring, " | |
227 | "Sector, " | |
e9c06036 | 228 | "Strip, " |
e9c06036 | 229 | "Pedestal, " |
230 | "Noise, " | |
231 | "Mu, " | |
232 | "Sigma, " | |
f7f0b643 | 233 | "Chi2/NDF \n", 71); |
3bd993ba | 234 | } |
235 | ||
236 | //_____________________________________________________________________ | |
e9c06036 | 237 | TH1S* AliFMDPedestalDA::GetChannel(UShort_t det, |
238 | Char_t ring, | |
239 | UShort_t sec, | |
240 | UShort_t strip) | |
241 | { | |
242 | UShort_t iring = (ring == 'O' ? 0 : 1); | |
3bd993ba | 243 | TObjArray* detArray = static_cast<TObjArray*>(fDetectorArray.At(det)); |
e9c06036 | 244 | TObjArray* ringArray = static_cast<TObjArray*>(detArray->At(iring)); |
3bd993ba | 245 | TObjArray* secArray = static_cast<TObjArray*>(ringArray->At(sec)); |
e9c06036 | 246 | #ifdef USE_SAMPLES |
247 | AliFMDParameters* pars = AliFMDParameters::Instance(); | |
248 | Int_t samples = pars->GetSampleRate(det, ring, sec, strip); | |
249 | TObjArray* sampleArray = static_cast<TObjArray*>(secArray->At(strip)); | |
250 | TH1S* hSample = static_cast<TH1S*>(sampleArray->At(sample)); | |
251 | return hSample; | |
252 | #else | |
253 | TH1S* hChannel = static_cast<TH1S*>(secArray->At(strip)); | |
3bd993ba | 254 | return hChannel; |
e9c06036 | 255 | #endif |
3bd993ba | 256 | } |
257 | //_____________________________________________________________________ | |
258 | // | |
259 | //EOF | |
260 | // |