]> 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 1bf4acdb65c94c7fa39540ddfbeb07b227c1ae43..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"
@@ -55,7 +54,7 @@ ClassImp( AliPHOSTrackSegmentMakerv1)
   fR0 = 10. ;   
   //clusters are sorted in "rows" and "columns" of width geom->GetCrystalSize(0),
   fDelta = fR0 + fGeom->GetCrystalSize(0) ;
-  fMinuit = new TMinuit(100) ;
+  if(!gMinuit) gMinuit = new TMinuit(100) ;
   fUnfoldFlag = kTRUE ; 
 }
 
@@ -63,8 +62,6 @@ ClassImp( AliPHOSTrackSegmentMakerv1)
  AliPHOSTrackSegmentMakerv1::~AliPHOSTrackSegmentMakerv1()
 { 
   // dtor
-   delete fMinuit ; 
 }
 
 //____________________________________________________________________________
@@ -73,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
@@ -123,7 +121,7 @@ Bool_t  AliPHOSTrackSegmentMakerv1::FindFit(AliPHOSEmcRecPoint * emcRP, int * ma
   Double_t p1 = 1.0 ;
   Double_t p2 = 0.0 ;
 
-  gMinuit->mnexcm("SET STR", &p2, 0, ierflg) ;   // force TgMinuit to reduce function calls  
+  gMinuit->mnexcm("SET STR", &p2, 0, ierflg) ;   // force TMinuit to reduce function calls  
   gMinuit->mnexcm("SET GRA", &p1, 1, ierflg) ;   // force TMinuit to use my gradient  
   gMinuit->SetMaxIterations(5);
   gMinuit->mnexcm("SET NOW", &p2 , 0, ierflg) ;  // No Warnings
@@ -155,7 +153,7 @@ void  AliPHOSTrackSegmentMakerv1::FillOneModule(AliPHOSRecPoint::RecPointsList *
                                                Int_t & emcStopedAt, 
                                                Int_t & ppsdStopedAt)
 {
-  // Fill xxxOut arrays with clusters from one PHOS module EMC+PPSD
+  // Fill xxxOut arrays with clusters from one PHOS module
  
   AliPHOSEmcRecPoint *  emcRecPoint  ; 
   AliPHOSPpsdRecPoint * ppsdRecPoint ;
@@ -186,57 +184,19 @@ 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);
   ppsdStopedAt = index ;
    
-}
-//____________________________________________________________________________
-void  AliPHOSTrackSegmentMakerv1::FillOneModule(AliPHOSRecPoint::RecPointsList * emcIn, 
-                                               TArrayI * emcOut, 
-                                               AliPHOSRecPoint::RecPointsList * cpvIn, 
-                                               TArrayI * cpvOut,
-                                               Int_t & phosmod, 
-                                               Int_t & emcStopedAt, 
-                                               Int_t & cpvStopedAt)
-{
-  // Fill xxxOut arrays with clusters from one PHOS module EMC+CPV
-  AliPHOSEmcRecPoint * emcRecPoint  ; 
-  AliPHOSEmcRecPoint * cpvRecPoint ;
-  Int_t index ;
-  
-  Int_t nEmcUnfolded = emcIn->GetEntries() ;
-  emcOut->Set(nEmcUnfolded);
-  Int_t inEmcOut = 0 ;
-  for(index = emcStopedAt; index < nEmcUnfolded; index++){
-    emcRecPoint = (AliPHOSEmcRecPoint *) emcIn->At(index) ;
-    if(emcRecPoint->GetPHOSMod() != phosmod )  
-      break ;
-    
-    emcOut->AddAt(emcRecPoint->GetIndexInList(),inEmcOut) ;
-    inEmcOut++ ; 
-  }
-  emcOut->Set(inEmcOut) ;
-  emcStopedAt = index ;
-
-  cpvOut->Set(cpvIn->GetEntries()) ;
-  Int_t inCpvOut = 0;
-  for(index = cpvStopedAt; index < cpvIn->GetEntries(); index++){
-    cpvRecPoint = (AliPHOSEmcRecPoint *) cpvIn->At(index) ;
-    if(cpvRecPoint->GetPHOSMod() != phosmod )   
-      break ;
-    else  
-      cpvOut->AddAt(index,inCpvOut++) ;
-  }
-  cpvOut->Set(inCpvOut);
-  cpvStopedAt = index ;
-   
 }
 //____________________________________________________________________________
 Float_t  AliPHOSTrackSegmentMakerv1::GetDistanceInPHOSPlane(AliPHOSEmcRecPoint * emcclu,AliPHOSPpsdRecPoint * PpsdClu, Bool_t &toofar)
