]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
Method SortTracks(..) imported from AliMUON.
authormorsch <morsch@f7af4fe6-9843-0410-8265-dc069ae4e863>
Mon, 5 Mar 2001 08:40:26 +0000 (08:40 +0000)
committermorsch <morsch@f7af4fe6-9843-0410-8265-dc069ae4e863>
Mon, 5 Mar 2001 08:40:26 +0000 (08:40 +0000)
MUON/AliMUONMerger.cxx
MUON/AliMUONMerger.h

index b20e246c50a527b4cdc6df774f07348c6298c074..5475931af420a15f4a8cc685b86cc700a00060f6 100644 (file)
@@ -15,6 +15,9 @@
 
 /*
 $Log$
+Revision 1.1  2001/02/02 14:11:53  morsch
+AliMUONMerger prototype to be called by the merge manager.
+
 */
 
 #include <TTree.h> 
@@ -426,7 +429,7 @@ void AliMUONMerger::Digitise()
            }      //end loop over list of tracks for one pad
             // Sort list of tracks according to charge
            if (nptracks > 1) {
-               pMUON->SortTracks(tracks,charges,nptracks);
+               SortTracks(tracks,charges,nptracks);
            }
            if (nptracks < 10 ) {
                for (Int_t i = nptracks; i < 10; i++) {
@@ -469,5 +472,59 @@ void AliMUONMerger::Digitise()
 
 
 
+void AliMUONMerger::SortTracks(Int_t *tracks,Int_t *charges,Int_t ntr)
+{
+  //
+  // Sort the list of tracks contributing to a given digit
+  // Only the 3 most significant tracks are acctually sorted
+  //
+  
+  //
+  //  Loop over signals, only 3 times
+  //
+  
+  Int_t qmax;
+  Int_t jmax;
+  Int_t idx[3] = {-2,-2,-2};
+  Int_t jch[3] = {-2,-2,-2};
+  Int_t jtr[3] = {-2,-2,-2};
+  Int_t i,j,imax;
+  
+  if (ntr<3) imax=ntr;
+  else imax=3;
+  for(i=0;i<imax;i++){
+    qmax=0;
+    jmax=0;
+    
+    for(j=0;j<ntr;j++){
+      
+      if((i == 1 && j == idx[i-1]) 
+        ||(i == 2 && (j == idx[i-1] || j == idx[i-2]))) continue;
+      
+      if(charges[j] > qmax) {
+       qmax = charges[j];
+       jmax=j;
+      }       
+    } 
+    
+    if(qmax > 0) {
+      idx[i]=jmax;
+      jch[i]=charges[jmax]; 
+      jtr[i]=tracks[jmax]; 
+    }
+    
+  } 
+  
+  for(i=0;i<3;i++){
+    if (jtr[i] == -2) {
+         charges[i]=0;
+         tracks[i]=0;
+    } else {
+         charges[i]=jch[i];
+         tracks[i]=jtr[i];
+    }
+  }
+}
+
 
 
index f894f1ebb6d665200e0317c741232dfe96776ada..137ebbe23f50b1b0e1eb315bb506763b029ee9f0 100644 (file)
@@ -43,6 +43,8 @@ class AliMUONMerger {
  private:    
     // Open the bgr file
     TFile *InitBgr();
+    void SortTracks(Int_t *tracks,Int_t *charges,Int_t ntr);
+    
  private:
     TTree *fTrH1;                   // ! Hits Tree for background event
     TClonesArray *fHitsBgr;         // ! List of hits for one track only