/* $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 <TObjArray.h>
#include <TH1F.h>
-#include <TH1D.h>
#include <TH2F.h>
-#include <TH2S.h>
-#include <TH1S.h>
#include <TString.h>
-#include <TVectorF.h>
#include <TMath.h>
#include <TF1.h>
#include <TRandom.h>
-#include <TROOT.h>
#include <TDirectory.h>
-#include <TSystem.h>
#include <TFile.h>
-
-
//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*/
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;
}
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)csignal<fAdcMin)) )
+ bin = (iChannel+1)*(fAdcMax-fAdcMin+2)+((Int_t)csignal-fAdcMin+1);
GetHistoPedestal(icsector,kTRUE)->GetArray()[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);
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);
}
}
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)
{
// 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)
);
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
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);
UInt_t nChannels = fROC->GetNChannels(iSec);
for (UInt_t iChannel=0; iChannel<nChannels; iChannel++){
-
- // set bin content of py in a dirty but fast way
- for (Int_t iAdc=0;iAdc<nbinsAdc;iAdc++)
- array_py[iAdc+1] = (Float_t)array_hP[(iChannel+1)*(nbinsAdc+2)+(iAdc+1)];
-
- gaus->SetParameters(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*/
// Write class to file
//
- TDirectory *backup = gDirectory;
TString sDir(dir);
TString option;
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();
-
}
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
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);
//Root includes
#include <TObjArray.h>
#include <TH1F.h>
-#include <TH1D.h>
-#include <TH2F.h>
#include <TH2S.h>
-#include <TH1S.h>
#include <TString.h>
#include <TVectorF.h>
#include <TMath.h>
-#include <TF1.h>
-
-#include <TStopwatch.h>
-#include <TCanvas.h>
-#include <TROOT.h>
#include <TDirectory.h>
#include <TSystem.h>
#include <TFile.h>
//AliRoot includes
#include "AliRawReader.h"
#include "AliRawReaderRoot.h"
+#include "AliRawReaderDate.h"
#include "AliTPCRawStream.h"
#include "AliTPCCalROC.h"
#include "AliTPCCalPad.h"
#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*/
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),
// 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) :
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),
}
}
-
- //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)
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 ){
//
// Process data of current pad
//
- if ( fDebugLevel > 4 )
- printf("process: sector-pad: %.2d-%.4d ... ", fCurrentSector, fCurrentChannel);
Float_t pedestal = 0;
pedestal = pedestalROC->GetValue(fCurrentChannel);
} else {
- if ( fDebugLevel > 4 )
- printf("pedestals ... ");
//find pedestal for pad on the fly
//using a few timebins before the signal
}
if ( sumN>0 ) pedestal/=sumN;
- if ( fDebugLevel > 4 )
- printf("%.2f ... ",pedestal);
}
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; i<fMaxTimeBin+tplus; i++){
- if ( i>fFirstTimeBin && i<fLastTimeBin ){
+ if ( 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);
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;
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
(*GetPadQEvent(fCurrentSector,kTRUE))[fCurrentChannel]=Qsum;
}
- if ( fDebugLevel > 4 )
- printf("reset pad ...");
-
ResetPad();
-
- if ( fDebugLevel > 4 )
- printf("end\n");
}
//_____________________________________________________________________
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;
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;
}
//_____________________________________________________________________
-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)
// 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;
// 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*/
// 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*/
// 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*/
// 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);
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; iChannel<fROC->GetNChannels(iSec); iChannel++){
+ for (UInt_t iChannel=0; iChannel<nChannels; iChannel++){
Float_t cogTime0 = -1000;
Float_t cogRMS = -1000;
Float_t cogOut = 0;
- hQ->SetAxisRange(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<??) && ( cogRMS>??) ){
cogOut = 1;
cogTime0 = 0;
//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);
// Write class to file
//
- TDirectory *backup = gDirectory;
TString sDir(dir);
TString option;
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();
-
}
/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
* See cxx source for full Copyright notice */
+#include <TVectorT.h>
class TObjArray;
class TH2S;
class TTreeSRedirector;
class AliTPCCalPad;
class AliTPCROC;
+class AliTPCCalROC;
class AliTPCParam;
class AliRawReader;
-
+class AliTPCRawStream;
+struct eventHeaderStruct;
class AliTPCCalibSignal : public TObject {
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);
//
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; }
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