/* $Id$ */
-//Root includes
-#include <TH1F.h>
-#include <TH2S.h>
-#include <TString.h>
-#include <TVectorF.h>
-#include <TMath.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 "AliTPCParam.h"
-#include "AliTPCCalibPulser.h"
-#include "AliTPCcalibDB.h"
-#include "AliMathBase.h"
-#include "TTreeStream.h"
-
-//date
-#include "event.h"
-
-
-///////////////////////////////////////////////////////////////////////////////////////
-// Implementation of the TPC pulser calibration
-//
-// Origin: Jens Wiechula, Marian Ivanov J.Wiechula@gsi.de, Marian.Ivanov@cern.ch
-//
-//
+/////////////////////////////////////////////////////////////////////////////////////////
+// //
+// Implementation of the TPC pulser calibration //
+// //
+// Origin: Jens Wiechula, Marian Ivanov J.Wiechula@gsi.de, Marian.Ivanov@cern.ch //
+// //
+/////////////////////////////////////////////////////////////////////////////////////////
/***************************************************************************
* Class Description *
***************************************************************************
*/
-ClassImp(AliTPCCalibPulser) /*FOLD00*/
+//Root includes
+#include <TObjArray.h>
+#include <TH1F.h>
+#include <TH2S.h>
+#include <TString.h>
+#include <TVectorF.h>
+#include <TMath.h>
+
+#include <TDirectory.h>
+#include <TSystem.h>
+#include <TROOT.h>
+#include <TFile.h>
+
+//AliRoot includes
+#include "AliRawReader.h"
+#include "AliRawReaderRoot.h"
+#include "AliRawReaderDate.h"
+#include "AliTPCRawStream.h"
+#include "AliTPCRawStreamFast.h"
+#include "AliTPCCalROC.h"
+#include "AliTPCCalPad.h"
+#include "AliTPCROC.h"
+#include "AliTPCParam.h"
+#include "AliTPCCalibPulser.h"
+#include "AliTPCcalibDB.h"
+#include "AliMathBase.h"
+#include "AliLog.h"
+#include "TTreeStream.h"
+
+//date
+#include "event.h"
+
-AliTPCCalibPulser::AliTPCCalibPulser() : /*FOLD00*/
+
+
+ClassImp(AliTPCCalibPulser)
+
+AliTPCCalibPulser::AliTPCCalibPulser() :
TObject(),
fFirstTimeBin(60),
fLastTimeBin(120),
fLastSector(-1),
fOldRCUformat(kTRUE),
fROC(AliTPCROC::Instance()),
+ fMapping(NULL),
fParam(new AliTPCParam),
fPedestalTPC(0x0),
fPadNoiseTPC(0x0),
+ fOutliers(0x0),
fPedestalROC(0x0),
fPadNoiseROC(0x0),
fCalRocArrayT0(72),
fPadNoise(0),
fVTime0Offset(72),
fVTime0OffsetCounter(72),
- fEvent(-1),
+// fEvent(-1),
fDebugStreamer(0x0),
fDebugLevel(0)
{
fLastSector(-1),
fOldRCUformat(kTRUE),
fROC(AliTPCROC::Instance()),
+ fMapping(NULL),
fParam(new AliTPCParam),
fPedestalTPC(0x0),
fPadNoiseTPC(0x0),
+ fOutliers(0x0),
fPedestalROC(0x0),
fPadNoiseROC(0x0),
fCalRocArrayT0(72),
fPadNoise(0),
fVTime0Offset(72),
fVTime0OffsetCounter(72),
- fEvent(-1),
+// fEvent(-1),
fDebugStreamer(0x0),
fDebugLevel(sig.fDebugLevel)
{
// destructor
//
+ Reset();
+
+ if ( fDebugStreamer) delete fDebugStreamer;
+ delete fROC;
+ delete fParam;
+}
+void AliTPCCalibPulser::Reset()
+{
+ //
+ // Delete all information: Arrays, Histograms, CalRoc objects
+ //
fCalRocArrayT0.Delete();
fCalRocArrayQ.Delete();
fCalRocArrayRMS.Delete();
fPadQArrayEvent.Delete();
fPadRMSArrayEvent.Delete();
fPadPedestalArrayEvent.Delete();
-
- if ( fDebugStreamer) delete fDebugStreamer;
- delete fParam;
}
//_____________________________________________________________________
-Int_t AliTPCCalibPulser::Update(const Int_t icsector, /*FOLD00*/
+Int_t AliTPCCalibPulser::Update(const Int_t icsector,
const Int_t icRow,
const Int_t icPad,
const Int_t icTimeBin,
const Float_t csignal)
{
//
- // Signal filling methode on the fly pedestal and Time offset correction if necessary.
+ // Signal filling methode on the fly pedestal and time offset correction if necessary.
// no extra analysis necessary. Assumes knowledge of the signal shape!
// assumes that it is looped over consecutive time bins of one pad
//
+
+ if (icRow<0) return 0;
+ if (icPad<0) return 0;
+ if (icTimeBin<0) return 0;
if ( (icTimeBin>fLastTimeBin) || (icTimeBin<fFirstTimeBin) ) return 0;
+ if ( icRow<0 || icPad<0 ){
+ AliWarning("Wrong Pad or Row number, skipping!");
+ return 0;
+ }
+
Int_t iChannel = fROC->GetRowIndexes(icsector)[icRow]+icPad; // global pad position in sector
//init first pad and sector in this event
}
// truncated mean
//
+ // what if by chance histo[median] == 0 ?!?
Float_t count=histo[median] ,mean=histo[median]*median, rms=histo[median]*median*median ;
//
for (Int_t idelta=1; idelta<10; ++idelta){
Float_t ceQmax =0, ceQsum=0, ceTime=0, ceRMS=0;
Int_t cemaxpos = fMaxTimeBin;
- Float_t ceSumThreshold = 8.*fPadNoise; // threshold for the signal sum
+ Float_t ceSumThreshold = 10.*TMath::Max(fPadNoise,Float_t(1.)); // threshold for the signal sum
+ Float_t ceMaxThreshold = 5.*TMath::Max(fPadNoise,Float_t(1.)); // threshold for the signal max
const Int_t kCemin = 2; // range for the analysis of the ce signal +- channels from the peak
const Int_t kCemax = 7;
+ param[0] = ceQmax;
+ param[1] = ceTime;
+ param[2] = ceRMS;
+ qSum = ceQsum;
- if (cemaxpos!=0){
- ceQmax = fPadSignal.GetMatrixArray()[cemaxpos]-fPadPedestal;
+ if (cemaxpos>0){
+ ceQmax = fPadSignal.GetMatrixArray()[cemaxpos]-fPadPedestal;
+ if ( ceQmax<ceMaxThreshold ) return;
for (Int_t i=cemaxpos-kCemin; i<cemaxpos+kCemax; ++i){
Float_t signal = fPadSignal.GetMatrixArray()[i]-fPadPedestal;
if ( (i>fFirstTimeBin) && (i<fLastTimeBin) && (signal>0) ){
}
}
}
- if (ceQmax&&ceQsum>ceSumThreshold) {
+ if (ceQsum>ceSumThreshold) {
ceTime/=ceQsum;
ceRMS = TMath::Sqrt(TMath::Abs(ceRMS/ceQsum-ceTime*ceTime));
- fVTime0Offset.GetMatrixArray()[fCurrentSector]+=ceTime; // mean time for each sector
- fVTime0OffsetCounter.GetMatrixArray()[fCurrentSector]++;
+ //only fill the Time0Offset if pad was not marked as an outlier!
+ if ( !fOutliers ){
+ fVTime0Offset.GetMatrixArray()[fCurrentSector]+=ceTime; // mean time for each sector
+ fVTime0OffsetCounter.GetMatrixArray()[fCurrentSector]++;
+ } else {
+ if ( !(fOutliers->GetCalROC(fCurrentSector)->GetValue(fCurrentChannel)) ){
+ fVTime0Offset.GetMatrixArray()[fCurrentSector]+=ceTime; // mean time for each sector
+ fVTime0OffsetCounter.GetMatrixArray()[fCurrentSector]++;
+ }
+ }
//Normalise Q to the pad area
Float_t norm = fParam->GetPadPitchWidth(fCurrentSector)*fParam->GetPadPitchLength(fCurrentSector,fCurrentRow);
qSum = ceQsum;
}
//_____________________________________________________________________
-void AliTPCCalibPulser::ProcessPad() /*FOLD00*/
+void AliTPCCalibPulser::ProcessPad()
{
//
// Process data of current pad
FindPedestal();
TVectorD param(3);
- Float_t Qsum;
- FindPulserSignal(param, Qsum);
+ Float_t qSum;
+ FindPulserSignal(param, qSum);
Double_t meanT = param[1];
Double_t sigmaT = param[2];
+
//Fill Event T0 counter
(*GetPadTimesEvent(fCurrentSector,kTRUE)).GetMatrixArray()[fCurrentChannel] = meanT;
//Fill Q histogram
- GetHistoQ(fCurrentSector,kTRUE)->Fill( TMath::Sqrt(Qsum), fCurrentChannel );
+ GetHistoQ(fCurrentSector,kTRUE)->Fill( TMath::Sqrt(qSum), fCurrentChannel );
//Fill RMS histogram
GetHistoRMS(fCurrentSector,kTRUE)->Fill( sigmaT, fCurrentChannel );
if ( fDebugLevel>0 ){
(*GetPadPedestalEvent(fCurrentSector,kTRUE))[fCurrentChannel]=fPadPedestal;
(*GetPadRMSEvent(fCurrentSector,kTRUE))[fCurrentChannel]=sigmaT;
- (*GetPadQEvent(fCurrentSector,kTRUE))[fCurrentChannel]=Qsum;
+ (*GetPadQEvent(fCurrentSector,kTRUE))[fCurrentChannel]=qSum;
}
-
ResetPad();
}
//_____________________________________________________________________
-void AliTPCCalibPulser::EndEvent() /*FOLD00*/
+void AliTPCCalibPulser::EndEvent()
{
//
// Process data of current event
//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;
-
+ if ( !vTimes || fVTime0OffsetCounter[iSec]==0 ) continue;
+ Float_t time0 = fVTime0Offset[iSec]/fVTime0OffsetCounter[iSec];
for ( UInt_t iChannel=0; iChannel<fROC->GetNChannels(iSec); ++iChannel ){
- Float_t Time0 = fVTime0Offset[iSec]/fVTime0OffsetCounter[iSec];
- Float_t Time = (*vTimes).GetMatrixArray()[iChannel];
+ Float_t time = (*vTimes).GetMatrixArray()[iChannel];
- GetHistoT0(iSec,kTRUE)->Fill( Time-Time0,iChannel );
+ GetHistoT0(iSec,kTRUE)->Fill( time-time0,iChannel );
+ //GetHistoT0(iSec,kTRUE)->Fill( time,iChannel );
//Debug start
Int_t pad=0;
Int_t padc=0;
- Float_t Q = (*GetPadQEvent(iSec)).GetMatrixArray()[iChannel];
- Float_t RMS = (*GetPadRMSEvent(iSec)).GetMatrixArray()[iChannel];
+ Float_t q = (*GetPadQEvent(iSec)).GetMatrixArray()[iChannel];
+ Float_t rms = (*GetPadRMSEvent(iSec)).GetMatrixArray()[iChannel];
UInt_t channel=iChannel;
Int_t sector=iSec;
h1->Fill(i,fPadSignal(i));
(*fDebugStreamer) << "DataPad" <<
- "Event=" << fEvent <<
+// "Event=" << fEvent <<
"Sector="<< sector <<
"Row=" << row<<
"Pad=" << pad <<
"PadC=" << padc <<
"PadSec="<< channel <<
- "Time0=" << Time0 <<
- "Time=" << Time <<
- "RMS=" << RMS <<
- "Sum=" << Q <<
+ "Time0=" << time0 <<
+ "Time=" << time <<
+ "RMS=" << rms <<
+ "Sum=" << q <<
"hist.=" << h1 <<
"\n";
delete h1;
}
//Debug end
-
}
}
+}
+//_____________________________________________________________________
+Bool_t AliTPCCalibPulser::ProcessEventFast(AliTPCRawStreamFast *rawStreamFast)
+{
+ //
+ // Event Processing loop - AliTPCRawStream
+ //
+ ResetEvent();
+
+ 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
+
+ while ( rawStreamFast->NextBunch() ){
+ Int_t startTbin = (Int_t)rawStreamFast->GetStartTimeBin();
+ Int_t endTbin = (Int_t)rawStreamFast->GetEndTimeBin();
+ 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;
+ }
+ }
+ }
+ }
+ if (withInput){
+ EndEvent();
+ }
+ return withInput;
+}
+//_____________________________________________________________________
+Bool_t AliTPCCalibPulser::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 AliTPCCalibPulser::ProcessEvent(AliTPCRawStream *rawStream) /*FOLD00*/
+Bool_t AliTPCCalibPulser::ProcessEvent(AliTPCRawStream *rawStream)
{
//
// Event Processing loop - AliTPCRawStream
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
Update(isector,iRow,iPad,iTimeBin,signal);
withInput = kTRUE;
}
-
if (withInput){
EndEvent();
}
-
return withInput;
}
//_____________________________________________________________________
//
- AliTPCRawStream rawStream(rawReader);
+ AliTPCRawStream rawStream(rawReader, (AliAltroMapping**)fMapping);
rawReader->Select("TPC");
}
//_____________________________________________________________________
-TH2S* AliTPCCalibPulser::GetHisto(Int_t sector, TObjArray *arr, /*FOLD00*/
+TH2S* AliTPCCalibPulser::GetHisto(Int_t sector, TObjArray *arr,
Int_t nbinsY, Float_t ymin, Float_t ymax,
Char_t *type, Bool_t force)
{
return hist;
}
//_____________________________________________________________________
-TH2S* AliTPCCalibPulser::GetHistoT0(Int_t sector, Bool_t force) /*FOLD00*/
+TH2S* AliTPCCalibPulser::GetHistoT0(Int_t sector, Bool_t force)
{
//
// return pointer to T0 histogram
return GetHisto(sector, arr, fNbinsT0, fXminT0, fXmaxT0, "T0", force);
}
//_____________________________________________________________________
-TH2S* AliTPCCalibPulser::GetHistoQ(Int_t sector, Bool_t force) /*FOLD00*/
+TH2S* AliTPCCalibPulser::GetHistoQ(Int_t sector, Bool_t force)
{
//
// return pointer to Q histogram
return GetHisto(sector, arr, fNbinsQ, fXminQ, fXmaxQ, "Q", force);
}
//_____________________________________________________________________
-TH2S* AliTPCCalibPulser::GetHistoRMS(Int_t sector, Bool_t force) /*FOLD00*/
+TH2S* AliTPCCalibPulser::GetHistoRMS(Int_t sector, Bool_t force)
{
//
// return pointer to Q histogram
return GetHisto(sector, arr, fNbinsRMS, fXminRMS, fXmaxRMS, "RMS", force);
}
//_____________________________________________________________________
-TVectorF* AliTPCCalibPulser::GetPadInfoEvent(Int_t sector, TObjArray *arr, Bool_t force) /*FOLD00*/
+TVectorF* AliTPCCalibPulser::GetPadInfoEvent(Int_t sector, TObjArray *arr, Bool_t force)
{
//
// return pointer to Pad Info from 'arr' for the current event and sector
return vect;
}
//_____________________________________________________________________
-TVectorF* AliTPCCalibPulser::GetPadTimesEvent(Int_t sector, Bool_t force) /*FOLD00*/
+TVectorF* AliTPCCalibPulser::GetPadTimesEvent(Int_t sector, Bool_t force)
{
//
// return pointer to Pad Times Array for the current event and sector
return GetPadInfoEvent(sector,arr,force);
}
//_____________________________________________________________________
-TVectorF* AliTPCCalibPulser::GetPadQEvent(Int_t sector, Bool_t force) /*FOLD00*/
+TVectorF* AliTPCCalibPulser::GetPadQEvent(Int_t sector, Bool_t force)
{
//
// return pointer to Pad Q Array for the current event and sector
return GetPadInfoEvent(sector,arr,force);
}
//_____________________________________________________________________
-TVectorF* AliTPCCalibPulser::GetPadRMSEvent(Int_t sector, Bool_t force) /*FOLD00*/
+TVectorF* AliTPCCalibPulser::GetPadRMSEvent(Int_t sector, Bool_t force)
{
//
// return pointer to Pad RMS Array for the current event and sector
return GetPadInfoEvent(sector,arr,force);
}
//_____________________________________________________________________
-TVectorF* AliTPCCalibPulser::GetPadPedestalEvent(Int_t sector, Bool_t force) /*FOLD00*/
+TVectorF* AliTPCCalibPulser::GetPadPedestalEvent(Int_t sector, Bool_t force)
{
//
// return pointer to Pad RMS Array for the current event and sector
return GetPadInfoEvent(sector,arr,force);
}
//_____________________________________________________________________
-AliTPCCalROC* AliTPCCalibPulser::GetCalRoc(Int_t sector, TObjArray* arr, Bool_t force) /*FOLD00*/
+AliTPCCalROC* AliTPCCalibPulser::GetCalRoc(Int_t sector, TObjArray* arr, Bool_t force) const
{
//
// return pointer to ROC Calibration
return croc;
}
//_____________________________________________________________________
-AliTPCCalROC* AliTPCCalibPulser::GetCalRocT0(Int_t sector, Bool_t force) /*FOLD00*/
+AliTPCCalROC* AliTPCCalibPulser::GetCalRocT0(Int_t sector, Bool_t force)
{
//
// return pointer to Carge ROC Calibration
return GetCalRoc(sector, arr, force);
}
//_____________________________________________________________________
-AliTPCCalROC* AliTPCCalibPulser::GetCalRocQ(Int_t sector, Bool_t force) /*FOLD00*/
+AliTPCCalROC* AliTPCCalibPulser::GetCalRocQ(Int_t sector, Bool_t force)
{
//
// return pointer to T0 ROC Calibration
return GetCalRoc(sector, arr, force);
}
//_____________________________________________________________________
-AliTPCCalROC* AliTPCCalibPulser::GetCalRocRMS(Int_t sector, Bool_t force) /*FOLD00*/
+AliTPCCalROC* AliTPCCalibPulser::GetCalRocRMS(Int_t sector, Bool_t force)
{
//
// return pointer to signal width ROC Calibration
return GetCalRoc(sector, arr, force);
}
//_____________________________________________________________________
-void AliTPCCalibPulser::ResetEvent() /*FOLD00*/
+void AliTPCCalibPulser::ResetEvent()
{
//
// Reset global counters -- Should be called before each event is processed
}
}
//_____________________________________________________________________
-void AliTPCCalibPulser::ResetPad() /*FOLD00*/
+void AliTPCCalibPulser::ResetPad()
{
//
// Reset pad infos -- Should be called after a pad has been processed
}
}
//_____________________________________________________________________
-void AliTPCCalibPulser::Analyse() /*FOLD00*/
+void AliTPCCalibPulser::Analyse()
{
//
// Calculate calibration constants
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();
+ Short_t *arrayhQ = hQ->GetArray();
+ Short_t *arrayhT0 = hT0->GetArray();
+ Short_t *arrayhRMS = hRMS->GetArray();
UInt_t nChannels = fROC->GetNChannels(iSec);
for (UInt_t iChannel=0; iChannel<nChannels; ++iChannel){
-
Float_t cogTime0 = -1000;
Float_t cogQ = -1000;
Float_t cogRMS = -1000;
Float_t cogOut = 0;
-
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);
+ AliMathBase::FitGaus(arrayhQ+offsetQ,fNbinsQ,fXminQ,fXmaxQ,¶mQ,&dummy);
+ AliMathBase::FitGaus(arrayhT0+offsetT0,fNbinsT0,fXminT0,fXmaxT0,¶mT0,&dummy);
+ AliMathBase::FitGaus(arrayhRMS+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);
-
-
+ cogQ = AliMathBase::GetCOG(arrayhQ+offsetQ,fNbinsQ,fXminQ,fXmaxQ);
+ cogTime0 = AliMathBase::GetCOG(arrayhT0+offsetT0,fNbinsT0,fXminT0,fXmaxT0);
+ cogRMS = AliMathBase::GetCOG(arrayhRMS+offsetRMS,fNbinsRMS,fXminRMS,fXmaxRMS);
/*
if ( (cogQ < ??) && (cogTime0 > ??) && (cogTime0<??) && ( cogRMS>??) ){
"\n";
}
//! debug
-
}
-
}
delete fDebugStreamer;
fDebugStreamer = 0x0;