]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - MUON/AliMUONPadStatusMapMaker.cxx
Added new files to build system
[u/mrichter/AliRoot.git] / MUON / AliMUONPadStatusMapMaker.cxx
index 48a8f1d4181244d74679b225fe25208f10fbd132..3159b978a656d296314e180e7b470ade7684329b 100644 (file)
@@ -14,6 +14,8 @@
 **************************************************************************/
 
 // $Id$
+
+//-----------------------------------------------------------------------------
 /// \class AliMUONPadStatusMapMaker
 /// 
 /// Convert a pad status container into a pad status *map* container
 /// If a pad is at a physical boundary, is will for sure have some bits at 1
 /// (i.e. a non-existing neighbour is considered = bad).
 ///
-// author Laurent Aphecetche
+/// \author Laurent Aphecetche
+//-----------------------------------------------------------------------------
 
 #include "AliMUONPadStatusMapMaker.h"
 
 #include "AliLog.h"
 #include "AliMUON2DMap.h"
-#include "AliMUONCalibParam1I.h"
-#include "AliMUONObjectPair.h"
-#include "AliMUONV2DStore.h"
+#include "AliMUONCalibParamNI.h"
+#include "AliMUONCalibrationData.h"
+#include "AliMUONVStore.h"
 #include "AliMUONVCalibParam.h"
-#include "AliMUONVDataIterator.h"
-#include "AliMpArea.h"
 #include "AliMpConstants.h"
-#include "AliMpDEManager.h"
+#include "AliMpIntPair.h"
 #include "AliMpManuList.h"
-#include "AliMpPad.h"
-#include "AliMpSegmentation.h"
-#include "AliMpStationType.h"
-#include "AliMpVPadIterator.h"
-#include "AliMpVSegmentation.h"
 #include <Riostream.h>
-#include <TMath.h>
-#include <TObjArray.h>
-#include <TStopwatch.h>
 #include <TList.h>
-#include <map>
-#include <utility>
+#include <TStopwatch.h>
 
+/// \cond CLASSIMP
 ClassImp(AliMUONPadStatusMapMaker)
+/// \endcond
 
 Int_t AliMUONPadStatusMapMaker::fgkSelfDead = 1;
 
-namespace
-{
-  Bool_t IsZero(Double_t x)
-  {
-    return TMath::Abs(x) < AliMpConstants::LengthTolerance();
-  }
-}
-
 //_____________________________________________________________________________
