fix finding of pad neighbours; remove methods to write them in OCDB
[u/mrichter/AliRoot.git] / MUON / AliMUONSimpleClusterServer.cxx
index 238c88a..b6bfe99 100644 (file)
 #include "AliMpDEIterator.h"
 #include "AliMpDEManager.h"
 #include "AliMpExMap.h"
+#include "AliMpExMapIterator.h"
 #include "AliMpPad.h"
 #include "AliMpSegmentation.h"
 #include "AliMpVSegmentation.h"
 #include <Riostream.h>
-#include <TClonesArray.h>
+#include <TObjArray.h>
 #include <TString.h>
 #include <float.h>
 
@@ -48,6 +49,8 @@
 /// 
 /// \author Laurent Aphecetche, Subatech
 
+using std::endl;
+using std::cout;
 /// \cond CLASSIMP  
 ClassImp(AliMUONSimpleClusterServer)
 /// \endcond
@@ -81,6 +84,8 @@ AliMUONSimpleClusterServer::AliMUONSimpleClusterServer(AliMUONVClusterFinder* cl
     fPads[0] = new AliMpExMap;
     fPads[1] = new AliMpExMap;
     
+    fPadsIterator[0] = fPads[0]->CreateIterator();
+    fPadsIterator[1] = fPads[1]->CreateIterator();
 }
 
 //_____________________________________________________________________________
@@ -90,6 +95,8 @@ AliMUONSimpleClusterServer::~AliMUONSimpleClusterServer()
   delete fClusterFinder;
   delete fPads[0];
   delete fPads[1];
+  delete fPadsIterator[0];
+  delete fPadsIterator[1];
   delete fBypass;
 }
 
@@ -132,10 +139,10 @@ AliMUONSimpleClusterServer::Clusterize(Int_t chamberId,
   {
     Int_t detElemId = it.CurrentDEId();
     
-    TClonesArray* pads[2] = 
+    TObjArray* pads[2] = 
     { 
-      static_cast<TClonesArray*>(fPads[0]->GetValue(detElemId)),
-      static_cast<TClonesArray*>(fPads[1]->GetValue(detElemId)) 
+      static_cast<TObjArray*>(fPads[0]->GetValue(detElemId)),
+      static_cast<TObjArray*>(fPads[1]->GetValue(detElemId)) 
     };
     
     if ( ( pads[0] && pads[0]->GetLast()>=0 ) || 
@@ -155,6 +162,10 @@ AliMUONSimpleClusterServer::Clusterize(Int_t chamberId,
         { AliMpSegmentation::Instance()->GetMpSegmentation(detElemId,AliMp::kCath0),
           AliMpSegmentation::Instance()->GetMpSegmentation(detElemId,AliMp::kCath1)
         };
+        
+        fClusterFinder->SetChargeHints(recoParam->LowestPadCharge(),
+                                       recoParam->LowestClusterCharge());
+        
         if ( fClusterFinder->NeedSegmentation() )
         {
           fClusterFinder->Prepare(detElemId,pads,deArea,seg);
@@ -235,7 +246,12 @@ AliMUONSimpleClusterServer::Global2Local(Int_t detElemId, const AliMpArea& globa
   
   Double_t xl,yl,zl;
   
-  Double_t zg = AliMUONConstants::DefaultChamberZ(AliMpDEManager::GetChamberId(detElemId));
+  Int_t chamberId = AliMpDEManager::GetChamberId(detElemId);
+  if ( chamberId < 0 ) {
+    AliErrorStream() << "Cannot get chamberId from detElemId=" << detElemId << endl;
+    return;
+  }  
+  Double_t zg = AliMUONConstants::DefaultChamberZ(chamberId);
   
   fkTransformer.Global2Local(detElemId,
                              globalArea.GetPositionX(),globalArea.GetPositionY(),zg,
@@ -285,12 +301,12 @@ AliMUONSimpleClusterServer::Overlap(Int_t detElemId,
 }
 
 //_____________________________________________________________________________
-TClonesArray* 
+TObjArray* 
 AliMUONSimpleClusterServer::PadArray(Int_t detElemId, Int_t cathode) const
 {
   /// Return array for given cathode of given DE
   
-  return static_cast<TClonesArray*>(fPads[cathode]->GetValue(detElemId));
+  return static_cast<TObjArray*>(fPads[cathode]->GetValue(detElemId));
 }
 
 //_____________________________________________________________________________
@@ -312,13 +328,21 @@ AliMUONSimpleClusterServer::UseDigits(TIter& next, AliMUONVDigitStore* digitStor
   
   fDigitStore = digitStore;
   
-  fPads[0]->Clear();
-  fPads[1]->Clear();
-  
+  // Clear pads arrays in the maps
+  for ( Int_t i=0; i<2; i++ ) {
+    fPadsIterator[i]->Reset();
+    Int_t key; TObject* obj;
+    while ( ( obj = fPadsIterator[i]->Next(key) ) ) {
+      //cout << "clearing array for detElemId " << key <<  "  ";
+      obj->Clear();
+    }  
+  }   
+
   AliMUONVDigit* d;
   while ( ( d = static_cast<AliMUONVDigit*>(next()) ) )
   {
     if ( ! d->Charge() > 0 ) continue; // skip void digits.
+    if ( ! d->IsTracker() ) continue; // skip trigger digits
     Int_t ix = d->PadX();
     Int_t iy = d->PadY();
     Int_t cathode = d->Cathode();
@@ -327,20 +351,21 @@ AliMUONSimpleClusterServer::UseDigits(TIter& next, AliMUONVDigitStore* digitStor
       GetMpSegmentation(detElemId,AliMp::GetCathodType(cathode));
     AliMpPad pad = seg->PadByIndices(ix,iy);
     
-    TClonesArray* padArray = PadArray(detElemId,cathode);
+    TObjArray* padArray = PadArray(detElemId,cathode);
     if (!padArray)
     {
-      padArray = new TClonesArray("AliMUONPad",100);
+      padArray = new TObjArray(100);
+      padArray->SetOwner(kTRUE);
       fPads[cathode]->Add(detElemId,padArray);
     }
     
-    AliMUONPad mpad(detElemId,cathode,
+    AliMUONPad* mpad = new AliMUONPad(detElemId,cathode,
                     ix,iy,pad.GetPositionX(),pad.GetPositionY(),
                     pad.GetDimensionX(),pad.GetDimensionY(),
                     d->Charge());
-    if ( d->IsSaturated() ) mpad.SetSaturated(kTRUE);
-    mpad.SetUniqueID(d->GetUniqueID());
-    new ((*padArray)[padArray->GetLast()+1]) AliMUONPad(mpad);      
+    if ( d->IsSaturated() ) mpad->SetSaturated(kTRUE);
+    mpad->SetUniqueID(d->GetUniqueID());
+    padArray->Add(mpad);      
   }
 }
 
@@ -439,7 +464,7 @@ AliMUONSimpleClusterServer::Print(Option_t*) const
       {
         cout << Form("  -- Cathode %1d",cathode) << endl;
         
-        TClonesArray* padArray = PadArray(detElemId,cathode);
+        TObjArray* padArray = PadArray(detElemId,cathode);
         
         if (!padArray)
         {