1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
18 //-------------------------------------------------------
19 // Implementation of the TPC clusterer
21 // 1. The Input data for reconstruction - Options
22 // 1.a Simulated data - TTree - invoked Digits2Clusters()
23 // 1.b Raw data - Digits2Clusters(AliRawReader* rawReader);
24 // 1.c HLT clusters - Digits2Clusters and Digits2Clusters(AliRawReader* rawReader)
25 // invoke ReadHLTClusters()
28 // 2.a TTree with clusters - if SetOutput(TTree * tree) invoked
29 // 2.b TObjArray - Faster option for HLT
30 // 2.c TClonesArray - Faster option for HLT (smaller memory consumption), activate with fBClonesArray flag
32 // 3. Reconstruction setup
33 // see AliTPCRecoParam for list of parameters
34 // The reconstruction parameterization taken from the
35 // AliTPCReconstructor::GetRecoParam()
36 // Possible to setup it in reconstruction macro AliTPCReconstructor::SetRecoParam(...)
40 // Origin: Marian Ivanov
41 //-------------------------------------------------------
43 #include "Riostream.h"
48 #include <TObjArray.h>
49 #include <TClonesArray.h>
52 #include <TTreeStream.h>
56 #include "AliDigits.h"
57 #include "AliLoader.h"
59 #include "AliMathBase.h"
60 #include "AliRawEventHeaderBase.h"
61 #include "AliRawReader.h"
62 #include "AliRunLoader.h"
63 #include "AliSimDigits.h"
64 #include "AliTPCCalPad.h"
65 #include "AliTPCCalROC.h"
66 #include "AliTPCClustersArray.h"
67 #include "AliTPCClustersRow.h"
68 #include "AliTPCParam.h"
69 #include "AliTPCRawStream.h"
70 #include "AliTPCRawStreamV3.h"
71 #include "AliTPCRecoParam.h"
72 #include "AliTPCReconstructor.h"
73 #include "AliTPCcalibDB.h"
74 #include "AliTPCclusterInfo.h"
75 #include "AliTPCclusterMI.h"
76 #include "AliTPCTransform.h"
77 #include "AliTPCclustererMI.h"
79 ClassImp(AliTPCclustererMI)
83 AliTPCclustererMI::AliTPCclustererMI(const AliTPCParam* par, const AliTPCRecoParam * recoParam):
89 fMaxTime(1006), // 1000>940 so use 1000, add 3 virtual time bins before and 3 after
98 fPedSubtraction(kFALSE),
105 fOutputClonesArray(0),
113 fBDumpSignal(kFALSE),
114 fBClonesArray(kFALSE),
115 fBUseHLTClusters(kFALSE),
122 // param - tpc parameters for given file
123 // recoparam - reconstruction parameters
128 fRecoParam = recoParam;
130 //set default parameters if not specified
131 fRecoParam = AliTPCReconstructor::GetRecoParam();
132 if (!fRecoParam) fRecoParam = AliTPCRecoParam::GetLowFluxParam();
135 if(AliTPCReconstructor::StreamLevel()>0) {
136 fDebugStreamer = new TTreeSRedirector("TPCsignal.root");
139 // Int_t nPoints = fRecoParam->GetLastBin()-fRecoParam->GetFirstBin();
140 fRowCl= new AliTPCClustersRow("AliTPCclusterMI");
142 // Non-persistent arrays
144 //alocate memory for sector - maximal case
146 AliTPCROC * roc = AliTPCROC::Instance();
147 Int_t nRowsMax = roc->GetNRows(roc->GetNSector()-1);
148 Int_t nPadsMax = roc->GetNPads(roc->GetNSector()-1,nRowsMax-1);
150 fAllBins = new Float_t*[nRowsMax];
151 fAllSigBins = new Int_t*[nRowsMax];
152 fAllNSigBins = new Int_t[nRowsMax];
153 for (Int_t iRow = 0; iRow < nRowsMax; iRow++) {
155 Int_t maxBin = fMaxTime*(nPadsMax+6); // add 3 virtual pads before and 3 after
156 fAllBins[iRow] = new Float_t[maxBin];
157 memset(fAllBins[iRow],0,sizeof(Float_t)*maxBin);
158 fAllSigBins[iRow] = new Int_t[maxBin];
159 fAllNSigBins[iRow]=0;
162 //______________________________________________________________
163 AliTPCclustererMI::AliTPCclustererMI(const AliTPCclustererMI ¶m)
179 fPedSubtraction(kFALSE),
186 fOutputClonesArray(0),
194 fBDumpSignal(kFALSE),
195 fBClonesArray(kFALSE),
196 fBUseHLTClusters(kFALSE),
204 fMaxBin = param.fMaxBin;
206 //______________________________________________________________
207 AliTPCclustererMI & AliTPCclustererMI::operator =(const AliTPCclustererMI & param)
210 // assignment operator - dummy
212 fMaxBin=param.fMaxBin;
215 //______________________________________________________________
216 AliTPCclustererMI::~AliTPCclustererMI(){
220 if (fDebugStreamer) delete fDebugStreamer;
222 //fOutputArray->Delete();
225 if (fOutputClonesArray){
226 fOutputClonesArray->Delete();
227 delete fOutputClonesArray;
231 fRowCl->GetArray()->Delete();
235 AliTPCROC * roc = AliTPCROC::Instance();
236 Int_t nRowsMax = roc->GetNRows(roc->GetNSector()-1);
237 for (Int_t iRow = 0; iRow < nRowsMax; iRow++) {
238 delete [] fAllBins[iRow];
239 delete [] fAllSigBins[iRow];
242 delete [] fAllSigBins;
243 delete [] fAllNSigBins;
246 void AliTPCclustererMI::SetInput(TTree * tree)
249 // set input tree with digits
252 if (!fInput->GetBranch("Segment")){
253 cerr<<"AliTPC::Digits2Clusters(): no porper input tree !\n";
259 void AliTPCclustererMI::SetOutput(TTree * tree)
262 // Set the output tree
263 // If not set the ObjArray used - Option for HLT
267 AliTPCClustersRow clrow("AliTPCclusterMI");
268 AliTPCClustersRow *pclrow=&clrow;
269 fOutput->Branch("Segment","AliTPCClustersRow",&pclrow,32000,200);
273 void AliTPCclustererMI::FillRow(){
275 // fill the output container -
276 // 2 Options possible
280 if (fOutput) fOutput->Fill();
281 if (!fOutput && !fBClonesArray){
283 if (!fOutputArray) fOutputArray = new TObjArray(fParam->GetNRowsTotal());
284 if (fRowCl && fRowCl->GetArray()->GetEntriesFast()>0) fOutputArray->AddAt(fRowCl->Clone(), fRowCl->GetID());
288 Float_t AliTPCclustererMI::GetSigmaY2(Int_t iz){
289 // sigma y2 = in digits - we don't know the angle
290 Float_t z = iz*fParam->GetZWidth()+fParam->GetNTBinsL1()*fParam->GetZWidth();
291 Float_t sd2 = (z*fParam->GetDiffL()*fParam->GetDiffL())/
292 (fPadWidth*fPadWidth);
294 Float_t res = sd2+sres;
299 Float_t AliTPCclustererMI::GetSigmaZ2(Int_t iz){
300 //sigma z2 = in digits - angle estimated supposing vertex constraint
301 Float_t z = iz*fZWidth+fParam->GetNTBinsL1()*fParam->GetZWidth();
302 Float_t sd2 = (z*fParam->GetDiffL()*fParam->GetDiffL())/(fZWidth*fZWidth);
303 Float_t angular = fPadLength*(fParam->GetZLength(fSector)-z)/(fRx*fZWidth);
306 Float_t sres = fParam->GetZSigma()/fZWidth;
308 Float_t res = angular +sd2+sres;
312 void AliTPCclustererMI::MakeCluster(Int_t k,Int_t max,Float_t *bins, UInt_t /*m*/,
316 // k - Make cluster at position k
317 // bins - 2 D array of signals mapped to 1 dimensional array -
318 // max - the number of time bins er one dimension
319 // c - refernce to cluster to be filled
321 Int_t i0=k/max; //central pad
322 Int_t j0=k%max; //central time bin
324 // set pointers to data
325 //Int_t dummy[5] ={0,0,0,0,0};
326 Float_t * matrix[5]; //5x5 matrix with digits - indexing i = 0 ..4 j = -2..2
327 for (Int_t di=-2;di<=2;di++){
328 matrix[di+2] = &bins[k+di*max];
330 //build matrix with virtual charge
331 Float_t sigmay2= GetSigmaY2(j0);
332 Float_t sigmaz2= GetSigmaZ2(j0);
334 Float_t vmatrix[5][5];
335 vmatrix[2][2] = matrix[2][0];
337 c.SetMax((UShort_t)(vmatrix[2][2])); // write maximal amplitude
338 for (Int_t di =-1;di <=1;di++)
339 for (Int_t dj =-1;dj <=1;dj++){
340 Float_t amp = matrix[di+2][dj];
341 if ( (amp<2) && (fLoop<2)){
342 // if under threshold - calculate virtual charge
343 Float_t ratio = TMath::Exp(-1.2*TMath::Abs(di)/sigmay2)*TMath::Exp(-1.2*TMath::Abs(dj)/sigmaz2);
344 amp = ((matrix[2][0]-2)*(matrix[2][0]-2)/(matrix[-di+2][-dj]+2))*ratio;
346 vmatrix[2+di][2+dj]=amp;
347 vmatrix[2+2*di][2+2*dj]=0;
350 vmatrix[2+2*di][2+dj] =0;
351 vmatrix[2+di][2+2*dj] =0;
356 //if small amplitude - below 2 x threshold - don't consider other one
357 vmatrix[2+di][2+dj]=amp;
358 vmatrix[2+2*di][2+2*dj]=0; // don't take to the account next bin
361 vmatrix[2+2*di][2+dj] =0;
362 vmatrix[2+di][2+2*dj] =0;
366 //if bigger then take everything
367 vmatrix[2+di][2+dj]=amp;
368 vmatrix[2+2*di][2+2*dj]= matrix[2*di+2][2*dj] ;
371 vmatrix[2+2*di][2+dj] = matrix[2*di+2][dj];
372 vmatrix[2+di][2+2*dj] = matrix[2+di][dj*2];
384 for (Int_t i=-2;i<=2;i++)
385 for (Int_t j=-2;j<=2;j++){
386 Float_t amp = vmatrix[i+2][j+2];
395 Float_t meani = sumiw/sumw;
396 Float_t mi2 = sumi2w/sumw-meani*meani;
397 Float_t meanj = sumjw/sumw;
398 Float_t mj2 = sumj2w/sumw-meanj*meanj;
400 Float_t ry = mi2/sigmay2;
401 Float_t rz = mj2/sigmaz2;
404 if ( ( (ry<0.6) || (rz<0.6) ) && fLoop==2) return;
405 if ( ((ry <1.2) && (rz<1.2)) || (!fRecoParam->GetDoUnfold())) {
407 //if cluster looks like expected or Unfolding not switched on
408 //standard COG is used
409 //+1.2 deviation from expected sigma accepted
410 // c.fMax = FitMax(vmatrix,meani,meanj,TMath::Sqrt(sigmay2),TMath::Sqrt(sigmaz2));
414 //set cluster parameters
417 c.SetTimeBin(meanj-3);
421 AddCluster(c,(Float_t*)vmatrix,k);
425 //unfolding when neccessary
428 Float_t * matrix2[7]; //7x7 matrix with digits - indexing i = 0 ..6 j = -3..3
429 Float_t dummy[7]={0,0,0,0,0,0};
430 for (Int_t di=-3;di<=3;di++){
431 matrix2[di+3] = &bins[k+di*max];
432 if ((k+di*max)<3) matrix2[di+3] = &dummy[3];
433 if ((k+di*max)>fMaxBin-3) matrix2[di+3] = &dummy[3];
435 Float_t vmatrix2[5][5];
438 UnfoldCluster(matrix2,vmatrix2,meani,meanj,sumu,overlap);
440 // c.fMax = FitMax(vmatrix2,meani,meanj,TMath::Sqrt(sigmay2),TMath::Sqrt(sigmaz2));
443 //set cluster parameters
446 c.SetTimeBin(meanj-3);
449 c.SetType(Char_t(overlap)+1);
450 AddCluster(c,(Float_t*)vmatrix,k);
459 void AliTPCclustererMI::UnfoldCluster(Float_t * matrix2[7], Float_t recmatrix[5][5], Float_t & meani, Float_t & meanj,
460 Float_t & sumu, Float_t & overlap )
463 //unfold cluster from input matrix
464 //data corresponding to cluster writen in recmatrix
465 //output meani and meanj
467 //take separatelly y and z
469 Float_t sum3i[7] = {0,0,0,0,0,0,0};
470 Float_t sum3j[7] = {0,0,0,0,0,0,0};
472 for (Int_t k =0;k<7;k++)
473 for (Int_t l = -1; l<=1;l++){
474 sum3i[k]+=matrix2[k][l];
475 sum3j[k]+=matrix2[l+3][k-3];
477 Float_t mratio[3][3]={{1,1,1},{1,1,1},{1,1,1}};
480 Float_t sum3wi = 0; //charge minus overlap
481 Float_t sum3wio = 0; //full charge
482 Float_t sum3iw = 0; //sum for mean value
483 for (Int_t dk=-1;dk<=1;dk++){
484 sum3wio+=sum3i[dk+3];
490 if ( ( ((sum3i[dk+3]+3)/(sum3i[3]-3))+1 < (sum3i[2*dk+3]-3)/(sum3i[dk+3]+3))||
491 (sum3i[dk+3]<=sum3i[2*dk+3] && sum3i[dk+3]>2 )){
492 Float_t xm2 = sum3i[-dk+3];
493 Float_t xm1 = sum3i[+3];
494 Float_t x1 = sum3i[2*dk+3];
495 Float_t x2 = sum3i[3*dk+3];
496 Float_t w11 = TMath::Max((Float_t)(4.*xm1-xm2),(Float_t)0.000001);
497 Float_t w12 = TMath::Max((Float_t)(4 *x1 -x2),(Float_t)0.);
498 ratio = w11/(w11+w12);
499 for (Int_t dl=-1;dl<=1;dl++)
500 mratio[dk+1][dl+1] *= ratio;
502 Float_t amp = sum3i[dk+3]*ratio;
507 meani = sum3iw/sum3wi;
508 Float_t overlapi = (sum3wio-sum3wi)/sum3wio;
513 Float_t sum3wj = 0; //charge minus overlap
514 Float_t sum3wjo = 0; //full charge
515 Float_t sum3jw = 0; //sum for mean value
516 for (Int_t dk=-1;dk<=1;dk++){
517 sum3wjo+=sum3j[dk+3];
523 if ( ( ((sum3j[dk+3]+3)/(sum3j[3]-3))+1 < (sum3j[2*dk+3]-3)/(sum3j[dk+3]+3)) ||
524 (sum3j[dk+3]<=sum3j[2*dk+3] && sum3j[dk+3]>2)){
525 Float_t xm2 = sum3j[-dk+3];
526 Float_t xm1 = sum3j[+3];
527 Float_t x1 = sum3j[2*dk+3];
528 Float_t x2 = sum3j[3*dk+3];
529 Float_t w11 = TMath::Max((Float_t)(4.*xm1-xm2),(Float_t)0.000001);
530 Float_t w12 = TMath::Max((Float_t)(4 *x1 -x2),(Float_t)0.);
531 ratio = w11/(w11+w12);
532 for (Int_t dl=-1;dl<=1;dl++)
533 mratio[dl+1][dk+1] *= ratio;
535 Float_t amp = sum3j[dk+3]*ratio;
540 meanj = sum3jw/sum3wj;
541 Float_t overlapj = (sum3wjo-sum3wj)/sum3wjo;
542 overlap = Int_t(100*TMath::Max(overlapi,overlapj)+3);
543 sumu = (sum3wj+sum3wi)/2.;
546 //if not overlap detected remove everything
547 for (Int_t di =-2; di<=2;di++)
548 for (Int_t dj =-2; dj<=2;dj++){
549 recmatrix[di+2][dj+2] = matrix2[3+di][dj];
553 for (Int_t di =-1; di<=1;di++)
554 for (Int_t dj =-1; dj<=1;dj++){
556 if (mratio[di+1][dj+1]==1){
557 recmatrix[di+2][dj+2] = matrix2[3+di][dj];
558 if (TMath::Abs(di)+TMath::Abs(dj)>1){
559 recmatrix[2*di+2][dj+2] = matrix2[3+2*di][dj];
560 recmatrix[di+2][2*dj+2] = matrix2[3+di][2*dj];
562 recmatrix[2*di+2][2*dj+2] = matrix2[3+2*di][2*dj];
566 //if we have overlap in direction
567 recmatrix[di+2][dj+2] = mratio[di+1][dj+1]* matrix2[3+di][dj];
568 if (TMath::Abs(di)+TMath::Abs(dj)>1){
569 ratio = TMath::Min((Float_t)(recmatrix[di+2][dj+2]/(matrix2[3+0*di][1*dj]+1)),(Float_t)1.);
570 recmatrix[2*di+2][dj+2] = ratio*recmatrix[di+2][dj+2];
572 ratio = TMath::Min((Float_t)(recmatrix[di+2][dj+2]/(matrix2[3+1*di][0*dj]+1)),(Float_t)1.);
573 recmatrix[di+2][2*dj+2] = ratio*recmatrix[di+2][dj+2];
576 ratio = recmatrix[di+2][dj+2]/matrix2[3][0];
577 recmatrix[2*di+2][2*dj+2] = ratio*recmatrix[di+2][dj+2];
585 Float_t AliTPCclustererMI::FitMax(Float_t vmatrix[5][5], Float_t y, Float_t z, Float_t sigmay, Float_t sigmaz)
592 for (Int_t di = -1;di<=1;di++)
593 for (Int_t dj = -1;dj<=1;dj++){
594 if (vmatrix[2+di][2+dj]>2){
595 Float_t teor = TMath::Gaus(di,y,sigmay*1.2)*TMath::Gaus(dj,z,sigmaz*1.2);
596 sumteor += teor*vmatrix[2+di][2+dj];
597 sumamp += vmatrix[2+di][2+dj]*vmatrix[2+di][2+dj];
600 Float_t max = sumamp/sumteor;
604 void AliTPCclustererMI::AddCluster(AliTPCclusterMI &c, Float_t * /*matrix*/, Int_t /*pos*/){
607 // Transform cluster to the rotated global coordinata
608 // Assign labels to the cluster
609 // add the cluster to the array
610 // for more details - See AliTPCTranform::Transform(x,i,0,1)
611 Float_t meani = c.GetPad();
612 Float_t meanj = c.GetTimeBin();
614 Int_t ki = TMath::Nint(meani);
616 if (ki>=fMaxPad) ki = fMaxPad-1;
617 Int_t kj = TMath::Nint(meanj);
619 if (kj>=fMaxTime-3) kj=fMaxTime-4;
620 // ki and kj shifted as integers coordinata
622 c.SetLabel(fRowDig->GetTrackIDFast(kj,ki,0)-2,0);
623 c.SetLabel(fRowDig->GetTrackIDFast(kj,ki,1)-2,1);
624 c.SetLabel(fRowDig->GetTrackIDFast(kj,ki,2)-2,2);
628 c.SetDetector(fSector);
629 Float_t s2 = c.GetSigmaY2();
630 Float_t w=fParam->GetPadPitchWidth(fSector);
631 c.SetSigmaY2(s2*w*w);
633 c.SetSigmaZ2(s2*fZWidth*fZWidth);
638 AliTPCTransform *transform = AliTPCcalibDB::Instance()->GetTransform() ;
640 AliFatal("Tranformations not in calibDB");
643 transform->SetCurrentRecoParam((AliTPCRecoParam*)fRecoParam);
644 Double_t x[3]={c.GetRow(),c.GetPad(),c.GetTimeBin()};
645 Int_t i[1]={fSector};
646 transform->Transform(x,i,0,1);
652 if (ki<=1 || ki>=fMaxPad-1 || kj==1 || kj==fMaxTime-2) {
653 c.SetType(-(c.GetType()+3)); //edge clusters
655 if (fLoop==2) c.SetType(100);
656 if (!AcceptCluster(&c)) return;
659 TClonesArray * arr = 0;
660 AliTPCclusterMI * cl = 0;
662 if(fBClonesArray==kFALSE) {
663 arr = fRowCl->GetArray();
664 cl = new ((*arr)[fNcluster]) AliTPCclusterMI(c);
666 cl = new ((*fOutputClonesArray)[fNclusters+fNcluster]) AliTPCclusterMI(c);
669 // if (fRecoParam->DumpSignal() &&matrix ) {
671 // Float_t *graph =0;
672 // if (fRecoParam->GetCalcPedestal() && cl->GetMax()>fRecoParam->GetDumpAmplitudeMin() &&fBDumpSignal){
674 // graph = &(fBins[fMaxTime*(pos/fMaxTime)]);
676 // AliTPCclusterInfo * info = new AliTPCclusterInfo(matrix,nbins,graph);
677 // cl->SetInfo(info);
679 if (!fRecoParam->DumpSignal()) {
683 if (AliTPCReconstructor::StreamLevel()>1) {
685 cl->GetGlobalXYZ(xyz);
686 (*fDebugStreamer)<<"Clusters"<<
698 //_____________________________________________________________________________
699 void AliTPCclustererMI::Digits2Clusters()
701 //-----------------------------------------------------------------
702 // This is a simple cluster finder.
703 //-----------------------------------------------------------------
706 Error("Digits2Clusters", "input tree not initialised");
709 fRecoParam = AliTPCReconstructor::GetRecoParam();
711 AliFatal("Can not get the reconstruction parameters");
713 if(AliTPCReconstructor::StreamLevel()>5) {
714 AliInfo("Parameter Dumps");
719 //-----------------------------------------------------------------
721 //-----------------------------------------------------------------
722 if (fBUseHLTClusters) {
723 AliInfo("Using HLT clusters for TPC off-line reconstruction");
724 fZWidth = fParam->GetZWidth();
730 //-----------------------------------------------------------------
731 // Run TPC off-line clusterer
732 //-----------------------------------------------------------------
733 AliTPCCalPad * gainTPC = AliTPCcalibDB::Instance()->GetPadGainFactor();
734 AliTPCCalPad * noiseTPC = AliTPCcalibDB::Instance()->GetPadNoise();
735 AliSimDigits digarr, *dummy=&digarr;
737 fInput->GetBranch("Segment")->SetAddress(&dummy);
738 Stat_t nentries = fInput->GetEntries();
740 fMaxTime=fRecoParam->GetLastBin()+6; // add 3 virtual time bins before and 3 after
744 for (Int_t n=0; n<nentries; n++) {
746 if (!fParam->AdjustSectorRow(digarr.GetID(),fSector,fRow)) {
747 cerr<<"AliTPC warning: invalid segment ID ! "<<digarr.GetID()<<endl;
751 AliTPCCalROC * gainROC = gainTPC->GetCalROC(fSector); // pad gains per given sector
752 AliTPCCalROC * noiseROC = noiseTPC->GetCalROC(fSector); // noise per given sector
755 fRowCl->SetID(digarr.GetID());
756 if (fOutput) fOutput->GetBranch("Segment")->SetAddress(&fRowCl);
757 fRx=fParam->GetPadRowRadii(fSector,row);
760 const Int_t kNIS=fParam->GetNInnerSector(), kNOS=fParam->GetNOuterSector();
761 fZWidth = fParam->GetZWidth();
762 if (fSector < kNIS) {
763 fMaxPad = fParam->GetNPadsLow(row);
764 fSign = (fSector < kNIS/2) ? 1 : -1;
765 fPadLength = fParam->GetPadPitchLength(fSector,row);
766 fPadWidth = fParam->GetPadPitchWidth();
768 fMaxPad = fParam->GetNPadsUp(row);
769 fSign = ((fSector-kNIS) < kNOS/2) ? 1 : -1;
770 fPadLength = fParam->GetPadPitchLength(fSector,row);
771 fPadWidth = fParam->GetPadPitchWidth();
775 fMaxBin=fMaxTime*(fMaxPad+6); // add 3 virtual pads before and 3 after
776 fBins =new Float_t[fMaxBin];
777 fSigBins =new Int_t[fMaxBin];
779 memset(fBins,0,sizeof(Float_t)*fMaxBin);
781 if (digarr.First()) //MI change
783 Float_t dig=digarr.CurrentDigit();
784 if (dig<=fParam->GetZeroSup()) continue;
785 Int_t j=digarr.CurrentRow()+3, i=digarr.CurrentColumn()+3;
786 Float_t gain = gainROC->GetValue(row,digarr.CurrentColumn());
787 Int_t bin = i*fMaxTime+j;
793 fSigBins[fNSigBins++]=bin;
794 } while (digarr.Next());
795 digarr.ExpandTrackBuffer();
797 FindClusters(noiseROC);
799 fRowCl->GetArray()->Clear("C");
800 nclusters+=fNcluster;
806 Info("Digits2Clusters", "Number of found clusters : %d", nclusters);
809 void AliTPCclustererMI::ProcessSectorData(){
811 // Process the data for the current sector
814 AliTPCCalPad * pedestalTPC = AliTPCcalibDB::Instance()->GetPedestals();
815 AliTPCCalPad * noiseTPC = AliTPCcalibDB::Instance()->GetPadNoise();
816 AliTPCCalROC * pedestalROC = pedestalTPC->GetCalROC(fSector); // pedestal per given sector
817 AliTPCCalROC * noiseROC = noiseTPC->GetCalROC(fSector); // noise per given sector
818 //check the presence of the calibration
819 if (!noiseROC ||!pedestalROC ) {
820 AliError(Form("Missing calibration per sector\t%d\n",fSector));
823 Int_t nRows=fParam->GetNRow(fSector);
824 Bool_t calcPedestal = fRecoParam->GetCalcPedestal();
825 Int_t zeroSup = fParam->GetZeroSup();
826 // if (calcPedestal) {
828 for (Int_t iRow = 0; iRow < nRows; iRow++) {
829 Int_t maxPad = fParam->GetNPads(fSector, iRow);
831 for (Int_t iPad = 3; iPad < maxPad + 3; iPad++) {
833 // Temporary fix for data production - !!!! MARIAN
834 // The noise calibration should take mean and RMS - currently the Gaussian fit used
835 // In case of double peak - the pad should be rejected
837 // Line mean - if more than given digits over threshold - make a noise calculation
838 // and pedestal substration
839 if (!calcPedestal && fAllBins[iRow][iPad*fMaxTime+0]<50) continue;
841 if (fAllBins[iRow][iPad*fMaxTime+0] <1 ) continue; // no data
842 Float_t *p = &fAllBins[iRow][iPad*fMaxTime+3];
843 //Float_t pedestal = TMath::Median(fMaxTime, p);
844 Int_t id[3] = {fSector, iRow, iPad-3};
846 Double_t rmsCalib= noiseROC->GetValue(iRow,iPad-3);
847 Double_t pedestalCalib = pedestalROC->GetValue(iRow,iPad-3);
848 Double_t rmsEvent = rmsCalib;
849 Double_t pedestalEvent = pedestalCalib;
850 ProcesSignal(p, fMaxTime, id, rmsEvent, pedestalEvent);
851 if (rmsEvent<rmsCalib) rmsEvent = rmsCalib; // take worst scenario
852 if (TMath::Abs(pedestalEvent-pedestalCalib)<1.0) pedestalEvent = pedestalCalib;
855 for (Int_t iTimeBin = 0; iTimeBin < fMaxTime; iTimeBin++) {
856 Int_t bin = iPad*fMaxTime+iTimeBin;
857 fAllBins[iRow][bin] -= pedestalEvent;
858 if (iTimeBin < fRecoParam->GetFirstBin())
859 fAllBins[iRow][bin] = 0;
860 if (iTimeBin > fRecoParam->GetLastBin())
861 fAllBins[iRow][bin] = 0;
862 if (fAllBins[iRow][iPad*fMaxTime+iTimeBin] < zeroSup)
863 fAllBins[iRow][bin] = 0;
864 if (fAllBins[iRow][bin] < 3.0*rmsEvent) // 3 sigma cut on RMS
865 fAllBins[iRow][bin] = 0;
866 if (fAllBins[iRow][bin]) fAllSigBins[iRow][fAllNSigBins[iRow]++] = bin;
872 if (AliTPCReconstructor::StreamLevel()>5) {
873 for (Int_t iRow = 0; iRow < nRows; iRow++) {
874 Int_t maxPad = fParam->GetNPads(fSector,iRow);
876 for (Int_t iPad = 3; iPad < maxPad + 3; iPad++) {
877 for (Int_t iTimeBin = 0; iTimeBin < fMaxTime; iTimeBin++) {
878 Int_t bin = iPad*fMaxTime+iTimeBin;
879 Float_t signal = fAllBins[iRow][bin];
880 if (AliTPCReconstructor::StreamLevel()>3 && signal>3) {
881 Double_t x[]={iRow,iPad-3,iTimeBin-3};
883 AliTPCTransform trafo;
884 trafo.Transform(x,i,0,1);
885 Double_t gx[3]={x[0],x[1],x[2]};
886 trafo.RotatedGlobal2Global(fSector,gx);
887 // fAllSigBins[iRow][fAllNSigBins[iRow]++]
888 Int_t rowsigBins = fAllNSigBins[iRow];
889 Int_t first=fAllSigBins[iRow][0];
891 // if (rowsigBins>0) fAllSigBins[iRow][fAllNSigBins[iRow]-1];
893 if (AliTPCReconstructor::StreamLevel()>5) {
894 (*fDebugStreamer)<<"Digits"<<
907 "rowsigBins="<<rowsigBins<<
918 // Now loop over rows and find clusters
919 for (fRow = 0; fRow < nRows; fRow++) {
920 fRowCl->SetID(fParam->GetIndex(fSector, fRow));
921 if (fOutput) fOutput->GetBranch("Segment")->SetAddress(&fRowCl);
923 fRx = fParam->GetPadRowRadii(fSector, fRow);
924 fPadLength = fParam->GetPadPitchLength(fSector, fRow);
925 fPadWidth = fParam->GetPadPitchWidth();
926 fMaxPad = fParam->GetNPads(fSector,fRow);
927 fMaxBin = fMaxTime*(fMaxPad+6); // add 3 virtual pads before and 3 after
929 fBins = fAllBins[fRow];
930 fSigBins = fAllSigBins[fRow];
931 fNSigBins = fAllNSigBins[fRow];
933 FindClusters(noiseROC);
936 if(fBClonesArray == kFALSE) fRowCl->GetArray()->Clear("C");
937 fNclusters += fNcluster;
939 } // End of loop to find clusters
943 void AliTPCclustererMI::Digits2Clusters(AliRawReader* rawReader)
945 //-----------------------------------------------------------------
946 // This is a cluster finder for the TPC raw data.
947 // The method assumes NO ordering of the altro channels.
948 // The pedestal subtraction can be switched on and off
949 // using an option of the TPC reconstructor
950 //-----------------------------------------------------------------
951 fRecoParam = AliTPCReconstructor::GetRecoParam();
953 AliFatal("Can not get the reconstruction parameters");
955 if(AliTPCReconstructor::StreamLevel()>5) {
956 AliInfo("Parameter Dumps");
962 //-----------------------------------------------------------------
964 //-----------------------------------------------------------------
965 if (fBUseHLTClusters) {
966 AliInfo("Using HLT clusters for TPC off-line reconstruction");
967 fZWidth = fParam->GetZWidth();
973 //-----------------------------------------------------------------
974 // Run TPC off-line clusterer
975 //-----------------------------------------------------------------
976 AliTPCCalPad * gainTPC = AliTPCcalibDB::Instance()->GetPadGainFactor();
977 AliTPCAltroMapping** mapping =AliTPCcalibDB::Instance()->GetMapping();
979 AliTPCRawStreamV3 input(rawReader,(AliAltroMapping**)mapping);
980 fEventHeader = (AliRawEventHeaderBase*)rawReader->GetEventHeader();
982 fTimeStamp = fEventHeader->Get("Timestamp");
983 fEventType = fEventHeader->Get("Type");
984 AliTPCTransform *transform = AliTPCcalibDB::Instance()->GetTransform() ;
985 transform->SetCurrentTimeStamp(fTimeStamp);
986 transform->SetCurrentRun(rawReader->GetRunNumber());
989 // creaate one TClonesArray for all clusters
990 if(fBClonesArray && !fOutputClonesArray) fOutputClonesArray = new TClonesArray("AliTPCclusterMI",1000);
994 fMaxTime = fRecoParam->GetLastBin() + 6; // add 3 virtual time bins before and 3 after
995 // const Int_t kNIS = fParam->GetNInnerSector();
996 // const Int_t kNOS = fParam->GetNOuterSector();
997 // const Int_t kNS = kNIS + kNOS;
998 fZWidth = fParam->GetZWidth();
999 Int_t zeroSup = fParam->GetZeroSup();
1003 AliTPCROC * roc = AliTPCROC::Instance();
1004 Int_t nRowsMax = roc->GetNRows(roc->GetNSector()-1);
1005 Int_t nPadsMax = roc->GetNPads(roc->GetNSector()-1,nRowsMax-1);
1006 for (Int_t iRow = 0; iRow < nRowsMax; iRow++) {
1008 Int_t maxBin = fMaxTime*(nPadsMax+6); // add 3 virtual pads before and 3 after
1009 memset(fAllBins[iRow],0,sizeof(Float_t)*maxBin);
1010 fAllNSigBins[iRow]=0;
1013 Int_t prevSector=-1;
1019 const Int_t kNIS = fParam->GetNInnerSector();
1020 const Int_t kNOS = fParam->GetNOuterSector();
1021 const Int_t kNS = kNIS + kNOS;
1023 for(fSector = 0; fSector < kNS; fSector++) {
1026 Int_t nDDLs = 0, indexDDL = 0;
1027 if (fSector < kNIS) {
1028 nRows = fParam->GetNRowLow();
1029 fSign = (fSector < kNIS/2) ? 1 : -1;
1031 indexDDL = fSector * 2;
1034 nRows = fParam->GetNRowUp();
1035 fSign = ((fSector-kNIS) < kNOS/2) ? 1 : -1;
1037 indexDDL = (fSector-kNIS) * 4 + kNIS * 2;
1040 // load the raw data for corresponding DDLs
1042 rawReader->Select("TPC",indexDDL,indexDDL+nDDLs-1);
1044 while (input.NextDDL()){
1045 if (input.GetSector() != fSector)
1046 AliFatal(Form("Sector index mismatch ! Expected (%d), but got (%d) !",fSector,input.GetSector()));
1048 //Int_t nRows = fParam->GetNRow(fSector);
1050 AliTPCCalROC * gainROC = gainTPC->GetCalROC(fSector); // pad gains per given sector
1051 // Begin loop over altro data
1052 Bool_t calcPedestal = fRecoParam->GetCalcPedestal();
1056 while ( input.NextChannel() ) {
1057 Int_t iRow = input.GetRow();
1062 AliError(Form("Pad-row index (%d) outside the range (%d -> %d) !",
1063 iRow, 0, nRows -1));
1067 Int_t iPad = input.GetPad();
1068 if (iPad < 0 || iPad >= nPadsMax) {
1069 AliError(Form("Pad index (%d) outside the range (%d -> %d) !",
1070 iPad, 0, nPadsMax-1));
1073 gain = gainROC->GetValue(iRow,iPad);
1077 while ( input.NextBunch() ){
1078 Int_t startTbin = (Int_t)input.GetStartTimeBin();
1079 Int_t bunchlength = (Int_t)input.GetBunchLength();
1080 const UShort_t *sig = input.GetSignals();
1081 for (Int_t iTime = 0; iTime<bunchlength; iTime++){
1082 Int_t iTimeBin=startTbin-iTime;
1083 if ( iTimeBin < fRecoParam->GetFirstBin() || iTimeBin >= fRecoParam->GetLastBin()){
1085 AliFatal(Form("Timebin index (%d) outside the range (%d -> %d) !",
1086 iTimeBin, 0, iTimeBin -1));
1090 Float_t signal=(Float_t)sig[iTime];
1091 if (!calcPedestal && signal <= zeroSup) continue;
1093 if (!calcPedestal) {
1094 Int_t bin = iPad*fMaxTime+iTimeBin;
1096 fAllBins[iRow][bin] = signal/gain;
1098 fAllBins[iRow][bin] =0;
1100 fAllSigBins[iRow][fAllNSigBins[iRow]++] = bin;
1102 fAllBins[iRow][iPad*fMaxTime+iTimeBin] = signal;
1104 fAllBins[iRow][iPad*fMaxTime+0]+=1.; // pad with signal
1108 }// end loop signals in bunch
1109 }// end loop bunches
1115 // Now loop over rows and perform pedestal subtraction
1116 if (digCounter==0) continue;
1117 } // End of loop over sectors
1118 //process last sector
1119 if ( digCounter>0 ){
1120 ProcessSectorData();
1121 for (Int_t iRow = 0; iRow < fParam->GetNRow(fSector); iRow++) {
1122 Int_t maxPad = fParam->GetNPads(fSector,iRow);
1123 Int_t maxBin = fMaxTime*(maxPad+6); // add 3 virtual pads before and 3 after
1124 memset(fAllBins[iRow],0,sizeof(Float_t)*maxBin);
1125 fAllNSigBins[iRow] = 0;
1132 if (rawReader->GetEventId() && fOutput ){
1133 Info("Digits2Clusters", "File %s Event\t%u\tNumber of found clusters : %d\n", fOutput->GetName(),*(rawReader->GetEventId()), fNclusters);
1136 if(rawReader->GetEventId()) {
1137 Info("Digits2Clusters", "Event\t%u\tNumber of found clusters : %d\n",*(rawReader->GetEventId()), fNclusters);
1141 //Info("Digits2Clusters", "Number of found clusters : %d\n",fOutputClonesArray->GetEntriesFast());
1149 void AliTPCclustererMI::Digits2ClustersOld
1150 (AliRawReader* rawReader)
1152 //-----------------------------------------------------------------
1153 // This is a cluster finder for the TPC raw data.
1154 // The method assumes NO ordering of the altro channels.
1155 // The pedestal subtraction can be switched on and off
1156 // using an option of the TPC reconstructor
1157 //-----------------------------------------------------------------
1158 fRecoParam = AliTPCReconstructor::GetRecoParam();
1160 AliFatal("Can not get the reconstruction parameters");
1162 if(AliTPCReconstructor::StreamLevel()>5) {
1163 AliInfo("Parameter Dumps");
1169 AliTPCCalPad * gainTPC = AliTPCcalibDB::Instance()->GetPadGainFactor();
1170 AliTPCAltroMapping** mapping =AliTPCcalibDB::Instance()->GetMapping();
1172 AliTPCRawStream input(rawReader,(AliAltroMapping**)mapping);
1173 fEventHeader = (AliRawEventHeaderBase*)rawReader->GetEventHeader();
1175 fTimeStamp = fEventHeader->Get("Timestamp");
1176 fEventType = fEventHeader->Get("Type");
1179 // creaate one TClonesArray for all clusters
1180 if(fBClonesArray && !fOutputClonesArray) fOutputClonesArray = new TClonesArray("AliTPCclusterMI",1000);
1184 fMaxTime = fRecoParam->GetLastBin() + 6; // add 3 virtual time bins before and 3 after
1185 const Int_t kNIS = fParam->GetNInnerSector();
1186 const Int_t kNOS = fParam->GetNOuterSector();
1187 const Int_t kNS = kNIS + kNOS;
1188 fZWidth = fParam->GetZWidth();
1189 Int_t zeroSup = fParam->GetZeroSup();
1194 AliTPCROC * roc = AliTPCROC::Instance();
1195 Int_t nRowsMax = roc->GetNRows(roc->GetNSector()-1);
1196 Int_t nPadsMax = roc->GetNPads(roc->GetNSector()-1,nRowsMax-1);
1197 for (Int_t iRow = 0; iRow < nRowsMax; iRow++) {
1199 Int_t maxBin = fMaxTime*(nPadsMax+6); // add 3 virtual pads before and 3 after
1200 memset(fAllBins[iRow],0,sizeof(Float_t)*maxBin);
1201 fAllNSigBins[iRow]=0;
1204 // Loop over sectors
1206 for(fSector = 0; fSector < kNS; fSector++) {
1209 Int_t nDDLs = 0, indexDDL = 0;
1210 if (fSector < kNIS) {
1211 nRows = fParam->GetNRowLow();
1212 fSign = (fSector < kNIS/2) ? 1 : -1;
1214 indexDDL = fSector * 2;
1217 nRows = fParam->GetNRowUp();
1218 fSign = ((fSector-kNIS) < kNOS/2) ? 1 : -1;
1220 indexDDL = (fSector-kNIS) * 4 + kNIS * 2;
1223 // load the raw data for corresponding DDLs
1225 rawReader->Select("TPC",indexDDL,indexDDL+nDDLs-1);
1227 // select only good sector
1228 if (!input.Next()) continue;
1229 if(input.GetSector() != fSector) continue;
1231 AliTPCCalROC * gainROC = gainTPC->GetCalROC(fSector); // pad gains per given sector
1233 for (Int_t iRow = 0; iRow < nRows; iRow++) {
1236 maxPad = fParam->GetNPadsLow(iRow);
1238 maxPad = fParam->GetNPadsUp(iRow);
1240 Int_t maxBin = fMaxTime*(maxPad+6); // add 3 virtual pads before and 3 after
1241 memset(fAllBins[iRow],0,sizeof(Float_t)*maxBin);
1242 fAllNSigBins[iRow] = 0;
1246 // Begin loop over altro data
1247 Bool_t calcPedestal = fRecoParam->GetCalcPedestal();
1252 while (input.Next()) {
1253 if (input.GetSector() != fSector)
1254 AliFatal(Form("Sector index mismatch ! Expected (%d), but got (%d) !",fSector,input.GetSector()));
1257 Int_t iRow = input.GetRow();
1262 if (iRow < 0 || iRow >= nRows){
1263 AliError(Form("Pad-row index (%d) outside the range (%d -> %d) !",
1264 iRow, 0, nRows -1));
1268 Int_t iPad = input.GetPad();
1269 if (iPad < 0 || iPad >= nPadsMax) {
1270 AliError(Form("Pad index (%d) outside the range (%d -> %d) !",
1271 iPad, 0, nPadsMax-1));
1275 gain = gainROC->GetValue(iRow,iPad);
1280 Int_t iTimeBin = input.GetTime();
1281 if ( iTimeBin < fRecoParam->GetFirstBin() || iTimeBin >= fRecoParam->GetLastBin()){
1283 AliFatal(Form("Timebin index (%d) outside the range (%d -> %d) !",
1284 iTimeBin, 0, iTimeBin -1));
1289 Float_t signal = input.GetSignal();
1290 if (!calcPedestal && signal <= zeroSup) continue;
1292 if (!calcPedestal) {
1293 Int_t bin = iPad*fMaxTime+iTimeBin;
1295 fAllBins[iRow][bin] = signal/gain;
1297 fAllBins[iRow][bin] =0;
1299 fAllSigBins[iRow][fAllNSigBins[iRow]++] = bin;
1301 fAllBins[iRow][iPad*fMaxTime+iTimeBin] = signal;
1303 fAllBins[iRow][iPad*fMaxTime+0]+=1.; // pad with signal
1307 } // End of the loop over altro data
1312 // Now loop over rows and perform pedestal subtraction
1313 if (digCounter==0) continue;
1314 ProcessSectorData();
1315 } // End of loop over sectors
1317 if (rawReader->GetEventId() && fOutput ){
1318 Info("Digits2Clusters", "File %s Event\t%d\tNumber of found clusters : %d\n", fOutput->GetName(),*(rawReader->GetEventId()), fNclusters);
1321 if(rawReader->GetEventId()) {
1322 Info("Digits2Clusters", "Event\t%d\tNumber of found clusters : %d\n",*(rawReader->GetEventId()), fNclusters);
1326 //Info("Digits2Clusters", "Number of found clusters : %d\n",fOutputClonesArray->GetEntriesFast());
1330 void AliTPCclustererMI::FindClusters(AliTPCCalROC * noiseROC)
1334 // add virtual charge at the edge
1336 Double_t kMaxDumpSize = 500000;
1338 fBDumpSignal =kFALSE;
1340 if (fRecoParam->GetCalcPedestal() && fOutput->GetZipBytes()< kMaxDumpSize) fBDumpSignal =kTRUE; //dump signal flag
1345 Int_t crtime = Int_t((fParam->GetZLength(fSector)-fRecoParam->GetCtgRange()*fRx)/fZWidth-fParam->GetNTBinsL1()-5);
1346 Float_t minMaxCutAbs = fRecoParam->GetMinMaxCutAbs();
1347 Float_t minLeftRightCutAbs = fRecoParam->GetMinLeftRightCutAbs();
1348 Float_t minUpDownCutAbs = fRecoParam->GetMinUpDownCutAbs();
1349 Float_t minMaxCutSigma = fRecoParam->GetMinMaxCutSigma();
1350 Float_t minLeftRightCutSigma = fRecoParam->GetMinLeftRightCutSigma();
1351 Float_t minUpDownCutSigma = fRecoParam->GetMinUpDownCutSigma();
1352 Int_t useOnePadCluster = fRecoParam->GetUseOnePadCluster();
1353 for (Int_t iSig = 0; iSig < fNSigBins; iSig++) {
1354 Int_t i = fSigBins[iSig];
1355 if (i%fMaxTime<=crtime) continue;
1356 Float_t *b = &fBins[i];
1358 if (b[0]<minMaxCutAbs) continue; //threshold for maxima
1360 if (useOnePadCluster==0){
1361 if (b[-1]+b[1]+b[-fMaxTime]+b[fMaxTime]<=0) continue; // cut on isolated clusters
1362 if (b[-1]+b[1]<=0) continue; // cut on isolated clusters
1363 if (b[-fMaxTime]+b[fMaxTime]<=0) continue; // cut on isolated clusters
1366 if ((b[0]+b[-1]+b[1])<minUpDownCutAbs) continue; //threshold for up down (TRF)
1367 if ((b[0]+b[-fMaxTime]+b[fMaxTime])<minLeftRightCutAbs) continue; //threshold for left right (PRF)
1368 if (!IsMaximum(*b,fMaxTime,b)) continue;
1370 Float_t noise = noiseROC->GetValue(fRow, i/fMaxTime);
1371 if (noise>fRecoParam->GetMaxNoise()) continue;
1373 if (b[0]<minMaxCutSigma*noise) continue; //threshold form maxima
1374 if ((b[0]+b[-1]+b[1])<minUpDownCutSigma*noise) continue; //threshold for up town TRF
1375 if ((b[0]+b[-fMaxTime]+b[fMaxTime])<minLeftRightCutSigma*noise) continue; //threshold for left right (PRF)
1377 AliTPCclusterMI c; // default cosntruction without info
1379 MakeCluster(i, fMaxTime, fBins, dummy,c);
1385 Bool_t AliTPCclustererMI::AcceptCluster(AliTPCclusterMI *cl){
1387 // Currently hack to filter digital noise (15.06.2008)
1388 // To be parameterized in the AliTPCrecoParam
1389 // More inteligent way to be used in future
1390 // Acces to the proper pedestal file needed
1392 if (cl->GetMax()<400) return kTRUE;
1393 Double_t ratio = cl->GetQ()/cl->GetMax();
1394 if (cl->GetMax()>700){
1395 if ((ratio - int(ratio)>0.8)) return kFALSE;
1397 if ((ratio - int(ratio)<0.95)) return kTRUE;
1402 Double_t AliTPCclustererMI::ProcesSignal(Float_t *signal, Int_t nchannels, Int_t id[3], Double_t &rmsEvent, Double_t &pedestalEvent){
1404 // process signal on given pad - + streaming of additional information in special mode
1411 // ESTIMATE pedestal and the noise
1413 const Int_t kPedMax = 100;
1419 Float_t rmsCalib = rmsEvent; // backup initial value ( from calib)
1420 Float_t pedestalCalib = pedestalEvent;// backup initial value ( from calib)
1421 Int_t firstBin = fRecoParam->GetFirstBin();
1423 UShort_t histo[kPedMax];
1424 //memset(histo,0,kPedMax*sizeof(UShort_t));
1425 for (Int_t i=0; i<kPedMax; i++) histo[i]=0;
1426 for (Int_t i=0; i<fMaxTime; i++){
1427 if (signal[i]<=0) continue;
1428 if (signal[i]>max && i>firstBin) {
1432 if (signal[i]>kPedMax-1) continue;
1433 histo[int(signal[i]+0.5)]++;
1437 for (Int_t i=1; i<kPedMax; i++){
1438 if (count1<count0*0.5) median=i;
1443 Float_t count10=histo[median] ,mean=histo[median]*median, rms=histo[median]*median*median ;
1444 Float_t count06=histo[median] ,mean06=histo[median]*median, rms06=histo[median]*median*median ;
1445 Float_t count09=histo[median] ,mean09=histo[median]*median, rms09=histo[median]*median*median ;
1447 for (Int_t idelta=1; idelta<10; idelta++){
1448 if (median-idelta<=0) continue;
1449 if (median+idelta>kPedMax) continue;
1450 if (count06<0.6*count1){
1451 count06+=histo[median-idelta];
1452 mean06 +=histo[median-idelta]*(median-idelta);
1453 rms06 +=histo[median-idelta]*(median-idelta)*(median-idelta);
1454 count06+=histo[median+idelta];
1455 mean06 +=histo[median+idelta]*(median+idelta);
1456 rms06 +=histo[median+idelta]*(median+idelta)*(median+idelta);
1458 if (count09<0.9*count1){
1459 count09+=histo[median-idelta];
1460 mean09 +=histo[median-idelta]*(median-idelta);
1461 rms09 +=histo[median-idelta]*(median-idelta)*(median-idelta);
1462 count09+=histo[median+idelta];
1463 mean09 +=histo[median+idelta]*(median+idelta);
1464 rms09 +=histo[median+idelta]*(median+idelta)*(median+idelta);
1466 if (count10<0.95*count1){
1467 count10+=histo[median-idelta];
1468 mean +=histo[median-idelta]*(median-idelta);
1469 rms +=histo[median-idelta]*(median-idelta)*(median-idelta);
1470 count10+=histo[median+idelta];
1471 mean +=histo[median+idelta]*(median+idelta);
1472 rms +=histo[median+idelta]*(median+idelta)*(median+idelta);
1477 rms = TMath::Sqrt(TMath::Abs(rms/count10-mean*mean));
1481 rms06 = TMath::Sqrt(TMath::Abs(rms06/count06-mean06*mean06));
1485 rms09 = TMath::Sqrt(TMath::Abs(rms09/count09-mean09*mean09));
1489 pedestalEvent = median;
1490 if (AliLog::GetDebugLevel("","AliTPCclustererMI")==0) return median;
1492 UInt_t uid[3] = {UInt_t(id[0]),UInt_t(id[1]),UInt_t(id[2])};
1494 // Dump mean signal info
1496 if (AliTPCReconstructor::StreamLevel()>0) {
1497 (*fDebugStreamer)<<"Signal"<<
1498 "TimeStamp="<<fTimeStamp<<
1499 "EventType="<<fEventType<<
1513 "RMSCalib="<<rmsCalib<<
1514 "PedCalib="<<pedestalCalib<<
1518 // fill pedestal histogram
1523 Float_t kMin =fRecoParam->GetDumpAmplitudeMin(); // minimal signal to be dumped
1524 Float_t *dsignal = new Float_t[nchannels];
1525 Float_t *dtime = new Float_t[nchannels];
1526 for (Int_t i=0; i<nchannels; i++){
1528 dsignal[i] = signal[i];
1532 // Big signals dumping
1534 if (AliTPCReconstructor::StreamLevel()>0) {
1535 if (max-median>kMin &&maxPos>fRecoParam->GetFirstBin())
1536 (*fDebugStreamer)<<"SignalB"<< // pads with signal
1537 "TimeStamp="<<fTimeStamp<<
1538 "EventType="<<fEventType<<
1542 // "Graph="<<graph<<
1558 if (rms06>fRecoParam->GetMaxNoise()) {
1559 pedestalEvent+=1024.;
1560 return 1024+median; // sign noisy channel in debug mode
1565 Int_t AliTPCclustererMI::ReadHLTClusters()
1568 // read HLT clusters instead of off line custers,
1569 // used in Digits2Clusters
1572 TObject* pClusterAccess=NULL;
1574 ROOT::NewFunc_t pNewFunc=NULL;
1576 pCl=TClass::GetClass("AliHLTTPCClusterAccessHLTOUT");
1577 } while (!pCl && gSystem->Load("libAliHLTTPC.so")==0);
1578 if (!pCl || (pNewFunc=pCl->GetNew())==NULL) {
1579 AliError("can not load class description of AliHLTTPCClusterAccessHLTOUT, aborting ...");
1583 void* p=(*pNewFunc)(NULL);
1585 AliError("unable to create instance of AliHLTTPCClusterAccessHLTOUT");
1588 pClusterAccess=reinterpret_cast<TObject*>(p);
1589 if (!pClusterAccess) {
1590 AliError("instance not of type TObject");
1594 const Int_t kNIS = fParam->GetNInnerSector();
1595 const Int_t kNOS = fParam->GetNOuterSector();
1596 const Int_t kNS = kNIS + kNOS;
1599 for(fSector = 0; fSector < kNS; fSector++) {
1601 TString param("sector="); param+=fSector;
1602 pClusterAccess->Clear();
1603 pClusterAccess->Execute("read", param);
1604 if (pClusterAccess->FindObject("clusterarray")==NULL) {
1605 AliError("HLT clusters requested, but not cluster array not present");
1609 TClonesArray* clusterArray=dynamic_cast<TClonesArray*>(pClusterAccess->FindObject("clusterarray"));
1610 if (!clusterArray) {
1611 AliError("HLT cluster array is not of class type TClonesArray");
1615 AliDebug(4,Form("Reading %d clusters from HLT for sector %d", clusterArray->GetEntriesFast(), fSector));
1617 Int_t nClusterSector=0;
1618 Int_t nRows=fParam->GetNRow(fSector);
1620 for (fRow = 0; fRow < nRows; fRow++) {
1621 fRowCl->SetID(fParam->GetIndex(fSector, fRow));
1622 if (fOutput) fOutput->GetBranch("Segment")->SetAddress(&fRowCl);
1623 fNcluster=0; // reset clusters per row
1625 fRx = fParam->GetPadRowRadii(fSector, fRow);
1626 fPadLength = fParam->GetPadPitchLength(fSector, fRow);
1627 fPadWidth = fParam->GetPadPitchWidth();
1628 fMaxPad = fParam->GetNPads(fSector,fRow);
1629 fMaxBin = fMaxTime*(fMaxPad+6); // add 3 virtual pads before and 3 after
1631 fBins = fAllBins[fRow];
1632 fSigBins = fAllSigBins[fRow];
1633 fNSigBins = fAllNSigBins[fRow];
1635 for (Int_t i=0; i<clusterArray->GetEntriesFast(); i++) {
1636 if (!clusterArray->At(i))
1639 AliTPCclusterMI* cluster=dynamic_cast<AliTPCclusterMI*>(clusterArray->At(i));
1640 if (!cluster) continue;
1641 if (cluster->GetRow()!=fRow) continue;
1643 AddCluster(*cluster, NULL, 0);
1647 fRowCl->GetArray()->Clear("c");
1649 } // for (fRow = 0; fRow < nRows; fRow++) {
1650 if (nClusterSector!=clusterArray->GetEntriesFast()) {
1651 AliError(Form("Failed to read %d out of %d HLT clusters",
1652 clusterArray->GetEntriesFast()-nClusterSector,
1653 clusterArray->GetEntriesFast()));
1655 fNclusters+=nClusterSector;
1656 } // for(fSector = 0; fSector < kNS; fSector++) {
1658 delete pClusterAccess;
1660 Info("Digits2Clusters", "Number of converted HLT clusters : %d", fNclusters);