]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - EMCAL/AliEMCALTrackSegmentMakerv1.cxx
Made more robust
[u/mrichter/AliRoot.git] / EMCAL / AliEMCALTrackSegmentMakerv1.cxx
index 3a1df1fa31bfe5c3f90db67ab74926f9962962a5..9d1b408804627fdb3d67ef076d199159abb9b1f5 100644 (file)
 //
 
 // --- ROOT system ---
-#include "TROOT.h"
-#include "TFile.h"
-#include "TFolder.h"
 #include "TTree.h"
-#include "TSystem.h"
 #include "TBenchmark.h"
 
 // --- Standard library ---
 // --- AliRoot header files ---
 
 #include "AliEMCALTrackSegmentMakerv1.h"
-#include "AliEMCALClusterizerv1.h"
 #include "AliEMCALTrackSegment.h"
 #include "AliEMCALLink.h"
 #include "AliEMCALGetter.h"
-#include "AliEMCAL.h"
 
 ClassImp( AliEMCALTrackSegmentMakerv1) 
 
@@ -79,11 +73,7 @@ ClassImp( AliEMCALTrackSegmentMakerv1)
 { 
   // dtor
   // fDefaultInit = kTRUE if TrackSegmentMaker created by default ctor (to get just the parameters)
-  
-  if (!fDefaultInit) {
-    delete fPRELinkArray  ;
-    delete fHCALinkArray  ;
-  }
+
 }
 
 //____________________________________________________________________________
@@ -94,7 +84,7 @@ const TString AliEMCALTrackSegmentMakerv1::BranchName() const
 }
 
 //____________________________________________________________________________