@@ -251,8 +211,8 @@ Float_t  AliPHOSTrackSegmentMakerv1::GetDistanceInPHOSPlane(AliPHOSEmcRecPoint *
   emcclu->GetLocalPosition(vecEmc) ;
   PpsdClu->GetLocalPosition(vecPpsd)  ; 
   if(emcclu->GetPHOSMod() == PpsdClu->GetPHOSMod()){ 
-    if(vecPpsd.X() >= vecEmc.X() - fDelta ){ 
-      if(vecPpsd.Z() >= vecEmc.Z() - fDelta ){
+    //    if(vecPpsd.X() >= vecEmc.X() - fDelta ){ 
+    //  if(vecPpsd.Z() >= vecEmc.Z() - fDelta ){
        // Correct to difference in CPV and EMC position due to different distance to center.
        // we assume, that particle moves from center
        Float_t dCPV = fGeom->GetIPtoOuterCoverDistance();
@@ -260,14 +220,17 @@ Float_t  AliPHOSTrackSegmentMakerv1::GetDistanceInPHOSPlane(AliPHOSEmcRecPoint *
        dEMC         = dEMC / dCPV ;
         vecPpsd = dEMC * vecPpsd  - vecEmc ; 
         r = vecPpsd.Mag() ;
-      } // if  zPpsd >= zEmc - fDelta
+       //    } // if  zPpsd >= zEmc - fDelta
       toofar = kFALSE ;
-    } // if  xPpsd >= xEmc - fDelta
-    else 
-      toofar = kTRUE ;
+      //} // if  xPpsd >= xEmc - fDelta
+      // else 
+      //toofar = kTRUE ;
   } 
   else 
     toofar = kTRUE ;
+
+  //toofar = kFALSE ;
   
   return r ;
 }
@@ -353,15 +316,16 @@ void  AliPHOSTrackSegmentMakerv1::MakePairs(TArrayI * emcRecPoints,
   
     emc = emcRecPoints->At(linkLow->GetEmc()) ;
     ppsdLow = ppsdRecPointsLow->At(linkLow->GetPpsd()) ;
-    if( (emc >= 0) && (ppsdLow >= 0) ){    // RecPoints not removed yet 
 
+    if( (emc >= 0) && (ppsdLow >= 0) ){    // RecPoints not removed yet 
+      
       new( (*trsl)[fNTrackSegments] ) AliPHOSTrackSegment((AliPHOSEmcRecPoint *)fPlease->GimeRecPoint(emc,"emc"), 
                                                          nullpointer, 
                                                          (AliPHOSPpsdRecPoint *)fPlease->GimeRecPoint(ppsdLow,"ppsd") ) ;
       ((AliPHOSTrackSegment* )trsl->At(fNTrackSegments))->SetIndexInList(fNTrackSegments);    
       //replace index of emc to negative and shifted index of TS      
       emcRecPoints->AddAt(-2 - fNTrackSegments,linkLow->GetEmc()) ;  
-      //replace index of emc to negative and shifted index of TS      
+      //replace index of PPSD Low to negative and shifted index of TS      
       ppsdRecPointsLow->AddAt(-2 - fNTrackSegments,linkLow->GetPpsd()) ; 
       fNTrackSegments++ ;
 
@@ -373,21 +337,25 @@ void  AliPHOSTrackSegmentMakerv1::MakePairs(TArrayI * emcRecPoints,
     if(emc != -1){ //without ppsd Up yet 
 
       ppsdUp = ppsdRecPointsUp->At(linkUp->GetPpsd()) ;
-
-      if(emc >= 0){ //without ppsd Low => create new TS
-
-       fNTrackSegments = trsl->GetEntries() ; 
-       new( (*trsl)[fNTrackSegments] ) AliPHOSTrackSegment((AliPHOSEmcRecPoint *) fPlease->GimeRecPoint(emc,"emc"), 
-                                                           (AliPHOSPpsdRecPoint *)fPlease->GimeRecPoint(ppsdUp,"ppsd"), 
-                                                           nullpointer) ;
-       ((AliPHOSTrackSegment *) trsl->At(fNTrackSegments))->SetIndexInList(fNTrackSegments);
-       fNTrackSegments++ ;
-      }
-      else{ // append ppsd Up to existing TS
-       ((AliPHOSTrackSegment *)trsl->At(-2-emc))->SetPpsdUpRecPoint((AliPHOSPpsdRecPoint *)fPlease->GimeRecPoint(ppsdUp,"ppsd"));
-      }
-      emcRecPoints->AddAt(-1,linkUp->GetEmc()) ; //Mark that PPSD Up found 
-      
+      if(ppsdUp >= 0){ //ppsdUp still exist
+       
+       if(emc >= 0){ //without ppsd Low => create new TS
+
+         fNTrackSegments = trsl->GetEntries() ; 
+         new( (*trsl)[fNTrackSegments] ) AliPHOSTrackSegment((AliPHOSEmcRecPoint *) fPlease->GimeRecPoint(emc,"emc"), 
+                                                             (AliPHOSPpsdRecPoint *)fPlease->GimeRecPoint(ppsdUp,"ppsd"), 
+                                                             nullpointer) ;
+         ((AliPHOSTrackSegment *) trsl->At(fNTrackSegments))->SetIndexInList(fNTrackSegments);
+         fNTrackSegments++ ;
+       }
+       else{ // append ppsd Up to existing TS
+         ((AliPHOSTrackSegment *)trsl->At(-2-emc))->SetPpsdUpRecPoint((AliPHOSPpsdRecPoint *)fPlease->GimeRecPoint(ppsdUp,"ppsd"));
+       }
+
+       emcRecPoints->AddAt(-1,linkUp->GetEmc()) ; //Mark that PPSD Up found 
+       //replace index of PPSD Up to negative and shifted index of TS      
+       ppsdRecPointsUp->AddAt(-2 - fNTrackSegments,linkUp->GetPpsd()) ; 
+      } //if ppsdUp still exist
     } 
   }     
 
@@ -415,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      = 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", 100);
-  TClonesArray * linkupArray  = new TClonesArray("AliPHOSLink", 100); 
-
+  TClonesArray * linklowArray = new TClonesArray("AliPHOSLink", 1000);
+  TClonesArray * linkupArray  = new TClonesArray("AliPHOSLink", 1000); 
 
   if(fUnfoldFlag){
-    UnfoldAll(dl, emcl) ;      // Unfolds all EMC clusters
+    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) ;
@@ -475,8 +440,8 @@ void  AliPHOSTrackSegmentMakerv1::MakeTrackSegments(DigitsList * dl,
 
 //____________________________________________________________________________
 void  AliPHOSTrackSegmentMakerv1::MakeTrackSegmentsCPV(DigitsList * dl, 
-                                                      AliPHOSRecPoint::RecPointsList * emcl, 
-                                                      AliPHOSRecPoint::RecPointsList * cpvl)
+                                                       AliPHOSRecPoint::RecPointsList * emcl, 
+                                                       AliPHOSRecPoint::RecPointsList * cpvl)
 {
   // Unfold clusters in EMC and CPV and refill reconstructed point lists emcl and ppsdl
   // Yuri Kharlov. 19 October 2000
@@ -520,42 +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 nModulesToUnfold ;
+
+  if(emcIn->GetEntries() > 0){
+
+    if(((AliPHOSRecPoint *)emcIn->At(0))->IsEmc()){
+      nModulesToUnfold = fGeom->GetNModules() ; 
+    }
+    else{
+      nModulesToUnfold = fGeom->GetNCPVModules() ;
+    }
     
-    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) ;
+    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() ;
     
-    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-- ;
-    }
+    // to set index to new and correct index of old RecPoints
+    for( index = 0 ; index < emcIn->GetEntries() ; index++)
+      ((AliPHOSEmcRecPoint *) emcIn->At(index))->SetIndexInList(index) ;   
     
-    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, 
@@ -579,7 +556,6 @@ void  AliPHOSTrackSegmentMakerv1::UnfoldClusters(DigitsList * dl,
     return ;
   }
 
-
   Float_t xDigit ;
   Float_t zDigit ;
   Int_t relid[4] ;
@@ -595,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() ;
 
@@ -631,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 ;