]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - MUON/AliMUONClusterFinderPeakFit.cxx
Move verbose to debug (Javier)
[u/mrichter/AliRoot.git] / MUON / AliMUONClusterFinderPeakFit.cxx
index 54c1ba97a67d9020590a735ce20fe6adf3e60cba..43ed7d9c66bf3b13e8f77f31239cf3b09d500500 100644 (file)
@@ -37,8 +37,8 @@
 
 #include "AliMpDEManager.h"
 #include "AliMpPad.h"
-#include "AliMpStationType.h"
 #include "AliMpVSegmentation.h"
+#include "AliMpEncodePair.h"
 
 #include "AliLog.h"
 #include "AliRunLoader.h"
@@ -152,7 +152,7 @@ fNAddVirtualPads(0)
 {
   /// Constructor
  
-  fSegmentation[1] = fSegmentation[0] = 0x0; 
+  fkSegmentation[1] = fkSegmentation[0] = 0x0; 
 
   if (fPlot) fDebug = 1;
 }
@@ -170,34 +170,36 @@ AliMUONClusterFinderPeakFit::~AliMUONClusterFinderPeakFit()
 
 //_____________________________________________________________________________
 Bool_t 
-AliMUONClusterFinderPeakFit::Prepare(Int_t detElemId, TClonesArray* pads[2],
-                                    const AliMpArea& area, const AliMpVSegmentation* seg[2])
+AliMUONClusterFinderPeakFit::Prepare(Int_t detElemId, TObjArray* pads[2],
+                                     const AliMpArea& area, 
+                                     const AliMpVSegmentation* seg[2])
 {
   /// Prepare for clustering
-//  AliCodeTimerAuto("")
+//  AliCodeTimerAuto("",0)
   
   for ( Int_t i = 0; i < 2; ++i )
   {
-    fSegmentation[i] = seg[i];
+    fkSegmentation[i] = seg[i];
   }
   
   // Find out the DetElemId
   fDetElemId = detElemId;
   
   // find out current event number, and reset the cluster number
-  fEventNumber = AliRunLoader::GetRunLoader()->GetEventNumber();
+  AliRunLoader *runLoader = AliRunLoader::Instance();
+  fEventNumber = runLoader ? runLoader->GetEventNumber() : 0;
   fClusterNumber = -1;
   fClusterList.Delete();
   
   AliDebug(3,Form("EVT %d DE %d",fEventNumber,fDetElemId));
   
-  AliMp::StationType stationType = AliMpDEManager::GetStationType(fDetElemId);
+  AliMq::Station12Type stationType = AliMpDEManager::GetStation12Type(fDetElemId);
   
   Float_t kx3 = AliMUONConstants::SqrtKx3();
   Float_t ky3 = AliMUONConstants::SqrtKy3();
   Float_t pitch = AliMUONConstants::Pitch();
   
-  if ( stationType == AliMp::kStation1 )
+  if ( stationType == AliMq::kStation1 )
   {
     kx3 = AliMUONConstants::SqrtKx3St1();
     ky3 = AliMUONConstants::SqrtKy3St1();
@@ -226,7 +228,7 @@ AliMUONCluster*
 AliMUONClusterFinderPeakFit::NextCluster()
 {
   /// Return next cluster
-//  AliCodeTimerAuto("")
+//  AliCodeTimerAuto("",0)
   
   // if the list of clusters is not void, pick one from there
   TObject* o = fClusterList.At(++fClusterNumber);
@@ -239,6 +241,9 @@ AliMUONClusterFinderPeakFit::NextCluster()
   // if the cluster list is exhausted, we need to go to the next
   // pre-cluster and treat it
 
+  fClusterList.Delete(); // reset the list of clusters for this pre-cluster
+  fClusterNumber = -1; 
+    
   fPreCluster = fPreClusterFinder->NextCluster();
   
   if (!fPreCluster)
@@ -247,9 +252,6 @@ AliMUONClusterFinderPeakFit::NextCluster()
     return 0x0;
   }
     
-  fClusterList.Delete(); // reset the list of clusters for this pre-cluster
-  fClusterNumber = -1; 
-  
   WorkOnPreCluster();
 
   // WorkOnPreCluster may have used only part of the pads, so we check that
@@ -275,10 +277,10 @@ AliMUONClusterFinderPeakFit::WorkOnPreCluster()
   /// Starting from a precluster, builds a pixel array, and then
   /// extract clusters from this array
   
-  //  AliCodeTimerAuto("")     
+  //  AliCodeTimerAuto("",0)   
 
   if (fDebug) {
-    cout << " *** Event # " << AliRunLoader::GetRunLoader()->GetEventNumber() 
+    cout << " *** Event # " << fEventNumber
         << " det. elem.: " << fDetElemId << endl;
     for (Int_t j = 0; j < fPreCluster->Multiplicity(); ++j) {
       AliMUONPad* pad = fPreCluster->Pad(j);
@@ -345,11 +347,11 @@ AliMUONClusterFinderPeakFit::CheckPrecluster(const AliMUONCluster& origCluster)
   /// Check precluster in order to attempt to simplify it (mostly for
   /// two-cathode preclusters)
     
-  //  AliCodeTimerAuto("")
+  //  AliCodeTimerAuto("",0)
 
   // Disregard small clusters (leftovers from splitting or noise)
   if ((origCluster.Multiplicity()==1 || origCluster.Multiplicity()==2) &&
-      origCluster.Charge(0)+origCluster.Charge(1) < 10) 
+      origCluster.Charge(0)+origCluster.Charge(1) < 1.525) // JC: adc -> fc
   { 
     return 0x0;
   }
@@ -415,10 +417,11 @@ AliMUONClusterFinderPeakFit::CheckPreclusterTwoCathodes(AliMUONCluster* cluster)
       Int_t cath = pad->Cathode();
       Int_t cath1 = TMath::Even(cath);
       // Check for edge effect (missing pads on the _other_ cathode)
-      AliMpPad mpPad = fSegmentation[cath1]->PadByPosition(pad->Position(),kFALSE);
+      AliMpPad mpPad 
+        = fkSegmentation[cath1]->PadByPosition(pad->Position().X(),pad->Position().Y(),kFALSE);
       if (!mpPad.IsValid()) continue;
       //if (nFlags == 1 && pad->Charge() < fgkZeroSuppression * 3) continue;
-      if (nFlags == 1 && pad->Charge() < 20) continue;
+      if (nFlags == 1 && pad->Charge() < 3.05) continue;  // JC: adc -> fc
       AliDebug(2,Form("Releasing the following pad : de,cath,ix,iy %d,%d,%d,%d charge %e",
                       fDetElemId,pad->Cathode(),pad->Ix(),pad->Iy(),pad->Charge()));
       toBeRemoved.AddLast(pad);
@@ -624,7 +627,7 @@ void AliMUONClusterFinderPeakFit::BuildPixArrayOneCathode(AliMUONCluster& cluste
 //  AliDebug(2,Form("cluster.Multiplicity=%d",cluster.Multiplicity()));
 
   TVector2 dim = cluster.MinPadDimensions (-1, kFALSE);
-  Double_t width[2] = {dim.X(), dim.Y()}, xy0[2];
+  Double_t width[2] = {dim.X(), dim.Y()}, xy0[2] = { 0.0, 0.0 };
   Int_t found[2] = {0}, mult = cluster.Multiplicity();
 
   for ( Int_t i = 0; i < mult; ++i) {
@@ -643,19 +646,21 @@ void AliMUONClusterFinderPeakFit::BuildPixArrayOneCathode(AliMUONCluster& cluste
   if (cluster.Multiplicity(0) == 0) cath0 = 1;
   else if (cluster.Multiplicity(1) == 0) cath1 = 0;
 
-  TVector2 leftDown = cluster.Area(cath0).LeftDownCorner();
-  TVector2 rightUp = cluster.Area(cath0).RightUpCorner();
-  min[0] = leftDown.X();
-  min[1] = leftDown.Y();
-  max[0] = rightUp.X();
-  max[1] = rightUp.Y();
+  Double_t leftDownX, leftDownY;
+  cluster.Area(cath0).LeftDownCorner(leftDownX, leftDownY);
+  Double_t rightUpX, rightUpY; 
+  cluster.Area(cath0).RightUpCorner(rightUpX, rightUpY);
+  min[0] = leftDownX;
+  min[1] = leftDownY;
+  max[0] = rightUpX;
+  max[1] = rightUpY;
   if (cath1 != cath0) {
-    leftDown = cluster.Area(cath1).LeftDownCorner();
-    rightUp = cluster.Area(cath1).RightUpCorner();
-    min[0] = TMath::Max (min[0], leftDown.X());
-    min[1] = TMath::Max (min[1], leftDown.Y());
-    max[0] = TMath::Min (max[0], rightUp.X());
-    max[1] = TMath::Min (max[1], rightUp.Y());
+    cluster.Area(cath1).LeftDownCorner(leftDownX, leftDownY);
+    cluster.Area(cath1).RightUpCorner(rightUpX, rightUpY);
+    min[0] = TMath::Max (min[0], leftDownX);
+    min[1] = TMath::Max (min[1], leftDownY);
+    max[0] = TMath::Min (max[0], rightUpX);
+    max[1] = TMath::Min (max[1], rightUpY);
   }
 
   // Adjust limits
@@ -710,12 +715,12 @@ void AliMUONClusterFinderPeakFit::BuildPixArrayOneCathode(AliMUONCluster& cluste
   for (Int_t i = 1; i <= nbins[0]; ++i) {
     Double_t x = xaxis->GetBinCenter(i);
     for (Int_t j = 1; j <= nbins[1]; ++j) {
-      if (hist2->GetCellContent(i,j) < 0.1) continue;
+      if (hist2->GetCellContent(i,j) < 0.01525) continue; // JC: adc -> fc
       if (cath0 != cath1) {
        // Two-sided cluster
        Double_t cont = hist2->GetCellContent(i,j);
        if (cont < 999.) continue;
-       if (cont-Int_t(cont/1000.)*1000. < 0.5) continue;
+       if (cont-Int_t(cont/1000.)*1000. < 0.07625) continue; // JC: adc -> fc
       }
       //if (hist2->GetCellContent(i,j) < 1.1 && cluster.Multiplicity(0) && 
       //  cluster.Multiplicity(1)) continue;
@@ -761,9 +766,9 @@ void AliMUONClusterFinderPeakFit::PadOverHist(Int_t idir, Int_t ix0, Int_t iy0,
     else {
       // Fill histogram
       Double_t cont = pad->Charge();
-      if (hist2->GetCellContent(ix0, ixy) > 0.1) 
+      if (hist2->GetCellContent(ix0, ixy) > 0.01525) // JC: adc -> fc
        cont = TMath::Min (hist1->GetCellContent(ix0, ixy), cont) 
-            + TMath::Min (TMath::Max(hist1->GetCellContent(ix0, ixy),cont)*0.1, 10.);
+            + TMath::Min (TMath::Max(hist1->GetCellContent(ix0, ixy),cont)*0.1, 1.525); // JC: adc -> fc
       hist1->SetCellContent(ix0, ixy, cont);
       hist2->SetCellContent(ix0, ixy, hist2->GetCellContent(ix0, ixy)+amask);
     }
@@ -778,9 +783,9 @@ void AliMUONClusterFinderPeakFit::PadOverHist(Int_t idir, Int_t ix0, Int_t iy0,
     else {
       // Fill histogram
       Double_t cont = pad->Charge();
-      if (hist2->GetCellContent(ix0, ixy) > 0.1) 
+      if (hist2->GetCellContent(ix0, ixy) > 0.01525) // JC: adc -> fc 
        cont = TMath::Min (hist1->GetCellContent(ix0, ixy), cont)
-            + TMath::Min (TMath::Max(hist1->GetCellContent(ix0, ixy),cont)*0.1,10.);
+            + TMath::Min (TMath::Max(hist1->GetCellContent(ix0, ixy),cont)*0.1,1.525); // JC: adc -> fc
       hist1->SetCellContent(ix0, ixy, cont);
       hist2->SetCellContent(ix0, ixy, hist2->GetCellContent(ix0, ixy)+amask);
     }
@@ -804,6 +809,9 @@ Int_t AliMUONClusterFinderPeakFit::FindLocalMaxima(TObjArray *pixArray, Int_t *l
   Double_t xylim[4] = {999, 999, 999, 999};
 
   Int_t nPix = pixArray->GetEntriesFast();
+  
+  if ( nPix <= 0 ) return 0;
+
   AliMUONPad *pixPtr = 0;
   for (Int_t ipix = 0; ipix < nPix; ++ipix) {
     pixPtr = (AliMUONPad*) pixArray->UncheckedAt(ipix);
@@ -829,7 +837,7 @@ Int_t AliMUONClusterFinderPeakFit::FindLocalMaxima(TObjArray *pixArray, Int_t *l
   for (Int_t i = 1; i <= ny; ++i) {
     indx = (i-1) * nx;
     for (Int_t j = 1; j <= nx; ++j) {
-      if (fHistAnode->GetCellContent(j,i) < 0.5) continue;
+      if (fHistAnode->GetCellContent(j,i) < 0.07625) continue;  // JC: adc -> fc
       //if (isLocalMax[indx+j-1] < 0) continue;
       if (isLocalMax[indx+j-1] != 0) continue;
       FlagLocalMax(fHistAnode, i, j, isLocalMax);
@@ -842,9 +850,13 @@ Int_t AliMUONClusterFinderPeakFit::FindLocalMaxima(TObjArray *pixArray, Int_t *l
       if (isLocalMax[indx+j-1] > 0) { 
        localMax[nMax] = indx + j - 1; 
        maxVal[nMax++] = fHistAnode->GetCellContent(j,i);
-       if (nMax > 99) AliFatal(" Too many local maxima !!!");
+       if (nMax > 99) break;
       }
     }
+    if (nMax > 99) {
+      AliError(" Too many local maxima !!!");
+      break;
+    }
   }
   if (fDebug) cout << " Local max: " << nMax << endl;
   delete [] isLocalMax; 
@@ -886,8 +898,8 @@ void AliMUONClusterFinderPeakFit::FlagLocalMax(TH2D *hist, Int_t i, Int_t j, Int
 }
 
 //_____________________________________________________________________________
-void AliMUONClusterFinderPeakFit::FindClusterFit(AliMUONCluster& cluster, Int_t *localMax, 
-                                                Int_t *maxPos, Int_t nMax)
+void AliMUONClusterFinderPeakFit::FindClusterFit(AliMUONCluster& cluster, const Int_t *localMax, 
+                                                 const Int_t *maxPos, Int_t nMax)
 {
 /// Fit pad charge distribution with nMax hit hypothesis
 
@@ -957,7 +969,7 @@ void AliMUONClusterFinderPeakFit::FindClusterFit(AliMUONCluster& cluster, Int_t
     err[indx] = fitter->GetParError(indx);
     err[indx+1] = fitter->GetParError(indx+1);
       
-    if ( coef*qTot >= 14 )
+    if ( coef*qTot >= 2.135 ) // JC: adc -> fc
     {
       AliMUONCluster* cluster1 = new AliMUONCluster(cluster);
       
@@ -980,7 +992,7 @@ void AliMUONClusterFinderPeakFit::FindClusterFit(AliMUONCluster& cluster, Int_t
 
 //_____________________________________________________________________________
 void AliMUONClusterFinderPeakFit::FindClusterCOG(AliMUONCluster& cluster, 
-                                                Int_t *localMax, Int_t iMax)
+                                                 const Int_t *localMax, Int_t iMax)
 {
 /// Find COG of pad charge distribution around local maximum \a iMax 
 
@@ -1021,8 +1033,8 @@ void AliMUONClusterFinderPeakFit::FindClusterCOG(AliMUONCluster& cluster,
   Double_t yc = fHistAnode->GetYaxis()->GetBinCenter(ic);
   Double_t xc = fHistAnode->GetXaxis()->GetBinCenter(jc);
   Double_t cont = fHistAnode->GetCellContent(jc,ic);
-  AliMUONPad* pixPtr = new AliMUONPad (xc, yc, wx, wy, cont);
-  if (fDebug) pixPtr->Print("full"); 
+  AliMUONPad pixel(xc, yc, wx, wy, cont);
+  if (fDebug) pixel.Print("full"); 
 
   Int_t npad = cluster.Multiplicity();
   
@@ -1032,7 +1044,7 @@ void AliMUONClusterFinderPeakFit::FindClusterCOG(AliMUONCluster& cluster,
   for (Int_t j = 0; j < npad; ++j) 
   {
     AliMUONPad* pad = cluster.Pad(j);
-    if ( Overlap(*pad,*pixPtr) )
+    if ( Overlap(*pad,pixel) )
     {
       if (fDebug) { cout << j << " "; pad->Print("full"); }
       if (pad->Charge() > qMax[pad->Cathode()]) {
@@ -1093,7 +1105,7 @@ void AliMUONClusterFinderPeakFit::FindClusterCOG(AliMUONCluster& cluster,
   }
 
   //qAver = TMath::Sqrt(qAver);
-  if ( qAver >= 14 )
+  if ( qAver >= 2.135 ) // JC: adc -> fc
   {
     
     AliMUONCluster* cluster1 = new AliMUONCluster(cluster);
@@ -1145,10 +1157,10 @@ void AliMUONClusterFinderPeakFit::PadsInXandY(AliMUONCluster& cluster,
        
   Bool_t mustMatch(kTRUE);
 
-  AliMpIntPair cn = cluster.NofPads(statusToTest,mustMatch);
+  Long_t cn = cluster.NofPads(statusToTest,mustMatch);
   
-  nInX = cn.GetFirst();
-  nInY = cn.GetSecond();
+  nInX = AliMp::PairFirst(cn);
+  nInY = AliMp::PairSecond(cn);
 }
 
 //_____________________________________________________________________________