-AliMUONPadStatusMapMaker::AliMUONPadStatusMapMaker() 
+AliMUONPadStatusMapMaker::AliMUONPadStatusMapMaker(const AliMUONCalibrationData& calibData
 : TObject(),
 fStatus(0x0),
 fMask(0),
-fSegmentation(0x0),
-fTimerComputeStatusMap(0x0)
+fCalibrationData(calibData)
 {
   /// ctor
 }
@@ -100,155 +85,132 @@ fTimerComputeStatusMap(0x0)
 AliMUONPadStatusMapMaker::~AliMUONPadStatusMapMaker()
 {
   /// dtor
-  delete fTimerComputeStatusMap;
 }
 
 //_____________________________________________________________________________
 Int_t
-AliMUONPadStatusMapMaker::ComputeStatusMap(const TObjArray& neighbours,
-                                           Int_t detElemId) const
+AliMUONPadStatusMapMaker::ComputeStatusMap(const AliMUONVCalibParam& neighbours,
+                                          Int_t manuChannel,
+                                          Int_t detElemId) const
 {
   /// Given a list of neighbours of one pad (which includes the pad itself)
   /// compute the status map (aka deadmap) for that pad.
   
-  fTimerComputeStatusMap->Start(kFALSE);
-  
   Int_t statusMap(0);
-  
- //Compute the statusmap related to the status of neighbouring
- //pads. An invalid pad means "outside of edges".
-  Int_t i(0);
-  TIter next(&neighbours);
-  AliMpPad* p;
-  
-  while ( ( p = static_cast<AliMpPad*>(next()) ) )
+
+  //Compute the statusmap related to the status of neighbouring
+  //pads. An invalid pad means "outside of edges".
+
+  Int_t n = neighbours.Dimension();
+  for ( Int_t i = 0; i < n; ++i )
   {
+    Int_t x = neighbours.ValueAsInt(manuChannel,i);
+    Int_t m,c;
+    neighbours.UnpackValue(x,m,c);
+    if ( c < 0 ) continue;
     Int_t status = 0;
-    if ( !p->IsValid() )
+    if ( !m )
     {
       status = -1;
     }
     else
     {
-      status = GetPadStatus(detElemId,*p);
+      status = GetPadStatus(detElemId,m,c);
     }
     if ( ( fMask==0 && status !=0 ) || ( (status & fMask) != 0 ) )
     {
       statusMap |= (1<<i);
     }
-    ++i;
   }
-  
-  fTimerComputeStatusMap->Stop();
   return statusMap;
 }
 
 //_____________________________________________________________________________
 Int_t
-AliMUONPadStatusMapMaker::GetPadStatus(Int_t detElemId,
-                                      const AliMpPad& pad) const
+AliMUONPadStatusMapMaker::GetPadStatus(Int_t detElemId, 
+                                       Int_t manuId, Int_t manuChannel) const
+                                      
 {
   /// Get the pad status
-  Int_t manuId = pad.GetLocation().GetFirst();
-  Int_t manuChannel = pad.GetLocation().GetSecond();
-  AliMUONVCalibParam* param = static_cast<AliMUONVCalibParam*>(fStatus->Get(detElemId,manuId));
+  AliMUONVCalibParam* param = static_cast<AliMUONVCalibParam*>(fStatus->FindObject(detElemId,manuId));
   return param->ValueAsInt(manuChannel);
 }
 
 //_____________________________________________________________________________
-Bool_t
-AliMUONPadStatusMapMaker::IsValid(const AliMpPad& pad, 
-                                  const TVector2& shift) const
-{
-  /// Whether pad.Position()+shift is within the detector
-  TVector2 testPos = pad.Position() - pad.Dimensions() + shift;
-  AliMpPad p = fSegmentation->PadByPosition(testPos,kFALSE);
-  return p.IsValid();
-}
-
-//_____________________________________________________________________________
-AliMUONV2DStore*
+AliMUONVStore*
 AliMUONPadStatusMapMaker::MakeEmptyPadStatusMap()
 {
-  AliMUONV2DStore* padStatusMap = new AliMUON2DMap(kTRUE);
-  
-  TList* list = AliMpManuList::ManuList();
-  
-  AliMpIntPair* pair;
-  
-  TIter next(list);
-  
-  while ( ( pair = static_cast<AliMpIntPair*>(next()) ) ) 
-  {
-    Int_t detElemId = pair->GetFirst();
-    Int_t manuId = pair->GetSecond();
-    padStatusMap->Set(detElemId,manuId,new AliMUONCalibParam1I(64,0),kFALSE);
-  }
-  
-  delete list;
-  
-  return padStatusMap;
+  /// Make an empty (but complete) statusMap
+    
+    AliMUONVStore* store = new AliMUON2DMap(true);
+    
+    TList* list = AliMpManuList::ManuList();
+    
+    AliMpIntPair* pair;
+    
+    TIter next(list);
+    
+    while ( ( pair = static_cast<AliMpIntPair*>(next()) ) ) 
+    {
+      Int_t detElemId = pair->GetFirst();
+      Int_t manuId = pair->GetSecond();
+      AliMUONVCalibParam* param = new AliMUONCalibParamNI(1,AliMpConstants::ManuNofChannels(),
+                                                          detElemId,manuId,
+                                                          0);
+      store->Add(param);
+    }
+    
+    delete list;
+    
+    return store;
 }
 
 //_____________________________________________________________________________
-AliMUONV2DStore*
-AliMUONPadStatusMapMaker::MakePadStatusMap(const AliMUONV2DStore& status,
+AliMUONVStore*
+AliMUONPadStatusMapMaker::MakePadStatusMap(const AliMUONVStore& status,
                                            Int_t mask)
 {
   /// Given the status store for all pads, compute a status map store
   /// for all pads. 
-  /// @param mask is the status mask to be tested to tell if a pad is ok or not
+  /// \param status
+  /// \param mask is the status mask to be tested to tell if a pad is ok or not
   
   fStatus = &status;
   fMask = mask;
   
-  AliMpExMap chamberTimers(kTRUE);
-  fTimerComputeStatusMap = new TStopwatch;
-  fTimerComputeStatusMap->Start(kTRUE);
-  fTimerComputeStatusMap->Stop();
-  
-  TStopwatch timer;
-  
+  TStopwatch timer;  
   timer.Start(kTRUE);
   
-  AliMUONV2DStore* statusMap = status.CloneEmpty();
+  AliMUONVStore* neighbourStore = fCalibrationData.Neighbours();
   
-  AliMUONVDataIterator* it = status.Iterator();
-  AliMUONObjectPair* pair;
+  AliMUONVStore* statusMap = status.Create();
   
-  while ( ( pair = static_cast<AliMUONObjectPair*>(it->Next()) ) )
+  TIter next(status.CreateIterator());
+  AliMUONVCalibParam* statusEntry;
+  
+  while ( ( statusEntry = static_cast<AliMUONVCalibParam*>(next()) ) )
   {
-    AliMpIntPair* ip = static_cast<AliMpIntPair*>(pair->First());
+    Int_t detElemId = statusEntry->ID0();
+    Int_t manuId = statusEntry->ID1();
+        
+    AliMUONVCalibParam* statusMapEntry = static_cast<AliMUONVCalibParam*>
+      (statusMap->FindObject(detElemId,manuId));
 
-    Int_t detElemId = ip->GetFirst();
-    
-    Int_t manuId = ip->GetSecond();
-    Int_t chamber = AliMpDEManager::GetChamberId(detElemId);
-    
-    TStopwatch* chTimer = static_cast<TStopwatch*>(chamberTimers.GetValue(chamber));
-    if (!chTimer)
+    if (!statusMapEntry)
     {
-      chTimer = new TStopwatch;
-      chTimer->Start(kTRUE);
-      chTimer->Stop();
-      chamberTimers.Add(chamber,chTimer);
+      statusMapEntry = new AliMUONCalibParamNI(1,AliMpConstants::ManuNofChannels(),
+                                               detElemId,manuId,0);
+      statusMap->Add(statusMapEntry);
     }
     
-    chTimer->Start(kFALSE);
-    
-    const AliMpVSegmentation* seg = 
-      AliMpSegmentation::Instance()->GetMpSegmentationByElectronics(detElemId,manuId);
-    fSegmentation = seg;
-    
-    AliMUONVCalibParam* statusEntry = static_cast<AliMUONVCalibParam*>(pair->Second());
+    AliMUONVCalibParam* neighbours = static_cast<AliMUONVCalibParam*>
+      (neighbourStore->FindObject(detElemId,manuId));
     
-    AliMUONVCalibParam* statusMapEntry = static_cast<AliMUONVCalibParam*>
-      (statusMap->Get(detElemId,manuId));
-
-    if (!statusMapEntry)
+    if (!neighbours)
     {
-      statusMapEntry = new AliMUONCalibParam1I(64,0);
-      statusMap->Set(detElemId,manuId,statusMapEntry,false);
+      AliFatal(Form("Could not find neighbours for DE %d manuId %d",
+                    detElemId,manuId));
+      continue;
     }
     
     for ( Int_t manuChannel = 0; manuChannel < statusEntry->Size(); ++manuChannel ) 
@@ -256,47 +218,31 @@ AliMUONPadStatusMapMaker::MakePadStatusMap(const AliMUONV2DStore& status,
       // Loop over channels and for each channel loop on its immediate neighbours
       // to produce a statusMap word for this channel.
       
-      AliMpPad pad = seg->PadByLocation(AliMpIntPair(manuId,manuChannel),kFALSE);
-      
       Int_t statusMapValue(0);
+
+      Int_t x = neighbours->ValueAsInt(manuChannel,0);
       
-      if ( pad.IsValid() )
-      {
-        TObjArray neighbours;
-        neighbours.SetOwner(kTRUE);
-        fSegmentation->GetNeighbours(pad,neighbours,true,true);
-        statusMapValue = ComputeStatusMap(neighbours,detElemId);      
+      if ( x > 0 )
+      { 
+        // channel is a valid one (i.e. (manuId,manuChannel) is an existing pad)
+        statusMapValue = ComputeStatusMap(*neighbours,manuChannel,detElemId);
       }
       else
       {
         statusMapValue = fgkSelfDead;
       }
+      
       statusMapEntry->SetValueAsInt(manuChannel,0,statusMapValue);
     }
-    chTimer->Stop();
   }
+  timer.Stop();
   
-  delete it;
-  
-  TExMapIter cit = chamberTimers.GetIterator();
-  
-  Long_t key, value;
-  
-  while ( cit.Next(key,value) ) 
-  {
-    TStopwatch* t = reinterpret_cast<TStopwatch*>(value);
-    cout << Form("Chamber %2ld CPU time/manu %5.0f ms ",key,t->CpuTime()*1e3/t->Counter());
-    t->Print();
-  }
+  StdoutToAliInfo(
+                  cout << "MakePadStatusMap total timer : ";
+                  timer.Print();
+                  cout << endl;
+                  );
 
-  cout << "ComputeStatusMap timer : ";
-  fTimerComputeStatusMap->Print();
-  cout<< endl;
-  
-  cout << "MakePadStatusMap total timer : ";
-  timer.Print();
-  cout << endl;
-  
   return statusMap;
 }