]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - MUON/AliMUONSimpleClusterServer.cxx
fix finding of pad neighbours; remove methods to write them in OCDB
[u/mrichter/AliRoot.git] / MUON / AliMUONSimpleClusterServer.cxx
index 1d97cb7631c49f015cbcd3be728f228a97b6a2de..b6bfe99e28901698edfb0fe7d6284c4e85e24930 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
@@ -57,10 +60,10 @@ namespace
   TString AsString(const AliMpArea& area)
   {
     return Form("(X,Y)=(%7.3f,%7.3f) (DX,DY)=(%7.3f,%7.3f)",
-                area.Position().X(),
-                area.Position().Y(),
-                area.Dimensions().Y(),
-                area.Dimensions().Y());
+                area.GetPositionX(),
+                area.GetPositionY(),
+                area.GetDimensionX(),  /// TBCL was Y !!!
+                area.GetDimensionY());
   }
 }
 
@@ -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;
 }
 
@@ -106,7 +113,7 @@ AliMUONSimpleClusterServer::Clusterize(Int_t chamberId,
   /// We first find out the list of DE that have a non-zero overlap with area,
   /// and then use the clusterfinder to find clusters in those areas (and DE).
   
-  AliCodeTimerAuto(Form("Chamber %d",chamberId));
+  AliCodeTimerAuto(Form("Chamber %d",chamberId),0);
   
   if ( fTriggerTrackStore && chamberId >= 6 ) 
   {
@@ -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,13 +246,18 @@ 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.Position().X(),globalArea.Position().Y(),zg,
+                             globalArea.GetPositionX(),globalArea.GetPositionY(),zg,
                              xl,yl,zl);
   
-  localArea = AliMpArea(TVector2(xl,yl), globalArea.Dimensions());
+  localArea = AliMpArea(xl,yl, globalArea.GetDimensionX(), globalArea.GetDimensionY());
 }
 
 //_____________________________________________________________________________
@@ -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,
-                    ix,iy,pad.Position().X(),pad.Position().Y(),
-                    pad.Dimensions().X(),pad.Dimensions().Y(),
+    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);      
   }
 }
 
@@ -355,7 +380,8 @@ AliMUONSimpleClusterServer::FindMCLabel(const AliMUONCluster& cluster, Int_t det
   Int_t nTracks[2] = {0, 0};
   AliMUONVDigit* digit[2] = {0x0, 0x0};
   for (Int_t iCath = 0; iCath < 2; iCath++) {
-    AliMpPad pad = seg[AliMp::GetCathodType(iCath)]->PadByPosition(cluster.Position(), kFALSE);
+    AliMpPad pad 
+      = seg[AliMp::GetCathodType(iCath)]->PadByPosition(cluster.Position().X(), cluster.Position().Y(),kFALSE);
     if (pad.IsValid()) {
       digit[iCath] = fDigitStore->FindObject(detElemId, pad.GetManuId(), pad.GetManuChannel(), iCath);
       if (digit[iCath]) nTracks[iCath] = digit[iCath]->Ntracks();
@@ -438,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)
         {