#include "AliRawReaderRoot.h"
#include "AliRawReaderDate.h"
#include "AliTPCRawStream.h"
+#include "AliTPCRawStreamFast.h"
#include "AliTPCCalROC.h"
#include "AliTPCCalPad.h"
#include "AliTPCROC.h"
#include "AliTPCCalibPulser.h"
#include "AliTPCcalibDB.h"
#include "AliMathBase.h"
+#include "AliLog.h"
#include "TTreeStream.h"
//date
fLastSector(-1),
fOldRCUformat(kTRUE),
fROC(AliTPCROC::Instance()),
+ fMapping(NULL),
fParam(new AliTPCParam),
fPedestalTPC(0x0),
fPadNoiseTPC(0x0),
+ fOutliers(0x0),
fPedestalROC(0x0),
fPadNoiseROC(0x0),
fCalRocArrayT0(72),
fLastSector(-1),
fOldRCUformat(kTRUE),
fROC(AliTPCROC::Instance()),
+ fMapping(NULL),
fParam(new AliTPCParam),
fPedestalTPC(0x0),
fPadNoiseTPC(0x0),
+ fOutliers(0x0),
fPedestalROC(0x0),
fPadNoiseROC(0x0),
fCalRocArrayT0(72),
// 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 fROC;
- delete fParam;
}
//_____________________________________________________________________
Int_t AliTPCCalibPulser::Update(const Int_t icsector,
// 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);
Double_t meanT = param[1];
Double_t sigmaT = param[2];
+
//Fill Event T0 counter
(*GetPadTimesEvent(fCurrentSector,kTRUE)).GetMatrixArray()[fCurrentChannel] = meanT;
//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];
GetHistoT0(iSec,kTRUE)->Fill( time-time0,iChannel );
+ //GetHistoT0(iSec,kTRUE)->Fill( time,iChannel );
//Debug start
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)
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");
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(arrayhQ+offsetQ,fNbinsQ,fXminQ,fXmaxQ,¶mQ,&dummy);
AliMathBase::FitGaus(arrayhT0+offsetT0,fNbinsT0,fXminT0,fXmaxT0,¶mT0,&dummy);
cogTime0 = AliMathBase::GetCOG(arrayhT0+offsetT0,fNbinsT0,fXminT0,fXmaxT0);
cogRMS = AliMathBase::GetCOG(arrayhRMS+offsetRMS,fNbinsRMS,fXminRMS,fXmaxRMS);
-
-
/*
if ( (cogQ < ??) && (cogTime0 > ??) && (cogTime0<??) && ( cogRMS>??) ){
cogOut = 1;
"\n";
}
//! debug
-
}
-
}
delete fDebugStreamer;
fDebugStreamer = 0x0;