]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - ITS/AliITSClusterFinderSDD.cxx
- AliITSInitGeometry.cxx (updated): fgkOldSSDcone changed from kTRUE to
[u/mrichter/AliRoot.git] / ITS / AliITSClusterFinderSDD.cxx
index 7494c78a702508f556621275ed81968961883744..6f24cf540df756dbabfa8126442b4ba2f3cd2d1e 100644 (file)
@@ -28,8 +28,9 @@
 #include "AliITSRecPoint.h"
 #include "AliITSdigitSDD.h"
 #include "AliITSDetTypeRec.h"
-#include "AliITSresponseSDD.h"
+#include "AliITSCalibrationSDD.h"
 #include "AliITSsegmentationSDD.h"
+#include "AliITSgeom.h"
 #include "AliLog.h"
 
 ClassImp(AliITSClusterFinderSDD)
@@ -69,9 +70,7 @@ fMaxNCells(0){
     SetCutAmplitude(fDetTypeRec->GetITSgeom()->GetStartSDD());
     SetDAnode();
     SetDTime();
-    SetMinPeak((Int_t)(((AliITSresponseSDD*)GetResp(fDetTypeRec->GetITSgeom()->GetStartSDD()))->
-                       GetNoiseAfterElectronics()*5));
-    //    SetMinPeak();
+    SetMinPeak((Int_t)((AliITSCalibrationSDD*)GetResp(fDetTypeRec->GetITSgeom()->GetStartSDD()))->GetNoiseAfterElectronics(0)*5);
     SetMinNCells();
     SetMaxNCells();
     SetTimeCorr();
@@ -81,11 +80,22 @@ fMaxNCells(0){
 //______________________________________________________________________
 void AliITSClusterFinderSDD::SetCutAmplitude(Int_t mod,Double_t nsigma){
     // set the signal threshold for cluster finder
-    Double_t baseline,noise,noiseAfterEl;
+    Double_t baseline,noiseAfterEl;
 
-    GetResp(mod)->GetNoiseParam(noise,baseline);
-    noiseAfterEl = ((AliITSresponseSDD*)GetResp(mod))->GetNoiseAfterElectronics();
-    fCutAmplitude = (Int_t)((baseline + nsigma*noiseAfterEl));
+    AliITSresponseSDD* res  = (AliITSresponseSDD*)((AliITSCalibrationSDD*)GetResp(mod))->GetResponse();
+    const char *option=res->ZeroSuppOption();
+    Int_t nanodes = GetResp(mod)->Wings()*GetResp(mod)->Channels()*GetResp(mod)->Chips();
+    fCutAmplitude.Set(nanodes);
+    for(Int_t ian=0;ian<nanodes;ian++){
+      noiseAfterEl = ((AliITSCalibrationSDD*)GetResp(mod))->GetNoiseAfterElectronics(ian);
+      if((strstr(option,"1D")) || (strstr(option,"2D"))){ 
+       fCutAmplitude[ian] = (Int_t)(nsigma*noiseAfterEl);
+      }
+      else{
+       baseline=GetResp(mod)->GetBaseline(ian);
+       fCutAmplitude[ian] = (Int_t)((baseline + nsigma*noiseAfterEl));
+      } 
+    }
 }
 //______________________________________________________________________
 void AliITSClusterFinderSDD::Find1DClusters(){
@@ -98,17 +108,14 @@ void AliITSClusterFinderSDD::Find1DClusters(){
     Int_t dummy          = 0;
     Double_t fTimeStep    = GetSeg()->Dpx(dummy);
     Double_t fSddLength   = GetSeg()->Dx();
-    Double_t fDriftSpeed  = GetResp(fModule)->DriftSpeed();  
-    Double_t anodePitch   = GetSeg()->Dpz(dummy);
+    AliITSCalibrationSDD* cal = (AliITSCalibrationSDD*)GetResp(fModule);
+    AliITSresponseSDD* res  = (AliITSresponseSDD*)((AliITSCalibrationSDD*)GetResp(fModule))->GetResponse();
+    const char *option=res->ZeroSuppOption();
 
     // map the signal
     Map()->ClearMap();
-    Map()->SetThreshold(fCutAmplitude);
-    Map()->FillMap();
-  
-    Double_t noise;
-    Double_t baseline;
-    GetResp(fModule)->GetNoiseParam(noise,baseline);
+    Map()->SetThresholdArr(fCutAmplitude);
+    Map()->FillMap2();
   
     Int_t nofFoundClusters = 0;
     Int_t i;
@@ -151,7 +158,7 @@ void AliITSClusterFinderSDD::Find1DClusters(){
                     if(id>=fMaxNofSamples) break;
                     fadc=(float)Map()->GetSignal(idx,id);
                     if(fadc > fadcmax) { fadcmax = fadc; imax = id;}
-                    if(fadc > (float)fCutAmplitude)lthrt++; 
+                    if(fadc > (float)fCutAmplitude[idx])lthrt++; 
                     if(dfadc[k][id] > dfadcmax) {
                         dfadcmax = dfadc[k][id];
                         imaxd    = id;
@@ -173,7 +180,7 @@ void AliITSClusterFinderSDD::Find1DClusters(){
                         if(tstart+ij > 255) { tstop = 255; break; }
                         fadc=(float)Map()->GetSignal(idx,tstart+ij);
                         if((dfadc[k][tstart+ij] < dfadcmin) && 
-                           (fadc > fCutAmplitude)) {
+                           (fadc > fCutAmplitude[idx])) {
                             tstop = tstart+ij+5;
                             if(tstop > 255) tstop = 255;
                             dfadcmin = dfadc[k][it+ij];
@@ -186,12 +193,14 @@ void AliITSClusterFinderSDD::Find1DClusters(){
                     Int_t   clusterMult   = 0;
                     Double_t clusterPeakAmplitude = 0.;
                     Int_t its,peakpos     = -1;
-                    Double_t n, baseline;
-                    GetResp(fModule)->GetNoiseParam(n,baseline);
-                    for(its=tstart; its<=tstop; its++) {
+                                  
+                   for(its=tstart; its<=tstop; its++) {
                         fadc=(float)Map()->GetSignal(idx,its);
-                        if(fadc>baseline) fadc -= baseline;
-                        else fadc = 0.;
+                       if(!((strstr(option,"1D")) || (strstr(option,"2D")))){
+                         Double_t baseline=GetResp(fModule)->GetBaseline(idx);
+                         if(fadc>baseline) fadc -= baseline;
+                         else fadc = 0.;
+                       }
                         clusterCharge += fadc;
                         // as a matter of fact we should take the peak
                         // pos before FFT
@@ -213,10 +222,9 @@ void AliITSClusterFinderSDD::Find1DClusters(){
                             //ns
                         } // end if
                     } // end for its
-
-                    Double_t clusteranodePath = (clusterAnode - fNofAnodes/2)*
-                                                 anodePitch;
-                    Double_t clusterDriftPath = clusterTime*fDriftSpeed;
+                   Float_t theAnode=clusterAnode+j*fNofAnodes;
+                    Double_t clusteranodePath = GetSeg()->GetLocalZFromAnode(theAnode);
+                   Double_t clusterDriftPath = (Double_t)cal->GetDriftPath(clusterTime,clusteranodePath);
                     clusterDriftPath = fSddLength-clusterDriftPath;
                     if(clusterCharge <= 0.) break;
                     AliITSRawClusterSDD clust(j+1,//i
@@ -251,20 +259,19 @@ void AliITSClusterFinderSDD::Find1DClustersE(){
     Int_t dummy=0;
     Double_t fTimeStep = GetSeg()->Dpx( dummy );
     Double_t fSddLength = GetSeg()->Dx();
-    Double_t fDriftSpeed = GetResp(fModule)->DriftSpeed();
-    Double_t anodePitch = GetSeg()->Dpz( dummy );
-    Double_t n, baseline;
-    GetResp(fModule)->GetNoiseParam( n, baseline );
-    // map the signal
+    AliITSCalibrationSDD* cal = (AliITSCalibrationSDD*)GetResp(fModule);
     Map()->ClearMap();
-    Map()->SetThreshold( fCutAmplitude );
-    Map()->FillMap();
-    
+    Map()->SetThresholdArr( fCutAmplitude );
+    Map()->FillMap2();
+
+    AliITSresponseSDD* res  = (AliITSresponseSDD*)cal->GetResponse();
+    const char *option=res->ZeroSuppOption();
+
     Int_t nClu = 0;
     //        cout << "Search  cluster... "<< endl;
     for( Int_t j=0; j<2; j++ ){
         for( Int_t k=0; k<fNofAnodes; k++ ){
-            Int_t idx = j*fNofAnodes+k;
+            Int_t idx = j*fNofAnodes+k;            
             Bool_t on = kFALSE;
             Int_t start = 0;
             Int_t nTsteps = 0;
@@ -290,8 +297,11 @@ void AliITSClusterFinderSDD::Find1DClustersE(){
                         nTsteps = 0;
                     } // end if on...
                     nTsteps++ ;
-                    if( fadc > baseline ) fadc -= baseline;
-                    else fadc=0.;
+                   if(!((strstr(option,"1D")) || (strstr(option,"2D")))){
+                     Double_t baseline=GetResp(fModule)->GetBaseline(idx);
+                     if( fadc > baseline ) fadc -= baseline;
+                     else fadc=0.;
+                   }
                     charge += fadc;
                     time += fadc*l;
                     if( fadc > fmax ){ 
@@ -313,8 +323,9 @@ void AliITSClusterFinderSDD::Find1DClustersE(){
                             time /= (charge/fTimeStep);   // ns
                                 // time = lmax*fTimeStep;   // ns
                             if( time > fTimeCorr ) time -= fTimeCorr;   // ns
-                            Double_t anodePath =(anode-fNofAnodes/2)*anodePitch;
-                            Double_t driftPath = time*fDriftSpeed;
+                           Float_t theAnode=anode+j*fNofAnodes;
+                            Double_t anodePath =GetSeg()->GetLocalZFromAnode(theAnode);
+                           Double_t driftPath = (Double_t)cal->GetDriftPath(time,anode);
                             driftPath = fSddLength-driftPath;
                             AliITSRawClusterSDD clust(j+1,anode,time,charge,
                                                       fmax, peakpos,0.,0.,
@@ -415,7 +426,7 @@ void AliITSClusterFinderSDD::PeakFunc( Int_t xdim, Int_t zdim, Double_t *par,
     //                 par[i+2] = zpos
     //                 par[i+3] = tau
     //                 par[i+4] = sigma.
-    Int_t electronics = GetResp(fModule)->Electronics(); // 1 = PASCAL, 2 = OLA
+    Int_t electronics = GetResp(fModule)->GetElectronics(); // 1 = PASCAL, 2 = OLA
     const Int_t knParam = 5;
     Int_t npeak = (Int_t)par[0];
 
@@ -694,11 +705,12 @@ void AliITSClusterFinderSDD::ResolveClusters(){
     Int_t dummy=0;
     Double_t fTimeStep = GetSeg()->Dpx( dummy );
     Double_t fSddLength = GetSeg()->Dx();
-    Double_t fDriftSpeed = GetResp(fModule)->DriftSpeed();
     Double_t anodePitch = GetSeg()->Dpz( dummy );
-    Double_t n, baseline;
-    GetResp(fModule)->GetNoiseParam( n, baseline );
-    Int_t electronics = GetResp(fModule)->Electronics(); // 1 = PASCAL, 2 = OLA
+    Int_t electronics =GetResp(fModule)->GetElectronics(); // 1 = PASCAL, 2 = OLA
+    AliITSCalibrationSDD* cal = (AliITSCalibrationSDD*)GetResp(fModule);
+    AliITSresponseSDD* res  = (AliITSresponseSDD*)cal->GetResponse();
+    const char *option=res->ZeroSuppOption();
+    
 
     for( Int_t j=0; j<nofClusters; j++ ){ 
         // get cluster information
@@ -724,9 +736,12 @@ void AliITSClusterFinderSDD::ResolveClusters(){
         // make a local map from cluster region
         for( Int_t ianode=astart; ianode<=astop; ianode++ ){
             for( Int_t itime=tstart; itime<=tstop; itime++ ){
-                Double_t fadc = Map()->GetSignal( ianode, itime );
-                if( fadc > baseline ) fadc -= (Double_t)baseline;
-                else fadc = 0.;
+                Double_t fadc = Map()->GetSignal( ianode, itime );            
+               if(!((strstr(option,"1D")) || (strstr(option,"2D")))){
+                 Double_t baseline=GetResp(fModule)->GetBaseline(ianode);
+                 if( fadc > baseline ) fadc -= (Double_t)baseline;
+                 else fadc = 0.;
+               }
                 Int_t index = (itime-tstart+1)*zdim+(ianode-astart+1);
                 sp[index] = fadc;
             } // time loop
@@ -819,11 +834,18 @@ void AliITSClusterFinderSDD::ResolveClusters(){
                     //if(AliDebugLevel()>=3) clusterI.PrintInfo(); 
                    continue;
                 }
-                clusterI.SetPeakPos( peakpos );    
-                Double_t driftPath = fSddLength - newiTimef * fDriftSpeed;
-                Double_t sign = ( wing == 1 ) ? -1. : 1.;
-                clusterI.SetX( driftPath*sign * 0.0001 );        
-                clusterI.SetZ( anodePath * 0.0001 );
+                clusterI.SetPeakPos( peakpos ); 
+               Float_t dp = cal->GetDriftPath(newiTimef,newAnodef);
+               Float_t driftPath = fSddLength - (Double_t)dp;
+                Float_t sign = ( wing == 1 ) ? -1. : 1.;
+               Float_t xcoord = driftPath*sign * 0.0001;
+               Float_t zcoord = anodePath * 0.0001;
+               Float_t corrx=0, corrz=0;
+               cal->GetCorrections(zcoord,xcoord,corrz,corrx,GetSeg());
+               xcoord+=corrx;
+               zcoord+=corrz;
+                clusterI.SetX( xcoord );        
+                clusterI.SetZ( zcoord );
                 clusterI.SetAnode( newAnodef );
                 clusterI.SetTime( newiTimef );
                 clusterI.SetAsigma( sigma[i]*anodePitch );
@@ -914,7 +936,7 @@ void AliITSClusterFinderSDD::SelectClusters(){
 }
 
 //______________________________________________________________________
-void AliITSClusterFinderSDD::GetRecPoints(){
+void AliITSClusterFinderSDD::GetRecPoints(AliITSCalibrationSDD* cal){
     // get rec points
   
     // get number of clusters for this module
@@ -922,12 +944,21 @@ void AliITSClusterFinderSDD::GetRecPoints(){
     nofClusters -= fNclusters;
     const Double_t kconvGeV = 1.e-6; // GeV -> KeV
     const Double_t kconv = 1.0e-4; 
+    const Double_t kcmToMicrons = 10000.;
     const Double_t kRMSx = 38.0*kconv; // microns->cm ITS TDR Table 1.3
     const Double_t kRMSz = 28.0*kconv; // microns->cm ITS TDR Table 1.3
+    Int_t nAnodes=GetSeg()->NpzHalf();
     Int_t i;
     Int_t ix, iz, idx=-1;
     AliITSdigitSDD *dig=0;
     Int_t ndigits=NDigits();
+
+    Int_t lay,lad,det;
+    fDetTypeRec->GetITSgeom()->GetModuleId(fModule,lay,lad,det);
+    Int_t ind=(lad-1)*fDetTypeRec->GetITSgeom()->GetNdetectors(lay)+(det-1);
+    Int_t lyr=(lay-1);
+
+
     for(i=0; i<nofClusters; i++) { 
         AliITSRawClusterSDD *clusterI = (AliITSRawClusterSDD*)Cluster(i);
         if(!clusterI) Error("SDD: GetRecPoints","i clusterI ",i,clusterI);
@@ -937,24 +968,32 @@ void AliITSClusterFinderSDD::GetRecPoints(){
         if(idx&&idx<= ndigits) dig =(AliITSdigitSDD*)GetDigit(idx);
         if(!dig) {
             // try cog
-            GetSeg()->GetPadIxz(clusterI->X(),clusterI->Z(),ix,iz);
+           Float_t xMicrons=clusterI->X()*kcmToMicrons;
+           Float_t zMicrons=clusterI->Z()*kcmToMicrons;
+           Float_t zAnode=zMicrons/GetSeg()->Dpz(0)+nAnodes/2;
+           Float_t driftSpeed=cal->GetDriftSpeedAtAnode(zAnode);           
+           Float_t driftPath=GetSeg()->Dx()-TMath::Abs(xMicrons);
+           ix=1+(Int_t)(driftPath/driftSpeed/GetSeg()->Dpx(0));
+           iz=1+(Int_t)zAnode;
+           if(xMicrons>0) iz+=nAnodes;
             dig = (AliITSdigitSDD*)Map()->GetHit(iz-1,ix-1);
             // if null try neighbours
             if (!dig) dig = (AliITSdigitSDD*)Map()->GetHit(iz-1,ix); 
             if (!dig) dig = (AliITSdigitSDD*)Map()->GetHit(iz-1,ix+1); 
             if (!dig) printf("SDD: cannot assign the track number!\n");
         } //  end if !dig
-        AliITSRecPoint rnew;
-        rnew.SetX(clusterI->X());
-        rnew.SetZ(clusterI->Z());
-        rnew.SetQ(clusterI->Q());   // in KeV - should be ADC
-        rnew.SetdEdX(kconvGeV*clusterI->Q());
-        rnew.SetSigmaX2(kRMSx*kRMSx);
-        rnew.SetSigmaZ2(kRMSz*kRMSz);
 
-        if(dig) rnew.fTracks[0]=dig->GetTrack(0);
-        if(dig) rnew.fTracks[1]=dig->GetTrack(1);
-        if(dig) rnew.fTracks[2]=dig->GetTrack(2);
+       Int_t lab[4] = {-3141593,-3141593,-3141593,ind};
+       if (dig) {
+         lab[0] = dig->GetTrack(0);
+         lab[1] = dig->GetTrack(1);
+         lab[2] = dig->GetTrack(2);
+       }
+       Float_t hit[5] = {clusterI->X(),clusterI->Z(),kRMSx*kRMSx,kRMSz*kRMSz,clusterI->Q()};
+       Int_t info[3] = {0,0,lyr};
+
+        AliITSRecPoint rnew(lab,hit,info,kTRUE);
+        rnew.SetdEdX(kconvGeV*clusterI->Q());
 
        fDetTypeRec->AddRecPoint(rnew);        
     } // I clusters
@@ -965,11 +1004,19 @@ void AliITSClusterFinderSDD::FindRawClusters(Int_t mod){
     // find raw clusters
     
     SetModule(mod);
+    SetCutAmplitude(mod);
+    AliITSCalibrationSDD* cal = (AliITSCalibrationSDD*)GetResp(mod);
+    Int_t nanodes=GetSeg()->Npz();
+    Int_t noise=0;
+    for(Int_t i=0;i<nanodes;i++){
+      noise+=(Int_t)cal->GetNoiseAfterElectronics(i);
+    }    
+    SetMinPeak((noise/nanodes)*5);
     Find1DClustersE();
     GroupClusters();
     SelectClusters();
     ResolveClusters();
-    GetRecPoints();
+    GetRecPoints(cal);
 }
 //_______________________________________________________________________
 void AliITSClusterFinderSDD::PrintStatus() const{
@@ -982,10 +1029,12 @@ void AliITSClusterFinderSDD::PrintStatus() const{
     cout << "Anode Tolerance: " << fDAnode << endl;
     cout << "Time  Tolerance: " << fDTime << endl;
     cout << "Time  correction (electronics): " << fTimeCorr << endl;
-    cout << "Cut Amplitude (threshold): " << fCutAmplitude << endl;
+    cout << "Cut Amplitude (threshold): " << fCutAmplitude[0] << endl;
     cout << "Minimum Amplitude: " << fMinPeak << endl;
     cout << "Minimum Charge: " << fMinCharge << endl;
     cout << "Minimum number of cells/clusters: " << fMinNCells << endl;
     cout << "Maximum number of cells/clusters: " << fMaxNCells << endl;
     cout << "**************************************************" << endl;
 }
+
+