From e9c06036f878d84c74f9d9345fae109f01bb6888 Mon Sep 17 00:00:00 2001 From: cholm Date: Tue, 27 May 2008 15:03:26 +0000 Subject: [PATCH] Fixes to DAs --- FMD/AliFMDBaseDA.cxx | 210 +++++++++++++++++++++-------------- FMD/AliFMDBaseDA.h | 34 ++++-- FMD/AliFMDGainDA.cxx | 55 ++++++--- FMD/AliFMDPedestalDA.cxx | 156 +++++++++++++++++++------- FMD/scripts/TestPedestalDA.C | 53 +++++++-- 5 files changed, 349 insertions(+), 159 deletions(-) diff --git a/FMD/AliFMDBaseDA.cxx b/FMD/AliFMDBaseDA.cxx index 10457f06aa1..e6793602ce1 100644 --- a/FMD/AliFMDBaseDA.cxx +++ b/FMD/AliFMDBaseDA.cxx @@ -19,10 +19,11 @@ @brief Base class for detector algorithms. */ // -//This is the implementation of the (virtual) base class for the FMD detector -//algorithms(DA). It implements the creation of the relevant containers and handles the -//loop over the raw data. The derived classes can control the parameters and action -//to be taken making this the base class for the Pedestal, Gain and Physics DA. +// This is the implementation of the (virtual) base class for the FMD +// detector algorithms(DA). It implements the creation of the relevant +// containers and handles the loop over the raw data. The derived +// classes can control the parameters and action to be taken making +// this the base class for the Pedestal, Gain and Physics DA. // #include "AliFMDBaseDA.h" @@ -33,6 +34,52 @@ #include "AliLog.h" //_____________________________________________________________________ ClassImp(AliFMDBaseDA) +#if 0 +; // Do not delete - to let Emacs for mat the code +#endif + +//_____________________________________________________________________ +const char* +AliFMDBaseDA::GetStripPath(UShort_t det, + Char_t ring, + UShort_t sec, + UShort_t str, + Bool_t full) const +{ + return Form("%s%sFMD%d%c[%02d,%03d]", + (full ? GetSectorPath(det, ring, sec, full) : ""), + (full ? "/" : ""), det, ring, sec, str); +} +//_____________________________________________________________________ +const char* +AliFMDBaseDA::GetSectorPath(UShort_t det, + Char_t ring, + UShort_t sec, + Bool_t full) const +{ + return Form("%s%sFMD%d%c[%02d]", + (full ? GetRingPath(det, ring, full) : ""), + (full ? "/" : ""), det, ring, sec); +} +//_____________________________________________________________________ +const char* +AliFMDBaseDA::GetRingPath(UShort_t det, + Char_t ring, + Bool_t full) const +{ + return Form("%s%sFMD%d%c", + (full ? GetDetectorPath(det, full) : ""), + (full ? "/" : ""), det, ring); +} +//_____________________________________________________________________ +const char* +AliFMDBaseDA::GetDetectorPath(UShort_t det, + Bool_t full) const +{ + return Form("%s%sFMD%d", + (full ? fDiagnosticsFilename.Data() : ""), + (full ? ":/" : ""), det); +} //_____________________________________________________________________ AliFMDBaseDA::AliFMDBaseDA() : TNamed(), @@ -64,132 +111,111 @@ AliFMDBaseDA::AliFMDBaseDA(const AliFMDBaseDA & baseDA) : //_____________________________________________________________________ -AliFMDBaseDA::~AliFMDBaseDA() { - +AliFMDBaseDA::~AliFMDBaseDA() +{ //destructor - } //_____________________________________________________________________ -void AliFMDBaseDA::Run(AliRawReader* reader) { - - - - InitContainer(); +void AliFMDBaseDA::Run(AliRawReader* reader) +{ + TFile* diagFile = 0; + if (fSaveHistograms) + diagFile = TFile::Open(fDiagnosticsFilename.Data(),"RECREATE"); + InitContainer(diagFile); Init(); - TFile* diagFile = 0; - if(fSaveHistograms) - { - diagFile = TFile::Open(fDiagnosticsFilename.Data(),"RECREATE"); - for(UShort_t det=1;det<=3;det++) { - UShort_t FirstRing = (det == 1 ? 1 : 0); - - for (UShort_t ir = FirstRing; ir < 2; ir++) { - Char_t ring = (ir == 0 ? 'O' : 'I'); - UShort_t nsec = (ir == 0 ? 40 : 20); - UShort_t nstr = (ir == 0 ? 256 : 512); - - gDirectory->cd(Form("%s:/",fDiagnosticsFilename.Data())); - gDirectory->mkdir(Form("FMD%d%c",det,ring),Form("FMD%d%c",det,ring)); - for(UShort_t sec =0; sec < nsec; sec++) { - gDirectory->cd(Form("%s:/FMD%d%c",fDiagnosticsFilename.Data(),det,ring)); - gDirectory->mkdir(Form("sector_%d",sec)); - for(UShort_t strip = 0; strip < nstr; strip++) { - gDirectory->cd(Form("%s:/FMD%d%c/sector_%d",fDiagnosticsFilename.Data(),det,ring,sec)); - gDirectory->mkdir(Form("strip_%d",strip)); - - } - } - } - } - - } - + reader->Reset(); - - - AliFMDRawReader* fmdReader = new AliFMDRawReader(reader,0); - TClonesArray* digitArray = new TClonesArray("AliFMDDigit",0); + AliFMDRawReader* fmdReader = new AliFMDRawReader(reader,0); + TClonesArray* digitArray = new TClonesArray("AliFMDDigit",0); WriteConditionsData(); - reader->NextEvent(); - reader->NextEvent(); + reader->NextEvent(); // Read Start-of-Run event + reader->NextEvent(); // Read Start-of-Files event int lastProgress = 0; - for(Int_t n =1;n <= GetRequiredEvents(); n++) - { - if(!reader->NextEvent()) - continue; - - SetCurrentEvent(*(reader->GetEventId())); - - digitArray->Clear(); - fmdReader->ReadAdcs(digitArray); - - - //std::cout<<"In event # "<< *(reader->GetEventId()) << " with " <GetEntries()<<" digits \r"<GetEntriesFast();i++) { - AliFMDDigit* digit = static_cast(digitArray->At(i)); - FillChannels(digit); - } - - FinishEvent(); - int progress = int((n *100)/ GetRequiredEvents()) ; - if (progress <= lastProgress) continue; - lastProgress = progress; - std::cout << "Progress: " << lastProgress << " / 100 " << std::endl; - - - + for(Int_t n =1;n <= GetRequiredEvents(); n++) { + if(!reader->NextEvent()) continue; + + SetCurrentEvent(*(reader->GetEventId())); + + digitArray->Clear(); + fmdReader->ReadAdcs(digitArray); + + AliDebug(5, Form("In event # %d with %d entries", + *(reader->GetEventId()), digitArray->GetEntriesFast())); + + for(Int_t i = 0; iGetEntriesFast();i++) { + AliFMDDigit* digit = static_cast(digitArray->At(i)); + FillChannels(digit); } + + FinishEvent(); + int progress = int((n *100)/ GetRequiredEvents()) ; + if (progress <= lastProgress) continue; + lastProgress = progress; + std::cout << "Progress: " << lastProgress << " / 100 " << std::endl; + } + AliInfo(Form("Looped over %d events",GetCurrentEvent())); WriteHeaderToFile(); for(UShort_t det=1;det<=3;det++) { + std::cout << "FMD" << det << std::endl; UShort_t FirstRing = (det == 1 ? 1 : 0); for (UShort_t ir = FirstRing; ir < 2; ir++) { Char_t ring = (ir == 0 ? 'O' : 'I'); UShort_t nsec = (ir == 0 ? 40 : 20); UShort_t nstr = (ir == 0 ? 256 : 512); + std::cout << " Ring " << ring << ": " << std::flush; for(UShort_t sec =0; sec < nsec; sec++) { for(UShort_t strip = 0; strip < nstr; strip++) { Analyse(det,ring,sec,strip); - } + std::cout << '.' << std::flush; } + diagFile->Flush(); + std::cout << "done" << std::endl; } } if(fOutputFile.is_open()) { - fOutputFile.write("# EOF\n",6); fOutputFile.close(); - } if(fSaveHistograms ) { - AliInfo("Closing diagnostics file...please wait"); + AliInfo("Closing diagnostics file - please wait ..."); + // diagFile->Write(); diagFile->Close(); + AliInfo("done"); } } //_____________________________________________________________________ -void AliFMDBaseDA::InitContainer(){ - +void AliFMDBaseDA::InitContainer(TDirectory* diagFile) +{ TObjArray* detArray; TObjArray* ringArray; TObjArray* sectorArray; + TDirectory* savDir = gDirectory; + for(UShort_t det=1;det<=3;det++) { detArray = new TObjArray(); detArray->SetOwner(); fDetectorArray.AddAtAndExpand(detArray,det); + + TDirectory* detDir = 0; + if (diagFile) { + diagFile->cd(); + detDir = diagFile->mkdir(GetDetectorPath(det, kFALSE)); + } + UShort_t FirstRing = (det == 1 ? 1 : 0); for (UShort_t ir = FirstRing; ir < 2; ir++) { Char_t ring = (ir == 0 ? 'O' : 'I'); @@ -198,21 +224,43 @@ void AliFMDBaseDA::InitContainer(){ ringArray = new TObjArray(); ringArray->SetOwner(); detArray->AddAtAndExpand(ringArray,ir); + + + TDirectory* ringDir = 0; + if (detDir) { + detDir->cd(); + ringDir = detDir->mkdir(GetRingPath(det,ring, kFALSE)); + } + + for(UShort_t sec =0; sec < nsec; sec++) { sectorArray = new TObjArray(); sectorArray->SetOwner(); ringArray->AddAtAndExpand(sectorArray,sec); + + + TDirectory* secDir = 0; + if (ringDir) { + ringDir->cd(); + secDir = ringDir->mkdir(GetSectorPath(det, ring, sec, kFALSE)); + } + for(UShort_t strip = 0; strip < nstr; strip++) { + if (secDir) { + secDir->cd(); + secDir->mkdir(GetStripPath(det, ring, sec, strip, kFALSE)); + } AddChannelContainer(sectorArray, det, ring, sec, strip); } } } } + savDir->cd(); } //_____________________________________________________________________ -void AliFMDBaseDA::WriteConditionsData() { - +void AliFMDBaseDA::WriteConditionsData() +{ AliFMDParameters* pars = AliFMDParameters::Instance(); fConditionsFile.write(Form("# %s \n",pars->GetConditionsShuttleID()),14); fConditionsFile.write("# Sample Rate, timebins \n",25); diff --git a/FMD/AliFMDBaseDA.h b/FMD/AliFMDBaseDA.h index e1923d3aa60..fcea581fd7b 100644 --- a/FMD/AliFMDBaseDA.h +++ b/FMD/AliFMDBaseDA.h @@ -1,3 +1,4 @@ +// -*- mode: C++ -*- #ifndef ALIFMDBASEDA_H #define ALIFMDBASEDA_H @@ -7,13 +8,16 @@ * See cxx source for full Copyright notice */ // -//This class provides a base interface for the Detector Algorithms (DA) of the FMD. -//At least three implementations are needed: AliFMDPedestalDA, AliFMDGainDA and AliFMDPhysicsDA . -//These classes will provide the calibration data for the AliFMDPreprocessor to be used in the shuttle. -//The input for this class are raw data (AliRawReader) and the output is a comma-separated file -//(std::ofstream) that contains the values defined in the implementations of this class. +// This class provides a base interface for the Detector Algorithms +// (DA) of the FMD. At least three implementations are needed: +// AliFMDPedestalDA, AliFMDGainDA and AliFMDPhysicsDA . These classes +// will provide the calibration data for the AliFMDPreprocessor to be +// used in the shuttle. The input for this class are raw data +// (AliRawReader) and the output is a comma-separated file +// (std::ofstream) that contains the values defined in the +// implementations of this class. // -//Author: Hans Hjersing Dalsgaard, hans.dalsgaard@cern.ch +// Author: Hans Hjersing Dalsgaard, hans.dalsgaard@cern.ch // #include "TNamed.h" @@ -26,11 +30,12 @@ #include "AliRawReader.h" #include "AliFMDDigit.h" #include "AliFMDParameters.h" +class TDirectory; class AliFMDBaseDA: public TNamed { - public: +public: AliFMDBaseDA() ; AliFMDBaseDA(const AliFMDBaseDA & baseDA) ; // AliFMDBaseDA& operator = (const AliFMDBaseDA & baseDA) ; @@ -41,7 +46,7 @@ class AliFMDBaseDA: public TNamed { void SetSaveDiagnostics(Bool_t save) {fSaveHistograms = save;} void SetRequiredEvents(Int_t nEvents) {fRequiredEvents = nEvents;} Int_t GetRequiredEvents() {return fRequiredEvents ;} - protected: +protected: virtual void Init() {}; virtual void FillChannels(AliFMDDigit* ) {}; @@ -61,15 +66,22 @@ class AliFMDBaseDA: public TNamed { Bool_t fSaveHistograms; TObjArray fDetectorArray; + const char* GetDetectorPath(UShort_t det, Bool_t full=kTRUE) const; + const char* GetRingPath(UShort_t det, Char_t ring, Bool_t full=kTRUE) const; + const char* GetSectorPath(UShort_t det, Char_t ring, UShort_t sec, + Bool_t full=kTRUE) const; + const char* GetStripPath(UShort_t det, Char_t ring, UShort_t sec, + UShort_t str, Bool_t full=kTRUE) const; - private: +private: void WriteConditionsData(); void SetCurrentEvent(Int_t currentEvent) {fCurrentEvent = currentEvent; } - void InitContainer(); + void InitContainer(TDirectory* dir); Int_t fRequiredEvents; Int_t fCurrentEvent; - + + ClassDef(AliFMDBaseDA,0) }; diff --git a/FMD/AliFMDGainDA.cxx b/FMD/AliFMDGainDA.cxx index 7a0b9f2ffa3..dd9372e6dda 100644 --- a/FMD/AliFMDGainDA.cxx +++ b/FMD/AliFMDGainDA.cxx @@ -149,7 +149,7 @@ void AliFMDGainDA::FillChannels(AliFMDDigit* digit) { //_____________________________________________________________________ void AliFMDGainDA::Analyse(UShort_t det, - Char_t ring, + Char_t ring, UShort_t sec, UShort_t strip) { TGraphErrors* grChannel = GetChannel(det,ring,sec,strip); @@ -160,7 +160,7 @@ void AliFMDGainDA::Analyse(UShort_t det, } TF1 fitFunc("fitFunc","pol1",-10,280); fitFunc.SetParameters(100,3); - grChannel->Fit("fitFunc","Q","Q",0,fHighPulse); + grChannel->Fit("fitFunc","Q0+","",0,fHighPulse); AliFMDParameters* pars = AliFMDParameters::Instance(); UInt_t ddl, board,chip,channel; pars->Detector2Hardware(det,ring,sec,strip,ddl,board,chip,channel); @@ -183,28 +183,51 @@ void AliFMDGainDA::Analyse(UShort_t det, if(fSaveHistograms) { - gDirectory->cd(Form("%s:FMD%d%c/sector_%d/strip_%d", - fDiagnosticsFilename.Data(),det,ring,sec,strip)); - grChannel->Write(Form("grFMD%d%c_%d_%d",det,ring,sec,strip)); - } - - - + gDirectory->cd(GetSectorPath(det,ring, sec, kTRUE)); + + TH1F* summary = dynamic_cast(gDirectory->Get("Summary")); + if (!summary) { + Int_t nStr = (ring == 'I' ? 512 : 256); + summary = new TH1F("Summary", Form("Summary of gains in FMD%d%c[%02d]", + det, ring, sec), + nStr, -.5, nStr-.5); + summary->SetXTitle("Strip"); + summary->SetYTitle("Gain [ADC/DAC]"); + summary->SetDirectory(gDirectory); + } + summary->SetBinContent(strip+1, fitFunc.GetParameter(1)); + summary->SetBinError(strip+1, fitFunc.GetParError(1)); + + gDirectory->cd(GetStripPath(det,ring,sec,strip, kTRUE)); + grChannel->SetName(Form("FMD%d%c[%02d,%03d]",det,ring,sec,strip)); + // grChannel->SetDirectory(gDirectory); + grChannel->Write(); + // grChannel->Write(Form("grFMD%d%c_%d_%d",det,ring,sec,strip)); + } } //_____________________________________________________________________ -void AliFMDGainDA::WriteHeaderToFile() { +void AliFMDGainDA::WriteHeaderToFile() +{ AliFMDParameters* pars = AliFMDParameters::Instance(); fOutputFile.write(Form("# %s \n",pars->GetGainShuttleID()),9); - fOutputFile.write("# Rcu, Board, Chip, Channel, Strip, Gain, Error, Chi2/NDF \n",59); + fOutputFile.write("# Rcu, " + "Board, " + "Chip, " + "Channel, " + "Strip, " + "Gain, " + "Error, " + "Chi2/NDF \n",59); } //_____________________________________________________________________ TH1S* AliFMDGainDA::GetChannelHistogram(UShort_t det, - Char_t ring, + Char_t ring, UShort_t sec, - UShort_t strip) { + UShort_t strip) +{ UShort_t Ring = 1; if(ring == 'O') @@ -221,10 +244,10 @@ TH1S* AliFMDGainDA::GetChannelHistogram(UShort_t det, //_____________________________________________________________________ TGraphErrors* AliFMDGainDA::GetChannel(UShort_t det, - Char_t ring, + Char_t ring, UShort_t sec, - UShort_t strip) { - + UShort_t strip) +{ UShort_t iring = (ring == 'O' ? 0 : 1); TObjArray* detArray = static_cast(fDetectorArray.At(det)); TObjArray* ringArray = static_cast(detArray->At(iring)); diff --git a/FMD/AliFMDPedestalDA.cxx b/FMD/AliFMDPedestalDA.cxx index a6b6e2cb7db..ccc15b8e069 100644 --- a/FMD/AliFMDPedestalDA.cxx +++ b/FMD/AliFMDPedestalDA.cxx @@ -19,11 +19,12 @@ @brief Derived class for the pedestal detector algorithm. */ // -// This class implements the virtual functions of the AliFMDBaseDA class. -// The most important of these functions, FillChannels(..) and Analyse(...) collect -// and analyse the data of each channel. The resulting pedestal and noise values are -// written to a comma separated values (csv) file on the go. The csv files produced -// in this way are the basic input to the AliFMDPreprocessor. +// This class implements the virtual functions of the AliFMDBaseDA +// class. The most important of these functions, FillChannels(..) and +// Analyse(...) collect and analyse the data of each channel. The +// resulting pedestal and noise values are written to a comma +// separated values (csv) file on the go. The csv files produced in +// this way are the basic input to the AliFMDPreprocessor. // #include "AliFMDPedestalDA.h" @@ -50,56 +51,85 @@ AliFMDPedestalDA::AliFMDPedestalDA(const AliFMDPedestalDA & pedDA) : } //_____________________________________________________________________ -AliFMDPedestalDA::~AliFMDPedestalDA() { - +AliFMDPedestalDA::~AliFMDPedestalDA() +{ } //_____________________________________________________________________ -void AliFMDPedestalDA::Init() { - +void AliFMDPedestalDA::Init() +{ SetRequiredEvents(1000); } //_____________________________________________________________________ void AliFMDPedestalDA::AddChannelContainer(TObjArray* sectorArray, UShort_t det, - Char_t ring, + Char_t ring, UShort_t sec, - UShort_t strip) { - + UShort_t strip) +{ +#ifdef USE_SAMPLES + AliFMDParameters* pars = AliFMDParameters::Instance(); + Int_t samples = pars->GetSampleRate(det, ring, sec, strip); + TObjArray* sampleArray = new TObjArray(samples); + for (size_t sample = 0; sample < samples; sample++) { + TH1S* hSample = new TH1S(Form("FMD%d%c[%02d,03%d]_%d", + det,ring,sec,strip,sample), + Form("FMD%d%c[%02d,%03%d]_%d", + det,ring,sec,strip), + 1024,-.5,1023.5); + hSample->SetXTitle("ADC"); + hSample->SetYTitle("Events"); + sampleArray->AddAt(hSample, sample); + } + sectorArray->AddAtAndExpand(sampleArray, strip); +#else TH1S* hChannel = new TH1S(Form("hFMD%d%c_%d_%d",det,ring,sec,strip), Form("hFMD%d%c_%d_%d",det,ring,sec,strip), - 1024,0,1023); + 1024,-.5,1023.5); hChannel->SetDirectory(0); sectorArray->AddAtAndExpand(hChannel,strip); +#endif + } //_____________________________________________________________________ -void AliFMDPedestalDA::FillChannels(AliFMDDigit* digit) { +void AliFMDPedestalDA::FillChannels(AliFMDDigit* digit) +{ UShort_t det = digit->Detector(); Char_t ring = digit->Ring(); UShort_t sec = digit->Sector(); UShort_t strip = digit->Strip(); - - TH1S* hChannel = GetChannel(det, ring, sec, strip); + +#ifdef USE_SAMPLES + AliFMDParameters* pars = AliFMDParameters::Instance(); + Int_t samples = pars->GetSampleRate(det, ring, sec, strip); + for (size_t sample = 0; sample < samples; sample++) { + TH1S* hSample = GetChannel(det, ring, sec, strip, sample); + hSample->Fill(digit->Count(sample)); + } +#else + TH1S* hChannel = GetChannel(det, ring, sec, strip); hChannel->Fill(digit->Counts()); - +#endif } //_____________________________________________________________________ void AliFMDPedestalDA::Analyse(UShort_t det, - Char_t ring, + Char_t ring, UShort_t sec, UShort_t strip) { TH1S* hChannel = GetChannel(det, ring, sec, strip); if(hChannel->GetEntries() == 0) { - // AliWarning(Form("No entries for FMD%d%c, sector %d, strip %d",det,ring,sec,strip)); + // AliWarning(Form("No entries for FMD%d%c, sector %d, strip %d", + // det,ring,sec,strip)); return; } - //std::cout<<"Fitting Channel #"<GetEntries()<<" entries \r"<GetEntries())); Float_t mean = hChannel->GetMean(); Float_t rms = hChannel->GetRMS(); @@ -109,17 +139,19 @@ void AliFMDPedestalDA::Analyse(UShort_t det, mean = hChannel->GetMean(); rms = hChannel->GetRMS(); - hChannel->Fit("gaus","QO","QO",mean-5*rms,mean+5*rms); + hChannel->Fit("gaus","Q0+","",mean-5*rms,mean+5*rms); TF1* fitFunc = hChannel->GetFunction("gaus"); UInt_t ddl, board, chip, channel; - UShort_t relStrip = strip%128; - AliFMDParameters* pars = AliFMDParameters::Instance(); + UShort_t relStrip = strip%128; + AliFMDParameters* pars = AliFMDParameters::Instance(); pars->Detector2Hardware(det,ring,sec,strip,ddl,board,chip,channel); + Float_t chi2ndf = 0; if(fitFunc->GetNDF()) chi2ndf = fitFunc->GetChisquare() / fitFunc->GetNDF(); + ddl = ddl + kBaseDDL; fOutputFile << ddl << ',' @@ -136,36 +168,78 @@ void AliFMDPedestalDA::Analyse(UShort_t det, << chi2ndf <<"\n"; if(fSaveHistograms) { - gDirectory->cd(Form("%s:FMD%d%c/sector_%d/strip_%d",fDiagnosticsFilename.Data(),det,ring,sec,strip)); - hChannel->GetXaxis()->SetRange(0,1023); + gDirectory->cd(GetSectorPath(det, ring, sec, kTRUE)); + TH1F* sumPed = dynamic_cast(gDirectory->Get("Pedestals")); + TH1F* sumNoise = dynamic_cast(gDirectory->Get("Noise")); + Int_t nStr = (ring == 'I' ? 512 : 256); + if (!sumPed) { + sumPed = new TH1F("Pedestals", + Form("Summary of pedestals in FMD%d%c[%02d]", + det, ring, sec), + nStr, -.5, nStr-.5); + sumPed->SetXTitle("Strip"); + sumPed->SetYTitle("Pedestal [ADC]"); + sumPed->SetDirectory(gDirectory); + } + if (!sumNoise) { + sumNoise = new TH1F("Noise", + Form("Summary of noise in FMD%d%c[%02d]", + det, ring, sec), + nStr, -.5, nStr-.5); + sumNoise->SetXTitle("Strip"); + sumNoise->SetYTitle("Noise [ADC]"); + sumNoise->SetDirectory(gDirectory); + } + sumPed->SetBinContent(strip+1, mean); + sumPed->SetBinError(strip+1, rms); + sumNoise->SetBinContent(strip+1, rms); + + gDirectory->cd(GetStripPath(det, ring, sec, strip, kTRUE)); + hChannel->GetXaxis()->SetRange(-.5,1023.5); + // hChannel->SetDirectory(gDirectory); hChannel->Write(); - - } - + } } //_____________________________________________________________________ -void AliFMDPedestalDA::WriteHeaderToFile() { +void AliFMDPedestalDA::WriteHeaderToFile() +{ AliFMDParameters* pars = AliFMDParameters::Instance(); fOutputFile.write(Form("# %s \n",pars->GetPedestalShuttleID()),13); - fOutputFile.write("# Rcu, Board, Chip, Channel, Strip, Sample, TimeBin, Pedestal, Noise, Mu, Sigma, Chi2/NDF \n",91); - + fOutputFile.write("# Rcu, " + "Board, " + "Chip, " + "Channel, " + "Strip, " + "Sample, " + "TimeBin, " + "Pedestal, " + "Noise, " + "Mu, " + "Sigma, " + "Chi2/NDF \n",91); } //_____________________________________________________________________ -TH1S* AliFMDPedestalDA::GetChannel(UShort_t det, Char_t ring, UShort_t sec, UShort_t strip) { - - UShort_t Ring = 1; - if(ring == 'O') - Ring = 0; - - +TH1S* AliFMDPedestalDA::GetChannel(UShort_t det, + Char_t ring, + UShort_t sec, + UShort_t strip) +{ + UShort_t iring = (ring == 'O' ? 0 : 1); TObjArray* detArray = static_cast(fDetectorArray.At(det)); - TObjArray* ringArray = static_cast(detArray->At(Ring)); + TObjArray* ringArray = static_cast(detArray->At(iring)); TObjArray* secArray = static_cast(ringArray->At(sec)); - TH1S* hChannel = static_cast(secArray->At(strip)); - +#ifdef USE_SAMPLES + AliFMDParameters* pars = AliFMDParameters::Instance(); + Int_t samples = pars->GetSampleRate(det, ring, sec, strip); + TObjArray* sampleArray = static_cast(secArray->At(strip)); + TH1S* hSample = static_cast(sampleArray->At(sample)); + return hSample; +#else + TH1S* hChannel = static_cast(secArray->At(strip)); return hChannel; +#endif } //_____________________________________________________________________ // diff --git a/FMD/scripts/TestPedestalDA.C b/FMD/scripts/TestPedestalDA.C index f5ce34a4241..c2608d8e52f 100644 --- a/FMD/scripts/TestPedestalDA.C +++ b/FMD/scripts/TestPedestalDA.C @@ -1,26 +1,59 @@ -void TestPedestalDA(Char_t* fileName, Int_t runNumber){ +//____________________________________________________________________ +// +// $Id: TestRawIO.C 13249 2006-03-24 16:09:36Z cholm $ +// +// Test of AliFMDPedestalDA +// +/** @ingroup simple_script + */ +#ifndef __CINT__ +# include +# include +# include +# include +# include +# include +#endif +void TestPedestalDA(Char_t* fileName="data.raw", Int_t runNumber=1, + Bool_t oldFormat=kTRUE, Bool_t diagnostics=kFALSE) +{ //This script runs the pedestal DA using the class AliFMDPedestalDA - - +#ifdef __CINT__ + // Load utility library gSystem->Load("libFMDutil"); - Bool_t old = kTRUE; +#endif + + // Set-up CDB interface AliCDBManager* cdb = AliCDBManager::Instance(); cdb->SetRun(runNumber); cdb->SetDefaultStorage("local://$ALICE_ROOT"); + + // Set debug level AliLog::SetModuleDebugLevel("FMD", 1); - AliFMDParameters::Instance()->Init(); - AliFMDParameters::Instance()->UseRcuTrailer(!old); - AliFMDParameters::Instance()->UseCompleteHeader(!old); + + // Set-up paramters + AliFMDParameters* params = AliFMDParameters::Instance(); + params->Init(); + params->UseCompleteHeader(oldFormat); + // Set-up raw readers AliRawReader *reader = new AliRawReaderDate(fileName,-1); + + + // Set-up timer TStopwatch timer; timer.Start(); + + // Make and run DA AliFMDPedestalDA pedestalDA; - //pedestalDA.SetSaveDiagnostics(kTRUE); + pedestalDA.SetSaveDiagnostics(diagnostics); pedestalDA.Run(reader); + + // Stop and print summary timer.Stop(); timer.Print(); - - } +// +// EOF +// -- 2.39.3