]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - PHOS/AliPHOSTrackSegmentMakerv1.cxx
parameters have been redistributed; Hits2SDigits etc ... introduce
[u/mrichter/AliRoot.git] / PHOS / AliPHOSTrackSegmentMakerv1.cxx
index 9d2a1802e92c708e60f2da2e6215239df00f9159..ea0e72bfcb99803fe6cf14faa06b46851a9afa1b 100644 (file)
@@ -12,9 +12,7 @@
  * about the suitability of this software for any purpose. It is          *
  * provided "as is" without express or implied warranty.                  *
  **************************************************************************/
-
 /* $Id$ */
-
 //_________________________________________________________________________
 // Implementation version 1 of algorithm class to construct PHOS track segments
 // Associates EMC and PPSD clusters
@@ -38,6 +36,7 @@
 #include "AliPHOSTrackSegmentMakerv1.h"
 #include "AliPHOSIndexToObject.h"
 #include "AliPHOSTrackSegment.h"
+#include "AliPHOSCpvRecPoint.h"
 #include "AliPHOSLink.h"
 #include "AliPHOSv0.h"
 #include "AliRun.h"
@@ -63,9 +62,6 @@ ClassImp( AliPHOSTrackSegmentMakerv1)
  AliPHOSTrackSegmentMakerv1::~AliPHOSTrackSegmentMakerv1()
 { 
   // dtor
-
-  delete gMinuit ; 
-  gMinuit = 0 ;
 }
 
 //____________________________________________________________________________
