- // simple ITS cluster finder -- online zero-suppression conditions
-
- Int_t db,tl,th;
- Float_t tmp1,tmp2;
- fResponse->Thresholds(tmp1,tmp2);
- Int_t minval = static_cast<Int_t>(tmp1);
- Bool_t write = fResponse->OutputOption();
- Bool_t do10to8 = fResponse->Do10to8();
- Int_t nz, nl, nh, low, i, j;
-
- for (i=0; i<fNofMaps; i++) {
- CompressionParam(i,db,tl,th);
- nz = 0;
- nl = 0;
- nh = 0;
- low = 0;
- for (j=0; j<fMaxNofSamples; j++) {
- Int_t signal=(Int_t)(fHitMap2->GetSignal(i,j));
- signal -= db; // if baseline eq. is done here
- if (signal <= 0) {nz++; continue;}
- if ((signal - tl) < minval) low++;
- if ((signal - th) >= minval) {
- nh++;
- Bool_t cond=kTRUE;
- FindCluster(i,j,signal,minval,cond);
- if(cond && j &&
- ((TMath::Abs(fHitMap2->GetSignal(i,j-1))-th)>=minval)){
- if(do10to8) signal = Convert10to8(signal);
- AddDigit(i,j,signal);
- } // end if cond&&j&&()
- } else if ((signal - tl) >= minval) nl++;
- } // end for j loop time samples
- if (write) TreeB()->Fill(nz,nl,nh,low,i+1);
- } //end for i loop anodes
-
- char hname[30];
- if (write) {
- sprintf(hname,"TNtuple%d_%d",fModule,fEvent);
- TreeB()->Write(hname);
- // reset tree
- TreeB()->Reset();
- } // end if write
-}
-//______________________________________________________________________
-void AliITSsimulationSDD::FindCluster(Int_t i,Int_t j,Int_t signal,
- Int_t minval,Bool_t &cond){
- // Find clusters according to the online 2D zero-suppression algorithm
- Bool_t do10to8 = fResponse->Do10to8();
- Bool_t high = kFALSE;
-
- fHitMap2->FlagHit(i,j);
-//
-// check the online zero-suppression conditions
-//
- const Int_t kMaxNeighbours = 4;
- Int_t nn;
- Int_t dbx,tlx,thx;
- Int_t xList[kMaxNeighbours], yList[kMaxNeighbours];
- fSegmentation->Neighbours(i,j,&nn,xList,yList);
- Int_t in,ix,iy,qns;
- for (in=0; in<nn; in++) {
- ix=xList[in];
- iy=yList[in];
- if (fHitMap2->TestHit(ix,iy)==kUnused) {
- CompressionParam(ix,dbx,tlx,thx);
- Int_t qn = (Int_t)(fHitMap2->GetSignal(ix,iy));
- qn -= dbx; // if baseline eq. is done here
- if ((qn-tlx) < minval) {
- fHitMap2->FlagHit(ix,iy);
- continue;
- } else {
- if ((qn - thx) >= minval) high=kTRUE;
- if (cond) {
- if(do10to8) signal = Convert10to8(signal);
- AddDigit(i,j,signal);
- } // end if cond
- if(do10to8) qns = Convert10to8(qn);
- else qns=qn;
- if (!high) AddDigit(ix,iy,qns);
- cond=kFALSE;
- if(!high) fHitMap2->FlagHit(ix,iy);
- } // end if qn-tlx < minval
- } // end if TestHit
- } // end for in loop over neighbours
-}
-//______________________________________________________________________
-void AliITSsimulationSDD::Init1D(){
- // this is just a copy-paste of input taken from 2D algo
- // Torino people should give input
- // Read 1D zero-suppression parameters for SDD
-
- if (!strstr(fParam.Data(),"file")) return;
-
- Int_t na,pos,tempTh;
- Float_t mu,sigma;
- Float_t *savemu = new Float_t [fNofMaps];
- Float_t *savesigma = new Float_t [fNofMaps];
- char input[100],basel[100],par[100];
- char *filtmp;
- Float_t tmp1,tmp2;
- fResponse->Thresholds(tmp1,tmp2);
- Int_t minval = static_cast<Int_t>(tmp1);
-
- fResponse->Filenames(input,basel,par);
- fFileName=par;
-
-// set first the disable and tol param
- SetCompressParam();
-//
- filtmp = gSystem->ExpandPathName(fFileName.Data());
- FILE *param = fopen(filtmp,"r");
- na = 0;
-
- if (param) {
- fscanf(param,"%d %d %d %d ", &fT2[0], &fT2[1], &fTol[0], &fTol[1]);
- while(fscanf(param,"%d %f %f",&pos, &mu, &sigma) != EOF) {
- if (pos != na+1) {
- Error("Init1D","Anode number not in increasing order!",filtmp);
- exit(1);
- } // end if pos != na+1
- savemu[na]=mu;
- savesigma[na]=sigma;
- if ((2.*sigma) < mu) {
- fD[na] = (Int_t)floor(mu - 2.0*sigma + 0.5);
- mu = 2.0 * sigma;
- } else fD[na] = 0;
- tempTh = (Int_t)floor(mu+2.25*sigma+0.5) - minval;
- if (tempTh < 0) tempTh=0;
- fT1[na] = tempTh;
- na++;
- } // end while
- } else {
- Error("Init1D","THE FILE %s DOES NOT EXIST !",filtmp);
- exit(1);
- } // end if(param)
-
- fclose(param);
- delete [] filtmp;
- delete [] savemu;
- delete [] savesigma;
-}
-//______________________________________________________________________
-void AliITSsimulationSDD::Compress1D(){
- // 1D zero-suppression algorithm (from Gianluca A.)
- Int_t dis,tol,thres,decr,diff;
- UChar_t *str=fStream->Stream();
- Int_t counter=0;
- Bool_t do10to8=fResponse->Do10to8();
- Int_t last=0;
- Int_t k,i,j;
-
- for (k=0; k<2; k++) {
- tol = Tolerance(k);
- dis = Disable(k);
- for (i=0; i<fNofMaps/2; i++) {
- Bool_t firstSignal=kTRUE;
- Int_t idx=i+k*fNofMaps/2;
- if( !fAnodeFire[idx] ) continue;
- CompressionParam(idx,decr,thres);
-
- decr=20; thres=3; //I.Belikov's temporary fix (needed for the PID)
-
- for (j=0; j<fMaxNofSamples; j++) {
- Int_t signal=(Int_t)(fHitMap2->GetSignal(idx,j));
- signal -= decr; // if baseline eq.
- if(do10to8) signal = Convert10to8(signal);
- if (signal <= thres) {
- signal=0;
- diff=128;
- last=0;
- // write diff in the buffer for HuffT
- str[counter]=(UChar_t)diff;
- counter++;
- continue;
- } // end if signal <= thres
- diff=signal-last;
- if (diff > 127) diff=127;
- if (diff < -128) diff=-128;
- if (signal < dis) {
- // tol has changed to 8 possible cases ? - one can write
- // this if(TMath::Abs(diff)<tol) ... else ...
- if(TMath::Abs(diff)<tol) diff=0;
- // or keep it as it was before
- AddDigit(idx,j,last+diff);
- } else {
- AddDigit(idx,j,signal);
- } // end if singal < dis
- diff += 128;
- // write diff in the buffer used to compute Huffman tables
- if (firstSignal) str[counter]=(UChar_t)signal;
- else str[counter]=(UChar_t)diff;
- counter++;
- last=signal;
- firstSignal=kFALSE;
- } // end for j loop time samples
- } // end for i loop anodes one half of detector
- } // end for k
-
- // check
- fStream->CheckCount(counter);
-
- // open file and write out the stream of diff's
- static Bool_t open=kTRUE;
- static TFile *outFile;
- Bool_t write = fResponse->OutputOption();
- TDirectory *savedir = gDirectory;
-
- if (write ) {
- if(open) {
- SetFileName("stream.root");
- cout<<"filename "<<fFileName<<endl;
- outFile=new TFile(fFileName,"recreate");
- cout<<"I have opened "<<fFileName<<" file "<<endl;
- } // end if open
- open = kFALSE;
- outFile->cd();
- fStream->Write();
- } // endif write
-
- fStream->ClearStream();
-
- // back to galice.root file
- if(savedir) savedir->cd();