-Float_t  AliEMCALTrackSegmentMakerv1::HowClose(AliEMCALTowerRecPoint * ec, AliEMCALTowerRecPoint * rp, Bool_t &toofar)const
+Float_t  AliEMCALTrackSegmentMakerv1::HowClose(AliEMCALRecPoint * ec, AliEMCALRecPoint * rp, Bool_t &toofar)const
 {
   // Calculates the distance between the EMC RecPoint and the PPSD RecPoint
   // Clusters are sorted in "rows" and "columns" of width 1 cm
@@ -103,8 +93,10 @@ Float_t  AliEMCALTrackSegmentMakerv1::HowClose(AliEMCALTowerRecPoint * ec, AliEM
   Float_t delta = 10. ;  // large enough to be ineffective ??! 
 
  
-  TVector3 vecEC = ec->XYZInAlice() ;
-  TVector3 vecRP = rp->XYZInAlice() ;
+  TVector3 vecEC;
+  TVector3 vecRP;
+  ec->GetGlobalPosition(vecEC);
+  rp->GetGlobalPosition(vecRP);
   
   Float_t pro = TMath::Abs(1 - (vecEC * vecRP / ( vecEC.Mag() * vecRP.Mag() ))) ; 
 
@@ -116,7 +108,7 @@ Float_t  AliEMCALTrackSegmentMakerv1::HowClose(AliEMCALTowerRecPoint * ec, AliEM
     toofar = kTRUE ;
 
   if (gDebug == 2 ) 
-    Info("HowClose", "ec = %d, rp = %d pro = %f, toofar=%d", ec->GetIndexInList(), rp->GetIndexInList(), pro, toofar ) ; 
+    printf("HowClose: ec = %d, rp = %d pro = %f, toofar=%d", ec->GetIndexInList(), rp->GetIndexInList(), pro, toofar ) ; 
  
   return r ;
 }
@@ -127,9 +119,7 @@ void  AliEMCALTrackSegmentMakerv1::Init()
   // Make all memory allocations that are not possible in default constructor
   
   AliEMCALGetter* gime = AliEMCALGetter::Instance(GetTitle(), fEventFolderName.Data());
-
-  fPRELinkArray = new TClonesArray("AliEMCALLink", 1000); 
-  fHCALinkArray = new TClonesArray("AliEMCALLink", 1000); 
   if ( !gime->TrackSegmentMaker() ) {
     gime->PostTrackSegmentMaker(this);
   }
@@ -139,8 +129,6 @@ void  AliEMCALTrackSegmentMakerv1::Init()
 void  AliEMCALTrackSegmentMakerv1::InitParameters()
 {
   fClose              = 10e-3 ;   
-  fPRELinkArray       = 0 ;
-  fHCALinkArray       = 0 ;
   fTrackSegmentsInRun = 0 ; 
 }
 
@@ -152,28 +140,28 @@ void  AliEMCALTrackSegmentMakerv1::MakeLinks()const
   // which are not further apart from each other than fDangle 
   // and sort them in accordance with this distance
   
-  AliEMCALGetter * gime = AliEMCALGetter::Instance() ; 
+  /* AliEMCALGetter * gime = AliEMCALGetter::Instance() ; 
   TObjArray * aECARecPoints  = gime->ECARecPoints() ; 
-  TObjArray * aPRERecPoints  = gime->PRERecPoints() ; 
-  TObjArray * aHCARecPoints  = gime->HCARecPoints() ; 
+  // TObjArray * aPRERecPoints  = gime->PRERecPoints() ; 
+  //TObjArray * aHCARecPoints  = gime->HCARecPoints() ; 
 
   fPRELinkArray->Clear() ;    
   fHCALinkArray->Clear() ;    
 
-  AliEMCALTowerRecPoint * pre ;
-  AliEMCALTowerRecPoint * eca ;
-  AliEMCALTowerRecPoint * hca ;
+  AliEMCALRecPoint * pre ;
+  AliEMCALRecPoint * eca ;
+  AliEMCALRecPoint * hca ;
 
   Int_t iPRELink  = 0 ;
   Int_t iHCALink  = 0 ;
     
   Int_t iECARP;
   for(iECARP = 0; iECARP < aECARecPoints->GetEntriesFast(); iECARP++ ) {
-    eca = dynamic_cast<AliEMCALTowerRecPoint *>(aECARecPoints->At(iECARP)) ;
+    eca = dynamic_cast<AliEMCALRecPoint *>(aECARecPoints->At(iECARP)) ;
     Bool_t toofar = kTRUE ;        
     Int_t iPRERP = 0 ;    
     for(iPRERP = 0; iPRERP < aPRERecPoints->GetEntriesFast(); iPRERP++ ) { 
-      pre = dynamic_cast<AliEMCALTowerRecPoint *>(aPRERecPoints->At(iPRERP)) ;
+      pre = dynamic_cast<AliEMCALRecPoint *>(aPRERecPoints->At(iPRERP)) ;
       Float_t prod = HowClose(eca, pre, toofar) ;    
       if(toofar)
        break ;  
@@ -184,7 +172,7 @@ void  AliEMCALTrackSegmentMakerv1::MakeLinks()const
     toofar = kTRUE ; 
     Int_t iHCARP = 0 ;    
     for(iHCARP = 0; iHCARP < aHCARecPoints->GetEntriesFast(); iHCARP++ ) { 
-      hca = dynamic_cast<AliEMCALTowerRecPoint *>(aHCARecPoints->At(iHCARP)) ;
+      hca = dynamic_cast<AliEMCALRecPoint *>(aHCARecPoints->At(iHCARP)) ;
       Float_t prod = HowClose(eca, hca, toofar) ;    
       if(toofar)
        break ;  
@@ -196,6 +184,7 @@ void  AliEMCALTrackSegmentMakerv1::MakeLinks()const
   
   fPRELinkArray->Sort() ;  //first links with largest scalar product
   fHCALinkArray->Sort() ;  //first links with largest scalar product
+  */
 }
 
 //____________________________________________________________________________
@@ -206,8 +195,8 @@ void  AliEMCALTrackSegmentMakerv1::MakePairs()
   // unassigned RecParticles. We assign these RecPoints to TrackSegment and 
   // remove them from the list of "unassigned". 
   
-  AliEMCALGetter * gime = AliEMCALGetter::Instance() ; 
-  TObjArray * aECARecPoints = gime->ECARecPoints() ; 
+  /*AliEMCALGetter * gime = AliEMCALGetter::Instance() ; 
+   TObjArray * aECARecPoints = gime->ECARecPoints() ; 
   TObjArray * aPRERecPoints = gime->PRERecPoints() ; 
   TObjArray * aHCARecPoints = gime->HCARecPoints() ; 
   TClonesArray * trackSegments = gime->TrackSegments() ;   
@@ -236,7 +225,7 @@ void  AliEMCALTrackSegmentMakerv1::MakePairs()
   for(index = 0; index < nHCA; index ++)
     hcaExist[index] = kTRUE ;
   
-  AliEMCALTowerRecPoint * null = 0 ; 
+  AliEMCALRecPoint * null = 0 ; 
  // Finds the smallest links and makes pairs of PRE and ECAL clusters with largest scalar product 
  
   TIter nextPRE(fPRELinkArray) ;
@@ -249,12 +238,12 @@ void  AliEMCALTrackSegmentMakerv1::MakePairs()
       if(preExist[linkPRE->GetOther()]){ // PRE still exist
        
        new ((* trackSegments)[fNTrackSegments]) 
-         AliEMCALTrackSegment(dynamic_cast<AliEMCALTowerRecPoint *>(aECARecPoints->At(linkPRE->GetECA())) , 
-                              dynamic_cast<AliEMCALTowerRecPoint *>(aPRERecPoints->At(linkPRE->GetOther())), null) ;
+         AliEMCALTrackSegment(dynamic_cast<AliEMCALRecPoint *>(aECARecPoints->At(linkPRE->GetECA())) , 
+                              dynamic_cast<AliEMCALRecPoint *>(aPRERecPoints->At(linkPRE->GetOther())), null) ;
        (dynamic_cast<AliEMCALTrackSegment *>(trackSegments->At(fNTrackSegments)))->SetIndexInList(fNTrackSegments);
        fNTrackSegments++ ;
        if (gDebug == 2 ) 
-         Info("MakePairs", "ECAL section with PRE section") ;  
+         printf("MakePairs: ECAL section with PRE section") ;  
        ecaExist[linkPRE->GetECA()] = -1 ; //Mark ecal  that pre was found 
        //mark PRE recpoint as already used 
        preExist[linkPRE->GetOther()] = kFALSE ;
@@ -284,18 +273,18 @@ void  AliEMCALTrackSegmentMakerv1::MakePairs()
          }
        }
        if (found){
-         ts->SetHCARecPoint( dynamic_cast<AliEMCALTowerRecPoint *>(aHCARecPoints->At(linkHCA->GetOther())) ) ;
+         ts->SetHCARecPoint( dynamic_cast<AliEMCALRecPoint *>(aHCARecPoints->At(linkHCA->GetOther())) ) ;
          if (gDebug == 2 ) 
-           Info("MakePairs", "ECAL section with PRE and HCAL sections") ;
+           printf("MakePairs: ECAL section with PRE and HCAL sections") ;
        }       
        if (!found) {
          new ((* trackSegments)[fNTrackSegments]) 
-           AliEMCALTrackSegment(dynamic_cast<AliEMCALTowerRecPoint *>(aECARecPoints->At(linkHCA->GetECA())), null,
-                                dynamic_cast<AliEMCALTowerRecPoint *>(aHCARecPoints->At(linkHCA->GetOther()))) ; 
+           AliEMCALTrackSegment(dynamic_cast<AliEMCALRecPoint *>(aECARecPoints->At(linkHCA->GetECA())), null,
+                                dynamic_cast<AliEMCALRecPoint *>(aHCARecPoints->At(linkHCA->GetOther()))) ; 
        (dynamic_cast<AliEMCALTrackSegment *>(trackSegments->At(fNTrackSegments)))->SetIndexInList(fNTrackSegments);
        fNTrackSegments++ ;
        if (gDebug == 2 ) 
-         Info("MakePairs", "ECAL section with HCAL section") ;         
+         printf("MakePairs: ECAL section with HCAL section") ;         
        }
        ecaExist[linkHCA->GetECA()] = -2 ; //Mark ecal  that hcal was found 
        //mark HCAL recpoint as already used 
@@ -311,17 +300,18 @@ void  AliEMCALTrackSegmentMakerv1::MakePairs()
     for(iECARP = 0; iECARP < nECA  ; iECARP++ ){
       if(ecaExist[iECARP] > 0 ){
        new ((*trackSegments)[fNTrackSegments])  
-         AliEMCALTrackSegment(dynamic_cast<AliEMCALTowerRecPoint *>(aECARecPoints->At(iECARP)), null, null) ;
+         AliEMCALTrackSegment(dynamic_cast<AliEMCALRecPoint *>(aECARecPoints->At(iECARP)), null, null) ;
        (dynamic_cast<AliEMCALTrackSegment *>(trackSegments->At(fNTrackSegments)))->SetIndexInList(fNTrackSegments);
        fNTrackSegments++;    
        if( gDebug == 2 ) 
-         Info("MakePairs", "ECAL section alone") ; 
+         printf("MakePairs: ECAL section alone") ; 
      } 
     }
   }
   delete [] ecaExist ; 
   delete [] preExist ; 
   delete [] hcaExist ; 
+  */
 }
 
 //____________________________________________________________________________
