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 class.
23 // The most important of these functions, FillChannels(..) and Analyse(...) collect
24 // and analyse the data of each channel. The resulting pedestal and noise values are
25 // written to a comma separated values (csv) file on the go. The csv files produced
26 // in this way are the basic input to the AliFMDPreprocessor.
29 #include "AliFMDPedestalDA.h"
35 //_____________________________________________________________________
36 ClassImp(AliFMDPedestalDA)
38 //_____________________________________________________________________
39 AliFMDPedestalDA::AliFMDPedestalDA() : AliFMDBaseDA()
41 fOutputFile.open("peds.csv");
45 //_____________________________________________________________________
46 AliFMDPedestalDA::AliFMDPedestalDA(const AliFMDPedestalDA & pedDA) :
52 //_____________________________________________________________________
53 AliFMDPedestalDA::~AliFMDPedestalDA() {
57 //_____________________________________________________________________
58 void AliFMDPedestalDA::Init() {
60 SetRequiredEvents(1000);
63 //_____________________________________________________________________
64 void AliFMDPedestalDA::AddChannelContainer(TObjArray* sectorArray,
70 TH1S* hChannel = new TH1S(Form("hFMD%d%c_%d_%d",det,ring,sec,strip),
71 Form("hFMD%d%c_%d_%d",det,ring,sec,strip),
74 hChannel->SetDirectory(0);
75 sectorArray->AddAtAndExpand(hChannel,strip);
78 //_____________________________________________________________________
79 void AliFMDPedestalDA::FillChannels(AliFMDDigit* digit) {
80 UShort_t det = digit->Detector();
81 Char_t ring = digit->Ring();
82 UShort_t sec = digit->Sector();
83 UShort_t strip = digit->Strip();
85 TH1S* hChannel = GetChannel(det, ring, sec, strip);
86 hChannel->Fill(digit->Counts());
90 //_____________________________________________________________________
91 void AliFMDPedestalDA::Analyse(UShort_t det,
96 TH1S* hChannel = GetChannel(det, ring, sec, strip);
97 if(hChannel->GetEntries() == 0) {
98 // AliWarning(Form("No entries for FMD%d%c, sector %d, strip %d",det,ring,sec,strip));
102 //std::cout<<"Fitting Channel #"<<Form("FMD%d%c_%d_%d",det,ring,sec,strip)<<" with "<<hChannel->GetEntries()<<" entries \r"<<std::flush;
104 Float_t mean = hChannel->GetMean();
105 Float_t rms = hChannel->GetRMS();
107 hChannel->GetXaxis()->SetRangeUser(mean-4*rms,mean+4*rms);
109 mean = hChannel->GetMean();
110 rms = hChannel->GetRMS();
112 hChannel->Fit("gaus","QO","QO",mean-5*rms,mean+5*rms);
113 TF1* fitFunc = hChannel->GetFunction("gaus");
115 UInt_t ddl, board, chip, channel;
117 UShort_t relStrip = strip%128;
118 AliFMDParameters* pars = AliFMDParameters::Instance();
119 pars->Detector2Hardware(det,ring,sec,strip,ddl,board,chip,channel);
121 if(fitFunc->GetNDF())
122 chi2ndf = fitFunc->GetChisquare() / fitFunc->GetNDF();
123 ddl = ddl + kBaseDDL;
125 fOutputFile << ddl << ','
134 << fitFunc->GetParameter(1) << ','
135 << fitFunc->GetParameter(2) << ','
138 if(fSaveHistograms) {
139 gDirectory->cd(Form("%s:FMD%d%c/sector_%d/strip_%d",fDiagnosticsFilename.Data(),det,ring,sec,strip));
140 hChannel->GetXaxis()->SetRange(0,1023);
147 //_____________________________________________________________________
148 void AliFMDPedestalDA::WriteHeaderToFile() {
149 AliFMDParameters* pars = AliFMDParameters::Instance();
150 fOutputFile.write(Form("# %s \n",pars->GetPedestalShuttleID()),13);
151 fOutputFile.write("# Rcu, Board, Chip, Channel, Strip, Sample, TimeBin, Pedestal, Noise, Mu, Sigma, Chi2/NDF \n",91);
155 //_____________________________________________________________________
156 TH1S* AliFMDPedestalDA::GetChannel(UShort_t det, Char_t ring, UShort_t sec, UShort_t strip) {
163 TObjArray* detArray = static_cast<TObjArray*>(fDetectorArray.At(det));
164 TObjArray* ringArray = static_cast<TObjArray*>(detArray->At(Ring));
165 TObjArray* secArray = static_cast<TObjArray*>(ringArray->At(sec));
166 TH1S* hChannel = static_cast<TH1S*>(secArray->At(strip));
170 //_____________________________________________________________________