@@ -74,6 +70,7 @@ Bool_t  AliPHOSTrackSegmentMakerv1::FindFit(AliPHOSEmcRecPoint * emcRP, int * ma
 { 
   // Calls TMinuit to fit the energy distribution of a cluster with several maxima 
 
+  gMinuit->mncler();                     // Reset Minuit list of paramters
   gMinuit->SetPrintLevel(-1) ;           // No Printout
   gMinuit->SetFCN(UnfoldingChiSquare) ;  // To set the address of the minimization function 
   gMinuit->SetObjectFit(emcRP) ;         // To tranfer pointer to UnfoldingChiSquare
@@ -187,10 +184,14 @@ void  AliPHOSTrackSegmentMakerv1::FillOneModule(AliPHOSRecPoint::RecPointsList *
     ppsdRecPoint = (AliPHOSPpsdRecPoint *) ppsdIn->At(index) ;
     if(ppsdRecPoint->GetPHOSMod() != phosmod )   
       break ;
-    if(ppsdRecPoint->GetUp() ) 
+    if(phosmod <= fGeom->GetNCPVModules())   //in CPV
       ppsdOutUp->AddAt(index,inPpsdUp++) ;
-    else  
-      ppsdOutLow->AddAt(index,inPpsdLow++) ;
+    else{                                   //in PPSD
+      if(ppsdRecPoint->GetUp() ) 
+       ppsdOutUp->AddAt(index,inPpsdUp++) ;
+      else  
+       ppsdOutLow->AddAt(index,inPpsdLow++) ;
+    }
   }
   ppsdOutLow->Set(inPpsdLow);
   ppsdOutUp->Set(inPpsdUp);
@@ -382,27 +383,24 @@ void  AliPHOSTrackSegmentMakerv1::MakeTrackSegments(DigitsList * dl,
 {
   // Makes the track segments out of the list of EMC and PPSD Recpoints and stores them in a list
   
-  Int_t phosmod      = fGeom->GetNCPVModules() + 1 ;
   Int_t emcStopedAt  = 0 ; 
   Int_t ppsdStopedAt = 0 ; 
 
   fNTrackSegments = 0 ; 
-
   
   TArrayI * emcRecPoints     = new TArrayI(1000) ;  // these arrays keep indexes 
   TArrayI * ppsdRecPointsUp  = new TArrayI(1000) ;  // of RecPoints, which are 
-  TArrayI * ppsdRecPointsLow = new TArrayI(1000) ;  // kept in TClonesArray's emcl and ppsdl
-  
+  TArrayI * ppsdRecPointsLow = new TArrayI(1000) ;  // kept in TClonesArray's emcl, ppsdl, cpv
   
   TClonesArray * linklowArray = new TClonesArray("AliPHOSLink", 1000);
   TClonesArray * linkupArray  = new TClonesArray("AliPHOSLink", 1000); 
 
-
   if(fUnfoldFlag){
     UnfoldAll(dl, emcl) ; // Unfolds all EMC clusters
+    UnfoldAll(dl, ppsdl) ; // Unfolds all CPV clusters
   }
 
-
+  Int_t phosmod  = 1 ;
   while(phosmod <= fGeom->GetNModules() ){
     
     FillOneModule(emcl, emcRecPoints, ppsdl, ppsdRecPointsUp, ppsdRecPointsLow, phosmod, emcStopedAt, ppsdStopedAt) ;
@@ -487,44 +485,54 @@ Double_t  AliPHOSTrackSegmentMakerv1::ShowerShape(Double_t r)
 //____________________________________________________________________________
 void  AliPHOSTrackSegmentMakerv1::UnfoldAll(DigitsList * dl, AliPHOSRecPoint::RecPointsList * emcIn) 
 {
-  // Performs unfolding of all EMC clusters, sorts them and resets indexes in RecPoints
+  // Performs unfolding of all EMC/CPV but NOT ppsd clusters, sorts them and resets indexes in RecPoints
 
   AliPHOSEmcRecPoint *  emcRecPoint  ; 
   Int_t index ;
   Int_t nEmcUnfolded = emcIn->GetEntries() ;
-  
-  for(index = 0 ; index < nEmcUnfolded; index++){
 
-    emcRecPoint = (AliPHOSEmcRecPoint *) emcIn->At(index) ;
-    
-    Int_t nMultipl = emcRecPoint->GetMultiplicity() ; 
-    Int_t * maxAt = new Int_t[nMultipl] ;
-    Float_t * maxAtEnergy = new Float_t[nMultipl] ;
-    Int_t nMax = emcRecPoint->GetNumberOfLocalMax(maxAt, maxAtEnergy) ;
-    
-    if( nMax > 1 ) {     // if cluster is very flat (no pronounced maximum) then nMax = 0       
-      UnfoldClusters(dl, emcIn, emcRecPoint, nMax, maxAt, maxAtEnergy) ;
-      emcIn->Remove(emcRecPoint); 
-      emcIn->Compress() ;
-      index-- ;
-      nEmcUnfolded-- ;
-    }
-    
-    delete[] maxAt ; 
-    delete[] maxAtEnergy ; 
-  } //Unfolding finished
+  Int_t nModulesToUnfold ;
 
-  emcIn->Sort() ;
+  if(emcIn->GetEntries() > 0){
 
-  // to set index to new and correct index of old RecPoints
-  for( index = 0 ; index < emcIn->GetEntries() ; index++){
+    if(((AliPHOSRecPoint *)emcIn->At(0))->IsEmc()){
+      nModulesToUnfold = fGeom->GetNModules() ; 
+    }
+    else{
+      nModulesToUnfold = fGeom->GetNCPVModules() ;
+    }
     
-    ((AliPHOSEmcRecPoint *) emcIn->At(index))->SetIndexInList(index) ;   
+    for(index = 0 ; index < nEmcUnfolded; index++){
+      
+      emcRecPoint = (AliPHOSEmcRecPoint *) emcIn->At(index) ;
+      if(emcRecPoint->GetPHOSMod()> nModulesToUnfold)
+       break ;
+      
+      Int_t nMultipl = emcRecPoint->GetMultiplicity() ; 
+      Int_t * maxAt = new Int_t[nMultipl] ;
+      Float_t * maxAtEnergy = new Float_t[nMultipl] ;
+      Int_t nMax = emcRecPoint->GetNumberOfLocalMax(maxAt, maxAtEnergy) ;
+      
+      if( nMax > 1 ) {     // if cluster is very flat (no pronounced maximum) then nMax = 0       
+       UnfoldClusters(dl, emcIn, emcRecPoint, nMax, maxAt, maxAtEnergy) ;
+       emcIn->Remove(emcRecPoint); 
+       emcIn->Compress() ;
+       index-- ;
+       nEmcUnfolded-- ;
+      }
+      
+      delete[] maxAt ; 
+      delete[] maxAtEnergy ; 
+    } //Unfolding finished
+   
+    emcIn->Sort() ;
+    
+    // to set index to new and correct index of old RecPoints
+    for( index = 0 ; index < emcIn->GetEntries() ; index++)
+      ((AliPHOSEmcRecPoint *) emcIn->At(index))->SetIndexInList(index) ;   
     
   }
 
-  emcIn->Sort() ;
-
 }
 //____________________________________________________________________________
 void  AliPHOSTrackSegmentMakerv1::UnfoldClusters(DigitsList * dl, 
@@ -563,7 +571,6 @@ void  AliPHOSTrackSegmentMakerv1::UnfoldClusters(DigitsList * dl,
   Int_t iDigit ;
   
   AliPHOSDigit * digit ;
-  AliPHOSEmcRecPoint * emcRP ;  
   Int_t * emcDigits = iniEmc->GetDigitsList() ;
   Float_t * emcEnergies = iniEmc->GetEnergiesList() ;
 
@@ -599,22 +606,45 @@ void  AliPHOSTrackSegmentMakerv1::UnfoldClusters(DigitsList * dl,
 
     if(iRecPoint >= emcIn->GetSize())
       emcIn->Expand(2*iRecPoint) ;
-    (*emcIn)[iRecPoint] = new AliPHOSEmcRecPoint( iniEmc->GetLogWeightCut(), iniEmc->GetLocMaxCut() ) ;
-    
-    emcRP = (AliPHOSEmcRecPoint *) emcIn->At(iRecPoint);
-    iRecPoint++ ;
 
-    for(iDigit = 0 ; iDigit < nDigits ; iDigit ++){
-      digit = fPlease->GimeDigit( emcDigits[iDigit] ) ; 
-      fGeom->AbsToRelNumbering(digit->GetId(), relid) ;
-      fGeom->RelPosInModule(relid, xDigit, zDigit) ;
-      distance = (xDigit - xpar) * (xDigit - xpar) + (zDigit - zpar) * (zDigit - zpar)  ;
-      distance =  TMath::Sqrt(distance) ;
-      ratio = epar * AliPHOSTrackSegmentMakerv1::ShowerShape(distance) / efit[iDigit] ; 
-      eDigit = emcEnergies[iDigit] * ratio ;
-      emcRP->AddDigit( *digit, eDigit ) ;
+    if(iniEmc->IsEmc()){
+      (*emcIn)[iRecPoint] = new AliPHOSEmcRecPoint( iniEmc->GetLogWeightCut(), iniEmc->GetLocMaxCut() ) ;
+
+      AliPHOSEmcRecPoint * emcRP ;  
+      emcRP = (AliPHOSEmcRecPoint *) emcIn->At(iRecPoint);
+      iRecPoint++ ;
+      
+      for(iDigit = 0 ; iDigit < nDigits ; iDigit ++){
+       digit = fPlease->GimeDigit( emcDigits[iDigit] ) ; 
+       fGeom->AbsToRelNumbering(digit->GetId(), relid) ;
+       fGeom->RelPosInModule(relid, xDigit, zDigit) ;
+       distance = (xDigit - xpar) * (xDigit - xpar) + (zDigit - zpar) * (zDigit - zpar)  ;
+       distance =  TMath::Sqrt(distance) ;
+       ratio = epar * AliPHOSTrackSegmentMakerv1::ShowerShape(distance) / efit[iDigit] ; 
+       eDigit = emcEnergies[iDigit] * ratio ;
+       emcRP->AddDigit( *digit, eDigit ) ;
+      }        
     }
+    else{
+      (*emcIn)[iRecPoint] = new AliPHOSCpvRecPoint( iniEmc->GetLogWeightCut(), iniEmc->GetLocMaxCut() ) ;
+     
+      AliPHOSCpvRecPoint * cpvRP ;  
+      cpvRP = (AliPHOSCpvRecPoint *) emcIn->At(iRecPoint);
 
+      iRecPoint++ ;
+      
+      for(iDigit = 0 ; iDigit < nDigits ; iDigit ++){
+       digit = fPlease->GimeDigit( emcDigits[iDigit] ) ; 
+       fGeom->AbsToRelNumbering(digit->GetId(), relid) ;
+       fGeom->RelPosInModule(relid, xDigit, zDigit) ;
+       distance = (xDigit - xpar) * (xDigit - xpar) + (zDigit - zpar) * (zDigit - zpar)  ;
+       distance =  TMath::Sqrt(distance) ;
+       ratio = epar * AliPHOSTrackSegmentMakerv1::ShowerShape(distance) / efit[iDigit] ; 
+       eDigit = emcEnergies[iDigit] * ratio ;
+       cpvRP->AddDigit( *digit, eDigit ) ;
+      }
+    }
+    
   }
   
   delete[] fitparameters ;