@@ -365,7 +355,7 @@ void  AliEMCALTrackSegmentMakerv1::Exec(Option_t * option)
   
   if(strstr(option,"tim")){
     gBenchmark->Stop("EMCALTSMaker");
-    Info("Exec", "took %f seconds for making TS %f seconds per event", 
+    printf("Exec: took %f seconds for making TS %f seconds per event", 
         gBenchmark->GetCpuTime("EMCALTSMaker"), gBenchmark->GetCpuTime("EMCALTSMaker")/nevents) ;
   }
    Unload();
@@ -374,6 +364,7 @@ void  AliEMCALTrackSegmentMakerv1::Exec(Option_t * option)
 //____________________________________________________________________________
 void AliEMCALTrackSegmentMakerv1::Unload() 
 {
+  // Unloads the RecPoints and Tracks
   AliEMCALGetter * gime = AliEMCALGetter::Instance() ;  
   gime->EmcalLoader()->UnloadRecPoints() ;
   gime->EmcalLoader()->UnloadTracks() ;
@@ -384,7 +375,7 @@ void AliEMCALTrackSegmentMakerv1::Print(Option_t * /*option*/)const
 {
   //  Print TrackSegmentMaker parameters
 
-  Info("Print", "TrackSegmentMakerv1 parameters:") ; 
+  printf("Print: TrackSegmentMakerv1 parameters:") ; 
   if( strcmp(GetName(), "") != 0 ) { 
     printf("Making Track segments with parameters:\n") ; 
     printf("    Allowed spred on the scalar product of two recpoints with same direction: %f\n", fClose) ;
@@ -431,17 +422,17 @@ void AliEMCALTrackSegmentMakerv1::PrintTrackSegments(Option_t * option)
   TClonesArray * trackSegments = AliEMCALGetter::Instance()->TrackSegments() ; 
 
 
-  Info("PrintTrackSegments", "Results from TrackSegmentMaker:") ; 
+  printf("PrintTrackSegments: Results from TrackSegmentMaker:") ; 
   printf("nevent: %d\n", gAlice->GetEvNumber()) ; 
   printf("        Found %d TrackSegments\n", trackSegments->GetEntriesFast() ); 
 
   if(strstr(option,"all")) {  // printing found TS
-    printf("TrackSegment#  ECAL RP#  PRE RP#   HCAL RP#  \n") ; 
+    printf("TrackSegment#  ECAL RP#  \n") ; 
     Int_t index;
     for (index = 0 ; index < fNTrackSegments ; index++) {
       AliEMCALTrackSegment * ts = (AliEMCALTrackSegment * )trackSegments->At(index) ; 
-      printf("   %d           %d        %d         %d \n", 
-            ts->GetIndexInList(), ts->GetECAIndex(), ts->GetPREIndex(), ts->GetHCAIndex() ); 
+      printf("   %d           %d \n", 
+            ts->GetIndexInList(), ts->GetECAIndex()); 
     }  
   }
 }