]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
Added AliMpVSegmentation* CreateMpSegmentationByElectronics(Int_t detElemId, Int_t...
authorivana <ivana@f7af4fe6-9843-0410-8265-dc069ae4e863>
Thu, 2 Mar 2006 17:00:28 +0000 (17:00 +0000)
committerivana <ivana@f7af4fe6-9843-0410-8265-dc069ae4e863>
Thu, 2 Mar 2006 17:00:28 +0000 (17:00 +0000)
method to fetch segmentation using manuIds.
(Laurent)

MUON/mapping/AliMpSegFactory.cxx
MUON/mapping/AliMpSegFactory.h

index 7aea8f0629044bbdeb5868ce32c727aa496cab1d..0e305a515f70b4b4b8060efb64d074b23d6ab74a 100644 (file)
 /* $Id$ */
 
 #include "AliMpSegFactory.h"
+
+#include "AliLog.h"
 #include "AliMpDEManager.h"
+#include "AliMpExMap.h"
 #include "AliMpSector.h"
 #include "AliMpSectorReader.h"
 #include "AliMpSectorSegmentation.h"
 #include "AliMpSlat.h"
-#include "AliMpSt345Reader.h"
 #include "AliMpSlatSegmentation.h"
+#include "AliMpSt345Reader.h"
 #include "AliMpTrigger.h"
 #include "AliMpTriggerReader.h"
 #include "AliMpTriggerSegmentation.h"
-
-#include "AliLog.h"
-
 #include <Riostream.h>
-#include <TSystem.h>
-#include <TObjString.h>
 #include <TMap.h>
+#include <TObjString.h>
+#include <TSystem.h>
 
 ClassImp(AliMpSegFactory)
 
 //______________________________________________________________________________
 AliMpSegFactory::AliMpSegFactory()
-    : TObject(),
-      fMpSegmentations()
+: TObject(),
+  fMpSegmentations(),
+  fMpMap(new AliMpExMap(true))
 {  
-/// Standard constructor
+    /// Standard constructor
+    AliDebug(1,"");
+    fMpMap->SetOwner(true);
 }
 
 //______________________________________________________________________________
@@ -64,6 +67,7 @@ AliMpSegFactory::~AliMpSegFactory()
 /// Destructor
 
   // The segmentations is supposed to be deleted in the client code
+  AliDebug(1,"");
 }
 
 //______________________________________________________________________________
@@ -98,6 +102,9 @@ AliMpSegFactory::CreateMpSegmentation(Int_t detElemId, Int_t cath)
   TObject* object = fMpSegmentations.Get(deName);
   if ( object ) return (AliMpVSegmentation*)object;
 
+  AliDebug(1,Form("Creating segmentation for detElemId=%d cath=%d",
+                  detElemId,cath));
+  
   // Read mapping data and create segmentation
   //
   AliMpStationType stationType = AliMpDEManager::GetStationType(detElemId);
@@ -125,12 +132,65 @@ AliMpSegFactory::CreateMpSegmentation(Int_t detElemId, Int_t cath)
   fMpSegmentations.Add(deName, mpSegmentation); 
   return mpSegmentation;
 } 
+
+//_____________________________________________________________________________
+AliMpVSegmentation* 
+AliMpSegFactory::CreateMpSegmentationByElectronics(Int_t detElemId,
+                                                   Int_t FEMId)
+{
+  AliMpExMap* m = static_cast<AliMpExMap*>(fMpMap->GetValue(detElemId));
+  
+  if (!m)
+  {
+    m = FillMpMap(detElemId);
+  }
+  
+  return static_cast<AliMpVSegmentation*>(m->GetValue(FEMId));
+}
     
 //______________________________________________________________________________
 void AliMpSegFactory::DeleteSegmentations()
 {
 /// Delete all segmentations created with this manager
-
+  AliDebug(1,"deleting mpSegmentations");
   fMpSegmentations.Clear();
+  AliDebug(1,"deleting mpMap");
+  delete fMpMap;
+  fMpMap = 0; 
+  AliDebug(1,"done");
 }
 
+//_____________________________________________________________________________
+AliMpExMap*
+AliMpSegFactory::FillMpMap(Int_t detElemId)
+{
+  AliDebug(1,Form("detElemId=%d",detElemId));
+  
+  AliMpExMap* mde = new AliMpExMap(true);
+  mde->SetOwner(kFALSE);
+  fMpMap->Add(detElemId,mde);
+  
+  AliMpVSegmentation* seg[2];
+  TArrayI ecn[2];
+  
+  // Do it in 2 steps to be able to set the AliMpExMap size once for all,
+  // to avoid annoying warning message in case of dynamical resizing.
+  // (not critical).
+  for ( Int_t cathode = 0; cathode < 2; ++cathode )
+  {
+    seg[cathode] = CreateMpSegmentation(detElemId,cathode);
+    seg[cathode]->GetAllElectronicCardIDs(ecn[cathode]);
+  }
+  
+  mde->SetSize(ecn[0].GetSize()+ecn[1].GetSize());
+  
+  for ( Int_t cathode = 0; cathode < 2; ++ cathode )
+  {
+    for ( Int_t i = 0; i < ecn[cathode].GetSize(); ++i )
+    {
+      mde->Add(ecn[cathode][i],const_cast<AliMpVSegmentation*>(seg[cathode]));
+    }
+  }
+  
+  return mde;
+}
index 116cb6631bb43f18fed1981576050fffb76afb6a..7b32e3fc61836f2b3046daaa19a7ec1e7c5f543c 100644 (file)
@@ -1,3 +1,6 @@
+#ifndef ALI_MP_SEG_FACTORY_H
+#define ALI_MP_SEG_FACTORY_H
+
 /* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
  * See cxx source for full Copyright notice                               */
 
 ///
 /// Authors: Ivana Hrivnacova, IPN Orsay
 
-#ifndef ALI_MP_SEG_FACTORY_H
-#define ALI_MP_SEG_FACTORY_H
-
-#include "AliMpStringObjMap.h"
+#ifndef ROOT_TObject
+#  include "TObject.h"
+#endif
 
-#include <TObject.h>
+#ifndef ALI_MP_STRING_OBJ_MAP_H
+#  include "AliMpStringObjMap.h"
+#endif
 
+class AliMpExMap;
 class AliMpVSegmentation;
 
 class AliMpSegFactory : public  TObject {
@@ -30,7 +35,12 @@ class AliMpSegFactory : public  TObject {
     virtual ~AliMpSegFactory();
     
     // methods
-    AliMpVSegmentation* CreateMpSegmentation(Int_t detElemId, Int_t cath);
+    AliMpVSegmentation* CreateMpSegmentation(
+                              Int_t detElemId, Int_t cath);
+
+    AliMpVSegmentation* CreateMpSegmentationByElectronics(
+                              Int_t detElemId, Int_t elCardID);
+
     void DeleteSegmentations();
 
   protected:
@@ -38,9 +48,13 @@ class AliMpSegFactory : public  TObject {
     AliMpSegFactory& operator=(const AliMpSegFactory& rhs);
 
   private:
-    // data members    
-    AliMpStringObjMap  fMpSegmentations;// Map of mapping segmentations to DE names
+    AliMpExMap* FillMpMap(Int_t detElemId);
+  
+  private:
 
+    AliMpStringObjMap  fMpSegmentations;// Map of mapping segmentations to DE names
+    AliMpExMap*        fMpMap;          // Map of el. cards IDs to segmentations
+      
   ClassDef(AliMpSegFactory,0)  // MUON Factory for Chambers and Segmentation
 };