From: marian Date: Thu, 3 May 2007 13:30:04 +0000 (+0000) Subject: Add additional functionality X-Git-Url: http://git.uio.no/git/?p=u%2Fmrichter%2FAliRoot.git;a=commitdiff_plain;h=bc331d5bf450a4fdaca96cd39be9d9771da119fc;hp=eae02153ec619fc8ee2b804862ac9c8be7f9084b Add additional functionality ProcessEvent from TPCRawStream Setters (Jens, Marian) --- diff --git a/TPC/AliTPCCalibPedestal.cxx b/TPC/AliTPCCalibPedestal.cxx index 43edb868659..a39a7358cf4 100644 --- a/TPC/AliTPCCalibPedestal.cxx +++ b/TPC/AliTPCCalibPedestal.cxx @@ -25,38 +25,59 @@ /* $Id$ */ - +/* + example: fill pedestal with gausschen noise + AliTPCCalibPedestal ped; + ped.TestEvent(); + ped.Analyse(); + //Draw output; + TCanvas* c1 = new TCanvas; + c1->Divide(1,2); + c1->cd(1); + ped.GetHistoPedestal(0)->SetEntries(1); //needed in order for colz to work, reason: fast filling does not increase the entries counter + ped.GetHistoPedestal(0)->Draw("colz"); + c1->cd(2); + ped.GetHistoPedestal(36)->SetEntries(1); //needed in order for colz to work, reason: fast filling does not increase the entries counter + ped.GetHistoPedestal(36)->Draw("colz"); + TCanvas* c2 = new TCanvas; + c2->Divide(2,2); + c2->cd(1); + ped.GetCalRocPedestal(0)->Draw("colz"); + c2->cd(2); + ped.GetCalRocRMS(0)->Draw("colz"); + c2->cd(3); + ped.GetCalRocPedestal(36)->Draw("colz"); + c2->cd(4); + ped.GetCalRocRMS(36)->Draw("colz"); + + +*/ //Root includes #include #include -#include #include -#include -#include #include -#include #include #include #include -#include #include -#include #include - - //AliRoot includes #include "AliRawReader.h" #include "AliRawReaderRoot.h" +#include "AliRawReaderDate.h" #include "AliTPCRawStream.h" #include "AliTPCCalROC.h" -#include "AliTPCCalPad.h" #include "AliTPCROC.h" -#include "AliTPCCalibPedestal.h" #include "AliMathBase.h" - #include "TTreeStream.h" +//date +#include "event.h" + +//header file +#include "AliTPCCalibPedestal.h" ClassImp(AliTPCCalibPedestal) /*FOLD00*/ @@ -76,27 +97,60 @@ AliTPCCalibPedestal::AliTPCCalibPedestal() : /*FOLD00*/ fROC(AliTPCROC::Instance()), fCalRocArrayPedestal(72), fCalRocArrayRMS(72), - fHistoPedestalArray(72), - fDebugStreamer(0), - fDebugLevel(0) + fHistoPedestalArray(72) { // - // AliTPCSignal default constructor + // default constructor // - //debug stream - TDirectory *backup = gDirectory; - fDebugStreamer = new TTreeSRedirector("deb2.root"); - if ( backup ) backup->cd(); //we don't want to be cd'd to the debug streamer } +//_____________________________________________________________________ +AliTPCCalibPedestal::AliTPCCalibPedestal(const AliTPCCalibPedestal &ped) : /*FOLD00*/ + TObject(ped), + fFirstTimeBin(ped.GetFirstTimeBin()), + fLastTimeBin(ped.GetLastTimeBin()), + fAdcMin(ped.GetAdcMin()), + fAdcMax(ped.GetAdcMax()), + fROC(AliTPCROC::Instance()), + fCalRocArrayPedestal(72), + fCalRocArrayRMS(72), + fHistoPedestalArray(72) +{ + // + // 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) +{ + // + // assignment operator + // + if (&source == this) return *this; + new (this) AliTPCCalibPedestal(source); + return *this; +} //_____________________________________________________________________ AliTPCCalibPedestal::~AliTPCCalibPedestal() /*FOLD00*/ { // // destructor // - if ( fDebugStreamer ) delete fDebugStreamer; - delete fROC; + delete fROC; } @@ -116,55 +170,73 @@ Int_t AliTPCCalibPedestal::Update(const Int_t icsector, /*FOLD00*/ Int_t iChannel = fROC->GetRowIndexes(icsector)[icRow]+icPad; // global pad position in sector - // dirty and fast filling methode. No boundary checking!!! + // 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 = (iChannel+1)*(fAdcMax-fAdcMin+2)+((Int_t)csignal-fAdcMin+1); + Int_t bin = 0; + if ( !(((Int_t)csignal>fAdcMax ) || ((Int_t)csignalGetArray()[bin]++; return 0; } //_____________________________________________________________________ -Bool_t AliTPCCalibPedestal::ProcessEvent(AliRawReader *rawReader) /*FOLD00*/ +Bool_t AliTPCCalibPedestal::ProcessEvent(AliTPCRawStream *rawStream) { // - // simple event processing loop + // Event Processing loop - AliTPCRawStream // - - AliTPCRawStream input(rawReader); - - rawReader->Select("TPC"); - - input.SetOldRCUFormat(1); - printf("start event processing\n"); - + rawStream->SetOldRCUFormat(1); Bool_t withInput = kFALSE; - while (input.Next()) { + while (rawStream->Next()) { - Int_t isector = input.GetSector(); // current sector - Int_t iRow = input.GetRow(); // current row - Int_t iPad = input.GetPad(); // current pad - Int_t iTimeBin = input.GetTime(); // current time bin - Float_t signal = input.GetSignal(); // current ADC signal + 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; } - printf("end event processing\n"); - if ( fDebugLevel>0 ) - fDebugStreamer->GetFile()->Write(); return withInput; } //_____________________________________________________________________ +Bool_t AliTPCCalibPedestal::ProcessEvent(AliRawReader *rawReader) +{ + // + // Event processing loop - AliRawReader + // + + + AliTPCRawStream rawStream(rawReader); + + 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; +} +//_____________________________________________________________________ Bool_t AliTPCCalibPedestal::TestEvent() /*FOLD00*/ { // // Test event loop + // fill one oroc and one iroc with random gaus // gRandom->SetSeed(0); @@ -174,7 +246,7 @@ Bool_t AliTPCCalibPedestal::TestEvent() /*FOLD00*/ 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+5+gRandom->Gaus(0,.7)); + Float_t signal=(Int_t)(iRow+3+gRandom->Gaus(0,.7)); if ( signal>0 )Update(iSec,iRow,iPad,iTimeBin,signal); } } @@ -183,7 +255,7 @@ Bool_t AliTPCCalibPedestal::TestEvent() /*FOLD00*/ return kTRUE; } //_____________________________________________________________________ -TH2S* AliTPCCalibPedestal::GetHisto(Int_t sector, TObjArray *arr, /*FOLD00*/ +TH2F* AliTPCCalibPedestal::GetHisto(Int_t sector, TObjArray *arr, /*FOLD00*/ Int_t nbinsY, Float_t ymin, Float_t ymax, Char_t *type, Bool_t force) { @@ -192,16 +264,16 @@ TH2S* AliTPCCalibPedestal::GetHisto(Int_t sector, TObjArray *arr, /*FOLD00*/ // if force is true create a new histogram if it doesn't exist allready // if ( !force || arr->UncheckedAt(sector) ) - return (TH2S*)arr->UncheckedAt(sector); + return (TH2F*)arr->UncheckedAt(sector); // if we are forced and histogram doesn't yes exist create it Char_t name[255], title[255]; sprintf(name,"hCalib%s%.2d",type,sector); - sprintf(title,"%s calibration histogram sector %.2d",type,sector); + sprintf(title,"%s calibration histogram sector %.2d;ADC channel;Channel (pad)",type,sector); // new histogram with Q calib information. One value for each pad! - TH2S* hist = new TH2S(name,title, + TH2F* hist = new TH2F(name,title, nbinsY, ymin, ymax, fROC->GetNChannels(sector),0,fROC->GetNChannels(sector) ); @@ -210,7 +282,7 @@ TH2S* AliTPCCalibPedestal::GetHisto(Int_t sector, TObjArray *arr, /*FOLD00*/ return hist; } //_____________________________________________________________________ -TH2S* AliTPCCalibPedestal::GetHistoPedestal(Int_t sector, Bool_t force) /*FOLD00*/ +TH2F* AliTPCCalibPedestal::GetHistoPedestal(Int_t sector, Bool_t force) /*FOLD00*/ { // // return pointer to T0 histogram @@ -269,17 +341,14 @@ void AliTPCCalibPedestal::Analyse() /*FOLD00*/ Int_t nbinsAdc = fAdcMax-fAdcMin; - TH1F *py = new TH1F("htemp_py","htemp_py", nbinsAdc, fAdcMin, fAdcMax); - TF1 *gaus = new TF1("fit","gaus"); TVectorD param(3); + TMatrixD dummy(3,3); - Float_t *array_py=0; - Short_t *array_hP=0; + Float_t *array_hP=0; - array_py = py->GetArray(); for (Int_t iSec=0; iSec<72; iSec++){ - TH2S *hP = GetHistoPedestal(iSec); + TH2F *hP = GetHistoPedestal(iSec); if ( !hP ) continue; AliTPCCalROC *rocPedestal = GetCalRocPedestal(iSec,kTRUE); @@ -289,26 +358,17 @@ void AliTPCCalibPedestal::Analyse() /*FOLD00*/ UInt_t nChannels = fROC->GetNChannels(iSec); for (UInt_t iChannel=0; iChannelSetParameters(0,0); - py->Fit(gaus,"nq"); - - rocPedestal->SetValue(iChannel,gaus->GetParameter(1)); - rocRMS->SetValue(iChannel,gaus->GetParameter(2)); - - //AliMathBase::FitGaus(nbinsAdc,array_hP+(iChannel+1)*(nbinsAdc+2),¶m) - //rocPedestal->SetValue(iChannel,param[1]); - //rocRMS->SetValue(iChannel,param[2]); + 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]); } } - delete py; - delete gaus; - delete fDebugStreamer; - fDebugStreamer = 0x0; } //_____________________________________________________________________ void AliTPCCalibPedestal::DumpToFile(const Char_t *filename, const Char_t *dir, Bool_t append) /*FOLD00*/ @@ -317,7 +377,6 @@ void AliTPCCalibPedestal::DumpToFile(const Char_t *filename, const Char_t *dir, // Write class to file // - TDirectory *backup = gDirectory; TString sDir(dir); TString option; @@ -326,14 +385,15 @@ void AliTPCCalibPedestal::DumpToFile(const Char_t *filename, const Char_t *dir, else option = "recreate"; + TDirectory *backup = gDirectory; TFile f(filename,option.Data()); + f.cd(); if ( !sDir.IsNull() ){ f.mkdir(sDir.Data()); f.cd(sDir); } - gDirectory->WriteTObject(this); + this->Write(); f.Close(); if ( backup ) backup->cd(); - } diff --git a/TPC/AliTPCCalibPedestal.h b/TPC/AliTPCCalibPedestal.h index e0302884b98..4ab27cbc7f3 100644 --- a/TPC/AliTPCCalibPedestal.h +++ b/TPC/AliTPCCalibPedestal.h @@ -9,37 +9,45 @@ class TObjArray; class TH2F; -class TH2S; -class TH1S; -class TH1F; -class TH1D; -class TF1; class TTreeSRedirector; class AliTPCROC; +class AliTPCCalROC; class AliRawReader; +struct eventHeaderStruct; class AliTPCCalibPedestal : public TObject { public: AliTPCCalibPedestal(); + AliTPCCalibPedestal(const AliTPCCalibPedestal &ped); virtual ~AliTPCCalibPedestal(); - - Bool_t ProcessEvent(AliRawReader *rawReader); + + AliTPCCalibPedestal& operator = (const AliTPCCalibPedestal &source); + + Bool_t ProcessEvent(AliTPCRawStream *rawStream); + Bool_t ProcessEvent(AliRawReader *rawReader); + Bool_t ProcessEvent(eventHeaderStruct *event); + Int_t Update(const Int_t isector, const Int_t iRow, const Int_t iPad, const Int_t iTimeBin, const Float_t signal); void Analyse(); // - AliTPCCalROC* GetCalRocPedestal (Int_t sector, Bool_t force=kFALSE); //get calibration object - sector - AliTPCCalROC* GetCalRocRMS(Int_t sector, Bool_t force=kFALSE); //get calibration object - sector - const TObjArray* GetCalPadPedestal (){return &fCalRocArrayPedestal;}//get calibration object - const TObjArray* GetCalPadRMS(){return &fCalRocArrayRMS;} //get calibration object + AliTPCCalROC* GetCalRocPedestal (Int_t sector, Bool_t force=kFALSE); // get calibration object - sector + AliTPCCalROC* GetCalRocRMS(Int_t sector, Bool_t force=kFALSE); // get calibration object - sector + const TObjArray* GetCalPadPedestal (){return &fCalRocArrayPedestal;} // get calibration object + const TObjArray* GetCalPadRMS(){return &fCalRocArrayRMS;} // get calibration object - TH2S* GetHistoPedestal (Int_t sector, Bool_t force=kFALSE); //get refernce histogram - void DumpToFile(const Char_t *filename, const Char_t *dir="", const Bool_t append=kFALSE); + TH2F* GetHistoPedestal (Int_t sector, Bool_t force=kFALSE); // get refernce histogram + void DumpToFile(const Char_t *filename, const Char_t *dir="", const Bool_t append=kFALSE); // - Short_t GetDebugLevel(){ return fDebugLevel; } - void SetDebugLevel(Short_t debug=1){ fDebugLevel = debug;} + Int_t GetFirstTimeBin() const { return fFirstTimeBin; } + Int_t GetLastTimeBin() const { return fLastTimeBin; } + Int_t GetAdcMin() const { return fAdcMin; } + Int_t GetAdcMax() const { return fAdcMax; } + + void SetRangeTime(Int_t tMin, Int_t tMax){ fFirstTimeBin=tMin; fLastTimeBin=tMax; } // Set time bin range that is used for the pedestal calibration + void SetRangeAdc (Int_t aMin, Int_t aMax){ fAdcMin=aMin; fAdcMax=aMax; } // Set adc range for the pedestal calibration Bool_t TestEvent(); //test the fast approach to fill histogram - used for test purposes @@ -58,12 +66,9 @@ private: TObjArray fHistoPedestalArray; // Calibration histograms for Pedestal distribution - TTreeSRedirector *fDebugStreamer; //! debug streamer - Short_t fDebugLevel; - //! debugging - TH2S* GetHisto(Int_t sector, TObjArray *arr, + TH2F* GetHisto(Int_t sector, TObjArray *arr, Int_t nbinsY, Float_t ymin, Float_t ymax, Char_t *type, Bool_t force); diff --git a/TPC/AliTPCCalibSignal.cxx b/TPC/AliTPCCalibSignal.cxx index 0f4c59caa2b..233dee9da54 100644 --- a/TPC/AliTPCCalibSignal.cxx +++ b/TPC/AliTPCCalibSignal.cxx @@ -33,19 +33,11 @@ //Root includes #include #include -#include -#include #include -#include #include #include #include -#include - -#include -#include -#include #include #include #include @@ -53,6 +45,7 @@ //AliRoot includes #include "AliRawReader.h" #include "AliRawReaderRoot.h" +#include "AliRawReaderDate.h" #include "AliTPCRawStream.h" #include "AliTPCCalROC.h" #include "AliTPCCalPad.h" @@ -60,8 +53,11 @@ #include "AliTPCParam.h" #include "AliTPCCalibSignal.h" #include "AliTPCcalibDB.h" - +#include "AliMathBase.h" #include "TTreeStream.h" + +//date +#include "event.h" ClassImp(AliTPCCalibSignal) /*FOLD00*/ AliTPCCalibSignal::AliTPCCalibSignal() : /*FOLD00*/ @@ -70,10 +66,19 @@ AliTPCCalibSignal::AliTPCCalibSignal() : /*FOLD00*/ fLastTimeBin(120), fFirstTimeBinT0(-15), fLastTimeBinT0(15), + fNbinsT0(200), + fXminT0(-2), + fXmaxT0(2), + fNbinsQ(200), + fXminQ(14), + fXmaxQ(55), + fNbinsRMS(100), + fXminRMS(0), + fXmaxRMS(5), fLastSector(-1), fROC(AliTPCROC::Instance()), fParam(new AliTPCParam), - fPedestalTPC(0), + fPedestalTPC(0x0), fBpedestal(kFALSE), fCalRocArrayT0(72), fCalRocArrayQ(72), @@ -102,11 +107,6 @@ AliTPCCalibSignal::AliTPCCalibSignal() : /*FOLD00*/ // AliTPCSignal default constructor // - //debug stream - TDirectory *backup = gDirectory; - fDebugStreamer = new TTreeSRedirector("deb2.root"); - if ( backup ) backup->cd(); //we don't want to be cd'd to the debug streamer - } //_____________________________________________________________________ AliTPCCalibSignal::AliTPCCalibSignal(const AliTPCCalibSignal &sig) : @@ -115,6 +115,15 @@ AliTPCCalibSignal::AliTPCCalibSignal(const AliTPCCalibSignal &sig) : fLastTimeBin(sig.fLastTimeBin), fFirstTimeBinT0(sig.fFirstTimeBinT0), fLastTimeBinT0(sig.fLastTimeBinT0), + fNbinsT0(sig.fNbinsT0), + fXminT0(sig.fXminT0), + fXmaxT0(sig.fXmaxT0), + fNbinsQ(sig.fNbinsQ), + fXminQ(sig.fXminQ), + fXmaxQ(sig.fXmaxQ), + fNbinsRMS(sig.fNbinsRMS), + fXminRMS(sig.fXminRMS), + fXmaxRMS(sig.fXmaxRMS), fLastSector(-1), fROC(AliTPCROC::Instance()), fParam(new AliTPCParam), @@ -179,12 +188,6 @@ AliTPCCalibSignal::AliTPCCalibSignal(const AliTPCCalibSignal &sig) : } } - - //debug stream - TDirectory *backup = gDirectory; - fDebugStreamer = new TTreeSRedirector("deb2.root"); - if ( backup ) backup->cd(); //we don't want to be cd'd to the debug streamer - } //_____________________________________________________________________ AliTPCCalibSignal& AliTPCCalibSignal::operator = (const AliTPCCalibSignal &source) @@ -252,10 +255,6 @@ Int_t AliTPCCalibSignal::Update(const Int_t icsector, /*FOLD00*/ fCurrentRow = icRow; } - if ( fDebugLevel > 6 ) - if ( icTimeBin == fLastTimeBin ) - printf("Filling sector: %d, channel: %d\n",icsector,iChannel); - //fill signals for current pad fPadSignal[icTimeBin]=csignal; if ( csignal > fMaxPadSignal ){ @@ -270,8 +269,6 @@ void AliTPCCalibSignal::ProcessPad() /*FOLD00*/ // // Process data of current pad // - if ( fDebugLevel > 4 ) - printf("process: sector-pad: %.2d-%.4d ... ", fCurrentSector, fCurrentChannel); Float_t pedestal = 0; @@ -289,8 +286,6 @@ void AliTPCCalibSignal::ProcessPad() /*FOLD00*/ pedestal = pedestalROC->GetValue(fCurrentChannel); } else { - if ( fDebugLevel > 4 ) - printf("pedestals ... "); //find pedestal for pad on the fly //using a few timebins before the signal @@ -305,8 +300,6 @@ void AliTPCCalibSignal::ProcessPad() /*FOLD00*/ } if ( sumN>0 ) pedestal/=sumN; - if ( fDebugLevel > 4 ) - printf("%.2f ... ",pedestal); } @@ -316,11 +309,9 @@ void AliTPCCalibSignal::ProcessPad() /*FOLD00*/ Int_t tminus = 2, tplus=7; Double_t meanT=0, sigmaT=0, Qsum=0; - if ( fDebugLevel > 4 ) - printf(" mean +- sigma (sum) ... "); for (Int_t i=fMaxTimeBin-tminus; ifFirstTimeBin && i=fFirstTimeBin && i<=fLastTimeBin ){ Double_t val=fPadSignal[i]-pedestal; meanT+=val*(i+.5); //+.5: center of the timebin sigmaT+=val*(i+.5)*(i+.5); @@ -348,14 +339,6 @@ void AliTPCCalibSignal::ProcessPad() /*FOLD00*/ sigmaT = fLastTimeBinT0-fFirstTimeBinT0; //put to overflow bin } - if ( fDebugLevel > 4 ) - printf("%.3f +- %.3f (%.3f) ... ",meanT,sigmaT,Qsum); - - - if ( fDebugLevel > 4 ) - printf("filling ... "); - - //Fill Event T0 counter (*GetPadTimesEvent(fCurrentSector,kTRUE))[fCurrentChannel] = meanT; @@ -364,13 +347,11 @@ void AliTPCCalibSignal::ProcessPad() /*FOLD00*/ Float_t norm = fParam->GetPadPitchWidth(0)*fParam->GetPadPitchLength(0,0)/( fParam->GetPadPitchWidth(fCurrentSector)*fParam->GetPadPitchLength(fCurrentSector,fCurrentRow)); -// if (fCurrentChannel == 0) printf("sec, norm: %d, %f\n", fCurrentSector, norm); - //Fill Q histogram - GetHistoQ(fCurrentSector,kTRUE)->Fill(fCurrentChannel, TMath::Sqrt(Qsum*norm)); + GetHistoQ(fCurrentSector,kTRUE)->Fill( TMath::Sqrt(Qsum*norm), fCurrentChannel ); //Fill RMS histogram - GetHistoRMS(fCurrentSector,kTRUE)->Fill(fCurrentChannel, sigmaT); + GetHistoRMS(fCurrentSector,kTRUE)->Fill( sigmaT, fCurrentChannel ); //Fill debugging info @@ -380,13 +361,7 @@ void AliTPCCalibSignal::ProcessPad() /*FOLD00*/ (*GetPadQEvent(fCurrentSector,kTRUE))[fCurrentChannel]=Qsum; } - if ( fDebugLevel > 4 ) - printf("reset pad ..."); - ResetPad(); - - if ( fDebugLevel > 4 ) - printf("end\n"); } //_____________________________________________________________________ void AliTPCCalibSignal::EndEvent() /*FOLD00*/ @@ -394,7 +369,10 @@ void AliTPCCalibSignal::EndEvent() /*FOLD00*/ // // Process data of current pad // - printf("end event\n"); + //check if last pad has allready been processed, if not do so + if ( fMaxTimeBin>-1 ) ProcessPad(); + + //loop over all ROCs, fill Time0 histogram corrected for the mean Time0 of each ROC for ( Int_t iSec = 0; iSec<72; iSec++ ){ TVectorF *vTimes = GetPadTimesEvent(iSec); if ( !vTimes ) continue; @@ -403,11 +381,18 @@ void AliTPCCalibSignal::EndEvent() /*FOLD00*/ Float_t Time0 = fVTime0Offset1[iSec]/fVTime0Offset1Counter[iSec]; Float_t Time = (*vTimes)[iChannel]; - GetHistoT0(iSec,kTRUE)->Fill(iChannel,Time-Time0); + GetHistoT0(iSec,kTRUE)->Fill( Time-Time0,iChannel ); //Debug start if ( fDebugLevel>0 ){ + if ( !fDebugStreamer ) { + //debug stream + TDirectory *backup = gDirectory; + fDebugStreamer = new TTreeSRedirector("deb2.root"); + if ( backup ) backup->cd(); //we don't want to be cd'd to the debug streamer + } + Int_t row=0; Int_t pad=0; Int_t padc=0; @@ -454,47 +439,63 @@ void AliTPCCalibSignal::EndEvent() /*FOLD00*/ } //_____________________________________________________________________ -Bool_t AliTPCCalibSignal::ProcessEvent(AliRawReader *rawReader) /*FOLD00*/ +Bool_t AliTPCCalibSignal::ProcessEvent(AliTPCRawStream *rawStream) /*FOLD00*/ { // + // Event Processing loop - AliTPCRawStream // - // - - AliTPCRawStream input(rawReader); - - rawReader->Select("TPC"); - - input.SetOldRCUFormat(1); - printf("start event processing\n"); + rawStream->SetOldRCUFormat(1); ResetEvent(); Bool_t withInput = kFALSE; - while (input.Next()) { + while (rawStream->Next()) { - Int_t isector = input.GetSector(); // current sector - Int_t iRow = input.GetRow(); // current row - Int_t iPad = input.GetPad(); // current pad - Int_t iTimeBin = input.GetTime(); // current time bin - Float_t signal = input.GetSignal(); // current ADC signal + 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; } if (withInput){ - ProcessPad(); EndEvent(); } - printf("end event processing\n"); - if ( fDebugLevel>0 ) - fDebugStreamer->GetFile()->Write(); return withInput; } //_____________________________________________________________________ +Bool_t AliTPCCalibSignal::ProcessEvent(AliRawReader *rawReader) +{ + // + // Event processing loop - AliRawReader + // + + + AliTPCRawStream rawStream(rawReader); + + rawReader->Select("TPC"); + + return ProcessEvent(&rawStream); +} +//_____________________________________________________________________ +Bool_t AliTPCCalibSignal::ProcessEvent(eventHeaderStruct *event) +{ + // + // Event processing loop - date event + // + AliRawReader *rawReader = new AliRawReaderDate((void*)event); + Bool_t result=ProcessEvent(rawReader); + delete rawReader; + return result; + +} +//_____________________________________________________________________ TH2S* AliTPCCalibSignal::GetHisto(Int_t sector, TObjArray *arr, /*FOLD00*/ Int_t nbinsY, Float_t ymin, Float_t ymax, Char_t *type, Bool_t force) @@ -514,8 +515,8 @@ TH2S* AliTPCCalibSignal::GetHisto(Int_t sector, TObjArray *arr, /*FOLD00*/ // new histogram with Q calib information. One value for each pad! TH2S* hist = new TH2S(name,title, - fROC->GetNChannels(sector),0,fROC->GetNChannels(sector), - nbinsY, ymin, ymax); + nbinsY, ymin, ymax, + fROC->GetNChannels(sector),0,fROC->GetNChannels(sector)); hist->SetDirectory(0); arr->AddAt(hist,sector); return hist; @@ -528,7 +529,7 @@ TH2S* AliTPCCalibSignal::GetHistoT0(Int_t sector, Bool_t force) /*FOLD00*/ // if force is true create a new histogram if it doesn't exist allready // TObjArray *arr = &fHistoT0Array; - return GetHisto(sector, arr, 200, -2, 2, "T0", force); + return GetHisto(sector, arr, fNbinsT0, fXminT0, fXmaxT0, "T0", force); } //_____________________________________________________________________ TH2S* AliTPCCalibSignal::GetHistoQ(Int_t sector, Bool_t force) /*FOLD00*/ @@ -538,7 +539,7 @@ TH2S* AliTPCCalibSignal::GetHistoQ(Int_t sector, Bool_t force) /*FOLD00*/ // if force is true create a new histogram if it doesn't exist allready // TObjArray *arr = &fHistoQArray; - return GetHisto(sector, arr, 150, 24, 55, "Q", force); + return GetHisto(sector, arr, fNbinsQ, fXminQ, fXmaxQ, "Q", force); } //_____________________________________________________________________ TH2S* AliTPCCalibSignal::GetHistoRMS(Int_t sector, Bool_t force) /*FOLD00*/ @@ -548,7 +549,7 @@ TH2S* AliTPCCalibSignal::GetHistoRMS(Int_t sector, Bool_t force) /*FOLD00*/ // if force is true create a new histogram if it doesn't exist allready // TObjArray *arr = &fHistoRMSArray; - return GetHisto(sector, arr, 100, 0, 5, "RMS", force); + return GetHisto(sector, arr, fNbinsRMS, fXminRMS, fXmaxRMS, "RMS", force); } //_____________________________________________________________________ TVectorF* AliTPCCalibSignal::GetPadInfoEvent(Int_t sector, TObjArray *arr, Bool_t force) /*FOLD00*/ @@ -710,6 +711,10 @@ void AliTPCCalibSignal::Analyse() /*FOLD00*/ // Calculate calibration constants // + TVectorD paramQ(3); + TVectorD paramT0(3); + TVectorD paramRMS(3); + TMatrixD dummy(3,3); for (Int_t iSec=0; iSec<72; iSec++){ TH2S *hT0 = GetHistoT0(iSec); @@ -723,13 +728,19 @@ void AliTPCCalibSignal::Analyse() /*FOLD00*/ TH2S *hQ = GetHistoQ(iSec); TH2S *hRMS = GetHistoRMS(iSec); + Short_t *array_hQ = hQ->GetArray(); + Short_t *array_hT0 = hT0->GetArray(); + Short_t *array_hRMS = hRMS->GetArray(); + + UInt_t nChannels = fROC->GetNChannels(iSec); + //debug Int_t row=0; Int_t pad=0; Int_t padc=0; //! debug - for (UInt_t iChannel=0; iChannelGetNChannels(iSec); iChannel++){ + for (UInt_t iChannel=0; iChannelSetAxisRange(iChannel,iChannel); - hT0->SetAxisRange(iChannel,iChannel); - hRMS->SetAxisRange(iChannel,iChannel); - cogTime0 = hT0->GetMean(2); - cogQ = hQ->GetMean(2); - cogRMS = hRMS->GetMean(2); + Int_t offsetQ = (fNbinsQ+2)*(iChannel+1)+1; + Int_t offsetT0 = (fNbinsT0+2)*(iChannel+1)+1; + Int_t offsetRMS = (fNbinsRMS+2)*(iChannel+1)+1; + /* + AliMathBase::FitGaus(array_hQ+offsetQ,fNbinsQ,fXminQ,fXmaxQ,¶mQ,&dummy); + AliMathBase::FitGaus(array_hT0+offsetT0,fNbinsT0,fXminT0,fXmaxT0,¶mT0,&dummy); + AliMathBase::FitGaus(array_hRMS+offsetRMS,fNbinsRMS,fXminRMS,fXmaxRMS,¶mRMS,&dummy); + cogQ = paramQ[1]; + cogTime0 = paramT0[1]; + cogRMS = paramRMS[1]; +*/ + cogQ = AliMathBase::GetCOG(array_hQ+offsetQ,fNbinsQ,fXminQ,fXmaxQ); + cogTime0 = AliMathBase::GetCOG(array_hT0+offsetT0,fNbinsT0,fXminT0,fXmaxT0); + cogRMS = AliMathBase::GetCOG(array_hRMS+offsetRMS,fNbinsRMS,fXminRMS,fXmaxRMS); + + + + /* if ( (cogQ < ??) && (cogTime0 > ??) && (cogTime0??) ){ cogOut = 1; cogTime0 = 0; @@ -760,6 +783,13 @@ void AliTPCCalibSignal::Analyse() /*FOLD00*/ //debug if ( fDebugLevel > 0 ){ + if ( !fDebugStreamer ) { + //debug stream + TDirectory *backup = gDirectory; + fDebugStreamer = new TTreeSRedirector("deb2.root"); + if ( backup ) backup->cd(); //we don't want to be cd'd to the debug streamer + } + while ( iChannel > (fROC->GetRowIndexes(iSec)[row]+fROC->GetNPads(iSec,row)-1) ) row++; pad = iChannel-fROC->GetRowIndexes(iSec)[row]; padc = pad-(fROC->GetNPads(iSec,row)/2); @@ -790,7 +820,6 @@ void AliTPCCalibSignal::DumpToFile(const Char_t *filename, const Char_t *dir, Bo // Write class to file // - TDirectory *backup = gDirectory; TString sDir(dir); TString option; @@ -799,14 +828,15 @@ void AliTPCCalibSignal::DumpToFile(const Char_t *filename, const Char_t *dir, Bo else option = "recreate"; + TDirectory *backup = gDirectory; TFile f(filename,option.Data()); + f.cd(); if ( !sDir.IsNull() ){ f.mkdir(sDir.Data()); f.cd(sDir); } - gDirectory->WriteTObject(this); + this->Write(); f.Close(); if ( backup ) backup->cd(); - } diff --git a/TPC/AliTPCCalibSignal.h b/TPC/AliTPCCalibSignal.h index 13020e7f7b5..b22f4059ef1 100644 --- a/TPC/AliTPCCalibSignal.h +++ b/TPC/AliTPCCalibSignal.h @@ -3,14 +3,17 @@ /* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * * See cxx source for full Copyright notice */ +#include class TObjArray; class TH2S; class TTreeSRedirector; class AliTPCCalPad; class AliTPCROC; +class AliTPCCalROC; class AliTPCParam; class AliRawReader; - +class AliTPCRawStream; +struct eventHeaderStruct; class AliTPCCalibSignal : public TObject { @@ -22,7 +25,9 @@ public: AliTPCCalibSignal& operator = (const AliTPCCalibSignal &source); - Bool_t ProcessEvent(AliRawReader *rawReader); //center of gravity approach event by event + Bool_t ProcessEvent(AliTPCRawStream *rawStream); + Bool_t ProcessEvent(AliRawReader *rawReader); + Bool_t ProcessEvent(eventHeaderStruct *event); Int_t Update(const Int_t isector, const Int_t iRow, const Int_t iPad, const Int_t iTimeBin, const Float_t signal); @@ -46,6 +51,12 @@ public: // void SetRangeTime (Int_t firstTimeBin, Int_t lastTimeBin) { fFirstTimeBin=firstTimeBin; fLastTimeBin=lastTimeBin; } //Set range in which the pulser signal is expected void SetRangeTime0(Int_t firstTimeBin, Int_t lastTimeBin) { fFirstTimeBinT0=firstTimeBin; fLastTimeBinT0=lastTimeBin;} //Set range for analysis after T0 substraction. Should be smaller than the above and around 0 + // + void SetRangeRefQ (Int_t nBins, Float_t xMin, Float_t xMax){ fNbinsQ = nBins; fXminQ = xMin; fXmaxQ = xMax; } //Set range for Q reference histograms + void SetRangeRefT0 (Int_t nBins, Float_t xMin, Float_t xMax){ fNbinsT0 = nBins; fXminT0 = xMin; fXmaxT0 = xMax; } //Set range for T0 reference histograms + void SetRangeRefRMS(Int_t nBins, Float_t xMin, Float_t xMax){ fNbinsRMS = nBins; fXminRMS = xMin; fXmaxRMS = xMax; } //Set range for T0 reference histograms + + void SetDebugLevel(Short_t debug=1){ fDebugLevel = debug;} Int_t GetFirstTimeBin() const { return fFirstTimeBin; } @@ -61,6 +72,17 @@ private: Int_t fFirstTimeBinT0; // First Time bin after T0 correction Int_t fLastTimeBinT0; // Last Time bin after T0 correction + // reference histogram ranges + Int_t fNbinsT0; // Number of bins for T0 reference histogram + Float_t fXminT0; // xmin of T0 reference histogram + Float_t fXmaxT0; // xmax of T0 reference histogram + Int_t fNbinsQ; // Number of bins for T0 reference histogram + Float_t fXminQ; // xmin of T0 reference histogram + Float_t fXmaxQ; // xmax of T0 reference histogram + Int_t fNbinsRMS; // Number of bins for T0 reference histogram + Float_t fXminRMS; // xmin of T0 reference histogram + Float_t fXmaxRMS; // xmax of T0 reference histogram + Int_t fLastSector; //! Last sector processed AliTPCROC *fROC; //! ROC information