**************************************************************************/
-//-------------------------------------------------------
+/* $Id$ */
+
+
+//Root includes
+#include <TH1F.h>
+#include <TH2F.h>
+#include <TString.h>
+#include <TMath.h>
+#include <TF1.h>
+#include <TRandom.h>
+#include <TDirectory.h>
+#include <TFile.h>
+//AliRoot includes
+#include "AliRawReader.h"
+#include "AliRawReaderRoot.h"
+#include "AliRawReaderDate.h"
+#include "AliTPCRawStream.h"
+#include "AliTPCCalROC.h"
+#include "AliTPCROC.h"
+#include "AliMathBase.h"
+#include "TTreeStream.h"
+#include "AliTPCRawStreamFast.h"
+
+//date
+#include "event.h"
+
+//header file
+#include "AliTPCCalibPedestal.h"
+
+
+///////////////////////////////////////////////////////////////////////////////////////
// Implementation of the TPC pedestal and noise calibration
//
// Origin: Jens Wiechula, Marian Ivanov J.Wiechula@gsi.de, Marian.Ivanov@cern.ch
//
//
-//-------------------------------------------------------
-
-
-/* $Id$ */
+// *************************************************************************************
+// * Class Description *
+// *************************************************************************************
+//
+// Working principle:
+// ------------------
+// Raw pedestal data is processed by calling one of the ProcessEvent(...) functions
+// (see below). These in the end call the Update(...) function, where the data is filled
+// into histograms.
+//
+// For each ROC one TH2F histo (ROC channel vs. ADC channel) is created when
+// it is filled for the first time (GetHistoPedestal(ROC,kTRUE)). All histos are stored in the
+// TObjArray fHistoPedestalArray.
+//
+// For a fast filling of the histogram the corresponding bin number of the channel and ADC channel
+// is computed by hand and the histogram array is accessed directly via its pointer.
+// ATTENTION: Doing so the the entry counter of the histogram is not increased
+// this means that e.g. the colz draw option gives an empty plot unless
+// calling 'histo->SetEntries(1)' before drawing.
+//
+// After accumulating the desired statistics the Analyse() function has to be called.
+// Whithin this function the pedestal and noise values are calculated for each pad, using
+// the fast gaus fit function AliMathBase::FitGaus(...), and the calibration
+// storage classes (AliTPCCalROC) are filled for each ROC.
+// The calibration information is stored in the TObjArrays fCalRocArrayPedestal and fCalRocArrayRMS;
+//
+//
+//
+// User interface for filling data:
+// --------------------------------
+//
+// To Fill information one of the following functions can be used:
+//
+// Bool_t ProcessEvent(eventHeaderStruct *event);
+// - process Date event
+// - use AliTPCRawReaderDate and call ProcessEvent(AliRawReader *rawReader)
+//
+// Bool_t ProcessEvent(AliRawReader *rawReader);
+// - process AliRawReader event
+// - use AliTPCRawStream to loop over data and call ProcessEvent(AliTPCRawStream *rawStream)
+//
+// Bool_t ProcessEvent(AliTPCRawStream *rawStream);
+// - process event from AliTPCRawStream
+// - call Update function for signal filling
+//
+// Int_t Update(const Int_t isector, const Int_t iRow, const Int_t
+// iPad, const Int_t iTimeBin, const Float_t signal);
+// - directly fill signal information (sector, row, pad, time bin, pad)
+// to the reference histograms
+//
+// It is also possible to merge two independently taken calibrations using the function
+//
+// void Merge(AliTPCCalibPedestal *ped)
+// - copy histograms in 'ped' if the do not exist in this instance
+// - Add histograms in 'ped' to the histograms in this instance if the allready exist
+// - After merging call Analyse again!
+//
+//
+//
+// -- example: filling data using root raw data:
+// void fillPedestal(Char_t *filename)
+// {
+// rawReader = new AliRawReaderRoot(fileName);
+// if ( !rawReader ) return;
+// AliTPCCalibPedestal *calib = new AliTPCCalibPedestal;
+// while (rawReader->NextEvent()){
+// calib->ProcessEvent(rawReader);
+// }
+// calib->Analyse();
+// calib->DumpToFile("PedestalData.root");
+// delete rawReader;
+// delete calib;
+// }
+//
+//
+// What kind of information is stored and how to retrieve them:
+// ------------------------------------------------------------
+//
+// - Accessing the 'Reference Histograms' (pedestal distribution histograms):
+//
+// TH2F *GetHistoPedestal(Int_t sector);
+//
+// - Accessing the calibration storage objects:
+//
+// AliTPCCalROC *GetCalRocPedestal(Int_t sector); - for the pedestal values
+// AliTPCCalROC *GetCalRocNoise(Int_t sector); - for the Noise values
+//
+// example for visualisation:
+// if the file "PedestalData.root" was created using the above example one could do the following:
+//
+// TFile filePedestal("PedestalData.root")
+// AliTPCCalibPedestal *ped = (AliTPCCalibPedestal*)filePedestal->Get("AliTPCCalibPedestal");
+// ped->GetCalRocPedestal(0)->Draw("colz");
+// ped->GetCalRocRMS(0)->Draw("colz");
+//
+// or use the AliTPCCalPad functionality:
+// AliTPCCalPad padPedestal(ped->GetCalPadPedestal());
+// AliTPCCalPad padNoise(ped->GetCalPadRMS());
+// padPedestal->MakeHisto2D()->Draw("colz"); //Draw A-Side Pedestal Information
+// padNoise->MakeHisto2D()->Draw("colz"); //Draw A-Side Noise Information
+//
/*
example: fill pedestal with gausschen noise
ped.GetCalRocPedestal(36)->Draw("colz");
c2->cd(4);
ped.GetCalRocRMS(36)->Draw("colz");
-
-
*/
-//Root includes
-#include <TObjArray.h>
-#include <TH1F.h>
-#include <TH2F.h>
-#include <TString.h>
-#include <TMath.h>
-#include <TF1.h>
-#include <TRandom.h>
-#include <TDirectory.h>
-#include <TFile.h>
-//AliRoot includes
-#include "AliRawReader.h"
-#include "AliRawReaderRoot.h"
-#include "AliRawReaderDate.h"
-#include "AliTPCRawStream.h"
-#include "AliTPCCalROC.h"
-#include "AliTPCROC.h"
-#include "AliMathBase.h"
-#include "TTreeStream.h"
-
-//date
-#include "event.h"
-
-//header file
-#include "AliTPCCalibPedestal.h"
-
-
-ClassImp(AliTPCCalibPedestal) /*FOLD00*/
-
-
-
-
+//
+// Time dependent pedestals:
+//
+// If wished there is the possibility to calculate for each channel and time bin
+// the mean pedestal [pedestals(t)]. This is done by
+//
+// 1) setting SetTimeAnalysis(kTRUE),
+// 2) processing the data by looping over the events using ProcessEvent(..)
+// 3) calling the Analyse() and AnalyseTime(nevents) functions (providing nevents)
+// 4) getting the pedestals(t) using TArrayF **timePed = calibPedestal.GetTimePedestals();
+// 5) looking at values using timePed[row][pad].At(timebin)
+//
+// This functionality is intended to be used on an LDC bu the detector algorithm
+// (TPCPEDESTALda) to generate a data set used for configuration of the pattern
+// memory for baseline subtraction in the ALTROs. Later the information should also
+// be stored as reference data.
+//
+ClassImp(AliTPCCalibPedestal)
AliTPCCalibPedestal::AliTPCCalibPedestal() : /*FOLD00*/
TObject(),
fLastTimeBin(1000),
fAdcMin(1),
fAdcMax(100),
+ fOldRCUformat(kTRUE),
+ fTimeAnalysis(kFALSE),
fROC(AliTPCROC::Instance()),
+ fMapping(NULL),
fCalRocArrayPedestal(72),
fCalRocArrayRMS(72),
- fHistoPedestalArray(72)
+ fHistoPedestalArray(72),
+ fTimeSignal(NULL)
{
- //
- // default constructor
- //
+ //
+ // default constructor
+ //
}
+
+
//_____________________________________________________________________
AliTPCCalibPedestal::AliTPCCalibPedestal(const AliTPCCalibPedestal &ped) : /*FOLD00*/
TObject(ped),
fLastTimeBin(ped.GetLastTimeBin()),
fAdcMin(ped.GetAdcMin()),
fAdcMax(ped.GetAdcMax()),
+ fOldRCUformat(ped.fOldRCUformat),
+ fTimeAnalysis(ped.fTimeAnalysis),
fROC(AliTPCROC::Instance()),
+ fMapping(NULL),
fCalRocArrayPedestal(72),
fCalRocArrayRMS(72),
- fHistoPedestalArray(72)
+ fHistoPedestalArray(72),
+ fTimeSignal(ped.fTimeSignal)
{
- //
- // copy constructor
- //
- for (Int_t iSec = 0; iSec < 72; iSec++){
- const AliTPCCalROC *calPed = (AliTPCCalROC*)ped.fCalRocArrayPedestal.UncheckedAt(iSec);
- const AliTPCCalROC *calRMS = (AliTPCCalROC*)ped.fCalRocArrayRMS.UncheckedAt(iSec);
- const TH2F *hPed = (TH2F*)ped.fHistoPedestalArray.UncheckedAt(iSec);
-
- if ( calPed != 0x0 ) fCalRocArrayPedestal.AddAt(new AliTPCCalROC(*calPed), iSec);
- if ( calRMS != 0x0 ) fCalRocArrayRMS.AddAt(new AliTPCCalROC(*calRMS), iSec);
-
- if ( hPed != 0x0 ){
- TH2F *hNew = new TH2F(*hPed);
- hNew->SetDirectory(0);
- fHistoPedestalArray.AddAt(hNew,iSec);
- }
+ //
+ // copy constructor
+ //
+ for (Int_t iSec = 0; iSec < 72; ++iSec){
+ const AliTPCCalROC *calPed = (AliTPCCalROC*)ped.fCalRocArrayPedestal.UncheckedAt(iSec);
+ const AliTPCCalROC *calRMS = (AliTPCCalROC*)ped.fCalRocArrayRMS.UncheckedAt(iSec);
+ const TH2F *hPed = (TH2F*)ped.fHistoPedestalArray.UncheckedAt(iSec);
+
+ if ( calPed != 0x0 ) fCalRocArrayPedestal.AddAt(new AliTPCCalROC(*calPed), iSec);
+ if ( calRMS != 0x0 ) fCalRocArrayRMS.AddAt(new AliTPCCalROC(*calRMS), iSec);
+
+ if ( hPed != 0x0 ){
+ TH2F *hNew = new TH2F(*hPed);
+ hNew->SetDirectory(0);
+ fHistoPedestalArray.AddAt(hNew,iSec);
}
+ }
}
+
+
//_____________________________________________________________________
AliTPCCalibPedestal& AliTPCCalibPedestal::operator = (const AliTPCCalibPedestal &source)
{
return *this;
}
+
+
//_____________________________________________________________________
AliTPCCalibPedestal::~AliTPCCalibPedestal() /*FOLD00*/
{
//
// destructor
//
- delete fROC;
+
+ fCalRocArrayPedestal.Delete();
+ fCalRocArrayRMS.Delete();
+ fHistoPedestalArray.Delete();
+
+ if ( fTimeSignal ) {
+ for (Int_t i = 0; i < 159; i++) {
+ delete [] fTimeSignal[i];
+ fTimeSignal[i] = 0;
+ }
+ delete [] fTimeSignal;
+ fTimeSignal = 0;
+ }
+
+ // do not delete fMapping, because we do not own it.
+
}
+//_____________________________________________________________________
+void AliTPCCalibPedestal::SetTimeAnalysis(Bool_t time)
+{
+ //
+ // Use time dependent analysis: Pedestals are analysed as a function
+ // of the drift time. There is one mean value generated for each time
+ // bin and each channel. It can be used as reference data and for
+ // configuration of the ALTRO pattern memory for baseline subtraction.
+ //
+ // ATTENTION: Use only on LDC in TPCPEDESTALda! On a LDC we get data
+ // only from one sector. For the full TPC we would need a lot of
+ // memory (36*159*140*1024*4bytes = 3.3GB)!
+ //
+
+ fTimeAnalysis = time;
+
+ if ( !fTimeAnalysis ) return;
+
+ // prepare array for one sector (159*140*1024*4bytes = 92MB):
+ fTimeSignal = new TArrayF*[159];
+ for (Int_t i = 0; i < 159; i++) { // padrows
+ fTimeSignal[i] = new TArrayF[140];
+ for (Int_t j = 0; j < 140; j++) { // pads per row
+ fTimeSignal[i][j].Set(1024);
+ for (Int_t k = 0; k < 1024; k++) { // time bins per pad
+ fTimeSignal[i][j].AddAt(0., k);
+ }
+ }
+ }
+}
//_____________________________________________________________________
Int_t AliTPCCalibPedestal::Update(const Int_t icsector, /*FOLD00*/
- const Int_t icRow,
- const Int_t icPad,
- const Int_t icTimeBin,
- const Float_t csignal)
+ const Int_t icRow,
+ const Int_t icPad,
+ const Int_t icTimeBin,
+ const Float_t csignal)
{
- //
- // Signal filling methode
- //
- if ( (icTimeBin>fLastTimeBin) || (icTimeBin<fFirstTimeBin) ) return 0;
+ //
+ // Signal filling method
+ //
+
+ // Time dependent pedestals
+ if ( fTimeAnalysis ) {
+ if ( icsector < 36 ) // IROC
+ fTimeSignal[icRow][icPad].AddAt(fTimeSignal[icRow][icPad].At(icTimeBin)+csignal, icTimeBin);
+ else
+ fTimeSignal[icRow+63][icPad].AddAt(fTimeSignal[icRow+63][icPad].At(icTimeBin)+csignal, icTimeBin);
+ }
+ //return if we are out of the specified time bin or adc range
+ if ( (icTimeBin>fLastTimeBin) || (icTimeBin<fFirstTimeBin) ) return 0;
+ if ( ((Int_t)csignal>fAdcMax) || ((Int_t)csignal<fAdcMin) ) return 0;
- Int_t iChannel = fROC->GetRowIndexes(icsector)[icRow]+icPad; // global pad position in sector
+ Int_t iChannel = fROC->GetRowIndexes(icsector)[icRow]+icPad; // global pad position in sector
- // fast filling methode.
- // Attention: the entry counter of the histogram is not increased
- // this means that e.g. the colz draw option gives an empty plot
- Int_t bin = 0;
- if ( !(((Int_t)csignal>fAdcMax ) || ((Int_t)csignal<fAdcMin)) )
- bin = (iChannel+1)*(fAdcMax-fAdcMin+2)+((Int_t)csignal-fAdcMin+1);
+ // fast filling method
+ // Attention: the entry counter of the histogram is not increased
+ // this means that e.g. the colz draw option gives an empty plot
+ Int_t bin = (iChannel+1)*(fAdcMax-fAdcMin+2)+((Int_t)csignal-fAdcMin+1);
- GetHistoPedestal(icsector,kTRUE)->GetArray()[bin]++;
+ GetHistoPedestal(icsector,kTRUE)->GetArray()[bin]++;
- return 0;
+ return 0;
+}
+
+
+//_____________________________________________________________________
+Bool_t AliTPCCalibPedestal::ProcessEventFast(AliTPCRawStreamFast *rawStreamFast)
+{
+ //
+ // Event Processing loop - AliTPCRawStream
+ //
+ Bool_t withInput = kFALSE;
+
+ while ( rawStreamFast->NextDDL() ){
+ while ( rawStreamFast->NextChannel() ){
+ Int_t isector = rawStreamFast->GetSector(); // current sector
+ Int_t iRow = rawStreamFast->GetRow(); // current row
+ Int_t iPad = rawStreamFast->GetPad(); // current pad
+ Int_t startTbin = (Int_t)rawStreamFast->GetStartTimeBin();
+ Int_t endTbin = (Int_t)rawStreamFast->GetEndTimeBin();
+
+ while ( rawStreamFast->NextBunch() ){
+ for (Int_t iTimeBin = startTbin; iTimeBin < endTbin; iTimeBin++){
+ Float_t signal=(Float_t)rawStreamFast->GetSignals()[iTimeBin-startTbin];
+ Update(isector,iRow,iPad,iTimeBin+1,signal);
+ withInput = kTRUE;
+ }
+ }
+ }
+ }
+
+ return withInput;
}
+//_____________________________________________________________________
+Bool_t AliTPCCalibPedestal::ProcessEventFast(AliRawReader *rawReader)
+{
+ //
+ // Event processing loop - AliRawReader
+ //
+ AliTPCRawStreamFast *rawStreamFast = new AliTPCRawStreamFast(rawReader, (AliAltroMapping**)fMapping);
+ Bool_t res=ProcessEventFast(rawStreamFast);
+ delete rawStreamFast;
+ return res;
+}
+
//_____________________________________________________________________
Bool_t AliTPCCalibPedestal::ProcessEvent(AliTPCRawStream *rawStream)
{
// Event Processing loop - AliTPCRawStream
//
- rawStream->SetOldRCUFormat(1);
+ rawStream->SetOldRCUFormat(fOldRCUformat);
Bool_t withInput = kFALSE;
while (rawStream->Next()) {
- Int_t isector = rawStream->GetSector(); // current sector
- Int_t iRow = rawStream->GetRow(); // current row
- Int_t iPad = rawStream->GetPad(); // current pad
- Int_t iTimeBin = rawStream->GetTime(); // current time bin
- Float_t signal = rawStream->GetSignal(); // current ADC signal
-
- Update(isector,iRow,iPad,iTimeBin,signal);
- withInput = kTRUE;
+ Int_t iSector = rawStream->GetSector(); // current ROC
+ Int_t iRow = rawStream->GetRow(); // current row
+ Int_t iPad = rawStream->GetPad(); // current pad
+ Int_t iTimeBin = rawStream->GetTime(); // current time bin
+ Float_t signal = rawStream->GetSignal(); // current ADC signal
+
+ Update(iSector,iRow,iPad,iTimeBin,signal);
+ withInput = kTRUE;
}
return withInput;
}
+
+
//_____________________________________________________________________
Bool_t AliTPCCalibPedestal::ProcessEvent(AliRawReader *rawReader)
{
// Event processing loop - AliRawReader
//
-
- AliTPCRawStream rawStream(rawReader);
-
+ // if fMapping is NULL the rawstream will crate its own mapping
+ AliTPCRawStream rawStream(rawReader, (AliAltroMapping**)fMapping);
rawReader->Select("TPC");
-
return ProcessEvent(&rawStream);
}
+
+
//_____________________________________________________________________
Bool_t AliTPCCalibPedestal::ProcessEvent(eventHeaderStruct *event)
{
//
// process date event
//
- AliRawReader *rawReader = new AliRawReaderDate((void*)event);
- Bool_t result=ProcessEvent(rawReader);
- delete rawReader;
- return result;
+
+ AliRawReader *rawReader = new AliRawReaderDate((void*)event);
+ Bool_t result=ProcessEvent(rawReader);
+ delete rawReader;
+ return result;
}
+
+
//_____________________________________________________________________
Bool_t AliTPCCalibPedestal::TestEvent() /*FOLD00*/
{
gRandom->SetSeed(0);
- for (UInt_t iSec=0; iSec<72; iSec++){
+ for (UInt_t iSec=0; iSec<72; ++iSec){
if (iSec%36>0) continue;
- for (UInt_t iRow=0; iRow < fROC->GetNRows(iSec); iRow++){
- for (UInt_t iPad=0; iPad < fROC->GetNPads(iSec,iRow); iPad++){
- for (UInt_t iTimeBin=0; iTimeBin<1024; iTimeBin++){
+ for (UInt_t iRow=0; iRow < fROC->GetNRows(iSec); ++iRow){
+ for (UInt_t iPad=0; iPad < fROC->GetNPads(iSec,iRow); ++iPad){
+ for (UInt_t iTimeBin=0; iTimeBin<1024; ++iTimeBin){
Float_t signal=(Int_t)(iRow+3+gRandom->Gaus(0,.7));
if ( signal>0 )Update(iSec,iRow,iPad,iTimeBin,signal);
}
}
return kTRUE;
}
+
+
//_____________________________________________________________________
TH2F* AliTPCCalibPedestal::GetHisto(Int_t sector, TObjArray *arr, /*FOLD00*/
- Int_t nbinsY, Float_t ymin, Float_t ymax,
- Char_t *type, Bool_t force)
+ Int_t nbinsY, Float_t ymin, Float_t ymax,
+ Char_t *type, Bool_t force)
{
//
// return pointer to Q histogram
arr->AddAt(hist,sector);
return hist;
}
+
+
//_____________________________________________________________________
TH2F* AliTPCCalibPedestal::GetHistoPedestal(Int_t sector, Bool_t force) /*FOLD00*/
{
TObjArray *arr = &fHistoPedestalArray;
return GetHisto(sector, arr, fAdcMax-fAdcMin, fAdcMin, fAdcMax, "Pedestal", force);
}
+
+
//_____________________________________________________________________
AliTPCCalROC* AliTPCCalibPedestal::GetCalRoc(Int_t sector, TObjArray* arr, Bool_t force) /*FOLD00*/
{
if ( !force || arr->UncheckedAt(sector) )
return (AliTPCCalROC*)arr->UncheckedAt(sector);
- // if we are forced and histogram doesn't yes exist create it
+ // if we are forced and the histogram doesn't yet exist create it
// new AliTPCCalROC for T0 information. One value for each pad!
AliTPCCalROC *croc = new AliTPCCalROC(sector);
- //init values
- for ( UInt_t iChannel = 0; iChannel<croc->GetNchannels(); iChannel++){
- croc->SetValue(iChannel, 0);
- }
arr->AddAt(croc,sector);
return croc;
}
+
+
//_____________________________________________________________________
AliTPCCalROC* AliTPCCalibPedestal::GetCalRocPedestal(Int_t sector, Bool_t force) /*FOLD00*/
{
TObjArray *arr = &fCalRocArrayPedestal;
return GetCalRoc(sector, arr, force);
}
+
+
//_____________________________________________________________________
AliTPCCalROC* AliTPCCalibPedestal::GetCalRocRMS(Int_t sector, Bool_t force) /*FOLD00*/
{
TObjArray *arr = &fCalRocArrayRMS;
return GetCalRoc(sector, arr, force);
}
+
+
+//_____________________________________________________________________
+void AliTPCCalibPedestal::Merge(AliTPCCalibPedestal *ped)
+{
+ //
+ // Merge reference histograms of sig to the current AliTPCCalibSignal
+ //
+
+ // merge histograms
+ for (Int_t iSec=0; iSec<72; ++iSec){
+ TH2F *hRefPedMerge = ped->GetHistoPedestal(iSec);
+
+ if ( hRefPedMerge ){
+ TDirectory *dir = hRefPedMerge->GetDirectory(); hRefPedMerge->SetDirectory(0);
+ TH2F *hRefPed = GetHistoPedestal(iSec);
+ if ( hRefPed ) hRefPed->Add(hRefPedMerge);
+ else {
+ TH2F *hist = new TH2F(*hRefPedMerge);
+ hist->SetDirectory(0);
+ fHistoPedestalArray.AddAt(hist, iSec);
+ }
+ hRefPedMerge->SetDirectory(dir);
+ }
+ }
+
+ // merge array
+ // ...
+
+}
+
+
//_____________________________________________________________________
void AliTPCCalibPedestal::Analyse() /*FOLD00*/
{
- //
- // Calculate calibration constants
- //
+ //
+ // Calculate calibration constants
+ //
- Int_t nbinsAdc = fAdcMax-fAdcMin;
+ Int_t nbinsAdc = fAdcMax-fAdcMin;
- TVectorD param(3);
- TMatrixD dummy(3,3);
+ TVectorD param(3);
+ TMatrixD dummy(3,3);
- Float_t *array_hP=0;
+ Float_t *array_hP=0;
+ for (Int_t iSec=0; iSec<72; ++iSec){
+ TH2F *hP = GetHistoPedestal(iSec);
+ if ( !hP ) continue;
- for (Int_t iSec=0; iSec<72; iSec++){
- TH2F *hP = GetHistoPedestal(iSec);
- if ( !hP ) continue;
+ AliTPCCalROC *rocPedestal = GetCalRocPedestal(iSec,kTRUE);
+ AliTPCCalROC *rocRMS = GetCalRocRMS(iSec,kTRUE);
- AliTPCCalROC *rocPedestal = GetCalRocPedestal(iSec,kTRUE);
- AliTPCCalROC *rocRMS = GetCalRocRMS(iSec,kTRUE);
+ array_hP = hP->GetArray();
+ UInt_t nChannels = fROC->GetNChannels(iSec);
- array_hP = hP->GetArray();
- UInt_t nChannels = fROC->GetNChannels(iSec);
+ for (UInt_t iChannel=0; iChannel<nChannels; ++iChannel){
+ Int_t offset = (nbinsAdc+2)*(iChannel+1)+1;
+ Double_t ret = AliMathBase::FitGaus(array_hP+offset,nbinsAdc,fAdcMin,fAdcMax,¶m,&dummy);
+ // if the fitting failed set noise and pedestal to 0
+ if ( ret == -4 ) {
+ param[1]=0;
+ param[2]=0;
+ }
+ rocPedestal->SetValue(iChannel,param[1]);
+ rocRMS->SetValue(iChannel,param[2]);
+ }
+ }
+}
- for (UInt_t iChannel=0; iChannel<nChannels; iChannel++){
- Int_t offset = (nbinsAdc+2)*(iChannel+1)+1;
- Double_t ret = AliMathBase::FitGaus(array_hP+offset,nbinsAdc,fAdcMin,fAdcMax,¶m,&dummy);
- // if the fitting failed set noise and pedestal to 0
- if ( ret == -4 ) {
- param[1]=0;
- param[2]=0;
- }
- rocPedestal->SetValue(iChannel,param[1]);
- rocRMS->SetValue(iChannel,param[2]);
+
+//_____________________________________________________________________
+void AliTPCCalibPedestal::AnalyseTime(Int_t nevents)
+{
+ //
+ // Calculate for each channel and time bin the mean pedestal. This
+ // is used on LDC by TPCPEDESTALda to generate data used for configuration
+ // of the pattern memory for baseline subtraction in the ALTROs.
+ //
+
+ if ( nevents <= 0 ) return;
+ if ( fTimeAnalysis ) {
+ for (Int_t i = 0; i < 159; i++) { // padrows
+ for (Int_t j = 0; j < 140; j++) { // pads per row
+ for (Int_t k = 0; k < 1024; k++) { // time bins per pad
+ fTimeSignal[i][j].AddAt(fTimeSignal[i][j].At(k)/(Float_t)nevents, k);
}
+ }
}
+ }
}
+
+
//_____________________________________________________________________
void AliTPCCalibPedestal::DumpToFile(const Char_t *filename, const Char_t *dir, Bool_t append) /*FOLD00*/
{
- //
- // Write class to file
- //
+ //
+ // Write class to file
+ //
- TString sDir(dir);
- TString option;
+ TString sDir(dir);
+ TString option;
- if ( append )
- option = "update";
- else
- option = "recreate";
+ if ( append )
+ option = "update";
+ else
+ option = "recreate";
- TDirectory *backup = gDirectory;
- TFile f(filename,option.Data());
- f.cd();
- if ( !sDir.IsNull() ){
- f.mkdir(sDir.Data());
- f.cd(sDir);
- }
- this->Write();
- f.Close();
+ TDirectory *backup = gDirectory;
+ TFile f(filename,option.Data());
+ f.cd();
+ if ( !sDir.IsNull() ){
+ f.mkdir(sDir.Data());
+ f.cd(sDir);
+ }
+ this->Write();
+ f.Close();
- if ( backup ) backup->cd();
+ if ( backup ) backup->cd();
}