1 /**************************************************************************
2 * Copyright(c) 2004, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
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.
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.
30 #include "AliFMDPedestalDA.h"
38 //_____________________________________________________________________
39 ClassImp(AliFMDPedestalDA)
41 //_____________________________________________________________________
42 AliFMDPedestalDA::AliFMDPedestalDA() : AliFMDBaseDA(),
44 fPedSummary("PedestalSummary","pedestals",51200,0,51200),
45 fNoiseSummary("NoiseSummary","noise",51200,0,51200)
47 fOutputFile.open("peds.csv");
51 //_____________________________________________________________________
52 AliFMDPedestalDA::AliFMDPedestalDA(const AliFMDPedestalDA & pedDA) :
55 fPedSummary("PedestalSummary","pedestals",51200,0,51200),
56 fNoiseSummary("NoiseSummary","noise",51200,0,51200)
61 //_____________________________________________________________________
62 AliFMDPedestalDA::~AliFMDPedestalDA()
66 //_____________________________________________________________________
67 void AliFMDPedestalDA::Init()
69 SetRequiredEvents(1000);
72 //_____________________________________________________________________
73 void AliFMDPedestalDA::AddChannelContainer(TObjArray* sectorArray,
80 AliFMDParameters* pars = AliFMDParameters::Instance();
81 Int_t samples = pars->GetSampleRate(det, ring, sec, strip);
82 TObjArray* sampleArray = new TObjArray(samples);
83 for (size_t sample = 0; sample < samples; sample++) {
84 TH1S* hSample = new TH1S(Form("FMD%d%c[%02d,03%d]_%d",
85 det,ring,sec,strip,sample),
86 Form("FMD%d%c[%02d,%03%d]_%d",
89 hSample->SetXTitle("ADC");
90 hSample->SetYTitle("Events");
91 sampleArray->AddAt(hSample, sample);
93 sectorArray->AddAtAndExpand(sampleArray, strip);
95 TH1S* hChannel = new TH1S(Form("hFMD%d%c_%d_%d",det,ring,sec,strip),
96 Form("hFMD%d%c_%d_%d",det,ring,sec,strip),
99 hChannel->SetDirectory(0);
100 sectorArray->AddAtAndExpand(hChannel,strip);
105 //_____________________________________________________________________
106 void AliFMDPedestalDA::FillChannels(AliFMDDigit* digit)
108 UShort_t det = digit->Detector();
109 Char_t ring = digit->Ring();
110 UShort_t sec = digit->Sector();
111 UShort_t strip = digit->Strip();
114 AliFMDParameters* pars = AliFMDParameters::Instance();
115 Int_t samples = pars->GetSampleRate(det, ring, sec, strip);
116 for (size_t sample = 0; sample < samples; sample++) {
117 TH1S* hSample = GetChannel(det, ring, sec, strip, sample);
118 hSample->Fill(digit->Count(sample));
121 TH1S* hChannel = GetChannel(det, ring, sec, strip);
122 hChannel->Fill(digit->Counts());
126 //_____________________________________________________________________
127 void AliFMDPedestalDA::Analyse(UShort_t det,
132 TH1S* hChannel = GetChannel(det, ring, sec, strip);
133 if(hChannel->GetEntries() == 0) {
134 // AliWarning(Form("No entries for FMD%d%c, sector %d, strip %d",
135 // det,ring,sec,strip));
139 AliDebug(50, Form("Fitting FMD%d%c_%d_%d with %d entries",det,ring,sec,strip,
140 hChannel->GetEntries()));
141 TF1 fitFunc("fitFunc","gausn",0,300);
142 fitFunc.SetParameters(100,100,1);
143 hChannel->Fit("fitFunc","Q0+","",10,200);
145 Float_t mean = hChannel->GetMean();
146 Float_t rms = hChannel->GetRMS();
150 hChannel->GetXaxis()->SetRangeUser(mean-5*rms,mean+5*rms);
152 mean = hChannel->GetMean();
153 rms = hChannel->GetRMS();
159 chi2ndf = fitFunc.GetChisquare() / fitFunc.GetNDF();
161 fOutputFile << det << ','
167 << fitFunc.GetParameter(1) << ','
168 << fitFunc.GetParameter(2) << ','
171 if(fSaveHistograms) {
172 gDirectory->cd(GetSectorPath(det, ring, sec, kTRUE));
173 TH1F* sumPed = dynamic_cast<TH1F*>(gDirectory->Get("Pedestals"));
174 TH1F* sumNoise = dynamic_cast<TH1F*>(gDirectory->Get("Noise"));
175 Int_t nStr = (ring == 'I' ? 512 : 256);
177 sumPed = new TH1F("Pedestals",
178 Form("Summary of pedestals in FMD%d%c[%02d]",
181 sumPed->SetXTitle("Strip");
182 sumPed->SetYTitle("Pedestal [ADC]");
183 sumPed->SetDirectory(gDirectory);
186 sumNoise = new TH1F("Noise",
187 Form("Summary of noise in FMD%d%c[%02d]",
190 sumNoise->SetXTitle("Strip");
191 sumNoise->SetYTitle("Noise [ADC]");
193 sumNoise->SetDirectory(gDirectory);
195 sumPed->SetBinContent(strip+1, mean);
196 sumPed->SetBinError(strip+1, rms);
197 sumNoise->SetBinContent(strip+1, rms);
199 if(sumNoise->GetEntries() == nStr)
200 sumNoise->Write(sumNoise->GetName(),TObject::kOverwrite);
201 if(sumPed->GetEntries() == nStr)
202 sumPed->Write(sumPed->GetName(),TObject::kOverwrite);
204 fPedSummary.SetBinContent(fCurrentChannel,mean);
205 fNoiseSummary.SetBinContent(fCurrentChannel,rms);
208 gDirectory->cd(GetStripPath(det, ring, sec, strip, kTRUE));
209 hChannel->GetXaxis()->SetRange(1,1024);
216 //_____________________________________________________________________
217 void AliFMDPedestalDA::Terminate(TFile* diagFile)
222 fNoiseSummary.Write();
226 //_____________________________________________________________________
227 void AliFMDPedestalDA::WriteHeaderToFile()
229 AliFMDParameters* pars = AliFMDParameters::Instance();
230 fOutputFile.write(Form("# %s \n",pars->GetPedestalShuttleID()),13);
231 fOutputFile.write("# Detector, "
242 //_____________________________________________________________________
243 TH1S* AliFMDPedestalDA::GetChannel(UShort_t det,
248 UShort_t iring = (ring == 'O' ? 0 : 1);
249 TObjArray* detArray = static_cast<TObjArray*>(fDetectorArray.At(det));
250 TObjArray* ringArray = static_cast<TObjArray*>(detArray->At(iring));
251 TObjArray* secArray = static_cast<TObjArray*>(ringArray->At(sec));
253 AliFMDParameters* pars = AliFMDParameters::Instance();
254 Int_t samples = pars->GetSampleRate(det, ring, sec, strip);
255 TObjArray* sampleArray = static_cast<TObjArray*>(secArray->At(strip));
256 TH1S* hSample = static_cast<TH1S*>(sampleArray->At(sample));
259 TH1S* hChannel = static_cast<TH1S*>(secArray->At(strip));
264 //_____________________________________________________________________