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()
27 // fUseHLTClusters - switches between different inputs
28 // 1 -> only TPC raw/sim data
29 // 2 -> if present TPC raw/sim data, otherwise HLT clusters
30 // 3 -> only HLT clusters
31 // 4 -> if present HLT clusters, otherwise TPC raw/sim data
34 // 2.a TTree with clusters - if SetOutput(TTree * tree) invoked
35 // 2.b TObjArray - Faster option for HLT
36 // 2.c TClonesArray - Faster option for HLT (smaller memory consumption), activate with fBClonesArray flag
38 // 3. Reconstruction setup
39 // see AliTPCRecoParam for list of parameters
40 // The reconstruction parameterization taken from the
41 // AliTPCReconstructor::GetRecoParam()
42 // Possible to setup it in reconstruction macro AliTPCReconstructor::SetRecoParam(...)
46 // Origin: Marian Ivanov
47 //-------------------------------------------------------
49 #include "Riostream.h"
54 #include <TObjArray.h>
55 #include <TClonesArray.h>
58 #include <TTreeStream.h>
62 #include "AliDigits.h"
63 #include "AliLoader.h"
65 #include "AliMathBase.h"
66 #include "AliRawEventHeaderBase.h"
67 #include "AliRawReader.h"
68 #include "AliRunLoader.h"
69 #include "AliSimDigits.h"
70 #include "AliTPCCalPad.h"
71 #include "AliTPCCalROC.h"
72 #include "AliTPCClustersArray.h"
73 #include "AliTPCClustersRow.h"
74 #include "AliTPCParam.h"
75 #include "AliTPCRawStream.h"
76 #include "AliTPCRawStreamV3.h"
77 #include "AliTPCRecoParam.h"
78 #include "AliTPCReconstructor.h"
79 #include "AliTPCcalibDB.h"
80 #include "AliTPCclusterInfo.h"
81 #include "AliTPCclusterMI.h"
82 #include "AliTPCTransform.h"
83 #include "AliTPCclustererMI.h"
85 ClassImp(AliTPCclustererMI)
89 AliTPCclustererMI::AliTPCclustererMI(const AliTPCParam* par, const AliTPCRecoParam * recoParam):
95 fMaxTime(1006), // 1000>940 so use 1000, add 3 virtual time bins before and 3 after
104 fPedSubtraction(kFALSE),
111 fOutputClonesArray(0),
119 fBDumpSignal(kFALSE),
120 fBClonesArray(kFALSE),
128 // param - tpc parameters for given file
129 // recoparam - reconstruction parameters
134 fRecoParam = recoParam;
136 //set default parameters if not specified
137 fRecoParam = AliTPCReconstructor::GetRecoParam();
138 if (!fRecoParam) fRecoParam = AliTPCRecoParam::GetLowFluxParam();
141 if(AliTPCReconstructor::StreamLevel()>0) {
142 fDebugStreamer = new TTreeSRedirector("TPCsignal.root");
145 // Int_t nPoints = fRecoParam->GetLastBin()-fRecoParam->GetFirstBin();
146 fRowCl= new AliTPCClustersRow("AliTPCclusterMI");
148 // Non-persistent arrays
150 //alocate memory for sector - maximal case
152 AliTPCROC * roc = AliTPCROC::Instance();
153 Int_t nRowsMax = roc->GetNRows(roc->GetNSector()-1);
154 Int_t nPadsMax = roc->GetNPads(roc->GetNSector()-1,nRowsMax-1);
156 fAllBins = new Float_t*[nRowsMax];
157 fAllSigBins = new Int_t*[nRowsMax];
158 fAllNSigBins = new Int_t[nRowsMax];
159 for (Int_t iRow = 0; iRow < nRowsMax; iRow++) {
161 Int_t maxBin = fMaxTime*(nPadsMax+6); // add 3 virtual pads before and 3 after
162 fAllBins[iRow] = new Float_t[maxBin];
163 memset(fAllBins[iRow],0,sizeof(Float_t)*maxBin);
164 fAllSigBins[iRow] = new Int_t[maxBin];
165 fAllNSigBins[iRow]=0;
168 //______________________________________________________________
169 AliTPCclustererMI::AliTPCclustererMI(const AliTPCclustererMI ¶m)
185 fPedSubtraction(kFALSE),
192 fOutputClonesArray(0),
200 fBDumpSignal(kFALSE),
201 fBClonesArray(kFALSE),
210 fMaxBin = param.fMaxBin;
212 //______________________________________________________________
213 AliTPCclustererMI & AliTPCclustererMI::operator =(const AliTPCclustererMI & param)
216 // assignment operator - dummy
218 fMaxBin=param.fMaxBin;
221 //______________________________________________________________
222 AliTPCclustererMI::~AliTPCclustererMI(){
226 if (fDebugStreamer) delete fDebugStreamer;
228 //fOutputArray->Delete();
231 if (fOutputClonesArray){
232 fOutputClonesArray->Delete();
233 delete fOutputClonesArray;
237 fRowCl->GetArray()->Delete();
241 AliTPCROC * roc = AliTPCROC::Instance();
242 Int_t nRowsMax = roc->GetNRows(roc->GetNSector()-1);
243 for (Int_t iRow = 0; iRow < nRowsMax; iRow++) {
244 delete [] fAllBins[iRow];
245 delete [] fAllSigBins[iRow];
248 delete [] fAllSigBins;
249 delete [] fAllNSigBins;
252 void AliTPCclustererMI::SetInput(TTree * tree)
255 // set input tree with digits
258 if (!fInput->GetBranch("Segment")){
259 cerr<<"AliTPC::Digits2Clusters(): no porper input tree !\n";
265 void AliTPCclustererMI::SetOutput(TTree * tree)
268 // Set the output tree
269 // If not set the ObjArray used - Option for HLT
273 AliTPCClustersRow clrow("AliTPCclusterMI");
274 AliTPCClustersRow *pclrow=&clrow;
275 fOutput->Branch("Segment","AliTPCClustersRow",&pclrow,32000,200);
279 void AliTPCclustererMI::FillRow(){
281 // fill the output container -
282 // 2 Options possible
286 if (fOutput) fOutput->Fill();
287 if (!fOutput && !fBClonesArray){
289 if (!fOutputArray) fOutputArray = new TObjArray(fParam->GetNRowsTotal());
290 if (fRowCl && fRowCl->GetArray()->GetEntriesFast()>0) fOutputArray->AddAt(fRowCl->Clone(), fRowCl->GetID());
294 Float_t AliTPCclustererMI::GetSigmaY2(Int_t iz){
295 // sigma y2 = in digits - we don't know the angle
296 Float_t z = iz*fParam->GetZWidth()+fParam->GetNTBinsL1()*fParam->GetZWidth();
297 Float_t sd2 = (z*fParam->GetDiffL()*fParam->GetDiffL())/
298 (fPadWidth*fPadWidth);
300 Float_t res = sd2+sres;
305 Float_t AliTPCclustererMI::GetSigmaZ2(Int_t iz){
306 //sigma z2 = in digits - angle estimated supposing vertex constraint
307 Float_t z = iz*fZWidth+fParam->GetNTBinsL1()*fParam->GetZWidth();
308 Float_t sd2 = (z*fParam->GetDiffL()*fParam->GetDiffL())/(fZWidth*fZWidth);
309 Float_t angular = fPadLength*(fParam->GetZLength(fSector)-z)/(fRx*fZWidth);
312 Float_t sres = fParam->GetZSigma()/fZWidth;
314 Float_t res = angular +sd2+sres;
318 void AliTPCclustererMI::MakeCluster(Int_t k,Int_t max,Float_t *bins, UInt_t /*m*/,
322 // k - Make cluster at position k
323 // bins - 2 D array of signals mapped to 1 dimensional array -
324 // max - the number of time bins er one dimension
325 // c - refernce to cluster to be filled
327 Int_t i0=k/max; //central pad
328 Int_t j0=k%max; //central time bin
330 // set pointers to data
331 //Int_t dummy[5] ={0,0,0,0,0};
332 Float_t * matrix[5]; //5x5 matrix with digits - indexing i = 0 ..4 j = -2..2
333 for (Int_t di=-2;di<=2;di++){
334 matrix[di+2] = &bins[k+di*max];
336 //build matrix with virtual charge
337 Float_t sigmay2= GetSigmaY2(j0);
338 Float_t sigmaz2= GetSigmaZ2(j0);
340 Float_t vmatrix[5][5];
341 vmatrix[2][2] = matrix[2][0];
343 c.SetMax((UShort_t)(vmatrix[2][2])); // write maximal amplitude
344 for (Int_t di =-1;di <=1;di++)
345 for (Int_t dj =-1;dj <=1;dj++){
346 Float_t amp = matrix[di+2][dj];
347 if ( (amp<2) && (fLoop<2)){
348 // if under threshold - calculate virtual charge
349 Float_t ratio = TMath::Exp(-1.2*TMath::Abs(di)/sigmay2)*TMath::Exp(-1.2*TMath::Abs(dj)/sigmaz2);
350 amp = ((matrix[2][0]-2)*(matrix[2][0]-2)/(matrix[-di+2][-dj]+2))*ratio;
352 vmatrix[2+di][2+dj]=amp;
353 vmatrix[2+2*di][2+2*dj]=0;
356 vmatrix[2+2*di][2+dj] =0;
357 vmatrix[2+di][2+2*dj] =0;
362 //if small amplitude - below 2 x threshold - don't consider other one
363 vmatrix[2+di][2+dj]=amp;
364 vmatrix[2+2*di][2+2*dj]=0; // don't take to the account next bin
367 vmatrix[2+2*di][2+dj] =0;
368 vmatrix[2+di][2+2*dj] =0;
372 //if bigger then take everything
373 vmatrix[2+di][2+dj]=amp;
374 vmatrix[2+2*di][2+2*dj]= matrix[2*di+2][2*dj] ;
377 vmatrix[2+2*di][2+dj] = matrix[2*di+2][dj];
378 vmatrix[2+di][2+2*dj] = matrix[2+di][dj*2];
390 for (Int_t i=-2;i<=2;i++)
391 for (Int_t j=-2;j<=2;j++){
392 Float_t amp = vmatrix[i+2][j+2];
401 Float_t meani = sumiw/sumw;
402 Float_t mi2 = sumi2w/sumw-meani*meani;
403 Float_t meanj = sumjw/sumw;
404 Float_t mj2 = sumj2w/sumw-meanj*meanj;
406 Float_t ry = mi2/sigmay2;
407 Float_t rz = mj2/sigmaz2;
410 if ( ( (ry<0.6) || (rz<0.6) ) && fLoop==2) return;
411 if ( ((ry <1.2) && (rz<1.2)) || (!fRecoParam->GetDoUnfold())) {
413 //if cluster looks like expected or Unfolding not switched on
414 //standard COG is used
415 //+1.2 deviation from expected sigma accepted
416 // c.fMax = FitMax(vmatrix,meani,meanj,TMath::Sqrt(sigmay2),TMath::Sqrt(sigmaz2));
420 //set cluster parameters
423 c.SetTimeBin(meanj-3);
427 AddCluster(c,(Float_t*)vmatrix,k);
431 //unfolding when neccessary
434 Float_t * matrix2[7]; //7x7 matrix with digits - indexing i = 0 ..6 j = -3..3
435 Float_t dummy[7]={0,0,0,0,0,0};
436 for (Int_t di=-3;di<=3;di++){
437 matrix2[di+3] = &bins[k+di*max];
438 if ((k+di*max)<3) matrix2[di+3] = &dummy[3];
439 if ((k+di*max)>fMaxBin-3) matrix2[di+3] = &dummy[3];
441 Float_t vmatrix2[5][5];
444 UnfoldCluster(matrix2,vmatrix2,meani,meanj,sumu,overlap);
446 // c.fMax = FitMax(vmatrix2,meani,meanj,TMath::Sqrt(sigmay2),TMath::Sqrt(sigmaz2));
449 //set cluster parameters
452 c.SetTimeBin(meanj-3);
455 c.SetType(Char_t(overlap)+1);
456 AddCluster(c,(Float_t*)vmatrix,k);
465 void AliTPCclustererMI::UnfoldCluster(Float_t * matrix2[7], Float_t recmatrix[5][5], Float_t & meani, Float_t & meanj,
466 Float_t & sumu, Float_t & overlap )
469 //unfold cluster from input matrix
470 //data corresponding to cluster writen in recmatrix
471 //output meani and meanj
473 //take separatelly y and z
475 Float_t sum3i[7] = {0,0,0,0,0,0,0};
476 Float_t sum3j[7] = {0,0,0,0,0,0,0};
478 for (Int_t k =0;k<7;k++)
479 for (Int_t l = -1; l<=1;l++){
480 sum3i[k]+=matrix2[k][l];
481 sum3j[k]+=matrix2[l+3][k-3];
483 Float_t mratio[3][3]={{1,1,1},{1,1,1},{1,1,1}};
486 Float_t sum3wi = 0; //charge minus overlap
487 Float_t sum3wio = 0; //full charge
488 Float_t sum3iw = 0; //sum for mean value
489 for (Int_t dk=-1;dk<=1;dk++){
490 sum3wio+=sum3i[dk+3];
496 if ( ( ((sum3i[dk+3]+3)/(sum3i[3]-3))+1 < (sum3i[2*dk+3]-3)/(sum3i[dk+3]+3))||
497 (sum3i[dk+3]<=sum3i[2*dk+3] && sum3i[dk+3]>2 )){
498 Float_t xm2 = sum3i[-dk+3];
499 Float_t xm1 = sum3i[+3];
500 Float_t x1 = sum3i[2*dk+3];
501 Float_t x2 = sum3i[3*dk+3];
502 Float_t w11 = TMath::Max((Float_t)(4.*xm1-xm2),(Float_t)0.000001);
503 Float_t w12 = TMath::Max((Float_t)(4 *x1 -x2),(Float_t)0.);
504 ratio = w11/(w11+w12);
505 for (Int_t dl=-1;dl<=1;dl++)
506 mratio[dk+1][dl+1] *= ratio;
508 Float_t amp = sum3i[dk+3]*ratio;
513 meani = sum3iw/sum3wi;
514 Float_t overlapi = (sum3wio-sum3wi)/sum3wio;
519 Float_t sum3wj = 0; //charge minus overlap
520 Float_t sum3wjo = 0; //full charge
521 Float_t sum3jw = 0; //sum for mean value
522 for (Int_t dk=-1;dk<=1;dk++){
523 sum3wjo+=sum3j[dk+3];
529 if ( ( ((sum3j[dk+3]+3)/(sum3j[3]-3))+1 < (sum3j[2*dk+3]-3)/(sum3j[dk+3]+3)) ||
530 (sum3j[dk+3]<=sum3j[2*dk+3] && sum3j[dk+3]>2)){
531 Float_t xm2 = sum3j[-dk+3];
532 Float_t xm1 = sum3j[+3];
533 Float_t x1 = sum3j[2*dk+3];
534 Float_t x2 = sum3j[3*dk+3];
535 Float_t w11 = TMath::Max((Float_t)(4.*xm1-xm2),(Float_t)0.000001);
536 Float_t w12 = TMath::Max((Float_t)(4 *x1 -x2),(Float_t)0.);
537 ratio = w11/(w11+w12);
538 for (Int_t dl=-1;dl<=1;dl++)
539 mratio[dl+1][dk+1] *= ratio;
541 Float_t amp = sum3j[dk+3]*ratio;
546 meanj = sum3jw/sum3wj;
547 Float_t overlapj = (sum3wjo-sum3wj)/sum3wjo;
548 overlap = Int_t(100*TMath::Max(overlapi,overlapj)+3);
549 sumu = (sum3wj+sum3wi)/2.;
552 //if not overlap detected remove everything
553 for (Int_t di =-2; di<=2;di++)
554 for (Int_t dj =-2; dj<=2;dj++){
555 recmatrix[di+2][dj+2] = matrix2[3+di][dj];
559 for (Int_t di =-1; di<=1;di++)
560 for (Int_t dj =-1; dj<=1;dj++){
562 if (mratio[di+1][dj+1]==1){
563 recmatrix[di+2][dj+2] = matrix2[3+di][dj];
564 if (TMath::Abs(di)+TMath::Abs(dj)>1){
565 recmatrix[2*di+2][dj+2] = matrix2[3+2*di][dj];
566 recmatrix[di+2][2*dj+2] = matrix2[3+di][2*dj];
568 recmatrix[2*di+2][2*dj+2] = matrix2[3+2*di][2*dj];
572 //if we have overlap in direction
573 recmatrix[di+2][dj+2] = mratio[di+1][dj+1]* matrix2[3+di][dj];
574 if (TMath::Abs(di)+TMath::Abs(dj)>1){
575 ratio = TMath::Min((Float_t)(recmatrix[di+2][dj+2]/(matrix2[3+0*di][1*dj]+1)),(Float_t)1.);
576 recmatrix[2*di+2][dj+2] = ratio*recmatrix[di+2][dj+2];
578 ratio = TMath::Min((Float_t)(recmatrix[di+2][dj+2]/(matrix2[3+1*di][0*dj]+1)),(Float_t)1.);
579 recmatrix[di+2][2*dj+2] = ratio*recmatrix[di+2][dj+2];
582 ratio = recmatrix[di+2][dj+2]/matrix2[3][0];
583 recmatrix[2*di+2][2*dj+2] = ratio*recmatrix[di+2][dj+2];
591 Float_t AliTPCclustererMI::FitMax(Float_t vmatrix[5][5], Float_t y, Float_t z, Float_t sigmay, Float_t sigmaz)
598 for (Int_t di = -1;di<=1;di++)
599 for (Int_t dj = -1;dj<=1;dj++){
600 if (vmatrix[2+di][2+dj]>2){
601 Float_t teor = TMath::Gaus(di,y,sigmay*1.2)*TMath::Gaus(dj,z,sigmaz*1.2);
602 sumteor += teor*vmatrix[2+di][2+dj];
603 sumamp += vmatrix[2+di][2+dj]*vmatrix[2+di][2+dj];
606 Float_t max = sumamp/sumteor;
610 void AliTPCclustererMI::AddCluster(AliTPCclusterMI &c, Float_t * /*matrix*/, Int_t /*pos*/){
613 // Transform cluster to the rotated global coordinata
614 // Assign labels to the cluster
615 // add the cluster to the array
616 // for more details - See AliTPCTranform::Transform(x,i,0,1)
617 Float_t meani = c.GetPad();
618 Float_t meanj = c.GetTimeBin();
620 Int_t ki = TMath::Nint(meani);
622 if (ki>=fMaxPad) ki = fMaxPad-1;
623 Int_t kj = TMath::Nint(meanj);
625 if (kj>=fMaxTime-3) kj=fMaxTime-4;
626 // ki and kj shifted as integers coordinata
628 c.SetLabel(fRowDig->GetTrackIDFast(kj,ki,0)-2,0);
629 c.SetLabel(fRowDig->GetTrackIDFast(kj,ki,1)-2,1);
630 c.SetLabel(fRowDig->GetTrackIDFast(kj,ki,2)-2,2);
634 c.SetDetector(fSector);
635 Float_t s2 = c.GetSigmaY2();
636 Float_t w=fParam->GetPadPitchWidth(fSector);
637 c.SetSigmaY2(s2*w*w);
639 c.SetSigmaZ2(s2*fZWidth*fZWidth);
644 AliTPCTransform *transform = AliTPCcalibDB::Instance()->GetTransform() ;
646 AliFatal("Tranformations not in calibDB");
649 transform->SetCurrentRecoParam((AliTPCRecoParam*)fRecoParam);
650 Double_t x[3]={c.GetRow(),c.GetPad(),c.GetTimeBin()};
651 Int_t i[1]={fSector};
652 transform->Transform(x,i,0,1);
658 if (ki<=1 || ki>=fMaxPad-1 || kj==1 || kj==fMaxTime-2) {
659 c.SetType(-(c.GetType()+3)); //edge clusters
661 if (fLoop==2) c.SetType(100);
662 if (!AcceptCluster(&c)) return;
665 TClonesArray * arr = 0;
666 AliTPCclusterMI * cl = 0;
668 if(fBClonesArray==kFALSE) {
669 arr = fRowCl->GetArray();
670 cl = new ((*arr)[fNcluster]) AliTPCclusterMI(c);
672 cl = new ((*fOutputClonesArray)[fNclusters+fNcluster]) AliTPCclusterMI(c);
675 // if (fRecoParam->DumpSignal() &&matrix ) {
677 // Float_t *graph =0;
678 // if (fRecoParam->GetCalcPedestal() && cl->GetMax()>fRecoParam->GetDumpAmplitudeMin() &&fBDumpSignal){
680 // graph = &(fBins[fMaxTime*(pos/fMaxTime)]);
682 // AliTPCclusterInfo * info = new AliTPCclusterInfo(matrix,nbins,graph);
683 // cl->SetInfo(info);
685 if (!fRecoParam->DumpSignal()) {
689 if (AliTPCReconstructor::StreamLevel()>1) {
691 cl->GetGlobalXYZ(xyz);
692 (*fDebugStreamer)<<"Clusters"<<
704 //_____________________________________________________________________________
705 void AliTPCclustererMI::Digits2Clusters()
707 //-----------------------------------------------------------------
708 // This is a simple cluster finder.
709 //-----------------------------------------------------------------
712 Error("Digits2Clusters", "input tree not initialised");
715 fRecoParam = AliTPCReconstructor::GetRecoParam();
717 AliFatal("Can not get the reconstruction parameters");
719 if(AliTPCReconstructor::StreamLevel()>5) {
720 AliInfo("Parameter Dumps");
725 //-----------------------------------------------------------------
727 //-----------------------------------------------------------------
728 fUseHLTClusters = fRecoParam->GetUseHLTClusters();
730 AliInfo(Form("Usage of HLT clusters in TPC reconstruction : %d",fUseHLTClusters));
732 if (fUseHLTClusters == 3 || fUseHLTClusters == 4) {
733 AliInfo("Using HLT clusters for TPC off-line reconstruction");
734 fZWidth = fParam->GetZWidth();
735 Int_t iResult = ReadHLTClusters();
737 // HLT clusters present
740 // HLT clusters not present
741 else if(iResult == -1) {
742 if (fUseHLTClusters == 3) {
743 AliError("No HLT clusters present, but requiered.");
747 // Some other problem during cluster reading
749 AliWarning("Some problem while unpacking of HLT clusters.");
752 } // if (fUseHLTClusters == 3 || fUseHLTClusters == 4) {
754 //-----------------------------------------------------------------
755 // Run TPC off-line clusterer
756 //-----------------------------------------------------------------
757 AliTPCCalPad * gainTPC = AliTPCcalibDB::Instance()->GetPadGainFactor();
758 AliTPCCalPad * noiseTPC = AliTPCcalibDB::Instance()->GetPadNoise();
759 AliSimDigits digarr, *dummy=&digarr;
761 fInput->GetBranch("Segment")->SetAddress(&dummy);
762 Stat_t nentries = fInput->GetEntries();
764 fMaxTime=fRecoParam->GetLastBin()+6; // add 3 virtual time bins before and 3 after
768 for (Int_t n=0; n<nentries; n++) {
770 if (!fParam->AdjustSectorRow(digarr.GetID(),fSector,fRow)) {
771 cerr<<"AliTPC warning: invalid segment ID ! "<<digarr.GetID()<<endl;
775 AliTPCCalROC * gainROC = gainTPC->GetCalROC(fSector); // pad gains per given sector
776 AliTPCCalROC * noiseROC = noiseTPC->GetCalROC(fSector); // noise per given sector
779 fRowCl->SetID(digarr.GetID());
780 if (fOutput) fOutput->GetBranch("Segment")->SetAddress(&fRowCl);
781 fRx=fParam->GetPadRowRadii(fSector,row);
784 const Int_t kNIS=fParam->GetNInnerSector(), kNOS=fParam->GetNOuterSector();
785 fZWidth = fParam->GetZWidth();
786 if (fSector < kNIS) {
787 fMaxPad = fParam->GetNPadsLow(row);
788 fSign = (fSector < kNIS/2) ? 1 : -1;
789 fPadLength = fParam->GetPadPitchLength(fSector,row);
790 fPadWidth = fParam->GetPadPitchWidth();
792 fMaxPad = fParam->GetNPadsUp(row);
793 fSign = ((fSector-kNIS) < kNOS/2) ? 1 : -1;
794 fPadLength = fParam->GetPadPitchLength(fSector,row);
795 fPadWidth = fParam->GetPadPitchWidth();
799 fMaxBin=fMaxTime*(fMaxPad+6); // add 3 virtual pads before and 3 after
800 fBins =new Float_t[fMaxBin];
801 fSigBins =new Int_t[fMaxBin];
803 memset(fBins,0,sizeof(Float_t)*fMaxBin);
805 if (digarr.First()) //MI change
807 Float_t dig=digarr.CurrentDigit();
808 if (dig<=fParam->GetZeroSup()) continue;
809 Int_t j=digarr.CurrentRow()+3, i=digarr.CurrentColumn()+3;
810 Float_t gain = gainROC->GetValue(row,digarr.CurrentColumn());
811 Int_t bin = i*fMaxTime+j;
817 fSigBins[fNSigBins++]=bin;
818 } while (digarr.Next());
819 digarr.ExpandTrackBuffer();
821 FindClusters(noiseROC);
823 fRowCl->GetArray()->Clear("C");
824 nclusters+=fNcluster;
830 Info("Digits2Clusters", "Number of found clusters : %d", nclusters);
833 void AliTPCclustererMI::ProcessSectorData(){
835 // Process the data for the current sector
838 AliTPCCalPad * pedestalTPC = AliTPCcalibDB::Instance()->GetPedestals();
839 AliTPCCalPad * noiseTPC = AliTPCcalibDB::Instance()->GetPadNoise();
840 AliTPCCalROC * pedestalROC = pedestalTPC->GetCalROC(fSector); // pedestal per given sector
841 AliTPCCalROC * noiseROC = noiseTPC->GetCalROC(fSector); // noise per given sector
842 //check the presence of the calibration
843 if (!noiseROC ||!pedestalROC ) {
844 AliError(Form("Missing calibration per sector\t%d\n",fSector));
847 Int_t nRows=fParam->GetNRow(fSector);
848 Bool_t calcPedestal = fRecoParam->GetCalcPedestal();
849 Int_t zeroSup = fParam->GetZeroSup();
850 // if (calcPedestal) {
852 for (Int_t iRow = 0; iRow < nRows; iRow++) {
853 Int_t maxPad = fParam->GetNPads(fSector, iRow);
855 for (Int_t iPad = 3; iPad < maxPad + 3; iPad++) {
857 // Temporary fix for data production - !!!! MARIAN
858 // The noise calibration should take mean and RMS - currently the Gaussian fit used
859 // In case of double peak - the pad should be rejected
861 // Line mean - if more than given digits over threshold - make a noise calculation
862 // and pedestal substration
863 if (!calcPedestal && fAllBins[iRow][iPad*fMaxTime+0]<50) continue;
865 if (fAllBins[iRow][iPad*fMaxTime+0] <1 ) continue; // no data
866 Float_t *p = &fAllBins[iRow][iPad*fMaxTime+3];
867 //Float_t pedestal = TMath::Median(fMaxTime, p);
868 Int_t id[3] = {fSector, iRow, iPad-3};
870 Double_t rmsCalib= noiseROC->GetValue(iRow,iPad-3);
871 Double_t pedestalCalib = pedestalROC->GetValue(iRow,iPad-3);
872 Double_t rmsEvent = rmsCalib;
873 Double_t pedestalEvent = pedestalCalib;
874 ProcesSignal(p, fMaxTime, id, rmsEvent, pedestalEvent);
875 if (rmsEvent<rmsCalib) rmsEvent = rmsCalib; // take worst scenario
876 if (TMath::Abs(pedestalEvent-pedestalCalib)<1.0) pedestalEvent = pedestalCalib;
879 for (Int_t iTimeBin = 0; iTimeBin < fMaxTime; iTimeBin++) {
880 Int_t bin = iPad*fMaxTime+iTimeBin;
881 fAllBins[iRow][bin] -= pedestalEvent;
882 if (iTimeBin < fRecoParam->GetFirstBin())
883 fAllBins[iRow][bin] = 0;
884 if (iTimeBin > fRecoParam->GetLastBin())
885 fAllBins[iRow][bin] = 0;
886 if (fAllBins[iRow][iPad*fMaxTime+iTimeBin] < zeroSup)
887 fAllBins[iRow][bin] = 0;
888 if (fAllBins[iRow][bin] < 3.0*rmsEvent) // 3 sigma cut on RMS
889 fAllBins[iRow][bin] = 0;
890 if (fAllBins[iRow][bin]) fAllSigBins[iRow][fAllNSigBins[iRow]++] = bin;
896 if (AliTPCReconstructor::StreamLevel()>5) {
897 for (Int_t iRow = 0; iRow < nRows; iRow++) {
898 Int_t maxPad = fParam->GetNPads(fSector,iRow);
900 for (Int_t iPad = 3; iPad < maxPad + 3; iPad++) {
901 for (Int_t iTimeBin = 0; iTimeBin < fMaxTime; iTimeBin++) {
902 Int_t bin = iPad*fMaxTime+iTimeBin;
903 Float_t signal = fAllBins[iRow][bin];
904 if (AliTPCReconstructor::StreamLevel()>3 && signal>3) {
905 Double_t x[]={iRow,iPad-3,iTimeBin-3};
907 AliTPCTransform trafo;
908 trafo.Transform(x,i,0,1);
909 Double_t gx[3]={x[0],x[1],x[2]};
910 trafo.RotatedGlobal2Global(fSector,gx);
911 // fAllSigBins[iRow][fAllNSigBins[iRow]++]
912 Int_t rowsigBins = fAllNSigBins[iRow];
913 Int_t first=fAllSigBins[iRow][0];
915 // if (rowsigBins>0) fAllSigBins[iRow][fAllNSigBins[iRow]-1];
917 if (AliTPCReconstructor::StreamLevel()>5) {
918 (*fDebugStreamer)<<"Digits"<<
931 "rowsigBins="<<rowsigBins<<
942 // Now loop over rows and find clusters
943 for (fRow = 0; fRow < nRows; fRow++) {
944 fRowCl->SetID(fParam->GetIndex(fSector, fRow));
945 if (fOutput) fOutput->GetBranch("Segment")->SetAddress(&fRowCl);
947 fRx = fParam->GetPadRowRadii(fSector, fRow);
948 fPadLength = fParam->GetPadPitchLength(fSector, fRow);
949 fPadWidth = fParam->GetPadPitchWidth();
950 fMaxPad = fParam->GetNPads(fSector,fRow);
951 fMaxBin = fMaxTime*(fMaxPad+6); // add 3 virtual pads before and 3 after
953 fBins = fAllBins[fRow];
954 fSigBins = fAllSigBins[fRow];
955 fNSigBins = fAllNSigBins[fRow];
957 FindClusters(noiseROC);
960 if(fBClonesArray == kFALSE) fRowCl->GetArray()->Clear("C");
961 fNclusters += fNcluster;
963 } // End of loop to find clusters
967 void AliTPCclustererMI::Digits2Clusters(AliRawReader* rawReader)
969 //-----------------------------------------------------------------
970 // This is a cluster finder for the TPC raw data.
971 // The method assumes NO ordering of the altro channels.
972 // The pedestal subtraction can be switched on and off
973 // using an option of the TPC reconstructor
974 //-----------------------------------------------------------------
975 fRecoParam = AliTPCReconstructor::GetRecoParam();
977 AliFatal("Can not get the reconstruction parameters");
979 if(AliTPCReconstructor::StreamLevel()>5) {
980 AliInfo("Parameter Dumps");
986 //-----------------------------------------------------------------
988 //-----------------------------------------------------------------
989 fUseHLTClusters = fRecoParam->GetUseHLTClusters();
991 AliInfo(Form("Usage of HLT clusters in TPC reconstruction : %d",fUseHLTClusters));
993 if (fUseHLTClusters == 3 || fUseHLTClusters == 4) {
994 AliInfo("Using HLT clusters for TPC off-line reconstruction");
995 fZWidth = fParam->GetZWidth();
996 Int_t iResult = ReadHLTClusters();
998 AliError(Form("HLT result : %d",iResult));
1000 // HLT clusters present
1003 // HLT clusters not present
1004 else if(iResult == -1) {
1005 if (fUseHLTClusters == 3) {
1006 AliError("No HLT clusters present, but requiered.");
1010 // Some other problem during cluster reading
1012 AliWarning("Some problem while unpacking of HLT clusters.");
1015 } // if (fUseHLTClusters == 3 || fUseHLTClusters == 4) {
1017 //-----------------------------------------------------------------
1018 // Run TPC off-line clusterer
1019 //-----------------------------------------------------------------
1020 AliTPCCalPad * gainTPC = AliTPCcalibDB::Instance()->GetPadGainFactor();
1021 AliTPCAltroMapping** mapping =AliTPCcalibDB::Instance()->GetMapping();
1023 AliTPCRawStreamV3 input(rawReader,(AliAltroMapping**)mapping);
1024 fEventHeader = (AliRawEventHeaderBase*)rawReader->GetEventHeader();
1026 fTimeStamp = fEventHeader->Get("Timestamp");
1027 fEventType = fEventHeader->Get("Type");
1028 AliTPCTransform *transform = AliTPCcalibDB::Instance()->GetTransform() ;
1029 transform->SetCurrentTimeStamp(fTimeStamp);
1030 transform->SetCurrentRun(rawReader->GetRunNumber());
1033 // creaate one TClonesArray for all clusters
1034 if(fBClonesArray && !fOutputClonesArray) fOutputClonesArray = new TClonesArray("AliTPCclusterMI",1000);
1038 fMaxTime = fRecoParam->GetLastBin() + 6; // add 3 virtual time bins before and 3 after
1039 // const Int_t kNIS = fParam->GetNInnerSector();
1040 // const Int_t kNOS = fParam->GetNOuterSector();
1041 // const Int_t kNS = kNIS + kNOS;
1042 fZWidth = fParam->GetZWidth();
1043 Int_t zeroSup = fParam->GetZeroSup();
1047 AliTPCROC * roc = AliTPCROC::Instance();
1048 Int_t nRowsMax = roc->GetNRows(roc->GetNSector()-1);
1049 Int_t nPadsMax = roc->GetNPads(roc->GetNSector()-1,nRowsMax-1);
1050 for (Int_t iRow = 0; iRow < nRowsMax; iRow++) {
1052 Int_t maxBin = fMaxTime*(nPadsMax+6); // add 3 virtual pads before and 3 after
1053 memset(fAllBins[iRow],0,sizeof(Float_t)*maxBin);
1054 fAllNSigBins[iRow]=0;
1057 Int_t prevSector=-1;
1063 const Int_t kNIS = fParam->GetNInnerSector();
1064 const Int_t kNOS = fParam->GetNOuterSector();
1065 const Int_t kNS = kNIS + kNOS;
1067 for(fSector = 0; fSector < kNS; fSector++) {
1070 Int_t nDDLs = 0, indexDDL = 0;
1071 if (fSector < kNIS) {
1072 nRows = fParam->GetNRowLow();
1073 fSign = (fSector < kNIS/2) ? 1 : -1;
1075 indexDDL = fSector * 2;
1078 nRows = fParam->GetNRowUp();
1079 fSign = ((fSector-kNIS) < kNOS/2) ? 1 : -1;
1081 indexDDL = (fSector-kNIS) * 4 + kNIS * 2;
1084 // load the raw data for corresponding DDLs
1086 rawReader->Select("TPC",indexDDL,indexDDL+nDDLs-1);
1088 while (input.NextDDL()){
1089 if (input.GetSector() != fSector)
1090 AliFatal(Form("Sector index mismatch ! Expected (%d), but got (%d) !",fSector,input.GetSector()));
1092 //Int_t nRows = fParam->GetNRow(fSector);
1094 AliTPCCalROC * gainROC = gainTPC->GetCalROC(fSector); // pad gains per given sector
1095 // Begin loop over altro data
1096 Bool_t calcPedestal = fRecoParam->GetCalcPedestal();
1100 while ( input.NextChannel() ) {
1101 Int_t iRow = input.GetRow();
1106 AliError(Form("Pad-row index (%d) outside the range (%d -> %d) !",
1107 iRow, 0, nRows -1));
1111 Int_t iPad = input.GetPad();
1112 if (iPad < 0 || iPad >= nPadsMax) {
1113 AliError(Form("Pad index (%d) outside the range (%d -> %d) !",
1114 iPad, 0, nPadsMax-1));
1117 gain = gainROC->GetValue(iRow,iPad);
1121 while ( input.NextBunch() ){
1122 Int_t startTbin = (Int_t)input.GetStartTimeBin();
1123 Int_t bunchlength = (Int_t)input.GetBunchLength();
1124 const UShort_t *sig = input.GetSignals();
1125 for (Int_t iTime = 0; iTime<bunchlength; iTime++){
1126 Int_t iTimeBin=startTbin-iTime;
1127 if ( iTimeBin < fRecoParam->GetFirstBin() || iTimeBin >= fRecoParam->GetLastBin()){
1129 AliFatal(Form("Timebin index (%d) outside the range (%d -> %d) !",
1130 iTimeBin, 0, iTimeBin -1));
1134 Float_t signal=(Float_t)sig[iTime];
1135 if (!calcPedestal && signal <= zeroSup) continue;
1137 if (!calcPedestal) {
1138 Int_t bin = iPad*fMaxTime+iTimeBin;
1140 fAllBins[iRow][bin] = signal/gain;
1142 fAllBins[iRow][bin] =0;
1144 fAllSigBins[iRow][fAllNSigBins[iRow]++] = bin;
1146 fAllBins[iRow][iPad*fMaxTime+iTimeBin] = signal;
1148 fAllBins[iRow][iPad*fMaxTime+0]+=1.; // pad with signal
1152 }// end loop signals in bunch
1153 }// end loop bunches
1159 // Now loop over rows and perform pedestal subtraction
1160 if (digCounter==0) continue;
1161 } // End of loop over sectors
1162 //process last sector
1163 if ( digCounter>0 ){
1164 ProcessSectorData();
1165 for (Int_t iRow = 0; iRow < fParam->GetNRow(fSector); iRow++) {
1166 Int_t maxPad = fParam->GetNPads(fSector,iRow);
1167 Int_t maxBin = fMaxTime*(maxPad+6); // add 3 virtual pads before and 3 after
1168 memset(fAllBins[iRow],0,sizeof(Float_t)*maxBin);
1169 fAllNSigBins[iRow] = 0;
1176 if (rawReader->GetEventId() && fOutput ){
1177 Info("Digits2Clusters", "File %s Event\t%u\tNumber of found clusters : %d\n", fOutput->GetName(),*(rawReader->GetEventId()), fNclusters);
1180 if(rawReader->GetEventId()) {
1181 Info("Digits2Clusters", "Event\t%u\tNumber of found clusters : %d\n",*(rawReader->GetEventId()), fNclusters);
1185 //Info("Digits2Clusters", "Number of found clusters : %d\n",fOutputClonesArray->GetEntriesFast());
1193 void AliTPCclustererMI::Digits2ClustersOld
1194 (AliRawReader* rawReader)
1196 //-----------------------------------------------------------------
1197 // This is a cluster finder for the TPC raw data.
1198 // The method assumes NO ordering of the altro channels.
1199 // The pedestal subtraction can be switched on and off
1200 // using an option of the TPC reconstructor
1201 //-----------------------------------------------------------------
1202 fRecoParam = AliTPCReconstructor::GetRecoParam();
1204 AliFatal("Can not get the reconstruction parameters");
1206 if(AliTPCReconstructor::StreamLevel()>5) {
1207 AliInfo("Parameter Dumps");
1213 AliTPCCalPad * gainTPC = AliTPCcalibDB::Instance()->GetPadGainFactor();
1214 AliTPCAltroMapping** mapping =AliTPCcalibDB::Instance()->GetMapping();
1216 AliTPCRawStream input(rawReader,(AliAltroMapping**)mapping);
1217 fEventHeader = (AliRawEventHeaderBase*)rawReader->GetEventHeader();
1219 fTimeStamp = fEventHeader->Get("Timestamp");
1220 fEventType = fEventHeader->Get("Type");
1223 // creaate one TClonesArray for all clusters
1224 if(fBClonesArray && !fOutputClonesArray) fOutputClonesArray = new TClonesArray("AliTPCclusterMI",1000);
1228 fMaxTime = fRecoParam->GetLastBin() + 6; // add 3 virtual time bins before and 3 after
1229 const Int_t kNIS = fParam->GetNInnerSector();
1230 const Int_t kNOS = fParam->GetNOuterSector();
1231 const Int_t kNS = kNIS + kNOS;
1232 fZWidth = fParam->GetZWidth();
1233 Int_t zeroSup = fParam->GetZeroSup();
1238 AliTPCROC * roc = AliTPCROC::Instance();
1239 Int_t nRowsMax = roc->GetNRows(roc->GetNSector()-1);
1240 Int_t nPadsMax = roc->GetNPads(roc->GetNSector()-1,nRowsMax-1);
1241 for (Int_t iRow = 0; iRow < nRowsMax; iRow++) {
1243 Int_t maxBin = fMaxTime*(nPadsMax+6); // add 3 virtual pads before and 3 after
1244 memset(fAllBins[iRow],0,sizeof(Float_t)*maxBin);
1245 fAllNSigBins[iRow]=0;
1248 // Loop over sectors
1250 for(fSector = 0; fSector < kNS; fSector++) {
1253 Int_t nDDLs = 0, indexDDL = 0;
1254 if (fSector < kNIS) {
1255 nRows = fParam->GetNRowLow();
1256 fSign = (fSector < kNIS/2) ? 1 : -1;
1258 indexDDL = fSector * 2;
1261 nRows = fParam->GetNRowUp();
1262 fSign = ((fSector-kNIS) < kNOS/2) ? 1 : -1;
1264 indexDDL = (fSector-kNIS) * 4 + kNIS * 2;
1267 // load the raw data for corresponding DDLs
1269 rawReader->Select("TPC",indexDDL,indexDDL+nDDLs-1);
1271 // select only good sector
1272 if (!input.Next()) continue;
1273 if(input.GetSector() != fSector) continue;
1275 AliTPCCalROC * gainROC = gainTPC->GetCalROC(fSector); // pad gains per given sector
1277 for (Int_t iRow = 0; iRow < nRows; iRow++) {
1280 maxPad = fParam->GetNPadsLow(iRow);
1282 maxPad = fParam->GetNPadsUp(iRow);
1284 Int_t maxBin = fMaxTime*(maxPad+6); // add 3 virtual pads before and 3 after
1285 memset(fAllBins[iRow],0,sizeof(Float_t)*maxBin);
1286 fAllNSigBins[iRow] = 0;
1290 // Begin loop over altro data
1291 Bool_t calcPedestal = fRecoParam->GetCalcPedestal();
1296 while (input.Next()) {
1297 if (input.GetSector() != fSector)
1298 AliFatal(Form("Sector index mismatch ! Expected (%d), but got (%d) !",fSector,input.GetSector()));
1301 Int_t iRow = input.GetRow();
1306 if (iRow < 0 || iRow >= nRows){
1307 AliError(Form("Pad-row index (%d) outside the range (%d -> %d) !",
1308 iRow, 0, nRows -1));
1312 Int_t iPad = input.GetPad();
1313 if (iPad < 0 || iPad >= nPadsMax) {
1314 AliError(Form("Pad index (%d) outside the range (%d -> %d) !",
1315 iPad, 0, nPadsMax-1));
1319 gain = gainROC->GetValue(iRow,iPad);
1324 Int_t iTimeBin = input.GetTime();
1325 if ( iTimeBin < fRecoParam->GetFirstBin() || iTimeBin >= fRecoParam->GetLastBin()){
1327 AliFatal(Form("Timebin index (%d) outside the range (%d -> %d) !",
1328 iTimeBin, 0, iTimeBin -1));
1333 Float_t signal = input.GetSignal();
1334 if (!calcPedestal && signal <= zeroSup) continue;
1336 if (!calcPedestal) {
1337 Int_t bin = iPad*fMaxTime+iTimeBin;
1339 fAllBins[iRow][bin] = signal/gain;
1341 fAllBins[iRow][bin] =0;
1343 fAllSigBins[iRow][fAllNSigBins[iRow]++] = bin;
1345 fAllBins[iRow][iPad*fMaxTime+iTimeBin] = signal;
1347 fAllBins[iRow][iPad*fMaxTime+0]+=1.; // pad with signal
1351 } // End of the loop over altro data
1356 // Now loop over rows and perform pedestal subtraction
1357 if (digCounter==0) continue;
1358 ProcessSectorData();
1359 } // End of loop over sectors
1361 if (rawReader->GetEventId() && fOutput ){
1362 Info("Digits2Clusters", "File %s Event\t%d\tNumber of found clusters : %d\n", fOutput->GetName(),*(rawReader->GetEventId()), fNclusters);
1365 if(rawReader->GetEventId()) {
1366 Info("Digits2Clusters", "Event\t%d\tNumber of found clusters : %d\n",*(rawReader->GetEventId()), fNclusters);
1370 //Info("Digits2Clusters", "Number of found clusters : %d\n",fOutputClonesArray->GetEntriesFast());
1374 void AliTPCclustererMI::FindClusters(AliTPCCalROC * noiseROC)
1378 // add virtual charge at the edge
1380 Double_t kMaxDumpSize = 500000;
1382 fBDumpSignal =kFALSE;
1384 if (fRecoParam->GetCalcPedestal() && fOutput->GetZipBytes()< kMaxDumpSize) fBDumpSignal =kTRUE; //dump signal flag
1389 Int_t crtime = Int_t((fParam->GetZLength(fSector)-fRecoParam->GetCtgRange()*fRx)/fZWidth-fParam->GetNTBinsL1()-5);
1390 Float_t minMaxCutAbs = fRecoParam->GetMinMaxCutAbs();
1391 Float_t minLeftRightCutAbs = fRecoParam->GetMinLeftRightCutAbs();
1392 Float_t minUpDownCutAbs = fRecoParam->GetMinUpDownCutAbs();
1393 Float_t minMaxCutSigma = fRecoParam->GetMinMaxCutSigma();
1394 Float_t minLeftRightCutSigma = fRecoParam->GetMinLeftRightCutSigma();
1395 Float_t minUpDownCutSigma = fRecoParam->GetMinUpDownCutSigma();
1396 Int_t useOnePadCluster = fRecoParam->GetUseOnePadCluster();
1397 for (Int_t iSig = 0; iSig < fNSigBins; iSig++) {
1398 Int_t i = fSigBins[iSig];
1399 if (i%fMaxTime<=crtime) continue;
1400 Float_t *b = &fBins[i];
1402 if (b[0]<minMaxCutAbs) continue; //threshold for maxima
1404 if (useOnePadCluster==0){
1405 if (b[-1]+b[1]+b[-fMaxTime]+b[fMaxTime]<=0) continue; // cut on isolated clusters
1406 if (b[-1]+b[1]<=0) continue; // cut on isolated clusters
1407 if (b[-fMaxTime]+b[fMaxTime]<=0) continue; // cut on isolated clusters
1410 if ((b[0]+b[-1]+b[1])<minUpDownCutAbs) continue; //threshold for up down (TRF)
1411 if ((b[0]+b[-fMaxTime]+b[fMaxTime])<minLeftRightCutAbs) continue; //threshold for left right (PRF)
1412 if (!IsMaximum(*b,fMaxTime,b)) continue;
1414 Float_t noise = noiseROC->GetValue(fRow, i/fMaxTime);
1415 if (noise>fRecoParam->GetMaxNoise()) continue;
1417 if (b[0]<minMaxCutSigma*noise) continue; //threshold form maxima
1418 if ((b[0]+b[-1]+b[1])<minUpDownCutSigma*noise) continue; //threshold for up town TRF
1419 if ((b[0]+b[-fMaxTime]+b[fMaxTime])<minLeftRightCutSigma*noise) continue; //threshold for left right (PRF)
1421 AliTPCclusterMI c; // default cosntruction without info
1423 MakeCluster(i, fMaxTime, fBins, dummy,c);
1429 Bool_t AliTPCclustererMI::AcceptCluster(AliTPCclusterMI *cl){
1431 // Currently hack to filter digital noise (15.06.2008)
1432 // To be parameterized in the AliTPCrecoParam
1433 // More inteligent way to be used in future
1434 // Acces to the proper pedestal file needed
1436 if (cl->GetMax()<400) return kTRUE;
1437 Double_t ratio = cl->GetQ()/cl->GetMax();
1438 if (cl->GetMax()>700){
1439 if ((ratio - int(ratio)>0.8)) return kFALSE;
1441 if ((ratio - int(ratio)<0.95)) return kTRUE;
1446 Double_t AliTPCclustererMI::ProcesSignal(Float_t *signal, Int_t nchannels, Int_t id[3], Double_t &rmsEvent, Double_t &pedestalEvent){
1448 // process signal on given pad - + streaming of additional information in special mode
1455 // ESTIMATE pedestal and the noise
1457 const Int_t kPedMax = 100;
1463 Float_t rmsCalib = rmsEvent; // backup initial value ( from calib)
1464 Float_t pedestalCalib = pedestalEvent;// backup initial value ( from calib)
1465 Int_t firstBin = fRecoParam->GetFirstBin();
1467 UShort_t histo[kPedMax];
1468 //memset(histo,0,kPedMax*sizeof(UShort_t));
1469 for (Int_t i=0; i<kPedMax; i++) histo[i]=0;
1470 for (Int_t i=0; i<fMaxTime; i++){
1471 if (signal[i]<=0) continue;
1472 if (signal[i]>max && i>firstBin) {
1476 if (signal[i]>kPedMax-1) continue;
1477 histo[int(signal[i]+0.5)]++;
1481 for (Int_t i=1; i<kPedMax; i++){
1482 if (count1<count0*0.5) median=i;
1487 Float_t count10=histo[median] ,mean=histo[median]*median, rms=histo[median]*median*median ;
1488 Float_t count06=histo[median] ,mean06=histo[median]*median, rms06=histo[median]*median*median ;
1489 Float_t count09=histo[median] ,mean09=histo[median]*median, rms09=histo[median]*median*median ;
1491 for (Int_t idelta=1; idelta<10; idelta++){
1492 if (median-idelta<=0) continue;
1493 if (median+idelta>kPedMax) continue;
1494 if (count06<0.6*count1){
1495 count06+=histo[median-idelta];
1496 mean06 +=histo[median-idelta]*(median-idelta);
1497 rms06 +=histo[median-idelta]*(median-idelta)*(median-idelta);
1498 count06+=histo[median+idelta];
1499 mean06 +=histo[median+idelta]*(median+idelta);
1500 rms06 +=histo[median+idelta]*(median+idelta)*(median+idelta);
1502 if (count09<0.9*count1){
1503 count09+=histo[median-idelta];
1504 mean09 +=histo[median-idelta]*(median-idelta);
1505 rms09 +=histo[median-idelta]*(median-idelta)*(median-idelta);
1506 count09+=histo[median+idelta];
1507 mean09 +=histo[median+idelta]*(median+idelta);
1508 rms09 +=histo[median+idelta]*(median+idelta)*(median+idelta);
1510 if (count10<0.95*count1){
1511 count10+=histo[median-idelta];
1512 mean +=histo[median-idelta]*(median-idelta);
1513 rms +=histo[median-idelta]*(median-idelta)*(median-idelta);
1514 count10+=histo[median+idelta];
1515 mean +=histo[median+idelta]*(median+idelta);
1516 rms +=histo[median+idelta]*(median+idelta)*(median+idelta);
1521 rms = TMath::Sqrt(TMath::Abs(rms/count10-mean*mean));
1525 rms06 = TMath::Sqrt(TMath::Abs(rms06/count06-mean06*mean06));
1529 rms09 = TMath::Sqrt(TMath::Abs(rms09/count09-mean09*mean09));
1533 pedestalEvent = median;
1534 if (AliLog::GetDebugLevel("","AliTPCclustererMI")==0) return median;
1536 UInt_t uid[3] = {UInt_t(id[0]),UInt_t(id[1]),UInt_t(id[2])};
1538 // Dump mean signal info
1540 if (AliTPCReconstructor::StreamLevel()>0) {
1541 (*fDebugStreamer)<<"Signal"<<
1542 "TimeStamp="<<fTimeStamp<<
1543 "EventType="<<fEventType<<
1557 "RMSCalib="<<rmsCalib<<
1558 "PedCalib="<<pedestalCalib<<
1562 // fill pedestal histogram
1567 Float_t kMin =fRecoParam->GetDumpAmplitudeMin(); // minimal signal to be dumped
1568 Float_t *dsignal = new Float_t[nchannels];
1569 Float_t *dtime = new Float_t[nchannels];
1570 for (Int_t i=0; i<nchannels; i++){
1572 dsignal[i] = signal[i];
1576 // Big signals dumping
1578 if (AliTPCReconstructor::StreamLevel()>0) {
1579 if (max-median>kMin &&maxPos>fRecoParam->GetFirstBin())
1580 (*fDebugStreamer)<<"SignalB"<< // pads with signal
1581 "TimeStamp="<<fTimeStamp<<
1582 "EventType="<<fEventType<<
1586 // "Graph="<<graph<<
1602 if (rms06>fRecoParam->GetMaxNoise()) {
1603 pedestalEvent+=1024.;
1604 return 1024+median; // sign noisy channel in debug mode
1609 Int_t AliTPCclustererMI::ReadHLTClusters()
1612 // read HLT clusters instead of off line custers,
1613 // used in Digits2Clusters
1616 TObject* pClusterAccess=NULL;
1618 ROOT::NewFunc_t pNewFunc=NULL;
1620 pCl=TClass::GetClass("AliHLTTPCClusterAccessHLTOUT");
1621 } while (!pCl && gSystem->Load("libAliHLTTPC.so")==0);
1622 if (!pCl || (pNewFunc=pCl->GetNew())==NULL) {
1623 AliError("can not load class description of AliHLTTPCClusterAccessHLTOUT, aborting ...");
1627 void* p=(*pNewFunc)(NULL);
1629 AliError("unable to create instance of AliHLTTPCClusterAccessHLTOUT");
1632 pClusterAccess=reinterpret_cast<TObject*>(p);
1633 if (!pClusterAccess) {
1634 AliError("instance not of type TObject");
1638 const Int_t kNIS = fParam->GetNInnerSector();
1639 const Int_t kNOS = fParam->GetNOuterSector();
1640 const Int_t kNS = kNIS + kNOS;
1643 for(fSector = 0; fSector < kNS; fSector++) {
1645 TString param("sector="); param+=fSector;
1646 pClusterAccess->Clear();
1647 pClusterAccess->Execute("read", param);
1648 if (pClusterAccess->FindObject("clusterarray")==NULL) {
1649 AliError("HLT clusters requested, but not cluster array not present");
1653 TClonesArray* clusterArray=dynamic_cast<TClonesArray*>(pClusterAccess->FindObject("clusterarray"));
1654 if (!clusterArray) {
1655 AliError("HLT cluster array is not of class type TClonesArray");
1659 AliDebug(4,Form("Reading %d clusters from HLT for sector %d", clusterArray->GetEntriesFast(), fSector));
1661 Int_t nClusterSector=0;
1662 Int_t nRows=fParam->GetNRow(fSector);
1664 for (fRow = 0; fRow < nRows; fRow++) {
1665 fRowCl->SetID(fParam->GetIndex(fSector, fRow));
1666 if (fOutput) fOutput->GetBranch("Segment")->SetAddress(&fRowCl);
1667 fNcluster=0; // reset clusters per row
1669 fRx = fParam->GetPadRowRadii(fSector, fRow);
1670 fPadLength = fParam->GetPadPitchLength(fSector, fRow);
1671 fPadWidth = fParam->GetPadPitchWidth();
1672 fMaxPad = fParam->GetNPads(fSector,fRow);
1673 fMaxBin = fMaxTime*(fMaxPad+6); // add 3 virtual pads before and 3 after
1675 fBins = fAllBins[fRow];
1676 fSigBins = fAllSigBins[fRow];
1677 fNSigBins = fAllNSigBins[fRow];
1679 for (Int_t i=0; i<clusterArray->GetEntriesFast(); i++) {
1680 if (!clusterArray->At(i))
1683 AliTPCclusterMI* cluster=dynamic_cast<AliTPCclusterMI*>(clusterArray->At(i));
1684 if (!cluster) continue;
1685 if (cluster->GetRow()!=fRow) continue;
1687 AddCluster(*cluster, NULL, 0);
1691 fRowCl->GetArray()->Clear("c");
1693 } // for (fRow = 0; fRow < nRows; fRow++) {
1694 if (nClusterSector!=clusterArray->GetEntriesFast()) {
1695 AliError(Form("Failed to read %d out of %d HLT clusters",
1696 clusterArray->GetEntriesFast()-nClusterSector,
1697 clusterArray->GetEntriesFast()));
1699 fNclusters+=nClusterSector;
1700 } // for(fSector = 0; fSector < kNS; fSector++) {
1702 delete pClusterAccess;
1704 Info("Digits2Clusters", "Number of converted HLT clusters : %d", fNclusters);