From 65c045f08b3230ef8e2b921779526424e7d4e22a Mon Sep 17 00:00:00 2001 From: hristov Date: Mon, 12 Jun 2006 16:51:45 +0000 Subject: [PATCH] New functioanality added - ProcessSignal + Extraction of the pedestal and noise (working in special run mode _data without zero suppresion AliLog::SetClassDebugLevel(AliTPCclustererMI,2)) (Marian) --- TPC/AliTPCclustererMI.cxx | 210 +++++++++++++++++++++++++++++++++++++- TPC/AliTPCclustererMI.h | 8 +- 2 files changed, 214 insertions(+), 4 deletions(-) diff --git a/TPC/AliTPCclustererMI.cxx b/TPC/AliTPCclustererMI.cxx index 430f9aa6bec..129c7c2b639 100644 --- a/TPC/AliTPCclustererMI.cxx +++ b/TPC/AliTPCclustererMI.cxx @@ -26,6 +26,11 @@ #include "AliTPCclusterMI.h" #include #include +#include "TGraph.h" +#include "TF1.h" +#include "TRandom.h" +#include "AliMathBase.h" + #include "AliTPCClustersArray.h" #include "AliTPCClustersRow.h" #include "AliDigits.h" @@ -37,10 +42,11 @@ #include "AliLoader.h" #include "Riostream.h" #include - #include "AliTPCcalibDB.h" #include "AliTPCCalPad.h" #include "AliTPCCalROC.h" +#include "TTreeStream.h" +#include "AliLog.h" ClassImp(AliTPCclustererMI) @@ -54,6 +60,14 @@ AliTPCclustererMI::AliTPCclustererMI(const AliTPCParam* par) fInput =0; fOutput=0; fParam = par; + fDebugStreamer = new TTreeSRedirector("TPCsignal.root"); + fAmplitudeHisto = 0; +} + +AliTPCclustererMI::~AliTPCclustererMI(){ + DumpHistos(); + if (fAmplitudeHisto) delete fAmplitudeHisto; + if (fDebugStreamer) delete fDebugStreamer; } void AliTPCclustererMI::SetInput(TTree * tree) @@ -661,7 +675,7 @@ void AliTPCclustererMI::Digits2Clusters(AliRawReader* rawReader) Float_t gain = gainROC->GetValue(iRow,input.GetPad()); allBins[iRow][iPad*fMaxTime+iTimeBin] = signal/gain; - + allBins[iRow][iPad*fMaxTime+0] = 1; // pad with signal } // End of the loop over altro data // Now loop over rows and perform pedestal subtraction @@ -674,8 +688,11 @@ void AliTPCclustererMI::Digits2Clusters(AliRawReader* rawReader) maxPad = fParam->GetNPadsUp(iRow); for (Int_t iPad = 0; iPad < maxPad + 6; iPad++) { + if (allBins[iRow][iPad*fMaxTime+0] !=1) continue; // no data Float_t *p = &allBins[iRow][iPad*fMaxTime+3]; - Float_t pedestal = TMath::Median(fMaxTime, p); + //Float_t pedestal = TMath::Median(fMaxTime, p); + Int_t id[3] = {fSector, iRow, iPad-3}; + Float_t pedestal = ProcesSignal(p, fMaxTime, id); for (Int_t iTimeBin = 0; iTimeBin < fMaxTime; iTimeBin++) { allBins[iRow][iPad*fMaxTime+iTimeBin] -= pedestal; if (allBins[iRow][iPad*fMaxTime+iTimeBin] < zeroSup) @@ -794,3 +811,190 @@ void AliTPCclustererMI::FindClusters() } */ } + + +Double_t AliTPCclustererMI::ProcesSignal(Float_t *signal, Int_t nchannels, Int_t id[3]){ + // + // process signal on given pad - + streaming of additional information in special mode + // + // id[0] - sector + // id[1] - row + // id[2] - pad + Int_t offset =100; + Float_t kMin =50; + Float_t kMaxNoise = 3; + Double_t median = TMath::Median(nchannels-offset, &(signal[offset])); + if (AliLog::GetDebugLevel("","AliTPCclustererMI")==0) return median; + // + + Double_t mean = TMath::Mean(nchannels-offset, &(signal[offset])); + Double_t rms = TMath::RMS(nchannels-offset, &(signal[offset])); + Double_t *dsignal = new Double_t[nchannels]; + Double_t *dtime = new Double_t[nchannels]; + Float_t max = 0; + Float_t maxPos = 0; + for (Int_t i=0; imax && i GetNSectors() + && uid[1]< AliTPCROC::Instance()->GetNRows(uid[0]) && + uid[2] < AliTPCROC::Instance()->GetNPads(uid[0], uid[1])){ + if (!fAmplitudeHisto){ + fAmplitudeHisto = new TObjArray(72); + } + TObjArray * sectorArray = (TObjArray*)fAmplitudeHisto->UncheckedAt(uid[0]); + if (!sectorArray){ + Int_t npads = AliTPCROC::Instance()->GetNChannels(uid[0]); + sectorArray = new TObjArray(npads); + fAmplitudeHisto->AddAt(sectorArray, uid[0]); + } + Int_t position = uid[2]+ AliTPCROC::Instance()->GetRowIndexes(uid[0])[uid[1]]; + TH1F * histo = (TH1F*)sectorArray->UncheckedAt(position); + if (!histo){ + char hname[100]; + sprintf(hname,"Amp_%d_%d_%d",uid[0],uid[1],uid[2]); + TFile * backup = gFile; + fDebugStreamer->GetFile()->cd(); + histo = new TH1F(hname, hname, 100, 1,100); + //histo->SetDirectory(0); // histogram not connected to directory -(File) + sectorArray->AddAt(histo, position); + if (backup) backup->cd(); + } + for (Int_t i=0; i0) histo->Fill(signal[i]); + } + } + // + TGraph * graph; + Bool_t random = (gRandom->Rndm()<0.0001); + if (max-median>kMin || rms06>2.*fParam->GetZeroSup() || random){ + graph =new TGraph(nchannels, dtime, dsignal); + if (rms06>2.*fParam->GetZeroSup() || random) + (*fDebugStreamer)<<"SignalN"<< //noise pads - or random sample of pads + "Sector="<kMin) + (*fDebugStreamer)<<"SignalB"<< // pads with signal + "Sector="<kMaxNoise) return 1024+median; // sign noisy channel in debug mode + return median; +} + + + +void AliTPCclustererMI::DumpHistos(){ + if (!fAmplitudeHisto) return; + for (UInt_t isector=0; isectorGetNSectors(); isector++){ + TObjArray * array = (TObjArray*)fAmplitudeHisto->UncheckedAt(isector); + if (!array) continue; + for (UInt_t ipad = 0; ipad <(UInt_t)array->GetEntriesFast(); ipad++){ + TH1F * histo = (TH1F*) array->UncheckedAt(ipad); + if (!histo) continue; + if (histo->GetEntries()<100) continue; + histo->Fit("gaus","q"); + Float_t mean = histo->GetMean(); + Float_t rms = histo->GetRMS(); + Float_t gmean = histo->GetFunction("gaus")->GetParameter(1); + Float_t gsigma = histo->GetFunction("gaus")->GetParameter(2); + Float_t max = histo->GetFunction("gaus")->GetParameter(0); + + // get pad number + UInt_t row=0, pad =0; + const UInt_t *indexes = AliTPCROC::Instance()->GetRowIndexes(isector); + for (UInt_t irow=0; irow< AliTPCROC::Instance()->GetNRows(isector); irow++){ + if (indexes[irow]GetNPads(isector,row))/2; + // + (*fDebugStreamer)<<"Fit"<< + "Sector="<UncheckedAt(ipad)) fDebugStreamer->StoreObject(array->UncheckedAt(ipad)); + } + } +} diff --git a/TPC/AliTPCclustererMI.h b/TPC/AliTPCclustererMI.h index 057944211e0..205d72b12a4 100644 --- a/TPC/AliTPCclustererMI.h +++ b/TPC/AliTPCclustererMI.h @@ -24,10 +24,12 @@ class AliTPCClustersRow; class AliRawReader; class AliSimDigits; class TTree; +class TTreeSRedirector; class AliTPCclustererMI : public TObject{ public: AliTPCclustererMI(const AliTPCParam* par); + virtual ~AliTPCclustererMI(); virtual void Digits2Clusters(); virtual void Digits2Clusters(AliRawReader* rawReader); virtual void SetPedSubtraction(Bool_t pedestalSub = kFALSE) @@ -49,7 +51,8 @@ private: void UnfoldCluster(Float_t * matrix[7], Float_t recmatrix[5][5], Float_t & meani, Float_t & meanj, Float_t & sum, Float_t &overlap ); void FindClusters(); - + Double_t ProcesSignal(Float_t * signal, Int_t nchannels, Int_t id[3]); + void DumpHistos(); Float_t * fBins; //!digits array @@ -75,6 +78,9 @@ private: AliSimDigits * fRowDig; //! current digits row const AliTPCParam * fParam; //! tpc parameters Int_t fNcluster; // number of clusters - for given row + TObjArray * fAmplitudeHisto; //! array of histograms of amplitudes + TTreeSRedirector *fDebugStreamer; //!debug streamer + ClassDef(AliTPCclustererMI,1) // Time Projection Chamber digits }; -- 2.43.0